diff --git a/.gitmodules b/.gitmodules index c278458f644f42badc0f3232d8929cd5c66cc6ec..161db96b277de95d29b47d9f93fedef056a672fa 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,10 +13,3 @@ [submodule "deps/TSZ"] path = deps/TSZ url = https://github.com/taosdata/TSZ.git -[submodule "tests"] - path = tests - url = https://github.com/taosdata/tests - branch = master -[submodule "examples/rust"] - path = examples/rust - url = https://github.com/songtianyi/tdengine-rust-bindings.git diff --git a/Jenkinsfile2 b/Jenkinsfile2 index 9e13b15d25dabcb2ba563de315f761fce8d52adc..d93ed9df5b70ce791c444005316bc279ef82666f 100644 --- a/Jenkinsfile2 +++ b/Jenkinsfile2 @@ -11,7 +11,11 @@ def sync_source() { sh ''' cd ${WKC} [ -f src/connector/grafanaplugin/README.md ] && rm -f src/connector/grafanaplugin/README.md > /dev/null || echo "failed to remove grafanaplugin README.md" - git reset --hard >/dev/null + git reset --hard + git fetch + cd ${WK} + git reset --hard + git fetch ''' script { if (env.CHANGE_TARGET == 'master') { @@ -37,64 +41,65 @@ def sync_source() { } } sh ''' + export TZ=Asia/Harbin cd ${WKC} - git reset --hard git remote prune origin [ -f src/connector/grafanaplugin/README.md ] && rm -f src/connector/grafanaplugin/README.md > /dev/null || echo "failed to remove grafanaplugin README.md" git pull >/dev/null - git fetch origin +refs/pull/${CHANGE_ID}/merge - git checkout -qf FETCH_HEAD - git reset --hard git clean -dfx - git submodule update --init --recursive --remote - git submodule update --init --recursive - cd ${WK} - git reset --hard - ''' - sh ''' - cd ${WKCT} - git reset --hard ''' script { if (env.CHANGE_TARGET == 'master') { sh ''' cd ${WK} git checkout master - cd ${WKCT} - git checkout master ''' } else if (env.CHANGE_TARGET == '2.0') { sh ''' cd ${WK} git checkout 2.0 - cd ${WKCT} - git checkout 2.0 ''' } else if (env.CHANGE_TARGET == '2.4') { sh ''' cd ${WK} git checkout 2.4 - cd ${WKCT} - git checkout 2.4 ''' } else { sh ''' cd ${WK} git checkout develop - cd ${WKCT} - git checkout develop ''' } } sh ''' - export TZ=Asia/Harbin cd ${WK} git pull >/dev/null git clean -dfx - cd ${WKCT} - git pull >/dev/null - git clean -dfx - date + ''' + script { + if (env.CHANGE_URL =~ /\/TDengine\//) { + sh ''' + echo "match /TDengine/ repository" + cd ${WKC} + git fetch origin +refs/pull/${CHANGE_ID}/merge + git checkout -qf FETCH_HEAD + ''' + } else if (env.CHANGE_URL =~ /\/TDinternal\//) { + sh ''' + echo "match /TDinternal/ repository" + cd ${WK} + git fetch origin +refs/pull/${CHANGE_ID}/merge + git checkout -qf FETCH_HEAD + ''' + } else { + sh ''' + echo "unmatched reposiotry ${CHANGE_URL}" + ''' + } + } + sh ''' + cd ${WKC} + git submodule update --init --recursive ''' } def pre_test() { @@ -129,7 +134,6 @@ pipeline { environment{ WK = '/var/data/jenkins/workspace/TDinternal' WKC = '/var/data/jenkins/workspace/TDinternal/community' - WKCT = '/var/data/jenkins/workspace/TDinternal/community/tests' LOGDIR = '/var/data/jenkins/workspace/log' } stages { @@ -248,7 +252,7 @@ pipeline { } parallel { stage ('build worker08_arm32') { - agent {label " worker08_arm32 "} + agent {label " worker08_arm32"} steps { timeout(time: 20, unit: 'MINUTES') { pre_test() diff --git a/examples/rust b/examples/rust deleted file mode 160000 index 1c8924dc668e6aa848214c2fc54e3ace3f5bf8df..0000000000000000000000000000000000000000 --- a/examples/rust +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1c8924dc668e6aa848214c2fc54e3ace3f5bf8df diff --git a/tests b/tests deleted file mode 160000 index 3f295e991ef7ba7c62e686cd9e88a3744c7edf41..0000000000000000000000000000000000000000 --- a/tests +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3f295e991ef7ba7c62e686cd9e88a3744c7edf41 diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec5487c8ac0a4ce20d1f9aaff20932f38d95c1e --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,14 @@ +# generate debug version: +# mkdir debug; cd debug; cmake -DCMAKE_BUILD_TYPE=Debug .. +# generate release version: +# mkdir release; cd release; cmake -DCMAKE_BUILD_TYPE=Release .. + +CMAKE_MINIMUM_REQUIRED(VERSION 2.8...3.20) +PROJECT(TDengine) + +SET(CMAKE_C_STANDARD 11) +SET(CMAKE_VERBOSE_MAKEFILE ON) + +ADD_SUBDIRECTORY(tsim) +ADD_SUBDIRECTORY(test/c) +ADD_SUBDIRECTORY(comparisonTest/tdengine) diff --git a/tests/How-To-Run-Test-And-How-To-Add-New-Test-Case.md b/tests/How-To-Run-Test-And-How-To-Add-New-Test-Case.md new file mode 100644 index 0000000000000000000000000000000000000000..6845d091b5f300bac0656078492467dc3db67830 --- /dev/null +++ b/tests/How-To-Run-Test-And-How-To-Add-New-Test-Case.md @@ -0,0 +1,243 @@ +### Prepare development environment + +1. sudo apt install + build-essential cmake net-tools python-pip python-setuptools python3-pip + python3-setuptools valgrind psmisc curl + +2. git clone ; cd TDengine + +3. mkdir debug; cd debug; cmake ..; make ; sudo make install + +4. pip install ../src/connector/python ; pip3 install + ../src/connector/python + +5. pip install numpy; pip3 install numpy (numpy is required only if you need to run querySort.py) + +> Note: Both Python2 and Python3 are currently supported by the Python test +> framework. Since Python2 is no longer officially supported by Python Software +> Foundation since January 1, 2020, it is recommended that subsequent test case +> development be guaranteed to run correctly on Python3. + +> For Python2, please consider being compatible if appropriate without +> additional burden. +> +> If you use some new Linux distribution like Ubuntu 20.04 which already do not +> include Python2, please do not install Python2-related packages. +> +>   + +### How to run Python test suite + +1. cd \/tests/pytest + +2. ./smoketest.sh \# for smoke test + +3. ./smoketest.sh -g \# for memory leak detection test with valgrind + +4. ./fulltest.sh \# for full test + +> Note1: TDengine daemon's configuration and data files are stored in +> \/sim directory. As a historical design, it's same place with +> TSIM script. So after the TSIM script ran with sudo privilege, the directory +> has been used by TSIM then the python script cannot write it by a normal +> user. You need to remove the directory completely first before running the +> Python test case. We should consider using two different locations to store +> for TSIM and Python script. + +> Note2: if you need to debug crash problem with a core dump, you need +> manually edit smoketest.sh or fulltest.sh to add "ulimit -c unlimited" +> before the script line. Then you can look for the core file in +> \/tests/pytest after the program crash. + + +### How to add a new test case + +**1. TSIM test cases:** + +TSIM was the testing framework has been used internally. Now it still be used to run the test cases we develop in the past as a legacy system. We are turning to use Python to develop new test case and are abandoning TSIM gradually. + +**2. Python test cases:** + +**2.1 Please refer to \/tests/pytest/insert/basic.py to add a new +test case.** The new test case must implement 3 functions, where self.init() +and self.stop() simply copy the contents of insert/basic.py and the test +logic is implemented in self.run(). You can refer to the code in the util +directory for more information. + +**2.2 Edit smoketest.sh to add the path and filename of the new test case** + +Note: The Python test framework may continue to be improved in the future, +hopefully, to provide more functionality and ease of writing test cases. The +method of writing the test case above does not exclude that it will also be +affected. + +**2.3 What test.py does in detail:** + +test.py is the entry program for test case execution and monitoring. + +test.py has the following functions. + +\-f --file, Specifies the test case file name to be executed +-p --path, Specifies deployment path + +\-m --master, Specifies the master server IP for cluster deployment +-c--cluster, test cluster function +-s--stop, terminates all running nodes + +\-g--valgrind, load valgrind for memory leak detection test + +\-h--help, display help + +**2.4 What util/log.py does in detail:** + +log.py is quite simple, the main thing is that you can print the output in +different colors as needed. The success() should be called for successful +test case execution and the success() will print green text. The exit() will +print red text and exit the program, exit() should be called for test +failure. + +**util/log.py** + +... + +    def info(self, info): + +        printf("%s %s" % (datetime.datetime.now(), info)) + +  + +    def sleep(self, sec): + +        printf("%s sleep %d seconds" % (datetime.datetime.now(), sec)) + +        time.sleep(sec) + +  + +    def debug(self, err): + +        printf("\\033[1;36m%s %s\\033[0m" % (datetime.datetime.now(), err)) + +  + +    def success(self, info): + +        printf("\\033[1;32m%s %s\\033[0m" % (datetime.datetime.now(), info)) + +  + +    def notice(self, err): + +        printf("\\033[1;33m%s %s\\033[0m" % (datetime.datetime.now(), err)) + +  + +    def exit(self, err): + +        printf("\\033[1;31m%s %s\\033[0m" % (datetime.datetime.now(), err)) + +        sys.exit(1) + +  + +    def printNoPrefix(self, info): + +        printf("\\033[1;36m%s\\033[0m" % (info) + +... + +**2.5 What util/sql.py does in detail:** + +SQL.py is mainly used to execute SQL statements to manipulate the database, +and the code is extracted and commented as follows: + +**util/sql.py** + +\# prepare() is mainly used to set up the environment for testing table and +data, and to set up the database db for testing. do not call prepare() if you +need to test the database operation command. + +def prepare(self): + +tdLog.info("prepare database:db") + +self.cursor.execute('reset query cache') + +self.cursor.execute('drop database if exists db') + +self.cursor.execute('create database db') + +self.cursor.execute('use db') + +... + +\# query() is mainly used to execute select statements for normal syntax input + +def query(self, sql): + +... + +\# error() is mainly used to execute the select statement with the wrong syntax +input, the error will be caught as a reasonable behavior, if not caught it will +prove that the test failed + +def error() + +... + +\# checkRows() is used to check the number of returned lines after calling +query(select ...) after calling the query(select ...) to check the number of +rows of returned results. + +def checkRows(self, expectRows): + +... + +\# checkData() is used to check the returned result data after calling +query(select ...) after the query(select ...) is called, failure to meet +expectation is + +def checkData(self, row, col, data): + +... + +\# getData() returns the result data after calling query(select ...) to return +the resulting data after calling query(select ...) + +def getData(self, row, col): + +... + +\# execute() used to execute sql and return the number of affected rows + +def execute(self, sql): + +... + +\# executeTimes() Multiple executions of the same sql statement + +def executeTimes(self, sql, times): + +... + +\# CheckAffectedRows() Check if the number of affected rows is as expected + +def checkAffectedRows(self, expectAffectedRows): + +... + +### CI submission adoption principle. + +- Every commit / PR compilation must pass. Currently, the warning is treated + as an error, so the warning must also be resolved. + +- Test cases that already exist must pass. + +- Because CI is very important to support build and automatically test + procedure, it is necessary to manually test the test case before adding it + and do as many iterations as possible to ensure that the test case provides + stable and reliable test results when added. + +> Note: In the future, according to the requirements and test development +> progress will add stress testing, performance testing, code style, +> and other features based on functional testing. diff --git a/tests/Jenkinsfile b/tests/Jenkinsfile new file mode 100644 index 0000000000000000000000000000000000000000..eeb56bd3b98deaebdcd4ef95e9aae514fb68de9b --- /dev/null +++ b/tests/Jenkinsfile @@ -0,0 +1,328 @@ +def pre_test(){ + + sh ''' + sudo rmtaos||echo 'no taosd installed' + ''' + sh ''' + cd ${WKC} + git reset --hard + git checkout $BRANCH_NAME + git pull + git submodule update + cd ${WK} + git reset --hard + git checkout $BRANCH_NAME + git pull + export TZ=Asia/Harbin + date + rm -rf ${WK}/debug + mkdir debug + cd debug + cmake .. > /dev/null + make > /dev/null + make install > /dev/null + pip3 install ${WKC}/src/connector/python + ''' + return 1 +} +def pre_test_p(){ + + sh ''' + sudo rmtaos||echo 'no taosd installed' + ''' + sh ''' + cd ${WKC} + git reset --hard + git checkout $BRANCH_NAME + git pull + git submodule update + cd ${WK} + git reset --hard + git checkout $BRANCH_NAME + git pull + export TZ=Asia/Harbin + date + rm -rf ${WK}/debug + mkdir debug + cd debug + cmake .. > /dev/null + make > /dev/null + make install > /dev/null + pip3 install ${WKC}/src/connector/python + ''' + return 1 +} +pipeline { + agent none + environment{ + + WK = '/data/lib/jenkins/workspace/TDinternal' + WKC= '/data/lib/jenkins/workspace/TDinternal/community' + } + + stages { + stage('Parallel test stage') { + parallel { + stage('pytest') { + agent{label 'slad1'} + steps { + pre_test_p() + sh ''' + cd ${WKC}/tests + find pytest -name '*'sql|xargs rm -rf + ./test-all.sh pytest + date''' + } + } + stage('test_b1') { + agent{label 'slad2'} + steps { + pre_test() + + sh ''' + cd ${WKC}/tests + ./test-all.sh b1 + date''' + + + } + } + + stage('test_crash_gen') { + agent{label "slad3"} + steps { + pre_test() + sh ''' + cd ${WKC}/tests/pytest + ''' + catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { + sh ''' + cd ${WKC}/tests/pytest + ./crash_gen.sh -a -p -t 4 -s 2000 + ''' + } + catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { + sh ''' + cd ${WKC}/tests/pytest + rm -rf /var/lib/taos/* + rm -rf /var/log/taos/* + ./handle_crash_gen_val_log.sh + ''' + } + catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { + sh ''' + cd ${WKC}/tests/pytest + rm -rf /var/lib/taos/* + rm -rf /var/log/taos/* + ./handle_taosd_val_log.sh + ''' + } + + sh''' + nohup taosd >/dev/null & + sleep 10 + ''' + catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { + sh ''' + cd ${WKC}/tests/gotest + bash batchtest.sh + ''' + } + catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { + sh ''' + cd ${WKC}/tests/examples/python/PYTHONConnectorChecker + python3 PythonChecker.py + ''' + } + catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { + sh ''' + cd ${WKC}/tests/examples/JDBC/JDBCDemo/ + mvn clean package >/dev/null + java -jar target/JdbcRestfulDemo-jar-with-dependencies.jar + ''' + } + catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { + sh ''' + cp -rf ${WKC}/tests/examples/nodejs ${JENKINS_HOME}/workspace/ + cd ${JENKINS_HOME}/workspace/nodejs + node nodejsChecker.js host=localhost + ''' + } + catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { + sh ''' + cd ${JENKINS_HOME}/workspace/C#NET/src/CheckC# + dotnet run + ''' + } + sh ''' + pkill -9 taosd || echo 1 + cd ${WKC}/tests + ./test-all.sh b2 + date + ''' + sh ''' + cd ${WKC}/tests + ./test-all.sh full unit + date''' + } + } + + stage('test_valgrind') { + agent{label "slad4"} + + steps { + pre_test() + catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { + sh ''' + cd ${WKC}/tests/pytest + nohup taosd >/dev/null & + sleep 10 + python3 concurrent_inquiry.py -c 1 + + ''' + } + sh ''' + cd ${WKC}/tests + ./test-all.sh full jdbc + date''' + sh ''' + cd ${WKC}/tests/pytest + ./valgrind-test.sh 2>&1 > mem-error-out.log + ./handle_val_log.sh + + date + cd ${WKC}/tests + ./test-all.sh b3 + date''' + sh ''' + date + cd ${WKC}/tests + ./test-all.sh full example + date''' + } + } + + stage('arm64_build'){ + agent{label 'arm64'} + steps{ + sh ''' + cd ${WK} + git fetch + git checkout develop + git pull + cd ${WKC} + git fetch + git checkout develop + git pull + git submodule update + cd ${WKC}/packaging + ./release.sh -v cluster -c aarch64 -n 2.0.0.0 -m 2.0.0.0 + + ''' + } + } + stage('arm32_build'){ + agent{label 'arm32'} + steps{ + catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { + sh ''' + cd ${WK} + git fetch + git checkout develop + git pull + cd ${WKC} + git fetch + git checkout develop + git pull + git submodule update + cd ${WKC}/packaging + ./release.sh -v cluster -c aarch32 -n 2.0.0.0 -m 2.0.0.0 + + ''' + } + + } + } + } + } + + } + post { + success { + emailext ( + subject: "PR-result: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' SUCCESS", + body: """ + + + + + + + + + + + + +

+ 构建信息 +
+
    +
    +
  • 构建名称>>分支:${env.BRANCH_NAME}
  • +
  • 构建结果: Successful
  • +
  • 构建编号:${BUILD_NUMBER}
  • +
  • 触发用户:${env.CHANGE_AUTHOR}
  • +
  • 提交信息:${env.CHANGE_TITLE}
  • +
  • 构建地址:${BUILD_URL}
  • +
  • 构建日志:${BUILD_URL}console
  • + +
    +
+
+ + """, + to: "yqliu@taosdata.com,pxiao@taosdata.com", + from: "support@taosdata.com" + ) + } + failure { + emailext ( + subject: "PR-result: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' FAIL", + body: """ + + + + + + + + + + + + +

+ 构建信息 +
+
    +
    +
  • 构建名称>>分支:${env.BRANCH_NAME}
  • +
  • 构建结果: Failure
  • +
  • 构建编号:${BUILD_NUMBER}
  • +
  • 触发用户:${env.CHANGE_AUTHOR}
  • +
  • 提交信息:${env.CHANGE_TITLE}
  • +
  • 构建地址:${BUILD_URL}
  • +
  • 构建日志:${BUILD_URL}console
  • + +
    +
+
+ + """, + to: "yqliu@taosdata.com,pxiao@taosdata.com", + from: "support@taosdata.com" + ) + } + } +} \ No newline at end of file diff --git a/tests/comparisonTest/cassandra/application.conf b/tests/comparisonTest/cassandra/application.conf new file mode 100644 index 0000000000000000000000000000000000000000..23b10682096473338f2084e024b1fdbd28e059b3 --- /dev/null +++ b/tests/comparisonTest/cassandra/application.conf @@ -0,0 +1,5 @@ +datastax-java-driver { + basic.request { + timeout = 200000 seconds + } +} diff --git a/tests/comparisonTest/cassandra/cassandratest/pom.xml b/tests/comparisonTest/cassandra/cassandratest/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..00630d93d197379e04268ef940a8e4db282d8186 --- /dev/null +++ b/tests/comparisonTest/cassandra/cassandratest/pom.xml @@ -0,0 +1,131 @@ + + + + 4.0.0 + + com.cassandra.test + cassandratest + 1.0-SNAPSHOT + jar + + + + + org.apache.maven.plugins + maven-plugins + 30 + + + org.apache.maven.plugins + maven-assembly-plugin + 3.0.0 + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.1.0 + + + + CassandraTest + + + + jar-with-dependencies + + + + + make-assembly + package + + single + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + 8 + 8 + + + + + + + cassandratest + + http://www.example.com + + + UTF-8 + 1.8 + 1.8 + + + + + junit + junit + 4.13.1 + test + + + + com.datastax.oss + java-driver-core + 4.1.0 + + + + com.datastax.oss + java-driver-query-builder + 4.1.0 + + + + com.datastax.oss + java-driver-mapper-runtime + 4.1.0 + + + + commons-io + commons-io + 2.7 + + + + org.apache.commons + commons-lang3 + 3.7 + + + + org.slf4j + slf4j-api + 1.7.5 + + + org.slf4j + slf4j-log4j12 + 1.7.5 + + + + org.apache.logging.log4j + log4j-1.2-api + 2.8.2 + + + + + diff --git a/tests/comparisonTest/cassandra/cassandratest/src/main/java/com/cassandra/test/CassandraTest.java b/tests/comparisonTest/cassandra/cassandratest/src/main/java/com/cassandra/test/CassandraTest.java new file mode 100644 index 0000000000000000000000000000000000000000..a3f72de13c714d8601d4249dd79819d3425012ce --- /dev/null +++ b/tests/comparisonTest/cassandra/cassandratest/src/main/java/com/cassandra/test/CassandraTest.java @@ -0,0 +1,200 @@ +import com.datastax.oss.driver.api.core.CqlSession; +import com.datastax.oss.driver.api.core.cql.*; +import com.datastax.oss.driver.api.core.session.*; +import com.datastax.oss.driver.api.core.config.*; +import com.datastax.oss.driver.api.core.cql.ResultSet; +import com.datastax.oss.driver.api.core.cql.Row; +//import com.datastax.driver.core.Cluster; +//import com.datastax.driver.core.Cluster; + +import java.io.BufferedWriter; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileWriter; +import java.io.FileReader; +import java.io.IOException; +import java.text.DecimalFormat; +import java.util.Random; +import java.math.*; +import java.lang.reflect.Method; + + +public class CassandraTest{ + + public static void main(String args[]) { + + + // begin to parse argument + String datadir = "/home/ubuntu/testdata"; + String sqlfile = "/home/ubuntu/fang/cassandra/q1.txt"; + String cfgfile = "/home/ubuntu/fang/cassandra/application.conf"; + boolean q4flag = false; + int numOfRows = 1000000; + int numOfFiles =0; + int numOfClients =0; + int rowsPerRequest =0; + for (int i = 0; i < args.length; ++i) { + if (args[i].equalsIgnoreCase("-dataDir")) { + if (i < args.length - 1) { + datadir = args[++i]; + } + } else if (args[i].equalsIgnoreCase("-numofFiles")) { + if (i < args.length - 1) { + numOfFiles = Integer.parseInt(args[++i]); + } + } else if (args[i].equalsIgnoreCase("-rowsPerRequest")) { + if (i < args.length - 1) { + rowsPerRequest = Integer.parseInt(args[++i]); + } + } else if (args[i].equalsIgnoreCase("-writeClients")) { + if (i < args.length - 1) { + numOfClients = Integer.parseInt(args[++i]); + } + } else if (args[i].equalsIgnoreCase("-sql")) { + sqlfile = args[++i]; + } else if (args[i].equalsIgnoreCase("-timetest")) { + q4flag = true; + } else if (args[i].equalsIgnoreCase("-conf")) { + cfgfile = args[++i]; + } + } + // file below to make sure no timeout error + File confile = new File(cfgfile); + + System.out.println("parameters\n"); + + if (numOfFiles >0) { + // write data + System.out.printf("----dataDir:%s\n", datadir); + System.out.printf("----numOfFiles:%d\n", numOfFiles); + System.out.printf("----numOfClients:%d\n", numOfClients); + System.out.printf("----rowsPerRequest:%d\n", rowsPerRequest); + + // connect to cassandra server + System.out.printf("----connecting to cassandra server\n"); + try { + CqlSession session = CqlSession.builder() + .withConfigLoader(DriverConfigLoader.fromFile(confile)) + .build(); + + session.execute("drop keyspace if exists cassandra"); + session.execute("CREATE KEYSPACE if not exists cassandra WITH replication = {'class':'SimpleStrategy', 'replication_factor':1}"); + if (q4flag) { + session.execute("create table if not exists cassandra.test (devid int, devname text, devgroup int, ts bigint, minute bigint, temperature int, humidity float ,primary key (minute,ts,devgroup,devid,devname))"); + } else { + session.execute("create table if not exists cassandra.test (devid int, devname text, devgroup int, ts bigint, temperature int, humidity float ,primary key (devgroup,devid,devname,ts))"); + } + session.close(); + System.out.printf("----created keyspace cassandra and table test\n"); + + // begin to insert data + System.out.printf("----begin to insert data\n"); + long startTime = System.currentTimeMillis(); + int a = numOfFiles/numOfClients; + int b = numOfFiles%numOfClients; + int last = 0; + + WriteThread[] writethreads = new WriteThread[numOfClients]; + int[] wargs = new int[2]; // data file start, end + wargs[0] = numOfRows; //rows to be read from each file + wargs[1] = rowsPerRequest; + int fstart =0; + int fend =0; + for (int i = 0; i10) { + long startTime = System.currentTimeMillis(); + // begin to query one line command // + // end querying one line command + try { + + ResultSet results = session.execute(line); + long icounter = 0; + for (Row row : results) { + icounter++; + } + + long stopTime = System.currentTimeMillis(); + float elapseTime = stopTime - startTime; + elapseTime = elapseTime/1000; + System.out.printf("----spend %f seconds to query: %s\n", elapseTime, line); + } catch (Exception ex) { + ex.printStackTrace(); + System.out.printf("---- query failed!\n"); + System.exit(1); + } + + } + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (br != null) { + try { + br.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + session.close(); + } + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + System.out.println("query end:----\n"); + } + } // end write or query + System.exit(0); + }// end main +}// end class diff --git a/tests/comparisonTest/cassandra/cassandratest/src/main/java/com/cassandra/test/WriteThread.java b/tests/comparisonTest/cassandra/cassandratest/src/main/java/com/cassandra/test/WriteThread.java new file mode 100644 index 0000000000000000000000000000000000000000..7d8679a3030dcd8f46062ac0e3fa6ce4ff3d1d3b --- /dev/null +++ b/tests/comparisonTest/cassandra/cassandratest/src/main/java/com/cassandra/test/WriteThread.java @@ -0,0 +1,99 @@ +import java.io.BufferedReader; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.math.*; + +import com.datastax.oss.driver.api.core.CqlSession; +import com.datastax.oss.driver.api.core.cql.*; +import com.datastax.oss.driver.api.core.session.*; +import com.datastax.oss.driver.api.core.config.*; + + +public class WriteThread extends Thread { + + private int[] wargs; // fstart, fend, rows to be read, rows perrequest + private String fdir; + private int fstart; + private int fend; + private boolean q4flag; + + public WriteThread (int fstart, int fend,int[] wargs, String fdir, boolean q4flag) { + this.fstart = fstart; + this.fend = fend; + this.fdir = fdir; + this.wargs = wargs; + this.q4flag = q4flag; + } + + // begin to insert in this thread + public void run() { + /* + // this configuration file makes sure no timeout error + File confile = new File("/home/ubuntu/fang/cassandra/application.conf"); + */ + // connect to server + try { + CqlSession session = CqlSession.builder() + //.withConfigLoader(DriverConfigLoader.fromFile(confile)) + .build(); + //session.execute("use cassandra"); + int tominute = 6000; + for (int i=fstart; i<=fend; i++) { + String csvfile; + csvfile = fdir + "/testdata"+ Integer.toString(i)+".csv"; + BufferedReader br = null; + String line = ""; + String cvsSplitBy = " "; + try { + br = new BufferedReader(new FileReader(csvfile)); + System.out.println("---- begin to read file " +csvfile+"\n"); + for (int itotalrow =0; itotalrow 3) { + v = 3; + } + + return (this.range / 3.00) * v + center; + } + } + + // data scale + private static int timestep = 1000; // sample time interval in milliseconds + + private static long dataStartTime = 1563249700000L; + private static int deviceId = 0; + private static String tagPrefix = "dev_"; + + // MachineNum RowsPerMachine MachinesInOneFile + public static void main(String args[]) { + int numOfDevice = 10000; + int numOfFiles = 100; + int rowsPerDevice = 10000; + String directory = "~/"; + + for (int i = 0; i < args.length; i++) { + if (args[i].equalsIgnoreCase("-numOfDevices")) { + if (i < args.length - 1) { + numOfDevice = Integer.parseInt(args[++i]); + } else { + System.out.println("'-numOfDevices' requires a parameter, default is 10000"); + } + } else if (args[i].equalsIgnoreCase("-numOfFiles")) { + if (i < args.length - 1) { + numOfFiles = Integer.parseInt(args[++i]); + } else { + System.out.println("'-numOfFiles' requires a parameter, default is 100"); + } + } else if (args[i].equalsIgnoreCase("-rowsPerDevice")) { + if (i < args.length - 1) { + rowsPerDevice = Integer.parseInt(args[++i]); + } else { + System.out.println("'-rowsPerDevice' requires a parameter, default is 10000"); + } + } else if (args[i].equalsIgnoreCase("-dataDir")) { + if (i < args.length - 1) { + directory = args[++i]; + } else { + System.out.println("'-dataDir' requires a parameter, default is ~/testdata"); + } + } + } + + System.out.println("parameters"); + System.out.printf("----dataDir:%s\n", directory); + System.out.printf("----numOfFiles:%d\n", numOfFiles); + System.out.printf("----numOfDevice:%d\n", numOfDevice); + System.out.printf("----rowsPerDevice:%d\n", rowsPerDevice); + + int numOfDevPerFile = numOfDevice / numOfFiles; + long ts = dataStartTime; + + // deviceId, time stamp, humid(int), temp(double), tagString(dev_deviceid) + int humidityDistRadius = 35; + int tempDistRadius = 17; + + for (int i = 0; i < numOfFiles; ++i) { // prepare the data file + dataStartTime = ts; + + // generate file name + String path = directory; + try { + path += "/testdata" + String.valueOf(i) + ".csv"; + getDataInOneFile(path, rowsPerDevice, numOfDevPerFile, humidityDistRadius, tempDistRadius); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + private static void getDataInOneFile(String path, int rowsPerDevice, int num, int humidityDistRadius, int tempDistRadius) throws IOException { + DecimalFormat df = new DecimalFormat("0.0000"); + long startTime = dataStartTime; + + FileWriter fw = new FileWriter(new File(path)); + BufferedWriter bw = new BufferedWriter(fw); + + for (int i = 0; i < num; ++i) { + deviceId += 1; + + Random rand = new Random(); + double centralVal = Math.abs(rand.nextInt(100)); + if (centralVal < humidityDistRadius) { + centralVal = humidityDistRadius; + } + + if (centralVal + humidityDistRadius > 100) { + centralVal = 100 - humidityDistRadius; + } + + DataGenerator.ValueGen humidityDataGen = new DataGenerator.ValueGen((int) centralVal, humidityDistRadius); + dataStartTime = startTime; + + centralVal = Math.abs(rand.nextInt(22)); + DataGenerator.ValueGen tempDataGen = new DataGenerator.ValueGen((int) centralVal, tempDistRadius); + + for (int j = 0; j < rowsPerDevice; ++j) { + int humidity = (int) humidityDataGen.next(); + double temp = tempDataGen.next(); + int deviceGroup = deviceId % 100; + + StringBuffer sb = new StringBuffer(); + sb.append(deviceId).append(" ").append(tagPrefix).append(deviceId).append(" ").append(deviceGroup) + .append(" ").append(dataStartTime).append(" ").append(humidity).append(" ") + .append(df.format(temp)); + bw.write(sb.toString()); + bw.write("\n"); + + dataStartTime += timestep; + } + } + + bw.close(); + fw.close(); + System.out.printf("file:%s generated\n", path); + } +} diff --git a/tests/comparisonTest/influxdb/main.go b/tests/comparisonTest/influxdb/main.go new file mode 100644 index 0000000000000000000000000000000000000000..2fb16fad89a51e6601a6f18163bac1a8c8bfdc7b --- /dev/null +++ b/tests/comparisonTest/influxdb/main.go @@ -0,0 +1,281 @@ +package main + +import ( + "bufio" + "flag" + "fmt" + "log" + "os" + "strconv" + "strings" + "sync" + "sync/atomic" + "time" + + "github.com/influxdata/influxdb1-client/v2" +) + +type ProArgs struct { + host string + username string + password string + db string + sql string + dataDir string + filesNum int + writeClients int + rowsPerRequest int +} + +type WriteInfo struct { + threadId int + sID int + eID int +} + +type StatisInfo struct { + totalRows int64 +} + +var statis StatisInfo + +func main() { + // Configuration + var arguments ProArgs + + // Parse options + flag.StringVar(&(arguments.host), "host", "http://localhost:8086", "Server host to connect") + flag.StringVar(&(arguments.db), "db", "db", "DB to insert data") + flag.StringVar(&(arguments.username), "user", "", "Username used to connect to server") + flag.StringVar(&(arguments.password), "pass", "", "Password used to connect to server") + flag.StringVar(&(arguments.sql), "sql", "./sqlCmd.txt", "File name of SQL commands") + flag.StringVar(&(arguments.dataDir), "dataDir", "./testdata", "Raw csv data") + flag.IntVar(&(arguments.filesNum), "numOfFiles", 10, "Number of files int dataDir ") + flag.IntVar(&(arguments.writeClients), "writeClients", 0, "Number of write clients") + flag.IntVar(&(arguments.rowsPerRequest), "rowsPerRequest", 100, "Number of rows per request") + + flag.Parse() + statis.totalRows = 0 + + if arguments.writeClients > 0 { + writeData(&arguments) + } else { + readData(&arguments) + } +} + +func writeData(arguments *ProArgs) { + log.Println("write data") + log.Println("---- writeClients:", arguments.writeClients) + log.Println("---- dataDir:", arguments.dataDir) + log.Println("---- numOfFiles:", arguments.filesNum) + log.Println("---- rowsPerRequest:", arguments.rowsPerRequest) + + var wg sync.WaitGroup + wg.Add(arguments.writeClients) + + st := time.Now() + + a := arguments.filesNum / arguments.writeClients + b := arguments.filesNum % arguments.writeClients + last := 0 + for i := 0; i < arguments.writeClients; i++ { + var wInfo WriteInfo + wInfo.threadId = i + 1 + wInfo.sID = last + if i < b { + wInfo.eID = last + a + } else { + wInfo.eID = last + a - 1 + } + last = wInfo.eID + 1 + go writeDataImp(&wInfo, &wg, arguments) + } + + wg.Wait() + + elapsed := time.Since(st) + seconds := float64(elapsed) / float64(time.Second) + + log.Println("---- Spent", seconds, "seconds to insert", statis.totalRows, "records, speed:", float64(statis.totalRows)/seconds, "Rows/Second") +} + +func writeDataImp(wInfo *WriteInfo, wg *sync.WaitGroup, arguments *ProArgs) { + defer wg.Done() + + log.Println("Thread", wInfo.threadId, "writing sID", wInfo.sID, "eID", wInfo.eID) + + // Connect to the server + conn, err := client.NewHTTPClient(client.HTTPConfig{ + Addr: arguments.host, + Username: arguments.username, + Password: arguments.password, + Timeout: 300 * time.Second, + }) + + if err != nil { + log.Fatal(err) + } + + defer conn.Close() + + // Create database + _, err = queryDB(conn, fmt.Sprintf("create database %s", arguments.db), arguments.db) + if err != nil { + log.Fatal(err) + } + + // Write data + counter := 0 + totalRecords := 0 + + bp, err := client.NewBatchPoints(client.BatchPointsConfig{ + Database: arguments.db, + Precision: "ms", + }) + if err != nil { + log.Fatal(err) + } + + for j := wInfo.sID; j <= wInfo.eID; j++ { + fileName := fmt.Sprintf("%s/testdata%d.csv", arguments.dataDir, j) + fs, err := os.Open(fileName) + if err != nil { + log.Printf("failed to open file %s", fileName) + log.Fatal(err) + } + log.Printf("open file %s success", fileName) + + bfRd := bufio.NewReader(fs) + for { + sline, err := bfRd.ReadString('\n') + if err != nil { + break + } + + sline = strings.TrimSuffix(sline, "\n") + s := strings.Split(sline, " ") + if len(s) != 6 { + continue + } + + // Create a point and add to batch + tags := map[string]string{ + "devid": s[0], + "devname": s[1], + "devgroup": s[2], + } + + timestamp, _ := strconv.ParseInt(s[3], 10, 64) + temperature, _ := strconv.ParseInt(s[4], 10, 32) + humidity, _ := strconv.ParseFloat(s[5], 64) + + fields := map[string]interface{}{ + "temperature": temperature, + "humidity": humidity, + } + + pt, err := client.NewPoint("devices", tags, fields, time.Unix(0, timestamp * int64(time.Millisecond))) + if err != nil { + log.Fatalln("Error: ", err) + } + + bp.AddPoint(pt) + counter++ + + if counter >= arguments.rowsPerRequest { + if err := conn.Write(bp); err != nil { + log.Fatal(err) + } + + totalRecords += counter + counter = 0 + bp, err = client.NewBatchPoints(client.BatchPointsConfig{ + Database: arguments.db, + Precision: "ms", + }) + if err != nil { + log.Fatal(err) + } + } + } + + fs.Close() + } + + totalRecords += counter + if counter > 0 { + if err := conn.Write(bp); err != nil { + log.Fatal(err) + } + } + + atomic.AddInt64(&statis.totalRows, int64(totalRecords)) +} + +func readData(arguments *ProArgs) { + log.Println("read data") + log.Println("---- sql:", arguments.sql) + + conn, err := client.NewHTTPClient(client.HTTPConfig{ + Addr: arguments.host, + Username: arguments.username, + Password: arguments.password, + Timeout: 300 * time.Second, + }) + + if err != nil { + log.Fatal(err) + } + + defer conn.Close() + + fs, err := os.Open(arguments.sql) + if err != nil { + log.Printf("failed to open file %s", arguments.sql) + log.Fatal(err) + } + log.Printf("open file %s success", arguments.sql) + + bfRd := bufio.NewReader(fs) + + for { + sline, err := bfRd.ReadString('\n') + if err != nil { + break + } + + sline = strings.TrimSuffix(sline, "\n") + + st := time.Now() + + _, err = queryDB(conn, sline, arguments.db) + if err != nil { + log.Fatal(err) + } + + elapsed := time.Since(st) + seconds := float64(elapsed) / float64(time.Second) + + log.Println("---- Spent", seconds, "seconds to query ", sline) + } +} + +func queryDB(conn client.Client, cmd string, db string) (res []client.Result, err error) { + query := client.Query{ + Command: cmd, + Database: db, + } + + response, err := conn.Query(query) + if err == nil { + if response.Error() != nil { + return res, response.Error() + } + res = response.Results + } else { + return res, err + } + + return res, nil +} diff --git a/tests/comparisonTest/influxdb/q1.txt b/tests/comparisonTest/influxdb/q1.txt new file mode 100644 index 0000000000000000000000000000000000000000..05076529fea1f1b18eb2e8a6ca284fa59538aa5f --- /dev/null +++ b/tests/comparisonTest/influxdb/q1.txt @@ -0,0 +1,10 @@ +select * from devices where devgroup='0'; +select * from devices where devgroup='10'; +select * from devices where devgroup='20'; +select * from devices where devgroup='30'; +select * from devices where devgroup='40'; +select * from devices where devgroup='50'; +select * from devices where devgroup='60'; +select * from devices where devgroup='70'; +select * from devices where devgroup='80'; +select * from devices where devgroup='90'; diff --git a/tests/comparisonTest/influxdb/q2.txt b/tests/comparisonTest/influxdb/q2.txt new file mode 100644 index 0000000000000000000000000000000000000000..10feba922c1575726e7c78cbfc1a090ab16c1a5e --- /dev/null +++ b/tests/comparisonTest/influxdb/q2.txt @@ -0,0 +1,60 @@ +select count(temperature) from devices where devgroup=~/[1-1][0-9]/; +select count(temperature) from devices where devgroup=~/[1-2][0-9]/; +select count(temperature) from devices where devgroup=~/[1-3][0-9]/; +select count(temperature) from devices where devgroup=~/[1-4][0-9]/; +select count(temperature) from devices where devgroup=~/[1-5][0-9]/; +select count(temperature) from devices where devgroup=~/[1-6][0-9]/; +select count(temperature) from devices where devgroup=~/[1-7][0-9]/; +select count(temperature) from devices where devgroup=~/[1-8][0-9]/; +select count(temperature) from devices where devgroup=~/[1-9][0-9]/; +select count(temperature) from devices; +select mean(temperature) from devices where devgroup=~/[1-1][0-9]/; +select mean(temperature) from devices where devgroup=~/[1-2][0-9]/; +select mean(temperature) from devices where devgroup=~/[1-3][0-9]/; +select mean(temperature) from devices where devgroup=~/[1-4][0-9]/; +select mean(temperature) from devices where devgroup=~/[1-5][0-9]/; +select mean(temperature) from devices where devgroup=~/[1-6][0-9]/; +select mean(temperature) from devices where devgroup=~/[1-7][0-9]/; +select mean(temperature) from devices where devgroup=~/[1-8][0-9]/; +select mean(temperature) from devices where devgroup=~/[1-9][0-9]/; +select mean(temperature) from devices; +select sum(temperature) from devices where devgroup=~/[1-1][0-9]/; +select sum(temperature) from devices where devgroup=~/[1-2][0-9]/; +select sum(temperature) from devices where devgroup=~/[1-3][0-9]/; +select sum(temperature) from devices where devgroup=~/[1-4][0-9]/; +select sum(temperature) from devices where devgroup=~/[1-5][0-9]/; +select sum(temperature) from devices where devgroup=~/[1-6][0-9]/; +select sum(temperature) from devices where devgroup=~/[1-7][0-9]/; +select sum(temperature) from devices where devgroup=~/[1-8][0-9]/; +select sum(temperature) from devices where devgroup=~/[1-9][0-9]/; +select sum(temperature) from devices; +select max(temperature) from devices where devgroup=~/[1-1][0-9]/; +select max(temperature) from devices where devgroup=~/[1-2][0-9]/; +select max(temperature) from devices where devgroup=~/[1-3][0-9]/; +select max(temperature) from devices where devgroup=~/[1-4][0-9]/; +select max(temperature) from devices where devgroup=~/[1-5][0-9]/; +select max(temperature) from devices where devgroup=~/[1-6][0-9]/; +select max(temperature) from devices where devgroup=~/[1-7][0-9]/; +select max(temperature) from devices where devgroup=~/[1-8][0-9]/; +select max(temperature) from devices where devgroup=~/[1-9][0-9]/; +select max(temperature) from devices; +select min(temperature) from devices where devgroup=~/[1-1][0-9]/; +select min(temperature) from devices where devgroup=~/[1-2][0-9]/; +select min(temperature) from devices where devgroup=~/[1-3][0-9]/; +select min(temperature) from devices where devgroup=~/[1-4][0-9]/; +select min(temperature) from devices where devgroup=~/[1-5][0-9]/; +select min(temperature) from devices where devgroup=~/[1-6][0-9]/; +select min(temperature) from devices where devgroup=~/[1-7][0-9]/; +select min(temperature) from devices where devgroup=~/[1-8][0-9]/; +select min(temperature) from devices where devgroup=~/[1-9][0-9]/; +select min(temperature) from devices; +select spread(temperature) from devices where devgroup=~/[1-1][0-9]/; +select spread(temperature) from devices where devgroup=~/[1-2][0-9]/; +select spread(temperature) from devices where devgroup=~/[1-3][0-9]/; +select spread(temperature) from devices where devgroup=~/[1-4][0-9]/; +select spread(temperature) from devices where devgroup=~/[1-5][0-9]/; +select spread(temperature) from devices where devgroup=~/[1-6][0-9]/; +select spread(temperature) from devices where devgroup=~/[1-7][0-9]/; +select spread(temperature) from devices where devgroup=~/[1-8][0-9]/; +select spread(temperature) from devices where devgroup=~/[1-9][0-9]/; +select spread(temperature) from devices; diff --git a/tests/comparisonTest/influxdb/q3.txt b/tests/comparisonTest/influxdb/q3.txt new file mode 100644 index 0000000000000000000000000000000000000000..ecfe80d4016d1c80749bd549b7b6ef1527a50832 --- /dev/null +++ b/tests/comparisonTest/influxdb/q3.txt @@ -0,0 +1,10 @@ +select count(temperature), sum(temperature), mean(temperature) from devices where devgroup=~/[1-1][0-9]/ group by devgroup; +select count(temperature), sum(temperature), mean(temperature) from devices where devgroup=~/[1-2][0-9]/ group by devgroup; +select count(temperature), sum(temperature), mean(temperature) from devices where devgroup=~/[1-3][0-9]/ group by devgroup; +select count(temperature), sum(temperature), mean(temperature) from devices where devgroup=~/[1-4][0-9]/ group by devgroup; +select count(temperature), sum(temperature), mean(temperature) from devices where devgroup=~/[1-5][0-9]/ group by devgroup; +select count(temperature), sum(temperature), mean(temperature) from devices where devgroup=~/[1-6][0-9]/ group by devgroup; +select count(temperature), sum(temperature), mean(temperature) from devices where devgroup=~/[1-7][0-9]/ group by devgroup; +select count(temperature), sum(temperature), mean(temperature) from devices where devgroup=~/[1-8][0-9]/ group by devgroup; +select count(temperature), sum(temperature), mean(temperature) from devices where devgroup=~/[1-9][0-9]/ group by devgroup; +select count(temperature), sum(temperature), mean(temperature) from devices group by devgroup; diff --git a/tests/comparisonTest/influxdb/q4.txt b/tests/comparisonTest/influxdb/q4.txt new file mode 100644 index 0000000000000000000000000000000000000000..d18869ebdab71314e8d85140cf7ab6c603ccc2fe --- /dev/null +++ b/tests/comparisonTest/influxdb/q4.txt @@ -0,0 +1,10 @@ +select count(temperature), sum(temperature), mean(temperature) from devices where devgroup=~/[1-1][0-9]/ group by time(1m); +select count(temperature), sum(temperature), mean(temperature) from devices where devgroup=~/[1-2][0-9]/ group by time(1m); +select count(temperature), sum(temperature), mean(temperature) from devices where devgroup=~/[1-3][0-9]/ group by time(1m); +select count(temperature), sum(temperature), mean(temperature) from devices where devgroup=~/[1-4][0-9]/ group by time(1m); +select count(temperature), sum(temperature), mean(temperature) from devices where devgroup=~/[1-5][0-9]/ group by time(1m); +select count(temperature), sum(temperature), mean(temperature) from devices where devgroup=~/[1-6][0-9]/ group by time(1m); +select count(temperature), sum(temperature), mean(temperature) from devices where devgroup=~/[1-7][0-9]/ group by time(1m); +select count(temperature), sum(temperature), mean(temperature) from devices where devgroup=~/[1-8][0-9]/ group by time(1m); +select count(temperature), sum(temperature), mean(temperature) from devices where devgroup=~/[1-9][0-9]/ group by time(1m); +select count(temperature), sum(temperature), mean(temperature) from devices group by time(1m); diff --git a/tests/comparisonTest/opentsdb/opentsdbtest/pom.xml b/tests/comparisonTest/opentsdb/opentsdbtest/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..b55a136c7393c2faa857edec801a27721a1eff20 --- /dev/null +++ b/tests/comparisonTest/opentsdb/opentsdbtest/pom.xml @@ -0,0 +1,285 @@ + + + + 4.0.0 + + com.opentsdb.test + opentsdbtest + 1.0-SNAPSHOT + jar + + + + + org.apache.maven.plugins + maven-plugins + 30 + + + org.apache.maven.plugins + maven-assembly-plugin + 3.0.0 + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.1.0 + + + + OpentsdbTest + + + + jar-with-dependencies + + + + + make-assembly + package + + single + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + 8 + 8 + + + + + + + opentsdbtest + + http://www.example.com + + + UTF-8 + 1.8 + 1.8 + + + + + net.opentsdb + opentsdb_gwt_theme + 1.0.0 + + + + net.opentsdb + opentsdb + 2.4.0 + + + + junit + junit + 4.13.1 + test + + + + com.google.guava + guava + 30.0-jre + + + + com.google.gwt + gwt-user + 2.6.0 + + + + com.fasterxml.jackson.core + jackson-annotations + 2.9.10 + + + + com.fasterxml.jackson.core + jackson-core + 2.9.10 + + + + com.fasterxml.jackson.core + jackson-databind + 2.10.0.pr1 + + + + io.netty + netty + 3.10.6.Final + + + + com.stumbleupon + async + 1.4.0 + + + + org.apache.commons + commons-math3 + 3.4.1 + + + org.apache.commons + commons-jexl + 2.1.1 + + + org.apache.commons + commons-lang3 + 3.7 + + + org.apache.commons + commons-collections4 + 4.3 + + + + org.apache.httpcomponents + httpasyncclient + 4.1.3 + + + org.apache.httpcomponents + httpclient + 4.5.13 + + + + org.jgrapht + jgrapht-core + 0.9.1 + + + + com.esotericsoftware.kryo + kryo + 2.21.1 + + + + com.datastax.oss + java-driver-core + 4.1.0 + + + + com.datastax.oss + java-driver-query-builder + 4.1.0 + + + + com.datastax.oss + java-driver-mapper-runtime + 4.1.0 + + + + commons-io + commons-io + 2.7 + + + + org.slf4j + slf4j-api + 1.7.25 + + + + org.apache.logging.log4j + log4j-1.2-api + 2.8.2 + + + + ch.qos.logback + logback-core + 1.2.0 + + + + ch.qos.logback + logback-classic + 1.2.0 + + + + org.projectlombok + lombok + 1.18.0 + + + + com.github.eulery + opentsdb-java-sdk + 1.1.4 + + + + + + + + hbase + + true + + + + + org.hbase + asynchbase + 1.8.2 + + + + org.apache.zookeeper + zookeeper + 3.4.14 + + + log4j + log4j + + + org.slf4j + slf4j-log4j12 + + + jline + jline + + + junit + junit + + + + + + + + + diff --git a/tests/comparisonTest/opentsdb/opentsdbtest/src/main/java/com/opentsdb/test/OpentsdbTest.java b/tests/comparisonTest/opentsdb/opentsdbtest/src/main/java/com/opentsdb/test/OpentsdbTest.java new file mode 100644 index 0000000000000000000000000000000000000000..0e82c480ece8063bd78090d4bb67d87ffa698cc3 --- /dev/null +++ b/tests/comparisonTest/opentsdb/opentsdbtest/src/main/java/com/opentsdb/test/OpentsdbTest.java @@ -0,0 +1,473 @@ +import com.stumbleupon.async.Callback; +import com.stumbleupon.async.Deferred; + +import net.opentsdb.core.TSDB; +import net.opentsdb.uid.NoSuchUniqueName; +import net.opentsdb.uid.UniqueId.UniqueIdType; +import net.opentsdb.utils.Config; + +import java.net.URL; +import org.apache.commons.lang3.StringUtils; +import org.apache.http.HttpResponse; +import org.apache.http.client.ResponseHandler; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.concurrent.FutureCallback; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.nio.client.CloseableHttpAsyncClient; + + +import java.io.BufferedWriter; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileWriter; +import java.io.FileReader; +import java.io.IOException; +import java.nio.charset.Charset; +import java.text.DecimalFormat; +import java.util.Random; +import java.util.ArrayList; +import java.util.List; +import java.util.LinkedHashMap; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.*; +import java.math.*; +import java.lang.reflect.Method; + +import org.apache.log4j.Logger; +import org.apache.log4j.LogManager; +import org.apache.log4j.Level; + + +public class OpentsdbTest{ + //static { System.setProperty("logback.configurationFile", "/home/ubuntu/fang/opentsdb/opentsdbtest/logback.xml");} + static { System.setProperty("logback.configurationFile", "/etc/opentsdb/logback.xml");} + + public static void main(String args[]) { + + Logger logger = LogManager.getLogger(OpentsdbTest.class); + logger.setLevel(Level.OFF); + // begin to parse argument + String datadir = "/home/ubuntu/testdata"; + String sqlchoice = "q1"; + int numOfRows = 1000000; + int numOfFiles = 0; + int numOfClients = 1; + int rowsPerRequest = 1; + for (int i = 0; i < args.length; ++i) { + if (args[i].equalsIgnoreCase("-dataDir")) { + if (i < args.length - 1) { + datadir = args[++i]; + } + } else if (args[i].equalsIgnoreCase("-numofFiles")) { + if (i < args.length - 1) { + numOfFiles = Integer.parseInt(args[++i]); + } + } else if (args[i].equalsIgnoreCase("-rowsPerRequest")) { + if (i < args.length - 1) { + rowsPerRequest = Integer.parseInt(args[++i]); + } + } else if (args[i].equalsIgnoreCase("-writeClients")) { + if (i < args.length - 1) { + numOfClients = Integer.parseInt(args[++i]); + } + } else if (args[i].equalsIgnoreCase("-sql")) { + sqlchoice = args[++i]; + } + } + System.out.println("parameters:\n"); + + + if (numOfFiles >0) { + // write data + System.out.printf("----dataDir:%s\n", datadir); + System.out.printf("----numOfFiles:%d\n", numOfFiles); + System.out.printf("----numOfClients:%d\n", numOfClients); + System.out.printf("----rowsPerRequest:%d\n", rowsPerRequest); + try { + // begin to insert data + System.out.printf("----begin to insert data\n"); + long startTime = System.currentTimeMillis(); + int a = numOfFiles/numOfClients; + int b = numOfFiles%numOfClients; + int last = 0; + + WriteThread[] writethreads = new WriteThread[numOfClients]; + int[] wargs = new int[2]; // data file start, end + wargs[0] = numOfRows; //rows to be read from each file + wargs[1] = rowsPerRequest; + int fstart =0; + int fend =0; + for (int i = 0; i + + + + + + + + %date [%thread] %-5level %logger{80} - %msg%n + + + + + UTF-8 + + ${logbase}%d{yyyy-MM-dd}.log.html + ${logbase}.%d{yyyy-MM-dd}.log.html.zip + + + + 2MB + + + %date%level%thread%10logger%file%line%msg + + + + + + + + + + + + + + + diff --git a/tests/comparisonTest/tdengine/CMakeLists.txt b/tests/comparisonTest/tdengine/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..0f389c4c0cefd10fe829d86342bc391cffe37901 --- /dev/null +++ b/tests/comparisonTest/tdengine/CMakeLists.txt @@ -0,0 +1,12 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8...3.20) +PROJECT(TDengine) + +IF (TD_LINUX) + add_executable(tdengineTest tdengineTest.c) + target_link_libraries(tdengineTest taos_static tutil common pthread) +ENDIF() + +IF (TD_DARWIN) + add_executable(tdengineTest tdengineTest.c) + target_link_libraries(tdengineTest taos_static tutil common pthread) +ENDIF() diff --git a/tests/comparisonTest/tdengine/makefile b/tests/comparisonTest/tdengine/makefile new file mode 100644 index 0000000000000000000000000000000000000000..6ee90e51a358f484fbb6055880ab9d4cfe21f46c --- /dev/null +++ b/tests/comparisonTest/tdengine/makefile @@ -0,0 +1,14 @@ +ROOT=./ +TARGET=exe +LFLAGS = '-Wl,-rpath,/usr/lib' -ltaos -lpthread -lm -lrt +CFLAGS = -O3 -g -Wall -Wno-deprecated -fPIC -Wno-unused-result -Wconversion -Wno-char-subscripts -D_REENTRANT -Wno-format -D_REENTRANT -DLINUX -msse4.2 -Wno-unused-function -D_M_X64 -std=gnu99 + +all: $(TARGET) + +exe: + gcc $(CFLAGS) ./tdengineTest.c -o $(ROOT)/tdengineTest $(LFLAGS) + +clean: + rm $(ROOT)tdengineTest + + \ No newline at end of file diff --git a/tests/comparisonTest/tdengine/q1.txt b/tests/comparisonTest/tdengine/q1.txt new file mode 100644 index 0000000000000000000000000000000000000000..dbe5d78a3f8d3bb00f9438860588fd5ba9057ee2 --- /dev/null +++ b/tests/comparisonTest/tdengine/q1.txt @@ -0,0 +1,11 @@ +select * from db.devices where devgroup=0; +select * from db.devices where devgroup=10; +select * from db.devices where devgroup=20; +select * from db.devices where devgroup=30; +select * from db.devices where devgroup=40; +select * from db.devices where devgroup=50; +select * from db.devices where devgroup=60; +select * from db.devices where devgroup=70; +select * from db.devices where devgroup=80; +select * from db.devices where devgroup=90; + diff --git a/tests/comparisonTest/tdengine/q2.txt b/tests/comparisonTest/tdengine/q2.txt new file mode 100644 index 0000000000000000000000000000000000000000..95d8a9e26170f99ea43250d224b4f6bde8a29c05 --- /dev/null +++ b/tests/comparisonTest/tdengine/q2.txt @@ -0,0 +1,61 @@ +select count(*) from db.devices where devgroup<10; +select count(*) from db.devices where devgroup<20; +select count(*) from db.devices where devgroup<30; +select count(*) from db.devices where devgroup<40; +select count(*) from db.devices where devgroup<50; +select count(*) from db.devices where devgroup<60; +select count(*) from db.devices where devgroup<70; +select count(*) from db.devices where devgroup<80; +select count(*) from db.devices where devgroup<90; +select count(*) from db.devices; +select avg(temperature) from db.devices where devgroup<10; +select avg(temperature) from db.devices where devgroup<20; +select avg(temperature) from db.devices where devgroup<30; +select avg(temperature) from db.devices where devgroup<40; +select avg(temperature) from db.devices where devgroup<50; +select avg(temperature) from db.devices where devgroup<60; +select avg(temperature) from db.devices where devgroup<70; +select avg(temperature) from db.devices where devgroup<80; +select avg(temperature) from db.devices where devgroup<90; +select avg(temperature) from db.devices; +select sum(temperature) from db.devices where devgroup<10; +select sum(temperature) from db.devices where devgroup<20; +select sum(temperature) from db.devices where devgroup<30; +select sum(temperature) from db.devices where devgroup<40; +select sum(temperature) from db.devices where devgroup<50; +select sum(temperature) from db.devices where devgroup<60; +select sum(temperature) from db.devices where devgroup<70; +select sum(temperature) from db.devices where devgroup<80; +select sum(temperature) from db.devices where devgroup<90; +select sum(temperature) from db.devices; +select max(temperature) from db.devices where devgroup<10; +select max(temperature) from db.devices where devgroup<20; +select max(temperature) from db.devices where devgroup<30; +select max(temperature) from db.devices where devgroup<40; +select max(temperature) from db.devices where devgroup<50; +select max(temperature) from db.devices where devgroup<60; +select max(temperature) from db.devices where devgroup<70; +select max(temperature) from db.devices where devgroup<80; +select max(temperature) from db.devices where devgroup<90; +select max(temperature) from db.devices; +select min(temperature) from db.devices where devgroup<10; +select min(temperature) from db.devices where devgroup<20; +select min(temperature) from db.devices where devgroup<30; +select min(temperature) from db.devices where devgroup<40; +select min(temperature) from db.devices where devgroup<50; +select min(temperature) from db.devices where devgroup<60; +select min(temperature) from db.devices where devgroup<70; +select min(temperature) from db.devices where devgroup<80; +select min(temperature) from db.devices where devgroup<90; +select min(temperature) from db.devices; +select spread(temperature) from db.devices where devgroup<10; +select spread(temperature) from db.devices where devgroup<20; +select spread(temperature) from db.devices where devgroup<30; +select spread(temperature) from db.devices where devgroup<40; +select spread(temperature) from db.devices where devgroup<50; +select spread(temperature) from db.devices where devgroup<60; +select spread(temperature) from db.devices where devgroup<70; +select spread(temperature) from db.devices where devgroup<80; +select spread(temperature) from db.devices where devgroup<90; +select spread(temperature) from db.devices; + diff --git a/tests/comparisonTest/tdengine/q3.txt b/tests/comparisonTest/tdengine/q3.txt new file mode 100644 index 0000000000000000000000000000000000000000..e2def2d66ce26f39c3139e7748812a3137fe0b46 --- /dev/null +++ b/tests/comparisonTest/tdengine/q3.txt @@ -0,0 +1,11 @@ +select count(temperature), sum(temperature), avg(temperature) from db.devices where devgroup<10 group by devgroup; +select count(temperature), sum(temperature), avg(temperature) from db.devices where devgroup<20 group by devgroup; +select count(temperature), sum(temperature), avg(temperature) from db.devices where devgroup<30 group by devgroup; +select count(temperature), sum(temperature), avg(temperature) from db.devices where devgroup<40 group by devgroup; +select count(temperature), sum(temperature), avg(temperature) from db.devices where devgroup<50 group by devgroup; +select count(temperature), sum(temperature), avg(temperature) from db.devices where devgroup<60 group by devgroup; +select count(temperature), sum(temperature), avg(temperature) from db.devices where devgroup<70 group by devgroup; +select count(temperature), sum(temperature), avg(temperature) from db.devices where devgroup<80 group by devgroup; +select count(temperature), sum(temperature), avg(temperature) from db.devices where devgroup<90 group by devgroup; +select count(temperature), sum(temperature), avg(temperature) from db.devices group by devgroup; + diff --git a/tests/comparisonTest/tdengine/q4.txt b/tests/comparisonTest/tdengine/q4.txt new file mode 100644 index 0000000000000000000000000000000000000000..7fb3a3ffdbe92b3435db1c9ac14dd35a8c69aadb --- /dev/null +++ b/tests/comparisonTest/tdengine/q4.txt @@ -0,0 +1,11 @@ +select count(temperature), sum(temperature), avg(temperature) from db.devices where devgroup<10 interval(1m); +select count(temperature), sum(temperature), avg(temperature) from db.devices where devgroup<20 interval(1m); +select count(temperature), sum(temperature), avg(temperature) from db.devices where devgroup<30 interval(1m); +select count(temperature), sum(temperature), avg(temperature) from db.devices where devgroup<40 interval(1m); +select count(temperature), sum(temperature), avg(temperature) from db.devices where devgroup<50 interval(1m); +select count(temperature), sum(temperature), avg(temperature) from db.devices where devgroup<60 interval(1m); +select count(temperature), sum(temperature), avg(temperature) from db.devices where devgroup<70 interval(1m); +select count(temperature), sum(temperature), avg(temperature) from db.devices where devgroup<80 interval(1m); +select count(temperature), sum(temperature), avg(temperature) from db.devices where devgroup<90 interval(1m); +select count(temperature), sum(temperature), avg(temperature) from db.devices interval(1m); + diff --git a/tests/comparisonTest/tdengine/q5.txt b/tests/comparisonTest/tdengine/q5.txt new file mode 100644 index 0000000000000000000000000000000000000000..5f36955dd6a426cd3fae0a15d264facf4633502f --- /dev/null +++ b/tests/comparisonTest/tdengine/q5.txt @@ -0,0 +1 @@ +select * from db.devices; diff --git a/tests/comparisonTest/tdengine/tdengineTest.c b/tests/comparisonTest/tdengine/tdengineTest.c new file mode 100644 index 0000000000000000000000000000000000000000..0de419e036f6af1e1808492fbb9f7b41d785b8df --- /dev/null +++ b/tests/comparisonTest/tdengine/tdengineTest.c @@ -0,0 +1,455 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef struct { + char sql[256]; + char dataDir[256]; + int filesNum; + int clients; + int rowsPerRequest; + int write; +} ProArgs; + +typedef struct { + int64_t totalRows; +} StatisInfo; + +typedef struct { + pthread_t pid; + int threadId; + int sID; + int eID; +} ThreadObj; + +static StatisInfo statis; +static ProArgs arguments; + +void parseArg(int argc, char *argv[]); + +void writeData(); + +void readData(); + +int main(int argc, char *argv[]) { + statis.totalRows = 0; + parseArg(argc, argv); + + if (arguments.write) { + writeData(); + } else { + readData(); + } +} + +void parseArg(int argc, char *argv[]) { + strcpy(arguments.sql, "./sqlCmd.txt"); + strcpy(arguments.dataDir, "./testdata"); + arguments.filesNum = 2; + arguments.clients = 1; + arguments.rowsPerRequest = 100; + + for (int i = 1; i < argc; ++i) { + if (strcmp(argv[i], "-sql") == 0) { + if (i < argc - 1) { + strcpy(arguments.sql, argv[++i]); + } + else { + fprintf(stderr, "'-sql' requires a parameter, default:%s\n", arguments.sql); + exit(EXIT_FAILURE); + } + } + else if (strcmp(argv[i], "-dataDir") == 0) { + if (i < argc - 1) { + strcpy(arguments.dataDir, argv[++i]); + } + else { + fprintf(stderr, "'-dataDir' requires a parameter, default:%s\n", arguments.dataDir); + exit(EXIT_FAILURE); + } + } + else if (strcmp(argv[i], "-numOfFiles") == 0) { + if (i < argc - 1) { + arguments.filesNum = atoi(argv[++i]); + } + else { + fprintf(stderr, "'-numOfFiles' requires a parameter, default:%d\n", arguments.filesNum); + exit(EXIT_FAILURE); + } + } + else if (strcmp(argv[i], "-clients") == 0) { + if (i < argc - 1) { + arguments.clients = atoi(argv[++i]); + } + else { + fprintf(stderr, "'-clients' requires a parameter, default:%d\n", arguments.clients); + exit(EXIT_FAILURE); + } + } + else if (strcmp(argv[i], "-rowsPerRequest") == 0) { + if (i < argc - 1) { + arguments.rowsPerRequest = atoi(argv[++i]); + } + else { + fprintf(stderr, "'-rowsPerRequest' requires a parameter, default:%d\n", arguments.rowsPerRequest); + exit(EXIT_FAILURE); + } + } + else if (strcmp(argv[i], "-w") == 0) { + arguments.write = 1; + } + } +} + +static void taos_error(TAOS_RES *tres, TAOS *conn) { + printf("TDengine error: %s\n", tres?taos_errstr(tres):"null result"); + taos_close(conn); + exit(1); +} + +int64_t getTimeStampMs() { + struct timeval systemTime; + gettimeofday(&systemTime, NULL); + return (int64_t)systemTime.tv_sec * 1000L + (int64_t)systemTime.tv_usec / 1000; +} + +void writeDataImp(void *param) { + ThreadObj *pThread = (ThreadObj *)param; + printf("Thread %d, writing sID %d, eID %d\n", pThread->threadId, pThread->sID, pThread->eID); + + void *taos = taos_connect("127.0.0.1", "root", "taosdata", NULL, 0); + if (taos == NULL) { + // where to find errstr? + // taos_error(NULL, taos); + printf("TDengine error: %s\n", "failed to connect"); + exit(1); + } + + TAOS_RES* result = taos_query(taos, "use db"); + int32_t code = taos_errno(result); + if (code != 0) { + taos_error(result, taos); + } + taos_free_result(result); + + char *sql = calloc(1, 8*1024*1024); + int sqlLen = 0; + int lastMachineid = 0; + int counter = 0; + int totalRecords = 0; + + for (int j = pThread->sID; j <= pThread->eID; j++) { + char fileName[300]; + sprintf(fileName, "%s/testdata%d.csv", arguments.dataDir, j); + + FILE *fp = fopen(fileName, "r"); + if (fp == NULL) { + printf("failed to open file %s\n", fileName); + exit(1); + } + printf("open file %s success\n", fileName); + + char *line = NULL; + size_t len = 0; + while (!feof(fp)) { + free(line); + line = NULL; + len = 0; + + getline(&line, &len, fp); + if (line == NULL) break; + + if (strlen(line) < 10) continue; + int machineid; + char machinename[16]; + int machinegroup; + int64_t timestamp; + int temperature; + float humidity; + sscanf(line, "%d%s%d%" PRId64 "%d%f", &machineid, machinename, &machinegroup, ×tamp, &temperature, &humidity); + + if (counter == 0) { + sqlLen = sprintf(sql, "insert into"); + } + + if (lastMachineid != machineid) { + lastMachineid = machineid; + sqlLen += sprintf(sql + sqlLen, " dev%d values", + machineid); + } + + sqlLen += sprintf(sql + sqlLen, "(%" PRId64 ",%d,%f)", timestamp, temperature, humidity); + counter++; + + if (counter >= arguments.rowsPerRequest) { + result = taos_query(taos, sql); + code = taos_errno(result); + if (code != 0) { + printf("insert into dev%d values (%" PRId64 ",%d,%f)\n",machineid, timestamp, temperature, humidity); + printf("thread:%d error:%d reason:%s\n", pThread->threadId, code, taos_errstr(result)); + } + taos_free_result(result); + + totalRecords += counter; + counter = 0; + lastMachineid = -1; + sqlLen = 0; + } + } + + fclose(fp); + } + + if (counter > 0) { + result = taos_query(taos, sql); + code = taos_errno(result); + if (code != 0) { + // printf("insert into dev%d using devices tags(%d,'%s',%d) values (%" PRId64 ",%d,%f)",machineid, machineid, machinename, machinegroup, timestamp, temperature, humidity); + printf("thread:%d error:%d reason:%s\n", pThread->threadId, code, taos_errstr(taos)); + } + taos_free_result(result); + + totalRecords += counter; + } + + __sync_fetch_and_add(&statis.totalRows, totalRecords); + free(sql); +} + +void writeData() { + printf("write data\n"); + printf("---- clients: %d\n", arguments.clients); + printf("---- dataDir: %s\n", arguments.dataDir); + printf("---- numOfFiles: %d\n", arguments.filesNum); + printf("---- rowsPerRequest: %d\n", arguments.rowsPerRequest); + + taos_init(); + + void *taos = taos_connect("127.0.0.1", "root", "taosdata", NULL, 0); + if (taos == NULL) { + // where to find errstr? + // taos_error(NULL, taos); + printf("TDengine error: %s\n", "failed to connect"); + exit(1); + } + + TAOS_RES *result = taos_query(taos, "create database if not exists db"); + int32_t code = taos_errno(result); + if (code != 0) { + taos_error(result, taos); + } + taos_free_result(result); + + result = taos_query(taos, + "create stable if not exists db.devices(ts timestamp, temperature int, humidity float) " + "tags(devid int, devname binary(16), devgroup int)"); + code = taos_errno(result); + if (code != 0) { + taos_error(result, taos); + } + taos_free_result(result); + + //create tables before insert the data + result = taos_query(taos, "use db"); + code = taos_errno(result); + if (code != 0) { + taos_error(result, taos); + } + taos_free_result(result); + + char *sql = calloc(1, 8*1024*1024); + int sqlLen = 0; + int lastMachineid = 0; + int counter = 0; + int totalRecords = 0; + for (int i = 0; i < arguments.filesNum; i++) { + char fileName[300]; + sprintf(fileName, "%s/testdata%d.csv", arguments.dataDir, i); + + FILE *fp = fopen(fileName, "r"); + if (fp == NULL) { + printf("failed to open file %s\n", fileName); + exit(1); + } + printf("open file %s success\n", fileName); + + char *line = NULL; + size_t len = 0; + while (!feof(fp)) { + free(line); + line = NULL; + len = 0; + + getline(&line, &len, fp); + if (line == NULL) break; + + if (strlen(line) < 10) continue; + + int machineid; + char machinename[16]; + int machinegroup; + int64_t timestamp; + int temperature; + float humidity; + sscanf(line, "%d%s%d%" PRId64 "%d%f", &machineid, machinename, &machinegroup, ×tamp, &temperature, &humidity); + + if (counter == 0) { + sqlLen = sprintf(sql, "create table if not exists"); + } + + if (lastMachineid != machineid) { + lastMachineid = machineid; + sqlLen += sprintf(sql + sqlLen, " dev%d using devices tags(%d,'%s',%d)", machineid, machineid, machinename, machinegroup); + } + counter++; + + if (counter >= arguments.rowsPerRequest) { + result = taos_query(taos, sql); + code = taos_errno(result); + if (code != 0) { + printf("create table error:%d reason:%s\n", code, taos_errstr(result)); + } + taos_free_result(result); + + totalRecords += counter; + counter = 0; + lastMachineid = -1; + sqlLen = 0; + } + } + fclose(fp); + } + + int64_t st = getTimeStampMs(); + + int a = arguments.filesNum / arguments.clients; + int b = arguments.filesNum % arguments.clients; + int last = 0; + + ThreadObj *threads = calloc((size_t)arguments.clients, sizeof(ThreadObj)); + for (int i = 0; i < arguments.clients; ++i) { + ThreadObj *pthread = threads + i; + pthread_attr_t thattr; + pthread->threadId = i + 1; + pthread->sID = last; + if (i < b) { + pthread->eID = last + a; + } else { + pthread->eID = last + a - 1; + } + last = pthread->eID + 1; + pthread_attr_init(&thattr); + pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_JOINABLE); + pthread_create(&pthread->pid, &thattr, (void *(*)(void *))writeDataImp, pthread); + } + + for (int i = 0; i < arguments.clients; i++) { + pthread_join(threads[i].pid, NULL); + } + + int64_t elapsed = getTimeStampMs() - st; + float seconds = (float)elapsed / 1000; + float rs = (float)statis.totalRows / seconds; + + free(threads); + + printf("---- Spent %f seconds to insert %" PRId64 " records, speed: %f Rows/Second\n", seconds, statis.totalRows, rs); +} + +void readDataImp(void *param) +{ + ThreadObj *pThread = (ThreadObj *)param; + printf("Thread %d\n", pThread->threadId); + FILE *fp = fopen(arguments.sql, "r"); + if (fp == NULL) { + printf("failed to open file %s\n", arguments.sql); + exit(1); + } + printf("open file %s success\n", arguments.sql); + + void *taos = taos_connect("127.0.0.1", "root", "taosdata", NULL, 0); + if (taos == NULL) { + // where to find errstr? + // taos_error(NULL, taos); + printf("TDengine error: %s\n", "failed to connect"); + exit(1); + } + + char *line = NULL; + size_t len = 0; + while (!feof(fp)) { + free(line); + line = NULL; + len = 0; + + getline(&line, &len, fp); + if (line == NULL) break; + + if (strlen(line) < 10) continue; + + int64_t st = getTimeStampMs(); + + TAOS_RES *result = taos_query(taos, line); + int32_t code = taos_errno(result); + if (code != 0) { + taos_error(result, taos); + } + + TAOS_ROW row; + int rows = 0; + //int num_fields = taos_field_count(taos); + //TAOS_FIELD *fields = taos_fetch_fields(result); + while ((row = taos_fetch_row(result))) { + rows++; + //char temp[256]; + //taos_print_row(temp, row, fields, num_fields); + //printf("%s\n", temp); + } + + taos_free_result(result); + + int64_t elapsed = getTimeStampMs() - st; + float seconds = (float)elapsed / 1000; + printf("---- Spent %f seconds to retrieve %d records, Thread:%d query: %s\n", seconds, rows, pThread->threadId, line); + } + + fclose(fp); +} + +void readData() { + printf("read data\n"); + printf("---- sql: %s\n", arguments.sql); + printf("---- clients: %d\n", arguments.clients); + + void *taos = taos_connect("127.0.0.1", "root", "taosdata", NULL, 0); + if (taos == NULL) { + // where to find errstr? + // taos_error(NULL, taos); + printf("TDengine error: %s\n", "failed to connect"); + exit(1); + } + + ThreadObj *threads = calloc((size_t)arguments.clients, sizeof(ThreadObj)); + + for (int i = 0; i < arguments.clients; ++i) { + ThreadObj *pthread = threads + i; + pthread_attr_t thattr; + pthread->threadId = i + 1; + pthread_attr_init(&thattr); + pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_JOINABLE); + pthread_create(&pthread->pid, &thattr, (void *(*)(void *))readDataImp, pthread); + } + + for (int i = 0; i < arguments.clients; i++) { + pthread_join(threads[i].pid, NULL); + } + + free(threads); +} \ No newline at end of file diff --git a/tests/fuzz/sql-fuzzer.c b/tests/fuzz/sql-fuzzer.c new file mode 100644 index 0000000000000000000000000000000000000000..3eb0eed2e76bfb41c26b7456a94b3d91148034ba --- /dev/null +++ b/tests/fuzz/sql-fuzzer.c @@ -0,0 +1,15 @@ +#include "qSqlparser.h" + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size){ + char *new_str = (char *)malloc(size+1); + if (new_str == NULL){ + return 0; + } + memcpy(new_str, data, size); + new_str[size] = '\0'; + + qSqlParse(new_str); + + free(new_str); + return 0; +} diff --git a/tests/gotest/batchtest.bat b/tests/gotest/batchtest.bat new file mode 100755 index 0000000000000000000000000000000000000000..f9e6f83d50b1f1fa04cb18972376b3951447cc81 --- /dev/null +++ b/tests/gotest/batchtest.bat @@ -0,0 +1,28 @@ + +@echo off +echo ==== start Go connector test cases test ==== +cd /d %~dp0 + +set severIp=%1 +set serverPort=%2 +if "%severIp%"=="" (set severIp=127.0.0.1) +if "%serverPort%"=="" (set serverPort=6030) + +go env -w GO111MODULE=on +go env -w GOPROXY=https://goproxy.cn,direct + +cd case001 +case001.bat %severIp% %serverPort% + +rem cd case002 +rem case002.bat + +:: cd case002 +:: case002.bat + + +rem cd nanosupport +rem nanoCase.bat + +:: cd nanosupport +:: nanoCase.bat diff --git a/tests/gotest/batchtest.sh b/tests/gotest/batchtest.sh new file mode 100755 index 0000000000000000000000000000000000000000..046249bcf7e8abab57d43b6b6e268361ccc1a695 --- /dev/null +++ b/tests/gotest/batchtest.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +echo "==== start Go connector test cases test ====" + +severIp=$1 +serverPort=$2 + +if [ ! -n "$severIp" ]; then + severIp=127.0.0.1 +fi + +if [ ! -n "$serverPort" ]; then + serverPort=6030 +fi + +go env -w GO111MODULE=on +go env -w GOPROXY=https://goproxy.cn,direct + +bash ./case001/case001.sh $severIp $serverPort +bash ./case002/case002.sh $severIp $serverPort +#bash ./case003/case003.sh $severIp $serverPort +bash ./nanosupport/nanoCase.sh $severIp $serverPort diff --git a/tests/gotest/case001/case001.bat b/tests/gotest/case001/case001.bat new file mode 100644 index 0000000000000000000000000000000000000000..ebec576e724ccb14319dd380c9783a783ac0db62 --- /dev/null +++ b/tests/gotest/case001/case001.bat @@ -0,0 +1,9 @@ +@echo off +echo ==== start run cases001.go + +del go.* +go mod init demotest +go build +demotest.exe -h %1 -p %2 +cd .. + diff --git a/tests/gotest/case001/case001.go b/tests/gotest/case001/case001.go new file mode 100644 index 0000000000000000000000000000000000000000..29bc92f2a0668b3f576145d5bd6d08ed37c82f1b --- /dev/null +++ b/tests/gotest/case001/case001.go @@ -0,0 +1,344 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package main + +import ( + "database/sql" + "flag" + "fmt" + _ "github.com/taosdata/driver-go/v2/taosSql" + "log" + "strconv" + "time" +) + +type config struct { + hostName string + serverPort int + user string + password string +} + +var configPara config +var url string + +func init() { + flag.StringVar(&configPara.hostName, "h", "127.0.0.1","The host to connect to TDengine server.") + flag.IntVar(&configPara.serverPort, "p", 6030, "The TCP/IP port number to use for the connection to TDengine server.") + flag.StringVar(&configPara.user, "u", "root", "The TDengine user name to use when connecting to the server.") + flag.StringVar(&configPara.password, "P", "taosdata", "The password to use when connecting to the server.") + + flag.Parse() +} + +func printAllArgs() { + fmt.Printf("\n============= args parse result: =============\n") + fmt.Printf("hostName: %v\n", configPara.hostName) + fmt.Printf("serverPort: %v\n", configPara.serverPort) + fmt.Printf("usr: %v\n", configPara.user) + fmt.Printf("password: %v\n", configPara.password) + fmt.Printf("================================================\n") +} + +func main() { + printAllArgs() + taosDriverName := "taosSql" + demodb := "demodb" + demot := "demot" + + fmt.Printf("\n======== start demo test ========\n") + + url = "root:taosdata@/tcp(" + configPara.hostName + ":" + strconv.Itoa(configPara.serverPort) + ")/" + // open connect to taos server + fmt.Printf("url:%s",url) + db, err := sql.Open(taosDriverName, url) + if err != nil { + log.Fatalf("Open database error: %s\n", err) + } + defer db.Close() + + drop_database(db, demodb) + create_database(db, demodb) + use_database(db, demodb) + create_table(db, demot) + insert_data(db, demot) + select_data(db, demot) + + fmt.Printf("\n======== start stmt mode test ========\n") + + demodbStmt := "demodbStmt" + demotStmt := "demotStmt" + drop_database_stmt(db, demodbStmt) + create_database_stmt(db, demodbStmt) + use_database_stmt(db, demodbStmt) + create_table_stmt(db, demotStmt) + insert_data_stmt(db, demotStmt) + select_data_stmt(db, demotStmt) + + fmt.Printf("\n======== end demo test ========\n") +} + +func drop_database(db *sql.DB, demodb string) { + st := time.Now().Nanosecond() + res, err := db.Exec("drop database if exists " + demodb) + checkErr(err, "drop database if exists "+demodb) + + affectd, err := res.RowsAffected() + checkErr(err, "drop db, res.RowsAffected") + + et := time.Now().Nanosecond() + + fmt.Printf("drop database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) + + //sleep 50毫秒 + time.Sleep(time.Duration(50)* time.Millisecond) +} + +func create_database(db *sql.DB, demodb string) { + st := time.Now().Nanosecond() + // create database + res, err := db.Exec("create database " + demodb) + checkErr(err, "create db, db.Exec") + + affectd, err := res.RowsAffected() + checkErr(err, "create db, res.RowsAffected") + + et := time.Now().Nanosecond() + + fmt.Printf("create database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) + + return +} + +func use_database(db *sql.DB, demodb string) { + st := time.Now().Nanosecond() + // use database + res, err := db.Exec("use " + demodb) // notes: must no quote to db name + checkErr(err, "use db db.Exec") + + affectd, err := res.RowsAffected() + checkErr(err, "use db, res.RowsAffected") + + et := time.Now().Nanosecond() + + fmt.Printf("use database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) +} + +func create_table(db *sql.DB, demot string) { + st := time.Now().Nanosecond() + // create table + res, err := db.Exec("create table " + demot + " (ts timestamp, id int, name binary(8), len tinyint, flag bool, notes binary(8), fv float, dv double)") + checkErr(err, "create table db.Exec") + + affectd, err := res.RowsAffected() + checkErr(err, "create table res.RowsAffected") + + et := time.Now().Nanosecond() + fmt.Printf("create table result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) +} + +func insert_data(db *sql.DB, demot string) { + st := time.Now().Nanosecond() + // insert data + res, err := db.Exec("insert into " + demot + + " values (now, 100, 'beijing', 10, true, 'one', 123.456, 123.456)" + + " (now+1s, 101, 'shanghai', 11, true, 'two', 789.123, 789.123)" + + " (now+2s, 102, 'shenzhen', 12, false, 'three', 456.789, 456.789)") + + checkErr(err, "insert data, db.Exec") + + affectd, err := res.RowsAffected() + checkErr(err, "insert data res.RowsAffected") + + et := time.Now().Nanosecond() + fmt.Printf("insert data result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) +} + +func select_data(db *sql.DB, demot string) { + st := time.Now().Nanosecond() + fmt.Println(demot) + rows, err := db.Query("select * from ? ", demot) // go text mode + fmt.Println("end query",err) + checkErr(err, "select db.Query") + + fmt.Printf("%10s%s%8s %5s %9s%s %s %8s%s %7s%s %8s%s %4s%s %5s%s\n", " ", "ts", " ", "id", " ", "name", " ", "len", " ", "flag", " ", "notes", " ", "fv", " ", " ", "dv") + var affectd int + + //decoder := mahonia.NewDecoder("gbk") // 把原来ANSI格式的文本文件里的字符,用gbk进行解码。 + fmt.Println("start next") + for rows.Next() { + var ts time.Time + var name string + var id int + var len int8 + var flag bool + var notes string + var fv float32 + var dv float64 + + err = rows.Scan(&ts, &id, &name, &len, &flag, ¬es, &fv, &dv) + fmt.Println("rows:",err) + checkErr(err, "select rows.Scan") + + fmt.Printf("%s|\t", ts) + fmt.Printf("%d|\t", id) + fmt.Printf("%10s|\t", name) + fmt.Printf("%d|\t", len) + fmt.Printf("%t|\t", flag) + fmt.Printf("%s|\t", notes) + fmt.Printf("%06.3f|\t", fv) + fmt.Printf("%09.6f|\n\n", dv) + + affectd++ + } + + et := time.Now().Nanosecond() + fmt.Printf("select data result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) + //fmt.Printf("insert data result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1E9) +} + +func drop_database_stmt(db *sql.DB, demodb string) { + st := time.Now().Nanosecond() + // drop test db + res, err := db.Exec("drop database if exists " + demodb) + checkErr(err, "drop database "+demodb) + + affectd, err := res.RowsAffected() + checkErr(err, "drop db, res.RowsAffected") + + et := time.Now().Nanosecond() + fmt.Printf("drop database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) +} + +func create_database_stmt(db *sql.DB, demodb string) { + st := time.Now().Nanosecond() + // create database + //var stmt interface{} + stmt, err := db.Prepare("create database ?") + checkErr(err, "create db, db.Prepare") + + //var res driver.Result + res, err := stmt.Exec(demodb) + checkErr(err, "create db, stmt.Exec") + + //fmt.Printf("Query OK, %d row(s) affected()", res.RowsAffected()) + affectd, err := res.RowsAffected() + checkErr(err, "create db, res.RowsAffected") + + et := time.Now().Nanosecond() + fmt.Printf("create database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) +} + +func use_database_stmt(db *sql.DB, demodb string) { + st := time.Now().Nanosecond() + // create database + //var stmt interface{} + stmt, err := db.Prepare("use " + demodb) + checkErr(err, "use db, db.Prepare") + + res, err := stmt.Exec() + checkErr(err, "use db, stmt.Exec") + + affectd, err := res.RowsAffected() + checkErr(err, "use db, res.RowsAffected") + + et := time.Now().Nanosecond() + fmt.Printf("use database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) +} + +func create_table_stmt(db *sql.DB, demot string) { + st := time.Now().Nanosecond() + // create table + // (ts timestamp, id int, name binary(8), len tinyint, flag bool, notes binary(8), fv float, dv double) + stmt, err := db.Prepare("create table ? (? timestamp, ? int, ? binary(10), ? tinyint, ? bool, ? binary(8), ? float, ? double)") + checkErr(err, "create table db.Prepare") + + res, err := stmt.Exec(demot, "ts", "id", "name", "len", "flag", "notes", "fv", "dv") + checkErr(err, "create table stmt.Exec") + + affectd, err := res.RowsAffected() + checkErr(err, "create table res.RowsAffected") + + et := time.Now().Nanosecond() + fmt.Printf("create table result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) +} + +func insert_data_stmt(db *sql.DB, demot string) { + st := time.Now().Nanosecond() + // insert data into table + stmt, err := db.Prepare("insert into ? values(?, ?, ?, ?, ?, ?, ?, ?) (?, ?, ?, ?, ?, ?, ?, ?) (?, ?, ?, ?, ?, ?, ?, ?)") + checkErr(err, "insert db.Prepare") + + res, err := stmt.Exec(demot, "now", 1000, "'haidian'", 6, true, "'AI world'", 6987.654, 321.987, + "now+1s", 1001, "'changyang'", 7, false, "'DeepMode'", 12356.456, 128634.456, + "now+2s", 1002, "'chuangping'", 8, true, "'database'", 3879.456, 65433478.456) + checkErr(err, "insert data, stmt.Exec") + + affectd, err := res.RowsAffected() + checkErr(err, "res.RowsAffected") + + et := time.Now().Nanosecond() + fmt.Printf("insert data result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) +} + +func select_data_stmt(db *sql.DB, demot string) { + st := time.Now().Nanosecond() + + stmt, err := db.Prepare("select ?, ?, ?, ?, ?, ?, ?, ? from ?") // go binary mode + checkErr(err, "db.Prepare") + + rows, err := stmt.Query("ts", "id", "name", "len", "flag", "notes", "fv", "dv", demot) + checkErr(err, "stmt.Query") + + fmt.Printf("%10s%s%8s %5s %8s%s %s %10s%s %7s%s %8s%s %11s%s %14s%s\n", " ", "ts", " ", "id", " ", "name", " ", "len", " ", "flag", " ", "notes", " ", "fv", " ", " ", "dv") + var affectd int + for rows.Next() { + var ts string + var name string + var id int + var len int8 + var flag bool + var notes string + var fv float32 + var dv float64 + + err = rows.Scan(&ts, &id, &name, &len, &flag, ¬es, &fv, &dv) + //fmt.Println("start scan fields from row.rs, &fv:", &fv) + //err = rows.Scan(&fv) + checkErr(err, "rows.Scan") + + fmt.Printf("%s|\t", ts) + fmt.Printf("%d|\t", id) + fmt.Printf("%10s|\t", name) + fmt.Printf("%d|\t", len) + fmt.Printf("%t|\t", flag) + fmt.Printf("%s|\t", notes) + fmt.Printf("%06.3f|\t", fv) + fmt.Printf("%09.6f|\n", dv) + + affectd++ + + } + + et := time.Now().Nanosecond() + fmt.Printf("select data result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) +} + +func checkErr(err error, prompt string) { + if err != nil { + fmt.Printf("%s\n", prompt) + panic(err) + } +} diff --git a/tests/gotest/case001/case001.sh b/tests/gotest/case001/case001.sh new file mode 100644 index 0000000000000000000000000000000000000000..831e9f83ac482c0a2c668e2ad0d16c4bf59f19aa --- /dev/null +++ b/tests/gotest/case001/case001.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +echo "==== start run cases001.go" + +set +e +#set -x + +script_dir="$(dirname $(readlink -f $0))" +#echo "pwd: $script_dir, para0: $0" + +#execName=$0 +#execName=`echo ${execName##*/}` +#goName=`echo ${execName%.*}` + +###### step 3: start build +cd $script_dir +rm -f go.* +go mod init demotest +go build +sleep 1s +./demotest -h $1 -p $2 diff --git a/tests/gotest/case002/case002.bat b/tests/gotest/case002/case002.bat new file mode 100644 index 0000000000000000000000000000000000000000..385677acae826e248a410472bfc7a022ff3003ab --- /dev/null +++ b/tests/gotest/case002/case002.bat @@ -0,0 +1,9 @@ +@echo off +echo ==== start run cases002.go + +del go.* +go mod init demotest +go build +demotest.exe -h %1 -p %2 +cd .. + diff --git a/tests/gotest/case002/case002.go b/tests/gotest/case002/case002.go new file mode 100644 index 0000000000000000000000000000000000000000..e2ba5ea28ee4f92cfbdca27c78d47268a387c693 --- /dev/null +++ b/tests/gotest/case002/case002.go @@ -0,0 +1,80 @@ +package main + +import ( + "database/sql/driver" + "fmt" + "io" + "os" + "time" + + taos "github.com/taosdata/driver-go/v2/af" +) + +func Subscribe_check(topic taos.Subscriber, check int) bool { + count := 0 + rows, err := topic.Consume() + defer func() { rows.Close(); time.Sleep(time.Second) }() + if err != nil { + fmt.Println(err) + os.Exit(3) + } + for { + values := make([]driver.Value, 2) + err := rows.Next(values) + if err == io.EOF { + break + } else if err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(4) + } + count++ + } + if count == check { + return false + } else { + return true + } +} +func main() { + ts := 1630461600000 + db, err := taos.Open("127.0.0.1", "", "", "", 0) + if err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } + defer db.Close() + db.Exec("drop database if exists test") + db.Exec("create database if not exists test ") + db.Exec("use test") + db.Exec("create table test (ts timestamp ,level int)") + for i := 0; i < 10; i++ { + sqlcmd := fmt.Sprintf("insert into test values(%d,%d)", ts+i, i) + db.Exec(sqlcmd) + } + + fmt.Println("consumption 01.") + topic, err := db.Subscribe(false, "test", "select ts, level from test", time.Second) + if Subscribe_check(topic, 10) { + os.Exit(3) + } + + fmt.Println("consumption 02: no new rows inserted") + if Subscribe_check(topic, 0) { + os.Exit(3) + } + + fmt.Println("consumption 03: after one new rows inserted") + sqlcmd := fmt.Sprintf("insert into test values(%d,%d)", ts+10, 10) + db.Exec(sqlcmd) + if Subscribe_check(topic, 1) { + os.Exit(3) + } + + fmt.Println("consumption 04: keep progress and continue previous subscription") + topic.Unsubscribe(true) + topic, err = db.Subscribe(false, "test", "select ts, level from test", time.Second) + if Subscribe_check(topic, 0) { + os.Exit(3) + } + +} diff --git a/tests/gotest/case002/case002.sh b/tests/gotest/case002/case002.sh new file mode 100644 index 0000000000000000000000000000000000000000..d98337cce7cfeb51ec9305226b20abdd7b360a46 --- /dev/null +++ b/tests/gotest/case002/case002.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +echo "==== start run cases002.go" + +set +e +#set -x + +script_dir="$(dirname $(readlink -f $0))" +#echo "pwd: $script_dir, para0: $0" + +#execName=$0 +#execName=`echo ${execName##*/}` +#goName=`echo ${execName%.*}` + +###### step 3: start build +cd $script_dir +rm -f go.* +go mod init demotest > /dev/null 2>&1 +go mod tidy > /dev/null 2>&1 +go build > /dev/null 2>&1 +sleep 1s +./demotest -h $1 -p $2 diff --git a/tests/gotest/nanosupport/connector/executor.go b/tests/gotest/nanosupport/connector/executor.go new file mode 100644 index 0000000000000000000000000000000000000000..218ea29af3b34a8cfb5ab56585eeb07bc467d209 --- /dev/null +++ b/tests/gotest/nanosupport/connector/executor.go @@ -0,0 +1,208 @@ +package connector + +import ( + "context" + "fmt" + "reflect" + "time" + + "github.com/taosdata/go-utils/log" + "github.com/taosdata/go-utils/tdengine/config" + "github.com/taosdata/go-utils/tdengine/connector" + tdengineExecutor "github.com/taosdata/go-utils/tdengine/executor" +) + +type Executor struct { + executor *tdengineExecutor.Executor + ctx context.Context +} + +var Logger = log.NewLogger("taos test") + +func NewExecutor(conf *config.TDengineGo, db string, showSql bool) (*Executor, error) { + tdengineConnector, err := connector.NewTDengineConnector("go", conf) + if err != nil { + return nil, err + } + executor := tdengineExecutor.NewExecutor(tdengineConnector, db, showSql, Logger) + return &Executor{ + executor: executor, + ctx: context.Background(), + }, nil +} + +func (e *Executor) Execute(sql string) (int64, error) { + return e.executor.DoExec(e.ctx, sql) +} +func (e *Executor) Query(sql string) (*connector.Data, error) { + fmt.Println("query :", sql) + return e.executor.DoQuery(e.ctx, sql) +} +func (e *Executor) CheckData(row, col int, value interface{}, data *connector.Data) (bool, error) { + if data == nil { + return false, fmt.Errorf("data is nil") + } + if col >= len(data.Head) { + return false, fmt.Errorf("col out of data") + } + if row >= len(data.Data) { + return false, fmt.Errorf("row out of data") + } + dataValue := data.Data[row][col] + + if dataValue == nil && value != nil { + return false, fmt.Errorf("dataValue is nil but value is not nil") + } + if dataValue == nil && value == nil { + return true, nil + } + if reflect.TypeOf(dataValue) != reflect.TypeOf(value) { + return false, fmt.Errorf("type not match expect %s got %s", reflect.TypeOf(value), reflect.TypeOf(dataValue)) + } + switch value.(type) { + case time.Time: + t, _ := dataValue.(time.Time) + if value.(time.Time).Nanosecond() != t.Nanosecond() { + return false, fmt.Errorf("value not match expect %d got %d", value.(time.Time).Nanosecond(), t.Nanosecond()) + } + case string: + if value.(string) != dataValue.(string) { + return false, fmt.Errorf("value not match expect %s got %s", value.(string), dataValue.(string)) + } + case int8: + if value.(int8) != dataValue.(int8) { + return false, fmt.Errorf("value not match expect %d got %d", value.(int8), dataValue.(int8)) + } + case int16: + if value.(int16) != dataValue.(int16) { + return false, fmt.Errorf("value not match expect %d got %d", value.(int16), dataValue.(int16)) + } + case int32: + if value.(int32) != dataValue.(int32) { + return false, fmt.Errorf("value not match expect %d got %d", value.(int32), dataValue.(int32)) + } + case int64: + if value.(int64) != dataValue.(int64) { + return false, fmt.Errorf("value not match expect %d got %d", value.(int64), dataValue.(int64)) + } + case float32: + if value.(float32) != dataValue.(float32) { + return false, fmt.Errorf("value not match expect %f got %f", value.(float32), dataValue.(float32)) + } + case float64: + if value.(float64) != dataValue.(float64) { + return false, fmt.Errorf("value not match expect %f got %f", value.(float32), dataValue.(float32)) + } + case bool: + if value.(bool) != dataValue.(bool) { + return false, fmt.Errorf("value not match expect %t got %t", value.(bool), dataValue.(bool)) + } + default: + return false, fmt.Errorf("unsupport type %v", reflect.TypeOf(value)) + } + return true, nil +} + +func (e *Executor) CheckData2(row, col int, value interface{}, data *connector.Data) { + + match, err := e.CheckData(row, col, value, data) + fmt.Println("expect data is :", value) + fmt.Println("go got data is :", data.Data[row][col]) + if err != nil { + fmt.Println(err) + } + if !match { + fmt.Println(" data not match") + + } + + /* + fmt.Println(value) + if data == nil { + // return false, fmt.Errorf("data is nil") + // fmt.Println("check failed") + } + if col >= len(data.Head) { + // return false, fmt.Errorf("col out of data") + // fmt.Println("check failed") + } + if row >= len(data.Data) { + // return false, fmt.Errorf("row out of data") + // fmt.Println("check failed") + } + dataValue := data.Data[row][col] + + if dataValue == nil && value != nil { + // return false, fmt.Errorf("dataValue is nil but value is not nil") + // fmt.Println("check failed") + } + if dataValue == nil && value == nil { + // return true, nil + fmt.Println("check pass") + } + if reflect.TypeOf(dataValue) != reflect.TypeOf(value) { + // return false, fmt.Errorf("type not match expect %s got %s", reflect.TypeOf(value), reflect.TypeOf(dataValue)) + fmt.Println("check failed") + } + switch value.(type) { + case time.Time: + t, _ := dataValue.(time.Time) + if value.(time.Time).Nanosecond() != t.Nanosecond() { + // return false, fmt.Errorf("value not match expect %d got %d", value.(time.Time).Nanosecond(), t.Nanosecond()) + // fmt.Println("check failed") + } + case string: + if value.(string) != dataValue.(string) { + // return false, fmt.Errorf("value not match expect %s got %s", value.(string), dataValue.(string)) + // fmt.Println("check failed") + } + case int8: + if value.(int8) != dataValue.(int8) { + // return false, fmt.Errorf("value not match expect %d got %d", value.(int8), dataValue.(int8)) + // fmt.Println("check failed") + } + case int16: + if value.(int16) != dataValue.(int16) { + // return false, fmt.Errorf("value not match expect %d got %d", value.(int16), dataValue.(int16)) + // fmt.Println("check failed") + } + case int32: + if value.(int32) != dataValue.(int32) { + // return false, fmt.Errorf("value not match expect %d got %d", value.(int32), dataValue.(int32)) + // fmt.Println("check failed") + } + case int64: + if value.(int64) != dataValue.(int64) { + // return false, fmt.Errorf("value not match expect %d got %d", value.(int64), dataValue.(int64)) + // fmt.Println("check failed") + } + case float32: + if value.(float32) != dataValue.(float32) { + // return false, fmt.Errorf("value not match expect %f got %f", value.(float32), dataValue.(float32)) + // fmt.Println("check failed") + } + case float64: + if value.(float64) != dataValue.(float64) { + // return false, fmt.Errorf("value not match expect %f got %f", value.(float32), dataValue.(float32)) + // fmt.Println("check failed") + } + case bool: + if value.(bool) != dataValue.(bool) { + // return false, fmt.Errorf("value not match expect %t got %t", value.(bool), dataValue.(bool)) + // fmt.Println("check failed") + } + default: + // return false, fmt.Errorf("unsupport type %v", reflect.TypeOf(value)) + // fmt.Println("check failed") + } + // return true, nil + // fmt.Println("check pass") + */ +} + +func (e *Executor) CheckRow(count int, data *connector.Data) { + + if len(data.Data) != count { + fmt.Println("check failed !") + } +} diff --git a/tests/gotest/nanosupport/nanoCase.bat b/tests/gotest/nanosupport/nanoCase.bat new file mode 100644 index 0000000000000000000000000000000000000000..86bddd5b02c5399d5b8d70bd08020e96a7d1c0e5 --- /dev/null +++ b/tests/gotest/nanosupport/nanoCase.bat @@ -0,0 +1,9 @@ +@echo off +echo ==== start run nanosupport.go + +del go.* +go mod init nano +go mod tidy +go build +nano.exe -h %1 -p %2 +cd .. diff --git a/tests/gotest/nanosupport/nanoCase.sh b/tests/gotest/nanosupport/nanoCase.sh new file mode 100644 index 0000000000000000000000000000000000000000..bec8929f14c0a56e7c4074efa39d1e1e881fb12e --- /dev/null +++ b/tests/gotest/nanosupport/nanoCase.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +echo "==== start run nanosupport.go " + +set +e +#set -x + +script_dir="$(dirname $(readlink -f $0))" +#echo "pwd: $script_dir, para0: $0" + +#execName=$0 +#execName=`echo ${execName##*/}` +#goName=`echo ${execName%.*}` + +###### step 3: start build +cd $script_dir +rm -f go.* +go mod init nano +go mod tidy +go build +sleep 10s +./nano -h $1 -p $2 diff --git a/tests/gotest/nanosupport/nanosupport.go b/tests/gotest/nanosupport/nanosupport.go new file mode 100644 index 0000000000000000000000000000000000000000..e2f24a73c0a6db3c94b90879c73d0f05e2476307 --- /dev/null +++ b/tests/gotest/nanosupport/nanosupport.go @@ -0,0 +1,269 @@ +package main + +import ( + "fmt" + "log" + "nano/connector" + "time" + + "github.com/taosdata/go-utils/tdengine/config" +) + +func main() { + e, err := connector.NewExecutor(&config.TDengineGo{ + Address: "root:taosdata@/tcp(127.0.0.1:6030)/", + MaxIdle: 20, + MaxOpen: 30, + MaxLifetime: 30, + }, "db", false) + if err != nil { + panic(err) + } + prepareData(e) + data, err := e.Query("select * from tb") + if err != nil { + panic(err) + } + + layout := "2006-01-02 15:04:05.999999999" + t0, _ := time.Parse(layout, "2021-06-10 00:00:00.100000001") + t1, _ := time.Parse(layout, "2021-06-10 00:00:00.150000000") + t2, _ := time.Parse(layout, "2021-06-10 00:00:00.299999999") + t3, _ := time.Parse(layout, "2021-06-10 00:00:00.300000000") + t4, _ := time.Parse(layout, "2021-06-10 00:00:00.300000001") + t5, _ := time.Parse(layout, "2021-06-10 00:00:00.999999999") + + e.CheckData2(0, 0, t0, data) + e.CheckData2(1, 0, t1, data) + e.CheckData2(2, 0, t2, data) + e.CheckData2(3, 0, t3, data) + e.CheckData2(4, 0, t4, data) + e.CheckData2(5, 0, t5, data) + e.CheckData2(3, 1, int32(3), data) + e.CheckData2(4, 1, int32(5), data) + e.CheckData2(5, 1, int32(7), data) + + fmt.Println(" start check nano support!") + + data, _ = e.Query("select count(*) from tb where ts > 1623254400100000000 and ts < 1623254400100000002;") + e.CheckData2(0, 0, int64(1), data) + + data, _ = e.Query("select count(*) from tb where ts > \"2021-06-10 0:00:00.100000001\" and ts < \"2021-06-10 0:00:00.160000000\";") + e.CheckData2(0, 0, int64(1), data) + + data, _ = e.Query("select count(*) from tb where ts > 1623254400100000000 and ts < 1623254400150000000;") + e.CheckData2(0, 0, int64(1), data) + data, _ = e.Query("select count(*) from tb where ts > \"2021-06-10 0:00:00.100000000\" and ts < \"2021-06-10 0:00:00.150000000\";") + e.CheckData2(0, 0, int64(1), data) + + data, _ = e.Query("select count(*) from tb where ts > 1623254400400000000;") + e.CheckData2(0, 0, int64(1), data) + data, _ = e.Query("select count(*) from tb where ts < \"2021-06-10 00:00:00.400000000\";") + e.CheckData2(0, 0, int64(5), data) + + data, _ = e.Query("select count(*) from tb where ts < now + 400000000b;") + e.CheckData2(0, 0, int64(6), data) + + data, _ = e.Query("select count(*) from tb where ts >= \"2021-06-10 0:00:00.100000001\";") + e.CheckData2(0, 0, int64(6), data) + + data, _ = e.Query("select count(*) from tb where ts <= 1623254400300000000;") + e.CheckData2(0, 0, int64(4), data) + + data, _ = e.Query("select count(*) from tb where ts = \"2021-06-10 0:00:00.000000000\";") + + data, _ = e.Query("select count(*) from tb where ts = 1623254400150000000;") + e.CheckData2(0, 0, int64(1), data) + + data, _ = e.Query("select count(*) from tb where ts = \"2021-06-10 0:00:00.100000001\";") + e.CheckData2(0, 0, int64(1), data) + + data, _ = e.Query("select count(*) from tb where ts between 1623254400000000000 and 1623254400400000000;") + e.CheckData2(0, 0, int64(5), data) + + data, _ = e.Query("select count(*) from tb where ts between \"2021-06-10 0:00:00.299999999\" and \"2021-06-10 0:00:00.300000001\";") + e.CheckData2(0, 0, int64(3), data) + + data, _ = e.Query("select avg(speed) from tb interval(5000000000b);") + e.CheckRow(1, data) + + data, _ = e.Query("select avg(speed) from tb interval(100000000b)") + e.CheckRow(4, data) + + data, _ = e.Query("select avg(speed) from tb interval(1000b);") + e.CheckRow(5, data) + + data, _ = e.Query("select avg(speed) from tb interval(1u);") + e.CheckRow(5, data) + + data, _ = e.Query("select avg(speed) from tb interval(100000000b) sliding (100000000b);") + e.CheckRow(4, data) + + data, _ = e.Query("select last(*) from tb") + tt, _ := time.Parse(layout, "2021-06-10 0:00:00.999999999") + e.CheckData2(0, 0, tt, data) + + data, _ = e.Query("select first(*) from tb") + tt1, _ := time.Parse(layout, "2021-06-10 0:00:00.100000001") + e.CheckData2(0, 0, tt1, data) + + e.Execute("insert into tb values(now + 500000000b, 6);") + data, _ = e.Query("select * from tb;") + e.CheckRow(7, data) + + e.Execute("create table tb2 (ts timestamp, speed int, ts2 timestamp);") + e.Execute("insert into tb2 values(\"2021-06-10 0:00:00.100000001\", 1, \"2021-06-11 0:00:00.100000001\");") + e.Execute("insert into tb2 values(1623254400150000000, 2, 1623340800150000000);") + e.Execute("import into tb2 values(1623254400300000000, 3, 1623340800300000000);") + e.Execute("import into tb2 values(1623254400299999999, 4, 1623340800299999999);") + e.Execute("insert into tb2 values(1623254400300000001, 5, 1623340800300000001);") + e.Execute("insert into tb2 values(1623254400999999999, 7, 1623513600999999999);") + + data, _ = e.Query("select * from tb2;") + tt2, _ := time.Parse(layout, "2021-06-10 0:00:00.100000001") + tt3, _ := time.Parse(layout, "2021-06-10 0:00:00.150000000") + + e.CheckData2(0, 0, tt2, data) + e.CheckData2(1, 0, tt3, data) + e.CheckData2(2, 1, int32(4), data) + e.CheckData2(3, 1, int32(3), data) + tt4, _ := time.Parse(layout, "2021-06-11 00:00:00.300000001") + e.CheckData2(4, 2, tt4, data) + e.CheckRow(6, data) + + data, _ = e.Query("select count(*) from tb2 where ts2 > 1623340800000000000 and ts2 < 1623340800150000000;") + e.CheckData2(0, 0, int64(1), data) + + data, _ = e.Query("select count(*) from tb2 where ts2 > \"2021-06-11 0:00:00.100000000\" and ts2 < \"2021-06-11 0:00:00.100000002\";") + e.CheckData2(0, 0, int64(1), data) + + data, _ = e.Query("select count(*) from tb2 where ts2 > 1623340800500000000;") + e.CheckData2(0, 0, int64(1), data) + data, _ = e.Query("select count(*) from tb2 where ts2 < \"2021-06-11 0:00:00.400000000\";") + e.CheckData2(0, 0, int64(5), data) + + data, _ = e.Query("select count(*) from tb2 where ts2 < now + 400000000b;") + e.CheckData2(0, 0, int64(6), data) + + data, _ = e.Query("select count(*) from tb2 where ts2 >= \"2021-06-11 0:00:00.100000001\";") + e.CheckData2(0, 0, int64(6), data) + + data, _ = e.Query("select count(*) from tb2 where ts2 <= 1623340800400000000;") + e.CheckData2(0, 0, int64(5), data) + + data, _ = e.Query("select count(*) from tb2 where ts2 = \"2021-06-11 0:00:00.000000000\";") + + data, _ = e.Query("select count(*) from tb2 where ts2 = \"2021-06-11 0:00:00.300000001\";") + e.CheckData2(0, 0, int64(1), data) + + data, _ = e.Query("select count(*) from tb2 where ts2 = 1623340800300000001;") + e.CheckData2(0, 0, int64(1), data) + + data, _ = e.Query("select count(*) from tb2 where ts2 between 1623340800000000000 and 1623340800450000000;") + e.CheckData2(0, 0, int64(5), data) + + data, _ = e.Query("select count(*) from tb2 where ts2 between \"2021-06-11 0:00:00.299999999\" and \"2021-06-11 0:00:00.300000001\";") + e.CheckData2(0, 0, int64(3), data) + + data, _ = e.Query("select count(*) from tb2 where ts2 <> 1623513600999999999;") + e.CheckData2(0, 0, int64(5), data) + + data, _ = e.Query("select count(*) from tb2 where ts2 <> \"2021-06-11 0:00:00.100000001\";") + e.CheckData2(0, 0, int64(5), data) + + data, _ = e.Query("select count(*) from tb2 where ts2 <> \"2021-06-11 0:00:00.100000000\";") + e.CheckData2(0, 0, int64(6), data) + + data, _ = e.Query("select count(*) from tb2 where ts2 != 1623513600999999999;") + e.CheckData2(0, 0, int64(5), data) + + data, _ = e.Query("select count(*) from tb2 where ts2 != \"2021-06-11 0:00:00.100000001\";") + e.CheckData2(0, 0, int64(5), data) + + data, _ = e.Query("select count(*) from tb2 where ts2 != \"2021-06-11 0:00:00.100000000\";") + e.CheckData2(0, 0, int64(6), data) + + e.Execute("insert into tb2 values(now + 500000000b, 6, now +2d);") + data, _ = e.Query("select * from tb2;") + e.CheckRow(7, data) + + e.Execute("create table tb3 (ts timestamp, speed int);") + _, err = e.Execute("insert into tb3 values(16232544001500000, 2);") + if err != nil { + fmt.Println("check pass! ") + } + + e.Execute("insert into tb3 values(\"2021-06-10 0:00:00.123456\", 2);") + data, _ = e.Query("select * from tb3 where ts = \"2021-06-10 0:00:00.123456000\";") + e.CheckRow(1, data) + + e.Execute("insert into tb3 values(\"2021-06-10 0:00:00.123456789000\", 2);") + data, _ = e.Query("select * from tb3 where ts = \"2021-06-10 0:00:00.123456789\";") + e.CheckRow(1, data) + + // check timezone support + + e.Execute("drop database if exists nsdb;") + e.Execute("create database nsdb precision 'ns';") + e.Execute("use nsdb;") + e.Execute("create stable st (ts timestamp ,speed float ) tags(time timestamp ,id int);") + e.Execute("insert into tb1 using st tags('2021-06-10 0:00:00.123456789' , 1 ) values('2021-06-10T0:00:00.123456789+07:00' , 1.0);") + data, _ = e.Query("select first(*) from tb1;") + + ttt, _ := time.Parse(layout, "2021-06-10 01:00:00.123456789") + e.CheckData2(0, 0, ttt, data) + + e.Execute("create database usdb precision 'us';") + e.Execute("use usdb;") + e.Execute("create stable st (ts timestamp ,speed float ) tags(time timestamp ,id int);") + e.Execute("insert into tb1 using st tags('2021-06-10 0:00:00.123456' , 1 ) values('2021-06-10T0:00:00.123456+07:00' , 1.0);") + data, _ = e.Query("select first(*) from tb1;") + ttt2, _ := time.Parse(layout, "2021-06-10 01:00:00.123456") + e.CheckData2(0, 0, ttt2, data) + + e.Execute("drop database if exists msdb;") + e.Execute("create database msdb precision 'ms';") + e.Execute("use msdb;") + e.Execute("create stable st (ts timestamp ,speed float ) tags(time timestamp ,id int);") + e.Execute("insert into tb1 using st tags('2021-06-10 0:00:00.123' , 1 ) values('2021-06-10T0:00:00.123+07:00' , 1.0);") + data, _ = e.Query("select first(*) from tb1;") + ttt3, _ := time.Parse(layout, "2021-06-10 01:00:00.123") + e.CheckData2(0, 0, ttt3, data) + fmt.Println("all test done!") + +} + +func prepareData(e *connector.Executor) { + sqlList := []string{ + "reset query cache;", + "drop database if exists db;", + "create database db;", + "use db;", + "reset query cache;", + "drop database if exists db;", + "create database db precision 'ns';", + "show databases;", + "use db;", + "create table tb (ts timestamp, speed int);", + "insert into tb values('2021-06-10 0:00:00.100000001', 1);", + "insert into tb values(1623254400150000000, 2);", + "import into tb values(1623254400300000000, 3);", + "import into tb values(1623254400299999999, 4);", + "insert into tb values(1623254400300000001, 5);", + "insert into tb values(1623254400999999999, 7);", + } + for _, sql := range sqlList { + err := executeSql(e, sql) + if err != nil { + log.Fatalf("prepare data error:%v, sql:%s", err, sql) + } + } +} + +func executeSql(e *connector.Executor, sql string) error { + _, err := e.Execute(sql) + if err != nil { + return err + } + return nil +} diff --git a/tests/gotest/test.sh b/tests/gotest/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..fe80d4429546513521286db657a961e0ca8ffc14 --- /dev/null +++ b/tests/gotest/test.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +################################################## +# +# Do go test +# +################################################## + +set +e +#set -x + +FILE_NAME= +RELEASE=0 +while getopts "f:" arg +do + case $arg in + f) + FILE_NAME=$OPTARG + echo "input file: $FILE_NAME" + ;; + ?) + echo "unknow argument" + ;; + esac +done + +# start one taosd +bash ../script/sh/stop_dnodes.sh +bash ../script/sh/deploy.sh -n dnode1 -i 1 +bash ../script/sh/cfg.sh -n dnode1 -c walLevel -v 0 +bash ../script/sh/exec.sh -n dnode1 -s start + +# start build test go file +caseDir=`echo ${FILE_NAME%/*}` +echo "caseDir: $caseDir" +cd $caseDir +rm go.* +go mod init $caseDir +go build +sleep 1s +./$caseDir + diff --git a/tests/mas/Jenkinsfile b/tests/mas/Jenkinsfile new file mode 100644 index 0000000000000000000000000000000000000000..84c2d8e4c2d63094812a0ebde7f5f3150f375ccf --- /dev/null +++ b/tests/mas/Jenkinsfile @@ -0,0 +1,336 @@ +def pre_test(){ + + sh ''' + sudo rmtaos||echo 'no taosd installed' + ''' + sh ''' + cd ${WKC} + git reset --hard + git checkout $BRANCH_NAME + git pull + git submodule update + cd ${WK} + git reset --hard + git checkout $BRANCH_NAME + git pull + export TZ=Asia/Harbin + date + rm -rf ${WK}/debug + mkdir debug + cd debug + cmake .. > /dev/null + make > /dev/null + make install > /dev/null + pip3 install ${WKC}/src/connector/python/ || echo 0 + ''' + return 1 +} +def pre_test_p(){ + + sh ''' + sudo rmtaos||echo 'no taosd installed' + ''' + sh ''' + cd ${WKC} + git reset --hard + git checkout $BRANCH_NAME + git pull + git submodule update + cd ${WK} + git reset --hard + git checkout $BRANCH_NAME + git pull + export TZ=Asia/Harbin + date + rm -rf ${WK}/debug + mkdir debug + cd debug + cmake .. > /dev/null + make > /dev/null + make install > /dev/null + pip3 install ${WKC}/src/connector/python/ || echo 0 + ''' + return 1 +} +pipeline { + agent none + environment{ + + WK = '/data/lib/jenkins/workspace/TDinternal' + WKC= '/data/lib/jenkins/workspace/TDinternal/community' + } + + stages { + stage('Parallel test stage') { + parallel { + stage('pytest') { + agent{label 'slam1'} + steps { + pre_test_p() + sh ''' + cd ${WKC}/tests + find pytest -name '*'sql|xargs rm -rf + ./test-all.sh pytest + date''' + } + } + stage('test_b1') { + agent{label 'slam2'} + steps { + pre_test() + + sh ''' + cd ${WKC}/tests + ./test-all.sh b1 + date''' + + + } + } + + stage('test_crash_gen') { + agent{label "slam3"} + steps { + pre_test() + sh ''' + cd ${WKC}/tests/pytest + ''' + catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { + sh ''' + cd ${WKC}/tests/pytest + ./crash_gen.sh -a -p -t 4 -s 2000 + ''' + } + catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { + sh ''' + cd ${WKC}/tests/pytest + rm -rf /var/lib/taos/* + rm -rf /var/log/taos/* + ./handle_crash_gen_val_log.sh + ''' + } + catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { + sh ''' + cd ${WKC}/tests/pytest + rm -rf /var/lib/taos/* + rm -rf /var/log/taos/* + ./handle_taosd_val_log.sh + ''' + } + + sh''' + nohup taosd >/dev/null & + sleep 10 + ''' + catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { + sh ''' + cd ${WKC}/tests/gotest + bash batchtest.sh + ''' + } + catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { + sh ''' + cd ${WKC}/tests/examples/python/PYTHONConnectorChecker + python3 PythonChecker.py + ''' + } + catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { + sh ''' + cd ${WKC}/tests/examples/JDBC/JDBCDemo/ + mvn clean package assembly:single -DskipTests >/dev/null + java -jar target/JDBCDemo-SNAPSHOT-jar-with-dependencies.jar -host 127.0.0.1 + ''' + } + catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { + sh ''' + cd ${WKC}/src/connector/jdbc + mvn clean package -Dmaven.test.skip=true >/dev/null + cd ${WKC}/tests/examples/JDBC/JDBCDemo/ + java --class-path=../../../../src/connector/jdbc/target:$JAVA_HOME/jre/lib/ext -jar target/JDBCDemo-SNAPSHOT-jar-with-dependencies.jar -host 127.0.0.1 + ''' + } + catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { + sh ''' + cp -rf ${WKC}/tests/examples/nodejs ${JENKINS_HOME}/workspace/ + cd ${JENKINS_HOME}/workspace/nodejs + node nodejsChecker.js host=localhost + ''' + } + catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { + sh ''' + cd ${JENKINS_HOME}/workspace/C#NET/src/CheckC# + dotnet run + ''' + } + sh ''' + pkill -9 taosd || echo 1 + cd ${WKC}/tests + ./test-all.sh b2 + date + ''' + sh ''' + cd ${WKC}/tests + ./test-all.sh full unit + date''' + } + } + + stage('test_valgrind') { + agent{label "slam4"} + + steps { + pre_test() + catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { + sh ''' + cd ${WKC}/tests/pytest + nohup taosd >/dev/null & + sleep 10 + python3 concurrent_inquiry.py -c 1 + + ''' + } + sh ''' + cd ${WKC}/tests + ./test-all.sh full jdbc + date''' + sh ''' + cd ${WKC}/tests/pytest + ./valgrind-test.sh 2>&1 > mem-error-out.log + ./handle_val_log.sh + + date + cd ${WKC}/tests + ./test-all.sh b3 + date''' + sh ''' + date + cd ${WKC}/tests + ./test-all.sh full example + date''' + } + } + + stage('arm64_build'){ + agent{label 'arm64'} + steps{ + sh ''' + cd ${WK} + git fetch + git checkout develop + git pull + cd ${WKC} + git fetch + git checkout develop + git pull + git submodule update + cd ${WKC}/packaging + ./release.sh -v cluster -c aarch64 -n 2.0.0.0 -m 2.0.0.0 + + ''' + } + } + stage('arm32_build'){ + agent{label 'arm32'} + steps{ + catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { + sh ''' + cd ${WK} + git fetch + git checkout develop + git pull + cd ${WKC} + git fetch + git checkout develop + git pull + git submodule update + cd ${WKC}/packaging + ./release.sh -v cluster -c aarch32 -n 2.0.0.0 -m 2.0.0.0 + + ''' + } + + } + } + } + } + + } + post { + success { + emailext ( + subject: "SUCCESSFUL: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'", + body: ''' + + + + + + + + + + + + +

+ 构建信息 +
+
    +
    +
  • 构建名称>>分支:${PROJECT_NAME}
  • +
  • 构建结果: Successful
  • +
  • 构建编号:${BUILD_NUMBER}
  • +
  • 触发用户:${CAUSE}
  • +
  • 变更概要:${CHANGES}
  • +
  • 构建地址:${BUILD_URL}
  • +
  • 构建日志:${BUILD_URL}console
  • +
  • 变更集:${JELLY_SCRIPT}
  • +
    +
+
+ + ''', + to: "yqliu@taosdata.com,pxiao@taosdata.com", + from: "support@taosdata.com" + ) + } + failure { + emailext ( + subject: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'", + body: ''' + + + + + + + + + + + + +

+ 构建信息 +
+
    +
    +
  • 构建名称>>分支:${PROJECT_NAME}
  • +
  • 构建结果: Successful
  • +
  • 构建编号:${BUILD_NUMBER}
  • +
  • 触发用户:${CAUSE}
  • +
  • 变更概要:${CHANGES}
  • +
  • 构建地址:${BUILD_URL}
  • +
  • 构建日志:${BUILD_URL}console
  • +
  • 变更集:${JELLY_SCRIPT}
  • +
    +
+
+ + ''', + to: "yqliu@taosdata.com,pxiao@taosdata.com", + from: "support@taosdata.com" + ) + } + } +} \ No newline at end of file diff --git a/tests/nettest/FQDNnettest.sh b/tests/nettest/FQDNnettest.sh new file mode 100755 index 0000000000000000000000000000000000000000..f4ee5d56bce9842537ea9cea224c22dee28e2a7e --- /dev/null +++ b/tests/nettest/FQDNnettest.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +taos -n fqdn diff --git a/tests/parallel_test/Jenkinsfile b/tests/parallel_test/Jenkinsfile new file mode 100644 index 0000000000000000000000000000000000000000..e70087520295e47e608adf561941dcbeae6faa5f --- /dev/null +++ b/tests/parallel_test/Jenkinsfile @@ -0,0 +1,375 @@ +import hudson.model.Result +import hudson.model.*; +import jenkins.model.CauseOfInterruption +node { +} +def sync_source() { + sh ''' + hostname + date + ''' + sh ''' + cd ${WKC} + [ -f src/connector/grafanaplugin/README.md ] && rm -f src/connector/grafanaplugin/README.md > /dev/null || echo "failed to remove grafanaplugin README.md" + git reset --hard HEAD~10 >/dev/null + ''' + script { + if (env.CHANGE_TARGET == 'master') { + sh ''' + cd ${WKC} + git checkout master + ''' + } else if (env.CHANGE_TARGET == '2.0') { + sh ''' + cd ${WKC} + git checkout 2.0 + ''' + } else if (env.CHANGE_TARGET == '2.4') { + sh ''' + cd ${WKC} + git checkout 2.4 + ''' + } else { + sh ''' + cd ${WKC} + git checkout develop + ''' + } + } + sh''' + cd ${WKC} + git remote prune origin + [ -f src/connector/grafanaplugin/README.md ] && rm -f src/connector/grafanaplugin/README.md > /dev/null || echo "failed to remove grafanaplugin README.md" + git pull >/dev/null + git fetch origin +refs/pull/${CHANGE_ID}/merge + git checkout -qf FETCH_HEAD + git clean -dfx + git submodule update --init --recursive + cd ${WK} + git reset --hard HEAD~10 + ''' + script { + if (env.CHANGE_TARGET == 'master') { + sh ''' + cd ${WK} + git checkout master + ''' + } else if (env.CHANGE_TARGET == '2.0') { + sh ''' + cd ${WK} + git checkout 2.0 + ''' + } else if (env.CHANGE_TARGET == '2.4') { + sh ''' + cd ${WK} + git checkout 2.4 + ''' + } else { + sh ''' + cd ${WK} + git checkout develop + ''' + } + } + sh ''' + cd ${WK} + git pull >/dev/null + export TZ=Asia/Harbin + date + git clean -dfx + ''' +} +def pre_test() { + sync_source() + sh ''' + cd ${WK} + mkdir -p debug + cd debug + go env -w GOPROXY=https://goproxy.cn,direct + go env -w GO111MODULE=on + cmake .. -DBUILD_HTTP=false -DBUILD_TOOLS=true > /dev/null + make -j8 >/dev/null + ''' + return 1 +} +def pre_test_mac() { + sync_source() + sh ''' + cd ${WK} + mkdir -p debug + cd debug + go env -w GOPROXY=https://goproxy.cn,direct + go env -w GO111MODULE=on + cmake .. -DBUILD_TOOLS=false > /dev/null + make -j8 >/dev/null + ''' + return 1 +} +pipeline { + agent {label " dispatcher "} + options { skipDefaultCheckout() } + environment{ + WK = '/var/data/jenkins/workspace/TDinternal' + WKC = '/var/data/jenkins/workspace/TDinternal/community' + LOGDIR = '/var/data/jenkins/workspace/log' + } + stages { + stage ('pre_build') { + steps { + sh ''' + date + pwd + env + hostname + ''' + } + } + stage ('Parallel build stage') { + //only build pr + options { skipDefaultCheckout() } + when { + allOf { + changeRequest() + not { expression { env.CHANGE_BRANCH =~ /docs\// }} + } + } + parallel { + stage ('dispatcher sync source') { + steps { + timeout(time: 20, unit: 'MINUTES') { + sync_source() + script { + sh ''' + echo "dispatcher ready" + date + ''' + } + } + } + } + stage ('build worker01') { + agent {label " worker01 "} + steps { + timeout(time: 20, unit: 'MINUTES') { + pre_test() + script { + sh ''' + echo "worker01 build done" + date + ''' + } + } + } + } + stage ('build worker02') { + agent {label " worker02 "} + steps { + timeout(time: 20, unit: 'MINUTES') { + pre_test() + script { + sh ''' + echo "worker02 build done" + date + ''' + } + } + } + } + stage ('build worker03') { + agent {label " worker03 "} + steps { + timeout(time: 20, unit: 'MINUTES') { + pre_test() + script { + sh ''' + echo "worker03 build done" + date + ''' + } + } + } + } + stage ('build worker04') { + agent {label " worker04 "} + steps { + timeout(time: 20, unit: 'MINUTES') { + pre_test() + script { + sh ''' + echo "worker04 build done" + date + ''' + } + } + } + } + stage ('build worker05') { + agent {label " worker05 "} + steps { + timeout(time: 20, unit: 'MINUTES') { + pre_test() + script { + sh ''' + echo "worker05 build done" + date + ''' + } + } + } + } + } + } + stage('run test') { + options { skipDefaultCheckout() } + when { + allOf { + changeRequest() + not { expression { env.CHANGE_BRANCH =~ /docs\// }} + } + } + parallel { + stage ('build worker06_arm64') { + agent {label " worker06_arm64 "} + steps { + timeout(time: 20, unit: 'MINUTES') { + pre_test() + script { + sh ''' + echo "worker06_arm64 build done" + date + ''' + } + } + } + } + stage ('build worker07_arm64') { + agent {label " worker07_arm64 "} + steps { + timeout(time: 20, unit: 'MINUTES') { + pre_test() + script { + sh ''' + echo "worker07_arm64 build done" + date + ''' + } + } + } + } + stage ('build Mac_catalina ') { + agent {label " Mac_catalina "} + steps { + timeout(time: 20, unit: 'MINUTES') { + pre_test_mac() + script { + sh ''' + echo "Mac_catalina build done" + date + ''' + } + } + } + } + stage('run cases') { + steps { + sh ''' + date + hostname + ''' + catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { + timeout(time: 20, unit: 'MINUTES') { + sh ''' + date + cd ${WKC}/tests/parallel_test + time ./run.sh -m m.json -t cases.task -l ${LOGDIR} -b ${BRANCH_NAME} + date + hostname + ''' + } + } + } + } + } + } + } + post { + success { + emailext ( + subject: "PR-result: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' SUCCESS", + body: """ + + + + + + + + + + + + +
+
+ 构建信息 +
+
+
    +
    +
  • 构建名称>>分支:${env.BRANCH_NAME}
  • +
  • 构建结果: Successful
  • +
  • 构建编号:${BUILD_NUMBER}
  • +
  • 触发用户:${env.CHANGE_AUTHOR}
  • +
  • 提交信息:${env.CHANGE_TITLE}
  • +
  • 构建地址:${BUILD_URL}
  • +
  • 构建日志:${BUILD_URL}console
  • +
    +
+
+ + """, + to: "${env.CHANGE_AUTHOR_EMAIL}", + from: "support@taosdata.com" + ) + } + failure { + emailext ( + subject: "PR-result: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' FAIL", + body: """ + + + + + + + + + + + + +
+
+ 构建信息 +
+
+
    +
    +
  • 构建名称>>分支:${env.BRANCH_NAME}
  • +
  • 构建结果: Failure
  • +
  • 构建编号:${BUILD_NUMBER}
  • +
  • 触发用户:${env.CHANGE_AUTHOR}
  • +
  • 提交信息:${env.CHANGE_TITLE}
  • +
  • 构建地址:${BUILD_URL}
  • +
  • 构建日志:${BUILD_URL}console
  • +
    +
+
+ + """, + to: "${env.CHANGE_AUTHOR_EMAIL}", + from: "support@taosdata.com" + ) + } + } +} diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task new file mode 100644 index 0000000000000000000000000000000000000000..6f37b3a22f6792a9adc12a884542ab6be460094a --- /dev/null +++ b/tests/parallel_test/cases.task @@ -0,0 +1,672 @@ +# 20,,pytest,insert/retentionpolicy.py change date time +,2,pytest,python3 ./test.py -f query/nestedQuery/nestedQuery_datacheck.py +305,,pytest,python3 ./test.py -f update/merge_commit_data-0.py +301,,pytest,python3 ./test.py -f update/merge_commit_data.py +258,,script,./test.sh -f general/stream/stream_3.sim +256,,script,./test.sh -f general/stream/restart_stream.sim +245,,pytest,python3 ./test.py -f update/merge_commit_data2.py +224,,pytest,python3 ./test.py -f query/queryNullValueTest.py +210,,pytest,python3 ./test.py -f update/merge_commit_data2_update0.py +198,,pytest,python3 ./test.py -f update/merge_commit_last-0.py +196,,pytest,python3 ./test.py -f update/merge_commit_last.py +172,,pytest,python3 ./test.py -f stream/stream2.py +156,,pytest,python3 ./test.py -f stream/stream1.py +139,,script,./test.sh -f general/stream/stream_restart.sim +137,,script,./test.sh -f unique/vnode/replica3_repeat.sim +135,,pytest,python3 ./test.py -f insert/randomNullCommit.py +129,,pytest,python3 ./test.py -f query/queryConnection.py +127,,script,./test.sh -f general/stream/metrics_replica1_vnoden.sim +126,,script,./test.sh -f general/stream/table_del.sim +125,,script,./test.sh -f general/stream/table_replica1_vnoden.sim +125,,script,./test.sh -f general/stream/metrics_del.sim +113,,pytest,python3 ./test.py -f update/append_commit_last.py +113,,pytest,python3 test.py -f update/append_commit_data.py +112,,pytest,python3 ./test.py -f update/append_commit_last-0.py +111,2,script,./test.sh -f unique/cluster/balance3.sim +110,,script,./test.sh -f unique/vnode/many.sim +110,,script,./test.sh -f general/parser/limit2.sim +101,,script,./test.sh -f general/db/alter_tables_d2.sim +99,,pytest,python3 ./test.py -f query/nestedQuery/nestedQuery.py +95,,script,./test.sh -f unique/vnode/replica2_repeat.sim +91,,script,./test.sh -f unique/cluster/vgroup100.sim +89,,pytest,python3 ./test.py -f functions/function_interp.py +87,,script,./test.sh -f general/parser/repeatAlter.sim +85,,script,./test.sh -f unique/cluster/balance2.sim +84,,script,./test.sh -f unique/big/balance.sim +83,,script,./test.sh -f unique/dnode/balance1.sim +80,,pytest,python3 ./test.py -f query/last_row_cache.py +80,,pytest,python3 ./test.py -f insert/boundary2.py +76,,pytest,python3 ./test.py -f insert/verifyMemToDiskCrash.py +75,,script,./test.sh -f unique/db/replica_reduce32.sim +73,,script,./test.sh -f unique/db/replica_add23.sim +73,,script,./test.sh -f unique/db/replica_add13.sim +72,,script,./test.sh -f general/db/alter_tables_v4.sim +71,,script,./test.sh -f unique/account/usage.sim +67,,script,./test.sh -f unique/cluster/balance1.sim +65,2,script,./test.sh -f unique/dnode/balance3.sim +65,,script,./test.sh -f general/parser/sliding.sim +64,,script,./test.sh -f unique/arbitrator/dn3_mn1_r3_vnode_delDir.sim +63,,script,./test.sh -f unique/mnode/mgmt20.sim +62,2,script,./test.sh -f unique/dnode/m3.sim +62,2,script,./test.sh -f unique/dnode/m2.sim +62,,script,./test.sh -f unique/dnode/data1.sim +61,,script,./test.sh -f unique/mnode/mgmtr2.sim +61,,script,./test.sh -f unique/db/replica_reduce31.sim +61,,script,./test.sh -f issue/TD-2713.sim +61,,script,./test.sh -f general/parser/selectResNum.sim +60,,script,./test.sh -f unique/import/replica3.sim +60,,script,./test.sh -f general/parser/join_manyblocks.sim +60,,script,./test.sh -f general/db/alter_tables_v1.sim +59,,script,./test.sh -f unique/vnode/replica3_basic.sim +59,,script,./test.sh -f unique/dnode/offline2.sim +59,,script,./test.sh -f unique/arbitrator/check_cluster_cfg_para.sim +58,,script,./test.sh -f unique/vnode/replica2_basic2.sim +58,,script,./test.sh -f unique/dnode/balancex.sim +57,,script,./test.sh -f unique/dnode/balance2.sim +57,,script,./test.sh -f unique/db/delete_part.sim +57,,script,./test.sh -f unique/arbitrator/replica_changeWithArbitrator.sim +57,,script,./test.sh -f unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim +57,,script,./test.sh -f unique/arbitrator/dn3_mn1_vnode_delDir.sim +57,,script,./test.sh -f general/parser/where.sim +56,,script,./test.sh -f general/wal/sync.sim +56,,script,./test.sh -f general/parser/first_last.sim +56,,script,./test.sh -f general/db/delete_reuse1.sim +56,,pytest,python3 test.py -f tools/taosdemoAllTest/TD-5213/insert4096columns_not_use_taosdemo.py +56,,pytest,python3 ./test.py -f stream/table_1.py +56,,pytest,python3 ./test.py -f stream/metric_1.py +55,,script,./test.sh -f unique/dnode/vnode_clean.sim +55,,script,./test.sh -f unique/dnode/remove2.sim +55,,script,./test.sh -f general/parser/limit1.sim +55,,script,./test.sh -f general/db/delete_reusevnode.sim +55,,pytest,python3 ./test.py -f stream/table_n.py +53,,script,./test.sh -f unique/db/replica_part.sim +53,,script,./test.sh -f general/parser/limit1_tblocks100.sim +52,,script,./test.sh -f unique/arbitrator/dn3_mn1_replica_change.sim +51,,script,./test.sh -f unique/db/delete.sim +51,,script,./test.sh -f general/db/delete_writing1.sim +50,,pytest,python3 ./test.py -f import_merge/import_update_2.py +49,,script,./test.sh -f unique/mnode/mgmt26.sim +49,,script,./test.sh -f unique/dnode/remove1.sim +49,,script,./test.sh -f unique/db/replica_add12.sim +48,,script,./test.sh -f unique/dnode/datatrans_3node_2.sim +48,,script,./test.sh -f unique/db/commit.sim +48,,script,./test.sh -f general/parser/commit.sim +47,,script,./test.sh -f unique/mnode/mgmt34.sim +47,,script,./test.sh -f unique/mnode/mgmt23.sim +47,,script,./test.sh -f unique/import/replica2.sim +47,,script,./test.sh -f unique/dnode/reason.sim +46,,script,./test.sh -f unique/mnode/mgmt22.sim +46,,pytest,python3 ./test.py -f stream/cqSupportBefore1970.py +45,,script,./test.sh -f general/parser/col_arithmetic_operation.sim +44,,script,./test.sh -f unique/big/tcp.sim +44,,script,./test.sh -f general/parser/topbot.sim +44,,pytest,python3 ./test.py -f stream/metric_n.py +43,,script,./test.sh -f unique/mnode/mgmt24.sim +42,,script,./test.sh -f unique/arbitrator/dn3_mn1_vnode_nomaster.sim +42,,script,./test.sh -f unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim +42,,pytest,python3 ./test.py -f import_merge/import_update_0.py +41,,script,./test.sh -f unique/dnode/datatrans_3node.sim +41,,script,./test.sh -f general/parser/groupby.sim +41,,pytest,python3 ./test.py -f update/allow_update.py +41,,pytest,python3 ./test.py -f import_merge/import_update_1.py +40,,script,./test.sh -f unique/vnode/replica3_vgroup.sim +40,,script,./test.sh -f unique/mnode/mgmt33.sim +40,,script,./test.sh -f unique/dnode/monitor.sim +40,,script,./test.sh -f unique/big/maxvnodes.sim +40,,script,./test.sh -f general/import/replica1.sim +39,,script,./test.sh -f unique/stable/balance_replica1.sim +39,,script,./test.sh -f unique/migrate/mn2_vn2_repl2_rmVnodeDir.sim +39,,script,./test.sh -f unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim +39,,script,./test.sh -f general/parser/union.sim +38,,script,./test.sh -f unique/dnode/lossdata.sim +38,,script,./test.sh -f unique/cluster/alter.sim +38,,script,./test.sh -f general/parser/interp.sim +38,,script,./test.sh -f general/db/delete_reuse2.sim +38,,script,./test.sh -f general/db/alter_vgroups.sim +37,,script,./test.sh -f unique/migrate/mn2_vn2_repl2_rmMnodeDir.sim +37,,script,./test.sh -f unique/dnode/offline3.sim +37,,script,./test.sh -f unique/arbitrator/dn3_mn1_multiCreateDropTable.sim +37,,script,./test.sh -f general/alter/count.sim +36,,script,./test.sh -f unique/dnode/offline1.sim +36,,script,./test.sh -f unique/account/authority.sim +36,,script,./test.sh -f general/table/delete_reuse2.sim +36,,pytest,python3 test.py -f tools/taosdemoTestQuery.py +36,,pytest,python3 ./test.py -f query/select_last_crash.py +35,,script,./test.sh -f unique/arbitrator/sync_replica3_alterTable_drop.sim +35,,script,./test.sh -f unique/arbitrator/sync_replica2_dropTable.sim +35,,script,./test.sh -f unique/arbitrator/sync_replica2_alterTable_add.sim +35,,script,./test.sh -f general/wal/kill.sim +35,,script,./test.sh -f general/wal/kill.sim +35,,script,./test.sh -f general/parser/projection_limit_offset.sim +35,,pytest,python3 ./test.py -f query/last_cache.py +34,,script,./test.sh -f unique/stable/replica3_vnode3.sim +34,,script,./test.sh -f unique/arbitrator/sync_replica2_dropDb.sim +34,,script,./test.sh -f general/table/delete_reuse1.sim +34,,script,./test.sh -f general/insert/insert_drop.sim +34,,pytest,python3 ./test.py -f update/update_options.py +34,,pytest,python3 ./test.py -f insert/flushwhiledrop.py +33,,script,./test.sh -f unique/mnode/mgmt25.sim +33,,script,./test.sh -f unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir.sim +33,,script,./test.sh -f general/db/delete_reusevnode2.sim +32,,script,./test.sh -f unique/mnode/mgmt30.sim +32,,script,./test.sh -f unique/mnode/mgmt21.sim +32,,script,./test.sh -f unique/arbitrator/offline_replica2_createTable_online.sim +32,,pytest,python3 test.py -f tools/taosdemoAllTest/taosdemoTestQueryWithJson.py +31,,script,./test.sh -f unique/dnode/monitor_bug.sim +31,,script,./test.sh -f unique/arbitrator/sync_replica3_dropDb.sim +31,,script,./test.sh -f unique/arbitrator/offline_replica3_alterTable_online.sim +31,,script,./test.sh -f general/parser/tbnameIn.sim +31,,script,./test.sh -f general/db/delete_writing2.sim +31,,pytest,python3 test.py -f tools/taosdemoTestLimitOffset.py +30,,script,./test.sh -f unique/dnode/alternativeRole.sim +30,,script,./test.sh -f unique/arbitrator/offline_replica2_alterTag_online.sim +30,,script,./test.sh -f issue/TD-2677.sim +30,,script,./test.sh -f general/db/topic1.sim +30,,pytest,python3 ./test.py -f wal/sdbComp.py +29,,script,./test.sh -f unique/column/replica3.sim +29,,script,./test.sh -f unique/arbitrator/sync_replica2_alterTable_drop.sim +29,,script,./test.sh -f general/table/delete_writing.sim +29,,script,./test.sh -f general/compress/compress.sim +29,,pytest,python3 test.py -f tools/taosdemoTestTblAlt.py +28,,script,./test.sh -f unique/stable/dnode2_stop.sim +28,,script,./test.sh -f unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir_stopAll_starAll.sim +28,,script,./test.sh -f unique/arbitrator/offline_replica2_dropDb_online.sim +28,,script,./test.sh -f unique/arbitrator/dn3_mn2_killDnode.sim +28,,script,./test.sh -f general/stable/disk.sim +28,,script,./test.sh -f general/compress/commitlog.sim +27,2,script,./test.sh -f unique/dnode/simple.sim +27,,script,./test.sh -f unique/arbitrator/sync_replica3_dropTable.sim +27,,script,./test.sh -f unique/arbitrator/offline_replica2_dropTable_online.sim +27,,script,./test.sh -f unique/account/pass_alter.sim +27,,script,./test.sh -f general/insert/query_multi_file.sim +26,,script,./test.sh -f unique/arbitrator/offline_replica3_createTable_online.sim +26,,script,./test.sh -f general/parser/slimit.sim +26,,script,./test.sh -f general/parser/lastrow.sim +26,,script,./test.sh -f general/compress/compress2.sim +26,,pytest,python3 ./test.py -f tag_lite/datatype-without-alter.py +26,,pytest,python3 ./test.py -f tag_lite/datatype.py +26,,pytest,python3 ./test.py -f stable/query_after_reset.py +25,,script,./test.sh -f unique/http/admin.sim +25,,script,./test.sh -f unique/arbitrator/sync_replica3_alterTable_add.sim +25,,script,./test.sh -f unique/arbitrator/offline_replica2_alterTable_online.sim +25,,script,./test.sh -f general/import/commit.sim +25,,script,./test.sh -f general/compress/uncompress.sim +25,,script,./test.sh -f general/cache/restart_metrics.sim +25,,script,./test.sh -f general/alter/cached_schema_after_alter.sim +25,,pytest,python3 ./test.py -f queryCount.py +25,,pytest,python3 test.py -f alter/alter_cacheLastRow.py +24,,script,./test.sh -f unique/arbitrator/offline_replica3_alterTag_online.sim +24,,script,./test.sh -f issue/TD-2680.sim +24,,script,./test.sh -f general/parser/select_with_tags.sim +24,,script,./test.sh -f general/import/large.sim +24,,script,./test.sh -f general/connection/test_old_data.sim +24,,script,./test.sh -f general/column/table.sim +24,,script,./test.sh -f general/column/metrics.sim +24,,script,./test.sh -f general/alter/insert2.sim +24,,script,./test.sh -f general/alter/insert1.sim +24,,pytest,python3 ./test.py -f import_merge/importLastTPO.py +23,,script,./test.sh -f unique/stable/dnode3.sim +23,,script,./test.sh -f unique/arbitrator/offline_replica3_dropTable_online.sim +23,,script,./test.sh -f general/wal/maxtables.sim +23,,script,./test.sh -f general/alter/table.sim +23,,pytest,python3 ./test.py -f import_merge/importDataHPO.py +23,,pytest,python3 ./test.py -f import_merge/importDataHO.py +23,,pytest,python3 ./test.py -f import_merge/importDataHO2.py +23,,pytest,python3 ./test.py -f import_merge/importDataH2.py +23,,pytest,python3 ./test.py -f import_merge/importCSV.py +23,,pytest,python3 ./test.py -f import_merge/importCacheFileT.py +23,,pytest,python3 ./test.py -f import_merge/importCacheFileSub.py +22,,script,./test.sh -f unique/arbitrator/offline_replica3_dropDb_online.sim +22,,script,./test.sh -f general/wal/maxtables.sim +22,,script,./test.sh -f general/user/pass_alter.sim +22,,script,./test.sh -f general/parser/mixed_blocks.sim +22,,script,./test.sh -f general/http/grafana.sim +22,,script,./test.sh -f general/http/chunked.sim +22,,script,./test.sh -f general/compute/diff2.sim +22,,script,./test.sh -f general/column/commit.sim +22,,script,./test.sh -f general/alter/metrics.sim +22,,pytest,python3 ./test.py -f import_merge/importLastT.py +22,,pytest,python3 ./test.py -f import_merge/importLastTO.py +22,,pytest,python3 ./test.py -f import_merge/importDataSub.py +22,,pytest,python3 ./test.py -f import_merge/importDataLastS.py +22,,pytest,python3 ./test.py -f import_merge/importDataLastHPO.py +22,,pytest,python3 ./test.py -f import_merge/importDataLastHO.py +22,,pytest,python3 ./test.py -f import_merge/importCacheFileTPO.py +22,,pytest,python3 ./test.py -f import_merge/importCacheFileS.py +21,,script,./test.sh -f unique/cluster/cache.sim +21,,script,./test.sh -f unique/arbitrator/dn3_mn1_full_createTableFail.sim +21,,script,./test.sh -f unique/account/account_delete.sim +21,,script,./test.sh -f general/parser/slimit_alter_tags.sim +21,,script,./test.sh -f general/parser/set_tag_vals.sim +21,,script,./test.sh -f general/http/grafana_bug.sim +21,,script,./test.sh -f general/cache/restart_table.sim +21,,pytest,python3 test.py -f tools/taosdemoTestInterlace.py +21,,pytest,python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoInsert.py +21,,pytest,python3 ./test.py -f import_merge/importDataLastSub.py +21,,pytest,python3 ./test.py -f import_merge/importCacheFileTO.py +21,,pytest,python3 ./test.py -f import_merge/importCacheFileH.py +21,,pytest,python3 ./test.py -f import_merge/importCacheFileHPO.py +21,,pytest,python3 ./test.py -f import_merge/importCacheFileHO.py +20,,script,./test.sh -f general/user/authority.sim +20,,script,./test.sh -f general/http/telegraf.sim +20,,script,./test.sh -f general/http/restful_insert.sim +20,,script,./test.sh -f general/db/nosuchfile.sim +20,,pytest,python3 ./test.py -f stream/new.py +20,,pytest,python3 ./test.py -f query/query.py +19,,script,./test.sh -f unique/http/opentsdb.sim +19,,script,./test.sh -f general/parser/limit.sim +19,,script,./test.sh -f general/parser/last_cache.sim +19,,script,./test.sh -f general/parser/join_multivnode.sim +19,,script,./test.sh -f general/http/restful.sim +19,,script,./test.sh -f general/http/restful_full.sim +19,,script,./test.sh -f general/db/repeat.sim +19,,pytest,python3 test.py -f tools/taosdemoTestSampleData.py +19,,pytest,python3 test.py -f tools/taosdemoTest.py +19,,pytest,python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertWithJsonStmt.py +19,,pytest,python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoQuery.py +19,,pytest,python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestInsertTime_step.py +19,,pytest,python3 ./test.py -f query/query1970YearsAf.py +19,,pytest,python3 ./test.py -f perfbenchmark/bug3433.py +19,,pytest,python3 ./test.py -f import_merge/importDataLastH.py +19,,pytest,python3 ./test.py -f client/taoshellCheckCase.py +18,,script,./test.sh -f unique/stable/dnode2.sim +18,,script,./test.sh -f general/stable/metrics.sim +18,,script,./test.sh -f general/parser/slimit1.sim +18,,script,./test.sh -f general/parser/select_from_cache_disk.sim +18,,script,./test.sh -f general/parser/auto_create_tb.sim +18,,script,./test.sh -f general/http/gzip.sim +18,2,script,./test.sh -f general/alter/dnode.sim +18,,pytest,python3 test.py -f tools/taosdemoTestWithJson.py +18,,pytest,python3 test.py -f tools/taosdemoAllTest/TD-4985/query-limit-offset.py +18,,pytest,python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertWithJson.py +18,,pytest,python3 ./test.py -f import_merge/importTORestart.py +17,,script,./test.sh -f general/user/monitor.sim +17,,script,./test.sh -f general/parser/single_row_in_tb.sim +17,,script,./test.sh -f general/parser/auto_create_tb_drop_tb.sim +17,,script,./test.sh -f general/insert/tcp.sim +17,,script,./test.sh -f general/db/tables.sim +17,,pytest,python3 test.py -f tools/taosdemoTestWithoutMetric.py +17,,pytest,python3 test.py -f tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.py +17,,pytest,python3 ./test.py -f stream/history.py +17,,pytest,python3 ./test.py -f import_merge/importTRestart.py +17,,pytest,python3 ./test.py -f import_merge/importTPORestart.py +17,,pytest,python3 ./test.py -f functions/variable_httpDbNameMandatory.py +16,,script,./test.sh -f unique/account/user_create.sim +16,,pytest,python3 ./test.py -f query/queryTscomputWithNow.py +16,,pytest,python3 ./test.py -f import_merge/importTailPartOverlap.py +16,,pytest,python3 ./test.py -f import_merge/importSubRestart.py +16,,pytest,python3 ./test.py -f import_merge/importInsertThenImport.py +16,,pytest,python3 ./test.py -f functions/function_operations.py -r 1 +15,,script,./test.sh -f general/parser/join.sim +15,,script,./test.sh -f general/import/basic.sim +15,,script,./test.sh -f general/http/restful_limit.sim +15,,script,./test.sh -f general/field/smallint.sim +15,,pytest,python3 ./test.py -f table/alter_wal0.py +15,,pytest,python3 ./test.py -f query/queryWithTaosdKilled.py +15,,pytest,python3 ./test.py -f query/queryNormal.py +15,,pytest,python3 test.py -f query/queryInterval.py +15,,pytest,python3 ./test.py -f insert/schemalessInsert.py +15,,pytest,python3 ./test.py -f import_merge/importToCommit.py +15,,pytest,python3 ./test.py -f import_merge/importTail.py +15,,pytest,python3 ./test.py -f import_merge/importSRestart.py +15,,pytest,python3 ./test.py -f import_merge/importLastS.py +15,,pytest,python3 ./test.py -f import_merge/importDataTO.py +15,,pytest,python3 ./test.py -f import_merge/importDataLastT.py +15,,pytest,python3 ./test.py -f import_merge/importBlock2T.py +15,,pytest,python3 ./test.py -f import_merge/importBlock2HO.py +15,,pytest,python3 ./test.py -f import_merge/importBlock1TPO.py +15,,pytest,python3 ./test.py -f import_merge/importBlock1Sub.py +15,,pytest,python3 ./test.py -f import_merge/importBlock1S.py +15,,pytest,python3 ./test.py -f import_merge/importBlock1HPO.py +15,,pytest,python3 ./test.py -f functions/function_leastsquares.py -r 1 +14,,script,./test.sh -f unique/db/replica_reduce21.sim +14,,script,./test.sh -f general/user/user_create.sim +14,,script,./test.sh -f general/stable/refcount.sim +14,,script,./test.sh -f general/insert/query_block2_file.sim +14,,script,./test.sh -f general/insert/query_block1_file.sim +14,,script,./test.sh -f general/field/bool.sim +14,,script,./test.sh -f general/db/vnodes.sim +14,,script,./test.sh -f general/compute/stddev.sim +14,,script,./test.sh -f general/compute/min.sim +14,,pytest,python3 ./test.py -f query/queryJoin10tables.py +14,,pytest,python3 ./test.py -f query/queryInsertValue.py +14,,pytest,python3 ./test.py -f query/bug1471.py +14,,pytest,python3 ./test.py -f insert/before_1970.py +14,,pytest,python3 ./test.py -f import_merge/importTailOverlap.py +14,,pytest,python3 ./test.py -f import_merge/importDataT.py +14,,pytest,python3 ./test.py -f import_merge/importDataTPO.py +14,,pytest,python3 ./test.py -f import_merge/importDataLastTPO.py +14,,pytest,python3 ./test.py -f import_merge/importBlockbetween.py +14,,pytest,python3 ./test.py -f import_merge/importBlock2TPO.py +14,,pytest,python3 ./test.py -f import_merge/importBlock2TO.py +14,,pytest,python3 ./test.py -f import_merge/importBlock2Sub.py +14,,pytest,python3 ./test.py -f import_merge/importBlock2S.py +14,,pytest,python3 ./test.py -f import_merge/importBlock2H.py +14,,pytest,python3 ./test.py -f import_merge/importBlock1T.py +14,,pytest,python3 ./test.py -f import_merge/importBlock1TO.py +14,,pytest,python3 ./test.py -f import_merge/importBlock1H.py +14,,pytest,python3 ./test.py -f import_merge/importBlock1HO.py +14,,pytest,python3 ./test.py -f functions/function_max.py -r 1 +14,,pytest,python3 ./test.py -f functions/function_last.py -r 1 +14,,pytest,python3 ./test.py -f functions/function_avg.py -r 1 +13,,script,./test.sh -f unique/account/user_len.sim +13,,script,./test.sh -f unique/account/account_len.sim +13,,script,./test.sh -f general/vector/table_query.sim +13,,script,./test.sh -f general/vector/table_mix.sim +13,,script,./test.sh -f general/table/limit.sim +13,,script,./test.sh -f general/parser/timestamp.sim +13,,script,./test.sh -f general/parser/import_commit3.sim +13,,script,./test.sh -f general/parser/fill_stb.sim +13,,script,./test.sh -f general/insert/query_file_memory.sim +13,,script,./test.sh -f general/field/5.sim +13,,script,./test.sh -f general/field/3.sim +13,,script,./test.sh -f general/field/2.sim +13,,script,./test.sh -f general/db/basic.sim +13,,script,./test.sh -f general/compute/avg.sim +13,,script,./test.sh -f general/cache/new_metrics.sim +13,,pytest,python3 ./test.py -f query/queryStddevWithGroupby.py +13,,pytest,python3 ./test.py -f import_merge/importSpan.py +13,,pytest,python3 ./test.py -f import_merge/importLastSub.py +13,,pytest,python3 ./test.py -f import_merge/importLastH.py +13,,pytest,python3 ./test.py -f import_merge/importLastHPO.py +13,,pytest,python3 ./test.py -f import_merge/importLastHO.py +13,,pytest,python3 ./test.py -f import_merge/importDataS.py +13,,pytest,python3 ./test.py -f import_merge/importDataLastTO.py +13,,pytest,python3 ./test.py -f import_merge/importBlock2HPO.py +13,,pytest,python3 ./test.py -f functions/function_twa.py -r 1 +13,,pytest,python3 ./test.py -f functions/function_sum.py -r 1 +13,,pytest,python3 ./test.py -f functions/function_stddev.py -r 1 +13,,pytest,python3 ./test.py -f functions/function_percentile.py -r 1 +13,,pytest,python3 ./test.py -f functions/function_min.py -r 1 +13,,pytest,python3 ./test.py -f functions/function_last_row.py -r 1 +13,,pytest,python3 ./test.py -f functions/function_diff.py -r 1 +13,,pytest,python3 ./test.py -f functions/function_count.py -r 1 +13,,pytest,python3 ./test.py -f functions/function_bottom.py -r 1 +13,,pytest,python3 ./test.py -f client/noConnectionErrorTest.py +12,,script,./test.sh -f unique/account/pass_len.sim +12,,script,./test.sh -f general/vector/single.sim +12,,script,./test.sh -f general/vector/metrics_time.sim +12,,script,./test.sh -f general/vector/metrics_tag.sim +12,,script,./test.sh -f general/vector/metrics_mix.sim +12,,script,./test.sh -f general/user/user_len.sim +12,,script,./test.sh -f general/user/pass_len.sim +12,,script,./test.sh -f general/table/tinyint.sim +12,,script,./test.sh -f general/stable/values.sim +12,,script,./test.sh -f general/stable/show.sim +12,,script,./test.sh -f general/stable/dnode3.sim +12,,script,./test.sh -f general/parser/tags_dynamically_specifiy.sim +12,,script,./test.sh -f general/parser/select_across_vnodes.sim +12,,script,./test.sh -f general/insert/query_block1_memory.sim +12,,script,./test.sh -f general/insert/basic.sim +12,,script,./test.sh -f general/http/prepare.sim +12,,script,./test.sh -f general/field/binary.sim +12,,script,./test.sh -f general/field/6.sim +12,,script,./test.sh -f general/field/4.sim +12,2,script,./test.sh -f general/db/topic2.sim +12,,script,./test.sh -f general/db/alter_option.sim +12,,script,./test.sh -f general/connection/connection.sim +12,,script,./test.sh -f general/compute/max.sim +12,,script,./test.sh -f general/compute/leastsquare.sim +12,,script,./test.sh -f general/compute/last.sim +12,,script,./test.sh -f general/compute/bottom.sim +12,,pytest,python3 ./test.py -f update/allow_update-0.py +12,,pytest,python3 ./test.py -f query/udf.py +12,,pytest,python3 ./test.py -f query/queryLimit.py +12,,pytest,python3 ./test.py -f import_merge/importHead.py +12,,pytest,python3 ./test.py -f functions/function_top.py -r 1 +12,,pytest,python3 ./test.py -f functions/function_spread.py -r 1 +12,,pytest,python3 ./test.py -f functions/function_first.py -r 1 +11,,script,./test.sh -f unique/account/basic.sim +11,,script,./test.sh -f general/vector/table_time.sim +11,,script,./test.sh -f general/vector/table_field.sim +11,,script,./test.sh -f general/vector/multi.sim +11,,script,./test.sh -f general/vector/metrics_query.sim +11,,script,./test.sh -f general/vector/metrics_field.sim +11,,script,./test.sh -f general/table/vgroup.sim +11,,script,./test.sh -f general/table/table.sim +11,,script,./test.sh -f general/table/table_len.sim +11,,script,./test.sh -f general/table/int.sim +11,,script,./test.sh -f general/table/float.sim +11,,script,./test.sh -f general/table/double.sim +11,,script,./test.sh -f general/table/describe.sim +11,,script,./test.sh -f general/table/db.table.sim +11,,script,./test.sh -f general/table/date.sim +11,,script,./test.sh -f general/table/createmulti.sim +11,,script,./test.sh -f general/table/column_value.sim +11,,script,./test.sh -f general/table/column_name.sim +11,,script,./test.sh -f general/table/column2.sim +11,,script,./test.sh -f general/table/bool.sim +11,,script,./test.sh -f general/table/binary.sim +11,,script,./test.sh -f general/table/basic3.sim +11,,script,./test.sh -f general/table/basic1.sim +11,,script,./test.sh -f general/table/autocreate.sim +11,,script,./test.sh -f general/stable/vnode3.sim +11,,script,./test.sh -f general/parser/udf_dll_stable.sim +11,,script,./test.sh -f general/parser/select_distinct_tag.sim +11,,script,./test.sh -f general/parser/insert_tb.sim +11,,script,./test.sh -f general/parser/import_commit2.sim +11,,script,./test.sh -f general/parser/import_commit1.sim +11,,script,./test.sh -f general/parser/having_child.sim +11,,script,./test.sh -f general/parser/binary_escapeCharacter.sim +11,,script,./test.sh -f general/parser/between_and.sim +11,,script,./test.sh -f general/parser/alter_stable.sim +11,,script,./test.sh -f general/insert/query_block2_memory.sim +11,,script,./test.sh -f general/field/tinyint.sim +11,,script,./test.sh -f general/field/single.sim +11,,script,./test.sh -f general/field/bigint.sim +11,,script,./test.sh -f general/db/len.sim +11,,script,./test.sh -f general/db/basic1.sim +11,,script,./test.sh -f general/compute/percentile.sim +11,,script,./test.sh -f general/compute/null.sim +11,,script,./test.sh -f general/compute/first.sim +11,,script,./test.sh -f general/compute/diff.sim +11,,script,./test.sh -f general/compute/count.sim +11,,script,./test.sh -f general/alter/import.sim +11,,pytest,python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanosubscribe.py +11,,pytest,python3 test.py -f subscribe/supertable.py +11,,pytest,python3 ./test.py -f functions/function_percentile2.py +10,,script,./test.sh -f unique/account/paras.sim +10,,script,./test.sh -f general/table/smallint.sim +10,,script,./test.sh -f general/table/column_num.sim +10,,script,./test.sh -f general/table/bigint.sim +10,,script,./test.sh -f general/table/basic2.sim +10,,script,./test.sh -f general/parser/udf.sim +10,,script,./test.sh -f general/parser/udf_dll.sim +10,,script,./test.sh -f general/parser/tags_filter.sim +10,,script,./test.sh -f general/parser/null_char.sim +10,,script,./test.sh -f general/parser/nchar.sim +10,,script,./test.sh -f general/parser/function.sim +10,,script,./test.sh -f general/parser/fill.sim +10,,script,./test.sh -f general/parser/create_tb.sim +10,,script,./test.sh -f general/parser/create_mt.sim +10,,script,./test.sh -f general/parser/alter.sim +10,,script,./test.sh -f general/http/autocreate.sim +10,,script,./test.sh -f general/db/basic5.sim +10,,script,./test.sh -f general/db/basic4.sim +10,,script,./test.sh -f general/db/basic3.sim +10,,script,./test.sh -f general/db/basic2.sim +10,,script,./test.sh -f general/compute/top.sim +10,,script,./test.sh -f general/compute/sum.sim +10,,pytest,python3 test.py -f tools/taosdumpTestNanoSupport.py +10,,pytest,python3 ./test.py -f query/bug1875.py +9,,script,./test.sh -f unique/stable/replica3_dnode6.sim +9,,script,./test.sh -f unique/account/account_create.sim +9,,script,./test.sh -f general/parser/stableOp.sim +9,,script,./test.sh -f general/parser/having.sim +9,,script,./test.sh -f general/parser/dbtbnameValidate.sim +9,,script,./test.sh -f general/parser/create_db.sim +9,,script,./test.sh -f general/compute/interval.sim +9,,pytest,python3 test.py -f tools/taosdumpTest.py +9,,pytest,python3 testCompress.py +9,,pytest,python3 ./test.py -f tag_lite/timestamp.py +9,,pytest,python3 ./test.py -f tag_lite/binary_binary.py +9,,pytest,python3 ./test.py -f query/queryJoin.py +9,,pytest,python3 ./test.py -f insert/metadataUpdate.py +9,,pytest,python3 ./test.py -f insert/insertFromCSV.py +9,,pytest,python3 test.py -f dbmgmt/nanoSecondCheck.py +8,,script,./test.sh -f unique/stable/replica2_vnode3.sim +8,,script,./test.sh -f general/parser/columnValue.sim +8,,pytest,python3 test.py -f tools/taosdumpTest2.py +8,,pytest,python3 ./test.py -f tag_lite/tinyint.py +8,,pytest,python3 ./test.py -f tag_lite/TestModifyTag.py +8,,pytest,python3 ./test.py -f tag_lite/set.py +8,,pytest,python3 ./test.py -f tag_lite/filter.py +8,,pytest,python3 ./test.py -f tag_lite/double.py +8,,pytest,python3 ./test.py -f tag_lite/delete.py +8,,pytest,python3 ./test.py -f tag_lite/commit.py +8,,pytest,python3 ./test.py -f tag_lite/column.py +8,,pytest,python3 ./test.py -f tag_lite/binary.py +8,,pytest,python3 ./test.py -f tag_lite/add.py +8,,pytest,python3 ./test.py -f tag_lite/5.py +8,,pytest,python3 ./test.py -f table/boundary.py +8,,pytest,python3 ./test.py -f insert/nchar-unicode.py +8,,pytest,python3 ./test.py -f insert/alterTableAndInsert.py +8,,pytest,python3 ./test.py -f import_merge/importHRestart.py +8,,pytest,python3 ./test.py -f import_merge/importHPORestart.py +8,,pytest,python3 ./test.py -f import_merge/importHORestart.py +8,,pytest,python3 ./test.py -f alter/alter_table_crash.py +7,,script,./test.sh -f unique/stable/replica2_dnode4.sim +7,,script,./test.sh -f general/db/delete.sim +7,,pytest,python3 testNoCompress.py +7,,pytest,python3 ./test.py -f tag_lite/int.py +7,,pytest,python3 ./test.py -f tag_lite/float.py +7,,pytest,python3 ./test.py -f tag_lite/bool.py +7,,pytest,python3 ./test.py -f tag_lite/6.py +7,,pytest,python3 ./test.py -f tag_lite/4.py +7,,pytest,python3 ./test.py -f tag_lite/3.py +7,,pytest,python3 ./test.py -f table/del_stable.py +7,,pytest,python3 ./test.py -f table/create.py +7,,pytest,python3 ./test.py -f table/create_db_from_normal_db.py +7,,pytest,python3 ./test.py -f table/column_num.py +7,,pytest,python3 ./test.py -f stream/showStreamExecTimeisNull.py +7,,pytest,python3 ./test.py -f query/querySort.py +7,,pytest,python3 ./test.py -f query/filterFloatAndDouble.py +7,,pytest,python3 ./test.py -f query/filterAllIntTypes.py +7,,pytest,python3 ./test.py -f insert/tinyint.py +7,,pytest,python3 ./test.py -f insert/modify_column.py +7,,pytest,python3 ./test.py -f insert/bug3654.py +7,,pytest,python3 ./test.py -f insert/binary.py +7,,pytest,python3 ./test.py -f insert/bigint.py +6,,pytest,python3 ./test.py -f update/updateWithClientMerge.py +6,,pytest,python3 ./test.py -f tag_lite/smallint.py +6,,pytest,python3 ./test.py -f tag_lite/int_float.py +6,,pytest,python3 ./test.py -f tag_lite/int_binary.py +6,,pytest,python3 ./test.py -f tag_lite/create-tags-boundary.py +6,,pytest,python3 ./test.py -f tag_lite/create.py +6,,pytest,python3 ./test.py -f tag_lite/bool_binary.py +6,,pytest,python3 ./test.py -f tag_lite/bigint.py +6,,pytest,python3 ./test.py -f table/max_table_length.py +6,,pytest,python3 ./test.py -f table/column_name.py +6,,pytest,python3 ./test.py -f stable/insert.py +6,,pytest,python3 test.py -f restful/restful_bind_db2.py +6,,pytest,python3 test.py -f restful/restful_bind_db1.py +6,,pytest,python3 ./test.py -f query/querySecondtscolumnTowherenow.py +6,,pytest,python3 ./test.py -f query/queryFilterTswithDateUnit.py +6,,pytest,python3 ./test.py -f query/natualInterval.py +6,,pytest,python3 ./test.py -f query/filter.py +6,,pytest,python3 ./test.py -f query/filterCombo.py +6,,pytest,python3 ./test.py -f query/computeErrorinWhere.py +6,,pytest,python3 ./test.py -f query/bug1876.py +6,,pytest,python3 ./test.py -f query/bug1874.py +6,,pytest,python3 ./test.py -f perfbenchmark/taosdemoInsert.py +6,,pytest,python3 ./test.py -f insert/specialSql.py +6,,pytest,python3 ./test.py -f insert/smallint.py +6,,pytest,python3 ./test.py -f insert/nchar.py +6,,pytest,python3 ./test.py -f insert/multi.py +6,,pytest,python3 ./test.py -f insert/line_insert.py +6,,pytest,python3 ./test.py -f insert/in_function.py +6,,pytest,python3 ./test.py -f insert/date.py +6,,pytest,python3 ./test.py -f import_merge/importHeadPartOverlap.py +6,,pytest,python3 ./test.py -f import_merge/importHeadOverlap.py +6,,pytest,python3 bug2265.py +5,,pytest,python3 ./test.py -f wal/addOldWalTest.py +5,,pytest,python3 ./test.py -f user/user_create.py +5,,pytest,python3 ./test.py -f user/pass_len.py +5,,pytest,python3 ./test.py -f tag_lite/unsignedSmallint.py +5,,pytest,python3 ./test.py -f tag_lite/unsignedInt.py +5,,pytest,python3 ./test.py -f tag_lite/change.py +5,,pytest,python3 ./test.py -f tag_lite/bool_int.py +5,,pytest,python3 ./test.py -f table/tablename-boundary.py +5,,pytest,python3 ./test.py -f table/db_table.py +5,,pytest,python3 ./test.py -f table/create_sensitive.py +5,,pytest,python3 ./test.py -f table/alter_column.py +5,,pytest,python3 ./test.py -f query/unionAllTest.py +5,,pytest,python3 ./test.py -f query/querySession.py +5,,pytest,python3 ./test.py -f query/queryError.py +5,,pytest,python3 ./test.py -f query/queryBetweenAnd.py +5,,pytest,python3 ./test.py -f query/queryBase.py +5,,pytest,python3 ./test.py -f query/operator_cost.py +5,,pytest,python3 ./test.py -f query/nestquery_last_row.py +5,,pytest,python3 test.py -f query/nestedQuery/queryWithSpread.py +5,,pytest,python3 ./test.py -f query/nestedQuery/queryInterval.py +5,,pytest,python3 ./test.py -f query/isNullTest.py +5,,pytest,python3 ./test.py -f query/floatCompare.py +5,,pytest,python3 ./test.py -f query/filterOtherTypes.py +5,,pytest,python3 ./test.py -f query/bug3375.py +5,,pytest,python3 ./test.py -f query/bug2218.py +5,,pytest,python3 ./test.py -f query/bug2143.py +5,,pytest,python3 ./test.py -f query/bug2118.py +5,,pytest,python3 ./test.py -f query/bug2117.py +5,,pytest,python3 ./test.py -f insert/unsignedInt.py +5,,pytest,python3 ./test.py -f insert/timestamp.py +5,,pytest,python3 ./test.py -f insert/special_character_show.py +5,,pytest,python3 ./test.py -f insert/int.py +5,,pytest,python3 ./test.py -f insert/insertIntoTwoTables.py +5,,pytest,python3 ./test.py -f insert/insertDynamicColBeforeVal.py +5,,pytest,python3 test.py -f insert/insert_before_use_db.py +5,,pytest,python3 ./test.py -f insert/float.py +5,,pytest,python3 ./test.py -f insert/double.py +5,,pytest,python3 ./test.py -f insert/bool.py +5,,pytest,python3 ./test.py -f functions/function_stddev_td2555.py +5,,pytest,python3 ./test.py -f functions/function_stateWindow.py +5,,pytest,python3 ./test.py -f functions/function_irate.py +5,,pytest,python3 ./test.py -f functions/function_derivative.py +5,,pytest,python3 ./test.py -f client/client.py +5,,pytest,python3 test.py -f alter/alter_keep.py +4,,script,./test.sh -f general/parser/alter1.sim +4,,pytest,python3 ./test.py -f topic/topicQuery.py +4,,pytest,python3 testMinTablesPerVnode.py +4,,pytest,python3 ./test.py -f tag_lite/unsignedTinyint.py +4,,pytest,python3 ./test.py -f tag_lite/unsignedBigint.py +4,,pytest,python3 ./test.py -f tag_lite/drop_auto_create.py +4,,pytest,python3 ./test.py -f tag_lite/alter_tag.py +4,,pytest,python3 test.py -f subscribe/singlemeter.py +4,,pytest,python3 ./test.py -f query/ts_2016.py +4,,pytest,python3 ./test.py -f query/subqueryFilter.py +4,,pytest,python3 ./test.py -f query/queryWildcardLength.py +4,,pytest,python3 ./test.py -f query/queryTsisNull.py +4,,pytest,python3 ./test.py -f query/queryTbnameUpperLower.py +4,,pytest,python3 ./test.py -f query/queryStateWindow.py +4,,pytest,python3 ./test.py -f query/queryStableJoin.py +4,,pytest,python3 ./test.py -f query/queryPriKey.py +4,,pytest,python3 ./test.py -f query/queryGroupTbname.py +4,,pytest,python3 ./test.py -f query/queryGroupbyWithInterval.py +4,,pytest,python3 test.py -f query/queryFillTest.py +4,,pytest,python3 ./test.py -f query/queryCountCSVData.py +4,,pytest,python3 ./test.py -f query/queryCnameDisplay.py +4,,pytest,python3 ./test.py -f query/filterAllUnsignedIntTypes.py +4,,pytest,python3 ./test.py -f query/bug6586.py +4,,pytest,python3 ./test.py -f query/bug3351.py +4,,pytest,python3 ./test.py -f query/bug2281.py +4,,pytest,python3 ./test.py -f query/bug2119.py +4,,pytest,python3 ./test.py -f insert/unsignedTinyint.py +4,,pytest,python3 ./test.py -f insert/unsignedSmallint.py +4,,pytest,python3 ./test.py -f insert/unsignedBigint.py +4,,pytest,python3 ./test.py -f insert/insert_locking.py +4,,pytest,python3 ./test.py -f insert/basic.py +4,,pytest,python3 ./test.py -f functions/showOfflineThresholdIs864000.py +4,,pytest,python3 ./test.py -f functions/function_twa_test2.py +4,,pytest,python3 ./test.py -f functions/function_count_last_stab.py +4,,pytest,python3 ./test.py -f functions/all_null_value.py +4,,pytest,python3 ./test.py -f client/version.py +4,,pytest,python3 client/twoClients.py +4,,pytest,python3 ./test.py -f client/alterDatabase.py +4,,pytest,python3 ./test.py -f alter/alter_table.py +4,,pytest,python3 test.py -f alter/alter_create_exception.py +4,,pytest,python3 ./test.py -f alter/alterColMultiTimes.py +3,,pytest,python3 ./test.py -f query/sliding.py +3,,pytest,python3 ./test.py -f query/queryGroupbySort.py +3,,pytest,python3 ./test.py -f alter/alterTimestampColDataProcess.py +3,,pytest,python3 ./test.py -f alter/alterTabAddTagWithNULL.py +3,,pytest,python3 ./test.py -f alter/alter_debugFlag.py +3,,pytest,python3 ./test.py -f account/account_create.py diff --git a/tests/parallel_test/m.json b/tests/parallel_test/m.json new file mode 100644 index 0000000000000000000000000000000000000000..f86c571728962783867680901dfa2611c37e660e --- /dev/null +++ b/tests/parallel_test/m.json @@ -0,0 +1,30 @@ +[{ + "host":"192.168.0.210", + "username":"root", + "workdir":"/var/data/jenkins/workspace", + "thread":25 +}, +{ + "host":"192.168.0.211", + "username":"root", + "workdir":"/var/data/jenkins/workspace", + "thread":25 +}, +{ + "host":"192.168.0.212", + "username":"root", + "workdir":"/var/data/jenkins/workspace", + "thread":25 +}, +{ + "host":"192.168.0.213", + "username":"root", + "workdir":"/var/data/jenkins/workspace", + "thread":25 +}, +{ + "host":"192.168.0.214", + "username":"root", + "workdir":"/var/data/jenkins/workspace", + "thread":25 +}] diff --git a/tests/parallel_test/run.sh b/tests/parallel_test/run.sh new file mode 100755 index 0000000000000000000000000000000000000000..026bfb020d9a77d5cd1b05e9030cfce69a7ba4c7 --- /dev/null +++ b/tests/parallel_test/run.sh @@ -0,0 +1,358 @@ +#!/bin/bash + +function usage() { + echo "$0" + echo -e "\t -m vm config file" + echo -e "\t -t task file" + echo -e "\t -b branch" + echo -e "\t -l log dir" + echo -e "\t -h help" +} + +while getopts "m:t:b:l:h" opt; do + case $opt in + m) + config_file=$OPTARG + ;; + t) + t_file=$OPTARG + ;; + b) + branch=$OPTARG + ;; + l) + log_dir=$OPTARG + ;; + h) + usage + exit 0 + ;; + \?) + echo "Invalid option: -$OPTARG" + usage + exit 0 + ;; + esac +done +#config_file=$1 +if [ -z $config_file ]; then + usage + exit 1 +fi +if [ ! -f $config_file ]; then + echo "$config_file not found" + usage + exit 1 +fi +#t_file=$2 +if [ -z $t_file ]; then + usage + exit 1 +fi +if [ ! -f $t_file ]; then + echo "$t_file not found" + usage + exit 1 +fi +date_tag=`date +%Y%m%d-%H%M%S` +if [ -z $log_dir ]; then + log_dir="log/${branch}_${date_tag}" +else + log_dir="$log_dir/${branch}_${date_tag}" +fi + +hosts=() +usernames=() +passwords=() +workdirs=() +threads=() + +i=0 +while [ 1 ]; do + host=`jq .[$i].host $config_file` + if [ "$host" = "null" ]; then + break + fi + username=`jq .[$i].username $config_file` + if [ "$username" = "null" ]; then + break + fi + password=`jq .[$i].password $config_file` + if [ "$password" = "null" ]; then + password="" + fi + workdir=`jq .[$i].workdir $config_file` + if [ "$workdir" = "null" ]; then + break + fi + thread=`jq .[$i].thread $config_file` + if [ "$thread" = "null" ]; then + break + fi + hosts[i]=`echo $host|sed 's/\"$//'|sed 's/^\"//'` + usernames[i]=`echo $username|sed 's/\"$//'|sed 's/^\"//'` + passwords[i]=`echo $password|sed 's/\"$//'|sed 's/^\"//'` + workdirs[i]=`echo $workdir|sed 's/\"$//'|sed 's/^\"//'` + threads[i]=$thread + i=$(( i + 1 )) +done + + +function prepare_cases() { + cat $t_file >>$task_file + local i=0 + while [ $i -lt $1 ]; do + echo "%%FINISHED%%" >>$task_file + i=$(( i + 1 )) + done +} + +function clean_tmp() { + # clean tmp dir + local index=$1 + local ssh_script="sshpass -p ${passwords[index]} ssh -o StrictHostKeyChecking=no ${usernames[index]}@${hosts[index]}" + if [ -z ${passwords[index]} ]; then + ssh_script="ssh -o StrictHostKeyChecking=no ${usernames[index]}@${hosts[index]}" + fi + local cmd="${ssh_script} rm -rf ${workdirs[index]}/tmp" + ${cmd} +} +# build source +function build_src() { + echo "build source" + local index=$1 + local ssh_script="sshpass -p ${passwords[index]} ssh -o StrictHostKeyChecking=no ${usernames[index]}@${hosts[index]}" + if [ -z ${passwords[index]} ]; then + ssh_script="ssh -o StrictHostKeyChecking=no ${usernames[index]}@${hosts[index]}" + fi + local script=". ~/.bashrc;cd ${workdirs[index]}/TDinternal;mkdir -p debug;cd debug;cmake .. -DBUILD_HTTP=false -DBUILD_TOOLS=true;make -j8;make install" + local cmd="${ssh_script} sh -c \"$script\"" + echo "$cmd" + ${cmd} + if [ $? -ne 0 ]; then + flock -x $lock_file -c "echo \"${hosts[index]} TDengine build failed\" >>$log_dir/failed.log" + return + fi + script=". ~/.bashrc;cd ${workdirs[index]}/taos-tools;git submodule update --init --recursive;mkdir -p build;cd build;cmake ..;make -j4" + cmd="${ssh_script} sh -c \"$script\"" + ${cmd} + if [ $? -ne 0 ]; then + flock -x $lock_file -c "echo \"${hosts[index]} taos-tools build failed\" >>$log_dir/failed.log" + return + fi + script="cp -rf ${workdirs[index]}/taos-tools/build/build/bin/* ${workdirs[index]}/TDinternal/debug/build/bin/;cp -rf ${workdirs[index]}/taos-tools/build/build/lib/* ${workdirs[index]}/TDinternal/debug/build/lib/;cp -rf ${workdirs[index]}/taos-tools/build/build/lib64/* ${workdirs[index]}/TDinternal/debug/build/lib/;cp -rf ${workdirs[index]}/TDinternal/debug/build/bin/taosBenchmark ${workdirs[index]}/TDinternal/debug/build/bin/taosdemo" + cmd="${ssh_script} sh -c \"$script\"" + ${cmd} +} +function rename_taosdemo() { + local index=$1 + local ssh_script="sshpass -p ${passwords[index]} ssh -o StrictHostKeyChecking=no ${usernames[index]}@${hosts[index]}" + if [ -z ${passwords[index]} ]; then + ssh_script="ssh -o StrictHostKeyChecking=no ${usernames[index]}@${hosts[index]}" + fi + local script="cp -rf ${workdirs[index]}/TDinternal/debug/build/bin/taosBenchmark ${workdirs[index]}/TDinternal/debug/build/bin/taosdemo 2>/dev/null" + cmd="${ssh_script} sh -c \"$script\"" + ${cmd} +} + +function run_thread() { + local index=$1 + local thread_no=$2 + local runcase_script="sshpass -p ${passwords[index]} ssh -o StrictHostKeyChecking=no ${usernames[index]}@${hosts[index]}" + if [ -z ${passwords[index]} ]; then + runcase_script="ssh -o StrictHostKeyChecking=no ${usernames[index]}@${hosts[index]}" + fi + local count=0 + local script="${workdirs[index]}/TDinternal/community/tests/parallel_test/run_container.sh" + local cmd="${runcase_script} ${script}" + + # script="echo" + while [ 1 ]; do + local line=`flock -x $lock_file -c "head -n1 $task_file;sed -i \"1d\" $task_file"` + if [ "x$line" = "x%%FINISHED%%" ]; then + # echo "$index . $thread_no EXIT" + break + fi + if [ -z "$line" ]; then + continue + fi + echo "$line"|grep -q "^#" + if [ $? -eq 0 ]; then + continue + fi + local case_redo_time=`echo "$line"|cut -d, -f2` + if [ -z "$case_redo_time" ]; then + case_redo_time=${DEFAULT_RETRY_TIME:-2} + fi + local exec_dir=`echo "$line"|cut -d, -f3` + local case_cmd=`echo "$line"|cut -d, -f4` + local case_file="" + echo "$case_cmd"|grep -q "^python3" + if [ $? -eq 0 ]; then + case_file=`echo "$case_cmd"|grep -o ".*\.py"|awk '{print $NF}'` + fi + echo "$case_cmd"|grep -q "\.sim" + if [ $? -eq 0 ]; then + case_file=`echo "$case_cmd"|grep -o ".*\.sim"|awk '{print $NF}'` + fi + if [ -z "$case_file" ]; then + case_file=`echo "$case_cmd"|awk '{print $NF}'` + fi + if [ -z "$case_file" ]; then + continue + fi + case_file="$exec_dir/${case_file}.${index}.${thread_no}" + count=$(( count + 1 )) + local case_path=`dirname "$case_file"` + if [ ! -z "$case_path" ]; then + mkdir -p $log_dir/$case_path + fi + cmd="${runcase_script} ${script} -w ${workdirs[index]} -c \"${case_cmd}\" -t ${thread_no} -d ${exec_dir}" + # echo "$thread_no $count $cmd" + local ret=0 + local redo_count=1 + start_time=`date +%s` + while [ ${redo_count} -lt 6 ]; do + echo "${hosts[index]}-${thread_no} order:${count}, redo:${redo_count} task:${line}" >$log_dir/$case_file.log + echo -e "\e[33m >>>>> \e[0m ${case_cmd}" + date >>$log_dir/$case_file.log + # $cmd 2>&1 | tee -a $log_dir/$case_file.log + # ret=${PIPESTATUS[0]} + $cmd >>$log_dir/$case_file.log 2>&1 + ret=$? + if [ $ret -eq 0 ]; then + break + fi + redo=0 + grep -q "wait too long for taosd start" $log_dir/$case_file.log + if [ $? -eq 0 ]; then + redo=1 + fi + grep -q "kex_exchange_identification: Connection closed by remote host" $log_dir/$case_file.log + if [ $? -eq 0 ]; then + redo=1 + fi + grep -q "ssh_exchange_identification: Connection closed by remote host" $log_dir/$case_file.log + if [ $? -eq 0 ]; then + redo=1 + fi + grep -q "kex_exchange_identification: read: Connection reset by peer" $log_dir/$case_file.log + if [ $? -eq 0 ]; then + redo=1 + fi + grep -q "Database not ready" $log_dir/$case_file.log + if [ $? -eq 0 ]; then + redo=1 + fi + grep -q "Unable to establish connection" $log_dir/$case_file.log + if [ $? -eq 0 ]; then + redo=1 + fi + if [ $redo_count -lt $case_redo_time ]; then + redo=1 + fi + if [ $redo -eq 0 ]; then + break + fi + redo_count=$(( redo_count + 1 )) + done + end_time=`date +%s` + echo >>$log_dir/$case_file.log + echo "${hosts[index]} execute time: $(( end_time - start_time ))s" >>$log_dir/$case_file.log + # echo "$thread_no ${line} DONE" + if [ $ret -ne 0 ]; then + flock -x $lock_file -c "echo \"${hosts[index]} ret:${ret} ${line}\" >>$log_dir/failed.log" + mkdir -p $log_dir/${case_file}.coredump + local remote_coredump_dir="${workdirs[index]}/tmp/thread_volume/$thread_no/coredump" + cmd="sshpass -p ${passwords[index]} scp -o StrictHostKeyChecking=no ${usernames[index]}@${hosts[index]}:${remote_coredump_dir}/* $log_dir/${case_file}.coredump/" + if [ -z ${passwords[index]} ]; then + cmd="scp -o StrictHostKeyChecking=no ${usernames[index]}@${hosts[index]}:${remote_coredump_dir}/* $log_dir/${case_file}.coredump/" + fi + $cmd # 2>/dev/null + local case_info=`echo "$line"|cut -d, -f 3,4` + local corefile=`ls $log_dir/${case_file}.coredump/` + corefile=`find $log_dir/${case_file}.coredump/ -name "core.*"` + echo -e "$case_info \e[31m failed\e[0m" + echo "=========================log============================" + cat $log_dir/$case_file.log + echo "=====================================================" + echo -e "\e[34m log file: $log_dir/$case_file.log \e[0m" + if [ ! -z "$corefile" ]; then + echo -e "\e[34m corefiles: $corefile \e[0m" + fi + fi + done +} + +# echo "hosts: ${hosts[@]}" +# echo "usernames: ${usernames[@]}" +# echo "passwords: ${passwords[@]}" +# echo "workdirs: ${workdirs[@]}" +# echo "threads: ${threads[@]}" +# TODO: check host accessibility + +i=0 +while [ $i -lt ${#hosts[*]} ]; do + clean_tmp $i & + i=$(( i + 1 )) +done +wait + +mkdir -p $log_dir +rm -rf $log_dir/* +task_file=$log_dir/$$.task +lock_file=$log_dir/$$.lock + +i=0 +while [ $i -lt ${#hosts[*]} ]; do + # build_src $i & + rename_taosdemo $i & + i=$(( i + 1 )) +done +wait +# if [ -f "$log_dir/failed.log" ]; then +# cat $log_dir/failed.log +# exit 1 +# fi + +i=0 +j=0 +while [ $i -lt ${#hosts[*]} ]; do + j=$(( j + threads[i] )) + i=$(( i + 1 )) +done +prepare_cases $j + +i=0 +while [ $i -lt ${#hosts[*]} ]; do + j=0 + while [ $j -lt ${threads[i]} ]; do + run_thread $i $j & + j=$(( j + 1 )) + done + i=$(( i + 1 )) +done + +wait + +rm -f $lock_file +rm -f $task_file + +# docker ps -a|grep -v CONTAINER|awk '{print $1}'|xargs docker rm -f +RET=0 +i=1 +if [ -f "$log_dir/failed.log" ]; then + echo "=====================================================" + while read line; do + line=`echo "$line"|cut -d, -f 3,4` + echo -e "$i. $line \e[31m failed\e[0m" >&2 + i=$(( i + 1 )) + done <$log_dir/failed.log + RET=1 +fi + +echo "${log_dir}" >&2 + +date + +exit $RET diff --git a/tests/parallel_test/run_case.sh b/tests/parallel_test/run_case.sh new file mode 100755 index 0000000000000000000000000000000000000000..5b7802ac2b346547e4d2cd171e93c1d5937a5360 --- /dev/null +++ b/tests/parallel_test/run_case.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +CONTAINER_TESTDIR=/home/community +# CONTAINER_TESTDIR=/root/tang/repository/TDengine + +# export PATH=$PATH:$CONTAINER_TESTDIR/debug/build/bin + +function usage() { + echo "$0" + echo -e "\t -d execution dir" + echo -e "\t -c command" + echo -e "\t -h help" +} + +while getopts "d:c:h" opt; do + case $opt in + d) + exec_dir=$OPTARG + ;; + c) + cmd=$OPTARG + ;; + h) + usage + exit 0 + ;; + \?) + echo "Invalid option: -$OPTARG" + usage + exit 0 + ;; + esac +done + +if [ -z "$exec_dir" ]; then + usage + exit 0 +fi +if [ -z "$cmd" ]; then + usage + exit 0 +fi + +go env -w GOPROXY=https://goproxy.cn +echo "StrictHostKeyChecking no" >>/etc/ssh/ssh_config +ln -s /home/debug/build/lib/libtaos.so /usr/lib/libtaos.so 2>/dev/null +npm config -g set unsafe-perm +npm config -g set registry https://registry.npm.taobao.org +mkdir -p /home/sim/tsim +mkdir -p /var/lib/taos/subscribe +rm -rf ${CONTAINER_TESTDIR}/src/connector/nodejs/node_modules +rm -rf ${CONTAINER_TESTDIR}/tests/examples/nodejs/node_modules +rm -rf ${CONTAINER_TESTDIR}/tests/connectorTest/nodejsTest/nanosupport/node_modules +# ln -s /home/node_modules ${CONTAINER_TESTDIR}/src/connector/nodejs/ +# ln -s /home/node_modules ${CONTAINER_TESTDIR}/tests/examples/nodejs/ +# ln -s /home/node_modules ${CONTAINER_TESTDIR}/tests/connectorTest/nodejsTest/nanosupport/ +# echo "$cmd"|grep -q "nodejs" +# if [ $? -eq 0 ]; then +# cd $CONTAINER_TESTDIR/src/connector/nodejs +# npm install node-gyp-build@4.3.0 --ignore-scripts +# fi + +cd $CONTAINER_TESTDIR/tests/$exec_dir +ulimit -c unlimited + +$cmd +RET=$? + +if [ $RET -ne 0 ]; then + pwd +fi + +exit $RET + diff --git a/tests/parallel_test/run_container.sh b/tests/parallel_test/run_container.sh new file mode 100755 index 0000000000000000000000000000000000000000..35ef3ad5a72b8c44b4de3db3159830c54cd1a6a3 --- /dev/null +++ b/tests/parallel_test/run_container.sh @@ -0,0 +1,107 @@ +#!/bin/bash + +function usage() { + echo "$0" + echo -e "\t -w work dir" + echo -e "\t -d execution dir" + echo -e "\t -c command" + echo -e "\t -t thread number" + echo -e "\t -h help" +} + +while getopts "w:d:c:t:h" opt; do + case $opt in + w) + WORKDIR=$OPTARG + ;; + d) + exec_dir=$OPTARG + ;; + c) + cmd=$OPTARG + ;; + t) + thread_no=$OPTARG + ;; + h) + usage + exit 0 + ;; + \?) + echo "Invalid option: -$OPTARG" + usage + exit 0 + ;; + esac +done + +if [ -z "$WORKDIR" ]; then + usage + exit 1 +fi +if [ -z "$exec_dir" ]; then + usage + exit 1 +fi +if [ -z "$cmd" ]; then + usage + exit 1 +fi +if [ -z "$thread_no" ]; then + usage + exit 1 +fi + +ulimit -c unlimited + +INTERNAL_REPDIR=$WORKDIR/TDinternal +REPDIR=$INTERNAL_REPDIR/community +CONTAINER_TESTDIR=/home/community +TMP_DIR=$WORKDIR/tmp + +MOUNT_DIR="" +mkdir -p ${TMP_DIR}/thread_volume/$thread_no/sim/tsim +mkdir -p ${TMP_DIR}/thread_volume/$thread_no/node_modules +mkdir -p ${TMP_DIR}/thread_volume/$thread_no/coredump +rm -rf ${TMP_DIR}/thread_volume/$thread_no/coredump/* +if [ ! -d "${TMP_DIR}/thread_volume/$thread_no/$exec_dir" ]; then + subdir=`echo "$exec_dir"|cut -d/ -f1` + echo "cp -rf ${REPDIR}/tests/$subdir ${TMP_DIR}/thread_volume/$thread_no/" + cp -rf ${REPDIR}/tests/$subdir ${TMP_DIR}/thread_volume/$thread_no/ +fi +MOUNT_DIR="$TMP_DIR/thread_volume/$thread_no/$exec_dir:$CONTAINER_TESTDIR/tests/$exec_dir" +echo "$thread_no -> ${exec_dir}:$cmd" +echo "$cmd"|grep -q "nodejs" +if [ $? -eq 0 ]; then + MOUNT_NODE_MOD="-v $TMP_DIR/thread_volume/$thread_no/node_modules:${CONTAINER_TESTDIR}/src/connector/nodejs/node_modules \ +-v $TMP_DIR/thread_volume/$thread_no/node_modules:${CONTAINER_TESTDIR}/tests/examples/nodejs/node_modules \ +-v $TMP_DIR/thread_volume/$thread_no/node_modules:${CONTAINER_TESTDIR}/tests/connectorTest/nodejsTest/nanosupport/node_modules" +fi +if [ -f "$REPDIR/src/plugins/taosadapter/example/config/taosadapter.toml" ]; then + TAOSADAPTER_TOML="-v $REPDIR/src/plugins/taosadapter/example/config/taosadapter.toml:/etc/taos/taosadapter.toml:ro" +fi + +docker run \ + -v $REPDIR/tests:$CONTAINER_TESTDIR/tests \ + -v $MOUNT_DIR \ + -v "$TMP_DIR/thread_volume/$thread_no/sim:${CONTAINER_TESTDIR}/sim" \ + -v ${TMP_DIR}/thread_volume/$thread_no/coredump:/home/coredump \ + -v $INTERNAL_REPDIR/debug:/home/debug:ro \ + -v $REPDIR/deps:$CONTAINER_TESTDIR/deps:ro \ + -v $REPDIR/src:$CONTAINER_TESTDIR/src \ + -v $REPDIR/src/inc/taos.h:/usr/include/taos.h:ro \ + $TAOSADAPTER_TOML \ + -v $REPDIR/examples:$CONTAINER_TESTDIR/tests/examples \ + -v $REPDIR/snap:$CONTAINER_TESTDIR/snap:ro \ + -v $REPDIR/alert:$CONTAINER_TESTDIR/alert:ro \ + -v $REPDIR/packaging/cfg/taos.cfg:/etc/taos/taos.cfg:ro \ + -v $REPDIR/packaging:$CONTAINER_TESTDIR/packaging:ro \ + -v $REPDIR/README.md:$CONTAINER_TESTDIR/README.md:ro \ + -v $REPDIR/src/connector/python/taos:/usr/local/lib/python3.8/site-packages/taos:ro \ + -e LD_LIBRARY_PATH=/home/debug/build/lib:/home/debug/build/lib64 \ + -e PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/debug/build/bin:/usr/local/go/bin:/usr/local/node-v12.20.0-linux-x64/bin:/usr/local/apache-maven-3.8.4/bin:/usr/local/jdk1.8.0_144/bin \ + -e JAVA_HOME=/usr/local/jdk1.8.0_144 \ + --rm --ulimit core=-1 taos_test:v1.0 $CONTAINER_TESTDIR/tests/parallel_test/run_case.sh -d "$exec_dir" -c "$cmd" +ret=$? +exit $ret + diff --git a/tests/perftest-scripts/cassandraTestQ1Loop.sh b/tests/perftest-scripts/cassandraTestQ1Loop.sh new file mode 100755 index 0000000000000000000000000000000000000000..e65ec2575c8070041c93a369dbb1b261d9cb37b2 --- /dev/null +++ b/tests/perftest-scripts/cassandraTestQ1Loop.sh @@ -0,0 +1,101 @@ +#!/bin/bash + +NUM_LOOP=5 + +function printTo { + if $verbose ; then + echo $1 + fi +} + +CASTESTQ1OUT=cassandraTestQ1.out + +function runTest { + totalG0=0 + totalG10=0 + totalG20=0 + totalG30=0 + totalG40=0 + totalG50=0 + totalG60=0 + totalG70=0 + totalG80=0 + totalG90=0 + for i in `seq 1 $NUM_LOOP`; do + printTo "loop i:$i, java -jar \ + $CASTEST_DIR/cassandratest/target/cassandratest-1.0-SNAPSHOT-jar-with-dependencies.jar \ + -conf $CASTEST_DIR/application.conf \ + -sql $CASTEST_DIR/q1.txt" + java -jar \ + $CASTEST_DIR/cassandratest/target/cassandratest-1.0-SNAPSHOT-jar-with-dependencies.jar \ + -conf $CASTEST_DIR/application.conf \ + -sql $CASTEST_DIR/q1.txt \ + > $CASTESTQ1OUT + G0=`grep "devgroup=0" $CASTESTQ1OUT| awk '{print $2}'` + totalG0=`echo "scale=4; $totalG0 + $G0" | bc` + G10=`grep "devgroup=10" $CASTESTQ1OUT| awk '{print $2}'` + totalG10=`echo "scale=4; $totalG10 + $G10" | bc` + G20=`grep "devgroup=20" $CASTESTQ1OUT| awk '{print $2}'` + totalG20=`echo "scale=4; $totalG20 + $G20" | bc` + G30=`grep "devgroup=30" $CASTESTQ1OUT| awk '{print $2}'` + totalG30=`echo "scale=4; $totalG30 + $G30" | bc` + G40=`grep "devgroup=40" $CASTESTQ1OUT| awk '{print $2}'` + totalG40=`echo "scale=4; $totalG40 + $G40" | bc` + G50=`grep "devgroup=50" $CASTESTQ1OUT| awk '{print $2}'` + totalG50=`echo "scale=4; $totalG50 + $G50" | bc` + G60=`grep "devgroup=60" $CASTESTQ1OUT| awk '{print $2}'` + totalG60=`echo "scale=4; $totalG60 + $G60" | bc` + G70=`grep "devgroup=70" $CASTESTQ1OUT| awk '{print $2}'` + totalG70=`echo "scale=4; $totalG70 + $G70" | bc` + G80=`grep "devgroup=80" $CASTESTQ1OUT| awk '{print $2}'` + totalG80=`echo "scale=4; $totalG80 + $G80" | bc` + G90=`grep "devgroup=90" $CASTESTQ1OUT| awk '{print $2}'` + totalG90=`echo "scale=4; $totalG90 + $G90" | bc` + done + avgG0=`echo "scale=4; x = $totalG0 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG10=`echo "scale=4; x = $totalG10 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG20=`echo "scale=4; x = $totalG20 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG30=`echo "scale=4; x = $totalG30 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG40=`echo "scale=4; x = $totalG40 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG50=`echo "scale=4; x = $totalG50 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG60=`echo "scale=4; x = $totalG60 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG70=`echo "scale=4; x = $totalG70 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG80=`echo "scale=4; x = $totalG80 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG90=`echo "scale=4; x = $totalG90 / $NUM_LOOP; if(x<1) print 0; x" | bc` + echo "Latency, G-0, G-10, G-20, G-30, G-40, G-50, G-60, G-70, G-80, G-90" + echo "Cassandra, $avgG0, $avgG10, $avgG20, $avgG30, $avgG40, $avgG50, $avgG60, $avgG70, $avgG80, $avgG90" +} + +################ Main ################ + +master=false +develop=true +verbose=false + +clients=1 + +while : ; do + case $1 in + -v) + verbose=true + shift ;; + + -c) + clients=$2 + shift 2;; + + -n) + NUM_LOOP=$2 + shift 2;; + + *) + break ;; + esac +done + +WORK_DIR=/mnt/root/TDengine +CASTEST_DIR=$WORK_DIR/tests/comparisonTest/cassandra + +runTest + +printTo "Test done!" diff --git a/tests/perftest-scripts/cassandraTestQ2Loop.sh b/tests/perftest-scripts/cassandraTestQ2Loop.sh new file mode 100755 index 0000000000000000000000000000000000000000..76e42cf89d6a8f0d1a395b41d9a357def3d37efb --- /dev/null +++ b/tests/perftest-scripts/cassandraTestQ2Loop.sh @@ -0,0 +1,278 @@ +#!/bin/bash + +NUM_LOOP=5 + +function printTo { + if $verbose ; then + echo $1 + fi +} + +CASTESTQ2OUT=cassandraTestQ2.out + +function runTest { + totalCount10=0 + totalCount20=0 + totalCount30=0 + totalCount40=0 + totalCount50=0 + totalCount60=0 + totalCount70=0 + totalCount80=0 + totalCount90=0 + totalCount100=0 + + totalAvg10=0 + totalAvg20=0 + totalAvg30=0 + totalAvg40=0 + totalAvg50=0 + totalAvg60=0 + totalAvg70=0 + totalAvg80=0 + totalAvg90=0 + totalAvg100=0 + + totalSum10=0 + totalSum20=0 + totalSum30=0 + totalSum40=0 + totalSum50=0 + totalSum60=0 + totalSum70=0 + totalSum80=0 + totalSum90=0 + totalSum100=0 + + totalMax10=0 + totalMax20=0 + totalMax30=0 + totalMax40=0 + totalMax50=0 + totalMax60=0 + totalMax70=0 + totalMax80=0 + totalMax90=0 + totalMax100=0 + + totalMin10=0 + totalMin20=0 + totalMin30=0 + totalMin40=0 + totalMin50=0 + totalMin60=0 + totalMin70=0 + totalMin80=0 + totalMin90=0 + totalMin100=0 + + for i in `seq 1 $NUM_LOOP`; do + printTo "loop i:$i, java -jar \ + $CASTEST_DIR/cassandratest/target/cassandratest-1.0-SNAPSHOT-jar-with-dependencies.jar \ + -conf $CASTEST_DIR/application.conf \ + -sql $CASTEST_DIR/q2.txt" + java -jar \ + $CASTEST_DIR/cassandratest/target/cassandratest-1.0-SNAPSHOT-jar-with-dependencies.jar \ + -conf $CASTEST_DIR/application.conf \ + -sql $CASTEST_DIR/q2.txt \ + > $CASTESTQ2OUT + + Count10=`cat $CASTESTQ2OUT | grep count | grep "devgroup<10" | awk '{print $2}'` + totalCount10=`echo "scale=4; $totalCount10 + $Count10" | bc` + Count20=`cat $CASTESTQ2OUT | grep count | grep "devgroup<20" | awk '{print $2}'` + totalCount20=`echo "scale=4; $totalCount20 + $Count20" | bc` + Count30=`cat $CASTESTQ2OUT | grep count | grep "devgroup<30" | awk '{print $2}'` + totalCount30=`echo "scale=4; $totalCount30 + $Count30" | bc` + Count40=`cat $CASTESTQ2OUT | grep count | grep "devgroup<40" | awk '{print $2}'` + totalCount40=`echo "scale=4; $totalCount40 + $Count40" | bc` + Count50=`cat $CASTESTQ2OUT | grep count | grep "devgroup<50" | awk '{print $2}'` + totalCount50=`echo "scale=4; $totalCount50 + $Count50" | bc` + Count60=`cat $CASTESTQ2OUT | grep count | grep "devgroup<60" | awk '{print $2}'` + totalCount60=`echo "scale=4; $totalCount60 + $Count60" | bc` + Count70=`cat $CASTESTQ2OUT | grep count | grep "devgroup<70" | awk '{print $2}'` + totalCount70=`echo "scale=4; $totalCount70 + $Count70" | bc` + Count80=`cat $CASTESTQ2OUT | grep count | grep "devgroup<80" | awk '{print $2}'` + totalCount80=`echo "scale=4; $totalCount80 + $Count80" | bc` + Count90=`cat $CASTESTQ2OUT | grep count | grep "devgroup<90" | awk '{print $2}'` + totalCount90=`echo "scale=4; $totalCount90 + $Count90" | bc` + Count100=`cat $CASTESTQ2OUT | grep count | grep "test allow filtering;" | awk '{print $2}'` + totalCount100=`echo "scale=4; $totalCount100 + $Count100" | bc` + + Avg10=`cat $CASTESTQ2OUT | grep avg | grep "devgroup<10" | awk '{print $2}'` + totalAvg10=`echo "scale=4; $totalAvg10 + $Avg10" | bc` + Avg20=`cat $CASTESTQ2OUT | grep avg | grep "devgroup<20" | awk '{print $2}'` + totalAvg20=`echo "scale=4; $totalAvg20 + $Avg20" | bc` + Avg30=`cat $CASTESTQ2OUT | grep avg | grep "devgroup<30" | awk '{print $2}'` + totalAvg30=`echo "scale=4; $totalAvg30 + $Avg30" | bc` + Avg40=`cat $CASTESTQ2OUT | grep avg | grep "devgroup<40" | awk '{print $2}'` + totalAvg40=`echo "scale=4; $totalAvg40 + $Avg40" | bc` + Avg50=`cat $CASTESTQ2OUT | grep avg | grep "devgroup<50" | awk '{print $2}'` + totalAvg50=`echo "scale=4; $totalAvg50 + $Avg50" | bc` + Avg60=`cat $CASTESTQ2OUT | grep avg | grep "devgroup<60" | awk '{print $2}'` + totalAvg60=`echo "scale=4; $totalAvg60 + $Avg60" | bc` + Avg70=`cat $CASTESTQ2OUT | grep avg | grep "devgroup<70" | awk '{print $2}'` + totalAvg70=`echo "scale=4; $totalAvg70 + $Avg70" | bc` + Avg80=`cat $CASTESTQ2OUT | grep avg | grep "devgroup<80" | awk '{print $2}'` + totalAvg80=`echo "scale=4; $totalAvg80 + $Avg80" | bc` + Avg90=`cat $CASTESTQ2OUT | grep avg | grep "devgroup<90" | awk '{print $2}'` + totalAvg90=`echo "scale=4; $totalAvg90 + $Avg90" | bc` + Avg100=`cat $CASTESTQ2OUT | grep avg | grep "test allow filtering;" | awk '{print $2}'` + totalAvg100=`echo "scale=4; $totalAvg100 + $Avg100" | bc` + + Sum10=`cat $CASTESTQ2OUT | grep sum | grep "devgroup<10" | awk '{print $2}'` + totalSum10=`echo "scale=4; $totalSum10 + $Sum10" | bc` + Sum20=`cat $CASTESTQ2OUT | grep sum | grep "devgroup<20" | awk '{print $2}'` + totalSum20=`echo "scale=4; $totalSum20 + $Sum20" | bc` + Sum30=`cat $CASTESTQ2OUT | grep sum | grep "devgroup<30" | awk '{print $2}'` + totalSum30=`echo "scale=4; $totalSum30 + $Sum30" | bc` + Sum40=`cat $CASTESTQ2OUT | grep sum | grep "devgroup<40" | awk '{print $2}'` + totalSum40=`echo "scale=4; $totalSum40 + $Sum40" | bc` + Sum50=`cat $CASTESTQ2OUT | grep sum | grep "devgroup<50" | awk '{print $2}'` + totalSum50=`echo "scale=4; $totalSum50 + $Sum50" | bc` + Sum60=`cat $CASTESTQ2OUT | grep sum | grep "devgroup<60" | awk '{print $2}'` + totalSum60=`echo "scale=4; $totalSum60 + $Sum60" | bc` + Sum70=`cat $CASTESTQ2OUT | grep sum | grep "devgroup<70" | awk '{print $2}'` + totalSum70=`echo "scale=4; $totalSum70 + $Sum70" | bc` + Sum80=`cat $CASTESTQ2OUT | grep sum | grep "devgroup<80" | awk '{print $2}'` + totalSum80=`echo "scale=4; $totalSum80 + $Sum80" | bc` + Sum90=`cat $CASTESTQ2OUT | grep sum | grep "devgroup<90" | awk '{print $2}'` + totalSum90=`echo "scale=4; $totalSum90 + $Sum90" | bc` + Sum100=`cat $CASTESTQ2OUT | grep sum | grep "test allow filtering;" | awk '{print $2}'` + totalSum100=`echo "scale=4; $totalSum100 + $Sum100" | bc` + + Max10=`cat $CASTESTQ2OUT | grep max | grep "devgroup<10" | awk '{print $2}'` + totalMax10=`echo "scale=4; $totalMax10 + $Max10" | bc` + Max20=`cat $CASTESTQ2OUT | grep max | grep "devgroup<20" | awk '{print $2}'` + totalMax20=`echo "scale=4; $totalMax20 + $Max20" | bc` + Max30=`cat $CASTESTQ2OUT | grep max | grep "devgroup<30" | awk '{print $2}'` + totalMax30=`echo "scale=4; $totalMax30 + $Max30" | bc` + Max40=`cat $CASTESTQ2OUT | grep max | grep "devgroup<40" | awk '{print $2}'` + totalMax40=`echo "scale=4; $totalMax40 + $Max40" | bc` + Max50=`cat $CASTESTQ2OUT | grep max | grep "devgroup<50" | awk '{print $2}'` + totalMax50=`echo "scale=4; $totalMax50 + $Max50" | bc` + Max60=`cat $CASTESTQ2OUT | grep max | grep "devgroup<60" | awk '{print $2}'` + totalMax60=`echo "scale=4; $totalMax60 + $Max60" | bc` + Max70=`cat $CASTESTQ2OUT | grep max | grep "devgroup<70" | awk '{print $2}'` + totalMax70=`echo "scale=4; $totalMax70 + $Max70" | bc` + Max80=`cat $CASTESTQ2OUT | grep max | grep "devgroup<80" | awk '{print $2}'` + totalMax80=`echo "scale=4; $totalMax80 + $Max80" | bc` + Max90=`cat $CASTESTQ2OUT | grep max | grep "devgroup<90" | awk '{print $2}'` + totalMax90=`echo "scale=4; $totalMax90 + $Max90" | bc` + Max100=`cat $CASTESTQ2OUT | grep max | grep "test allow filtering;" | awk '{print $2}'` + totalMax100=`echo "scale=4; $totalMax100 + $Max100" | bc` + + Min10=`cat $CASTESTQ2OUT | grep min | grep "devgroup<10" | awk '{print $2}'` + totalMin10=`echo "scale=4; $totalMin10 + $Min10" | bc` + Min20=`cat $CASTESTQ2OUT | grep min | grep "devgroup<20" | awk '{print $2}'` + totalMin20=`echo "scale=4; $totalMin20 + $Min20" | bc` + Min30=`cat $CASTESTQ2OUT | grep min | grep "devgroup<30" | awk '{print $2}'` + totalMin30=`echo "scale=4; $totalMin30 + $Min30" | bc` + Min40=`cat $CASTESTQ2OUT | grep min | grep "devgroup<40" | awk '{print $2}'` + totalMin40=`echo "scale=4; $totalMin40 + $Min40" | bc` + Min50=`cat $CASTESTQ2OUT | grep min | grep "devgroup<50" | awk '{print $2}'` + totalMin50=`echo "scale=4; $totalMin50 + $Min50" | bc` + Min60=`cat $CASTESTQ2OUT | grep min | grep "devgroup<60" | awk '{print $2}'` + totalMin60=`echo "scale=4; $totalMin60 + $Min60" | bc` + Min70=`cat $CASTESTQ2OUT | grep min | grep "devgroup<70" | awk '{print $2}'` + totalMin70=`echo "scale=4; $totalMin70 + $Min70" | bc` + Min80=`cat $CASTESTQ2OUT | grep min | grep "devgroup<80" | awk '{print $2}'` + totalMin80=`echo "scale=4; $totalMin80 + $Min80" | bc` + Min90=`cat $CASTESTQ2OUT | grep min | grep "devgroup<90" | awk '{print $2}'` + totalMin90=`echo "scale=4; $totalMin90 + $Min90" | bc` + Min100=`cat $CASTESTQ2OUT | grep min | grep "test allow filtering;" | awk '{print $2}'` + totalMin100=`echo "scale=4; $totalMin100 + $Min100" | bc` + + done + avgCount10=`echo "scale=4; x = $totalCount10 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount20=`echo "scale=4; x = $totalCount20 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount30=`echo "scale=4; x = $totalCount30 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount40=`echo "scale=4; x = $totalCount40 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount50=`echo "scale=4; x = $totalCount50 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount60=`echo "scale=4; x = $totalCount60 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount70=`echo "scale=4; x = $totalCount70 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount80=`echo "scale=4; x = $totalCount80 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount90=`echo "scale=4; x = $totalCount90 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount100=`echo "scale=4; x = $totalCount100 / $NUM_LOOP; if(x<1) print 0; x" | bc` + + avgAvg10=`echo "scale=4; x = $totalAvg10 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgAvg20=`echo "scale=4; x = $totalAvg20 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgAvg30=`echo "scale=4; x = $totalAvg30 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgAvg40=`echo "scale=4; x = $totalAvg40 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgAvg50=`echo "scale=4; x = $totalAvg50 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgAvg60=`echo "scale=4; x = $totalAvg60 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgAvg70=`echo "scale=4; x = $totalAvg70 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgAvg80=`echo "scale=4; x = $totalAvg80 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgAvg90=`echo "scale=4; x = $totalAvg90 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgAvg100=`echo "scale=4; x = $totalAvg100 / $NUM_LOOP; if(x<1) print 0; x" | bc` + + avgSum10=`echo "scale=4; x = $totalSum10 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum20=`echo "scale=4; x = $totalSum20 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum30=`echo "scale=4; x = $totalSum30 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum40=`echo "scale=4; x = $totalSum40 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum50=`echo "scale=4; x = $totalSum50 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum60=`echo "scale=4; x = $totalSum60 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum70=`echo "scale=4; x = $totalSum70 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum80=`echo "scale=4; x = $totalSum80 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum90=`echo "scale=4; x = $totalSum90 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum100=`echo "scale=4; x = $totalSum100 / $NUM_LOOP; if(x<1) print 0; x" | bc` + + avgMax10=`echo "scale=4; x = $totalMax10 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax20=`echo "scale=4; x = $totalMax20 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax30=`echo "scale=4; x = $totalMax30 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax40=`echo "scale=4; x = $totalMax40 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax50=`echo "scale=4; x = $totalMax50 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax60=`echo "scale=4; x = $totalMax60 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax70=`echo "scale=4; x = $totalMax70 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax80=`echo "scale=4; x = $totalMax80 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax90=`echo "scale=4; x = $totalMax90 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax100=`echo "scale=4; x = $totalMax100 / $NUM_LOOP; if(x<1) print 0; x" | bc` + + avgMin10=`echo "scale=4; x = $totalMin10 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin20=`echo "scale=4; x = $totalMin20 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin30=`echo "scale=4; x = $totalMin30 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin40=`echo "scale=4; x = $totalMin40 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin50=`echo "scale=4; x = $totalMin50 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin60=`echo "scale=4; x = $totalMin60 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin70=`echo "scale=4; x = $totalMin70 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin80=`echo "scale=4; x = $totalMin80 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin90=`echo "scale=4; x = $totalMin90 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin100=`echo "scale=4; x = $totalMin100 / $NUM_LOOP; if(x<1) print 0; x" | bc` + + echo "Latency, 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%, 100%" + echo "Count, $avgCount10, $avgCount20, $avgCount30, $avgCount40, $avgCount50, $avgCount60, $avgCount70, $avgCount80, $avgCount90, $avgCount100" + echo "Avg, $avgAvg10, $avgAvg20, $avgAvg30, $avgAvg40, $avgAvg50, $avgAvg60, $avgAvg70, $avgAvg80, $avgAvg90, $avgAvg100" + echo "Sum, $avgSum10, $avgSum20, $avgSum30, $avgSum40, $avgSum50, $avgSum60, $avgSum70, $avgSum80, $avgSum90, $avgSum100" + echo "Max, $avgMax10, $avgMax20, $avgMax30, $avgMax40, $avgMax50, $avgMax60, $avgMax70, $avgMax80, $avgMax90, $avgMax100" + echo "Min, $avgMin10, $avgMin20, $avgMin30, $avgMin40, $avgMin50, $avgMin60, $avgMin70, $avgMin80, $avgMin90, $avgMin100" +} + +################ Main ################ + +verbose=false + +for arg in "$@" +do + case $arg in + -v) + verbose=true + shift ;; + + -c) + clients=$2 + shift 2;; + + -n) + NUM_LOOP=$2 + shift 2;; + + *) + ;; + esac +done + +WORK_DIR=/mnt/root/TDengine +CASTEST_DIR=$WORK_DIR/tests/comparisonTest/cassandra + +runTest + +printTo "Test done!" diff --git a/tests/perftest-scripts/cassandraTestQ3Loop.sh b/tests/perftest-scripts/cassandraTestQ3Loop.sh new file mode 100755 index 0000000000000000000000000000000000000000..ce81fcb818bd90bd99ab9b31a58db611445efffd --- /dev/null +++ b/tests/perftest-scripts/cassandraTestQ3Loop.sh @@ -0,0 +1,98 @@ +#!/bin/bash + +NUM_LOOP=5 + +function printTo { + if $verbose ; then + echo $1 + fi +} + +CASTESTQ3OUT=cassandraTestQ3.out + +function runTest { + totalG10=0 + totalG20=0 + totalG30=0 + totalG40=0 + totalG50=0 + totalG60=0 + totalG70=0 + totalG80=0 + totalG90=0 + totalG100=0 + for i in `seq 1 $NUM_LOOP`; do + printTo "loop i:$i, java -jar \ + $CASTEST_DIR/cassandratest/target/cassandratest-1.0-SNAPSHOT-jar-with-dependencies.jar \ + -conf $CASTEST_DIR/application.conf \ + -sql $CASTEST_DIR/q3.txt" + java -jar \ + $CASTEST_DIR/cassandratest/target/cassandratest-1.0-SNAPSHOT-jar-with-dependencies.jar \ + -conf $CASTEST_DIR/application.conf \ + -sql $CASTEST_DIR/q3.txt \ + > $CASTESTQ3OUT + G10=`grep "devgroup<10" $CASTESTQ3OUT| awk '{print $2}'` + totalG10=`echo "scale=4; $totalG10 + $G10" | bc` + G20=`grep "devgroup<20" $CASTESTQ3OUT| awk '{print $2}'` + totalG20=`echo "scale=4; $totalG20 + $G20" | bc` + G30=`grep "devgroup<30" $CASTESTQ3OUT| awk '{print $2}'` + totalG30=`echo "scale=4; $totalG30 + $G30" | bc` + G40=`grep "devgroup<40" $CASTESTQ3OUT| awk '{print $2}'` + totalG40=`echo "scale=4; $totalG40 + $G40" | bc` + G50=`grep "devgroup<50" $CASTESTQ3OUT| awk '{print $2}'` + totalG50=`echo "scale=4; $totalG50 + $G50" | bc` + G60=`grep "devgroup<60" $CASTESTQ3OUT| awk '{print $2}'` + totalG60=`echo "scale=4; $totalG60 + $G60" | bc` + G70=`grep "devgroup<70" $CASTESTQ3OUT| awk '{print $2}'` + totalG70=`echo "scale=4; $totalG70 + $G70" | bc` + G80=`grep "devgroup<80" $CASTESTQ3OUT| awk '{print $2}'` + totalG80=`echo "scale=4; $totalG80 + $G80" | bc` + G90=`grep "devgroup<90" $CASTESTQ3OUT| awk '{print $2}'` + totalG90=`echo "scale=4; $totalG90 + $G90" | bc` + G100=`grep "test group by " $CASTESTQ3OUT| awk '{print $2}'` + totalG100=`echo "scale=4; $totalG100 + $G100" | bc` + done + avgG10=`echo "scale=4; x = $totalG10 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG20=`echo "scale=4; x = $totalG20 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG30=`echo "scale=4; x = $totalG30 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG40=`echo "scale=4; x = $totalG40 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG50=`echo "scale=4; x = $totalG50 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG60=`echo "scale=4; x = $totalG60 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG70=`echo "scale=4; x = $totalG70 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG80=`echo "scale=4; x = $totalG80 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG90=`echo "scale=4; x = $totalG90 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG100=`echo "scale=4; x = $totalG100 / $NUM_LOOP; if(x<1) print 0; x" | bc` + echo "Latency, 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%, 100%" + echo "Cassandra, $avgG10, $avgG20, $avgG30, $avgG40, $avgG50, $avgG60, $avgG70, $avgG80, $avgG90, $avgG100" +} + +################ Main ################ + +verbose=false + +for arg in "$@" +do + case $arg in + -v) + verbose=true + shift ;; + + -c) + clients=$2 + shift 2;; + + -n) + NUM_LOOP=$2 + shift 2;; + + *) + ;; + esac +done + +WORK_DIR=/mnt/root/TDengine +CASTEST_DIR=$WORK_DIR/tests/comparisonTest/cassandra + +runTest + +printTo "Test done!" diff --git a/tests/perftest-scripts/cassandraTestQ4Loop.sh b/tests/perftest-scripts/cassandraTestQ4Loop.sh new file mode 100755 index 0000000000000000000000000000000000000000..85e45787b89a7700f0b6de3eb87ee8143f05ca92 --- /dev/null +++ b/tests/perftest-scripts/cassandraTestQ4Loop.sh @@ -0,0 +1,123 @@ +#!/bin/bash + +DATA_DIR=/mnt/root/testdata +NUM_LOOP=5 + +function printTo { + if $verbose ; then + echo $1 + fi +} + +CASTESTQ4OUT=cassandraTestQ4.out + +function runTest { + totalG10=0 + totalG20=0 + totalG30=0 + totalG40=0 + totalG50=0 + totalG60=0 + totalG70=0 + totalG80=0 + totalG90=0 + totalG100=0 + for i in `seq 1 $NUM_LOOP`; do + if $regeneratedata ; then + printTo "java -jar $CASTEST_DIR/cassandratest-1.0-SNAPSHOT-jar-with-dependencies.jar \ + -datadir $DATA_DIR \ + -numofFiles 100 \ + -rowsperrequest 100 \ + -writeclients 4 \ + -conf $CASTEST_DIR/application.conf \ + -timetest" + java -jar $CASTEST_DIR/cassandratest-1.0-SNAPSHOT-jar-with-dependencies.jar \ + -datadir $DATA_DIR \ + -numofFiles 100 \ + -rowsperrequest 100 \ + -writeclients 4 \ + -conf $CASTEST_DIR/application.conf \ + -timetest + fi + + printTo "loop i:$i, java -jar \ + $CASTEST_DIR/cassandratest/target/cassandratest-1.0-SNAPSHOT-jar-with-dependencies.jar \ + -conf $CASTEST_DIR/application.conf \ + -sql $CASTEST_DIR/q4.txt" + java -jar \ + $CASTEST_DIR/cassandratest/target/cassandratest-1.0-SNAPSHOT-jar-with-dependencies.jar \ + -conf $CASTEST_DIR/application.conf \ + -sql $CASTEST_DIR/q4.txt \ + > $CASTESTQ4OUT + G10=`grep "devgroup<10" $CASTESTQ4OUT| awk '{print $2}'` + totalG10=`echo "scale=4; $totalG10 + $G10" | bc` + G20=`grep "devgroup<20" $CASTESTQ4OUT| awk '{print $2}'` + totalG20=`echo "scale=4; $totalG20 + $G20" | bc` + G30=`grep "devgroup<30" $CASTESTQ4OUT| awk '{print $2}'` + totalG30=`echo "scale=4; $totalG30 + $G30" | bc` + G40=`grep "devgroup<40" $CASTESTQ4OUT| awk '{print $2}'` + totalG40=`echo "scale=4; $totalG40 + $G40" | bc` + G50=`grep "devgroup<50" $CASTESTQ4OUT| awk '{print $2}'` + totalG50=`echo "scale=4; $totalG50 + $G50" | bc` + G60=`grep "devgroup<60" $CASTESTQ4OUT| awk '{print $2}'` + totalG60=`echo "scale=4; $totalG60 + $G60" | bc` + G70=`grep "devgroup<70" $CASTESTQ4OUT| awk '{print $2}'` + totalG70=`echo "scale=4; $totalG70 + $G70" | bc` + G80=`grep "devgroup<80" $CASTESTQ4OUT| awk '{print $2}'` + totalG80=`echo "scale=4; $totalG80 + $G80" | bc` + G90=`grep "devgroup<90" $CASTESTQ4OUT| awk '{print $2}'` + totalG90=`echo "scale=4; $totalG90 + $G90" | bc` + G100=`grep "test group by minute;" $CASTESTQ4OUT| awk '{print $2}'` + totalG100=`echo "scale=4; $totalG100 + $G100" | bc` + done + avgG10=`echo "scale=4; x = $totalG10 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG20=`echo "scale=4; x = $totalG20 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG30=`echo "scale=4; x = $totalG30 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG40=`echo "scale=4; x = $totalG40 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG50=`echo "scale=4; x = $totalG50 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG60=`echo "scale=4; x = $totalG60 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG70=`echo "scale=4; x = $totalG70 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG80=`echo "scale=4; x = $totalG80 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG90=`echo "scale=4; x = $totalG90 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG100=`echo "scale=4; x = $totalG100 / $NUM_LOOP; if(x<1) print 0; x" | bc` + echo "Latency, 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%, 100%" + echo "Cassandra, $avgG10, $avgG20, $avgG30, $avgG40, $avgG50, $avgG60, $avgG70, $avgG80, $avgG90, $avgG100" +} + +################ Main ################ + +master=false +develop=true +verbose=false +regeneratedata=false + +for arg in "$@" +do + case $arg in + -v) + verbose=true + shift ;; + + -c) + clients=$2 + shift 2;; + + -r) + regeneratedata=true + ;; + + -n) + NUM_LOOP=$2 + shift 2;; + + *) + ;; + esac +done + +WORK_DIR=/mnt/root/TDengine +CASTEST_DIR=$WORK_DIR/tests/comparisonTest/cassandra + +runTest + +printTo "Test done!" diff --git a/tests/perftest-scripts/cassandraTestWriteLoop.sh b/tests/perftest-scripts/cassandraTestWriteLoop.sh new file mode 100755 index 0000000000000000000000000000000000000000..d20b6204124696b994817c141f1cfc310a4f062d --- /dev/null +++ b/tests/perftest-scripts/cassandraTestWriteLoop.sh @@ -0,0 +1,101 @@ +#!/bin/bash + +DATA_DIR=/mnt/root/testdata +NUM_LOOP=1 +NUM_OF_FILES=100 + +rowsPerRequest=(1 10 50 100 500 1000 2000) + +function printTo { + if $verbose ; then + echo $1 + fi +} + +function runTest { + declare -A avgRPR + + for r in ${!rowsPerRequest[@]}; do + for c in `seq 1 $clients`; do + avgRPR[$r,$c]=0 + done + done + + for r in ${!rowsPerRequest[@]}; do + for c in `seq 1 $clients`; do + totalRPR=0 + OUT_FILE=cassandraWrite-rows${rowsPerRequest[$r]}-clients$c.out + for i in `seq 1 $NUM_LOOP`; do + printTo "loop i:$i, java -jar $CAS_TEST_DIR/cassandratest/target/cassandratest-1.0-SNAPSHOT-jar-with-dependencies.jar \ + -datadir $DATA_DIR \ + -numofFiles $NUM_OF_FILES \ + -rowsperrequest ${rowsPerRequest[$r]} \ + -writeclients $c \ + -conf $CAS_TEST_DIR/application.conf" + java -jar $CAS_TEST_DIR/cassandratest/target/cassandratest-1.0-SNAPSHOT-jar-with-dependencies.jar \ + -datadir $DATA_DIR \ + -numofFiles $NUM_OF_FILES \ + -rowsperrequest ${rowsPerRequest[$r]} \ + -writeclients $c \ + -conf $CAS_TEST_DIR/application.conf \ + 2>&1 | tee $OUT_FILE + RPR=`cat $OUT_FILE | grep "insertation speed:" | awk '{print $(NF-1)}'` + totalRPR=`echo "scale=4; $totalRPR + $RPR" | bc` + printTo "r:$r rows:${rowsPerRequest[$r]}, clients:$c, i:$i RPR:$RPR" + done + avgRPR[$r,$c]=`echo "scale=4; $totalRPR / $NUM_LOOP" | bc` + printTo "r:$r c:$c avgRPR:${avgRPR[$r,$c]}" + done + done + + printf "R/R, " + for c in `seq 1 $clients`; do + if [ "$c" == "1" ]; then + printf "$c client, " + else + printf "$c clients, " + fi + done + printf "\n" + + for r in ${!rowsPerRequest[@]}; do + printf "${rowsPerRequest[$r]}, " + for c in `seq 1 $clients`; do + printf "${avgRPR[$r,$c]}, " + done + printf "\n" + done +} + +################ Main ################ + +verbose=false +clients=1 + +while : ; do + case $1 in + -v) + verbose=true + shift ;; + + -n) + NUM_LOOP=$2 + shift 2;; + + -c) + clients=$2 + shift 2;; + + *) + break ;; + esac +done + +printTo "Cassandra Test begin.." + +WORK_DIR=/mnt/root/TDengine +CAS_TEST_DIR=$WORK_DIR/tests/comparisonTest/cassandra + +runTest + +printTo "Cassandra Test done!" diff --git a/tests/perftest-scripts/coverage_test.sh b/tests/perftest-scripts/coverage_test.sh new file mode 100755 index 0000000000000000000000000000000000000000..1be2053f24f28dd825c040912783675b1eab94f9 --- /dev/null +++ b/tests/perftest-scripts/coverage_test.sh @@ -0,0 +1,217 @@ +#!/bin/bash + +today=`date +"%Y%m%d"` +TDENGINE_DIR=/home/shuduo/work/taosdata/TDengine.cover +TDENGINE_COVERAGE_REPORT=$TDENGINE_DIR/tests/coverage-report-$today.log + +# Color setting +RED='\033[0;31m' +GREEN='\033[1;32m' +GREEN_DARK='\033[0;32m' +GREEN_UNDERLINE='\033[4;32m' +NC='\033[0m' + +function buildTDengine { + echo "check if TDengine need build" + cd $TDENGINE_DIR + git remote prune origin > /dev/null + git remote update > /dev/null + REMOTE_COMMIT=`git rev-parse --short remotes/origin/develop` + LOCAL_COMMIT=`git rev-parse --short @` + echo " LOCAL: $LOCAL_COMMIT" + echo "REMOTE: $REMOTE_COMMIT" + + # reset counter + lcov -d . --zerocounters + + cd $TDENGINE_DIR/debug + + if [ "$LOCAL_COMMIT" == "$REMOTE_COMMIT" ]; then + echo "repo up-to-date" + else + echo "repo need to pull" + git reset --hard + git pull + fi + + [ -d $TDENGINE_DIR/debug ] || mkdir $TDENGINE_DIR/debug + cd $TDENGINE_DIR/debug + [ -f $TDENGINE_DIR/debug/build/bin/taosd ] || need_rebuild=true + + if $need_rebuild ; then + echo "rebuild.." + LOCAL_COMMIT=`git rev-parse --short @` + + rm -rf * + cmake -DCOVER=true -DRANDOM_FILE_FAIL=true .. > /dev/null + make > /dev/null + fi + + make install > /dev/null +} + +function runGeneralCaseOneByOne { + while read -r line; do + if [[ $line =~ ^./test.sh* ]]; then + case=`echo $line | grep sim$ |awk '{print $NF}'` + + if [ -n "$case" ]; then + date +%F\ %T | tee -a $TDENGINE_COVERAGE_REPORT && ./test.sh -f $case > /dev/null 2>&1 && \ + ( grep -q 'script.*success.*m$' ../../sim/tsim/log/taoslog0.0 && echo -e "${GREEN}$case success${NC}" | tee -a $TDENGINE_COVERAGE_REPORT ) \ + || echo -e "${RED}$case failed${NC}" | tee -a $TDENGINE_COVERAGE_REPORT + fi + fi + done < $1 +} + +function runTest { + echo "run Test" + + cd $TDENGINE_DIR/tests/script + + [ -d ../../sim ] && rm -rf ../../sim + [ -f $TDENGINE_COVERAGE_REPORT ] && rm $TDENGINE_COVERAGE_REPORT + + runGeneralCaseOneByOne jenkins/basic.txt + + sed -i "1i\SIM cases test result" $TDENGINE_COVERAGE_REPORT + + totalSuccess=`grep 'success' $TDENGINE_COVERAGE_REPORT | wc -l` + if [ "$totalSuccess" -gt "0" ]; then + sed -i -e "2i\ ### Total $totalSuccess SIM test case(s) succeed! ###" $TDENGINE_COVERAGE_REPORT + fi + + totalFailed=`grep 'failed\|fault' $TDENGINE_COVERAGE_REPORT | wc -l` + if [ "$totalFailed" -ne "0" ]; then + sed -i '3i\### Total $totalFailed SIM test case(s) failed! ###' $TDENGINE_COVERAGE_REPORT + else + sed -i '3i\\n' $TDENGINE_COVERAGE_REPORT + fi + + cd $TDENGINE_DIR/tests + rm -rf ../sim + ./test-all.sh full python | tee -a $TDENGINE_COVERAGE_REPORT + + sed -i "4i\Python cases test result" $TDENGINE_COVERAGE_REPORT + totalPySuccess=`grep 'python case(s) succeed!' $TDENGINE_COVERAGE_REPORT | awk '{print $4}'` + if [ "$totalPySuccess" -gt "0" ]; then + sed -i -e "5i\ ### Total $totalPySuccess Python test case(s) succeed! ###" $TDENGINE_COVERAGE_REPORT + fi + + totalPyFailed=`grep 'python case(s) failed!' $TDENGINE_COVERAGE_REPORT | awk '{print $4}'` + if [ -z $totalPyFailed ]; then + sed -i '6i\\n' $TDENGINE_COVERAGE_REPORT + else + sed -i '6i\### Total $totalPyFailed Python test case(s) failed! ###' $TDENGINE_COVERAGE_REPORT + fi + + # Test Connector + stopTaosd + $TDENGINE_DIR/debug/build/bin/taosd -c $TDENGINE_DIR/debug/test/cfg > /dev/null & + sleep 10 + + cd $TDENGINE_DIR/src/connector/jdbc + mvn clean package > /dev/null 2>&1 + mvn test > /dev/null 2>&1 | tee -a $TDENGINE_COVERAGE_REPORT + + # Test C Demo + stopTaosd + $TDENGINE_DIR/debug/build/bin/taosd -c $TDENGINE_DIR/debug/test/cfg > /dev/null & + sleep 10 + yes | $TDENGINE_DIR/debug/build/bin/demo 127.0.0.1 > /dev/null 2>&1 | tee -a $TDENGINE_COVERAGE_REPORT + + # Test waltest + dataDir=`grep dataDir $TDENGINE_DIR/debug/test/cfg/taos.cfg|awk '{print $2}'` + walDir=`find $dataDir -name "wal"|head -n1` + echo "dataDir: $dataDir" | tee -a $TDENGINE_COVERAGE_REPORT + echo "walDir: $walDir" | tee -a $TDENGINE_COVERAGE_REPORT + if [ -n "$walDir" ]; then + yes | $TDENGINE_DIR/debug/build/bin/waltest -p $walDir > dev/null 2>&1 | tee -a $TDENGINE_COVERAGE_REPORT + fi + + # run Unit Test + echo "Run Unit Test: utilTest, queryTest and cliTest" + $TDENGINE_DIR/debug/build/bin/utilTest > /dev/null 2>&1 && echo "utilTest pass!" || echo "utilTest failed!" + $TDENGINE_DIR/debug/build/bin/queryTest > /dev/null 2>&1 && echo "queryTest pass!" || echo "queryTest failed!" + $TDENGINE_DIR/debug/build/bin/cliTest > /dev/null 2>&1 && echo "cliTest pass!" || echo "cliTest failed!" + + stopTaosd +} + +function lcovFunc { + echo "collect data by lcov" + cd $TDENGINE_DIR + + # collect data + lcov -d . --capture --rc lcov_branch_coverage=1 --rc genhtml_branch_coverage=1 --no-external -b $TDENGINE_DIR -o coverage.info + + # remove exclude paths + lcov --remove coverage.info \ + '*/tests/*' '*/test/*' '*/deps/*' '*/plugins/*' '*/taosdef.h' \ + --rc lcov_branch_coverage=1 -o coverage.info + + # generate result + lcov -l --rc lcov_branch_coverage=1 coverage.info | tee -a $TDENGINE_COVERAGE_REPORT + + # push result to coveralls.io + coveralls-lcov coverage.info | tee -a $TDENGINE_COVERAGE_REPORT +} + +function sendReport { + echo "send report" + receiver="sdsang@taosdata.com, sangshuduo@gmail.com, pxiao@taosdata.com" + mimebody="MIME-Version: 1.0\nContent-Type: text/html; charset=utf-8\n" + + cd $TDENGINE_DIR + + sed -i 's/\x1b\[[0-9;]*m//g' $TDENGINE_COVERAGE_REPORT + BODY_CONTENT=`cat $TDENGINE_COVERAGE_REPORT` + echo -e "to: ${receiver}\nsubject: Coverage test report ${today}, commit ID: ${LOCAL_COMMIT}\n\n${today}:\n${BODY_CONTENT}" | \ + (cat - && uuencode $TDENGINE_COVERAGE_REPORT coverage-report-$today.log) | \ + ssmtp "${receiver}" && echo "Report Sent!" +} + +function stopTaosd { + echo "Stop taosd" + systemctl stop taosd + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + pkill -TERM -x taosd + sleep 1 + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + done +} + +function runTestRandomFail { + exec_random_fail_sh=$1 + default_exec_sh=$TDENGINE_DIR/tests/script/sh/exec.sh + [ -f $exec_random_fail_sh ] && cp $exec_random_fail_sh $default_exec_sh || exit 1 + + dnodes_random_fail_py=$TDENGINE_DIR/tests/pytest/util/dnodes-no-random-fail.py + default_dnodes_py=$TDENGINE_DIR/tests/pytest/util/dnodes.py + [ -f $dnodes_random_fail_py ] && cp $dnodes_random_fail_py $default_dnodes_py || exit 1 + + runTest NoRandomFail +} + +WORK_DIR=/home/shuduo/work/taosdata + +date >> $WORK_DIR/cron.log +echo "Run Coverage Test" | tee -a $WORK_DIR/cron.log + +rm /tmp/core-* + +stopTaosd +buildTDengine + +runTestRandomFail $TDENGINE_DIR/tests/script/sh/exec-random-fail.sh +runTestRandomFail $TDENGINE_DIR/tests/script/sh/exec-default.sh +runTestRandomFail $TDENGINE_DIR/tests/script/sh/exec-no-random-fail.sh + +lcovFunc +sendReport +stopTaosd + +date >> $WORK_DIR/cron.log +echo "End of Coverage Test" | tee -a $WORK_DIR/cron.log diff --git a/tests/perftest-scripts/full_test.sh b/tests/perftest-scripts/full_test.sh new file mode 100755 index 0000000000000000000000000000000000000000..1738f69f35207161121c5cbd00816ae37a46745e --- /dev/null +++ b/tests/perftest-scripts/full_test.sh @@ -0,0 +1,191 @@ +#!/bin/bash + +today=`date +"%Y%m%d"` +TDENGINE_DIR=/home/shuduo/work/taosdata/TDengine.orig +TDENGINE_FULLTEST_REPORT=$TDENGINE_DIR/tests/full-report-$today.log + +# Color setting +RED='\033[0;31m' +GREEN='\033[1;32m' +GREEN_DARK='\033[0;32m' +GREEN_UNDERLINE='\033[4;32m' +NC='\033[0m' + +function buildTDengine { + echo "check if TDengine need build" + + need_rebuild=false + + if [ ! -d $TDENGINE_DIR ]; then + echo "No TDengine source code found!" + git clone https://github.com/taosdata/TDengine $TDENGINE_DIR + need_rebuild=true + fi + + cd $TDENGINE_DIR + git remote prune origin > /dev/null + git remote update > /dev/null + REMOTE_COMMIT=`git rev-parse --short remotes/origin/develop` + LOCAL_COMMIT=`git rev-parse --short @` + echo " LOCAL: $LOCAL_COMMIT" + echo "REMOTE: $REMOTE_COMMIT" + + if [ "$LOCAL_COMMIT" == "$REMOTE_COMMIT" ]; then + echo "repo up-to-date" + else + echo "repo need to pull" + git pull + need_rebuild=true + fi + + [ -d $TDENGINE_DIR/debug ] || mkdir $TDENGINE_DIR/debug + cd $TDENGINE_DIR/debug + [ -f $TDENGINE_DIR/debug/build/bin/taosd ] || need_rebuild=true + + if $need_rebuild ; then + echo "rebuild.." + + LOCAL_COMMIT=`git rev-parse --short @` + rm -rf * + cmake .. > /dev/null + make > /dev/null + fi + + make install > /dev/null +} + +function runGeneralCaseOneByOne { + while read -r line; do + if [[ $line =~ ^./test.sh* ]]; then + general_case=`echo $line | grep -w general` + + if [ -n "$general_case" ]; then + case=`echo $line | awk '{print $NF}'` + + start_time=`date +%s` + ./test.sh -f $case > /dev/null 2>&1 && ret=0 || ret = 1 + end_time=`date +%s` + + if [[ ret -eq 0 ]]; then + echo -e "${GREEN}$case success${NC}" | tee -a $TDENGINE_FULLTEST_REPORT + else + casename=`echo $case|sed 's/\//\-/g'` + find $TDENGINE_DIR/sim -name "*log" -exec tar czf $TDENGINE_DIR/fulltest-$today-$casename.log.tar.gz {} + + echo -e "${RED}$case failed and log saved${NC}" | tee -a $TDENGINE_FULLTEST_REPORT + fi + echo execution time of $case was `expr $end_time - $start_time`s. | tee -a $TDENGINE_FULLTEST_REPORT + fi + fi + done < $1 +} + +function runPyCaseOneByOne { + while read -r line; do + if [[ $line =~ ^python.* ]]; then + if [[ $line != *sleep* ]]; then + case=`echo $line|awk '{print $NF}'` + start_time=`date +%s` + $line > /dev/null 2>&1 && ret=0 || ret=1 + end_time=`date +%s` + + if [[ ret -eq 0 ]]; then + echo -e "${GREEN}$case success${NC}" | tee -a pytest-out.log + else + casename=`echo $case|sed 's/\//\-/g'` + find $TDENGINE_DIR/sim -name "*log" -exec tar czf $TDENGINE_DIR/fulltest-$today-$casename.log.tar.gz {} + + echo -e "${RED}$case failed and log saved${NC}" | tee -a pytest-out.log + fi + echo execution time of $case was `expr $end_time - $start_time`s. | tee -a pytest-out.log + else + $line > /dev/null 2>&1 + fi + fi + done < $1 +} + +function runTest { + echo "Run Test" + cd $TDENGINE_DIR/tests/script + + [ -d $TDENGINE_DIR/sim ] && rm -rf $TDENGINE_DIR/sim + [ -f $TDENGINE_FULLTEST_REPORT ] && rm $TDENGINE_FULLTEST_REPORT + + runGeneralCaseOneByOne jenkins/basic.txt + + totalSuccess=`grep 'success' $TDENGINE_FULLTEST_REPORT | wc -l` + + if [ "$totalSuccess" -gt "0" ]; then + echo -e "\n${GREEN} ### Total $totalSuccess SIM case(s) succeed! ### ${NC}" \ + | tee -a $TDENGINE_FULLTEST_REPORT + fi + + totalFailed=`grep 'failed\|fault' $TDENGINE_FULLTEST_REPORT | wc -l` + if [ "$totalFailed" -ne "0" ]; then + echo -e "${RED} ### Total $totalFailed SIM case(s) failed! ### ${NC}\n" \ + | tee -a $TDENGINE_FULLTEST_REPORT + fi + + cd $TDENGINE_DIR/tests/pytest + [ -d $TDENGINE_DIR/sim ] && rm -rf $TDENGINE_DIR/sim + [ -f pytest-out.log ] && rm -f pytest-out.log + runPyCaseOneByOne fulltest.sh + + totalPySuccess=`grep 'success' pytest-out.log | wc -l` + totalPyFailed=`grep 'failed\|fault' pytest-out.log | wc -l` + + cat pytest-out.log >> $TDENGINE_FULLTEST_REPORT + if [ "$totalPySuccess" -gt "0" ]; then + echo -e "\n${GREEN} ### Total $totalPySuccess python case(s) succeed! ### ${NC}" \ + | tee -a $TDENGINE_FULLTEST_REPORT + fi + + if [ "$totalPyFailed" -ne "0" ]; then + echo -e "\n${RED} ### Total $totalPyFailed python case(s) failed! ### ${NC}" \ + | tee -a $TDENGINE_FULLTEST_REPORT + fi +} + +function sendReport { + echo "Send Report" + receiver="sdsang@taosdata.com, sangshuduo@gmail.com, pxiao@taosdata.com" + mimebody="MIME-Version: 1.0\nContent-Type: text/html; charset=utf-8\n" + + cd $TDENGINE_DIR/tests + + sed -i 's/\x1b\[[0-9;]*m//g' $TDENGINE_FULLTEST_REPORT + BODY_CONTENT=`cat $TDENGINE_FULLTEST_REPORT` + + cd $TDENGINE_DIR + tar czf fulltest-$today.tar.gz fulltest-$today-*.log.tar.gz + + echo -e "to: ${receiver}\nsubject: Full test report ${today}, commit ID: ${LOCAL_COMMIT}\n\n${today}:\n${BODY_CONTENT}" | \ + (cat - && uuencode $TDENGINE_FULLTEST_REPORT fulltest-report-$today.log) | \ + (cat - && uuencode $TDENGINE_DIR/fulltest-$today.tar.gz fulltest-$today.tar.gz) | \ + ssmtp "${receiver}" && echo "Report Sent!" +} + +function stopTaosd { + echo "Stop taosd" + systemctl stop taosd + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + pkill -TERM -x taosd + sleep 1 + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + done +} + +WORK_DIR=/home/shuduo/work/taosdata + +date >> $WORK_DIR/cron.log +echo "Run Full Test" | tee -a $WORK_DIR/cron.log + +stopTaosd +buildTDengine +runTest +sendReport +stopTaosd + +date >> $WORK_DIR/cron.log +echo "End of Full Test" | tee -a $WORK_DIR/cron.log diff --git a/tests/perftest-scripts/influxdbTestQ1Loop.sh b/tests/perftest-scripts/influxdbTestQ1Loop.sh new file mode 100755 index 0000000000000000000000000000000000000000..86735899c804485dff7a7f69a4b2610ef4e7c942 --- /dev/null +++ b/tests/perftest-scripts/influxdbTestQ1Loop.sh @@ -0,0 +1,97 @@ +#!/bin/bash + +NUM_LOOP=5 + +function printTo { + if $verbose ; then + echo $1 + fi +} + +INFLUXDBTESTQ1OUT=influxdbTestQ1.out + +function runTest { + totalG0=0 + totalG10=0 + totalG20=0 + totalG30=0 + totalG40=0 + totalG50=0 + totalG60=0 + totalG70=0 + totalG80=0 + totalG90=0 + for i in `seq 1 $NUM_LOOP`; do + printTo "loop i:$i, $INFLUXDBTEST_DIR/infludbTest \ + -sql $INFLUXDBTEST_DIR/q1.txt" + $INFLUXDBTEST_DIR/influxdbTest \ + -sql $INFLUXDBTEST_DIR/q1.txt 2>&1 \ + | tee $INFLUXDBTESTQ1OUT + G0=`grep "devgroup='0'" $INFLUXDBTESTQ1OUT| awk '{print $5}'` + totalG0=`echo "scale=4; $totalG0 + $G0" | bc` + G10=`grep "devgroup='10'" $INFLUXDBTESTQ1OUT| awk '{print $5}'` + totalG10=`echo "scale=4; $totalG10 + $G10" | bc` + G20=`grep "devgroup='20'" $INFLUXDBTESTQ1OUT| awk '{print $5}'` + totalG20=`echo "scale=4; $totalG20 + $G20" | bc` + G30=`grep "devgroup='30'" $INFLUXDBTESTQ1OUT| awk '{print $5}'` + totalG30=`echo "scale=4; $totalG30 + $G30" | bc` + G40=`grep "devgroup='40'" $INFLUXDBTESTQ1OUT| awk '{print $5}'` + totalG40=`echo "scale=4; $totalG40 + $G40" | bc` + G50=`grep "devgroup='50'" $INFLUXDBTESTQ1OUT| awk '{print $5}'` + totalG50=`echo "scale=4; $totalG50 + $G50" | bc` + G60=`grep "devgroup='60'" $INFLUXDBTESTQ1OUT| awk '{print $5}'` + totalG60=`echo "scale=4; $totalG60 + $G60" | bc` + G70=`grep "devgroup='70'" $INFLUXDBTESTQ1OUT| awk '{print $5}'` + totalG70=`echo "scale=4; $totalG70 + $G70" | bc` + G80=`grep "devgroup='80'" $INFLUXDBTESTQ1OUT| awk '{print $5}'` + totalG80=`echo "scale=4; $totalG80 + $G80" | bc` + G90=`grep "devgroup='90'" $INFLUXDBTESTQ1OUT| awk '{print $5}'` + totalG90=`echo "scale=4; $totalG90 + $G90" | bc` + done + avgG0=`echo "scale=4; x = $totalG0 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG10=`echo "scale=4; x = $totalG10 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG20=`echo "scale=4; x = $totalG20 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG30=`echo "scale=4; x = $totalG30 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG40=`echo "scale=4; x = $totalG40 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG50=`echo "scale=4; x = $totalG50 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG60=`echo "scale=4; x = $totalG60 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG70=`echo "scale=4; x = $totalG70 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG80=`echo "scale=4; x = $totalG80 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG90=`echo "scale=4; x = $totalG90 / $NUM_LOOP; if(x<1) print 0; x" | bc` + echo "Latency, G-0, G-10, G-20, G-30, G-40, G-50, G-60, G-70, G-80, G-90" + echo "InfluxDB, $avgG0, $avgG10, $avgG20, $avgG30, $avgG40, $avgG50, $avgG60, $avgG70, $avgG80, $avgG90" +} + +################ Main ################ + +master=false +develop=true +verbose=false + +clients=1 + +while : ; do + case $1 in + -v) + verbose=true + shift ;; + + -c) + clients=$2 + shift 2;; + + -n) + NUM_LOOP=$2 + shift 2;; + + *) + break ;; + esac +done + +WORK_DIR=/mnt/root/TDengine +INFLUXDBTEST_DIR=$WORK_DIR/tests/comparisonTest/influxdb + +runTest + +printTo "Test done!" diff --git a/tests/perftest-scripts/influxdbTestQ2Loop.sh b/tests/perftest-scripts/influxdbTestQ2Loop.sh new file mode 100755 index 0000000000000000000000000000000000000000..394b47b125e13c0f5672ec66afec8aafd69fa5f7 --- /dev/null +++ b/tests/perftest-scripts/influxdbTestQ2Loop.sh @@ -0,0 +1,318 @@ +#!/bin/bash + +NUM_LOOP=5 + +function printTo { + if $verbose ; then + echo $1 + fi +} + +INFLUXDBTESTQ2OUT=influxdbTestQ2.out + +function runTest { + totalCount10=0 + totalCount20=0 + totalCount30=0 + totalCount40=0 + totalCount50=0 + totalCount60=0 + totalCount70=0 + totalCount80=0 + totalCount90=0 + totalCount100=0 + + totalMean10=0 + totalMean20=0 + totalMean30=0 + totalMean40=0 + totalMean50=0 + totalMean60=0 + totalMean70=0 + totalMean80=0 + totalMean90=0 + totalMean100=0 + + totalSum10=0 + totalSum20=0 + totalSum30=0 + totalSum40=0 + totalSum50=0 + totalSum60=0 + totalSum70=0 + totalSum80=0 + totalSum90=0 + totalSum100=0 + + totalMax10=0 + totalMax20=0 + totalMax30=0 + totalMax40=0 + totalMax50=0 + totalMax60=0 + totalMax70=0 + totalMax80=0 + totalMax90=0 + totalMax100=0 + + totalMin10=0 + totalMin20=0 + totalMin30=0 + totalMin40=0 + totalMin50=0 + totalMin60=0 + totalMin70=0 + totalMin80=0 + totalMin90=0 + totalMin100=0 + + totalSpread10=0 + totalSpread20=0 + totalSpread30=0 + totalSpread40=0 + totalSpread50=0 + totalSpread60=0 + totalSpread70=0 + totalSpread80=0 + totalSpread90=0 + totalSpread100=0 + + for i in `seq 1 $NUM_LOOP`; do + printTo "loop i:$i, $INFLUXDBTEST_DIR/influxdbTest \ + -sql $INFLUXDBTEST_DIR/q2.txt" + $INFLUXDBTEST_DIR/influxdbTest \ + -sql $INFLUXDBTEST_DIR/q2.txt 2>&1 \ + | tee $INFLUXDBTESTQ2OUT + + Count10=`cat $INFLUXDBTESTQ2OUT | grep count | grep "devgroup=~\/\[1-1\]" | awk '{print $5}'` + totalCount10=`echo "scale=4; $totalCount10 + $Count10" | bc` + Count20=`cat $INFLUXDBTESTQ2OUT | grep count | grep "devgroup=~\/\[1-2\]" | awk '{print $5}'` + totalCount20=`echo "scale=4; $totalCount20 + $Count20" | bc` + Count30=`cat $INFLUXDBTESTQ2OUT | grep count | grep "devgroup=~\/\[1-3\]" | awk '{print $5}'` + totalCount30=`echo "scale=4; $totalCount30 + $Count30" | bc` + Count40=`cat $INFLUXDBTESTQ2OUT | grep count | grep "devgroup=~\/\[1-4\]" | awk '{print $5}'` + totalCount40=`echo "scale=4; $totalCount40 + $Count40" | bc` + Count50=`cat $INFLUXDBTESTQ2OUT | grep count | grep "devgroup=~\/\[1-5\]" | awk '{print $5}'` + totalCount50=`echo "scale=4; $totalCount50 + $Count50" | bc` + Count60=`cat $INFLUXDBTESTQ2OUT | grep count | grep "devgroup=~\/\[1-6\]" | awk '{print $5}'` + totalCount60=`echo "scale=4; $totalCount60 + $Count60" | bc` + Count70=`cat $INFLUXDBTESTQ2OUT | grep count | grep "devgroup=~\/\[1-7\]" | awk '{print $5}'` + totalCount70=`echo "scale=4; $totalCount70 + $Count70" | bc` + Count80=`cat $INFLUXDBTESTQ2OUT | grep count | grep "devgroup=~\/\[1-8\]" | awk '{print $5}'` + totalCount80=`echo "scale=4; $totalCount80 + $Count80" | bc` + Count90=`cat $INFLUXDBTESTQ2OUT | grep count | grep "devgroup=~\/\[1-9\]" | awk '{print $5}'` + totalCount90=`echo "scale=4; $totalCount90 + $Count90" | bc` + Count100=`cat $INFLUXDBTESTQ2OUT | grep count | grep "devices;" | awk '{print $5}'` + totalCount100=`echo "scale=4; $totalCount100 + $Count100" | bc` + + Mean10=`cat $INFLUXDBTESTQ2OUT | grep mean | grep "devgroup=~\/\[1-1\]" | awk '{print $5}'` + totalMean10=`echo "scale=4; $totalMean10 + $Mean10" | bc` + Mean20=`cat $INFLUXDBTESTQ2OUT | grep mean | grep "devgroup=~\/\[1-2\]" | awk '{print $5}'` + totalMean20=`echo "scale=4; $totalMean20 + $Mean20" | bc` + Mean30=`cat $INFLUXDBTESTQ2OUT | grep mean | grep "devgroup=~\/\[1-3\]" | awk '{print $5}'` + totalMean30=`echo "scale=4; $totalMean30 + $Mean30" | bc` + Mean40=`cat $INFLUXDBTESTQ2OUT | grep mean | grep "devgroup=~\/\[1-4\]" | awk '{print $5}'` + totalMean40=`echo "scale=4; $totalMean40 + $Mean40" | bc` + Mean50=`cat $INFLUXDBTESTQ2OUT | grep mean | grep "devgroup=~\/\[1-5\]" | awk '{print $5}'` + totalMean50=`echo "scale=4; $totalMean50 + $Mean50" | bc` + Mean60=`cat $INFLUXDBTESTQ2OUT | grep mean | grep "devgroup=~\/\[1-6\]" | awk '{print $5}'` + totalMean60=`echo "scale=4; $totalMean60 + $Mean60" | bc` + Mean70=`cat $INFLUXDBTESTQ2OUT | grep mean | grep "devgroup=~\/\[1-7\]" | awk '{print $5}'` + totalMean70=`echo "scale=4; $totalMean70 + $Mean70" | bc` + Mean80=`cat $INFLUXDBTESTQ2OUT | grep mean | grep "devgroup=~\/\[1-8\]" | awk '{print $5}'` + totalMean80=`echo "scale=4; $totalMean80 + $Mean80" | bc` + Mean90=`cat $INFLUXDBTESTQ2OUT | grep mean | grep "devgroup=~\/\[1-9\]" | awk '{print $5}'` + totalMean90=`echo "scale=4; $totalMean90 + $Mean90" | bc` + Mean100=`cat $INFLUXDBTESTQ2OUT | grep mean | grep "devices;" | awk '{print $5}'` + totalMean100=`echo "scale=4; $totalMean100 + $Mean100" | bc` + + Sum10=`cat $INFLUXDBTESTQ2OUT | grep sum | grep "devgroup=~\/\[1-1\]" | awk '{print $5}'` + totalSum10=`echo "scale=4; $totalSum10 + $Sum10" | bc` + Sum20=`cat $INFLUXDBTESTQ2OUT | grep sum | grep "devgroup=~\/\[1-2\]" | awk '{print $5}'` + totalSum20=`echo "scale=4; $totalSum20 + $Sum20" | bc` + Sum30=`cat $INFLUXDBTESTQ2OUT | grep sum | grep "devgroup=~\/\[1-3\]" | awk '{print $5}'` + totalSum30=`echo "scale=4; $totalSum30 + $Sum30" | bc` + Sum40=`cat $INFLUXDBTESTQ2OUT | grep sum | grep "devgroup=~\/\[1-4\]" | awk '{print $5}'` + totalSum40=`echo "scale=4; $totalSum40 + $Sum40" | bc` + Sum50=`cat $INFLUXDBTESTQ2OUT | grep sum | grep "devgroup=~\/\[1-5\]" | awk '{print $5}'` + totalSum50=`echo "scale=4; $totalSum50 + $Sum50" | bc` + Sum60=`cat $INFLUXDBTESTQ2OUT | grep sum | grep "devgroup=~\/\[1-6\]" | awk '{print $5}'` + totalSum60=`echo "scale=4; $totalSum60 + $Sum60" | bc` + Sum70=`cat $INFLUXDBTESTQ2OUT | grep sum | grep "devgroup=~\/\[1-7\]" | awk '{print $5}'` + totalSum70=`echo "scale=4; $totalSum70 + $Sum70" | bc` + Sum80=`cat $INFLUXDBTESTQ2OUT | grep sum | grep "devgroup=~\/\[1-8\]" | awk '{print $5}'` + totalSum80=`echo "scale=4; $totalSum80 + $Sum80" | bc` + Sum90=`cat $INFLUXDBTESTQ2OUT | grep sum | grep "devgroup=~\/\[1-9\]" | awk '{print $5}'` + totalSum90=`echo "scale=4; $totalSum90 + $Sum90" | bc` + Sum100=`cat $INFLUXDBTESTQ2OUT | grep sum | grep "devices;" | awk '{print $5}'` + totalSum100=`echo "scale=4; $totalSum100 + $Sum100" | bc` + + Max10=`cat $INFLUXDBTESTQ2OUT | grep max | grep "devgroup=~\/\[1-1\]" | awk '{print $5}'` + totalMax10=`echo "scale=4; $totalMax10 + $Max10" | bc` + Max20=`cat $INFLUXDBTESTQ2OUT | grep max | grep "devgroup=~\/\[1-2\]" | awk '{print $5}'` + totalMax20=`echo "scale=4; $totalMax20 + $Max20" | bc` + Max30=`cat $INFLUXDBTESTQ2OUT | grep max | grep "devgroup=~\/\[1-3\]" | awk '{print $5}'` + totalMax30=`echo "scale=4; $totalMax30 + $Max30" | bc` + Max40=`cat $INFLUXDBTESTQ2OUT | grep max | grep "devgroup=~\/\[1-4\]" | awk '{print $5}'` + totalMax40=`echo "scale=4; $totalMax40 + $Max40" | bc` + Max50=`cat $INFLUXDBTESTQ2OUT | grep max | grep "devgroup=~\/\[1-5\]" | awk '{print $5}'` + totalMax50=`echo "scale=4; $totalMax50 + $Max50" | bc` + Max60=`cat $INFLUXDBTESTQ2OUT | grep max | grep "devgroup=~\/\[1-6\]" | awk '{print $5}'` + totalMax60=`echo "scale=4; $totalMax60 + $Max60" | bc` + Max70=`cat $INFLUXDBTESTQ2OUT | grep max | grep "devgroup=~\/\[1-7\]" | awk '{print $5}'` + totalMax70=`echo "scale=4; $totalMax70 + $Max70" | bc` + Max80=`cat $INFLUXDBTESTQ2OUT | grep max | grep "devgroup=~\/\[1-8\]" | awk '{print $5}'` + totalMax80=`echo "scale=4; $totalMax80 + $Max80" | bc` + Max90=`cat $INFLUXDBTESTQ2OUT | grep max | grep "devgroup=~\/\[1-9\]" | awk '{print $5}'` + totalMax90=`echo "scale=4; $totalMax90 + $Max90" | bc` + Max100=`cat $INFLUXDBTESTQ2OUT | grep max | grep "devices;" | awk '{print $5}'` + totalMax100=`echo "scale=4; $totalMax100 + $Max100" | bc` + + Min10=`cat $INFLUXDBTESTQ2OUT | grep min | grep "devgroup=~\/\[1-1\]" | awk '{print $5}'` + totalMin10=`echo "scale=4; $totalMin10 + $Min10" | bc` + Min20=`cat $INFLUXDBTESTQ2OUT | grep min | grep "devgroup=~\/\[1-2\]" | awk '{print $5}'` + totalMin20=`echo "scale=4; $totalMin20 + $Min20" | bc` + Min30=`cat $INFLUXDBTESTQ2OUT | grep min | grep "devgroup=~\/\[1-3\]" | awk '{print $5}'` + totalMin30=`echo "scale=4; $totalMin30 + $Min30" | bc` + Min40=`cat $INFLUXDBTESTQ2OUT | grep min | grep "devgroup=~\/\[1-4\]" | awk '{print $5}'` + totalMin40=`echo "scale=4; $totalMin40 + $Min40" | bc` + Min50=`cat $INFLUXDBTESTQ2OUT | grep min | grep "devgroup=~\/\[1-5\]" | awk '{print $5}'` + totalMin50=`echo "scale=4; $totalMin50 + $Min50" | bc` + Min60=`cat $INFLUXDBTESTQ2OUT | grep min | grep "devgroup=~\/\[1-6\]" | awk '{print $5}'` + totalMin60=`echo "scale=4; $totalMin60 + $Min60" | bc` + Min70=`cat $INFLUXDBTESTQ2OUT | grep min | grep "devgroup=~\/\[1-7\]" | awk '{print $5}'` + totalMin70=`echo "scale=4; $totalMin70 + $Min70" | bc` + Min80=`cat $INFLUXDBTESTQ2OUT | grep min | grep "devgroup=~\/\[1-8\]" | awk '{print $5}'` + totalMin80=`echo "scale=4; $totalMin80 + $Min80" | bc` + Min90=`cat $INFLUXDBTESTQ2OUT | grep min | grep "devgroup=~\/\[1-9\]" | awk '{print $5}'` + totalMin90=`echo "scale=4; $totalMin90 + $Min90" | bc` + Min100=`cat $INFLUXDBTESTQ2OUT | grep min | grep "devices;" | awk '{print $5}'` + totalMin100=`echo "scale=4; $totalMin100 + $Min100" | bc` + + Spread10=`cat $INFLUXDBTESTQ2OUT | grep spread | grep "devgroup=~\/\[1-1\]" | awk '{print $5}'` + totalSpread10=`echo "scale=4; $totalSpread10 + $Spread10" | bc` + Spread20=`cat $INFLUXDBTESTQ2OUT | grep spread | grep "devgroup=~\/\[1-2\]" | awk '{print $5}'` + totalSpread20=`echo "scale=4; $totalSpread20 + $Spread20" | bc` + Spread30=`cat $INFLUXDBTESTQ2OUT | grep spread | grep "devgroup=~\/\[1-3\]" | awk '{print $5}'` + totalSpread30=`echo "scale=4; $totalSpread30 + $Spread30" | bc` + Spread40=`cat $INFLUXDBTESTQ2OUT | grep spread | grep "devgroup=~\/\[1-4\]" | awk '{print $5}'` + totalSpread40=`echo "scale=4; $totalSpread40 + $Spread40" | bc` + Spread50=`cat $INFLUXDBTESTQ2OUT | grep spread | grep "devgroup=~\/\[1-5\]" | awk '{print $5}'` + totalSpread50=`echo "scale=4; $totalSpread50 + $Spread50" | bc` + Spread60=`cat $INFLUXDBTESTQ2OUT | grep spread | grep "devgroup=~\/\[1-6\]" | awk '{print $5}'` + totalSpread60=`echo "scale=4; $totalSpread60 + $Spread60" | bc` + Spread70=`cat $INFLUXDBTESTQ2OUT | grep spread | grep "devgroup=~\/\[1-7\]" | awk '{print $5}'` + totalSpread70=`echo "scale=4; $totalSpread70 + $Spread70" | bc` + Spread80=`cat $INFLUXDBTESTQ2OUT | grep spread | grep "devgroup=~\/\[1-8\]" | awk '{print $5}'` + totalSpread80=`echo "scale=4; $totalSpread80 + $Spread80" | bc` + Spread90=`cat $INFLUXDBTESTQ2OUT | grep spread | grep "devgroup=~\/\[1-9\]" | awk '{print $5}'` + totalSpread90=`echo "scale=4; $totalSpread90 + $Spread90" | bc` + Spread100=`cat $INFLUXDBTESTQ2OUT | grep spread | grep "devices;" | awk '{print $5}'` + totalSpread100=`echo "scale=4; $totalSpread100 + $Spread100" | bc` + + done + avgCount10=`echo "scale=4; x = $totalCount10 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount20=`echo "scale=4; x = $totalCount20 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount30=`echo "scale=4; x = $totalCount30 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount40=`echo "scale=4; x = $totalCount40 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount50=`echo "scale=4; x = $totalCount50 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount60=`echo "scale=4; x = $totalCount60 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount70=`echo "scale=4; x = $totalCount70 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount80=`echo "scale=4; x = $totalCount80 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount90=`echo "scale=4; x = $totalCount90 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount100=`echo "scale=4; x = $totalCount100 / $NUM_LOOP; if(x<1) print 0; x" | bc` + + avgMean10=`echo "scale=4; x = $totalMean10 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMean20=`echo "scale=4; x = $totalMean20 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMean30=`echo "scale=4; x = $totalMean30 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMean40=`echo "scale=4; x = $totalMean40 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMean50=`echo "scale=4; x = $totalMean50 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMean60=`echo "scale=4; x = $totalMean60 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMean70=`echo "scale=4; x = $totalMean70 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMean80=`echo "scale=4; x = $totalMean80 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMean90=`echo "scale=4; x = $totalMean90 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMean100=`echo "scale=4; x = $totalMean100 / $NUM_LOOP; if(x<1) print 0; x" | bc` + + avgSum10=`echo "scale=4; x = $totalSum10 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum20=`echo "scale=4; x = $totalSum20 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum30=`echo "scale=4; x = $totalSum30 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum40=`echo "scale=4; x = $totalSum40 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum50=`echo "scale=4; x = $totalSum50 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum60=`echo "scale=4; x = $totalSum60 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum70=`echo "scale=4; x = $totalSum70 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum80=`echo "scale=4; x = $totalSum80 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum90=`echo "scale=4; x = $totalSum90 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum100=`echo "scale=4; x = $totalSum100 / $NUM_LOOP; if(x<1) print 0; x" | bc` + + avgMax10=`echo "scale=4; x = $totalMax10 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax20=`echo "scale=4; x = $totalMax20 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax30=`echo "scale=4; x = $totalMax30 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax40=`echo "scale=4; x = $totalMax40 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax50=`echo "scale=4; x = $totalMax50 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax60=`echo "scale=4; x = $totalMax60 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax70=`echo "scale=4; x = $totalMax70 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax80=`echo "scale=4; x = $totalMax80 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax90=`echo "scale=4; x = $totalMax90 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax100=`echo "scale=4; x = $totalMax100 / $NUM_LOOP; if(x<1) print 0; x" | bc` + + avgMin10=`echo "scale=4; x = $totalMin10 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin20=`echo "scale=4; x = $totalMin20 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin30=`echo "scale=4; x = $totalMin30 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin40=`echo "scale=4; x = $totalMin40 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin50=`echo "scale=4; x = $totalMin50 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin60=`echo "scale=4; x = $totalMin60 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin70=`echo "scale=4; x = $totalMin70 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin80=`echo "scale=4; x = $totalMin80 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin90=`echo "scale=4; x = $totalMin90 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin100=`echo "scale=4; x = $totalMin100 / $NUM_LOOP; if(x<1) print 0; x" | bc` + + avgSpread10=`echo "scale=4; x = $totalSpread10 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSpread20=`echo "scale=4; x = $totalSpread20 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSpread30=`echo "scale=4; x = $totalSpread30 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSpread40=`echo "scale=4; x = $totalSpread40 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSpread50=`echo "scale=4; x = $totalSpread50 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSpread60=`echo "scale=4; x = $totalSpread60 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSpread70=`echo "scale=4; x = $totalSpread70 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSpread80=`echo "scale=4; x = $totalSpread80 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSpread90=`echo "scale=4; x = $totalSpread90 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSpread100=`echo "scale=4; x = $totalSpread100 / $NUM_LOOP; if(x<1) print 0; x" | bc` + + echo "Latency, 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%, 100%" + echo "Count, $avgCount10, $avgCount20, $avgCount30, $avgCount40, $avgCount50, $avgCount60, $avgCount70, $avgCount80, $avgCount90, $avgCount100" + echo "Mean, $avgMean10, $avgMean20, $avgMean30, $avgMean40, $avgMean50, $avgMean60, $avgMean70, $avgMean80, $avgMean90, $avgMean100" + echo "Sum, $avgSum10, $avgSum20, $avgSum30, $avgSum40, $avgSum50, $avgSum60, $avgSum70, $avgSum80, $avgSum90, $avgSum100" + echo "Max, $avgMax10, $avgMax20, $avgMax30, $avgMax40, $avgMax50, $avgMax60, $avgMax70, $avgMax80, $avgMax90, $avgMax100" + echo "Min, $avgMin10, $avgMin20, $avgMin30, $avgMin40, $avgMin50, $avgMin60, $avgMin70, $avgMin80, $avgMin90, $avgMin100" + echo "Spread, $avgSpread10, $avgSpread20, $avgSpread30, $avgSpread40, $avgSpread50, $avgSpread60, $avgSpread70, $avgSpread80, $avgSpread90, $avgSpread100" +} + +################ Main ################ + +verbose=false + +for arg in "$@" +do + case $arg in + -v) + verbose=true + shift ;; + + -c) + clients=$2 + shift 2;; + + -n) + NUM_LOOP=$2 + shift 2;; + + *) + ;; + esac +done + +WORK_DIR=/mnt/root/TDengine +INFLUXDBTEST_DIR=$WORK_DIR/tests/comparisonTest/influxdb + +runTest + +printTo "Test done!" diff --git a/tests/perftest-scripts/influxdbTestQ3Loop.sh b/tests/perftest-scripts/influxdbTestQ3Loop.sh new file mode 100755 index 0000000000000000000000000000000000000000..e1cfb848faff6c42b98584c80040c7b721c0bfdf --- /dev/null +++ b/tests/perftest-scripts/influxdbTestQ3Loop.sh @@ -0,0 +1,94 @@ +#!/bin/bash + +NUM_LOOP=5 + +function printTo { + if $verbose ; then + echo $1 + fi +} + +INFLUXDBTESTQ3OUT=opentsdbTestQ3.out + +function runTest { + totalG10=0 + totalG20=0 + totalG30=0 + totalG40=0 + totalG50=0 + totalG60=0 + totalG70=0 + totalG80=0 + totalG90=0 + totalG100=0 + for i in `seq 1 $NUM_LOOP`; do + printTo "loop i:$i, $INFLUXDBTEST_DIR/influxdbTest \ + -sql $INFLUXDBTEST_DIR/q3.txt" + $INFLUXDBTEST_DIR/influxdbTest \ + -sql $INFLUXDBTEST_DIR/q3.txt 2>&1 \ + | tee $INFLUXDBTESTQ3OUT + G10=`grep -w "devgroup=~\/\[1-1\]" $INFLUXDBTESTQ3OUT| awk '{print $5}'` + totalG10=`echo "scale=4; $totalG10 + $G10" | bc` + G20=`grep -w "devgroup=~\/\[1-2\]" $INFLUXDBTESTQ3OUT| awk '{print $5}'` + totalG20=`echo "scale=4; $totalG20 + $G20" | bc` + G30=`grep -w "devgroup=~\/\[1-3\]" $INFLUXDBTESTQ3OUT| awk '{print $5}'` + totalG30=`echo "scale=4; $totalG30 + $G30" | bc` + G40=`grep -w "devgroup=~\/\[1-4\]" $INFLUXDBTESTQ3OUT| awk '{print $5}'` + totalG40=`echo "scale=4; $totalG40 + $G40" | bc` + G50=`grep -w "devgroup=~\/\[1-5\]" $INFLUXDBTESTQ3OUT| awk '{print $5}'` + totalG50=`echo "scale=4; $totalG50 + $G50" | bc` + G60=`grep -w "devgroup=~\/\[1-6\]" $INFLUXDBTESTQ3OUT| awk '{print $5}'` + totalG60=`echo "scale=4; $totalG60 + $G60" | bc` + G70=`grep -w "devgroup=~\/\[1-7\]" $INFLUXDBTESTQ3OUT| awk '{print $5}'` + totalG70=`echo "scale=4; $totalG70 + $G70" | bc` + G80=`grep -w "devgroup=~\/\[1-8\]" $INFLUXDBTESTQ3OUT| awk '{print $5}'` + totalG80=`echo "scale=4; $totalG80 + $G80" | bc` + G90=`grep -w "devgroup=~\/\[1-9\]" $INFLUXDBTESTQ3OUT| awk '{print $5}'` + totalG90=`echo "scale=4; $totalG90 + $G90" | bc` + G100=`grep -w "devices group by devgroup;" $INFLUXDBTESTQ3OUT| awk '{print $5}'` + totalG100=`echo "scale=4; $totalG100 + $G100" | bc` + done + avgG10=`echo "scale=4; x = $totalG10 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG20=`echo "scale=4; x = $totalG20 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG30=`echo "scale=4; x = $totalG30 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG40=`echo "scale=4; x = $totalG40 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG50=`echo "scale=4; x = $totalG50 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG60=`echo "scale=4; x = $totalG60 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG70=`echo "scale=4; x = $totalG70 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG80=`echo "scale=4; x = $totalG80 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG90=`echo "scale=4; x = $totalG90 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG100=`echo "scale=4; x = $totalG100 / $NUM_LOOP; if(x<1) print 0; x" | bc` + echo "Latency, 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%, 100%" + echo "InfluxDB, $avgG10, $avgG20, $avgG30, $avgG40, $avgG50, $avgG60, $avgG70, $avgG80, $avgG90, $avgG100" +} + +################ Main ################ + +verbose=false + +for arg in "$@" +do + case $arg in + -v) + verbose=true + shift ;; + + -c) + clients=$2 + shift 2;; + + -n) + NUM_LOOP=$2 + shift 2;; + + *) + ;; + esac +done + +WORK_DIR=/mnt/root/TDengine +INFLUXDBTEST_DIR=$WORK_DIR/tests/comparisonTest/influxdb + +runTest + +printTo "Test done!" diff --git a/tests/perftest-scripts/influxdbTestQ4Loop.sh b/tests/perftest-scripts/influxdbTestQ4Loop.sh new file mode 100755 index 0000000000000000000000000000000000000000..eb7cfc55569ec5760cb48b2ff6326104e09fccb0 --- /dev/null +++ b/tests/perftest-scripts/influxdbTestQ4Loop.sh @@ -0,0 +1,101 @@ +#!/bin/bash -x + +DATA_DIR=/mnt/root/testdata +NUM_LOOP=5 + +function printTo { + if $verbose ; then + echo $1 + fi +} + +INFLUXDBTESTQ4OUT=influxdbTestQ4.out + +function runTest { + totalG10=0 + totalG20=0 + totalG30=0 + totalG40=0 + totalG50=0 + totalG60=0 + totalG70=0 + totalG80=0 + totalG90=0 + totalG100=0 + for i in `seq 1 $NUM_LOOP`; do + printTo "loop i:$i, $INFLUXDBTEST_DIR/influxdbTest \ + -sql $INFLUXDBTEST_DIR/q4.txt" + + $INFLUXDBTEST_DIR/influxdbTest \ + -sql $INFLUXDBTEST_DIR/q4.txt 2>&1 | + tee $INFLUXDBTESTQ4OUT + G10=`grep -w "devgroup=~\/\[1-1\]" $INFLUXDBTESTQ4OUT| awk '{print $5}'` + totalG10=`echo "scale=4; $totalG10 + $G10" | bc` + G20=`grep -w "devgroup=~\/\[1-2\]" $INFLUXDBTESTQ4OUT| awk '{print $5}'` + totalG20=`echo "scale=4; $totalG20 + $G20" | bc` + G30=`grep -w "devgroup=~\/\[1-3\]" $INFLUXDBTESTQ4OUT| awk '{print $5}'` + totalG30=`echo "scale=4; $totalG30 + $G30" | bc` + G40=`grep -w "devgroup=~\/\[1-4\]" $INFLUXDBTESTQ4OUT| awk '{print $5}'` + totalG40=`echo "scale=4; $totalG40 + $G40" | bc` + G50=`grep -w "devgroup=~\/\[1-5\]" $INFLUXDBTESTQ4OUT| awk '{print $5}'` + totalG50=`echo "scale=4; $totalG50 + $G50" | bc` + G60=`grep -w "devgroup=~\/\[1-6\]" $INFLUXDBTESTQ4OUT| awk '{print $5}'` + totalG60=`echo "scale=4; $totalG60 + $G60" | bc` + G70=`grep -w "devgroup=~\/\[1-7\]" $INFLUXDBTESTQ4OUT| awk '{print $5}'` + totalG70=`echo "scale=4; $totalG70 + $G70" | bc` + G80=`grep -w "devgroup=~\/\[1-8\]" $INFLUXDBTESTQ4OUT| awk '{print $5}'` + totalG80=`echo "scale=4; $totalG80 + $G80" | bc` + G90=`grep -w "devgroup=~\/\[1-9\]" $INFLUXDBTESTQ4OUT| awk '{print $5}'` + totalG90=`echo "scale=4; $totalG90 + $G90" | bc` + G100=`grep -w "devices group by time" $INFLUXDBTESTQ4OUT| awk '{print $5}'` + totalG100=`echo "scale=4; $totalG100 + $G100" | bc` + done + avgG10=`echo "scale=4; x = $totalG10 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG20=`echo "scale=4; x = $totalG20 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG30=`echo "scale=4; x = $totalG30 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG40=`echo "scale=4; x = $totalG40 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG50=`echo "scale=4; x = $totalG50 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG60=`echo "scale=4; x = $totalG60 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG70=`echo "scale=4; x = $totalG70 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG80=`echo "scale=4; x = $totalG80 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG90=`echo "scale=4; x = $totalG90 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG100=`echo "scale=4; x = $totalG100 / $NUM_LOOP; if(x<1) print 0; x" | bc` + echo "Latency, 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%, 100%" + echo "InfluxDB, $avgG10, $avgG20, $avgG30, $avgG40, $avgG50, $avgG60, $avgG70, $avgG80, $avgG90, $avgG100" +} + +################ Main ################ + +verbose=false +regeneratedata=false + +for arg in "$@" +do + case $arg in + -v) + verbose=true + shift ;; + + -c) + clients=$2 + shift 2;; + + -r) + regeneratedata=true + ;; + + -n) + NUM_LOOP=$2 + shift 2;; + + *) + ;; + esac +done + +WORK_DIR=/mnt/root/TDengine +INFLUXDBTEST_DIR=$WORK_DIR/tests/comparisonTest/influxdb + +runTest + +printTo "Test done!" diff --git a/tests/perftest-scripts/influxdbTestWriteLoop.sh b/tests/perftest-scripts/influxdbTestWriteLoop.sh new file mode 100755 index 0000000000000000000000000000000000000000..89eabbd7eca5ce4668a02349816bb38f56847133 --- /dev/null +++ b/tests/perftest-scripts/influxdbTestWriteLoop.sh @@ -0,0 +1,104 @@ +#!/bin/bash + +DATA_DIR=/mnt/root/testdata +NUM_LOOP=1 +NUM_OF_FILES=100 + +rowsPerRequest=(1 100 1000 10000 20000 50000 100000) + +function printTo { + if $verbose ; then + echo $1 + fi +} + +function runTest { + declare -A avgRPR + + for r in ${!rowsPerRequest[@]}; do + for c in `seq 1 $clients`; do + avgRPR[$r, $c]=0 + done + done + + for r in ${!rowsPerRequest[@]}; do + if [ "$r" == "1" ] || [ "$r" == "100" ] || [ "$r" == "1000" ]; then + NUM_OF_FILES=$clients + else + NUM_OF_FILES=100 + fi + + for c in `seq 1 $clients`; do + totalRPR=0 + OUTPUT_FILE=influxdbTestWrite-RPR${rowsPerRequest[$r]}-clients$c.out + for i in `seq 1 $NUM_LOOP`; do + printTo "loop i:$i, $INF_TEST_DIR/influxdbTest \ + -dataDir $DATA_DIR \ + -numOfFiles $NUM_OF_FILES \ + -writeClients $c \ + -rowsPerRequest $r" + $INF_TEST_DIR/influxdbTest \ + -dataDir $DATA_DIR \ + -numOfFiles $NUM_OF_FILES \ + -writeClients $c \ + -rowsPerRequest $r 2>&1 \ + | tee $OUTPUT_FILE + RPR=`cat $OUTPUT_FILE | grep speed | awk '{print $(NF-1)}'` + totalRPR=`echo "scale=4; $totalRPR + $RPR" | bc` + printTo "rows:$r, clients:$c, i:$i RPR:$RPR" + done + avgRPR[$r,$c]=`echo "scale=4; $totalRPR / $NUM_LOOP" | bc` + printTo "r:$r c:$c avgRPR:${avgRPR[$r, $c]}" + done + done + + printf "R/R, " + for c in `seq 1 $clients`; do + if [ "$c" == "1" ]; then + printf "$c client, " + else + printf "$c clients, " + fi + done + printf "\n" + + for r in ${!rowsPerRequest[@]}; do + printf "${rowsPerRequest[$r]}, " + for c in `seq 1 $clients`; do + printf "${avgRPR[$r,$c]}, " + done + printf "\n" + done +} + +################ Main ################ + +verbose=false +clients=1 + +while : ; do + case $1 in + -v) + verbose=true + shift ;; + + -n) + NUM_LOOP=$2 + shift 2;; + + -c) + clients=$2 + shift 2;; + + *) + break ;; + esac +done + +WORK_DIR=/mnt/root/TDengine + +INF_TEST_DIR=$WORK_DIR/tests/comparisonTest/influxdb + +runTest + +echo "Test done!" diff --git a/tests/perftest-scripts/opentsdbTestQ1Loop.sh b/tests/perftest-scripts/opentsdbTestQ1Loop.sh new file mode 100755 index 0000000000000000000000000000000000000000..2f9ca0dfdb7b851739e97c0d056017255292e288 --- /dev/null +++ b/tests/perftest-scripts/opentsdbTestQ1Loop.sh @@ -0,0 +1,99 @@ +#!/bin/bash + +NUM_LOOP=5 + +function printTo { + if $verbose ; then + echo $1 + fi +} + +TSDBTESTQ1OUT=opentsdbTestQ1.out + +function runTest { + totalG0=0 + totalG10=0 + totalG20=0 + totalG30=0 + totalG40=0 + totalG50=0 + totalG60=0 + totalG70=0 + totalG80=0 + totalG90=0 + for i in `seq 1 $NUM_LOOP`; do + printTo "loop i:$i, java -jar \ + $TSDBTEST_DIR/opentsdbtest/target/opentsdbtest-1.0-SNAPSHOT-jar-with-dependencies.jar \ + -sql q1" + java -jar \ + $TSDBTEST_DIR/opentsdbtest/target/opentsdbtest-1.0-SNAPSHOT-jar-with-dependencies.jar \ + -sql q1 2>&1 \ + | tee $TSDBTESTQ1OUT + G0=`grep "devgroup = 0" $TSDBTESTQ1OUT| awk '{print $2}'` + totalG0=`echo "scale=4; $totalG0 + $G0" | bc` + G10=`grep "devgroup = 10" $TSDBTESTQ1OUT| awk '{print $2}'` + totalG10=`echo "scale=4; $totalG10 + $G10" | bc` + G20=`grep "devgroup = 20" $TSDBTESTQ1OUT| awk '{print $2}'` + totalG20=`echo "scale=4; $totalG20 + $G20" | bc` + G30=`grep "devgroup = 30" $TSDBTESTQ1OUT| awk '{print $2}'` + totalG30=`echo "scale=4; $totalG30 + $G30" | bc` + G40=`grep "devgroup = 40" $TSDBTESTQ1OUT| awk '{print $2}'` + totalG40=`echo "scale=4; $totalG40 + $G40" | bc` + G50=`grep "devgroup = 50" $TSDBTESTQ1OUT| awk '{print $2}'` + totalG50=`echo "scale=4; $totalG50 + $G50" | bc` + G60=`grep "devgroup = 60" $TSDBTESTQ1OUT| awk '{print $2}'` + totalG60=`echo "scale=4; $totalG60 + $G60" | bc` + G70=`grep "devgroup = 70" $TSDBTESTQ1OUT| awk '{print $2}'` + totalG70=`echo "scale=4; $totalG70 + $G70" | bc` + G80=`grep "devgroup = 80" $TSDBTESTQ1OUT| awk '{print $2}'` + totalG80=`echo "scale=4; $totalG80 + $G80" | bc` + G90=`grep "devgroup = 90" $TSDBTESTQ1OUT| awk '{print $2}'` + totalG90=`echo "scale=4; $totalG90 + $G90" | bc` + done + avgG0=`echo "scale=4; x = $totalG0 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG10=`echo "scale=4; x = $totalG10 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG20=`echo "scale=4; x = $totalG20 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG30=`echo "scale=4; x = $totalG30 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG40=`echo "scale=4; x = $totalG40 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG50=`echo "scale=4; x = $totalG50 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG60=`echo "scale=4; x = $totalG60 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG70=`echo "scale=4; x = $totalG70 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG80=`echo "scale=4; x = $totalG80 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG90=`echo "scale=4; x = $totalG90 / $NUM_LOOP; if(x<1) print 0; x" | bc` + echo "Latency, G-0, G-10, G-20, G-30, G-40, G-50, G-60, G-70, G-80, G-90" + echo "OpenTSDB, $avgG0, $avgG10, $avgG20, $avgG30, $avgG40, $avgG50, $avgG60, $avgG70, $avgG80, $avgG90" +} + +################ Main ################ + +master=false +develop=true +verbose=false + +clients=1 + +while : ; do + case $1 in + -v) + verbose=true + shift ;; + + -c) + clients=$2 + shift 2;; + + -n) + NUM_LOOP=$2 + shift 2;; + + *) + break ;; + esac +done + +WORK_DIR=/mnt/root/TDengine +TSDBTEST_DIR=$WORK_DIR/tests/comparisonTest/opentsdb + +runTest + +printTo "Test done!" diff --git a/tests/perftest-scripts/opentsdbTestQ2Loop.sh b/tests/perftest-scripts/opentsdbTestQ2Loop.sh new file mode 100755 index 0000000000000000000000000000000000000000..db2d0435a3322e10a27f3cbe4a52ea8d623e6690 --- /dev/null +++ b/tests/perftest-scripts/opentsdbTestQ2Loop.sh @@ -0,0 +1,276 @@ +#!/bin/bash + +NUM_LOOP=5 + +function printTo { + if $verbose ; then + echo $1 + fi +} + +TSDBTESTQ2OUT=opentsdbTestQ2.out + +function runTest { + totalCount10=0 + totalCount20=0 + totalCount30=0 + totalCount40=0 + totalCount50=0 + totalCount60=0 + totalCount70=0 + totalCount80=0 + totalCount90=0 + totalCount100=0 + + totalAvg10=0 + totalAvg20=0 + totalAvg30=0 + totalAvg40=0 + totalAvg50=0 + totalAvg60=0 + totalAvg70=0 + totalAvg80=0 + totalAvg90=0 + totalAvg100=0 + + totalSum10=0 + totalSum20=0 + totalSum30=0 + totalSum40=0 + totalSum50=0 + totalSum60=0 + totalSum70=0 + totalSum80=0 + totalSum90=0 + totalSum100=0 + + totalMax10=0 + totalMax20=0 + totalMax30=0 + totalMax40=0 + totalMax50=0 + totalMax60=0 + totalMax70=0 + totalMax80=0 + totalMax90=0 + totalMax100=0 + + totalMin10=0 + totalMin20=0 + totalMin30=0 + totalMin40=0 + totalMin50=0 + totalMin60=0 + totalMin70=0 + totalMin80=0 + totalMin90=0 + totalMin100=0 + + for i in `seq 1 $NUM_LOOP`; do + printTo "loop i:$i, java -jar \ + $TSDBTEST_DIR/opentsdbtest/target/opentsdbtest-1.0-SNAPSHOT-jar-with-dependencies.jar \ + -sql q2" + java -jar \ + $TSDBTEST_DIR/opentsdbtest/target/opentsdbtest-1.0-SNAPSHOT-jar-with-dependencies.jar \ + -sql q2 2>&1 \ + | tee $TSDBTESTQ2OUT + + Count10=`cat $TSDBTESTQ2OUT | grep count | grep "devgroup < 10" | awk '{print $2}'` + totalCount10=`echo "scale=4; $totalCount10 + $Count10" | bc` + Count20=`cat $TSDBTESTQ2OUT | grep count | grep "devgroup < 20" | awk '{print $2}'` + totalCount20=`echo "scale=4; $totalCount20 + $Count20" | bc` + Count30=`cat $TSDBTESTQ2OUT | grep count | grep "devgroup < 30" | awk '{print $2}'` + totalCount30=`echo "scale=4; $totalCount30 + $Count30" | bc` + Count40=`cat $TSDBTESTQ2OUT | grep count | grep "devgroup < 40" | awk '{print $2}'` + totalCount40=`echo "scale=4; $totalCount40 + $Count40" | bc` + Count50=`cat $TSDBTESTQ2OUT | grep count | grep "devgroup < 50" | awk '{print $2}'` + totalCount50=`echo "scale=4; $totalCount50 + $Count50" | bc` + Count60=`cat $TSDBTESTQ2OUT | grep count | grep "devgroup < 60" | awk '{print $2}'` + totalCount60=`echo "scale=4; $totalCount60 + $Count60" | bc` + Count70=`cat $TSDBTESTQ2OUT | grep count | grep "devgroup < 70" | awk '{print $2}'` + totalCount70=`echo "scale=4; $totalCount70 + $Count70" | bc` + Count80=`cat $TSDBTESTQ2OUT | grep count | grep "devgroup < 80" | awk '{print $2}'` + totalCount80=`echo "scale=4; $totalCount80 + $Count80" | bc` + Count90=`cat $TSDBTESTQ2OUT | grep count | grep "devgroup < 90" | awk '{print $2}'` + totalCount90=`echo "scale=4; $totalCount90 + $Count90" | bc` + Count100=`cat $TSDBTESTQ2OUT | grep count | grep "devgroup < 100" | awk '{print $2}'` + totalCount100=`echo "scale=4; $totalCount100 + $Count100" | bc` + + Avg10=`cat $TSDBTESTQ2OUT | grep avg | grep "devgroup < 10" | awk '{print $2}'` + totalAvg10=`echo "scale=4; $totalAvg10 + $Avg10" | bc` + Avg20=`cat $TSDBTESTQ2OUT | grep avg | grep "devgroup < 20" | awk '{print $2}'` + totalAvg20=`echo "scale=4; $totalAvg20 + $Avg20" | bc` + Avg30=`cat $TSDBTESTQ2OUT | grep avg | grep "devgroup < 30" | awk '{print $2}'` + totalAvg30=`echo "scale=4; $totalAvg30 + $Avg30" | bc` + Avg40=`cat $TSDBTESTQ2OUT | grep avg | grep "devgroup < 40" | awk '{print $2}'` + totalAvg40=`echo "scale=4; $totalAvg40 + $Avg40" | bc` + Avg50=`cat $TSDBTESTQ2OUT | grep avg | grep "devgroup < 50" | awk '{print $2}'` + totalAvg50=`echo "scale=4; $totalAvg50 + $Avg50" | bc` + Avg60=`cat $TSDBTESTQ2OUT | grep avg | grep "devgroup < 60" | awk '{print $2}'` + totalAvg60=`echo "scale=4; $totalAvg60 + $Avg60" | bc` + Avg70=`cat $TSDBTESTQ2OUT | grep avg | grep "devgroup < 70" | awk '{print $2}'` + totalAvg70=`echo "scale=4; $totalAvg70 + $Avg70" | bc` + Avg80=`cat $TSDBTESTQ2OUT | grep avg | grep "devgroup < 80" | awk '{print $2}'` + totalAvg80=`echo "scale=4; $totalAvg80 + $Avg80" | bc` + Avg90=`cat $TSDBTESTQ2OUT | grep avg | grep "devgroup < 90" | awk '{print $2}'` + totalAvg90=`echo "scale=4; $totalAvg90 + $Avg90" | bc` + Avg100=`cat $TSDBTESTQ2OUT | grep avg | grep "devgroup < 100" | awk '{print $2}'` + totalAvg100=`echo "scale=4; $totalAvg100 + $Avg100" | bc` + + Sum10=`cat $TSDBTESTQ2OUT | grep sum | grep "devgroup < 10" | awk '{print $2}'` + totalSum10=`echo "scale=4; $totalSum10 + $Sum10" | bc` + Sum20=`cat $TSDBTESTQ2OUT | grep sum | grep "devgroup < 20" | awk '{print $2}'` + totalSum20=`echo "scale=4; $totalSum20 + $Sum20" | bc` + Sum30=`cat $TSDBTESTQ2OUT | grep sum | grep "devgroup < 30" | awk '{print $2}'` + totalSum30=`echo "scale=4; $totalSum30 + $Sum30" | bc` + Sum40=`cat $TSDBTESTQ2OUT | grep sum | grep "devgroup < 40" | awk '{print $2}'` + totalSum40=`echo "scale=4; $totalSum40 + $Sum40" | bc` + Sum50=`cat $TSDBTESTQ2OUT | grep sum | grep "devgroup < 50" | awk '{print $2}'` + totalSum50=`echo "scale=4; $totalSum50 + $Sum50" | bc` + Sum60=`cat $TSDBTESTQ2OUT | grep sum | grep "devgroup < 60" | awk '{print $2}'` + totalSum60=`echo "scale=4; $totalSum60 + $Sum60" | bc` + Sum70=`cat $TSDBTESTQ2OUT | grep sum | grep "devgroup < 70" | awk '{print $2}'` + totalSum70=`echo "scale=4; $totalSum70 + $Sum70" | bc` + Sum80=`cat $TSDBTESTQ2OUT | grep sum | grep "devgroup < 80" | awk '{print $2}'` + totalSum80=`echo "scale=4; $totalSum80 + $Sum80" | bc` + Sum90=`cat $TSDBTESTQ2OUT | grep sum | grep "devgroup < 90" | awk '{print $2}'` + totalSum90=`echo "scale=4; $totalSum90 + $Sum90" | bc` + Sum100=`cat $TSDBTESTQ2OUT | grep sum | grep "devgroup < 100" | awk '{print $2}'` + totalSum100=`echo "scale=4; $totalSum100 + $Sum100" | bc` + + Max10=`cat $TSDBTESTQ2OUT | grep max | grep "devgroup < 10" | awk '{print $2}'` + totalMax10=`echo "scale=4; $totalMax10 + $Max10" | bc` + Max20=`cat $TSDBTESTQ2OUT | grep max | grep "devgroup < 20" | awk '{print $2}'` + totalMax20=`echo "scale=4; $totalMax20 + $Max20" | bc` + Max30=`cat $TSDBTESTQ2OUT | grep max | grep "devgroup < 30" | awk '{print $2}'` + totalMax30=`echo "scale=4; $totalMax30 + $Max30" | bc` + Max40=`cat $TSDBTESTQ2OUT | grep max | grep "devgroup < 40" | awk '{print $2}'` + totalMax40=`echo "scale=4; $totalMax40 + $Max40" | bc` + Max50=`cat $TSDBTESTQ2OUT | grep max | grep "devgroup < 50" | awk '{print $2}'` + totalMax50=`echo "scale=4; $totalMax50 + $Max50" | bc` + Max60=`cat $TSDBTESTQ2OUT | grep max | grep "devgroup < 60" | awk '{print $2}'` + totalMax60=`echo "scale=4; $totalMax60 + $Max60" | bc` + Max70=`cat $TSDBTESTQ2OUT | grep max | grep "devgroup < 70" | awk '{print $2}'` + totalMax70=`echo "scale=4; $totalMax70 + $Max70" | bc` + Max80=`cat $TSDBTESTQ2OUT | grep max | grep "devgroup < 80" | awk '{print $2}'` + totalMax80=`echo "scale=4; $totalMax80 + $Max80" | bc` + Max90=`cat $TSDBTESTQ2OUT | grep max | grep "devgroup < 90" | awk '{print $2}'` + totalMax90=`echo "scale=4; $totalMax90 + $Max90" | bc` + Max100=`cat $TSDBTESTQ2OUT | grep max | grep "devgroup < 100" | awk '{print $2}'` + totalMax100=`echo "scale=4; $totalMax100 + $Max100" | bc` + + Min10=`cat $TSDBTESTQ2OUT | grep min | grep "devgroup < 10" | awk '{print $2}'` + totalMin10=`echo "scale=4; $totalMin10 + $Min10" | bc` + Min20=`cat $TSDBTESTQ2OUT | grep min | grep "devgroup < 20" | awk '{print $2}'` + totalMin20=`echo "scale=4; $totalMin20 + $Min20" | bc` + Min30=`cat $TSDBTESTQ2OUT | grep min | grep "devgroup < 30" | awk '{print $2}'` + totalMin30=`echo "scale=4; $totalMin30 + $Min30" | bc` + Min40=`cat $TSDBTESTQ2OUT | grep min | grep "devgroup < 40" | awk '{print $2}'` + totalMin40=`echo "scale=4; $totalMin40 + $Min40" | bc` + Min50=`cat $TSDBTESTQ2OUT | grep min | grep "devgroup < 50" | awk '{print $2}'` + totalMin50=`echo "scale=4; $totalMin50 + $Min50" | bc` + Min60=`cat $TSDBTESTQ2OUT | grep min | grep "devgroup < 60" | awk '{print $2}'` + totalMin60=`echo "scale=4; $totalMin60 + $Min60" | bc` + Min70=`cat $TSDBTESTQ2OUT | grep min | grep "devgroup < 70" | awk '{print $2}'` + totalMin70=`echo "scale=4; $totalMin70 + $Min70" | bc` + Min80=`cat $TSDBTESTQ2OUT | grep min | grep "devgroup < 80" | awk '{print $2}'` + totalMin80=`echo "scale=4; $totalMin80 + $Min80" | bc` + Min90=`cat $TSDBTESTQ2OUT | grep min | grep "devgroup < 90" | awk '{print $2}'` + totalMin90=`echo "scale=4; $totalMin90 + $Min90" | bc` + Min100=`cat $TSDBTESTQ2OUT | grep min | grep "devgroup < 100" | awk '{print $2}'` + totalMin100=`echo "scale=4; $totalMin100 + $Min100" | bc` + + done + avgCount10=`echo "scale=4; x = $totalCount10 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount20=`echo "scale=4; x = $totalCount20 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount30=`echo "scale=4; x = $totalCount30 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount40=`echo "scale=4; x = $totalCount40 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount50=`echo "scale=4; x = $totalCount50 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount60=`echo "scale=4; x = $totalCount60 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount70=`echo "scale=4; x = $totalCount70 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount80=`echo "scale=4; x = $totalCount80 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount90=`echo "scale=4; x = $totalCount90 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount100=`echo "scale=4; x = $totalCount100 / $NUM_LOOP; if(x<1) print 0; x" | bc` + + avgAvg10=`echo "scale=4; x = $totalAvg10 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgAvg20=`echo "scale=4; x = $totalAvg20 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgAvg30=`echo "scale=4; x = $totalAvg30 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgAvg40=`echo "scale=4; x = $totalAvg40 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgAvg50=`echo "scale=4; x = $totalAvg50 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgAvg60=`echo "scale=4; x = $totalAvg60 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgAvg70=`echo "scale=4; x = $totalAvg70 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgAvg80=`echo "scale=4; x = $totalAvg80 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgAvg90=`echo "scale=4; x = $totalAvg90 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgAvg100=`echo "scale=4; x = $totalAvg100 / $NUM_LOOP; if(x<1) print 0; x" | bc` + + avgSum10=`echo "scale=4; x = $totalSum10 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum20=`echo "scale=4; x = $totalSum20 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum30=`echo "scale=4; x = $totalSum30 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum40=`echo "scale=4; x = $totalSum40 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum50=`echo "scale=4; x = $totalSum50 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum60=`echo "scale=4; x = $totalSum60 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum70=`echo "scale=4; x = $totalSum70 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum80=`echo "scale=4; x = $totalSum80 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum90=`echo "scale=4; x = $totalSum90 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum100=`echo "scale=4; x = $totalSum100 / $NUM_LOOP; if(x<1) print 0; x" | bc` + + avgMax10=`echo "scale=4; x = $totalMax10 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax20=`echo "scale=4; x = $totalMax20 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax30=`echo "scale=4; x = $totalMax30 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax40=`echo "scale=4; x = $totalMax40 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax50=`echo "scale=4; x = $totalMax50 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax60=`echo "scale=4; x = $totalMax60 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax70=`echo "scale=4; x = $totalMax70 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax80=`echo "scale=4; x = $totalMax80 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax90=`echo "scale=4; x = $totalMax90 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax100=`echo "scale=4; x = $totalMax100 / $NUM_LOOP; if(x<1) print 0; x" | bc` + + avgMin10=`echo "scale=4; x = $totalMin10 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin20=`echo "scale=4; x = $totalMin20 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin30=`echo "scale=4; x = $totalMin30 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin40=`echo "scale=4; x = $totalMin40 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin50=`echo "scale=4; x = $totalMin50 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin60=`echo "scale=4; x = $totalMin60 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin70=`echo "scale=4; x = $totalMin70 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin80=`echo "scale=4; x = $totalMin80 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin90=`echo "scale=4; x = $totalMin90 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin100=`echo "scale=4; x = $totalMin100 / $NUM_LOOP; if(x<1) print 0; x" | bc` + + echo "Latency, 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%, 100%" + echo "Count, $avgCount10, $avgCount20, $avgCount30, $avgCount40, $avgCount50, $avgCount60, $avgCount70, $avgCount80, $avgCount90, $avgCount100" + echo "Avg, $avgAvg10, $avgAvg20, $avgAvg30, $avgAvg40, $avgAvg50, $avgAvg60, $avgAvg70, $avgAvg80, $avgAvg90, $avgAvg100" + echo "Sum, $avgSum10, $avgSum20, $avgSum30, $avgSum40, $avgSum50, $avgSum60, $avgSum70, $avgSum80, $avgSum90, $avgSum100" + echo "Max, $avgMax10, $avgMax20, $avgMax30, $avgMax40, $avgMax50, $avgMax60, $avgMax70, $avgMax80, $avgMax90, $avgMax100" + echo "Min, $avgMin10, $avgMin20, $avgMin30, $avgMin40, $avgMin50, $avgMin60, $avgMin70, $avgMin80, $avgMin90, $avgMin100" +} + +################ Main ################ + +verbose=false + +for arg in "$@" +do + case $arg in + -v) + verbose=true + shift ;; + + -c) + clients=$2 + shift 2;; + + -n) + NUM_LOOP=$2 + shift 2;; + + *) + ;; + esac +done + +WORK_DIR=/mnt/root/TDengine +TSDBTEST_DIR=$WORK_DIR/tests/comparisonTest/opentsdb + +runTest + +printTo "Test done!" diff --git a/tests/perftest-scripts/opentsdbTestQ3Loop.sh b/tests/perftest-scripts/opentsdbTestQ3Loop.sh new file mode 100755 index 0000000000000000000000000000000000000000..6f69cf85a0d9d3a196991b40655d9c90e6865253 --- /dev/null +++ b/tests/perftest-scripts/opentsdbTestQ3Loop.sh @@ -0,0 +1,96 @@ +#!/bin/bash + +NUM_LOOP=5 + +function printTo { + if $verbose ; then + echo $1 + fi +} + +TSDBTESTQ3OUT=opentsdbTestQ3.out + +function runTest { + totalG10=0 + totalG20=0 + totalG30=0 + totalG40=0 + totalG50=0 + totalG60=0 + totalG70=0 + totalG80=0 + totalG90=0 + totalG100=0 + for i in `seq 1 $NUM_LOOP`; do + printTo "loop i:$i, java -jar \ + $TSDBTEST_DIR/opentsdbtest/target/opentsdbtest-1.0-SNAPSHOT-jar-with-dependencies.jar \ + -sql q3" + java -jar \ + $TSDBTEST_DIR/opentsdbtest/target/opentsdbtest-1.0-SNAPSHOT-jar-with-dependencies.jar \ + -sql q3 2>&1 \ + | tee $TSDBTESTQ3OUT + G10=`grep -w "devgroup < 10" $TSDBTESTQ3OUT| awk '{print $2}'` + totalG10=`echo "scale=4; $totalG10 + $G10" | bc` + G20=`grep -w "devgroup < 20" $TSDBTESTQ3OUT| awk '{print $2}'` + totalG20=`echo "scale=4; $totalG20 + $G20" | bc` + G30=`grep -w "devgroup < 30" $TSDBTESTQ3OUT| awk '{print $2}'` + totalG30=`echo "scale=4; $totalG30 + $G30" | bc` + G40=`grep -w "devgroup < 40" $TSDBTESTQ3OUT| awk '{print $2}'` + totalG40=`echo "scale=4; $totalG40 + $G40" | bc` + G50=`grep -w "devgroup < 50" $TSDBTESTQ3OUT| awk '{print $2}'` + totalG50=`echo "scale=4; $totalG50 + $G50" | bc` + G60=`grep -w "devgroup < 60" $TSDBTESTQ3OUT| awk '{print $2}'` + totalG60=`echo "scale=4; $totalG60 + $G60" | bc` + G70=`grep -w "devgroup < 70" $TSDBTESTQ3OUT| awk '{print $2}'` + totalG70=`echo "scale=4; $totalG70 + $G70" | bc` + G80=`grep -w "devgroup < 80" $TSDBTESTQ3OUT| awk '{print $2}'` + totalG80=`echo "scale=4; $totalG80 + $G80" | bc` + G90=`grep -w "devgroup < 90" $TSDBTESTQ3OUT| awk '{print $2}'` + totalG90=`echo "scale=4; $totalG90 + $G90" | bc` + G100=`grep -w "devgroup < 100" $TSDBTESTQ3OUT| awk '{print $2}'` + totalG100=`echo "scale=4; $totalG100 + $G100" | bc` + done + avgG10=`echo "scale=4; x = $totalG10 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG20=`echo "scale=4; x = $totalG20 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG30=`echo "scale=4; x = $totalG30 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG40=`echo "scale=4; x = $totalG40 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG50=`echo "scale=4; x = $totalG50 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG60=`echo "scale=4; x = $totalG60 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG70=`echo "scale=4; x = $totalG70 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG80=`echo "scale=4; x = $totalG80 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG90=`echo "scale=4; x = $totalG90 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG100=`echo "scale=4; x = $totalG100 / $NUM_LOOP; if(x<1) print 0; x" | bc` + echo "Latency, 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%, 100%" + echo "OpenTSDB, $avgG10, $avgG20, $avgG30, $avgG40, $avgG50, $avgG60, $avgG70, $avgG80, $avgG90, $avgG100" +} + +################ Main ################ + +verbose=false + +for arg in "$@" +do + case $arg in + -v) + verbose=true + shift ;; + + -c) + clients=$2 + shift 2;; + + -n) + NUM_LOOP=$2 + shift 2;; + + *) + ;; + esac +done + +WORK_DIR=/mnt/root/TDengine +TSDBTEST_DIR=$WORK_DIR/tests/comparisonTest/opentsdb + +runTest + +printTo "Test done!" diff --git a/tests/perftest-scripts/opentsdbTestQ4Loop.sh b/tests/perftest-scripts/opentsdbTestQ4Loop.sh new file mode 100755 index 0000000000000000000000000000000000000000..4341f2165ce05da20d268b991f596d6636f3bdb2 --- /dev/null +++ b/tests/perftest-scripts/opentsdbTestQ4Loop.sh @@ -0,0 +1,103 @@ +#!/bin/bash + +DATA_DIR=/mnt/root/testdata +NUM_LOOP=5 + +function printTo { + if $verbose ; then + echo $1 + fi +} + +TSDBTESTQ4OUT=opentsdbTestQ4.out + +function runTest { + totalG10=0 + totalG20=0 + totalG30=0 + totalG40=0 + totalG50=0 + totalG60=0 + totalG70=0 + totalG80=0 + totalG90=0 + totalG100=0 + for i in `seq 1 $NUM_LOOP`; do + printTo "loop i:$i, java -jar \ + $TSDBTEST_DIR/opentsdbtest/target/opentsdbtest-1.0-SNAPSHOT-jar-with-dependencies.jar \ + -sql q4" + + java -jar \ + $TSDBTEST_DIR/opentsdbtest/target/opentsdbtest-1.0-SNAPSHOT-jar-with-dependencies.jar \ + -sql q4 2>&1 | + tee $TSDBTESTQ4OUT + G10=`grep -w "devgroup < 10" $TSDBTESTQ4OUT| awk '{print $2}'` + totalG10=`echo "scale=4; $totalG10 + $G10" | bc` + G20=`grep -w "devgroup < 20" $TSDBTESTQ4OUT| awk '{print $2}'` + totalG20=`echo "scale=4; $totalG20 + $G20" | bc` + G30=`grep -w "devgroup < 30" $TSDBTESTQ4OUT| awk '{print $2}'` + totalG30=`echo "scale=4; $totalG30 + $G30" | bc` + G40=`grep -w "devgroup < 40" $TSDBTESTQ4OUT| awk '{print $2}'` + totalG40=`echo "scale=4; $totalG40 + $G40" | bc` + G50=`grep -w "devgroup < 50" $TSDBTESTQ4OUT| awk '{print $2}'` + totalG50=`echo "scale=4; $totalG50 + $G50" | bc` + G60=`grep -w "devgroup < 60" $TSDBTESTQ4OUT| awk '{print $2}'` + totalG60=`echo "scale=4; $totalG60 + $G60" | bc` + G70=`grep -w "devgroup < 70" $TSDBTESTQ4OUT| awk '{print $2}'` + totalG70=`echo "scale=4; $totalG70 + $G70" | bc` + G80=`grep -w "devgroup < 80" $TSDBTESTQ4OUT| awk '{print $2}'` + totalG80=`echo "scale=4; $totalG80 + $G80" | bc` + G90=`grep -w "devgroup < 90" $TSDBTESTQ4OUT| awk '{print $2}'` + totalG90=`echo "scale=4; $totalG90 + $G90" | bc` + G100=`grep -w "devgroup < 100" $TSDBTESTQ4OUT| awk '{print $2}'` + totalG100=`echo "scale=4; $totalG100 + $G100" | bc` + done + avgG10=`echo "scale=4; x = $totalG10 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG20=`echo "scale=4; x = $totalG20 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG30=`echo "scale=4; x = $totalG30 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG40=`echo "scale=4; x = $totalG40 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG50=`echo "scale=4; x = $totalG50 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG60=`echo "scale=4; x = $totalG60 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG70=`echo "scale=4; x = $totalG70 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG80=`echo "scale=4; x = $totalG80 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG90=`echo "scale=4; x = $totalG90 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG100=`echo "scale=4; x = $totalG100 / $NUM_LOOP; if(x<1) print 0; x" | bc` + echo "Latency, 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%, 100%" + echo "OpenTSDB, $avgG10, $avgG20, $avgG30, $avgG40, $avgG50, $avgG60, $avgG70, $avgG80, $avgG90, $avgG100" +} + +################ Main ################ + +verbose=false +regeneratedata=false + +for arg in "$@" +do + case $arg in + -v) + verbose=true + shift ;; + + -c) + clients=$2 + shift 2;; + + -r) + regeneratedata=true + ;; + + -n) + NUM_LOOP=$2 + shift 2;; + + *) + ;; + esac +done + +WORK_DIR=/mnt/root/TDengine +TSDBTEST_DIR=$WORK_DIR/tests/comparisonTest/opentsdb + +runTest + +printTo "Test done!" diff --git a/tests/perftest-scripts/opentsdbTestWriteLoop.sh b/tests/perftest-scripts/opentsdbTestWriteLoop.sh new file mode 100755 index 0000000000000000000000000000000000000000..8bbd5aa9bd7a63294a04ff50714f3744ddb8b4c4 --- /dev/null +++ b/tests/perftest-scripts/opentsdbTestWriteLoop.sh @@ -0,0 +1,99 @@ +#!/bin/bash + +DATA_DIR=/mnt/root/testdata +NUM_LOOP=1 +NUM_OF_FILES=100 + +rowsPerRequest=(1 10 50 100 500 1000 2000) + +function printTo { + if $verbose ; then + echo $1 + fi +} + +function runTest { + declare -A avgRPR + + for r in ${!rowsPerRequest[@]}; do + for c in `seq 1 $clients`; do + avgRPR[$r, $c]=0 + done + done + + for r in ${!rowsPerRequest[@]}; do + for c in `seq 1 $clients`; do + totalRPR=0 + OUT_FILE=opentsdbWrite-rows${rowsPerRequest[$r]}-clients$c.out + for i in `seq 1 $NUM_LOOP`; do + printTo "loop i:$i java -jar \ + $TSDBTEST_DIR/opentsdbtest/target/opentsdbtest-1.0-SNAPSHOT-jar-with-dependencies.jar \ + -dataDir $DATA_DIR \ + -numOfFiles $NUM_OF_FILES \ + -writeClients $c \ + -rowsPerRequest $r" + java -jar \ + $TSDBTEST_DIR/opentsdbtest/target/opentsdbtest-1.0-SNAPSHOT-jar-with-dependencies.jar \ + -dataDir $DATA_DIR \ + -numOfFiles $NUM_OF_FILES \ + -writeClients $c \ + -rowsPerRequest ${rowsPerRequest[$r]} \ + 2>&1 | tee $OUT_FILE + RPR=`cat $OUT_FILE | grep speed | awk '{print $(NF-1)}'` + totalRPR=`echo "scale=4; $totalRPR + $RPR" | bc` + printTo "r:$r rows:${rowsPerRequest[$r]}, clients:$c, i:$i RPR:$RPR" + done + avgRPR[$r,$c]=`echo "scale=4; $totalRPR / $NUM_LOOP" | bc` + printTo "r:$r c:$c avgRPR:${avgRPR[$r, $c]}" + done + done + + printf "R/R, " + for c in `seq 1 $clients`; do + if [ "$c" == "1" ]; then + printf "$c client, " + else + printf "$c clients, " + fi + done + printf "\n" + + for r in ${!rowsPerRequest[@]}; do + printf "${rowsPerRequest[$r]}, " + for c in `seq 1 $clients`; do + printf "${avgRPR[$r,$c]}, " + done + printf "\n" + done +} + +################ Main ################ + +verbose=false +clients=1 + +while : ; do + case $1 in + -v) + verbose=true + shift ;; + + -n) + NUM_LOOP=$2 + shift 2;; + + -c) + clients=$2 + shift 2;; + + *) + break ;; + esac +done + +WORK_DIR=/mnt/root/TDengine +TSDBTEST_DIR=$WORK_DIR/tests/comparisonTest/opentsdb + +runTest + +printTo "Test done!" diff --git a/tests/perftest-scripts/perftest-consistent-inserting-data.sh b/tests/perftest-scripts/perftest-consistent-inserting-data.sh new file mode 100755 index 0000000000000000000000000000000000000000..bfed398b963e0902c1fe7a690b0b38bb43bdbc52 --- /dev/null +++ b/tests/perftest-scripts/perftest-consistent-inserting-data.sh @@ -0,0 +1,43 @@ +#!/bin/bash +ulimit -c unlimited + +function buildTDengine { + cd /root/TDengine + + git remote update + REMOTE_COMMIT=`git rev-parse --short remotes/origin/develop` + LOCAL_COMMIT=`git rev-parse --short @` + + echo " LOCAL: $LOCAL_COMMIT" + echo "REMOTE: $REMOTE_COMMIT" + if [ "$LOCAL_COMMIT" == "$REMOTE_COMMIT" ]; then + echo "repo up-to-date" + else + echo "repo need to pull" + git pull + + LOCAL_COMMIT=`git rev-parse --short @` + cd debug + rm -rf * + cmake .. + make > /dev/null + make install + fi +} + +function restartTaosd { + systemctl stop taosd + pkill -KILL -x taosd + sleep 10 + + rm -rf /var/lib/taos/data/* + rm -rf /var/lib/taos/log/* + + taosd 2>&1 > /dev/null & + sleep 10 +} + +buildTDengine +restartTaosd +cd /root/TDengine/tests/pytest/insert +python3 writeDBNonStop.py \ No newline at end of file diff --git a/tests/perftest-scripts/perftest-csv2png.gnuplot b/tests/perftest-scripts/perftest-csv2png.gnuplot new file mode 100644 index 0000000000000000000000000000000000000000..eabab268cab099e0ad06b8999961ddc5cf7b85d8 --- /dev/null +++ b/tests/perftest-scripts/perftest-csv2png.gnuplot @@ -0,0 +1,33 @@ +#!/user/bin/gnuplot +reset +set terminal png + +set title filename font ",20" + +set ylabel "Time in Seconds" + +set xdata time +set timefmt "%Y%m%d" +set format x "%Y-%m-%d" +set xlabel "Date" + +set style data linespoints + +set terminal pngcairo size 1024,768 enhanced font 'Segoe UI, 10' +set output filename . '.png' +set datafile separator ',' + +set key reverse Left outside +set grid + +# plot 'perftest-influx-report.csv' using 1:2 title "InfluxDB Write", \ +# "" using 1:3 title "InfluxDB Query case1", \ +# "" using 1:4 title "InfluxDB Query case2", \ +# "" using 1:5 title "InfluxDB Query case3", \ +# "" using 1:6 title "InfluxDB Query case4" +# +plot filename . '.csv' using 1:2 title "TDengine Write", \ + "" using 1:3 title "TDengine Query case1", \ + "" using 1:4 title "TDengine Query case2", \ + "" using 1:5 title "TDengine Query case3", \ + "" using 1:6 title "TDengine Query case4" diff --git a/tests/perftest-scripts/perftest-daily.sh b/tests/perftest-scripts/perftest-daily.sh new file mode 100755 index 0000000000000000000000000000000000000000..beac8de15aa2ed6490bae2854b0c9d046d97e134 --- /dev/null +++ b/tests/perftest-scripts/perftest-daily.sh @@ -0,0 +1,210 @@ +#!/bin/bash + +WORK_DIR=/mnt/root + +# Coloured Echoes # +function red_echo { echo -e "\033[31m$@\033[0m"; } # +function green_echo { echo -e "\033[32m$@\033[0m"; } # +function yellow_echo { echo -e "\033[33m$@\033[0m"; } # +function white_echo { echo -e "\033[1;37m$@\033[0m"; } # +# Coloured Printfs # +function red_printf { printf "\033[31m$@\033[0m"; } # +function green_printf { printf "\033[32m$@\033[0m"; } # +function yellow_printf { printf "\033[33m$@\033[0m"; } # +function white_printf { printf "\033[1;37m$@\033[0m"; } # +# Debugging Outputs # +function white_brackets { local args="$@"; white_printf "["; printf "${args}"; white_printf "]"; } # +function echoInfo { local args="$@"; white_brackets $(green_printf "INFO") && echo " ${args}"; } # +function echoWarn { local args="$@"; echo "$(white_brackets "$(yellow_printf "WARN")" && echo " ${args}";)" 1>&2; } # +function echoError { local args="$@"; echo "$(white_brackets "$(red_printf "ERROR")" && echo " ${args}";)" 1>&2; } # + +function setMaxTablesPerVnode { + echo "/etc/taos/taos.cfg maxTablesPerVnode will be set to $1" + + hasText=`grep "maxTablesPerVnode" /etc/taos/taos.cfg` + if [[ -z "$hasText" ]]; then + echo "maxTablesPerVnode $1" >> /etc/taos/taos.cfg + else + sed -i 's/^maxTablesPerVnode.*$/maxTablesPerVnode '"$1"'/g' /etc/taos/taos.cfg + fi +} + +function setMaxConnections { + echo "/etc/taos/taos.cfg maxConnection will be set to $1" + + hasText=`grep "maxConnections" /etc/taos/taos.cfg` + if [[ -z "$hasText" ]]; then + echo "maxConnections $1" >> /etc/taos/taos.cfg + else + sed -i 's/^maxConnections.*$/maxConnections '"$1"'/g' /etc/taos/taos.cfg + fi +} + +function setQDebugFlag { + echo "/etc/taos/taos.cfg qDebugFlag will be set to $1" + + hasText=`grep -w "qDebugFlag" /etc/taos/taos.cfg` + if [[ -z "$hasText" ]]; then + echo "qDebugFlag $1" >> /etc/taos/taos.cfg + else + sed -i 's/^qDebugFlag.*$/qDebugFlag '"$1"'/g' /etc/taos/taos.cfg + fi +} + +function setDebugFlag { + echo "/etc/taos/taos.cfg DebugFlag will be set to $1" + + hasText=`grep -w "DebugFlag" /etc/taos/taos.cfg` + if [[ -z "$hasText" ]]; then + echo "DebugFlag $1" >> /etc/taos/taos.cfg + else + sed -i 's/^DebugFlag.*$/DebugFlag '"$1"'/g' /etc/taos/taos.cfg + fi +} + +function setWal { + echo "/etc/taos/taos.cfg walLevel will be set to $1" + + hasText=`grep "walLevel" /etc/taos/taos.cfg` + if [[ -z "$hasText" ]]; then + echo "walLevel $1" >> /etc/taos/taos.cfg + else + sed -i 's/^walLevel.*$/walLevel '"$1"'/g' /etc/taos/taos.cfg + fi +} + +function collectSysInfo { + rm sysinfo.log + grep model /proc/cpuinfo | tail -n1 | tee sysinfo.log + grep cores /proc/cpuinfo | tail -n1 | tee -a sysinfo.log + grep MemTotal /proc/meminfo | tee -a sysinfo.log + grep "^[^#;]" /etc/taos/taos.cfg | tee taos.cfg +} + +function buildTDengine { + echoInfo "Build TDengine" + cd $WORK_DIR/TDengine + + git remote update > /dev/null + REMOTE_COMMIT=`git rev-parse --short remotes/origin/develop` + LOCAL_COMMIT=`git rev-parse --short @` + + echo " LOCAL: $LOCAL_COMMIT" + echo "REMOTE: $REMOTE_COMMIT" + if [ "$LOCAL_COMMIT" == "$REMOTE_COMMIT" ]; then + echo "repo up-to-date" + else + echo "repo need to pull" + git pull > /dev/null + + LOCAL_COMMIT=`git rev-parse --short @` + cd debug + rm -rf * + cmake .. > /dev/null + make > /dev/null + make install + fi +} + +function sendReport { + receiver="sdsang@taosdata.com, sangshuduo@gmail.com" + mimebody="MIME-Version: 1.0\nContent-Type: text/html; charset=utf-8\n" + + echo -e "to: ${receiver}\nsubject: Perf test report ${today}, commit ID: ${LOCAL_COMMIT}\n" | \ + (cat - && uuencode perftest-1d-wal1-$today.log perftest-1d-wal1-$today.log)| \ + (cat - && uuencode perftest-1d-wal1-report.csv perftest-1d-wal1-report-$today.csv) | \ + (cat - && uuencode perftest-1d-wal1-report.png perftest-1d-wal1-report-$today.png) | \ + (cat - && uuencode perftest-13d-wal1-$today.log perftest-13d-wal1-$today.log)| \ + (cat - && uuencode perftest-13d-wal1-report.csv perftest-13d-wal1-report-$today.csv) | \ + (cat - && uuencode perftest-13d-wal1-report.png perftest-13d-wal1-report-$today.png) | \ + (cat - && uuencode perftest-var10k-int10s-wal1-$today.log perftest-var10k-int10s-wal1-$today.log)| \ + (cat - && uuencode perftest-var10k-int10s-wal1-report.csv perftest-var10k-int10s-wal1-report-$today.csv) | \ + (cat - && uuencode perftest-var10k-int10s-wal1-report.png perftest-var10k-int10s-wal1-report-$today.png) | \ + (cat - && uuencode taosdemo-wal1-$today.log taosdemo-wal1-$today.log) | \ + (cat - && uuencode taosdemo-wal1-report.csv taosdemo-wal1-report-$today.csv) | \ + (cat - && uuencode taosdemo-wal1-report.png taosdemo-wal1-report-$today.png) | \ + (cat - && uuencode taosdemo-rps-wal1-report.csv taosdemo-rps-wal1-report-$today.csv) | \ + (cat - && uuencode taosdemo-rps-wal1-report.png taosdemo-rps-wal1-report-$today.png) | \ + (cat - && uuencode perftest-1d-wal2-$today.log perftest-1d-wal2-$today.log)| \ + (cat - && uuencode perftest-1d-wal2-report.csv perftest-1d-wal2-report-$today.csv) | \ + (cat - && uuencode perftest-1d-wal2-report.png perftest-1d-wal2-report-$today.png) | \ + (cat - && uuencode perftest-13d-wal2-$today.log perftest-13d-wal2-$today.log)| \ + (cat - && uuencode perftest-13d-wal2-report.csv perftest-13d-wal2-report-$today.csv) | \ + (cat - && uuencode perftest-13d-wal2-report.png perftest-13d-wal2-report-$today.png) | \ + (cat - && uuencode perftest-var10k-int10s-wal2-$today.log perftest-var10k-int10s-wal2-$today.log)| \ + (cat - && uuencode perftest-var10k-int10s-wal2-report.csv perftest-var10k-int10s-wal2-report-$today.csv) | \ + (cat - && uuencode perftest-var10k-int10s-wal2-report.png perftest-var10k-int10s-wal2-report-$today.png) | \ + (cat - && uuencode taosdemo-wal2-$today.log taosdemo-wal2-$today.log) | \ + (cat - && uuencode taosdemo-wal2-report.csv taosdemo-wal2-report-$today.csv) | \ + (cat - && uuencode taosdemo-wal2-report.png taosdemo-wal2-report-$today.png) | \ + (cat - && uuencode taosdemo-rps-wal2-report.csv taosdemo-rps-wal2-report-$today.csv) | \ + (cat - && uuencode taosdemo-rps-wal2-report.png taosdemo-rps-wal2-report-$today.png) | \ + (cat - && uuencode sysinfo.log sysinfo.txt) | \ + (cat - && uuencode taos.cfg taos-cfg-$today.txt) | \ + ssmtp "${receiver}" +} + +today=`date +"%Y%m%d"` +cd $WORK_DIR +echo -e "cron-ran-at-${today}" >> $WORK_DIR/cron.log + +buildTDengine + +############################ +setMaxConnections 1000 +setMaxTablesPerVnode 6000 +setDebugFlag 131 +setQDebugFlag 131 + +############################ +setWal "2" + +cd $WORK_DIR +date >> $WORK_DIR/cron.log +./perftest-taosdemo.sh "wal2" +date >> $WORK_DIR/cron.log + +cd $WORK_DIR +date >> $WORK_DIR/cron.log +./perftest-tsdb-compare-1d.sh +date >> $WORK_DIR/cron.log + +cd $WORK_DIR +date >> $WORK_DIR/cron.log +./perftest-tsdb-compare-13d.sh +date >> $WORK_DIR/cron.log + +cd $WORK_DIR +date >> $WORK_DIR/cron.log +./perftest-tsdb-compare-var10k-int10s.sh +date >> $WORK_DIR/cron.log + +############################# +setWal "1" + +cd $WORK_DIR +date >> $WORK_DIR/cron.log +./perftest-taosdemo.sh "wal1" +date >> $WORK_DIR/cron.log + +cd $WORK_DIR +date >> $WORK_DIR/cron.log +./perftest-tsdb-compare-1d.sh +date >> $WORK_DIR/cron.log + +cd $WORK_DIR +date >> $WORK_DIR/cron.log +./perftest-tsdb-compare-13d.sh +date >> $WORK_DIR/cron.log + +cd $WORK_DIR +date >> $WORK_DIR/cron.log +./perftest-tsdb-compare-var10k-int10s.sh +date >> $WORK_DIR/cron.log + +############################# +collectSysInfo + +echoInfo "Send Report" +sendReport +echoInfo "End of Test" diff --git a/tests/perftest-scripts/perftest-query.sh b/tests/perftest-scripts/perftest-query.sh new file mode 100755 index 0000000000000000000000000000000000000000..05b2d45ce434d0990d7c143863b9ca268a7d6a26 --- /dev/null +++ b/tests/perftest-scripts/perftest-query.sh @@ -0,0 +1,152 @@ +#!/bin/bash + + +branch= +if [ x$1 != x ];then + branch=$1 + echo "Testing branch: $branch" +else + echo "Please enter branch name as a parameter" + exit 1 +fi + +type= +if [ x$2 != x ];then + type=jemalloc + echo "Building TDengine using jemalloc" +else + type=glibc + echo "Building TDengine using glibc" +fi + +today=`date +"%Y%m%d"` +WORK_DIR=/root/pxiao +name=`echo $branch | cut -d '/' -f2` +PERFORMANCE_TEST_REPORT=$WORK_DIR/TDinternal/community/tests/performance-report-$name-$type-$today.log + +# Coloured Echoes # +function red_echo { echo -e "\033[31m$@\033[0m"; } # +function green_echo { echo -e "\033[32m$@\033[0m"; } # +function yellow_echo { echo -e "\033[33m$@\033[0m"; } # +function white_echo { echo -e "\033[1;37m$@\033[0m"; } # +# Coloured Printfs # +function red_printf { printf "\033[31m$@\033[0m"; } # +function green_printf { printf "\033[32m$@\033[0m"; } # +function yellow_printf { printf "\033[33m$@\033[0m"; } # +function white_printf { printf "\033[1;37m$@\033[0m"; } # +# Debugging Outputs # +function white_brackets { local args="$@"; white_printf "["; printf "${args}"; white_printf "]"; } # +function echoInfo { local args="$@"; white_brackets $(green_printf "INFO") && echo " ${args}"; } # +function echoWarn { local args="$@"; echo "$(white_brackets "$(yellow_printf "WARN")" && echo " ${args}";)" 1>&2; } # +function echoError { local args="$@"; echo "$(white_brackets "$(red_printf "ERROR")" && echo " ${args}";)" 1>&2; } # + + +function stopTaosd { + echo "Stop taosd" + systemctl stop taosd + snap stop tdengine + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + pkill -TERM -x taosd + sleep 1 + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + done +} + +function buildTDengine { + echoInfo "Build TDinternal" + cd $WORK_DIR/TDinternal + + git remote update > /dev/null + git reset --hard HEAD + git fetch + git checkout $branch + REMOTE_COMMIT=`git rev-parse --short remotes/origin/$branch` + LOCAL_COMMIT=`git rev-parse --short @` + + echo " LOCAL: $LOCAL_COMMIT" + echo "REMOTE: $REMOTE_COMMIT" + if [ "$LOCAL_COMMIT" == "$REMOTE_COMMIT" ]; then + echo "repo up-to-date" + fi + + cd community + git reset --hard HEAD + cd .. + echo "git submodule update --init --recursive" + git submodule update --init --recursive + + git pull > /dev/null 2>&1 + + cd community + git remote update > /dev/null + git reset --hard HEAD + git fetch + git checkout $branch + REMOTE_COMMIT=`git rev-parse --short remotes/origin/$branch` + LOCAL_COMMIT=`git rev-parse --short @` + cd ../debug + rm -rf * + if [ $type = "jemalloc" ];then + echo "cmake .. -DJEMALLOC_ENABLED=true > /dev/null" + cmake .. -DJEMALLOC_ENABLED=true > /dev/null + else + cmake .. > /dev/null + fi + #cp $WORK_DIR/taosdemoPerformance.py $WORK_DIR/TDinternal/community/tests/pytest/tools/ + #cp $WORK_DIR/insertFromCSVPerformance.py $WORK_DIR/TDinternal/community/tests/pytest/insert/ + #cp $WORK_DIR/queryPerformance.py $WORK_DIR/TDinternal/community/tests/pytest/query/ + rm -rf $WORK_DIR/TDinternal/community/tests/pytest/query/operator.py + make > /dev/null 2>&1 + make install > /dev/null 2>&1 + echo "Build TDengine on remote server" + ssh perftest "./buildTDengine.sh $branch > /dev/null" +} + +function runQueryPerfTest { + [ -f $PERFORMANCE_TEST_REPORT ] && rm $PERFORMANCE_TEST_REPORT + nohup $WORK_DIR/TDinternal/debug/build/bin/taosd -c /etc/perf/ > /dev/null 2>&1 & + echoInfo "Wait TDengine to start" + sleep 60 + echoInfo "Run Performance Test" + cd $WORK_DIR/TDinternal/community/tests/pytest + + python3 query/queryPerformance.py -c $LOCAL_COMMIT -b $branch -T $type -d perf2 | tee -a $PERFORMANCE_TEST_REPORT + + python3 insert/insertFromCSVPerformance.py -c $LOCAL_COMMIT -b $branch -T $type | tee -a $PERFORMANCE_TEST_REPORT + + echo "=========== taosdemo performance: 4 int columns, 10000 tables, 100000 recoreds per table ===========" | tee -a $PERFORMANCE_TEST_REPORT + python3 tools/taosdemoPerformance.py -c $LOCAL_COMMIT -b $branch -T $type | tee -a $PERFORMANCE_TEST_REPORT + + echo "=========== taosdemo performance: 400 int columns, 400 double columns, 200 binary(128) columns, 10000 tables, 10 recoreds per table ===========" | tee -a $PERFORMANCE_TEST_REPORT + python3 tools/taosdemoPerformance.py -c $LOCAL_COMMIT -b $branch -T $type -i 400 -D 400 -B 200 -t 10000 -r 10 | tee -a $PERFORMANCE_TEST_REPORT + + echo "=========== taosdemo performance: 1900 int columns, 1900 double columns, 200 binary(128) columns, 10000 tables, 10 recoreds per table ===========" | tee -a $PERFORMANCE_TEST_REPORT + python3 tools/taosdemoPerformance.py -c $LOCAL_COMMIT -b $branch -T $type -i 1900 -D 1900 -B 200 -t 10000 -r 10 | tee -a $PERFORMANCE_TEST_REPORT +} + + +function sendReport { + echo "send report" + receiver="develop@taosdata.com" + mimebody="MIME-Version: 1.0\nContent-Type: text/html; charset=utf-8\n" + + cd $TDENGINE_DIR + + sed -i 's/\x1b\[[0-9;]*m//g' $PERFORMANCE_TEST_REPORT + BODY_CONTENT=`cat $PERFORMANCE_TEST_REPORT` + echo -e "From: \nto: ${receiver}\nsubject: Query Performace Report ${branch} ${type} commit ID: ${LOCAL_COMMIT}\n\n${today}:\n${BODY_CONTENT}" | \ + (cat - && uuencode $PERFORMANCE_TEST_REPORT performance-test-report-$today.log) | \ + /usr/sbin/ssmtp "${receiver}" && echo "Report Sent!" +} + + +stopTaosd +buildTDengine +runQueryPerfTest +stopTaosd + +echoInfo "Send Report" +sendReport +echoInfo "End of Test" \ No newline at end of file diff --git a/tests/perftest-scripts/perftest-taosdemo-compare.sh b/tests/perftest-scripts/perftest-taosdemo-compare.sh new file mode 100755 index 0000000000000000000000000000000000000000..60b6d1310dbb023b81bad87efae273637b5f4dc0 --- /dev/null +++ b/tests/perftest-scripts/perftest-taosdemo-compare.sh @@ -0,0 +1,147 @@ +#!/bin/bash + +WORK_DIR=/home/ubuntu/pxiao +TDENGINE_DIR=/home/ubuntu/pxiao/TDengine +NUM_OF_VERSIONS=5 +CURRENT_VERSION=0 +today=`date +"%Y%m%d"` +TAOSDEMO_COMPARE_TEST_REPORT=$TDENGINE_DIR/tests/taosdemo-compare-test-report-$today.log + +# Coloured Echoes +function red_echo { echo -e "\033[31m$@\033[0m"; } +function green_echo { echo -e "\033[32m$@\033[0m"; } +function yellow_echo { echo -e "\033[33m$@\033[0m"; } +function white_echo { echo -e "\033[1;37m$@\033[0m"; } +# Coloured Printfs +function red_printf { printf "\033[31m$@\033[0m"; } +function green_printf { printf "\033[32m$@\033[0m"; } +function yellow_printf { printf "\033[33m$@\033[0m"; } +function white_printf { printf "\033[1;37m$@\033[0m"; } +# Debugging Outputs +function white_brackets { local args="$@"; white_printf "["; printf "${args}"; white_printf "]"; } +function echoInfo { local args="$@"; white_brackets $(green_printf "INFO") && echo " ${args}"; } +function echoWarn { local args="$@"; echo "$(white_brackets "$(yellow_printf "WARN")" && echo " ${args}";)" 1>&2; } +function echoError { local args="$@"; echo "$(white_brackets "$(red_printf "ERROR")" && echo " ${args}";)" 1>&2; } + +function getCurrentVersion { + echoInfo "Build TDengine" + cd $WORK_DIR/TDengine + + git remote update > /dev/null + git reset --hard HEAD + git checkout master + REMOTE_COMMIT=`git rev-parse --short remotes/origin/master` + LOCAL_COMMIT=`git rev-parse --short @` + + echo " LOCAL: $LOCAL_COMMIT" + echo "REMOTE: $REMOTE_COMMIT" + if [ "$LOCAL_COMMIT" == "$REMOTE_COMMIT" ]; then + echo "repo up-to-date" + else + echo "repo need to pull" + git pull > /dev/null 2>&1 + fi + cd debug + rm -rf * + cmake .. > /dev/null 2>&1 + make > /dev/null 2>&1 + make install > /dev/null 2>&1 + + rm -rf $WORK_DIR/taosdemo + cp -r $TDENGINE_DIR/src/kit/taosdemo $WORK_DIR + CURRENT_VERSION=`taosd -V | grep version | awk '{print $3}' | awk -F. '{print $3}'` +} + +function buildTDengineByVersion() { + echoInfo "build TDengine on branch: $1" + git reset --hard HEAD + git checkout $1 + git pull > /dev/null + + rm -rf $TDENGINE_DIR/src/kit/taosdemo + cp -r $WORK_DIR/taosdemo $TDENGINE_DIR/src/kit + + cd $TDENGINE_DIR/debug + rm -rf * + cmake .. > /dev/null 2>&1 + make > /dev/null 2>&1 + make install > /dev/null 2>&1 +} + +function stopTaosd { + echo "Stop taosd" + systemctl stop taosd + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + pkill -TERM -x taosd + sleep 1 + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + done +} + +function startTaosd { + echo "Start taosd" + rm -rf /var/lib/perf/* + rm -rf /var/log/perf/* + nohup taosd -c /etc/perf/ > /dev/null 2>&1 & + sleep 10 +} + +function runTaosdemoCompare { + echoInfo "Stop Taosd" + stopTaosd + + getCurrentVersion + release="master" + + [ -f $TAOSDEMO_COMPARE_TEST_REPORT ] && rm $TAOSDEMO_COMPARE_TEST_REPORT + + for((i=0;i<$NUM_OF_VERSIONS;i++)) + do + startTaosd + taos -s "drop database if exists demodb;" + taosdemo -y -d demodb > taosdemoperf.txt + + echo "==================== taosdemo performance for $release ====================" | tee -a $TAOSDEMO_COMPARE_TEST_REPORT + CREATE_TABLE_TIME=`grep 'Spent' taosdemoperf.txt | awk 'NR==1{print $2}'` + INSERT_RECORDS_TIME=`grep 'Spent' taosdemoperf.txt | awk 'NR==2{print $2}'` + RECORDS_PER_SECOND=`grep 'Spent' taosdemoperf.txt | awk 'NR==2{print $16}'` + AVG_DELAY=`grep 'delay' taosdemoperf.txt | awk '{print $4}' | awk -Fm '{print $1}'` + MAX_DELAY=`grep 'delay' taosdemoperf.txt | awk '{print $6}' | awk -Fm '{print $1}'` + MIN_DELAY=`grep 'delay' taosdemoperf.txt | awk '{print $8}' | awk -Fm '{print $1}'` + + echo "create table time: $CREATE_TABLE_TIME seconds" | tee -a $TAOSDEMO_COMPARE_TEST_REPORT + echo "insert records time: $INSERT_RECORDS_TIME seconds" | tee -a $TAOSDEMO_COMPARE_TEST_REPORT + echo "records per second: $RECORDS_PER_SECOND records/second" | tee -a $TAOSDEMO_COMPARE_TEST_REPORT + echo "avg delay: $AVG_DELAY ms" | tee -a $TAOSDEMO_COMPARE_TEST_REPORT + echo "max delay: $MAX_DELAY ms" | tee -a $TAOSDEMO_COMPARE_TEST_REPORT + echo "min delay: $MIN_DELAY ms" | tee -a $TAOSDEMO_COMPARE_TEST_REPORT + + [ -f taosdemoperf.txt ] && rm taosdemoperf.txt + + stopTaosd + version=`expr $CURRENT_VERSION - $i` + release="release/s1$version" + buildTDengineByVersion $release + done +} + +function sendReport { + echo "send report" + receiver="develop@taosdata.com" + mimebody="MIME-Version: 1.0\nContent-Type: text/html; charset=utf-8\n" + + cd $TDENGINE_DIR + + sed -i 's/\x1b\[[0-9;]*m//g' $TAOSDEMO_COMPARE_TEST_REPORT + BODY_CONTENT=`cat $TAOSDEMO_COMPARE_TEST_REPORT` + echo -e "to: ${receiver}\nsubject: taosdemo performance compare test report ${today}, commit ID: ${LOCAL_COMMIT}\n\n${today}:\n${BODY_CONTENT}" | \ + (cat - && uuencode $TAOSDEMO_COMPARE_TEST_REPORT taosdemo-compare-test-report-$today.log) | \ + ssmtp "${receiver}" && echo "Report Sent!" +} + +runTaosdemoCompare +sendReport + +echoInfo "End of Taosdemo Compare Test" | tee -a $WORK_DIR/cron.log \ No newline at end of file diff --git a/tests/perftest-scripts/perftest-taosdemo.sh b/tests/perftest-scripts/perftest-taosdemo.sh new file mode 100755 index 0000000000000000000000000000000000000000..dffa251ef76d866f33247bd0ce6fd5bb718449de --- /dev/null +++ b/tests/perftest-scripts/perftest-taosdemo.sh @@ -0,0 +1,128 @@ +#!/bin/bash + +WORK_DIR=/mnt/root +TDENGINE_DIR=/root/TDengine + +walLevel=`grep "^walLevel" /etc/taos/taos.cfg | awk '{print $2}'` +if [[ "$walLevel" -eq "2" ]]; then + walPostfix="wal2" +elif [[ "$walLevel" -eq "1" ]]; then + walPostfix="wal1" +else + echo -e "${RED}wrong walLevel $walLevel found! ${NC}" + exit 1 +fi + +logDir=`grep "^logDir" /etc/taos/taos.cfg | awk '{print $2}'` +dataDir=`grep "^dataDir" /etc/taos/taos.cfg | awk '{print $2}'` + +[ -z "$logDir" ] && logDir="/var/log/taos" +[ -z "$dataDir" ] && dataDir="/var/lib/taos" + +# Coloured Echoes +function red_echo { echo -e "\033[31m$@\033[0m"; } +function green_echo { echo -e "\033[32m$@\033[0m"; } +function yellow_echo { echo -e "\033[33m$@\033[0m"; } +function white_echo { echo -e "\033[1;37m$@\033[0m"; } +# Coloured Printfs +function red_printf { printf "\033[31m$@\033[0m"; } +function green_printf { printf "\033[32m$@\033[0m"; } +function yellow_printf { printf "\033[33m$@\033[0m"; } +function white_printf { printf "\033[1;37m$@\033[0m"; } +# Debugging Outputs +function white_brackets { local args="$@"; white_printf "["; printf "${args}"; white_printf "]"; } +function echoInfo { local args="$@"; white_brackets $(green_printf "INFO") && echo " ${args}"; } +function echoWarn { local args="$@"; echo "$(white_brackets "$(yellow_printf "WARN")" && echo " ${args}";)" 1>&2; } +function echoError { local args="$@"; echo "$(white_brackets "$(red_printf "ERROR")" && echo " ${args}";)" 1>&2; } + +function restartTaosd { + echo "Stop taosd" + systemctl stop taosd + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + pkill -TERM -x taosd + sleep 1 + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + done + + rm -rf $logDir/* + rm -rf $dataDir/* + + echo "Start taosd" + taosd 2>&1 > /dev/null & + sleep 10 +} + +function runCreateTableOnly { + echoInfo "Restart Taosd" + restartTaosd + + /usr/bin/time -f "Total: %e" -o totaltime.out bash -c "yes | taosdemo -n 0 2>&1 | tee taosdemo-$walPostfix-$today.log" + demoCreateTableOnly=`grep "Total:" totaltime.out|awk '{print $2}'` +} + +function runDeleteTableOnly { + echoInfo "Restart Taosd" + restartTaosd + + /usr/bin/time -f "Total: %e" -o totaltime.out bash -c "yes | taosdemo -t 0 -D 1 2>&1 | tee taosdemo-$walPostfix-$today.log" + demoDeleteTableOnly=`grep "Total:" totaltime.out|awk '{print $2}'` +} + +function runCreateTableThenInsert { + echoInfo "Restart Taosd" + restartTaosd + + /usr/bin/time -f "Total: %e" -o totaltime.out bash -c "yes | taosdemo 2>&1 | tee -a taosdemo-$walPostfix-$today.log" + demoTableAndInsert=`grep "Total:" totaltime.out|awk '{print $2}'` + demoRPS=`grep "records\/second" taosdemo-$walPostfix-$today.log | tail -n1 | awk '{print $13}'` +} + +function queryPerformance { + echoInfo "Restart Taosd" + restartTaosd + + cd $TDENGINE_DIR/tests/pytest + python3 query/queryPerformance.py +} + +function generateTaosdemoPlot { + echo "${today} $walPostfix, demoCreateTableOnly: ${demoCreateTableOnly}, demoDeleteTableOnly: ${demoDeleteTableOnly}, demoTableAndInsert: ${demoTableAndInsert}" | tee -a taosdemo-$today.log + echo "${today}, ${demoCreateTableOnly}, ${demoDeleteTableOnly}, ${demoTableAndInsert}">> taosdemo-$walPostfix-report.csv + echo "${today}, ${demoRPS}" >> taosdemo-rps-$walPostfix-report.csv + + csvLines=`cat taosdemo-$walPostfix-report.csv | wc -l` + + if [ "$csvLines" -gt "10" ]; then + sed -i '1d' taosdemo-$walPostfix-report.csv + fi + + csvLines=`cat taosdemo-rps-$walPostfix-report.csv | wc -l` + + if [ "$csvLines" -gt "10" ]; then + sed -i '1d' taosdemo-rps-$walPostfix-report.csv + fi + + gnuplot -e "filename='taosdemo-$walPostfix-report'" -p taosdemo-csv2png.gnuplot + gnuplot -e "filename='taosdemo-rps-$walPostfix-report'" -p taosdemo-rps-csv2png.gnuplot +} + +today=`date +"%Y%m%d"` + +cd $WORK_DIR +echoInfo "Test Create Table Only " +runCreateTableOnly +echoInfo "Test Delete Table Only" +runDeleteTableOnly +echoInfo "Test Create Table then Insert data" +runCreateTableThenInsert +echoInfo "Query Performance for 10 Billion Records" +queryPerformance +echoInfo "Generate plot for taosdemo" +generateTaosdemoPlot + + +tar czf $WORK_DIR/taos-log-taosdemo-$today.tar.gz $logDir/* + +echoInfo "End of TaosDemo Test" | tee -a $WORK_DIR/cron.log diff --git a/tests/perftest-scripts/perftest-tsdb-compare-13d.sh b/tests/perftest-scripts/perftest-tsdb-compare-13d.sh new file mode 100755 index 0000000000000000000000000000000000000000..3f56a048e9f78b9e6d02bf8f1d704d27d46e1149 --- /dev/null +++ b/tests/perftest-scripts/perftest-tsdb-compare-13d.sh @@ -0,0 +1,87 @@ +#!/bin/bash + +WORK_DIR=/mnt/root +TSDB_CMP_DIR=timeseriesdatabase-comparisons/build/tsdbcompare + +walLevel=`grep "^walLevel" /etc/taos/taos.cfg | awk '{print $2}'` +if [[ "$walLevel" -eq "2" ]]; then + walPostfix="wal2" +elif [[ "$walLevel" -eq "1" ]]; then + walPostfix="wal1" +else + echo -e "${RED}wrong walLevel $walLevel found! ${NC}" + exit 1 +fi + +logDir=`grep "^logDir" /etc/taos/taos.cfg | awk '{print $2}'` +dataDir=`grep "^dataDir" /etc/taos/taos.cfg | awk '{print $2}'` + +[ -z "$logDir" ] && logDir="/var/log/taos" +[ -z "$dataDir" ] && dataDir="/var/lib/taos" + +# Coloured Echoes # +function red_echo { echo -e "\033[31m$@\033[0m"; } # +function green_echo { echo -e "\033[32m$@\033[0m"; } # +function yellow_echo { echo -e "\033[33m$@\033[0m"; } # +function white_echo { echo -e "\033[1;37m$@\033[0m"; } # +# Coloured Printfs # +function red_printf { printf "\033[31m$@\033[0m"; } # +function green_printf { printf "\033[32m$@\033[0m"; } # +function yellow_printf { printf "\033[33m$@\033[0m"; } # +function white_printf { printf "\033[1;37m$@\033[0m"; } # +# Debugging Outputs # +function white_brackets { local args="$@"; white_printf "["; printf "${args}"; white_printf "]"; } # +function echoInfo { local args="$@"; white_brackets $(green_printf "INFO") && echo " ${args}"; } # +function echoWarn { local args="$@"; echo "$(white_brackets "$(yellow_printf "WARN")" && echo " ${args}";)" 1>&2; } # +function echoError { local args="$@"; echo "$(white_brackets "$(red_printf "ERROR")" && echo " ${args}";)" 1>&2; } # + +function restartTaosd { + echo "Stop taosd" + systemctl stop taosd + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + pkill -TERM -x taosd + sleep 1 + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + done + + rm -rf $logDir/* + rm -rf $dataDir/* + + echo "Start taosd" + taosd 2>&1 > /dev/null & + sleep 10 +} + +function runPerfTest13d { + echoInfo "Restart Taosd" + restartTaosd + + cd $WORK_DIR/$TSDB_CMP_DIR + ./runTDengine.sh -d 13 -w -q 2>&1 | tee $WORK_DIR/perftest-13d-$walPostfix-$today.log +} + +function generatePerfPlot13d { + cd $WORK_DIR + + csvLines=`cat perftest-13d-$walPostfix-report.csv | wc -l` + + if [ "$csvLines" -gt "10" ]; then + sed -i '1d' perftest-13d-$walPostfix-report.csv + fi + + gnuplot -e "filename='perftest-13d-$walPostfix-report'" -p perftest-csv2png.gnuplot +} + +today=`date +"%Y%m%d"` +cd $WORK_DIR + +echoInfo "run Performance Test with 13 days data" +runPerfTest13d $1 +echoInfo "Generate plot of 13 days data" +generatePerfPlot13d $1 + +tar czf $WORK_DIR/taos-log-13d-$today.tar.gz $logDir/* + +echoInfo "End of TSDB-Compare 13-days-data Test" | tee -a $WORK_DIR/cron.log diff --git a/tests/perftest-scripts/perftest-tsdb-compare-1d.sh b/tests/perftest-scripts/perftest-tsdb-compare-1d.sh new file mode 100755 index 0000000000000000000000000000000000000000..29e72d7b3ff62aa30fdefd694e435335e752e630 --- /dev/null +++ b/tests/perftest-scripts/perftest-tsdb-compare-1d.sh @@ -0,0 +1,87 @@ +#!/bin/bash + +WORK_DIR=/mnt/root +TSDB_CMP_DIR=timeseriesdatabase-comparisons/build/tsdbcompare + +walLevel=`grep "^walLevel" /etc/taos/taos.cfg | awk '{print $2}'` +if [[ "$walLevel" -eq "2" ]]; then + walPostfix="wal2" +elif [[ "$walLevel" -eq "1" ]]; then + walPostfix="wal1" +else + echo -e "${RED}wrong walLevel $walLevel found! ${NC}" + exit 1 +fi + +logDir=`grep "^logDir" /etc/taos/taos.cfg | awk '{print $2}'` +dataDir=`grep "^dataDir" /etc/taos/taos.cfg | awk '{print $2}'` + +[ -z "$logDir" ] && logDir="/var/log/taos" +[ -z "$dataDir" ] && dataDir="/var/lib/taos" + +# Coloured Echoes # +function red_echo { echo -e "\033[31m$@\033[0m"; } # +function green_echo { echo -e "\033[32m$@\033[0m"; } # +function yellow_echo { echo -e "\033[33m$@\033[0m"; } # +function white_echo { echo -e "\033[1;37m$@\033[0m"; } # +# Coloured Printfs # +function red_printf { printf "\033[31m$@\033[0m"; } # +function green_printf { printf "\033[32m$@\033[0m"; } # +function yellow_printf { printf "\033[33m$@\033[0m"; } # +function white_printf { printf "\033[1;37m$@\033[0m"; } # +# Debugging Outputs # +function white_brackets { local args="$@"; white_printf "["; printf "${args}"; white_printf "]"; } # +function echoInfo { local args="$@"; white_brackets $(green_printf "INFO") && echo " ${args}"; } # +function echoWarn { local args="$@"; echo "$(white_brackets "$(yellow_printf "WARN")" && echo " ${args}";)" 1>&2; } # +function echoError { local args="$@"; echo "$(white_brackets "$(red_printf "ERROR")" && echo " ${args}";)" 1>&2; } # + +function restartTaosd { + echo "Stop taosd" + systemctl stop taosd + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + pkill -TERM -x taosd + sleep 1 + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + done + + rm -rf $logDir/* + rm -rf $dataDir/* + + echo "Start taosd" + taosd 2>&1 > /dev/null & + sleep 10 +} + +function runPerfTest1d { + echoInfo "Restart Taosd" + restartTaosd + + cd $WORK_DIR/$TSDB_CMP_DIR + ./runTDengine.sh -d 1 -w -q 2>&1 | tee $WORK_DIR/perftest-1d-$walPostfix-$today.log +} + +function generatePerfPlot1d { + cd $WORK_DIR + + csvLines=`cat perftest-1d-$walPostfix-report.csv | wc -l` + + if [ "$csvLines" -gt "10" ]; then + sed -i '1d' perftest-1d-$walPostfix-report.csv + fi + + gnuplot -e "filename='perftest-1d-$walPostfix-report'" -p perftest-csv2png.gnuplot +} + +today=`date +"%Y%m%d"` +cd $WORK_DIR + +echoInfo "run Performance Test with 1 day data" +runPerfTest1d +echoInfo "Generate plot of 1 day data" +generatePerfPlot1d + +tar czf $WORK_DIR/taos-log-1d-$today.tar.gz $logDir/* + +echoInfo "End of TSDB-Compare 1-day-data Test" | tee -a $WORK_DIR/cron.log diff --git a/tests/perftest-scripts/perftest-tsdb-compare-var10k-int100s.sh b/tests/perftest-scripts/perftest-tsdb-compare-var10k-int100s.sh new file mode 100755 index 0000000000000000000000000000000000000000..3bc63b831b901b9a8a4b9b96385574a345ab58c6 --- /dev/null +++ b/tests/perftest-scripts/perftest-tsdb-compare-var10k-int100s.sh @@ -0,0 +1,87 @@ +#!/bin/bash + +WORK_DIR=/mnt/root +TSDB_CMP_DIR=timeseriesdatabase-comparisons/build/tsdbcompare + +walLevel=`grep "^walLevel" /etc/taos/taos.cfg | awk '{print $2}'` +if [[ "$walLevel" -eq "2" ]]; then + walPostfix="wal2" +elif [[ "$walLevel" -eq "1" ]]; then + walPostfix="wal1" +else + echo -e "${RED}wrong walLevel $walLevel found! ${NC}" + exit 1 +fi + +logDir=`grep "^logDir" /etc/taos/taos.cfg | awk '{print $2}'` +dataDir=`grep "^dataDir" /etc/taos/taos.cfg | awk '{print $2}'` + +[ -z "$logDir" ] && logDir="/var/log/taos" +[ -z "$dataDir" ] && dataDir="/var/lib/taos" + +# Coloured Echoes # +function red_echo { echo -e "\033[31m$@\033[0m"; } # +function green_echo { echo -e "\033[32m$@\033[0m"; } # +function yellow_echo { echo -e "\033[33m$@\033[0m"; } # +function white_echo { echo -e "\033[1;37m$@\033[0m"; } # +# Coloured Printfs # +function red_printf { printf "\033[31m$@\033[0m"; } # +function green_printf { printf "\033[32m$@\033[0m"; } # +function yellow_printf { printf "\033[33m$@\033[0m"; } # +function white_printf { printf "\033[1;37m$@\033[0m"; } # +# Debugging Outputs # +function white_brackets { local args="$@"; white_printf "["; printf "${args}"; white_printf "]"; } # +function echoInfo { local args="$@"; white_brackets $(green_printf "INFO") && echo " ${args}"; } # +function echoWarn { local args="$@"; echo "$(white_brackets "$(yellow_printf "WARN")" && echo " ${args}";)" 1>&2; } # +function echoError { local args="$@"; echo "$(white_brackets "$(red_printf "ERROR")" && echo " ${args}";)" 1>&2; } # + +function restartTaosd { + echo "Stop taosd" + systemctl stop taosd + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + pkill -TERM -x taosd + sleep 1 + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + done + + rm -rf $logDir/* + rm -rf $dataDir/* + + echo "Start taosd" + taosd 2>&1 > /dev/null & + sleep 10 +} + +function runPerfTestVar10K { + echoInfo "Restart Taosd" + restartTaosd + + cd $WORK_DIR/$TSDB_CMP_DIR + ./runTDengine.sh -v 10000 -i 100 -w -q 2>&1 | tee $WORK_DIR/perftest-var10k-int100s-$walPostfix-$today.log +} + +function generatePerfPlotVar10K { + cd $WORK_DIR + + csvLines=`cat perftest-var10k-int100s-$walPostfix-report.csv | wc -l` + + if [ "$csvLines" -gt "10" ]; then + sed -i '1d' perftest-var10k-int100s-$walPostfix-report.csv + fi + + gnuplot -e "filename='perftest-var10k-int100s-$walPostfix-report'" -p perftest-csv2png.gnuplot +} + +today=`date +"%Y%m%d"` +cd $WORK_DIR + +echoInfo "run Performance Test with 10K tables data" +runPerfTestVar10K +echoInfo "Generate plot of 10K tables data" +generatePerfPlotVar10K + +tar czf $WORK_DIR/taos-log-var10k-int100s-$today.tar.gz $logDir/* + +echoInfo "End of TSDB-Compare var10k-int100s-tables-data Test" | tee -a $WORK_DIR/cron.log diff --git a/tests/perftest-scripts/perftest-tsdb-compare-var10k-int10s.sh b/tests/perftest-scripts/perftest-tsdb-compare-var10k-int10s.sh new file mode 100755 index 0000000000000000000000000000000000000000..566479c967320e9bbb8a9e877d26e1bbeb750add --- /dev/null +++ b/tests/perftest-scripts/perftest-tsdb-compare-var10k-int10s.sh @@ -0,0 +1,87 @@ +#!/bin/bash + +WORK_DIR=/mnt/root +TSDB_CMP_DIR=timeseriesdatabase-comparisons/build/tsdbcompare + +walLevel=`grep "^walLevel" /etc/taos/taos.cfg | awk '{print $2}'` +if [[ "$walLevel" -eq "2" ]]; then + walPostfix="wal2" +elif [[ "$walLevel" -eq "1" ]]; then + walPostfix="wal1" +else + echo -e "${RED}wrong walLevel $walLevel found! ${NC}" + exit 1 +fi + +logDir=`grep "^logDir" /etc/taos/taos.cfg | awk '{print $2}'` +dataDir=`grep "^dataDir" /etc/taos/taos.cfg | awk '{print $2}'` + +[ -z "$logDir" ] && logDir="/var/log/taos" +[ -z "$dataDir" ] && dataDir="/var/lib/taos" + +# Coloured Echoes # +function red_echo { echo -e "\033[31m$@\033[0m"; } # +function green_echo { echo -e "\033[32m$@\033[0m"; } # +function yellow_echo { echo -e "\033[33m$@\033[0m"; } # +function white_echo { echo -e "\033[1;37m$@\033[0m"; } # +# Coloured Printfs # +function red_printf { printf "\033[31m$@\033[0m"; } # +function green_printf { printf "\033[32m$@\033[0m"; } # +function yellow_printf { printf "\033[33m$@\033[0m"; } # +function white_printf { printf "\033[1;37m$@\033[0m"; } # +# Debugging Outputs # +function white_brackets { local args="$@"; white_printf "["; printf "${args}"; white_printf "]"; } # +function echoInfo { local args="$@"; white_brackets $(green_printf "INFO") && echo " ${args}"; } # +function echoWarn { local args="$@"; echo "$(white_brackets "$(yellow_printf "WARN")" && echo " ${args}";)" 1>&2; } # +function echoError { local args="$@"; echo "$(white_brackets "$(red_printf "ERROR")" && echo " ${args}";)" 1>&2; } # + +function restartTaosd { + echo "Stop taosd" + systemctl stop taosd + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + pkill -TERM -x taosd + sleep 1 + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + done + + rm -rf $logDir/* + rm -rf $dataDir/* + + echo "Start taosd" + taosd 2>&1 > /dev/null & + sleep 10 +} + +function runPerfTestVar10K { + echoInfo "Restart Taosd" + restartTaosd + + cd $WORK_DIR/$TSDB_CMP_DIR + ./runTDengine.sh -v 10000 -w -q 2>&1 | tee $WORK_DIR/perftest-var10k-int10s-$walPostfix-$today.log +} + +function generatePerfPlotVar10K { + cd $WORK_DIR + + csvLines=`cat perftest-var10k-int10s-$walPostfix-report.csv | wc -l` + + if [ "$csvLines" -gt "10" ]; then + sed -i '1d' perftest-var10k-int10s-$walPostfix-report.csv + fi + + gnuplot -e "filename='perftest-var10k-int10s-$walPostfix-report'" -p perftest-csv2png.gnuplot +} + +today=`date +"%Y%m%d"` +cd $WORK_DIR + +echoInfo "run Performance Test with 10K tables data" +runPerfTestVar10K +echoInfo "Generate plot of 10K tables data" +generatePerfPlotVar10K + +tar czf $WORK_DIR/taos-log-var10k-int10s-$today.tar.gz $logDir/* + +echoInfo "End of TSDB-Compare var10k-int10s-tables-data Test" | tee -a $WORK_DIR/cron.log diff --git a/tests/perftest-scripts/run-csv.sh b/tests/perftest-scripts/run-csv.sh new file mode 100755 index 0000000000000000000000000000000000000000..afa1d5df5de0c9780d65ff12ae680a323851444f --- /dev/null +++ b/tests/perftest-scripts/run-csv.sh @@ -0,0 +1,209 @@ +#!/bin/bash + + +# Color setting +RED='\033[0;31m' +GREEN='\033[1;32m' +GREEN_DARK='\033[0;32m' +GREEN_UNDERLINE='\033[4;32m' +NC='\033[0m' +docker rm -f `docker ps -a -q` +#set -x +echo +echo "---------------Generating Data-----------------" +echo +echo "Prepare data for InfluxDB...." +#bin/bulk_data_gen -seed 123 -format influx-bulk -scale-var 100 -use-case devops -timestamp-start "2018-01-01T00:00:00Z" -timestamp-end "2018-01-02T00:00:00Z" >data/influx.dat +bin/bulk_data_gen -seed 123 -format influx-bulk -sampling-interval 1s -scale-var 10 -use-case devops -timestamp-start "2018-01-01T00:00:00Z" -timestamp-end "2018-01-02T00:00:00Z" >data/influx.dat + +echo +echo "Prepare data for TDengine...." +#bin/bulk_data_gen -seed 123 -format tdengine -tdschema-file config/TDengineSchema.toml -scale-var 100 -use-case devops -timestamp-start "2018-01-01T00:00:00Z" -timestamp-end "2018-01-02T00:00:00Z" > data/tdengine.dat +bin/bulk_data_gen -seed 123 -format tdengine -sampling-interval 1s -tdschema-file config/TDengineSchema.toml -scale-var 10 -use-case devops -timestamp-start "2018-01-01T00:00:00Z" -timestamp-end "2018-01-02T00:00:00Z" > data/tdengine.dat + + + +docker network create --ip-range 172.15.1.255/24 --subnet 172.15.1.1/16 tsdbcomp >>/dev/null 2>&1 + + +TDENGINE=`docker run -d --net tsdbcomp --ip 172.15.1.6 -p 6030:6030 -p 6020:6020 -p 6031:6031 -p 6032:6032 -p 6033:6033 -p 6034:6034 -p 6035:6035 -p 6036:6036 -p 6037:6037 -p 6038:6038 -p 6039:6039 tdengine/tdengine:1.6.4.5` +echo +echo "------------------Writing Data-----------------" +echo +sleep 5 +echo +echo -e "Start test TDengine, result in ${GREEN}Green line${NC}" + +TDENGINERES=`cat data/tdengine.dat |bin/bulk_load_tdengine --url 172.15.1.6:0 --batch-size 300 -do-load -report-tags n1 -workers 20 -fileout=false| grep loaded` +#TDENGINERES=`cat data/tdengine.dat |gunzip|bin/bulk_load_tdengine --url 172.15.1.6:0 --batch-size 300 -do-load -report-tags n1 -workers 10 -fileout=false| grep loaded` +echo +echo -e "${GREEN}TDengine writing result:${NC}" +echo -e "${GREEN}$TDENGINERES${NC}" +DATA=`echo $TDENGINERES|awk '{print($2)}'` +TMP=`echo $TDENGINERES|awk '{print($5)}'` +TDWTM=`echo ${TMP%s*}` + + +INFLUX=`docker run -d -p 8086:8086 --net tsdbcomp --ip 172.15.1.5 influxdb` >>/dev/null 2>&1 +sleep 10 +echo +echo -e "Start test InfluxDB, result in ${GREEN}Green line${NC}" + + +INFLUXRES=`cat data/influx.dat |bin/bulk_load_influx --batch-size=5000 --workers=20 --urls="http://172.15.1.5:8086" | grep loaded` + + +echo +echo -e "${GREEN}InfluxDB writing result:${NC}" +echo -e "${GREEN}$INFLUXRES${NC}" + +TMP=`echo $INFLUXRES|awk '{print($5)}'` +IFWTM=`echo ${TMP%s*}` + +echo +echo "------------------Querying Data-----------------" +echo + +sleep 10 +echo +echo "start query test, query max from 8 hosts group by 1 hour, TDengine" +echo + +#Test case 1 +#测试用例1,查询所有数据中,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据的最大值。 +#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') ; +# a,b,c,d,e,f,g,h are random 8 numbers. +TDQS1=`bin/bulk_query_gen -seed 123 -format tdengine -query-type 8-host-all -scale-var 10 -queries 1000 | bin/query_benchmarker_tdengine -urls="http://172.15.1.6:6020" -workers 50 -print-interval 0|grep wall` +echo +echo -e "${GREEN}TDengine query test case 1 result:${NC}" +echo -e "${GREEN}$TDQS1${NC}" +TMP=`echo $TDQS1|awk '{print($4)}'` +TDQ1=`echo ${TMP%s*}` + +#Test case 2 +#测试用例2,查询所有数据中,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据,以1小时为粒度,查询每1小时的最大值。 +#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') interval(1h); +# a,b,c,d,e,f,g,h are random 8 numbers +TDQS2=`bin/bulk_query_gen -seed 123 -format tdengine -query-type 8-host-allbyhr -scale-var 10 -queries 1000 | bin/query_benchmarker_tdengine -urls="http://172.15.1.6:6020" -workers 50 -print-interval 0|grep wall` + +echo +echo -e "${GREEN}TDengine query test case 2 result:${NC}" +echo -e "${GREEN}$TDQS2${NC}" +TMP=`echo $TDQS2|awk '{print($4)}'` +TDQ2=`echo ${TMP%s*}` + +#Test case 3 +#测试用例3,测试用例3,随机查询12个小时的数据,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据,以10分钟为粒度,查询每10分钟的最大值 +#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') and time >x and time x and time x and time x and time >/dev/null 2>&1 +docker container rm -f $INFLUX >>/dev/null 2>&1 +docker stop $TDENGINE >>/dev/null 2>&1 +docker container rm -f $TDENGINE >>/dev/null 2>&1 +docker network rm tsdbcomp >>/dev/null 2>&1 +#bulk_query_gen/bulk_query_gen -format influx-http -query-type 1-host-1-hr -scale-var 10 -queries 1000 | query_benchmarker_influxdb/query_benchmarker_influxdb -urls="http://172.26.89.231:8086" +#bulk_query_gen/bulk_query_gen -format tdengine -query-type 1-host-1-hr -scale-var 10 -queries 1000 | query_benchmarker_tdengine/query_benchmarker_tdengine -urls="http://172.26.89.231:6020" + + +today=`date +"%Y%m%d"` +echo "${today}, ${IFWTM}, ${IFQ1}, ${IFQ2}, ${IFQ3}, ${IFQ4}" >> /root/perftest-influx-report.csv + diff --git a/tests/perftest-scripts/runInfluxdb-13d-csv.sh b/tests/perftest-scripts/runInfluxdb-13d-csv.sh new file mode 100755 index 0000000000000000000000000000000000000000..2eb36068688e8e180165c487bdeacbba9a9e7b73 --- /dev/null +++ b/tests/perftest-scripts/runInfluxdb-13d-csv.sh @@ -0,0 +1,126 @@ +#!/bin/bash + + +# Color setting +RED='\033[0;31m' +GREEN='\033[1;32m' +GREEN_DARK='\033[0;32m' +GREEN_UNDERLINE='\033[4;32m' +NC='\033[0m' +docker rm -f `docker ps -a -q` +#set -x +echo +echo "---------------Generating Data-----------------" +echo +echo "Prepare data for InfluxDB...." +#bin/bulk_data_gen -seed 123 -format influx-bulk -scale-var 100 -use-case devops -timestamp-start "2018-01-01T00:00:00Z" -timestamp-end "2018-01-02T00:00:00Z" >data/influx.dat +bin/bulk_data_gen -seed 123 -format influx-bulk -sampling-interval 1s -scale-var 10 -use-case devops -timestamp-start "2018-01-02T00:00:00Z" -timestamp-end "2018-01-15T00:00:00Z" > /mnt/data/influx.dat + +docker network create --ip-range 172.15.1.255/24 --subnet 172.15.1.1/16 tsdbcomp >>/dev/null 2>&1 + +INFLUX=`docker run -d -p 8086:8086 --net tsdbcomp --ip 172.15.1.5 influxdb` >>/dev/null 2>&1 +sleep 10 +echo +echo -e "Start test InfluxDB, result in ${GREEN}Green line${NC}" + + +INFLUXRES=`cat /mnt/data/influx.dat |bin/bulk_load_influx --batch-size=5000 --workers=20 --urls="http://172.15.1.5:8086" | grep loaded` + + +echo +echo -e "${GREEN}InfluxDB writing result:${NC}" +echo -e "${GREEN}$INFLUXRES${NC}" +DATA=`echo $INFLUXRES|awk '{print($2)}'` +TMP=`echo $INFLUXRES|awk '{print($5)}'` +IFWTM=`echo ${TMP%s*}` + +echo +echo "------------------Querying Data-----------------" +echo + +sleep 10 + +echo +echo "start query test, query max from 8 hosts group by 1hour, Influxdb" +echo +#Test case 1 +#测试用例1,查询所有数据中,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据的最大值。 +#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') ; +# a,b,c,d,e,f,g,h are random 8 numbers. +IFQS1=`bin/bulk_query_gen -seed 123 -format influx-http -query-type 8-host-all -scale-var 10 -queries 1000 | bin/query_benchmarker_influxdb -urls="http://172.15.1.5:8086" -workers 50 -print-interval 0|grep wall` +echo -e "${GREEN}InfluxDB query test case 1 result:${NC}" +echo -e "${GREEN}$IFQS1${NC}" +TMP=`echo $IFQS1|awk '{print($4)}'` +IFQ1=`echo ${TMP%s*}` +#Test case 2 +#测试用例2,查询所有数据中,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据,以1小时为粒度,查询每1小时的最大值。 +#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') interval(1h); +# a,b,c,d,e,f,g,h are random 8 numbers +IFQS2=`bin/bulk_query_gen -seed 123 -format influx-http -query-type 8-host-allbyhr -scale-var 10 -queries 1000 | bin/query_benchmarker_influxdb -urls="http://172.15.1.5:8086" -workers 50 -print-interval 0|grep wall` +echo -e "${GREEN}InfluxDB query test case 2 result:${NC}" +echo -e "${GREEN}$IFQS2${NC}" +TMP=`echo $IFQS2|awk '{print($4)}'` +IFQ2=`echo ${TMP%s*}` +#Test case 3 +#测试用例3,测试用例3,随机查询12个小时的数据,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据,以10分钟为粒度,查询每10分钟的最大值 +#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') and time >x and time x and time > /root/perftest-influxdb-report-13d.csv + +docker stop $INFLUX >>/dev/null 2>&1 +docker container rm -f $INFLUX >>/dev/null 2>&1 +docker network rm tsdbcomp >>/dev/null 2>&1 +#bulk_query_gen/bulk_query_gen -format influx-http -query-type 1-host-1-hr -scale-var 10 -queries 1000 | query_benchmarker_influxdb/query_benchmarker_influxdb -urls="http://172.26.89.231:8086" +#bulk_query_gen/bulk_query_gen -format tdengine -query-type 1-host-1-hr -scale-var 10 -queries 1000 | query_benchmarker_tdengine/query_benchmarker_tdengine -urls="http://172.26.89.231:6020" + diff --git a/tests/perftest-scripts/runInfluxdb.sh b/tests/perftest-scripts/runInfluxdb.sh new file mode 100755 index 0000000000000000000000000000000000000000..e8975b05cf43671c174fb95942da89ef8ae4631b --- /dev/null +++ b/tests/perftest-scripts/runInfluxdb.sh @@ -0,0 +1,251 @@ +#!/bin/bash +#set -x + +WORK_DIR=/mnt/root +DATA_DIR=/mnt/data + +# Color setting +RED='\033[0;31m' +GREEN='\033[1;32m' +GREEN_DARK='\033[0;32m' +GREEN_UNDERLINE='\033[4;32m' +NC='\033[0m' + +# default value +DEFAULT_BATCH=5000 +DEFAULT_DAYS=1 +DEFAULT_INTERVAL=1 +DEFAULT_SCALEVAR=10 +DEFAULT_DOPREPARE=false +DEFAULT_DOWRITE=false +DEFAULT_DOQUERY=false + +# function +function do_prepare { + echo + echo "---------------Generating Data-----------------" + echo + + echo + echo "Prepare data for InfluxDB...." + + echo "bin/bulk_data_gen -seed 123 -format influx-bulk -sampling-interval $interval_s \ + -scale-var $scalevar -use-case devops -timestamp-start $TIME_START \ + -timestamp-end $TIME_END > $DATA_FILE" + + bin/bulk_data_gen -seed 123 -format influx-bulk -sampling-interval $interval_s \ + -scale-var $scalevar -use-case devops -timestamp-start $TIME_START \ + -timestamp-end $TIME_END > $DATA_FILE +} + +function do_write { + echo "cat $DATA_FILE | bin/bulk_load_influx \ + --batch-size=$batch --workers=20 --urls=http://172.15.1.5:8086 | grep loaded" + INFLUXRES=`cat $DATA_FILE | bin/bulk_load_influx \ + --batch-size=$batch --workers=20 --urls="http://172.15.1.5:8086" | grep loaded` + + echo -e "${GREEN}InfluxDB writing result:${NC}" + echo -e "${GREEN}$INFLUXRES${NC}" + DATA=`echo $INFLUXRES|awk '{print($2)}'` + TMP=`echo $INFLUXRES|awk '{print($5)}'` + IFWTM=`echo ${TMP%s*}` +} + +function do_query { + + echo + echo "------------------Querying Data-----------------" + echo + + echo + echo "start query test, query max from 8 hosts group by 1 hour, InfluxDB" + echo + +#Test case 1 +#测试用例1,查询所有数据中,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据的最大值。 +#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') ; +# a,b,c,d,e,f,g,h are random 8 numbers. + echo "IFQS1=bin/bulk_query_gen -seed 123 -format influx-http -query-type 8-host-all -scale-var $scalevar -queries 1000 | bin/query_benchmarker_influxdb -urls="http://172.15.1.5:8086" -workers 50 -print-interval 0|grep wall" + + IFQS1=`bin/bulk_query_gen -seed 123 -format influx-http -query-type 8-host-all -scale-var $scalevar -queries 1000 | bin/query_benchmarker_influxdb -urls="http://172.15.1.5:8086" -workers 50 -print-interval 0|grep wall` + echo -e "${GREEN}InfluxDB query test case 1 result:${NC}" + echo -e "${GREEN}$IFQS1${NC}" + TMP=`echo $IFQS1|awk '{print($4)}'` + IFQ1=`echo ${TMP%s*}` + +#Test case 2 +#测试用例2,查询所有数据中,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据,以1小时为粒度,查询每1小时的最大值。 +#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') interval(1h); +# a,b,c,d,e,f,g,h are random 8 numbers + echo "IFQS2=bin/bulk_query_gen -seed 123 -format influx-http -query-type 8-host-allbyhr -scale-var $scalevar -queries 1000 | bin/query_benchmarker_influxdb -urls=http://172.15.1.5:8086 -workers 50 -print-interval 0|grep wall" + + IFQS2=`bin/bulk_query_gen -seed 123 -format influx-http -query-type 8-host-allbyhr \ + -scale-var $scalevar -queries 1000 | bin/query_benchmarker_influxdb \ + -urls="http://172.15.1.5:8086" -workers 50 -print-interval 0|grep wall` + echo -e "${GREEN}InfluxDB query test case 2 result:${NC}" + echo -e "${GREEN}$IFQS2${NC}" + TMP=`echo $IFQS2|awk '{print($4)}'` + IFQ2=`echo ${TMP%s*}` + +#Test case 3 +#测试用例3,测试用例3,随机查询12个小时的数据,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据,以10分钟为粒度,查询每10分钟的最大值 +#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') and time >x and time x and time >/dev/null 2>&1 +INFLUX=`docker run -d -p 8086:8086 --net tsdbcomp --ip 172.15.1.5 influxdb` >>/dev/null 2>&1 +sleep 10 + +if $dowrite; +then + echo -e "Start test InfluxDB writting, result in ${GREEN}Green line${NC}" + do_write +fi + +if $doquery; +then + echo -e "Start test InfluxDB query, result in ${GREEN}Green line${NC}" + do_query +fi + +echo +echo +echo "======================================================" +echo " tsdb performance comparision " +echo "======================================================" +if $dowrite; +then + echo -e " Writing $DATA records test takes: " + printf " InfluxDB | %-4.5f Seconds \n" $IFWTM + echo "------------------------------------------------------" +fi + +if $doquery; +then + echo " Query test cases: " + echo " case 1: select the max(value) from all data " + echo " filtered out 8 hosts " + echo " Query test case 1 takes: " + printf " InfluxDB | %-4.5f Seconds \n" $IFQ1 + echo "------------------------------------------------------" + echo " case 2: select the max(value) from all data " + echo " filtered out 8 hosts with an interval of 1 hour " + echo " case 2 takes: " + printf " InfluxDB | %-4.5f Seconds \n" $IFQ2 + echo "------------------------------------------------------" + echo " case 3: select the max(value) from random 12 hours" + echo " data filtered out 8 hosts with an interval of 10 min " + echo " filtered out 8 hosts interval(1h) " + echo " case 3 takes: " + printf " InfluxDB | %-4.5f Seconds \n" $IFQ3 + echo "------------------------------------------------------" + echo " case 4: select the max(value) from random 1 hour data " + echo " data filtered out 8 hosts with an interval of 1 min " + echo " case 4 takes: " + printf " InfluxDB | %-4.5f Seconds \n" $IFQ4 + echo "------------------------------------------------------" +fi + +docker stop $INFLUX >>/dev/null 2>&1 +docker container rm -f $INFLUX >>/dev/null 2>&1 +docker network rm tsdbcomp >>/dev/null 2>&1 + +today=`date +"%Y%m%d"` +echo "${today}, ${IFWTM}, ${IFQ1}, ${IFQ2}, ${IFQ3}, ${IFQ4}" >> $RECORD_CSV_FILE diff --git a/tests/perftest-scripts/runTDengine.sh b/tests/perftest-scripts/runTDengine.sh new file mode 100755 index 0000000000000000000000000000000000000000..6c5cf4e55ecb263501e90a91866d14289de9184b --- /dev/null +++ b/tests/perftest-scripts/runTDengine.sh @@ -0,0 +1,283 @@ +#!/bin/bash +#set -x + +WORK_DIR=/mnt/root +DATA_DIR=/mnt/data + +# Color setting +RED='\033[0;31m' +GREEN='\033[1;32m' +GREEN_DARK='\033[0;32m' +GREEN_UNDERLINE='\033[4;32m' +NC='\033[0m' + +# default value +DEFAULT_BATCH=5000 +DEFAULT_DAYS=1 +DEFAULT_INTERVAL=1 +DEFAULT_SCALEVAR=10 +DEFAULT_DOPREPARE=false +DEFAULT_DOWRITE=false +DEFAULT_DOQUERY=false + +# function +function do_prepare { + echo + echo "---------------Generating Data-----------------" + echo + + echo + echo "Prepare data for TDengine...." + + # bin/bulk_data_gen -seed 123 -format tdengine -tdschema-file config/TDengineSchema.toml -scale-var 100 -use-case devops -timestamp-start "2018-01-01T00:00:00Z" -timestamp-end "2018-01-02T00:00:00Z" > $DATA_DIR/tdengine.dat + echo "bin/bulk_data_gen -seed 123 -format tdengine -sampling-interval $interval_s \ + -tdschema-file config/TDengineSchema.toml -scale-var $scalevar \ + -use-case devops -timestamp-start $TIME_START \ + -timestamp-end $TIME_END \ + > $DATA_FILE" + + bin/bulk_data_gen -seed 123 -format tdengine -sampling-interval $interval_s \ + -tdschema-file config/TDengineSchema.toml -scale-var $scalevar \ + -use-case devops -timestamp-start $TIME_START \ + -timestamp-end $TIME_END \ + > $DATA_FILE +} + +function do_write { + echo "TDENGINERES=cat $DATA_FILE |bin/bulk_load_tdengine --url 127.0.0.1:0 \ + --batch-size $batch -do-load -report-tags n1 -workers 20 -fileout=false| grep loaded" + + TDENGINERES=`cat $DATA_FILE |bin/bulk_load_tdengine --url 127.0.0.1:0 \ + --batch-size $batch -do-load -report-tags n1 -workers 20 -fileout=false| grep loaded` + + echo + echo -e "${GREEN}TDengine writing result:${NC}" + echo -e "${GREEN}$TDENGINERES${NC}" + DATA=`echo $TDENGINERES|awk '{print($2)}'` + TMP=`echo $TDENGINERES|awk '{print($5)}'` + TDWTM=`echo ${TMP%s*}` + +} + +function do_query { + + echo + echo "------------------Querying Data-----------------" + echo + + echo + echo "start query test, query max from 8 hosts group by 1 hour, TDengine" + echo + +#Test case 1 +#测试用例1,查询所有数据中,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据的最大值。 +#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') ; +# a,b,c,d,e,f,g,h are random 8 numbers. + echo "TDQS1=bin/bulk_query_gen -seed 123 -format tdengine -query-type 8-host-all \ + -scale-var $scalevar -queries 1000 | bin/query_benchmarker_tdengine \ + -urls=http://127.0.0.1:6020 -workers 50 -print-interval 0|grep wall" + + TDQS1=`bin/bulk_query_gen -seed 123 -format tdengine -query-type 8-host-all \ + -scale-var $scalevar -queries 1000 | bin/query_benchmarker_tdengine \ + -urls="http://127.0.0.1:6020" -workers 50 -print-interval 0|grep wall` + echo + echo -e "${GREEN}TDengine query test case 1 result:${NC}" + echo -e "${GREEN}$TDQS1${NC}" + TMP=`echo $TDQS1|awk '{print($4)}'` + TDQ1=`echo ${TMP%s*}` + +#Test case 2 +#测试用例2,查询所有数据中,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据,以1小时为粒度,查询每1小时的最大值。 +#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') interval(1h); +# a,b,c,d,e,f,g,h are random 8 numbers + echo "TDQS2=bin/bulk_query_gen -seed 123 -format tdengine -query-type 8-host-allbyhr \ + -scale-var $scalevar -queries 1000 | bin/query_benchmarker_tdengine \ + -urls=http://127.0.0.1:6020 -workers 50 -print-interval 0|grep wall" + + TDQS2=`bin/bulk_query_gen -seed 123 -format tdengine -query-type 8-host-allbyhr \ + -scale-var $scalevar -queries 1000 | bin/query_benchmarker_tdengine \ + -urls="http://127.0.0.1:6020" -workers 50 -print-interval 0|grep wall` + + echo + echo -e "${GREEN}TDengine query test case 2 result:${NC}" + echo -e "${GREEN}$TDQS2${NC}" + TMP=`echo $TDQS2|awk '{print($4)}'` + TDQ2=`echo ${TMP%s*}` + +#Test case 3 +#测试用例3,测试用例3,随机查询12个小时的数据,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据,以10分钟为粒度,查询每10分钟的最大值 +#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') and time >x and time x and time > $RECORD_CSV_FILE diff --git a/tests/perftest-scripts/runreal-13d-csv.sh b/tests/perftest-scripts/runreal-13d-csv.sh new file mode 100755 index 0000000000000000000000000000000000000000..48ef01e6a08b37e9bceb2bb599f7ded6bee2dcd1 --- /dev/null +++ b/tests/perftest-scripts/runreal-13d-csv.sh @@ -0,0 +1,149 @@ +#!/bin/bash + + +# Color setting +RED='\033[0;31m' +GREEN='\033[1;32m' +GREEN_DARK='\033[0;32m' +GREEN_UNDERLINE='\033[4;32m' +NC='\033[0m' +#set -x +echo +echo "---------------Generating Data-----------------" +echo + +echo +echo "Prepare data for TDengine...." +#bin/bulk_data_gen -seed 123 -format tdengine -tdschema-file config/TDengineSchema.toml -scale-var 100 -use-case devops -timestamp-start "2018-01-01T00:00:00Z" -timestamp-end "2018-01-02T00:00:00Z" > data/tdengine.dat +bin/bulk_data_gen -seed 123 -format tdengine -sampling-interval 1s -tdschema-file config/TDengineSchema.toml -scale-var 10 -use-case devops -timestamp-start "2018-01-01T00:00:00Z" -timestamp-end "2018-01-14T00:00:00Z" > /mnt/data/tdengine.dat + + +echo +echo -e "Start test TDengine, result in ${GREEN}Green line${NC}" + +for i in {1..5}; do + TDENGINERES=`cat /mnt/data/tdengine.dat |bin/bulk_load_tdengine --url 127.0.0.1:0 --batch-size 5000 -do-load -report-tags n1 -workers 20 -fileout=false| grep loaded` +#TDENGINERES=`cat data/tdengine.dat |gunzip|bin/bulk_load_tdengine --url 127.0.0.1:0 --batch-size 300 -do-load -report-tags n1 -workers 10 -fileout=false| grep loaded` + echo + echo -e "${GREEN}TDengine writing result:${NC}" + echo -e "${GREEN}$TDENGINERES${NC}" + DATA=`echo $TDENGINERES|awk '{print($2)}'` + TMP=`echo $TDENGINERES|awk '{print($5)}'` + TDWTM=`echo ${TMP%s*}` + + [ -z "$TDWTM" ] || break +done + + + +echo +echo "------------------Querying Data-----------------" +echo + +sleep 10 +echo +echo "start query test, query max from 8 hosts group by 1 hour, TDengine" +echo + +#Test case 1 +#测试用例1,查询所有数据中,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据的最大值。 +#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') ; +# a,b,c,d,e,f,g,h are random 8 numbers. +for i in {1..5}; do + TDQS1=`bin/bulk_query_gen -seed 123 -format tdengine -query-type 8-host-all -scale-var 10 -queries 1000 | bin/query_benchmarker_tdengine -urls="http://127.0.0.1:6020" -workers 50 -print-interval 0|grep wall` + echo + echo -e "${GREEN}TDengine query test case 1 result:${NC}" + echo -e "${GREEN}$TDQS1${NC}" + TMP=`echo $TDQS1|awk '{print($4)}'` + TDQ1=`echo ${TMP%s*}` + + [ -z "$TDQ1" ] || break +done + +#Test case 2 +#测试用例2,查询所有数据中,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据,以1小时为粒度,查询每1小时的最大值。 +#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') interval(1h); +# a,b,c,d,e,f,g,h are random 8 numbers +for i in {1..5}; do + TDQS2=`bin/bulk_query_gen -seed 123 -format tdengine -query-type 8-host-allbyhr -scale-var 10 -queries 1000 | bin/query_benchmarker_tdengine -urls="http://127.0.0.1:6020" -workers 50 -print-interval 0|grep wall` + + echo + echo -e "${GREEN}TDengine query test case 2 result:${NC}" + echo -e "${GREEN}$TDQS2${NC}" + TMP=`echo $TDQS2|awk '{print($4)}'` + TDQ2=`echo ${TMP%s*}` + + [ -z "$TDQ2" ] || break +done + +#Test case 3 +#测试用例3,测试用例3,随机查询12个小时的数据,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据,以10分钟为粒度,查询每10分钟的最大值 +#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') and time >x and time x and time > /root/perftest-13d-$1-report.csv + +#bulk_query_gen/bulk_query_gen -format influx-http -query-type 1-host-1-hr -scale-var 10 -queries 1000 | query_benchmarker_influxdb/query_benchmarker_influxdb -urls="http://172.26.89.231:8086" +#bulk_query_gen/bulk_query_gen -format tdengine -query-type 1-host-1-hr -scale-var 10 -queries 1000 | query_benchmarker_tdengine/query_benchmarker_tdengine -urls="http://172.26.89.231:6020" diff --git a/tests/perftest-scripts/runreal-1d-csv.sh b/tests/perftest-scripts/runreal-1d-csv.sh new file mode 100755 index 0000000000000000000000000000000000000000..20c8b4138c5625e816cbe08a368d9f5fc7fc67dc --- /dev/null +++ b/tests/perftest-scripts/runreal-1d-csv.sh @@ -0,0 +1,149 @@ +#!/bin/bash + + +# Color setting +RED='\033[0;31m' +GREEN='\033[1;32m' +GREEN_DARK='\033[0;32m' +GREEN_UNDERLINE='\033[4;32m' +NC='\033[0m' +#set -x +echo +echo "---------------Generating Data-----------------" +echo + +echo +echo "Prepare data for TDengine...." +#bin/bulk_data_gen -seed 123 -format tdengine -tdschema-file config/TDengineSchema.toml -scale-var 100 -use-case devops -timestamp-start "2018-01-01T00:00:00Z" -timestamp-end "2018-01-02T00:00:00Z" > data/tdengine.dat +bin/bulk_data_gen -seed 123 -format tdengine -sampling-interval 1s -tdschema-file config/TDengineSchema.toml -scale-var 10 -use-case devops -timestamp-start "2018-01-01T00:00:00Z" -timestamp-end "2018-01-02T00:00:00Z" > data/tdengine.dat + + +echo +echo -e "Start test TDengine, result in ${GREEN}Green line${NC}" + +for i in {1..5}; do + TDENGINERES=`cat data/tdengine.dat |bin/bulk_load_tdengine --url 127.0.0.1:0 --batch-size 300 -do-load -report-tags n1 -workers 20 -fileout=false| grep loaded` +#TDENGINERES=`cat data/tdengine.dat |gunzip|bin/bulk_load_tdengine --url 127.0.0.1:0 --batch-size 300 -do-load -report-tags n1 -workers 10 -fileout=false| grep loaded` + echo + echo -e "${GREEN}TDengine writing result:${NC}" + echo -e "${GREEN}$TDENGINERES${NC}" + DATA=`echo $TDENGINERES|awk '{print($2)}'` + TMP=`echo $TDENGINERES|awk '{print($5)}'` + TDWTM=`echo ${TMP%s*}` + + [ -z "$TDWTM" ] || break +done + + + +echo +echo "------------------Querying Data-----------------" +echo + +sleep 10 +echo +echo "start query test, query max from 8 hosts group by 1 hour, TDengine" +echo + +#Test case 1 +#测试用例1,查询所有数据中,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据的最大值。 +#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') ; +# a,b,c,d,e,f,g,h are random 8 numbers. +for i in {1..5}; do + TDQS1=`bin/bulk_query_gen -seed 123 -format tdengine -query-type 8-host-all -scale-var 10 -queries 1000 | bin/query_benchmarker_tdengine -urls="http://127.0.0.1:6020" -workers 50 -print-interval 0|grep wall` + echo + echo -e "${GREEN}TDengine query test case 1 result:${NC}" + echo -e "${GREEN}$TDQS1${NC}" + TMP=`echo $TDQS1|awk '{print($4)}'` + TDQ1=`echo ${TMP%s*}` + + [ -z "$TDQ1" ] || break +done + +#Test case 2 +#测试用例2,查询所有数据中,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据,以1小时为粒度,查询每1小时的最大值。 +#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') interval(1h); +# a,b,c,d,e,f,g,h are random 8 numbers +for i in {1..5}; do + TDQS2=`bin/bulk_query_gen -seed 123 -format tdengine -query-type 8-host-allbyhr -scale-var 10 -queries 1000 | bin/query_benchmarker_tdengine -urls="http://127.0.0.1:6020" -workers 50 -print-interval 0|grep wall` + + echo + echo -e "${GREEN}TDengine query test case 2 result:${NC}" + echo -e "${GREEN}$TDQS2${NC}" + TMP=`echo $TDQS2|awk '{print($4)}'` + TDQ2=`echo ${TMP%s*}` + + [ -z "$TDQ2" ] || break +done + +#Test case 3 +#测试用例3,测试用例3,随机查询12个小时的数据,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据,以10分钟为粒度,查询每10分钟的最大值 +#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') and time >x and time x and time > /root/perftest-1d-$1-report.csv + +#bulk_query_gen/bulk_query_gen -format influx-http -query-type 1-host-1-hr -scale-var 10 -queries 1000 | query_benchmarker_influxdb/query_benchmarker_influxdb -urls="http://172.26.89.231:8086" +#bulk_query_gen/bulk_query_gen -format tdengine -query-type 1-host-1-hr -scale-var 10 -queries 1000 | query_benchmarker_tdengine/query_benchmarker_tdengine -urls="http://172.26.89.231:6020" diff --git a/tests/perftest-scripts/taosdemo-csv2png.gnuplot b/tests/perftest-scripts/taosdemo-csv2png.gnuplot new file mode 100644 index 0000000000000000000000000000000000000000..7cdcb84fce7cdf52dd223e1af6f6d68a46b13893 --- /dev/null +++ b/tests/perftest-scripts/taosdemo-csv2png.gnuplot @@ -0,0 +1,26 @@ +#!/user/bin/gnuplot +reset +set terminal png + +set title filename font ",20" + +set ylabel "Time in Seconds" + +set xdata time +set timefmt "%Y%m%d" +set format x "%Y-%m-%d" +set xlabel "Date" + +set style data linespoints + +set terminal pngcairo size 1024,768 enhanced font 'Segoe UI, 10' +set output filename . '.png' +set datafile separator ',' + +set key reverse Left outside +set grid + + +plot filename . '.csv' using 1:2 title "Create 10,000 Tables", \ + "" using 1:3 title "Delete 10,000 Tables", \ + "" using 1:4 title "Create 10,000 Tables and Insert 100,000 records" diff --git a/tests/perftest-scripts/taosdemo-rps-csv2png.gnuplot b/tests/perftest-scripts/taosdemo-rps-csv2png.gnuplot new file mode 100644 index 0000000000000000000000000000000000000000..a7fcb4bd43b17a03f92a432446971412dcfcc54c --- /dev/null +++ b/tests/perftest-scripts/taosdemo-rps-csv2png.gnuplot @@ -0,0 +1,24 @@ +#!/user/bin/gnuplot +reset +set terminal png + +set title filename font ",20" + +set ylabel "Time in Seconds" + +set xdata time +set timefmt "%Y%m%d" +set format x "%Y-%m-%d" +set xlabel "Date" + +set style data linespoints + +set terminal pngcairo size 1024,768 enhanced font 'Segoe UI, 10' +set output filename . '.png' +set datafile separator ',' + +set key reverse Left outside +set grid + + +plot filename . '.csv' using 1:2 title "Request Per Second" diff --git a/tests/perftest-scripts/tdengineTestQ1Loop.sh b/tests/perftest-scripts/tdengineTestQ1Loop.sh new file mode 100755 index 0000000000000000000000000000000000000000..fb2810b00e194bf4d232f19fb353bbad02261ac9 --- /dev/null +++ b/tests/perftest-scripts/tdengineTestQ1Loop.sh @@ -0,0 +1,127 @@ +#!/bin/bash + +DATA_DIR=/mnt/root/testdata +NUM_LOOP=5 + +function printTo { + if $verbose ; then + echo $1 + fi +} + +TDTESTQ1OUT=tdengineTestQ1.out + +function runTest { + totalG0=0 + totalG10=0 + totalG20=0 + totalG30=0 + totalG40=0 + totalG50=0 + totalG60=0 + totalG70=0 + totalG80=0 + totalG90=0 + for i in `seq 1 $NUM_LOOP`; do + printTo "loop i:$i, $TDTEST_DIR/tdengineTest \ + -sql q1.txt" + restartTaosd + $TDTEST_DIR/tdengineTest \ + -sql $TDTEST_DIR/q1.txt > $TDTESTQ1OUT + G0=`grep "devgroup=0" $TDTESTQ1OUT| awk '{print $3}'` + totalG0=`echo "scale=4; $totalG0 + $G0" | bc` + printTo "i: $i, G0: $G0, totalG0:$totalG0" + G10=`grep "devgroup=10" $TDTESTQ1OUT| awk '{print $3}'` + totalG10=`echo "scale=4; $totalG10 + $G10" | bc` + printTo "i: $i, G10: $G10, totalG10:$totalG10" + G20=`grep "devgroup=20" $TDTESTQ1OUT| awk '{print $3}'` + totalG20=`echo "scale=4; $totalG20 + $G20" | bc` + G30=`grep "devgroup=30" $TDTESTQ1OUT| awk '{print $3}'` + totalG30=`echo "scale=4; $totalG30 + $G30" | bc` + G40=`grep "devgroup=40" $TDTESTQ1OUT| awk '{print $3}'` + totalG40=`echo "scale=4; $totalG40 + $G40" | bc` + G50=`grep "devgroup=50" $TDTESTQ1OUT| awk '{print $3}'` + totalG50=`echo "scale=4; $totalG50 + $G50" | bc` + G60=`grep "devgroup=60" $TDTESTQ1OUT| awk '{print $3}'` + totalG60=`echo "scale=4; $totalG60 + $G60" | bc` + G70=`grep "devgroup=70" $TDTESTQ1OUT| awk '{print $3}'` + totalG70=`echo "scale=4; $totalG70 + $G70" | bc` + G80=`grep "devgroup=80" $TDTESTQ1OUT| awk '{print $3}'` + totalG80=`echo "scale=4; $totalG80 + $G80" | bc` + G90=`grep "devgroup=90" $TDTESTQ1OUT| awk '{print $3}'` + totalG90=`echo "scale=4; $totalG90 + $G90" | bc` + printTo "i: $i, G90: $G90, totalG90:$totalG90" + done + avgG0=`echo "scale=4; x = $totalG0 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG10=`echo "scale=4; x = $totalG10 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG20=`echo "scale=4; x = $totalG20 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG30=`echo "scale=4; x = $totalG30 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG40=`echo "scale=4; x = $totalG40 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG50=`echo "scale=4; x = $totalG50 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG60=`echo "scale=4; x = $totalG60 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG70=`echo "scale=4; x = $totalG70 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG80=`echo "scale=4; x = $totalG80 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG90=`echo "scale=4; x = $totalG90 / $NUM_LOOP; if(x<1) print 0; x" | bc` + echo "Latency, G-0, G-10, G-20, G-30, G-40, G-50, G-60, G-70, G-80, G-90" + echo "TDengine, $avgG0, $avgG10, $avgG20, $avgG30, $avgG40, $avgG50, $avgG60, $avgG70, $avgG80, $avgG90" +} + +function restartTaosd { + printTo "Stop taosd" + systemctl stop taosd + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + pkill -TERM -x taosd + sleep 1 + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + done + + printTo "Start taosd" + $TAOSD_DIR/taosd > /dev/null 2>&1 & + sleep 10 +} + +################ Main ################ + +master=false +develop=true +verbose=false + +for arg in "$@" +do + case $arg in + -v) + verbose=true + ;; + + master) + master=true + develop=false + ;; + + develop) + master=false + develop=true + ;; + *) + ;; + esac +done + +if $master ; then + echo "Test master branch.." + cp /mnt/root/cfg/master/taos.cfg /etc/taos/taos.cfg + WORK_DIR=/mnt/root/TDengine.master +else + echo "Test develop branch.." + cp /mnt/root/cfg/10billion/taos.cfg /etc/taos/taos.cfg + WORK_DIR=/mnt/root/TDengine +fi + +TAOSD_DIR=$WORK_DIR/debug/build/bin +TDTEST_DIR=$WORK_DIR/tests/comparisonTest/tdengine + +runTest + +echo "Test done!" diff --git a/tests/perftest-scripts/tdengineTestQ2Loop.sh b/tests/perftest-scripts/tdengineTestQ2Loop.sh new file mode 100755 index 0000000000000000000000000000000000000000..ede9d98f98ab974c6a763bd33f139a136edb6206 --- /dev/null +++ b/tests/perftest-scripts/tdengineTestQ2Loop.sh @@ -0,0 +1,348 @@ +#!/bin/bash + +DATA_DIR=/mnt/root/testdata +NUM_LOOP=5 + +function printTo { + if $verbose ; then + echo $1 + fi +} + +TDTESTQ2OUT=tdengineTestQ2.out + +function runTest { + totalCount10=0 + totalCount20=0 + totalCount30=0 + totalCount40=0 + totalCount50=0 + totalCount60=0 + totalCount70=0 + totalCount80=0 + totalCount90=0 + totalCount100=0 + + totalAvg10=0 + totalAvg20=0 + totalAvg30=0 + totalAvg40=0 + totalAvg50=0 + totalAvg60=0 + totalAvg70=0 + totalAvg80=0 + totalAvg90=0 + totalAvg100=0 + + totalSum10=0 + totalSum20=0 + totalSum30=0 + totalSum40=0 + totalSum50=0 + totalSum60=0 + totalSum70=0 + totalSum80=0 + totalSum90=0 + totalSum100=0 + + totalMax10=0 + totalMax20=0 + totalMax30=0 + totalMax40=0 + totalMax50=0 + totalMax60=0 + totalMax70=0 + totalMax80=0 + totalMax90=0 + totalMax100=0 + + totalMin10=0 + totalMin20=0 + totalMin30=0 + totalMin40=0 + totalMin50=0 + totalMin60=0 + totalMin70=0 + totalMin80=0 + totalMin90=0 + totalMin100=0 + + totalSpread10=0 + totalSpread20=0 + totalSpread30=0 + totalSpread40=0 + totalSpread50=0 + totalSpread60=0 + totalSpread70=0 + totalSpread80=0 + totalSpread90=0 + totalSpread100=0 + + for i in `seq 1 $NUM_LOOP`; do + printTo "loop i:$i, $TDTEST_DIR/tdengineTest \ + -sql q2.txt" + restartTaosd + $TDTEST_DIR/tdengineTest \ + -sql $TDTEST_DIR/q2.txt > $TDTESTQ2OUT + + Count10=`cat $TDTESTQ2OUT | grep "count" | grep "devgroup<10;" | awk '{print $3}'` + totalCount10=`echo "scale=4; $totalCount10 + $Count10" | bc` + Count20=`cat $TDTESTQ2OUT | grep "count" | grep "devgroup<20;" | awk '{print $3}'` + totalCount20=`echo "scale=4; $totalCount20 + $Count20" | bc` + Count30=`cat $TDTESTQ2OUT | grep count | grep "devgroup<30;" | awk '{print $3}'` + totalCount30=`echo "scale=4; $totalCount30 + $Count30" | bc` + Count40=`cat $TDTESTQ2OUT | grep count | grep "devgroup<40;" | awk '{print $3}'` + totalCount40=`echo "scale=4; $totalCount40 + $Count40" | bc` + Count50=`cat $TDTESTQ2OUT | grep count | grep "devgroup<50;" | awk '{print $3}'` + totalCount50=`echo "scale=4; $totalCount50 + $Count50" | bc` + Count60=`cat $TDTESTQ2OUT | grep count | grep "devgroup<60;" | awk '{print $3}'` + totalCount60=`echo "scale=4; $totalCount60 + $Count60" | bc` + Count70=`cat $TDTESTQ2OUT | grep count | grep "devgroup<70;" | awk '{print $3}'` + totalCount70=`echo "scale=4; $totalCount70 + $Count70" | bc` + Count80=`cat $TDTESTQ2OUT | grep count | grep "devgroup<80;" | awk '{print $3}'` + totalCount80=`echo "scale=4; $totalCount80 + $Count80" | bc` + Count90=`cat $TDTESTQ2OUT | grep count | grep "devgroup<90;" | awk '{print $3}'` + totalCount90=`echo "scale=4; $totalCount90 + $Count90" | bc` + Count100=`cat $TDTESTQ2OUT | grep count | grep "db.devices;" | awk '{print $3}'` + totalCount100=`echo "scale=4; $totalCount100 + $Count100" | bc` + + Avg10=`cat $TDTESTQ2OUT | grep "avg" | grep "devgroup<10;" | awk '{print $3}'` + totalAvg10=`echo "scale=4; $totalAvg10 + $Avg10" | bc` + Avg20=`cat $TDTESTQ2OUT | grep "avg" | grep "devgroup<20;" | awk '{print $3}'` + totalAvg20=`echo "scale=4; $totalAvg20 + $Avg20" | bc` + Avg30=`cat $TDTESTQ2OUT | grep avg | grep "devgroup<30;" | awk '{print $3}'` + totalAvg30=`echo "scale=4; $totalAvg30 + $Avg30" | bc` + Avg40=`cat $TDTESTQ2OUT | grep avg | grep "devgroup<40;" | awk '{print $3}'` + totalAvg40=`echo "scale=4; $totalAvg40 + $Avg40" | bc` + Avg50=`cat $TDTESTQ2OUT | grep avg | grep "devgroup<50;" | awk '{print $3}'` + totalAvg50=`echo "scale=4; $totalAvg50 + $Avg50" | bc` + Avg60=`cat $TDTESTQ2OUT | grep avg | grep "devgroup<60;" | awk '{print $3}'` + totalAvg60=`echo "scale=4; $totalAvg60 + $Avg60" | bc` + Avg70=`cat $TDTESTQ2OUT | grep avg | grep "devgroup<70;" | awk '{print $3}'` + totalAvg70=`echo "scale=4; $totalAvg70 + $Avg70" | bc` + Avg80=`cat $TDTESTQ2OUT | grep avg | grep "devgroup<80;" | awk '{print $3}'` + totalAvg80=`echo "scale=4; $totalAvg80 + $Avg80" | bc` + Avg90=`cat $TDTESTQ2OUT | grep avg | grep "devgroup<90;" | awk '{print $3}'` + totalAvg90=`echo "scale=4; $totalAvg90 + $Avg90" | bc` + Avg100=`cat $TDTESTQ2OUT | grep avg | grep "db.devices;" | awk '{print $3}'` + totalAvg100=`echo "scale=4; $totalAvg100 + $Avg100" | bc` + + Sum10=`cat $TDTESTQ2OUT | grep "sum" | grep "devgroup<10;" | awk '{print $3}'` + totalSum10=`echo "scale=4; $totalSum10 + $Sum10" | bc` + Sum20=`cat $TDTESTQ2OUT | grep "sum" | grep "devgroup<20;" | awk '{print $3}'` + totalSum20=`echo "scale=4; $totalSum20 + $Sum20" | bc` + Sum30=`cat $TDTESTQ2OUT | grep sum | grep "devgroup<30;" | awk '{print $3}'` + totalSum30=`echo "scale=4; $totalSum30 + $Sum30" | bc` + Sum40=`cat $TDTESTQ2OUT | grep sum | grep "devgroup<40;" | awk '{print $3}'` + totalSum40=`echo "scale=4; $totalSum40 + $Sum40" | bc` + Sum50=`cat $TDTESTQ2OUT | grep sum | grep "devgroup<50;" | awk '{print $3}'` + totalSum50=`echo "scale=4; $totalSum50 + $Sum50" | bc` + Sum60=`cat $TDTESTQ2OUT | grep sum | grep "devgroup<60;" | awk '{print $3}'` + totalSum60=`echo "scale=4; $totalSum60 + $Sum60" | bc` + Sum70=`cat $TDTESTQ2OUT | grep sum | grep "devgroup<70;" | awk '{print $3}'` + totalSum70=`echo "scale=4; $totalSum70 + $Sum70" | bc` + Sum80=`cat $TDTESTQ2OUT | grep sum | grep "devgroup<80;" | awk '{print $3}'` + totalSum80=`echo "scale=4; $totalSum80 + $Sum80" | bc` + Sum90=`cat $TDTESTQ2OUT | grep sum | grep "devgroup<90;" | awk '{print $3}'` + totalSum90=`echo "scale=4; $totalSum90 + $Sum90" | bc` + Sum100=`cat $TDTESTQ2OUT | grep sum | grep "db.devices;" | awk '{print $3}'` + totalSum100=`echo "scale=4; $totalSum100 + $Sum100" | bc` + + Max10=`cat $TDTESTQ2OUT | grep "max" | grep "devgroup<10;" | awk '{print $3}'` + totalMax10=`echo "scale=4; $totalMax10 + $Max10" | bc` + Max20=`cat $TDTESTQ2OUT | grep "max" | grep "devgroup<20;" | awk '{print $3}'` + totalMax20=`echo "scale=4; $totalMax20 + $Max20" | bc` + Max30=`cat $TDTESTQ2OUT | grep max | grep "devgroup<30;" | awk '{print $3}'` + totalMax30=`echo "scale=4; $totalMax30 + $Max30" | bc` + Max40=`cat $TDTESTQ2OUT | grep max | grep "devgroup<40;" | awk '{print $3}'` + totalMax40=`echo "scale=4; $totalMax40 + $Max40" | bc` + Max50=`cat $TDTESTQ2OUT | grep max | grep "devgroup<50;" | awk '{print $3}'` + totalMax50=`echo "scale=4; $totalMax50 + $Max50" | bc` + Max60=`cat $TDTESTQ2OUT | grep max | grep "devgroup<60;" | awk '{print $3}'` + totalMax60=`echo "scale=4; $totalMax60 + $Max60" | bc` + Max70=`cat $TDTESTQ2OUT | grep max | grep "devgroup<70;" | awk '{print $3}'` + totalMax70=`echo "scale=4; $totalMax70 + $Max70" | bc` + Max80=`cat $TDTESTQ2OUT | grep max | grep "devgroup<80;" | awk '{print $3}'` + totalMax80=`echo "scale=4; $totalMax80 + $Max80" | bc` + Max90=`cat $TDTESTQ2OUT | grep max | grep "devgroup<90;" | awk '{print $3}'` + totalMax90=`echo "scale=4; $totalMax90 + $Max90" | bc` + Max100=`cat $TDTESTQ2OUT | grep max | grep "db.devices;" | awk '{print $3}'` + totalMax100=`echo "scale=4; $totalMax100 + $Max100" | bc` + + Min10=`cat $TDTESTQ2OUT | grep "min" | grep "devgroup<10;" | awk '{print $3}'` + totalMin10=`echo "scale=4; $totalMin10 + $Min10" | bc` + Min20=`cat $TDTESTQ2OUT | grep "min" | grep "devgroup<20;" | awk '{print $3}'` + totalMin20=`echo "scale=4; $totalMin20 + $Min20" | bc` + Min30=`cat $TDTESTQ2OUT | grep min | grep "devgroup<30;" | awk '{print $3}'` + totalMin30=`echo "scale=4; $totalMin30 + $Min30" | bc` + Min40=`cat $TDTESTQ2OUT | grep min | grep "devgroup<40;" | awk '{print $3}'` + totalMin40=`echo "scale=4; $totalMin40 + $Min40" | bc` + Min50=`cat $TDTESTQ2OUT | grep min | grep "devgroup<50;" | awk '{print $3}'` + totalMin50=`echo "scale=4; $totalMin50 + $Min50" | bc` + Min60=`cat $TDTESTQ2OUT | grep min | grep "devgroup<60;" | awk '{print $3}'` + totalMin60=`echo "scale=4; $totalMin60 + $Min60" | bc` + Min70=`cat $TDTESTQ2OUT | grep min | grep "devgroup<70;" | awk '{print $3}'` + totalMin70=`echo "scale=4; $totalMin70 + $Min70" | bc` + Min80=`cat $TDTESTQ2OUT | grep min | grep "devgroup<80;" | awk '{print $3}'` + totalMin80=`echo "scale=4; $totalMin80 + $Min80" | bc` + Min90=`cat $TDTESTQ2OUT | grep min | grep "devgroup<90;" | awk '{print $3}'` + totalMin90=`echo "scale=4; $totalMin90 + $Min90" | bc` + Min100=`cat $TDTESTQ2OUT | grep min | grep "db.devices;" | awk '{print $3}'` + totalMin100=`echo "scale=4; $totalMin100 + $Min100" | bc` + + Spread10=`cat $TDTESTQ2OUT | grep "spread" | grep "devgroup<10;" | awk '{print $3}'` + totalSpread10=`echo "scale=4; $totalSpread10 + $Spread10" | bc` + Spread20=`cat $TDTESTQ2OUT | grep "spread" | grep "devgroup<20;" | awk '{print $3}'` + totalSpread20=`echo "scale=4; $totalSpread20 + $Spread20" | bc` + Spread30=`cat $TDTESTQ2OUT | grep spread | grep "devgroup<30;" | awk '{print $3}'` + totalSpread30=`echo "scale=4; $totalSpread30 + $Spread30" | bc` + Spread40=`cat $TDTESTQ2OUT | grep spread | grep "devgroup<40;" | awk '{print $3}'` + totalSpread40=`echo "scale=4; $totalSpread40 + $Spread40" | bc` + Spread50=`cat $TDTESTQ2OUT | grep spread | grep "devgroup<50;" | awk '{print $3}'` + totalSpread50=`echo "scale=4; $totalSpread50 + $Spread50" | bc` + Spread60=`cat $TDTESTQ2OUT | grep spread | grep "devgroup<60;" | awk '{print $3}'` + totalSpread60=`echo "scale=4; $totalSpread60 + $Spread60" | bc` + Spread70=`cat $TDTESTQ2OUT | grep spread | grep "devgroup<70;" | awk '{print $3}'` + totalSpread70=`echo "scale=4; $totalSpread70 + $Spread70" | bc` + Spread80=`cat $TDTESTQ2OUT | grep spread | grep "devgroup<80;" | awk '{print $3}'` + totalSpread80=`echo "scale=4; $totalSpread80 + $Spread80" | bc` + Spread90=`cat $TDTESTQ2OUT | grep spread | grep "devgroup<90;" | awk '{print $3}'` + totalSpread90=`echo "scale=4; $totalSpread90 + $Spread90" | bc` + Spread100=`cat $TDTESTQ2OUT | grep spread | grep "db.devices;" | awk '{print $3}'` + totalSpread100=`echo "scale=4; $totalSpread100 + $Spread100" | bc` + + done + avgCount10=`echo "scale=4; x = $totalCount10 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount20=`echo "scale=4; x = $totalCount20 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount30=`echo "scale=4; x = $totalCount30 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount40=`echo "scale=4; x = $totalCount40 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount50=`echo "scale=4; x = $totalCount50 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount60=`echo "scale=4; x = $totalCount60 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount70=`echo "scale=4; x = $totalCount70 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount80=`echo "scale=4; x = $totalCount80 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount90=`echo "scale=4; x = $totalCount90 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgCount100=`echo "scale=4; x = $totalCount100 / $NUM_LOOP; if(x<1) print 0; x" | bc` + + avgAvg10=`echo "scale=4; x = $totalAvg10 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgAvg20=`echo "scale=4; x = $totalAvg20 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgAvg30=`echo "scale=4; x = $totalAvg30 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgAvg40=`echo "scale=4; x = $totalAvg40 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgAvg50=`echo "scale=4; x = $totalAvg50 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgAvg60=`echo "scale=4; x = $totalAvg60 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgAvg70=`echo "scale=4; x = $totalAvg70 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgAvg80=`echo "scale=4; x = $totalAvg80 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgAvg90=`echo "scale=4; x = $totalAvg90 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgAvg100=`echo "scale=4; x = $totalAvg100 / $NUM_LOOP; if(x<1) print 0; x" | bc` + + avgSum10=`echo "scale=4; x = $totalSum10 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum20=`echo "scale=4; x = $totalSum20 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum30=`echo "scale=4; x = $totalSum30 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum40=`echo "scale=4; x = $totalSum40 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum50=`echo "scale=4; x = $totalSum50 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum60=`echo "scale=4; x = $totalSum60 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum70=`echo "scale=4; x = $totalSum70 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum80=`echo "scale=4; x = $totalSum80 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum90=`echo "scale=4; x = $totalSum90 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSum100=`echo "scale=4; x = $totalSum100 / $NUM_LOOP; if(x<1) print 0; x" | bc` + + avgMax10=`echo "scale=4; x = $totalMax10 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax20=`echo "scale=4; x = $totalMax20 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax30=`echo "scale=4; x = $totalMax30 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax40=`echo "scale=4; x = $totalMax40 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax50=`echo "scale=4; x = $totalMax50 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax60=`echo "scale=4; x = $totalMax60 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax70=`echo "scale=4; x = $totalMax70 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax80=`echo "scale=4; x = $totalMax80 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax90=`echo "scale=4; x = $totalMax90 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMax100=`echo "scale=4; x = $totalMax100 / $NUM_LOOP; if(x<1) print 0; x" | bc` + + avgMin10=`echo "scale=4; x = $totalMin10 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin20=`echo "scale=4; x = $totalMin20 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin30=`echo "scale=4; x = $totalMin30 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin40=`echo "scale=4; x = $totalMin40 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin50=`echo "scale=4; x = $totalMin50 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin60=`echo "scale=4; x = $totalMin60 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin70=`echo "scale=4; x = $totalMin70 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin80=`echo "scale=4; x = $totalMin80 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin90=`echo "scale=4; x = $totalMin90 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgMin100=`echo "scale=4; x = $totalMin100 / $NUM_LOOP; if(x<1) print 0; x" | bc` + + avgSpread10=`echo "scale=4; x = $totalSpread10 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSpread20=`echo "scale=4; x = $totalSpread20 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSpread30=`echo "scale=4; x = $totalSpread30 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSpread40=`echo "scale=4; x = $totalSpread40 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSpread50=`echo "scale=4; x = $totalSpread50 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSpread60=`echo "scale=4; x = $totalSpread60 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSpread70=`echo "scale=4; x = $totalSpread70 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSpread80=`echo "scale=4; x = $totalSpread80 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSpread90=`echo "scale=4; x = $totalSpread90 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgSpread100=`echo "scale=4; x = $totalSpread100 / $NUM_LOOP; if(x<1) print 0; x" | bc` + + echo "Latency, 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%, 100%" + echo "Count, $avgCount10, $avgCount20, $avgCount30, $avgCount40, $avgCount50, $avgCount60, $avgCount70, $avgCount80, $avgCount90, $avgCount100" + echo "Avg, $avgAvg10, $avgAvg20, $avgAvg30, $avgAvg40, $avgAvg50, $avgAvg60, $avgAvg70, $avgAvg80, $avgAvg90, $avgAvg100" + echo "Sum, $avgSum10, $avgSum20, $avgSum30, $avgSum40, $avgSum50, $avgSum60, $avgSum70, $avgSum80, $avgSum90, $avgSum100" + echo "Max, $avgMax10, $avgMax20, $avgMax30, $avgMax40, $avgMax50, $avgMax60, $avgMax70, $avgMax80, $avgMax90, $avgMax100" + echo "Min, $avgMin10, $avgMin20, $avgMin30, $avgMin40, $avgMin50, $avgMin60, $avgMin70, $avgMin80, $avgMin90, $avgMin100" + echo "Spread, $avgSpread10, $avgSpread20, $avgSpread30, $avgSpread40, $avgSpread50, $avgSpread60, $avgSpread70, $avgSpread80, $avgSpread90, $avgSpread100" +} + +function restartTaosd { + printTo "Stop taosd" + systemctl stop taosd + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + pkill -TERM -x taosd + sleep 1 + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + done + + printTo "Start taosd" + $TAOSD_DIR/taosd > /dev/null 2>&1 & + sleep 10 +} + +################ Main ################ + +master=false +develop=true +verbose=false + +for arg in "$@" +do + case $arg in + -v) + verbose=true + ;; + + master) + master=true + develop=false + ;; + + develop) + master=false + develop=true + ;; + *) + ;; + esac +done + +if $master ; then + echo "Test master branch.." + cp /mnt/root/cfg/master/taos.cfg /etc/taos/taos.cfg + WORK_DIR=/mnt/root/TDengine.master +else + echo "Test develop branch.." + cp /mnt/root/cfg/10billion/taos.cfg /etc/taos/taos.cfg + WORK_DIR=/mnt/root/TDengine +fi + +TAOSD_DIR=$WORK_DIR/debug/build/bin +TDTEST_DIR=$WORK_DIR/tests/comparisonTest/tdengine + +runTest + +echo "Test done!" diff --git a/tests/perftest-scripts/tdengineTestQ3Loop.sh b/tests/perftest-scripts/tdengineTestQ3Loop.sh new file mode 100755 index 0000000000000000000000000000000000000000..f59f6372586c857096ece51f0626f365d290ad73 --- /dev/null +++ b/tests/perftest-scripts/tdengineTestQ3Loop.sh @@ -0,0 +1,124 @@ +#!/bin/bash + +DATA_DIR=/mnt/root/testdata +NUM_LOOP=5 + +function printTo { + if $verbose ; then + echo $1 + fi +} + +TDTESTQ3OUT=tdengineTestQ3.out + +function runTest { + totalG10=0 + totalG20=0 + totalG30=0 + totalG40=0 + totalG50=0 + totalG60=0 + totalG70=0 + totalG80=0 + totalG90=0 + totalG100=0 + for i in `seq 1 $NUM_LOOP`; do + printTo "loop i:$i, $TDTEST_DIR/tdengineTest \ + -sql q3.txt" + restartTaosd + $TDTEST_DIR/tdengineTest \ + -sql $TDTEST_DIR/q3.txt > $TDTESTQ3OUT + G10=`grep "devgroup<10" $TDTESTQ3OUT| awk '{print $3}'` + totalG10=`echo "scale=4; $totalG10 + $G10" | bc` + G20=`grep "devgroup<20" $TDTESTQ3OUT| awk '{print $3}'` + totalG20=`echo "scale=4; $totalG20 + $G20" | bc` + G30=`grep "devgroup<30" $TDTESTQ3OUT| awk '{print $3}'` + totalG30=`echo "scale=4; $totalG30 + $G30" | bc` + G40=`grep "devgroup<40" $TDTESTQ3OUT| awk '{print $3}'` + totalG40=`echo "scale=4; $totalG40 + $G40" | bc` + G50=`grep "devgroup<50" $TDTESTQ3OUT| awk '{print $3}'` + totalG50=`echo "scale=4; $totalG50 + $G50" | bc` + G60=`grep "devgroup<60" $TDTESTQ3OUT| awk '{print $3}'` + totalG60=`echo "scale=4; $totalG60 + $G60" | bc` + G70=`grep "devgroup<70" $TDTESTQ3OUT| awk '{print $3}'` + totalG70=`echo "scale=4; $totalG70 + $G70" | bc` + G80=`grep "devgroup<80" $TDTESTQ3OUT| awk '{print $3}'` + totalG80=`echo "scale=4; $totalG80 + $G80" | bc` + G90=`grep "devgroup<90" $TDTESTQ3OUT| awk '{print $3}'` + totalG90=`echo "scale=4; $totalG90 + $G90" | bc` + G100=`grep "db.devices group by devgroup;" $TDTESTQ3OUT| awk '{print $3}'` + totalG100=`echo "scale=4; $totalG100 + $G100" | bc` + done + avgG10=`echo "scale=4; x = $totalG10 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG20=`echo "scale=4; x = $totalG20 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG30=`echo "scale=4; x = $totalG30 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG40=`echo "scale=4; x = $totalG40 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG50=`echo "scale=4; x = $totalG50 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG60=`echo "scale=4; x = $totalG60 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG70=`echo "scale=4; x = $totalG70 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG80=`echo "scale=4; x = $totalG80 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG90=`echo "scale=4; x = $totalG90 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG100=`echo "scale=4; x = $totalG100 / $NUM_LOOP; if(x<1) print 0; x" | bc` + echo "Latency, 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%, 100%" + echo "TDengine, $avgG10, $avgG20, $avgG30, $avgG40, $avgG50, $avgG60, $avgG70, $avgG80, $avgG90, $avgG100" +} + +function restartTaosd { + printTo "Stop taosd" + systemctl stop taosd + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + pkill -TERM -x taosd + sleep 1 + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + done + + printTo "Start taosd" + $TAOSD_DIR/taosd > /dev/null 2>&1 & + sleep 10 +} + +################ Main ################ + +master=false +develop=true +verbose=false + +for arg in "$@" +do + case $arg in + -v) + verbose=true + ;; + + master) + master=true + develop=false + ;; + + develop) + master=false + develop=true + ;; + *) + ;; + esac +done + +if $master ; then + echo "Test master branch.." + cp /mnt/root/cfg/master/taos.cfg /etc/taos/taos.cfg + WORK_DIR=/mnt/root/TDengine.master +else + echo "Test develop branch.." + cp /mnt/root/cfg/10billion/taos.cfg /etc/taos/taos.cfg + WORK_DIR=/mnt/root/TDengine +fi + +TAOSD_DIR=$WORK_DIR/debug/build/bin +TDTEST_DIR=$WORK_DIR/tests/comparisonTest/tdengine + +runTest + +echo "Test done!" diff --git a/tests/perftest-scripts/tdengineTestQ4Loop.sh b/tests/perftest-scripts/tdengineTestQ4Loop.sh new file mode 100755 index 0000000000000000000000000000000000000000..8ea3cb402335bd9fea808316f0ba504451dbf2bc --- /dev/null +++ b/tests/perftest-scripts/tdengineTestQ4Loop.sh @@ -0,0 +1,124 @@ +#!/bin/bash + +DATA_DIR=/mnt/root/testdata +NUM_LOOP=5 + +function printTo { + if $verbose ; then + echo $1 + fi +} + +TDTESTQ4OUT=tdengineTestQ4.out + +function runTest { + totalG10=0 + totalG20=0 + totalG30=0 + totalG40=0 + totalG50=0 + totalG60=0 + totalG70=0 + totalG80=0 + totalG90=0 + totalG100=0 + for i in `seq 1 $NUM_LOOP`; do + printTo "loop i:$i, $TDTEST_DIR/tdengineTest \ + -sql q4.txt" + restartTaosd + $TDTEST_DIR/tdengineTest \ + -sql $TDTEST_DIR/q4.txt > $TDTESTQ4OUT + G10=`grep "devgroup<10" $TDTESTQ4OUT| awk '{print $3}'` + totalG10=`echo "scale=4; $totalG10 + $G10" | bc` + G20=`grep "devgroup<20" $TDTESTQ4OUT| awk '{print $3}'` + totalG20=`echo "scale=4; $totalG20 + $G20" | bc` + G30=`grep "devgroup<30" $TDTESTQ4OUT| awk '{print $3}'` + totalG30=`echo "scale=4; $totalG30 + $G30" | bc` + G40=`grep "devgroup<40" $TDTESTQ4OUT| awk '{print $3}'` + totalG40=`echo "scale=4; $totalG40 + $G40" | bc` + G50=`grep "devgroup<50" $TDTESTQ4OUT| awk '{print $3}'` + totalG50=`echo "scale=4; $totalG50 + $G50" | bc` + G60=`grep "devgroup<60" $TDTESTQ4OUT| awk '{print $3}'` + totalG60=`echo "scale=4; $totalG60 + $G60" | bc` + G70=`grep "devgroup<70" $TDTESTQ4OUT| awk '{print $3}'` + totalG70=`echo "scale=4; $totalG70 + $G70" | bc` + G80=`grep "devgroup<80" $TDTESTQ4OUT| awk '{print $3}'` + totalG80=`echo "scale=4; $totalG80 + $G80" | bc` + G90=`grep "devgroup<90" $TDTESTQ4OUT| awk '{print $3}'` + totalG90=`echo "scale=4; $totalG90 + $G90" | bc` + G100=`grep "db.devices interval" $TDTESTQ4OUT| awk '{print $3}'` + totalG100=`echo "scale=4; $totalG100 + $G100" | bc` + done + avgG10=`echo "scale=4; x = $totalG10 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG20=`echo "scale=4; x = $totalG20 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG30=`echo "scale=4; x = $totalG30 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG40=`echo "scale=4; x = $totalG40 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG50=`echo "scale=4; x = $totalG50 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG60=`echo "scale=4; x = $totalG60 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG70=`echo "scale=4; x = $totalG70 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG80=`echo "scale=4; x = $totalG80 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG90=`echo "scale=4; x = $totalG90 / $NUM_LOOP; if(x<1) print 0; x" | bc` + avgG100=`echo "scale=4; x = $totalG100 / $NUM_LOOP; if(x<1) print 0; x" | bc` + echo "Latency, 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%, 100%" + echo "TDengine, $avgG10, $avgG20, $avgG30, $avgG40, $avgG50, $avgG60, $avgG70, $avgG80, $avgG90, $avgG100" +} + +function restartTaosd { + printTo "Stop taosd" + systemctl stop taosd + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + pkill -TERM -x taosd + sleep 1 + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + done + + printTo "Start taosd" + $TAOSD_DIR/taosd > /dev/null 2>&1 & + sleep 10 +} + +################ Main ################ + +master=false +develop=true +verbose=false + +for arg in "$@" +do + case $arg in + -v) + verbose=true + ;; + + master) + master=true + develop=false + ;; + + develop) + master=false + develop=true + ;; + *) + ;; + esac +done + +if $master ; then + echo "Test master branch.." + cp /mnt/root/cfg/master/taos.cfg /etc/taos/taos.cfg + WORK_DIR=/mnt/root/TDengine.master +else + echo "Test develop branch.." + cp /mnt/root/cfg/10billion/taos.cfg /etc/taos/taos.cfg + WORK_DIR=/mnt/root/TDengine +fi + +TAOSD_DIR=$WORK_DIR/debug/build/bin +TDTEST_DIR=$WORK_DIR/tests/comparisonTest/tdengine + +runTest + +echo "Test done!" diff --git a/tests/perftest-scripts/tdengineTestQ5Loop.sh b/tests/perftest-scripts/tdengineTestQ5Loop.sh new file mode 100755 index 0000000000000000000000000000000000000000..9eff74f563fdd21fddd885324096daef26170f94 --- /dev/null +++ b/tests/perftest-scripts/tdengineTestQ5Loop.sh @@ -0,0 +1,107 @@ +#!/bin/bash + +DATA_DIR=/mnt/root/testdata +NUM_LOOP=5 + +function printTo { + if $verbose ; then + echo $1 + fi +} + +TDTESTQ5OUT=tdengineTestQ5.out + +function runTest { + totalThroughput=0 + for i in `seq 1 $NUM_LOOP`; do + for c in `seq 1 $clients`; do + records[$c]=0 + spentTime[$c]=0 + throughput[$c]=0 + done + printTo "loop i:$i, $TDTEST_DIR/tdengineTest \ + -clients $clients -sql q5.txt" + restartTaosd + beginMS=`date +%s%3N` + $TDTEST_DIR/tdengineTest \ + -clients $clients -sql $TDTEST_DIR/q5.txt > $TDTESTQ5OUT + endMS=`date +%s%3N` + totalRecords=0 + for c in `seq 1 $clients`; do + records[$c]=`grep Thread:$c $TDTESTQ5OUT | awk '{print $7}'` + totalRecords=`echo "$totalRecords + ${records[$c]}"|bc` + done + spending=`echo "scale=4; x = ($endMS - $beginMS)/1000; if (x<1) print 0; x"|bc` + throughput=`echo "scale=4; x= $totalRecords / $spending; if (x<1) print 0; x" | bc` + printTo "spending: $spending sec, throughput: $throughput" + totalThroughput=`echo "scale=4; x = $totalThroughput + $throughput; if(x<1) print 0; x"|bc` + done + avgThrougput=`echo "scale=4; x = $totalThroughput / $NUM_LOOP; if (x<1) print 0; x"|bc` + echo "avg Throughput: $avgThrougput" +} + +function restartTaosd { + printTo "Stop taosd" + systemctl stop taosd + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + pkill -TERM -x taosd + sleep 1 + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + done + + printTo "Start taosd" + $TAOSD_DIR/taosd > /dev/null 2>&1 & + sleep 10 +} + +################ Main ################ + +master=false +develop=true +verbose=false + +clients=1 + +while : ; do + case $1 in + -v) + verbose=true + shift ;; + + master) + master=true + develop=false + shift ;; + + develop) + master=false + develop=true + shift ;; + + -c) + clients=$2 + shift 2;; + + *) + break ;; + esac +done + +if $master ; then + printTo "Test master branch.." + cp /mnt/root/cfg/master/taos.cfg /etc/taos/taos.cfg + WORK_DIR=/mnt/root/TDengine.master +else + printTo "Test develop branch.." + cp /mnt/root/cfg/10billion/taos.cfg /etc/taos/taos.cfg + WORK_DIR=/mnt/root/TDengine +fi + +TAOSD_DIR=$WORK_DIR/debug/build/bin +TDTEST_DIR=$WORK_DIR/tests/comparisonTest/tdengine + +runTest + +printTo "Test done!" diff --git a/tests/perftest-scripts/tdengineTestWriteLoop.sh b/tests/perftest-scripts/tdengineTestWriteLoop.sh new file mode 100755 index 0000000000000000000000000000000000000000..cb9d87d0c19fc171ee87c35b96ad47cd8dbf3cf7 --- /dev/null +++ b/tests/perftest-scripts/tdengineTestWriteLoop.sh @@ -0,0 +1,172 @@ +#!/bin/bash + +DATA_DIR=/mnt/root/testdata +NUM_LOOP=5 +NUM_OF_FILES=100 + +rowsPerRequest=(1 100 500 1000 2000) + +function printTo { + if $verbose ; then + echo $1 + fi +} + +function runTest { + declare -A avgRPR + + for r in ${!rowsPerRequest[@]}; do + for c in `seq 1 $clients`; do + avgRPR[$r,$c]=0 + done + done + + for r in ${!rowsPerRequest[@]}; do + for c in `seq 1 $clients`; do + totalRPR=0 + if $v16 ; then + OUTPUT_FILE=tdengineTestWrite-v16-RPR${rowsPerRequest[$r]}-clients$c.out + else + OUTPUT_FILE=tdengineTestWrite-v20-RPR${rowsPerRequest[$r]}-clients$c.out + fi + + for i in `seq 1 $NUM_LOOP`; do + if ! $printresultonly ; then + restartTaosd + $TAOSD_DIR/taos -s "drop database db" > /dev/null 2>&1 + + if $v16 ; then + printTo "loop i:$i, $TDTEST_DIR/tdengineTest \ + -dataDir $DATA_DIR \ + -numOfFiles $NUM_OF_FILES \ + -writeClients $c \ + -rowsPerRequest ${rowsPerRequest[$r]} \ + | tee $OUTPUT_FILE" + $TDTEST_DIR/tdengineTest \ + -dataDir $DATA_DIR \ + -numOfFiles $NUM_OF_FILES \ + -writeClients $c \ + -rowsPerRequest ${rowsPerRequest[$r]} \ + | tee $OUTPUT_FILE + else + printTo "loop i:$i, $TDTEST_DIR/tdengineTest \ + -dataDir $DATA_DIR \ + -numOfFiles $NUM_OF_FILES \ + -w -clients $c \ + -rowsPerRequest ${rowsPerRequest[$r]} \ + | tee $OUTPUT_FILE" + $TDTEST_DIR/tdengineTest \ + -dataDir $DATA_DIR \ + -numOfFiles $NUM_OF_FILES \ + -w -clients $c \ + -rowsPerRequest ${rowsPerRequest[$r]} \ + | tee $OUTPUT_FILE + fi + fi + + RPR=`cat $OUTPUT_FILE | grep speed | awk '{print $(NF-1)}'` + totalRPR=`echo "scale=4; $totalRPR + $RPR" | bc` + printTo "rows:${rowsPerRequest[$r]}, clients:$c, i:$i RPR:$RPR" + done + avgRPR[$r,$c]=`echo "scale=4; $totalRPR / $NUM_LOOP" | bc` + printTo "r:${rowsPerRequest[$r]} c:$c avgRPR:${avgRPR[$r,$c]}" + done + done + + printf "R/R, " + for c in `seq 1 $clients`; do + if [ "$c" == "1" ]; then + printf "$c client, " + else + printf "$c clients, " + fi + done + printf "\n" + + for r in ${!rowsPerRequest[@]}; do + printf "${rowsPerRequest[$r]}, " + for c in `seq 1 $clients`; do + printf "${avgRPR[$r,$c]}, " + done + printf "\n" + done +} + +function restartTaosd { + printTo "Stop taosd" + systemctl stop taosd + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + pkill -TERM -x taosd + sleep 1 + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + done + + printTo "Start taosd" + $TAOSD_DIR/taosd > /dev/null 2>&1 & + sleep 10 +} + +################ Main ################ + +v16=false +v20=true +verbose=false +clients=1 +printresultonly=false + +while : ; do + case $1 in + printresultonly) + printresultonly=true + shift ;; + + -v) + verbose=true + shift ;; + + v16) + v16=true + v20=false + shift ;; + + v20) + v16=false + v20=true + shift ;; + + -c) + clients=$2 + shift 2;; + + -n) + NUM_LOOP=$2 + shift 2;; + + *) + break ;; + esac +done + +if $v16 ; then + echo "Test v16 branch.." + WORK_DIR=/mnt/root/TDengine.v16 + cp /mnt/root/cfg/v16/taos.cfg /etc/taos/taos.cfg +else + echo "Test v20 branch.." + cp /mnt/root/cfg/v20/taos.cfg /etc/taos/taos.cfg + WORK_DIR=/mnt/root/TDengine +fi + +TAOSD_DIR=$WORK_DIR/debug/build/bin +TDTEST_DIR=$WORK_DIR/tests/comparisonTest/tdengine + +if [ ! -f $TDTEST_DIR/tdengineTest ]; then + echo "Please build tdengineTest first!" + exit 1 +fi + +runTest + +echo "Test done!" diff --git a/tests/perftest-scripts/tdinternal_coverage_test.sh b/tests/perftest-scripts/tdinternal_coverage_test.sh new file mode 100755 index 0000000000000000000000000000000000000000..654c06cd0b8ae28bdb05520ffb4d041ca9b82110 --- /dev/null +++ b/tests/perftest-scripts/tdinternal_coverage_test.sh @@ -0,0 +1,193 @@ +#!/bin/bash + +today=`date +"%Y%m%d"` +TDINTERNAL_DIR=/home/shuduo/work/taosdata/TDinternal.cover +TDINTERNAL_COVERAGE_REPORT=$TDINTERNAL_DIR/community/tests/tdinternal-coverage-report-$today.log + +# Color setting +RED='\033[0;31m' +GREEN='\033[1;32m' +GREEN_DARK='\033[0;32m' +GREEN_UNDERLINE='\033[4;32m' +NC='\033[0m' + +function buildTDinternal { + echo "check if TDinternal need build" + cd $TDINTERNAL_DIR + NEED_COMPILE=0 +# git remote update + REMOTE_COMMIT=`git rev-parse --short remotes/origin/develop` + LOCAL_COMMIT=`git rev-parse --short @` + echo " LOCAL: $LOCAL_COMMIT" + echo "REMOTE: $REMOTE_COMMIT" + if [ "$LOCAL_COMMIT" == "$REMOTE_COMMIT" ]; then + echo "TDinternal repo is up-to-date" + else + echo "repo need to pull" +# git pull + +# NEED_COMPILE=1 + fi + + lcov -d . --zerocounters +# git submodule update --init --recursive + cd $TDINTERNAL_DIR/community + TDENGINE_REMOTE_COMMIT=`git rev-parse --short remotes/origin/develop` + TDENGINE_LOCAL_COMMIT=`git rev-parse --short @` + if [ "$TDENGINE_LOCAL_COMMIT" == "$TDENGINE_REMOTE_COMMIT" ]; then + echo "community repo is up-to-date" + else + echo "repo need to pull" +# git checkout develop +# git pull +# NEED_COMPILE=1 + fi + + cd $TDINTERNAL_DIR/debug + + if [[ $NEED_COMPILE -eq 1 ]]; then + LOCAL_COMMIT=`git rev-parse --short @` + rm -rf * + cmake .. > /dev/null + make > /dev/null + fi + + make install > /dev/null +} + +function runUniqueCaseOneByOne { + while read -r line; do + if [[ $line =~ ^./test.sh* ]]; then + case=`echo $line | awk '{print $NF}'` + start_time=`date +%s` + ./test.sh -f $case > /dev/null 2>&1 && \ + echo -e "${GREEN}$case success${NC}" | tee -a $TDINTERNAL_COVERAGE_REPORT || \ + echo -e "${RED}$case failed${NC}" | tee -a $TDINTERNAL_COVERAGE_REPORT + end_time=`date +%s` + echo execution time of $case was `expr $end_time - $start_time`s. | tee -a $TDINTERNAL_COVERAGE_REPORT + fi + done < $1 +} + +function runTest { + echo "Run Test" + cd $TDINTERNAL_DIR/community/tests/script + [ -d ../../sim ] && rm -rf ../../sim + + [ -f $TDINTERNAL_COVERAGE_REPORT ] && rm $TDINTERNAL_COVERAGE_REPORT + + runUniqueCaseOneByOne jenkins/basic.txt + + totalSuccess=`grep 'success' $TDINTERNAL_COVERAGE_REPORT | wc -l` + + if [ "$totalSuccess" -gt "0" ]; then + echo -e "\n${GREEN} ### Total $totalSuccess TDinternal case(s) succeed! ### ${NC}" | tee -a $TDINTERNAL_COVERAGE_REPORT + fi + + totalFailed=`grep 'failed\|fault' $TDINTERNAL_COVERAGE_REPORT | wc -l` + if [ "$totalFailed" -ne "0" ]; then + echo -e "${RED} ### Total $totalFailed TDinternal case(s) failed! ### ${NC}\n" | tee -a $TDINTERNAL_COVERAGE_REPORT +# exit $totalPyFailed + fi + + # Test Python test case + cd $TDINTERNAL_DIR/community/tests + /usr/bin/time -f "Total spent: %e" ./test-all.sh full python | tee -a $TDINTERNAL_COVERAGE_REPORT + + # Test Connector + stopTaosd + $TDINTERNAL_DIR/debug/build/bin/taosd -c $TDINTERNAL_DIR/debug/test/cfg > /dev/null & + sleep 10 + + cd $TDINTERNAL_DIR/community/src/connector/jdbc + mvn clean package > /dev/null + mvn test > /dev/null | tee -a $TDINTERNAL_COVERAGE_REPORT + + # Test C Demo + stopTaosd + $TDINTERNAL_DIR/debug/build/bin/taosd -c $TDINTERNAL_DIR/debug/test/cfg > /dev/null & + sleep 10 + yes | $TDINTERNAL_DIR/debug/build/bin/demo 127.0.0.1 > /dev/null | tee -a $TDINTERNAL_COVERAGE_REPORT + + # Test waltest + dataDir=`grep dataDir $TDINTERNAL_DIR/debug/test/cfg/taos.cfg|awk '{print $2}'` + walDir=`find $dataDir -name "wal"|head -n1` + echo "dataDir: $dataDir" | tee -a $TDINTERNAL_COVERAGE_REPORT + echo "walDir: $walDir" | tee -a $TDINTERNAL_COVERAGE_REPORT + if [ -n "$walDir" ]; then + yes | $TDINTERNAL_DIR/debug/build/bin/waltest -p $walDir > /dev/null | tee -a $TDINTERNAL_COVERAGE_REPORT + fi + + # run Unit Test + echo "Run Unit Test: utilTest, queryTest and cliTest" + $TDINTERNAL_DIR/debug/build/bin/utilTest > /dev/null 2>&1 && echo "utilTest pass!" || echo "utilTest failed!" + $TDINTERNAL_DIR/debug/build/bin/queryTest > /dev/null 2>&1 && echo "queryTest pass!" || echo "queryTest failed!" + $TDINTERNAL_DIR/debug/build/bin/cliTest > /dev/null 2>&1 && echo "cliTest pass!" || echo "cliTest failed!" + + stopTaosd +} + +function sendReport { + echo "Send Report" + receiver="sdsang@taosdata.com, sangshuduo@gmail.com, pxiao@taosdata.com" + mimebody="MIME-Version: 1.0\nContent-Type: text/html; charset=utf-8\n" + + cd $TDINTERNAL_DIR + + sed -i 's/\x1b\[[0-9;]*m//g' $TDINTERNAL_COVERAGE_REPORT + + BODY_CONTENT=`cat $TDINTERNAL_COVERAGE_REPORT` + echo -e "to: ${receiver}\nsubject: TDinternal coverage test report ${today}, commit ID: ${LOCAL_COMMIT}\n\n${today}:\n${BODY_CONTENT}" | \ + (cat - && uuencode tdinternal-coverage-report-$today.tar.gz tdinternal-coverage-report-$today.tar.gz) | \ + (cat - && uuencode $TDINTERNAL_COVERAGE_REPORT tdinternal-coverage-report-$today.log) | \ + ssmtp "${receiver}" && echo "Report Sent!" +} + +function lcovFunc { + echo "collect data by lcov" + cd $TDINTERNAL_DIR + + sed -i 's/\x1b\[[0-9;]*m//g' $TDINTERNAL_COVERAGE_REPORT + # collect data + lcov -d . --capture --rc lcov_branch_coverage=1 --rc genhtmml_branch_coverage=1 --no-external -b $TDINTERNAL_DIR -o coverage.info + + # remove exclude paths + lcov --remove coverage.info '*/tests/*' '*/test/*' '*/deps/*' '*/plugins/*' '*/taosdef.h' \ + --rc lcov_branch_coverage=1 -o coverage.info + + # generate result + lcov -l --rc lcov_branch_coverage=1 coverage.info | tee -a $TDINTERNAL_COVERAGE_REPORT + + genhtml -o html coverage.info + + tar czf tdinternal-coverage-report-$today.tar.gz html coverage.info $TDINTERNAL_COVERAGE_REPORT + # push result to coveralls.io +# coveralls-lcov coverage.info | tee -a tdinternal-coverage-report-$today.log +} + +function stopTaosd { + echo "Stop taosd" + systemctl stop taosd + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + pkill -TERM -x taosd + sleep 1 + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + done +} + +WORK_DIR=/home/shuduo/work/taosdata + +date >> $WORK_DIR/cron.log +echo "Run Coverage Test for TDinternal" | tee -a $WORK_DIR/cron.log + +stopTaosd +buildTDinternal +runTest +lcovFunc +sendReport +stopTaosd + +date >> $WORK_DIR/cron.log +echo "End of TDinternal Coverage Test" | tee -a $WORK_DIR/cron.log diff --git a/tests/perftest-scripts/tdinternal_test.sh b/tests/perftest-scripts/tdinternal_test.sh new file mode 100755 index 0000000000000000000000000000000000000000..4de0549be06f2da7b17924a6dd87c18e007ebcc0 --- /dev/null +++ b/tests/perftest-scripts/tdinternal_test.sh @@ -0,0 +1,179 @@ +#!/bin/bash + +today=`date +"%Y%m%d"` +TDINTERNAL_DIR=/home/shuduo/work/taosdata/TDinternal +TDINTERNAL_TEST_REPORT=$TDINTERNAL_DIR/community/tests/tdinternal-report-$today.log + +# Color setting +RED='\033[0;31m' +GREEN='\033[1;32m' +GREEN_DARK='\033[0;32m' +GREEN_UNDERLINE='\033[4;32m' +NC='\033[0m' + +function buildTDinternal { + echo "check if TDinternal need build" + cd $TDINTERNAL_DIR + NEED_COMPILE=0 +# git remote update + REMOTE_COMMIT=`git rev-parse --short remotes/origin/develop` + LOCAL_COMMIT=`git rev-parse --short @` + echo " LOCAL: $LOCAL_COMMIT" + echo "REMOTE: $REMOTE_COMMIT" + if [ "$LOCAL_COMMIT" == "$REMOTE_COMMIT" ]; then + echo "TDinternal repo is up-to-date" + else + echo "repo need to pull" +# git pull + +# NEED_COMPILE=1 + fi + +# git submodule update --init --recursive + cd $TDINTERNAL_DIR/community + TDENGINE_REMOTE_COMMIT=`git rev-parse --short remotes/origin/develop` + TDENGINE_LOCAL_COMMIT=`git rev-parse --short @` + if [ "$TDENGINE_LOCAL_COMMIT" == "$TDENGINE_REMOTE_COMMIT" ]; then + echo "community repo is up-to-date" + else + echo "repo need to pull" +# git checkout develop +# git pull +# NEED_COMPILE=1 + fi + + cd $TDINTERNAL_DIR/debug + + if [[ $NEED_COMPILE -eq 1 ]]; then + LOCAL_COMMIT=`git rev-parse --short @` + rm -rf * + cmake .. > /dev/null + make > /dev/null + fi + + make install > /dev/null +} + +function runUniqueCaseOneByOne { + while read -r line; do + if [[ $line =~ ^./test.sh* ]]; then + case=`echo $line | awk '{print $NF}'` + start_time=`date +%s` + ./test.sh -f $case > /dev/null 2>&1 && \ + echo -e "${GREEN}$case success${NC}" | tee -a $TDINTERNAL_TEST_REPORT || \ + echo -e "${RED}$case failed${NC}" | tee -a $TDINTERNAL_TEST_REPORT + end_time=`date +%s` + echo execution time of $case was `expr $end_time - $start_time`s. | tee -a $TDINTERNAL_TEST_REPORT + fi + done < $1 +} + +function runPyCaseOneByOne { + while read -r line; do + if [[ $line =~ ^python.* ]]; then + if [[ $line != *sleep* ]]; then + case=`echo $line|awk '{print $NF}'` + start_time=`date +%s` + $line > /dev/null 2>&1 && ret=0 || ret=1 + end_time=`date +%s` + + if [[ ret -eq 0 ]]; then + echo -e "${GREEN}$case success${NC}" | tee -a pytest-out.log + else + casename=`echo $case|sed 's/\//\-/g'` + find $TDINTERNAL_DIR/community/sim -name "*log" -exec tar czf $TDINTERNAL_DIR/fulltest-$today-$casename.log.tar.gz {} + + echo -e "${RED}$case failed and log saved${NC}" | tee -a pytest-out.log + fi + echo execution time of $case was `expr $end_time - $start_time`s. | tee -a pytest-out.log + else + $line > /dev/null 2>&1 + fi + fi + done < $1 +} + +function runTest { + echo "Run Test" + cd $TDINTERNAL_DIR/community/tests/script + [ -d $TDINTERNAL_DIR/sim ] && rm -rf $TDINTERNAL_DIR/sim + + [ -f $TDINTERNAL_TEST_REPORT ] && rm $TDINTERNAL_TEST_REPORT + + runUniqueCaseOneByOne jenkins/basic.txt + + totalSuccess=`grep 'success' $TDINTERNAL_TEST_REPORT | wc -l` + + if [ "$totalSuccess" -gt "0" ]; then + echo -e "\n${GREEN} ### Total $totalSuccess TDinternal case(s) succeed! ### ${NC}" | tee -a $TDINTERNAL_TEST_REPORT + fi + + totalFailed=`grep 'failed\|fault' $TDINTERNAL_TEST_REPORT | wc -l` + if [ "$totalFailed" -ne "0" ]; then + echo -e "${RED} ### Total $totalFailed TDinternal case(s) failed! ### ${NC}\n" | tee -a $TDINTERNAL_TEST_REPORT +# exit $totalPyFailed + fi + + cd $TDINTERNAL_DIR/community/tests/pytest + [ -d $TDINTERNAL_DIR/community/sim ] && rm -rf $TDINTERNAL_DIR/community/sim + [ -f pytest-out.log ] && rm -f pytest-out.log + + /usr/bin/time -f "Total spent: %e" ./test-all.sh full python | tee -a $TDINTERNAL_TEST_REPORT + runPyCaseOneByOne fulltest.sh + + totalPySuccess=`grep 'success' pytest-out.log | wc -l` + totalPyFailed=`grep 'failed\|fault' pytest-out.log | wc -l` + + cat pytest-out.log >> $TDINTERNAL_TEST_REPORT + if [ "$totalPySuccess" -gt "0" ]; then + echo -e "\n${GREEN} ### Total $totalPySuccess python case(s) succeed! ### ${NC}" \ + | tee -a $TDINTERNAL_TEST_REPORT + fi + + if [ "$totalPyFailed" -ne "0" ]; then + echo -e "\n${RED} ### Total $totalPyFailed python case(s) failed! ### ${NC}" \ + | tee -a $TDINTERNAL_TEST_REPORT + fi +} + +function sendReport { + echo "Send Report" + receiver="sdsang@taosdata.com, sangshuduo@gmail.com, pxiao@taosdata.com" + mimebody="MIME-Version: 1.0\nContent-Type: text/html; charset=utf-8\n" + + cd $TDINTERNAL_DIR + + sed -i 's/\x1b\[[0-9;]*m//g' $TDINTERNAL_TEST_REPORT + BODY_CONTENT=`cat $TDINTERNAL_TEST_REPORT` + + cd $TDINTERNAL_DIR + tar czf fulltest-$today.tar.gz fulltest-$today-*.log.tar.gz + + echo -e "to: ${receiver}\nsubject: TDinternal test report ${today}, commit ID: ${LOCAL_COMMIT}\n\n${today}:\n${BODY_CONTENT}" | \ + (cat - && uuencode $TDINTERNAL_TEST_REPORT tdinternal-report-$today.log) | \ + ssmtp "${receiver}" && echo "Report Sent!" +} + +function stopTaosd { + echo "Stop taosd" + systemctl stop taosd + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + pkill -KILL -x taosd + sleep 1 + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + done +} + +WORK_DIR=/home/shuduo/work/taosdata + +date >> $WORK_DIR/cron.log +echo "Run Test for TDinternal" | tee -a $WORK_DIR/cron.log + +buildTDinternal +runTest +sendReport +stopTaosd + +date >> $WORK_DIR/cron.log +echo "End of TDinternal Test" | tee -a $WORK_DIR/cron.log diff --git a/tests/pytest/account/__init__.py b/tests/pytest/account/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/pytest/account/account_create.py b/tests/pytest/account/account_create.py new file mode 100644 index 0000000000000000000000000000000000000000..c008acccd8d8d33af0ca77bd161d4ab020c1543e --- /dev/null +++ b/tests/pytest/account/account_create.py @@ -0,0 +1,53 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.query("show users") + rows = tdSql.queryRows + + tdSql.execute("create user test PASS 'test' ") + tdSql.query("show users") + tdSql.checkRows(rows + 1) + + tdSql.error("create user tdenginetdenginetdengine PASS 'test' ") + + tdSql.error("create user tdenginet PASS '1234512345123456' ") + + try: + tdSql.execute("create account a&cc PASS 'pass123'") + except Exception as e: + print("create account a&cc PASS 'pass123'") + return + + tdLog.exit("drop built-in user is error.") + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/account/account_del.py b/tests/pytest/account/account_del.py new file mode 100644 index 0000000000000000000000000000000000000000..7f05a39765099e896a56af9cfafcfce3957076e1 --- /dev/null +++ b/tests/pytest/account/account_del.py @@ -0,0 +1,52 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + print("==========step1") + print("drop built-in account") + try: + tdSql.execute("drop account root") + except Exception as e: + if len(e.args) > 0 and 'no rights' != e.args[0]: + tdLog.exit(e) + + print("==========step2") + print("drop built-in user") + try: + tdSql.execute("drop user root") + except Exception as e: + if len(e.args) > 0 and 'no rights' != e.args[0]: + tdLog.exit(e) + return + + tdLog.exit("drop built-in user is error.") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/alter/__init__.py b/tests/pytest/alter/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/pytest/alter/alterColMultiTimes.py b/tests/pytest/alter/alterColMultiTimes.py new file mode 100644 index 0000000000000000000000000000000000000000..173ca8158deeb1e98bd3fc5ff3b942b20b8bc26e --- /dev/null +++ b/tests/pytest/alter/alterColMultiTimes.py @@ -0,0 +1,67 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import random +import string +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def genColList(self): + ''' + generate column list + ''' + col_list = list() + for i in range(1, 18): + col_list.append(f'c{i}') + return col_list + + def genIncreaseValue(self, input_value): + ''' + add ', 1' to end of value every loop + ''' + value_list = list(input_value) + value_list.insert(-1, ", 1") + return ''.join(value_list) + + def insertAlter(self): + ''' + after each alter and insert, when execute 'select * from {tbname};' taosd will coredump + ''' + tbname = ''.join(random.choice(string.ascii_letters.lower()) for i in range(7)) + input_value = '(now, 1)' + tdSql.execute(f'create table {tbname} (ts timestamp, c0 int);') + tdSql.execute(f'insert into {tbname} values {input_value};') + for col in self.genColList(): + input_value = self.genIncreaseValue(input_value) + tdSql.execute(f'alter table {tbname} add column {col} int;') + tdSql.execute(f'insert into {tbname} values {input_value};') + tdSql.query(f'select * from {tbname};') + tdSql.checkRows(18) + + def run(self): + tdSql.prepare() + self.insertAlter() + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/alter/alterTabAddTagWithNULL.py b/tests/pytest/alter/alterTabAddTagWithNULL.py new file mode 100644 index 0000000000000000000000000000000000000000..52bdc0fe75b6edc1d75e8dacd468ea4493c88271 --- /dev/null +++ b/tests/pytest/alter/alterTabAddTagWithNULL.py @@ -0,0 +1,85 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug(f"start to execute {__file__}") + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.execute("drop database if exists db") + tdSql.execute("create database if not exists db keep 36500") + tdSql.execute("use db") + + tdLog.printNoPrefix("==========step1:create table && insert data") + tdSql.execute("create table stbtag (ts timestamp, c1 int) TAGS(t1 int)") + tdSql.execute("create table tag1 using stbtag tags(1)") + + tdLog.printNoPrefix("==========step2:alter stb add tag create new chiltable") + tdSql.execute("alter table stbtag add tag t2 int") + tdSql.execute("alter table stbtag add tag t3 tinyint") + tdSql.execute("alter table stbtag add tag t4 smallint ") + tdSql.execute("alter table stbtag add tag t5 bigint") + tdSql.execute("alter table stbtag add tag t6 float ") + tdSql.execute("alter table stbtag add tag t7 double ") + tdSql.execute("alter table stbtag add tag t8 bool ") + tdSql.execute("alter table stbtag add tag t9 binary(10) ") + tdSql.execute("alter table stbtag add tag t10 nchar(10)") + + tdSql.execute("create table tag2 using stbtag tags(2, 22, 23, 24, 25, 26.1, 27.1, 1, 'binary9', 'nchar10')") + tdSql.query( "select tbname, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10 from stbtag" ) + tdSql.checkData(1, 0, "tag2") + tdSql.checkData(1, 1, 2) + tdSql.checkData(1, 2, 22) + tdSql.checkData(1, 3, 23) + tdSql.checkData(1, 4, 24) + tdSql.checkData(1, 5, 25) + tdSql.checkData(1, 6, 26.1) + tdSql.checkData(1, 7, 27.1) + tdSql.checkData(1, 8, 1) + tdSql.checkData(1, 9, "binary9") + tdSql.checkData(1, 10, "nchar10") + + tdLog.printNoPrefix("==========step3:alter stb drop tag create new chiltable") + tdSql.execute("alter table stbtag drop tag t2 ") + tdSql.execute("alter table stbtag drop tag t3 ") + tdSql.execute("alter table stbtag drop tag t4 ") + tdSql.execute("alter table stbtag drop tag t5 ") + tdSql.execute("alter table stbtag drop tag t6 ") + tdSql.execute("alter table stbtag drop tag t7 ") + tdSql.execute("alter table stbtag drop tag t8 ") + tdSql.execute("alter table stbtag drop tag t9 ") + tdSql.execute("alter table stbtag drop tag t10 ") + + tdSql.execute("create table tag3 using stbtag tags(3)") + tdSql.query("select * from stbtag where tbname like 'tag3' ") + tdSql.checkCols(3) + tdSql.query("select tbname, t1 from stbtag where tbname like 'tag3' ") + tdSql.checkData(0, 1, 3) + + + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/alter/alterTimestampColDataProcess.py b/tests/pytest/alter/alterTimestampColDataProcess.py new file mode 100644 index 0000000000000000000000000000000000000000..b235a8bf4c0c7166b66f87642d477ba78bccc44d --- /dev/null +++ b/tests/pytest/alter/alterTimestampColDataProcess.py @@ -0,0 +1,73 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug(f"start to execute {__file__}") + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.execute("drop database if exists db") + tdSql.execute("create database if not exists db keep 36500") + tdSql.execute("use db") + + tdLog.printNoPrefix("==========step1:create table && insert data") + # timestamp list: + # 0 -> "1970-01-01 08:00:00" | -28800000 -> "1970-01-01 00:00:00" | -946800000000 -> "1940-01-01 00:00:00" + # -631180800000 -> "1950-01-01 00:00:00" + ts1 = 0 + ts2 = -28800000 + ts3 = -946800000000 + ts4 = "1950-01-01 00:00:00" + tdSql.execute( + "create table stb2ts (ts timestamp, ts1 timestamp, ts2 timestamp, c1 int, ts3 timestamp) TAGS(t1 int)" + ) + tdSql.execute("create table t2ts1 using stb2ts tags(1)") + + tdSql.execute(f"insert into t2ts1 values ({ts1}, {ts1}, {ts1}, 1, {ts1})") + tdSql.execute(f"insert into t2ts1 values ({ts2}, {ts2}, {ts2}, 2, {ts2})") + tdSql.execute(f"insert into t2ts1 values ({ts3}, {ts3}, {ts3}, 4, {ts3})") + tdSql.execute(f"insert into t2ts1 values ('{ts4}', '{ts4}', '{ts4}', 3, '{ts4}')") + + tdLog.printNoPrefix("==========step2:check inserted data") + tdSql.query("select * from stb2ts where ts1=0 and ts2='1970-01-01 08:00:00' ") + tdSql.checkRows(1) + tdSql.checkData(0, 4,'1970-01-01 08:00:00') + + tdSql.query("select * from stb2ts where ts1=-28800000 and ts2='1970-01-01 00:00:00' ") + tdSql.checkRows(1) + tdSql.checkData(0, 4, '1970-01-01 00:00:00') + + tdSql.query("select * from stb2ts where ts1=-946800000000 and ts2='1940-01-01 00:00:00' ") + tdSql.checkRows(1) + tdSql.checkData(0, 4, '1940-01-01 00:00:00') + + tdSql.query("select * from stb2ts where ts1=-631180800000 and ts2='1950-01-01 00:00:00' ") + tdSql.checkRows(1) + tdSql.checkData(0, 4, '1950-01-01 00:00:00') + + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/alter/alter_cacheLastRow.py b/tests/pytest/alter/alter_cacheLastRow.py new file mode 100644 index 0000000000000000000000000000000000000000..36a2864d0f91cf485505ee105870a98df71c4df8 --- /dev/null +++ b/tests/pytest/alter/alter_cacheLastRow.py @@ -0,0 +1,109 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import tdDnodes +from datetime import datetime + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def run(self): + tdSql.prepare() + tdSql.query('show databases') + tdSql.checkData(0,15,0) + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath + "/build/bin/" + + #write 5M rows into db, then restart to force the data move into disk. + #create 500 tables + os.system("%staosdemo -f tools/taosdemoAllTest/insert_5M_rows.json -y " % binPath) + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.execute('use db') + + #prepare to query 500 tables last_row() + tableName = [] + for i in range(500): + tableName.append(f"stb_{i}") + tdSql.execute('use db') + lastRow_Off_start = datetime.now() + + slow = 0 #count time where lastRow on is slower + for i in range(5): + #switch lastRow to off and check + tdSql.execute('alter database db cachelast 0') + tdSql.query('show databases') + tdSql.checkData(0,15,0) + + #run last_row(*) query 500 times + for i in range(500): + tdSql.execute(f'SELECT LAST_ROW(*) FROM {tableName[i]}') + lastRow_Off_end = datetime.now() + + tdLog.debug(f'time used:{lastRow_Off_end-lastRow_Off_start}') + + #switch lastRow to on and check + tdSql.execute('alter database db cachelast 1') + tdSql.query('show databases') + tdSql.checkData(0,15,1) + + #run last_row(*) query 500 times + tdSql.execute('use db') + lastRow_On_start = datetime.now() + for i in range(500): + tdSql.execute(f'SELECT LAST_ROW(*) FROM {tableName[i]}') + lastRow_On_end = datetime.now() + + tdLog.debug(f'time used:{lastRow_On_end-lastRow_On_start}') + + #check which one used more time + if (lastRow_Off_end-lastRow_Off_start > lastRow_On_end-lastRow_On_start): + pass + else: + slow += 1 + tdLog.debug(slow) + if slow > 1: #tolerance for the first time + tdLog.exit('lastRow hot alter failed') + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/alter/alter_create_exception.py b/tests/pytest/alter/alter_create_exception.py new file mode 100644 index 0000000000000000000000000000000000000000..19f1ba9464617fe120740ec26a411a216cfd9a48 --- /dev/null +++ b/tests/pytest/alter/alter_create_exception.py @@ -0,0 +1,91 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +#TODO: after TD-4518 and TD-4510 is resolved, add the exception test case for these situations + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + #checking string input exception for alter + tdSql.error("alter database db keep '10'") + tdSql.error('alter database db keep "10"') + tdSql.error("alter database db keep '\t'") + tdSql.error("alter database db keep \'\t\'") + tdSql.error('alter database db keep "a"') + tdSql.error('alter database db keep "1.4"') + tdSql.error("alter database db blocks '10'") + tdSql.error('alter database db comp "0"') + tdSql.execute('drop database if exists db') + + #checking string input exception for create + tdSql.error("create database db comp '0'") + tdSql.error('create database db comp "1"') + tdSql.error("create database db comp '\t'") + tdSql.error("alter database db keep \'\t\'") + tdSql.error('create database db comp "a"') + tdSql.error('create database db comp "1.4"') + tdSql.error("create database db blocks '10'") + tdSql.error('create database db keep "3650"') + tdSql.error('create database db fsync "3650"') + tdSql.execute('create database db precision "us"') + tdSql.query('show databases') + tdSql.checkData(0,16,'us') + tdSql.execute('drop database if exists db') + + #checking float input exception for create + tdSql.error("create database db fsync 7.3") + tdSql.error("create database db fsync 0.0") + tdSql.error("create database db fsync -5.32") + tdSql.error('create database db comp 7.2') + tdSql.error("create database db blocks 5.87") + tdSql.error('create database db keep 15.4') + + #checking float input exception for insert + tdSql.execute('create database db') + tdSql.error('alter database db blocks 5.9') + tdSql.error('alter database db blocks -4.7') + tdSql.error('alter database db blocks 0.0') + tdSql.error('alter database db keep 15.4') + tdSql.error('alter database db comp 2.67') + + #checking additional exception param for alter keep + tdSql.error('alter database db keep 365001') + tdSql.error('alter database db keep 364999,365000,365001') + tdSql.error('alter database db keep -10') + tdSql.error('alter database db keep 5') + tdSql.error('alter database db keep ') + tdSql.error('alter database db keep 40,a,60') + tdSql.error('alter database db keep ,,60,') + tdSql.error('alter database db keep \t') + tdSql.execute('alter database db keep \t50') + tdSql.query('show databases') + tdSql.checkData(0,7,'50,50,50') + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/alter/alter_debugFlag.py b/tests/pytest/alter/alter_debugFlag.py new file mode 100644 index 0000000000000000000000000000000000000000..38d972b58252a704420af0dda7c091c22c894ecd --- /dev/null +++ b/tests/pytest/alter/alter_debugFlag.py @@ -0,0 +1,54 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import random +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import tdDnodes + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + flagList=["debugflag", "cdebugflag", "tmrDebugFlag", "uDebugFlag", "rpcDebugFlag"] + + for flag in flagList: + tdSql.execute("alter local %s 131" % flag) + tdSql.execute("alter local %s 135" % flag) + tdSql.execute("alter local %s 143" % flag) + randomFlag = random.randint(100, 250) + if randomFlag != 131 and randomFlag != 135 and randomFlag != 143: + tdSql.error("alter local %s %d" % (flag, randomFlag)) + + tdSql.query("show dnodes") + dnodeId = tdSql.getData(0, 0) + + for flag in flagList: + tdSql.execute("alter dnode %d %s 131" % (dnodeId, flag)) + tdSql.execute("alter dnode %d %s 135" % (dnodeId, flag)) + tdSql.execute("alter dnode %d %s 143" % (dnodeId, flag)) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/alter/alter_keep.py b/tests/pytest/alter/alter_keep.py new file mode 100644 index 0000000000000000000000000000000000000000..b23f364fc6f16973f8e7b5e6159f95718df9b91b --- /dev/null +++ b/tests/pytest/alter/alter_keep.py @@ -0,0 +1,208 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +import time + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def alterKeepCommunity(self): + tdLog.notice('running Keep Test, Community Version') + tdLog.notice('running parameter test for keep during create') + #testing keep parameter during create + tdSql.query('show databases') + tdSql.checkData(0,7,'3650') + tdSql.execute('drop database db') + + tdSql.execute('create database db keep 100') + tdSql.query('show databases') + tdSql.checkData(0,7,'100') + tdSql.execute('drop database db') + + tdSql.error('create database db keep ') + tdSql.error('create database db keep 0') + tdSql.error('create database db keep 10,20') + tdSql.error('create database db keep 10,20,30') + tdSql.error('create database db keep 20,30,40,50') + + #testing keep parameter during alter + tdSql.execute('create database db') + tdLog.notice('running parameter test for keep during alter') + + tdSql.execute('alter database db keep 100') + tdSql.query('show databases') + tdSql.checkData(0,7,'100') + + tdSql.error('alter database db keep ') + tdSql.error('alter database db keep 0') + tdSql.error('alter database db keep 10,20') + tdSql.error('alter database db keep 10,20,30') + tdSql.error('alter database db keep 20,30,40,50') + tdSql.query('show databases') + tdSql.checkData(0,7,'100') + + def alterKeepEnterprise(self): + tdLog.notice('running Keep Test, Enterprise Version') + #testing keep parameter during create + tdLog.notice('running parameter test for keep during create') + + tdSql.query('show databases') + tdSql.checkData(0,7,'3650,3650,3650') + tdSql.execute('drop database db') + + tdSql.execute('create database db keep 100') + tdSql.query('show databases') + tdSql.checkData(0,7,'100,100,100') + tdSql.execute('drop database db') + + tdSql.execute('create database db keep 20, 30') + tdSql.query('show databases') + tdSql.checkData(0,7,'20,30,30') + tdSql.execute('drop database db') + + tdSql.execute('create database db keep 30,40,50') + tdSql.query('show databases') + tdSql.checkData(0,7,'30,40,50') + tdSql.execute('drop database db') + + tdSql.error('create database db keep ') + tdSql.error('create database db keep 20,30,40,50') + tdSql.error('create database db keep 0') + tdSql.error('create database db keep 100,50') + tdSql.error('create database db keep 100,40,50') + tdSql.error('create database db keep 20,100,50') + tdSql.error('create database db keep 50,60,20') + + #testing keep parameter during alter + tdSql.execute('create database db') + tdLog.notice('running parameter test for keep during alter') + + tdSql.execute('alter database db keep 10') + tdSql.query('show databases') + tdSql.checkData(0,7,'10,10,10') + + tdSql.execute('alter database db keep 20,30') + tdSql.query('show databases') + tdSql.checkData(0,7,'20,30,30') + + tdSql.execute('alter database db keep 100,200,300') + tdSql.query('show databases') + tdSql.checkData(0,7,'100,200,300') + + tdSql.error('alter database db keep ') + tdSql.error('alter database db keep 20,30,40,50') + tdSql.error('alter database db keep 0') + tdSql.error('alter database db keep 100,50') + tdSql.error('alter database db keep 100,40,50') + tdSql.error('alter database db keep 20,100,50') + tdSql.error('alter database db keep 50,60,20') + tdSql.query('show databases') + tdSql.checkData(0,7,'100,200,300') + + + def run(self): + tdSql.prepare() + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + tdLog.debug('running enterprise test') + self.alterKeepEnterprise() + else: + tdLog.debug('running community test') + self.alterKeepCommunity() + + tdSql.prepare() + + + ## preset the keep + tdSql.prepare() + + tdLog.notice('testing if alter will cause any error') + tdSql.execute('create table tb (ts timestamp, speed int)') + tdSql.execute('alter database db keep 10,10,10') + tdSql.execute('insert into tb values (now, 10)') + tdSql.execute('insert into tb values (now + 10m, 10)') + tdSql.query('select * from tb') + tdSql.checkRows(2) + + + #after alter from small to large, check if the alter if functioning + #test if change through test.py is consistent with change from taos client + #test case for TD-4459 and TD-4445 + tdLog.notice('testing keep will be altered changing from small to big') + tdSql.execute('alter database db keep 40,40,40') + tdSql.query('show databases') + tdSql.checkData(0,7,'40,40,40') + tdSql.error('insert into tb values (now-60d, 10)') + tdSql.execute('insert into tb values (now-30d, 10)') + tdSql.query('select * from tb') + tdSql.checkRows(3) + + rowNum = 3 + for i in range(30): + rowNum += 1 + tdSql.execute('alter database db keep 20,20,20') + tdSql.execute('alter database db keep 40,40,40') + tdSql.query('show databases') + tdSql.checkData(0,7,'40,40,40') + tdSql.error('insert into tb values (now-60d, 10)') + tdSql.execute('insert into tb values (now-30d, 10)') + tdSql.query('select * from tb') + tdSql.checkRows(rowNum) + + tdLog.notice('testing keep will be altered changing from big to small') + tdSql.execute('alter database db keep 10,10,10') + tdSql.query('show databases') + tdSql.checkData(0,7,'10,10,10') + tdSql.error('insert into tb values (now-15d, 10)') + tdSql.query('select * from tb') + tdSql.checkRows(2) + + rowNum = 2 + tdLog.notice('testing keep will be altered if sudden change from small to big') + for i in range(30): + tdSql.execute('alter database db keep 14,14,14') + tdSql.execute('alter database db keep 16,16,16') + tdSql.execute('insert into tb values (now-15d, 10)') + tdSql.query('select * from tb') + rowNum += 1 + tdSql.checkRows(rowNum) + + tdLog.notice('testing keep will be altered if sudden change from big to small') + tdSql.execute('alter database db keep 16,16,16') + tdSql.execute('alter database db keep 14,14,14') + tdSql.error('insert into tb values (now-15d, 10)') + tdSql.query('select * from tb') + tdSql.checkRows(2) + + tdLog.notice('testing data will show up again when keep is being changed to large value') + tdSql.execute('alter database db keep 40,40,40') + tdSql.query('select * from tb') + tdSql.checkRows(63) + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/alter/alter_replica.py b/tests/pytest/alter/alter_replica.py new file mode 100644 index 0000000000000000000000000000000000000000..6cf0f65825920a10ab1a8de175325e535f5828e6 --- /dev/null +++ b/tests/pytest/alter/alter_replica.py @@ -0,0 +1,129 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self): + tdLog.debug("start to execute %s" % __file__) + tdLog.info("prepare cluster") + tdDnodes.stopAll() + tdDnodes.deploy(1) + tdDnodes.start(1) + + self.conn = taos.connect(config=tdDnodes.getSimCfgPath()) + tdSql.init(self.conn.cursor()) + tdSql.execute('reset query cache') + tdSql.execute('create dnode 192.168.0.2') + tdDnodes.deploy(2) + tdDnodes.start(2) + + self.conn = taos.connect(config=tdDnodes.getSimCfgPath()) + tdSql.init(self.conn.cursor()) + tdSql.execute('reset query cache') + tdSql.execute('create dnode 192.168.0.3') + tdDnodes.deploy(3) + tdDnodes.start(3) + + def run(self): + tdSql.execute('create database db replica 3 days 7') + tdSql.execute('use db') + for tid in range(1, 11): + tdSql.execute('create table tb%d(ts timestamp, i int)' % tid) + tdLog.sleep(10) + + tdLog.info("================= step1") + startTime = 1520000010000 + for rid in range(1, 11): + for tid in range(1, 11): + tdSql.execute( + 'insert into tb%d values(%ld, %d)' % + (tid, startTime, rid)) + startTime += 1 + tdSql.query('select * from tb1') + tdSql.checkRows(10) + tdLog.sleep(5) + + tdLog.info("================= step2") + tdSql.execute('alter database db replica 2') + tdLog.sleep(10) + + tdLog.info("================= step3") + for rid in range(1, 11): + for tid in range(1, 11): + tdSql.execute( + 'insert into tb%d values(%ld, %d)' % + (tid, startTime, rid)) + startTime += 1 + tdSql.query('select * from tb1') + tdSql.checkRows(20) + tdLog.sleep(5) + + tdLog.info("================= step4") + tdSql.execute('alter database db replica 1') + tdLog.sleep(10) + + tdLog.info("================= step5") + for rid in range(1, 11): + for tid in range(1, 11): + tdSql.execute( + 'insert into tb%d values(%ld, %d)' % + (tid, startTime, rid)) + startTime += 1 + tdSql.query('select * from tb1') + tdSql.checkRows(30) + tdLog.sleep(5) + + tdLog.info("================= step6") + tdSql.execute('alter database db replica 2') + tdLog.sleep(10) + + tdLog.info("================= step7") + for rid in range(1, 11): + for tid in range(1, 11): + tdSql.execute( + 'insert into tb%d values(%ld, %d)' % + (tid, startTime, rid)) + startTime += 1 + tdSql.query('select * from tb1') + tdSql.checkRows(40) + tdLog.sleep(5) + + tdLog.info("================= step8") + tdSql.execute('alter database db replica 3') + tdLog.sleep(10) + + tdLog.info("================= step9") + for rid in range(1, 11): + for tid in range(1, 11): + tdSql.execute( + 'insert into tb%d values(%ld, %d)' % + (tid, startTime, rid)) + startTime += 1 + tdSql.query('select * from tb1') + tdSql.checkRows(50) + tdLog.sleep(5) + + def stop(self): + tdSql.close() + self.conn.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addCluster(__file__, TDTestCase()) diff --git a/tests/pytest/alter/alter_stable.py b/tests/pytest/alter/alter_stable.py new file mode 100644 index 0000000000000000000000000000000000000000..6dad43313248388ab34a51f6dd40414f67ebdb7f --- /dev/null +++ b/tests/pytest/alter/alter_stable.py @@ -0,0 +1,142 @@ +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self.types = [ + "int", + "bigint", + "float", + "double", + "smallint", + "tinyint", + "int unsigned", + "bigint unsigned", + "smallint unsigned", + "tinyint unsigned", + "binary(10)", + "nchar(10)", + "timestamp"] + self.rowNum = 300 + self.ts = 1537146000000 + self.step = 1000 + self.sqlHead = "select count(*), count(c1) " + self.sqlTail = " from stb" + + def addColumnAndCount(self): + for colIdx in range(len(self.types)): + tdSql.execute( + "alter table stb add column c%d %s" % + (colIdx + 2, self.types[colIdx])) + self.sqlHead = self.sqlHead + ",count(c%d) " % (colIdx + 2) + tdSql.query(self.sqlHead + self.sqlTail) + + # count non-NULL values in each column + tdSql.checkData(0, 0, self.rowNum * (colIdx + 1)) + tdSql.checkData(0, 1, self.rowNum * (colIdx + 1)) + for i in range(2, colIdx + 2): + print("check1: i=%d colIdx=%d" % (i, colIdx)) + tdSql.checkData(0, i, self.rowNum * (colIdx - i + 2)) + + # insert more rows + for k in range(self.rowNum): + self.ts += self.step + sql = "insert into tb values (%d, %d" % (self.ts, colIdx + 2) + for j in range(colIdx + 1): + sql += ", %d" % (colIdx + 2) + sql += ")" + tdSql.execute(sql) + + # count non-NULL values in each column + tdSql.query(self.sqlHead + self.sqlTail) + tdSql.checkData(0, 0, self.rowNum * (colIdx + 2)) + tdSql.checkData(0, 1, self.rowNum * (colIdx + 2)) + for i in range(2, colIdx + 2): + print("check2: i=%d colIdx=%d" % (i, colIdx)) + tdSql.checkData(0, i, self.rowNum * (colIdx - i + 3)) + + def dropColumnAndCount(self): + tdSql.query(self.sqlHead + self.sqlTail) + res = [] + for i in range(len(self.types)): + res.append(tdSql.getData(0, i + 2)) + + print(res) + + for colIdx in range(len(self.types), 0, -1): + tdSql.execute("alter table stb drop column c%d" % (colIdx + 2)) + # self.sqlHead = self.sqlHead + ",count(c%d) " %(colIdx + 2) + tdSql.query(self.sqlHead + self.sqlTail) + + # count non-NULL values in each column + tdSql.checkData(0, 0, self.rowNum * (colIdx + 1)) + tdSql.checkData(0, 1, self.rowNum * (colIdx + 1)) + for i in range(2, colIdx + 2): + print("check1: i=%d colIdx=%d" % (i, colIdx)) + tdSql.checkData(0, i, self.rowNum * (colIdx - i + 2)) + + # insert more rows + for k in range(self.rowNum): + self.ts += self.step + sql = "insert into tb values (%d, %d" % (self.ts, colIdx + 2) + for j in range(colIdx + 1): + sql += ", %d" % (colIdx + 2) + sql += ")" + tdSql.execute(sql) + + # count non-NULL values in each column + tdSql.query(self.sqlHead + self.sqlTail) + tdSql.checkData(0, 0, self.rowNum * (colIdx + 2)) + tdSql.checkData(0, 1, self.rowNum * (colIdx + 2)) + for i in range(2, colIdx + 2): + print("check2: i=%d colIdx=%d" % (i, colIdx)) + tdSql.checkData(0, i, self.rowNum * (colIdx - i + 3)) + + def run(self): + # Setup params + db = "db" + + # Create db + tdSql.execute("drop database if exists %s" % (db)) + tdSql.execute("reset query cache") + tdSql.execute("create database %s maxrows 200 maxtables 4" % (db)) + tdSql.execute("use %s" % (db)) + + # Create a table with one colunm of int type and insert 300 rows + tdLog.info("Create stb and tb") + tdSql.execute("create table stb (ts timestamp, c1 int) tags (tg1 int)") + tdSql.execute("create table tb using stb tags (0)") + tdLog.info("Insert %d rows into tb" % (self.rowNum)) + for k in range(1, self.rowNum + 1): + self.ts += self.step + tdSql.execute("insert into tb values (%d, 1)" % (self.ts)) + + # Alter tb and add a column of smallint type, then query tb to see if + # all added column are NULL + self.addColumnAndCount() + tdDnodes.stop(1) + time.sleep(5) + tdDnodes.start(1) + time.sleep(5) + tdSql.query(self.sqlHead + self.sqlTail) + for i in range(2, len(self.types) + 2): + tdSql.checkData(0, i, self.rowNum * (len(self.types) + 2 - i)) + + self.dropColumnAndCount() + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +#tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/alter/alter_table.py b/tests/pytest/alter/alter_table.py new file mode 100644 index 0000000000000000000000000000000000000000..33e0aec72756418fca41ef72d48e442da5aa135d --- /dev/null +++ b/tests/pytest/alter/alter_table.py @@ -0,0 +1,161 @@ +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self.types = [ + "int", + "bigint", + "float", + "double", + "smallint", + "tinyint", + "int unsigned", + "bigint unsigned", + "smallint unsigned", + "tinyint unsigned", + "binary(10)", + "nchar(10)", + "timestamp"] + self.rowNum = 300 + self.ts = 1537146000000 + self.step = 1000 + self.sqlHead = "select count(*), count(c1) " + self.sqlTail = " from tb" + + def addColumnAndCount(self): + for colIdx in range(len(self.types)): + tdSql.execute( + "alter table tb add column c%d %s" % + (colIdx + 2, self.types[colIdx])) + self.sqlHead = self.sqlHead + ",count(c%d) " % (colIdx + 2) + tdSql.query(self.sqlHead + self.sqlTail) + + # count non-NULL values in each column + tdSql.checkData(0, 0, self.rowNum * (colIdx + 1)) + tdSql.checkData(0, 1, self.rowNum * (colIdx + 1)) + for i in range(2, colIdx + 2): + print("check1: i=%d colIdx=%d" % (i, colIdx)) + tdSql.checkData(0, i, self.rowNum * (colIdx - i + 2)) + + # insert more rows + for k in range(self.rowNum): + self.ts += self.step + sql = "insert into tb values (%d, %d" % (self.ts, colIdx + 2) + for j in range(colIdx + 1): + sql += ", %d" % (colIdx + 2) + sql += ")" + tdSql.execute(sql) + + # count non-NULL values in each column + tdSql.query(self.sqlHead + self.sqlTail) + tdSql.checkData(0, 0, self.rowNum * (colIdx + 2)) + tdSql.checkData(0, 1, self.rowNum * (colIdx + 2)) + for i in range(2, colIdx + 2): + print("check2: i=%d colIdx=%d" % (i, colIdx)) + tdSql.checkData(0, i, self.rowNum * (colIdx - i + 3)) + + def dropColumnAndCount(self): + + tdSql.query(self.sqlHead + self.sqlTail) + res = [] + for i in range(len(self.types)): + res[i] = tdSql.getData(0, i + 2) + + print(res.join) + + for colIdx in range(len(self.types), 0, -1): + tdSql.execute("alter table tb drop column c%d" % (colIdx + 2)) + # self.sqlHead = self.sqlHead + ",count(c%d) " %(colIdx + 2) + tdSql.query(self.sqlHead + self.sqlTail) + + # count non-NULL values in each column + tdSql.checkData(0, 0, self.rowNum * (colIdx + 1)) + tdSql.checkData(0, 1, self.rowNum * (colIdx + 1)) + for i in range(2, colIdx + 2): + print("check1: i=%d colIdx=%d" % (i, colIdx)) + tdSql.checkData(0, i, self.rowNum * (colIdx - i + 2)) + + # insert more rows + for k in range(self.rowNum): + self.ts += self.step + sql = "insert into tb values (%d, %d" % (self.ts, colIdx + 2) + for j in range(colIdx + 1): + sql += ", %d" % (colIdx + 2) + sql += ")" + tdSql.execute(sql) + + # count non-NULL values in each column + tdSql.query(self.sqlHead + self.sqlTail) + tdSql.checkData(0, 0, self.rowNum * (colIdx + 2)) + tdSql.checkData(0, 1, self.rowNum * (colIdx + 2)) + for i in range(2, colIdx + 2): + print("check2: i=%d colIdx=%d" % (i, colIdx)) + tdSql.checkData(0, i, self.rowNum * (colIdx - i + 3)) + + def alter_table_255_times(self): # add case for TD-6207 + for i in range(255): + tdLog.info("alter table st add column cb%d int"%i) + tdSql.execute("alter table st add column cb%d int"%i) + tdSql.execute("insert into t0 (ts,c1) values(now,1)") + tdSql.execute("reset query cache") + tdSql.query("select * from st") + tdSql.execute("create table mt(ts timestamp, i int)") + tdSql.execute("insert into mt values(now,11)") + tdSql.query("select * from mt") + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("describe db.st") + + def run(self): + # Setup params + db = "db" + + # Create db + tdSql.execute("drop database if exists %s" % (db)) + tdSql.execute("reset query cache") + tdSql.execute("create database %s maxrows 200" % (db)) + tdSql.execute("use %s" % (db)) + + # Create a table with one colunm of int type and insert 300 rows + tdLog.info("create table tb") + tdSql.execute("create table tb (ts timestamp, c1 int)") + tdLog.info("Insert %d rows into tb" % (self.rowNum)) + for k in range(1, self.rowNum + 1): + self.ts += self.step + tdSql.execute("insert into tb values (%d, 1)" % (self.ts)) + + # Alter tb and add a column of smallint type, then query tb to see if + # all added column are NULL + self.addColumnAndCount() + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query(self.sqlHead + self.sqlTail) + size = len(self.types) + 2 + for i in range(2, size): + tdSql.checkData(0, i, self.rowNum * (size - i)) + + + tdSql.execute("create table st(ts timestamp, c1 int) tags(t1 float,t2 int,t3 double)") + tdSql.execute("create table t0 using st tags(null,1,2.3)") + tdSql.execute("alter table t0 set tag t1=2.1") + + tdSql.query("show tables") + tdSql.checkRows(2) + self.alter_table_255_times() + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/alter/alter_table_crash.py b/tests/pytest/alter/alter_table_crash.py new file mode 100644 index 0000000000000000000000000000000000000000..2ec24860db9c078445cd186807a4c1834469f909 --- /dev/null +++ b/tests/pytest/alter/alter_table_crash.py @@ -0,0 +1,91 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + def run(self): + tdSql.prepare() + + print("==============Case 1: add column, restart taosd, drop the same colum then add it back") + tdSql.execute( + "create table st(ts timestamp, speed int) tags(loc nchar(20))") + tdSql.execute( + "insert into t1 using st tags('beijing') values(now, 1)") + tdSql.execute( + "alter table st add column tbcol binary(20)") + + # restart taosd + tdDnodes.forcestop(1) + tdDnodes.start(1) + + tdSql.execute( + "alter table st drop column tbcol") + tdSql.execute( + "alter table st add column tbcol binary(20)") + + tdSql.query("select * from st") + tdSql.checkRows(1) + + print("==============Case 2: keep adding columns, restart taosd") + tdSql.execute( + "create table dt(ts timestamp, tbcol1 tinyint) tags(tgcol1 tinyint)") + tdSql.execute( + "alter table dt add column tbcol2 int") + tdSql.execute( + "alter table dt add column tbcol3 smallint") + tdSql.execute( + "alter table dt add column tbcol4 bigint") + tdSql.execute( + "alter table dt add column tbcol5 float") + tdSql.execute( + "alter table dt add column tbcol6 double") + tdSql.execute( + "alter table dt add column tbcol7 bool") + tdSql.execute( + "alter table dt add column tbcol8 nchar(20)") + tdSql.execute( + "alter table dt add column tbcol9 binary(20)") + tdSql.execute( + "alter table dt add column tbcol10 tinyint unsigned") + tdSql.execute( + "alter table dt add column tbcol11 int unsigned") + tdSql.execute( + "alter table dt add column tbcol12 smallint unsigned") + tdSql.execute( + "alter table dt add column tbcol13 bigint unsigned") + + # restart taosd + tdDnodes.forcestop(1) + tdDnodes.start(1) + + tdSql.query("select * from dt") + tdSql.checkRows(0) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/alter/db_update_options.py b/tests/pytest/alter/db_update_options.py new file mode 100644 index 0000000000000000000000000000000000000000..224e0f25b074deed55802b9ba847f7f845716a23 --- /dev/null +++ b/tests/pytest/alter/db_update_options.py @@ -0,0 +1,71 @@ + +# -*- coding: utf-8 -*- + +import random +import string +import subprocess +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + def run(self): + tdLog.debug("check database") + tdSql.prepare() + + # check default update value + sql = "create database if not exists db" + tdSql.execute(sql) + tdSql.query('show databases') + tdSql.checkRows(1) + tdSql.checkData(0,16,0) + + sql = "alter database db update 1" + + # check update value + tdSql.execute(sql) + tdSql.query('show databases') + tdSql.checkRows(1) + tdSql.checkData(0,16,1) + + + sql = "alter database db update 0" + tdSql.execute(sql) + tdSql.query('show databases') + tdSql.checkRows(1) + tdSql.checkData(0,16,0) + + sql = "alter database db update -1" + tdSql.error(sql) + + sql = "alter database db update 100" + tdSql.error(sql) + + tdSql.query('show databases') + tdSql.checkRows(1) + tdSql.checkData(0,16,0) + + tdSql.execute('drop database db') + tdSql.error('create database db update 100') + tdSql.error('create database db update -1') + + tdSql.execute('create database db update 1') + + tdSql.query('show databases') + tdSql.checkRows(1) + tdSql.checkData(0,16,1) + + tdSql.execute('drop database db') + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/alter/file_corrupt.py b/tests/pytest/alter/file_corrupt.py new file mode 100644 index 0000000000000000000000000000000000000000..28d50cdd38c9e7359f67996713f746fb0c213edb --- /dev/null +++ b/tests/pytest/alter/file_corrupt.py @@ -0,0 +1,77 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + tdSql.execute( + 'create table st (ts timestamp, v1 int, v2 int, v3 int, v4 int, v5 int) tags (t int)') + + totalTables = 100 + batchSize = 500 + totalBatch = 60 + + tdLog.info( + "create %d tables, insert %d rows per table" % + (totalTables, batchSize * totalBatch)) + + for t in range(0, totalTables): + tdSql.execute('create table t%d using st tags(%d)' % (t, t)) + # 2019-06-10 00:00:00 + beginTs = 1560096000000 + interval = 10000 + for r in range(0, totalBatch): + sql = 'insert into t%d values ' % (t) + for b in range(0, batchSize): + ts = beginTs + (r * batchSize + b) * interval + sql += '(%d, 1, 2, 3, 4, 5)' % (ts) + tdSql.execute(sql) + + tdLog.info("insert data finished") + tdSql.execute('alter table st add column v6 int') + tdLog.sleep(5) + tdLog.info("alter table finished") + + tdSql.query("select count(*) from t50") + tdSql.checkData(0, 0, (int)(batchSize * totalBatch)) + + tdLog.info("insert") + tdSql.execute( + "insert into t50 values ('2019-06-13 07:59:55.000', 1, 2, 3, 4, 5, 6)") + + tdLog.info("import") + tdSql.execute( + "import into t50 values ('2019-06-13 07:59:55.000', 1, 2, 3, 4, 5, 6)") + + tdLog.info("query") + tdSql.query("select count(*) from t50") + tdSql.checkData(0, 0, batchSize * totalBatch + 1) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/bug2265.py b/tests/pytest/bug2265.py new file mode 100644 index 0000000000000000000000000000000000000000..e78233928fcd7f2348dc83c64b85cca3cf983477 --- /dev/null +++ b/tests/pytest/bug2265.py @@ -0,0 +1,85 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import taos +if __name__ == "__main__": + + logSql = True + deployPath = "" + testCluster = False + valgrind = 0 + + print("start to execute %s" % __file__) + tdDnodes.init(deployPath) + tdDnodes.setTestCluster(testCluster) + tdDnodes.setValgrind(valgrind) + + tdDnodes.stopAll() + tdDnodes.addSimExtraCfg("maxSQLLength", "1048576") + tdDnodes.deploy(1) + tdDnodes.start(1) + host = '127.0.0.1' + + tdLog.info("Procedures for tdengine deployed in %s" % (host)) + + tdCases.logSql(logSql) + print('1') + conn = taos.connect( + host, + config=tdDnodes.getSimCfgPath()) + + tdSql.init(conn.cursor(), True) + + print("==========step1") + print("create table ") + tdSql.execute("create database db") + tdSql.execute("use db") + tdSql.execute("create table t1 (ts timestamp, c1 int,c2 int ,c3 int)") + + print("==========step2") + print("insert maxSQLLength data ") + data = 'insert into t1 values' + ts = 1604298064000 + i = 0 + while ((len(data)<(1024*1024)) & (i < 32767 - 1) ): + data += '(%s,%d,%d,%d)'%(ts+i,i%1000,i%1000,i%1000) + i+=1 + tdSql.execute(data) + + print("==========step4") + print("insert data batch larger than 32767 ") + i = 0 + while ((len(data)<(1024*1024)) & (i < 32767) ): + data += '(%s,%d,%d,%d)'%(ts+i,i%1000,i%1000,i%1000) + i+=1 + tdSql.error(data) + + print("==========step4") + print("insert data larger than maxSQLLength ") + tdSql.execute("create table t2 (ts timestamp, c1 binary(50))") + data = 'insert into t2 values' + i = 0 + while ((len(data)<(1024*1024)) & (i < 32767 - 1 ) ): + data += '(%s,%s)'%(ts+i,'a'*50) + i+=1 + tdSql.error(data) + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + + diff --git a/tests/pytest/client/alterDatabase.py b/tests/pytest/client/alterDatabase.py new file mode 100644 index 0000000000000000000000000000000000000000..bc8c4fc17ee956ad21525adb0587f925bb35d2bf --- /dev/null +++ b/tests/pytest/client/alterDatabase.py @@ -0,0 +1,54 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdSql.query('select database()') + tdSql.checkData(0, 0, "db") + + tdSql.execute("alter database db comp 2") + tdSql.query("show databases") + tdSql.checkData(0, 14, 2) + + tdSql.execute("alter database db keep 365,365,365") + tdSql.query("show databases") + tdSql.checkData(0, 7, "365,365,365") + + tdSql.error("alter database db quorum 2") + + + tdSql.execute("alter database db blocks 100") + tdSql.query("show databases") + tdSql.checkData(0, 9, 100) + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/client/change_time_1_1.py b/tests/pytest/client/change_time_1_1.py new file mode 100644 index 0000000000000000000000000000000000000000..acdea17fbf1d093cef522d9a99ec17f80b9a4d3b --- /dev/null +++ b/tests/pytest/client/change_time_1_1.py @@ -0,0 +1,88 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.pathFinding import * +from util.dnodes import tdDnodes +from datetime import datetime +import subprocess +import time + +##TODO: this is now automatic, but not sure if this will run through jenkins +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + tdFindPath.init(__file__) + + def run(self): + tdSql.prepare() + binPath = tdFindPath.getTaosdemoPath() + TDenginePath = tdFindPath.getTDenginePath() + + ## change system time to 2020/10/20 + os.system('sudo timedatectl set-ntp off') + tdLog.sleep(10) + os.system('sudo timedatectl set-time 2020-10-20') + + #run taosdemo to insert data. one row per second from 2020/10/11 to 2020/10/20 + #11 data files should be generated + #vnode at TDinternal/community/sim/dnode1/data/vnode + try: + os.system(f"{binPath}taosdemo -f tools/taosdemoAllTest/manual_change_time_1_1_A.json") + commandArray = ['ls', '-l', f'{TDenginePath}/sim/dnode1/data/vnode/vnode2/tsdb/data'] + result = subprocess.run(commandArray, stdout=subprocess.PIPE).stdout.decode('utf-8') + except BaseException: + os.system('sudo timedatectl set-ntp on') + tdLog.sleep(10) + if result.count('data') != 11: + os.system('sudo timedatectl set-ntp on') + tdLog.sleep(10) + tdLog.exit('wrong number of files') + else: + tdLog.debug("data file number correct") + + #move 5 days ahead to 2020/10/25. 4 oldest files should be removed during the new write + #leaving 7 data files. + try: + os.system ('timedatectl set-time 2020-10-25') + os.system(f"{binPath}taosdemo -f tools/taosdemoAllTest/manual_change_time_1_1_B.json") + except BaseException: + os.system('sudo timedatectl set-ntp on') + tdLog.sleep(10) + os.system('sudo timedatectl set-ntp on') + tdLog.sleep(10) + commandArray = ['ls', '-l', f'{TDenginePath}/sim/dnode1/data/vnode/vnode2/tsdb/data'] + result = subprocess.run(commandArray, stdout=subprocess.PIPE).stdout.decode('utf-8') + print(result.count('data')) + if result.count('data') != 7: + tdLog.exit('wrong number of files') + else: + tdLog.debug("data file number correct") + tdSql.query('select first(ts) from stb_0') + tdSql.checkData(0,0,datetime(2020,10,14,8,0,0,0)) #check the last data in the database + os.system('sudo timedatectl set-ntp on') + tdLog.sleep(10) + + def stop(self): + os.system('sudo timedatectl set-ntp on') + tdLog.sleep(10) + tdSql.close() + tdLog.success("alter block manual check finish") + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/client/change_time_1_2.py b/tests/pytest/client/change_time_1_2.py new file mode 100644 index 0000000000000000000000000000000000000000..ec483b00be34ad52c2b22f77ed8d81fdfc43c068 --- /dev/null +++ b/tests/pytest/client/change_time_1_2.py @@ -0,0 +1,100 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import tdDnodes +from util.pathFinding import * +from datetime import datetime +import subprocess + +##TODO: this is now automatic, but not sure if this will run through jenkins +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + tdFindPath.init(__file__) + + def run(self): + tdSql.prepare() + binPath = tdFindPath.getTaosdemoPath() + TDenginePath = tdFindPath.getTDenginePath() + + ## change system time to 2020/10/20 + os.system ('timedatectl set-ntp off') + tdLog.sleep(10) + os.system ('timedatectl set-time 2020-10-20') + + #run taosdemo to insert data. one row per second from 2020/10/11 to 2020/10/20 + #11 data files should be generated + #vnode at TDinternal/community/sim/dnode1/data/vnode + try: + os.system(f"{binPath}taosdemo -f tools/taosdemoAllTest/manual_change_time_1_1_A.json") + commandArray = ['ls', '-l', f'{TDenginePath}/sim/dnode1/data/vnode/vnode2/tsdb/data'] + result = subprocess.run(commandArray, stdout=subprocess.PIPE).stdout.decode('utf-8') + except BaseException: + os.system('sudo timedatectl set-ntp on') + tdLog.sleep(10) + + if result.count('data') != 11: + os.system('sudo timedatectl set-ntp on') + tdLog.sleep(10) + tdLog.exit('wrong number of files') + else: + tdLog.debug("data file number correct") + + + try: + tdSql.query('select first(ts) from stb_0') #check the last data in the database + tdSql.checkData(0,0,datetime(2020,10,11,0,0,0,0)) + except BaseException: + os.system('sudo timedatectl set-ntp on') + tdLog.sleep(10) + + #moves 5 days ahead to 2020/10/25 and restart taosd + #4 oldest data file should be removed from tsdb/data + #7 data file should be found + #vnode at TDinternal/community/sim/dnode1/data/vnode + + try: + os.system ('timedatectl set-time 2020-10-25') + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query('select first(ts) from stb_0') + tdSql.checkData(0,0,datetime(2020,10,14,8,0,0,0)) #check the last data in the database + except BaseException: + os.system('sudo timedatectl set-ntp on') + tdLog.sleep(10) + + os.system('sudo timedatectl set-ntp on') + tdLog.sleep(10) + commandArray = ['ls', '-l', f'{TDenginePath}/sim/dnode1/data/vnode/vnode2/tsdb/data'] + result = subprocess.run(commandArray, stdout=subprocess.PIPE).stdout.decode('utf-8') + print(result.count('data')) + if result.count('data') != 7: + tdLog.exit('wrong number of files') + else: + tdLog.debug("data file number correct") + os.system('sudo timedatectl set-ntp on') + tdLog.sleep(10) + + def stop(self): + os.system('sudo timedatectl set-ntp on') + tdSql.close() + tdLog.success("alter block manual check finish") + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/client/client.py b/tests/pytest/client/client.py new file mode 100644 index 0000000000000000000000000000000000000000..b40511094b3bf76825c2572c8ad747807a3f2d65 --- /dev/null +++ b/tests/pytest/client/client.py @@ -0,0 +1,55 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + ret = tdSql.query('select database()') + tdSql.checkData(0, 0, "db") + + ret = tdSql.query('select server_status()') + tdSql.checkData(0, 0, 1) + + ret = tdSql.query('select server_status() as result') + tdSql.checkData(0, 0, 1) + + ret = tdSql.query('show dnodes') + + ret = tdSql.execute('alter dnode "%s" debugFlag 135' % tdSql.getData(0,0)) + tdLog.info('alter dnode "%s" debugFlag 135 -> ret: %d' % (tdSql.getData(0, 0), ret)) + + ret = tdSql.query('show mnodes') + tdSql.checkRows(1) + + ret = tdSql.query('show vgroups') + tdSql.checkRows(0) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/client/noConnectionErrorTest.py b/tests/pytest/client/noConnectionErrorTest.py new file mode 100644 index 0000000000000000000000000000000000000000..2c13016cf19506a6cb76bef1a294e5ec1a9c2b84 --- /dev/null +++ b/tests/pytest/client/noConnectionErrorTest.py @@ -0,0 +1,48 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import tdDnodes + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdDnodes.stop(1) + sql = "use db" + + try: + tdSql.execute(sql) + except Exception as e: + expectError = 'Unable to establish connection' + if expectError in str(e): + pass + else: + caller = inspect.getframeinfo(inspect.stack()[1][1]) + tdLog.exit("%s(%d) failed: sql:%s, expect error not occured" % (caller.filename, caller.lineno, sql)) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/client/taoshellCheckCase.py b/tests/pytest/client/taoshellCheckCase.py new file mode 100644 index 0000000000000000000000000000000000000000..936f7dfa159d2949ed7f029c3f754f6a039bce2d --- /dev/null +++ b/tests/pytest/client/taoshellCheckCase.py @@ -0,0 +1,202 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys, shutil +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import subprocess + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getBuildPath(self) -> str: + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/debug/build/bin")] + break + return buildPath + + def execute_cmd(self,cmd): + out = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,stderr=subprocess.PIPE).stderr.read().decode("utf-8") + if out.find("error:") >=0: + print(cmd) + print(out) + sys.exit() + + + + def run(self): + tdSql.prepare() + build_path = self.getBuildPath() + "/debug/build/bin" + tdLog.info("====== check tables use taos -d -k ========") + + tdSql.execute("drop database if exists test") + tdSql.execute("drop database if exists dumptest") + tdSql.execute("create database if not exists test") + tdLog.info("====== only create database test ==== ") + self.execute_cmd(build_path + "/" + "taos -d test -k 1 > res.txt 2>&1") + + tdSql.execute("use test") + tdSql.execute("create stable st (ts timestamp , id int , val double , str binary(20) ) tags (ind int)") + tdSql.execute("create table tb1 using st tags(1)") + tdLog.info("======= only create one table ==========") + self.execute_cmd(build_path + "/" + "taos -d test -k 1 > res.txt 2>&1") + + tdSql.execute("create table tb2 using st tags(2)") + tdSql.execute("create table tb3 using st tags(3)") + tdLog.info("======= only create three table =======") + self.execute_cmd(build_path + "/" + "taos -d test -k 1 > res.txt 2>&1") + + tdSql.execute("create table tb4 using st tags(4)") + tdSql.execute("create table tb5 using st tags(5)") + tdLog.info("======= only create five table =======") + self.execute_cmd(build_path + "/" + "taos -d test -k 1 > res.txt 2>&1") + + start_time = 1604298064000 + rows = 10 + tb_nums = 5 + tdLog.info("====== start insert rows ========") + + for i in range(1, tb_nums + 1): + for j in range(rows): + start_time += 10 + tdSql.execute( + "insert into tb%d values(%d, %d,%f,%s) " % (i, start_time, j, float(j), "'str" + str(j) + "'")) + tdSql.query("select count(*) from st") + tdSql.checkData(0, 0, 50) + + for i in range(1, tb_nums + 1): + tdSql.execute("select * from test.tb%s" % (str(i))) + + tdLog.info("====== check taos -D filedir ========") + + if not os.path.exists("./dumpdata"): + os.mkdir("./dumpdata") + else: + shutil.rmtree("./dumpdata") + os.mkdir("./dumpdata") + + os.system(build_path + "/" + "taosdump -D test -o ./dumpdata") + sleep(2) + os.system("cd ./dumpdata && mv dbs.sql tables.sql") + os.system('sed -i "s/test/dumptest/g" `grep test -rl ./dumpdata`') + os.system(build_path + "/" + "taos -D ./dumpdata") + tdSql.query("select count(*) from dumptest.st") + tdSql.checkData(0, 0, 50) + + tdLog.info("========test other file name about tables.sql========") + os.system("rm -rf ./dumpdata/*") + os.system(build_path + "/" + "taosdump -D test -o ./dumpdata") + sleep(2) + os.system("cd ./dumpdata && mv dbs.sql table.sql") + os.system('sed -i "s/test/tt/g" `grep test -rl ./dumpdata`') + cmd = build_path + "/" + "taos -D ./dumpdata" + out = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,stderr=subprocess.PIPE).stderr.read().decode("utf-8") + if out.find("error:") >=0: + print("===========expected error occured======") + + + tdLog.info("====== check taos shell params ========") + + tdLog.info("====== step 1 : insert data with some unicode ========") + + sqls = ["drop database if exists dbst", + "create database dbst", + "use dbst", + "create stable dbst.st (ts timestamp , id int , val double , str binary(200) ,char nchar(200) ) tags (ind int)", + "create table dbst.tb1 using dbst.st tags(1)", + "create table dbst.tb2 using dbst.st tags(2)", + "insert into dbst.tb1 values('2021-07-14T10:40:00.006+0800' , 1 , 1.0 , 'binary_1','中文-1') ", + "insert into dbst.tb1 values('2021-07-14T10:40:00.006Z' , 1 , 1.0 , 'binary\\'1','中文?-1')", + "insert into dbst.tb1 values('2021-07-14 10:40:00.000',1,1.0,'!@#¥%……&*', '中文12&%#@!*')", + "insert into dbst.tb1 values(now ,1,1.0,'(){}[];./?&*\n', '中文&%#@!*34')", + "insert into dbst.tb1 values(now ,1,1.0,'\\t\\0', '中文_\\t\\0')", + # "insert into dbst.tb1 values(now ,1,1.0,'\t\"', '中文_\t\\')", + "CREATE STABLE dbst.stb (TS TIMESTAMP , ID INT , VAL DOUBLE , STR BINARY(200) ,CHAR NCHAR(200) ) TAGS (IND INT)", + "CREATE TABLE dbst.tbb1 USING dbst.STB TAGS(1)", + "CREATE TABLE dbst.tbb2 USING dbst.STB TAGS(2)", + "INSERT INTO dbst.TBB1 VALUES('2021-07-14T10:40:00.006+0800' , 1 , 1.0 , 'BINARY_1','中文-1')", + "INSERT INTO dbst.TBB1 VALUES('2021-07-14T10:40:00.006Z' , 1 , 1.0 , 'BINARY1','中文?-1')", + "INSERT INTO dbst.TBB1 VALUES('2021-07-14 10:40:00.000',1,1.0,'!@#¥%……&*', '中文12&%#@!*');"] + for sql in sqls: + cmd = build_path + "/" + "taos -s \""+sql+"\"" + self.execute_cmd(cmd) + + basic_code = ['!' ,'#', '$', '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', + '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'A', + 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M','N', 'O', 'P', 'Q', 'R', + 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\',']' ,'^', '_', '`', 'a', 'b', 'c', + 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r','s', 't', 'u', + 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~'] + for code in basic_code: + # bug -> : this is a bug need be repaired to support '`' and '\' + if code=='\\': + cmd = build_path + "/" + "taos -s \" insert into dbst.tb2 values(now ,2,2.0," +r'"\\"'+",'中文"+r'\\'+ "')\"" + continue + elif code =='`': + cmd = build_path + "/" + "taos -s \" insert into dbst.tb2 values(now ,2,2.0,'"+code+"','汉字"+code+"\')\"" + continue + else: + cmd = build_path + "/" + "taos -s \" insert into dbst.tb2 values(now ,2,2.0,'"+code+"','汉字"+code+"\')\"" + + self.execute_cmd(cmd) + + + tdLog.info("====== step 2 : query result of results ========") + + querys = ["select count(*) from dbst.tb2", + "show dbst.tables", + "show dbst.tables like tb_", + "show dbst.tables like 't%'", + "select * from dbst.stb", + "select avg(val),max(id),min(id) from dbst.st ", + "select last_row(*) from dbst.st", + "select * from dbst.st where ts >'2021-07-14T10:40:00.006+0800' and ind = 1 ", + "select max(val) from dbst.st where ts >'2021-07-14T10:40:00.006+0800' group by tbname", + "select count(*) from dbst.st interval(1s) group by tbname", + "show queries ", + "show connections", + "show functions", + "select * from dbst.tb2 where str like 'a'", + "select bottom(id, 3) from dbst.st; ", + "select _block_dist() from dbst.st;", + "select 5 from dbst.tb1;", + "select id , val from dbst.st", + "describe dbst.st", + "alter stable dbst.st modify column str binary(205);" ] + + for query in querys: + cmd = build_path + "/" + "taos -s \""+query+"\"" + self.execute_cmd(cmd) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/client/thousandsofClient.py b/tests/pytest/client/thousandsofClient.py new file mode 100644 index 0000000000000000000000000000000000000000..36c816aa5bd9ee9ed788b77c1f881f5e76adace5 --- /dev/null +++ b/tests/pytest/client/thousandsofClient.py @@ -0,0 +1,55 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import os +import sys +sys.path.insert(0, os.getcwd()) +from util.log import * +from util.sql import * +from util.dnodes import * +import taos +import threading + + +class TwoClients: + def initConnection(self): + self.host = "127.0.0.1" + self.user = "root" + self.password = "taosdata" + self.config = "/home/chr/taosdata/TDengine/sim/dnode1/cfg " + + def newCloseCon(times): + newConList = [] + for times in range(0,times) : + newConList.append(taos.connect(self.host, self.user, self.password, self.config)) + for times in range(0,times) : + newConList[times].close() + + def run(self): + tdDnodes.init("") + tdDnodes.setTestCluster(False) + tdDnodes.setValgrind(False) + + tdDnodes.stopAll() + tdDnodes.deploy(1) + tdDnodes.start(1) + + # multiple new and cloes connection + for m in range(1,101) : + t= threading.Thread(target=newCloseCon,args=(10,)) + t.start() + + +clients = TwoClients() +clients.initConnection() +clients.run() \ No newline at end of file diff --git a/tests/pytest/client/twoClients.py b/tests/pytest/client/twoClients.py new file mode 100644 index 0000000000000000000000000000000000000000..1a1b36c55438f8ea4050bb804b739be71c570960 --- /dev/null +++ b/tests/pytest/client/twoClients.py @@ -0,0 +1,96 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import os +import sys +sys.path.insert(0, os.getcwd()) +from util.log import * +from util.sql import * +from util.dnodes import * +import taos + + +class TwoClients: + def initConnection(self): + self.host = "127.0.0.1" + self.user = "root" + self.password = "taosdata" + self.config = "/home/xp/git/TDengine/sim/dnode1/cfg" + + def run(self): + tdDnodes.init("") + tdDnodes.setTestCluster(False) + tdDnodes.setValgrind(False) + + tdDnodes.stopAll() + tdDnodes.deploy(1) + tdDnodes.start(1) + + # first client create a stable and insert data + conn1 = taos.connect(self.host, self.user, self.password, self.config) + cursor1 = conn1.cursor() + cursor1.execute("drop database if exists db") + cursor1.execute("create database db") + cursor1.execute("use db") + cursor1.execute("create table tb (ts timestamp, id int) tags(loc nchar(30))") + cursor1.execute("insert into t0 using tb tags('beijing') values(now, 1)") + + # second client alter the table created by cleint + conn2 = taos.connect(self.host, self.user, self.password, self.config) + cursor2 = conn2.cursor() + cursor2.execute("use db") + cursor2.execute("alter table tb add column name nchar(30)") + + # first client should not be able to use the origin metadata + tdSql.init(cursor1, True) + tdSql.error("insert into t0 values(now, 2)") + + # first client should be able to insert data with udpated medadata + tdSql.execute("insert into t0 values(now, 2, 'test')") + tdSql.query("select * from tb") + tdSql.checkRows(2) + + # second client drop the table + cursor2.execute("drop table t0") + cursor2.execute("create table t0 using tb tags('beijing')") + + tdSql.execute("insert into t0 values(now, 2, 'test')") + tdSql.query("select * from tb") + tdSql.checkRows(1) + + # error expected for two clients drop the same cloumn + cursor2.execute("alter table tb drop column name") + tdSql.error("alter table tb drop column name") + + cursor2.execute("alter table tb add column speed int") + tdSql.error("alter table tb add column speed int") + + + tdSql.execute("alter table tb add column size int") + tdSql.query("describe tb") + tdSql.checkRows(5) + tdSql.checkData(0, 0, "ts") + tdSql.checkData(1, 0, "id") + tdSql.checkData(2, 0, "speed") + tdSql.checkData(3, 0, "size") + tdSql.checkData(4, 0, "loc") + + + cursor1.close() + cursor2.close() + conn1.close() + conn2.close() + +clients = TwoClients() +clients.initConnection() +clients.run() \ No newline at end of file diff --git a/tests/pytest/client/version.py b/tests/pytest/client/version.py new file mode 100644 index 0000000000000000000000000000000000000000..0dbddbe9b5d86a9abf5c102d72b7f4b3e36eceaa --- /dev/null +++ b/tests/pytest/client/version.py @@ -0,0 +1,55 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from math import floor + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + sql = "select server_version()" + ret = tdSql.query(sql) + version = floor(float(tdSql.getData(0, 0)[0:3])) + expectedVersion = 2 + if(version == expectedVersion): + tdLog.info("sql:%s, row:%d col:%d data:%d == expect" % (sql, 0, 0, version)) + else: + tdLog.exit("sql:%s, row:%d col:%d data:%d != expect:%d " % (sql, 0, 0, version, expectedVersion)) + + + sql = "select client_version()" + ret = tdSql.query(sql) + version = floor(float(tdSql.getData(0, 0)[0:3])) + expectedVersion = 2 + if(version == expectedVersion): + tdLog.info("sql:%s, row:%d col:%d data:%d == expect" % (sql, 0, 0, version)) + else: + tdLog.exit("sql:%s, row:%d col:%d data:%d != expect:%d " % (sql, 0, 0, version, expectedVersion)) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/cluster/TD-3693/how-to-use b/tests/pytest/cluster/TD-3693/how-to-use new file mode 100644 index 0000000000000000000000000000000000000000..05a16a8534b07849f933dc7d6c33ea6306854ba0 --- /dev/null +++ b/tests/pytest/cluster/TD-3693/how-to-use @@ -0,0 +1,9 @@ +execute: +cd TDengine/tests/pytest && python3 ./test.py -f cluster/TD-3693/multClient.py && python3 cluster/TD-3693/multQuery.py + +1. 使用测试的集群,三个节点fc1、fct2、fct4。 +2. 用taosdemo建两个库db1和db2,副本数目为1,插入一定数据。 +3. db1在mnode的master上(fct2),db2在mnode的slave上(fct4)。 +4. 珲哥修改taosdemo,变成多线程查询,修改后的软件我命名成taosdemoMul,然后做持续多线程查询db2上的数据,建立多个连接 +5. 4中查询过程放到后台,同时再次在db2执行建表、插入,查询操作。循环执行查询10次,每次间隔91s。 +6. 然后查询taosd的log日志,看是否还存在上述问题“send auth msg to mnodes”。 \ No newline at end of file diff --git a/tests/pytest/cluster/TD-3693/insert1Data.json b/tests/pytest/cluster/TD-3693/insert1Data.json new file mode 100644 index 0000000000000000000000000000000000000000..3ac289a63a846c7de117ce6171ad023ca3f56211 --- /dev/null +++ b/tests/pytest/cluster/TD-3693/insert1Data.json @@ -0,0 +1,88 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "192.168.1.104", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db1", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 3650, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 10, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 10000, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":10}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 20, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 20000, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":10}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/cluster/TD-3693/insert2Data.json b/tests/pytest/cluster/TD-3693/insert2Data.json new file mode 100644 index 0000000000000000000000000000000000000000..25717df4c76f59e8ef7d638c8793a391ff338a7c --- /dev/null +++ b/tests/pytest/cluster/TD-3693/insert2Data.json @@ -0,0 +1,88 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "192.168.1.104", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db2", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 3650, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 10, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 10000, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":10}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 20, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 20000, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":10}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/cluster/TD-3693/multClient.py b/tests/pytest/cluster/TD-3693/multClient.py new file mode 100644 index 0000000000000000000000000000000000000000..24c27d9de9ff383f412af33e8d5f8318d1032f63 --- /dev/null +++ b/tests/pytest/cluster/TD-3693/multClient.py @@ -0,0 +1,74 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self.rowNum = 100000 + self.ts = 1537146000000 + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def run(self): + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + + # insert data to cluster'db + os.system("%staosdemo -f cluster/TD-3693/insert1Data.json -y " % binPath) + # multiple new and cloes connection with query data + os.system("%staosdemo -f cluster/TD-3693/insert2Data.json -y " % binPath) + os.system("nohup %staosdemoMul -f cluster/TD-3693/queryCount.json -y & " % binPath) + + + + # delete useless files + os.system("rm -rf ./insert_res.txt") + os.system("rm -rf ./querySystemInfo*") + os.system("rm -rf cluster/TD-3693/multClient.py.sql") + os.system("rm -rf ./querySystemInfo*") + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/cluster/TD-3693/multQuery.py b/tests/pytest/cluster/TD-3693/multQuery.py new file mode 100644 index 0000000000000000000000000000000000000000..70061a27f2ccb7cdef9cdea1b62cd0060f972c3c --- /dev/null +++ b/tests/pytest/cluster/TD-3693/multQuery.py @@ -0,0 +1,72 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import os +import sys +sys.path.insert(0, os.getcwd()) +from util.log import * +from util.sql import * +from util.dnodes import * +import taos +import threading + + +class TwoClients: + def initConnection(self): + self.host = "fct4" + self.user = "root" + self.password = "taosdata" + self.config = "/etc/taos/" + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + # query data from cluster'db + conn = taos.connect(host=self.host, user=self.user, password=self.password, config=self.config) + cur = conn.cursor() + tdSql.init(cur, True) + tdSql.execute("use db2") + cur.execute("select count (tbname) from stb0") + tdSql.query("select count (tbname) from stb0") + tdSql.checkData(0, 0, 10) + tdSql.query("select count (tbname) from stb1") + tdSql.checkData(0, 0, 20) + tdSql.query("select count(*) from stb00_0") + tdSql.checkData(0, 0, 10000) + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 100000) + tdSql.query("select count(*) from stb01_0") + tdSql.checkData(0, 0, 20000) + tdSql.query("select count(*) from stb1") + tdSql.checkData(0, 0, 400000) + tdSql.execute("drop table if exists squerytest") + tdSql.execute("drop table if exists querytest") + tdSql.execute('''create stable squerytest(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''') + tdSql.execute("create table querytest using squerytest tags('beijing')") + tdSql.execute("insert into querytest(ts) values(%d)" % (self.ts - 1)) + for i in range(self.rowNum): + tdSql.execute("insert into querytest values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" % (self.ts + i, i + 1, 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) + for j in range(10): + tdSql.execute("use db2") + tdSql.query("select count(*),last(*) from querytest group by col1") + tdSql.checkRows(10) + tdSql.checkData(0, 0, 1) + tdSql.checkData(1, 2, 2) + tdSql.checkData(1, 3, 1) + sleep(88) + tdSql.execute("drop table if exists squerytest") + tdSql.execute("drop table if exists querytest") + +clients = TwoClients() +clients.initConnection() +clients.run() \ No newline at end of file diff --git a/tests/pytest/cluster/TD-3693/queryCount.json b/tests/pytest/cluster/TD-3693/queryCount.json new file mode 100644 index 0000000000000000000000000000000000000000..089ae42aab379f806d13fd4dec66af680b546154 --- /dev/null +++ b/tests/pytest/cluster/TD-3693/queryCount.json @@ -0,0 +1,15 @@ +{ + "filetype":"query", + "cfgdir": "/etc/taos", + "host": "192.168.1.104", + "port": 6030, + "user": "root", + "password": "taosdata", + "confirm_parameter_prompt": "no", + "databases": "db2", + "query_times": 1000000, + "specified_table_query": + {"query_interval":1, "concurrent":100, + "sqls": [{"sql": "select count(*) from db.stb0", "result": ""}] + } +} \ No newline at end of file diff --git a/tests/pytest/cluster/bananceTest.py b/tests/pytest/cluster/bananceTest.py new file mode 100644 index 0000000000000000000000000000000000000000..ef25afa7d2f7ea3b5358f8ba74d6702d28d54c85 --- /dev/null +++ b/tests/pytest/cluster/bananceTest.py @@ -0,0 +1,57 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from clusterSetup import * +from util.sql import tdSql +from util.log import tdLog +import random +import time + +class ClusterTestcase: + + ## test case 32 ## + def run(self): + + nodes = Nodes() + nodes.addConfigs("maxVgroupsPerDb", "10") + nodes.addConfigs("maxTablesPerVnode", "1000") + nodes.restartAllTaosd() + + ctest = ClusterTest(nodes.node1.hostName) + ctest.connectDB() + ctest.createSTable(1) + ctest.run() + tdSql.init(ctest.conn.cursor(), False) + + tdSql.execute("use %s" % ctest.dbName) + tdSql.query("show vgroups") + dnodes = [] + for i in range(10): + dnodes.append(int(tdSql.getData(i, 4))) + + s = set(dnodes) + if len(s) < 3: + tdLog.exit("cluster is not balanced") + + tdLog.info("cluster is balanced") + + nodes.removeConfigs("maxVgroupsPerDb", "10") + nodes.removeConfigs("maxTablesPerVnode", "1000") + nodes.restartAllTaosd() + + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +ct = ClusterTestcase() +ct.run() diff --git a/tests/pytest/cluster/basicTest.py b/tests/pytest/cluster/basicTest.py new file mode 100644 index 0000000000000000000000000000000000000000..b990d7fd982a490383939707a32635d37e546b13 --- /dev/null +++ b/tests/pytest/cluster/basicTest.py @@ -0,0 +1,47 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from clusterSetup import * +from util.sql import tdSql +from util.log import tdLog +import random + +class ClusterTestcase: + + ## test case 1, 33 ## + def run(self): + + nodes = Nodes() + ctest = ClusterTest(nodes.node1.hostName) + + ctest.connectDB() + tdSql.init(ctest.conn.cursor(), False) + + ## Test case 1 ## + tdLog.info("Test case 1 repeat %d times" % ctest.repeat) + for i in range(ctest.repeat): + tdLog.info("Start Round %d" % (i + 1)) + replica = random.randint(1,3) + ctest.createSTable(replica) + ctest.run() + tdLog.sleep(10) + tdSql.query("select count(*) from %s.%s" %(ctest.dbName, ctest.stbName)) + tdSql.checkData(0, 0, ctest.numberOfRecords * ctest.numberOfTables) + tdLog.info("Round %d completed" % (i + 1)) + + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +ct = ClusterTestcase() +ct.run() \ No newline at end of file diff --git a/tests/pytest/cluster/changeReplicaTest.py b/tests/pytest/cluster/changeReplicaTest.py new file mode 100644 index 0000000000000000000000000000000000000000..7fa68edbfee2db599076befdf9bed5f4b4be3c83 --- /dev/null +++ b/tests/pytest/cluster/changeReplicaTest.py @@ -0,0 +1,51 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from clusterSetup import * +from util.sql import tdSql +from util.log import tdLog +import random + +class ClusterTestcase: + + ## test case 7, ## + def run(self): + + nodes = Nodes() + ctest = ClusterTest(nodes.node1.hostName) + ctest.connectDB() + tdSql.init(ctest.conn.cursor(), False) + + tdSql.execute("use %s" % ctest.dbName) + tdSql.query("show vgroups") + for i in range(10): + tdSql.checkData(i, 5, "master") + + tdSql.execute("alter database %s replica 2" % ctest.dbName) + tdLog.sleep(30) + tdSql.query("show vgroups") + for i in range(10): + tdSql.checkData(i, 5, "master") + tdSql.checkData(i, 7, "slave") + + tdSql.execute("alter database %s replica 3" % ctest.dbName) + tdLog.sleep(30) + tdSql.query("show vgroups") + for i in range(10): + tdSql.checkData(i, 5, "master") + tdSql.checkData(i, 7, "slave") + tdSql.checkData(i, 9, "slave") + +ct = ClusterTestcase() +ct.run() \ No newline at end of file diff --git a/tests/pytest/cluster/clusterSetup.py b/tests/pytest/cluster/clusterSetup.py new file mode 100644 index 0000000000000000000000000000000000000000..87414303f850bcbd78468238e7b76aa3dbb3326e --- /dev/null +++ b/tests/pytest/cluster/clusterSetup.py @@ -0,0 +1,214 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +from fabric import Connection +import random +import time +import logging + +class Node: + def __init__(self, index, username, hostIP, hostName, password, homeDir): + self.index = index + self.username = username + self.hostIP = hostIP + self.hostName = hostName + self.homeDir = homeDir + self.corePath = '/coredump' + self.conn = Connection("{}@{}".format(username, hostName), connect_kwargs={"password": "{}".format(password)}) + + def buildTaosd(self): + try: + self.conn.cd("/root/TDinternal/community") + self.conn.run("git checkout develop") + self.conn.run("git pull") + self.conn.cd("/root/TDinternal") + self.conn.run("git checkout develop") + self.conn.run("git pull") + self.conn.cd("/root/TDinternal/debug") + self.conn.run("cmake ..") + self.conn.run("make") + self.conn.run("make install") + except Exception as e: + print("Build Taosd error for node %d " % self.index) + logging.exception(e) + pass + + def startTaosd(self): + try: + self.conn.run("sudo systemctl start taosd") + except Exception as e: + print("Start Taosd error for node %d " % self.index) + logging.exception(e) + + def stopTaosd(self): + try: + self.conn.run("sudo systemctl stop taosd") + except Exception as e: + print("Stop Taosd error for node %d " % self.index) + logging.exception(e) + + def restartTaosd(self): + try: + self.conn.run("sudo systemctl restart taosd") + except Exception as e: + print("Stop Taosd error for node %d " % self.index) + logging.exception(e) + + def removeTaosd(self): + try: + self.conn.run("rmtaos") + except Exception as e: + print("remove taosd error for node %d " % self.index) + logging.exception(e) + + def forceStopOneTaosd(self): + try: + self.conn.run("kill -9 $(ps -ax|grep taosd|awk '{print $1}')") + except Exception as e: + print("kill taosd error on node%d " % self.index) + + def startOneTaosd(self): + try: + self.conn.run("nohup taosd -c /etc/taos/ > /dev/null 2>&1 &") + except Exception as e: + print("start taosd error on node%d " % self.index) + logging.exception(e) + + def installTaosd(self, packagePath): + self.conn.put(packagePath, self.homeDir) + self.conn.cd(self.homeDir) + self.conn.run("tar -zxf $(basename '%s')" % packagePath) + with self.conn.cd("TDengine-enterprise-server"): + self.conn.run("yes|./install.sh") + + def configTaosd(self, taosConfigKey, taosConfigValue): + self.conn.run("sudo echo '%s %s' >> %s" % (taosConfigKey, taosConfigValue, "/etc/taos/taos.cfg")) + + def removeTaosConfig(self, taosConfigKey, taosConfigValue): + self.conn.run("sudo sed -in-place -e '/%s %s/d' %s" % (taosConfigKey, taosConfigValue, "/etc/taos/taos.cfg")) + + def configHosts(self, ip, name): + self.conn.run("echo '%s %s' >> %s" % (ip, name, '/etc/hosts')) + + def removeData(self): + try: + self.conn.run("sudo rm -rf /var/lib/taos/*") + except Exception as e: + print("remove taosd data error for node %d " % self.index) + logging.exception(e) + + def removeLog(self): + try: + self.conn.run("sudo rm -rf /var/log/taos/*") + except Exception as e: + print("remove taosd error for node %d " % self.index) + logging.exception(e) + + def removeDataForMnode(self): + try: + self.conn.run("sudo rm -rf /var/lib/taos/*") + except Exception as e: + print("remove taosd error for node %d " % self.index) + logging.exception(e) + + def removeDataForVnode(self, id): + try: + self.conn.run("sudo rm -rf /var/lib/taos/vnode%d/*.data" % id) + except Exception as e: + print("remove taosd error for node %d " % self.index) + logging.exception(e) + + + def detectCoredumpFile(self): + try: + result = self.conn.run("find /coredump -name 'core_*' ", hide=True) + output = result.stdout + print("output: %s" % output) + return output + except Exception as e: + print("find coredump file error on node %d " % self.index) + logging.exception(e) + + +class Nodes: + def __init__(self): + self.tdnodes = [] + self.tdnodes.append(Node(0, 'root', '192.168.17.194', 'taosdata', 'r', '/root/')) + # self.tdnodes.append(Node(1, 'root', '52.250.48.222', 'node2', 'a', '/root/')) + # self.tdnodes.append(Node(2, 'root', '51.141.167.23', 'node3', 'a', '/root/')) + # self.tdnodes.append(Node(3, 'root', '52.247.207.173', 'node4', 'a', '/root/')) + # self.tdnodes.append(Node(4, 'root', '51.141.166.100', 'node5', 'a', '/root/')) + + def stopOneNode(self, index): + self.tdnodes[index].stopTaosd() + self.tdnodes[index].forceStopOneTaosd() + + def startOneNode(self, index): + self.tdnodes[index].startOneTaosd() + + def detectCoredumpFile(self, index): + return self.tdnodes[index].detectCoredumpFile() + + def stopAllTaosd(self): + for i in range(len(self.tdnodes)): + self.tdnodes[i].stopTaosd() + + def startAllTaosd(self): + for i in range(len(self.tdnodes)): + self.tdnodes[i].startTaosd() + + def restartAllTaosd(self): + for i in range(len(self.tdnodes)): + self.tdnodes[i].restartTaosd() + + def addConfigs(self, configKey, configValue): + for i in range(len(self.tdnodes)): + self.tdnodes[i].configTaosd(configKey, configValue) + + def removeConfigs(self, configKey, configValue): + for i in range(len(self.tdnodes)): + self.tdnodes[i].removeTaosConfig(configKey, configValue) + + def removeAllDataFiles(self): + for i in range(len(self.tdnodes)): + self.tdnodes[i].removeData() + +class Test: + def __init__(self): + self.nodes = Nodes() + + # kill taosd randomly every 10 mins + def randomlyKillDnode(self): + loop = 0 + while True: + index = random.randint(0, 4) + print("loop: %d, kill taosd on node%d" %(loop, index)) + self.nodes.stopOneNode(index) + time.sleep(60) + self.nodes.startOneNode(index) + time.sleep(600) + loop = loop + 1 + + def detectCoredump(self): + loop = 0 + while True: + for i in range(len(self.nodes.tdnodes)): + result = self.nodes.detectCoredumpFile(i) + print("core file path is %s" % result) + if result and not result.isspace(): + self.nodes.stopAllTaosd() + print("sleep for 10 mins") + time.sleep(600) + +test = Test() +test.detectCoredump() \ No newline at end of file diff --git a/tests/pytest/cluster/dataFileRecoveryTest.py b/tests/pytest/cluster/dataFileRecoveryTest.py new file mode 100644 index 0000000000000000000000000000000000000000..089d3fffc1499a8d9cafc87a8d94252111fcd604 --- /dev/null +++ b/tests/pytest/cluster/dataFileRecoveryTest.py @@ -0,0 +1,53 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from clusterSetup import * +from util.sql import tdSql +from util.log import tdLog +import random + +class ClusterTestcase: + + ## test case 20, 21, 22 ## + def run(self): + + nodes = Nodes() + ctest = ClusterTest(nodes.node1.hostName) + ctest.connectDB() + ctest.createSTable(3) + ctest.run() + tdSql.init(ctest.conn.cursor(), False) + + nodes.node2.stopTaosd() + tdSql.execute("use %s" % ctest.dbName) + tdSql.query("show vgroups") + vnodeID = tdSql.getData(0, 0) + nodes.node2.removeDataForVnode(vnodeID) + nodes.node2.startTaosd() + + # Wait for vnode file to recover + for i in range(10): + tdSql.query("select count(*) from t0") + + tdLog.sleep(10) + + for i in range(10): + tdSql.query("select count(*) from t0") + tdSql.checkData(0, 0, 1000) + + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +ct = ClusterTestcase() +ct.run() diff --git a/tests/pytest/cluster/fullDnodesTest.py b/tests/pytest/cluster/fullDnodesTest.py new file mode 100644 index 0000000000000000000000000000000000000000..3c4b10d97a24dfbb156122aa0afdbb5d22ce3941 --- /dev/null +++ b/tests/pytest/cluster/fullDnodesTest.py @@ -0,0 +1,47 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from clusterSetup import * +from util.sql import tdSql +from util.log import tdLog +import random + +class ClusterTestcase: + + ##Cover test case 5 ## + def run(self): + # cluster environment set up + nodes = Nodes() + nodes.addConfigs("maxVgroupsPerDb", "10") + nodes.addConfigs("maxTablesPerVnode", "1000") + nodes.restartAllTaosd() + + ctest = ClusterTest(nodes.node1.hostName) + ctest.connectDB() + ctest.createSTable(1) + ctest.run() + + tdSql.init(ctest.conn.cursor(), False) + tdSql.execute("use %s" % ctest.dbName) + tdSql.error("create table tt1 using %s tags(1)" % ctest.stbName) + + nodes.removeConfigs("maxVgroupsPerDb", "10") + nodes.removeConfigs("maxTablesPerVnode", "1000") + nodes.restartAllTaosd() + + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +ct = ClusterTestcase() +ct.run() \ No newline at end of file diff --git a/tests/pytest/cluster/killAndRestartDnodesTest.py b/tests/pytest/cluster/killAndRestartDnodesTest.py new file mode 100644 index 0000000000000000000000000000000000000000..be927e862f616c7fbe490e733a18984b6971ef1f --- /dev/null +++ b/tests/pytest/cluster/killAndRestartDnodesTest.py @@ -0,0 +1,75 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from clusterSetup import * +from util.sql import tdSql +from util.log import tdLog +import random + +class ClusterTestcase: + + ## test case 7, 10 ## + def run(self): + # cluster environment set up + tdLog.info("Test case 7, 10") + + nodes = Nodes() + ctest = ClusterTest(nodes.node1.hostName) + ctest.connectDB() + tdSql.init(ctest.conn.cursor(), False) + + nodes.node1.stopTaosd() + tdSql.query("show dnodes") + tdSql.checkRows(3) + tdSql.checkData(0, 4, "offline") + tdSql.checkData(1, 4, "ready") + tdSql.checkData(2, 4, "ready") + + nodes.node1.startTaosd() + tdSql.checkRows(3) + tdSql.checkData(0, 4, "ready") + tdSql.checkData(1, 4, "ready") + tdSql.checkData(2, 4, "ready") + + nodes.node2.stopTaosd() + tdSql.query("show dnodes") + tdSql.checkRows(3) + tdSql.checkData(0, 4, "ready") + tdSql.checkData(1, 4, "offline") + tdSql.checkData(2, 4, "ready") + + nodes.node2.startTaosd() + tdSql.checkRows(3) + tdSql.checkData(0, 4, "ready") + tdSql.checkData(1, 4, "ready") + tdSql.checkData(2, 4, "ready") + + nodes.node3.stopTaosd() + tdSql.query("show dnodes") + tdSql.checkRows(3) + tdSql.checkData(0, 4, "ready") + tdSql.checkData(1, 4, "ready") + tdSql.checkData(2, 4, "offline") + + nodes.node3.startTaosd() + tdSql.checkRows(3) + tdSql.checkData(0, 4, "ready") + tdSql.checkData(1, 4, "ready") + tdSql.checkData(2, 4, "ready") + + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +ct = ClusterTestcase() +ct.run() \ No newline at end of file diff --git a/tests/pytest/cluster/offlineThresholdTest.py b/tests/pytest/cluster/offlineThresholdTest.py new file mode 100644 index 0000000000000000000000000000000000000000..8373424f93c8217250907e09620c8523d63071ad --- /dev/null +++ b/tests/pytest/cluster/offlineThresholdTest.py @@ -0,0 +1,54 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from clusterSetup import * +from util.sql import tdSql +from util.log import tdLog +import random + +class ClusterTestcase: + + ## cover test case 6, 8, 9, 11 ## + def run(self): + # cluster environment set up + nodes = Nodes() + ctest = ClusterTest(nodes.node1.hostName) + ctest.connectDB() + tdSql.init(ctest.conn.cursor(), False) + + nodes.addConfigs("offlineThreshold", "10") + nodes.removeAllDataFiles() + nodes.restartAllTaosd() + nodes.node3.stopTaosd() + + tdLog.sleep(10) + tdSql.query("show dnodes") + tdSql.checkRows(3) + tdSql.checkData(2, 4, "offline") + + tdLog.sleep(60) + tdSql.checkRows(3) + tdSql.checkData(2, 4, "dropping") + + tdLog.sleep(300) + tdSql.checkRows(2) + + nodes.removeConfigs("offlineThreshold", "10") + nodes.restartAllTaosd() + + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +ct = ClusterTestcase() +ct.run() \ No newline at end of file diff --git a/tests/pytest/cluster/oneReplicaOfflineTest.py b/tests/pytest/cluster/oneReplicaOfflineTest.py new file mode 100644 index 0000000000000000000000000000000000000000..0223dfe01add9faca7987d7767f5c41a58b8edd2 --- /dev/null +++ b/tests/pytest/cluster/oneReplicaOfflineTest.py @@ -0,0 +1,65 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from clusterSetup import * +from util.sql import tdSql +from util.log import tdLog +import random + +class ClusterTestcase: + + ## test case 28, 29, 30, 31 ## + def run(self): + + nodes = Nodes() + ctest = ClusterTest(nodes.node1.hostName) + ctest.connectDB() + ctest.createSTable(3) + ctest.run() + tdSql.init(ctest.conn.cursor(), False) + + tdSql.execute("use %s" % ctest.dbName) + + nodes.node2.stopTaosd() + for i in range(100): + tdSql.execute("drop table t%d" % i) + + nodes.node2.startTaosd() + tdSql.query("show tables") + tdSql.checkRows(9900) + + nodes.node2.stopTaosd() + for i in range(10): + tdSql.execute("create table a%d using meters tags(2)" % i) + + nodes.node2.startTaosd() + tdSql.query("show tables") + tdSql.checkRows(9910) + + nodes.node2.stopTaosd() + tdSql.execute("alter table meters add col col6 int") + nodes.node2.startTaosd() + + nodes.node2.stopTaosd() + tdSql.execute("drop database %s" % ctest.dbName) + + nodes.node2.startTaosd() + tdSql.query("show databases") + tdSql.checkRows(0) + + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +ct = ClusterTestcase() +ct.run() diff --git a/tests/pytest/cluster/queryTimeTest.py b/tests/pytest/cluster/queryTimeTest.py new file mode 100644 index 0000000000000000000000000000000000000000..74a9081ccf4fd8abc175e2e0c82b0c6feedcbb26 --- /dev/null +++ b/tests/pytest/cluster/queryTimeTest.py @@ -0,0 +1,54 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from clusterSetup import * +from util.sql import tdSql +from util.log import tdLog +import random +import time + +class ClusterTestcase: + + ## test case 32 ## + def run(self): + + nodes = Nodes() + ctest = ClusterTest(nodes.node1.hostName) + ctest.connectDB() + ctest.createSTable(1) + ctest.run() + tdSql.init(ctest.conn.cursor(), False) + + tdSql.execute("use %s" % ctest.dbName) + totalTime = 0 + for i in range(10): + startTime = time.time() + tdSql.query("select * from %s" % ctest.stbName) + totalTime += time.time() - startTime + print("replica 1: avarage query time for %d records: %f seconds" % (ctest.numberOfTables * ctest.numberOfRecords,totalTime / 10)) + + tdSql.execute("alter database %s replica 3" % ctest.dbName) + tdLog.sleep(60) + totalTime = 0 + for i in range(10): + startTime = time.time() + tdSql.query("select * from %s" % ctest.stbName) + totalTime += time.time() - startTime + print("replica 3: avarage query time for %d records: %f seconds" % (ctest.numberOfTables * ctest.numberOfRecords,totalTime / 10)) + + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +ct = ClusterTestcase() +ct.run() diff --git a/tests/pytest/cluster/stopAllDnodesTest.py b/tests/pytest/cluster/stopAllDnodesTest.py new file mode 100644 index 0000000000000000000000000000000000000000..a71ae52e3d7a640bb589f3bafe16b2e4d45c7b93 --- /dev/null +++ b/tests/pytest/cluster/stopAllDnodesTest.py @@ -0,0 +1,45 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from clusterSetup import * +from util.sql import tdSql +from util.log import tdLog +import random + +class ClusterTestcase: + + ## test case 19 ## + def run(self): + + nodes = Nodes() + ctest = ClusterTest(nodes.node1.hostName) + tdSql.init(ctest.conn.cursor(), False) + + tdSql.query("show databases") + count = tdSql.queryRows; + + nodes.stopAllTaosd() + nodes.node1.startTaosd() + tdSql.error("show databases") + + nodes.node2.startTaosd() + tdSql.error("show databases") + + nodes.node3.startTaosd() + tdLog.sleep(10) + tdSql.query("show databases") + tdSql.checkRows(count) + +ct = ClusterTestcase() +ct.run() diff --git a/tests/pytest/cluster/stopTwoDnodesTest.py b/tests/pytest/cluster/stopTwoDnodesTest.py new file mode 100644 index 0000000000000000000000000000000000000000..9e9958e2d32018b6a89a3e0d08da2c1597151ff2 --- /dev/null +++ b/tests/pytest/cluster/stopTwoDnodesTest.py @@ -0,0 +1,48 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from clusterSetup import * +from util.sql import tdSql +from util.log import tdLog +import random + +class ClusterTestcase: + + ## test case 17, 18 ## + def run(self): + + nodes = Nodes() + ctest = ClusterTest(nodes.node1.hostName) + ctest.connectDB() + ctest.createSTable(1) + ctest.run() + tdSql.init(ctest.conn.cursor(), False) + + tdSql.query("show databases") + count = tdSql.queryRows; + tdSql.execute("use %s" % ctest.dbName) + tdSql.execute("alter database %s replica 3" % ctest.dbName) + nodes.node2.stopTaosd() + nodes.node3.stopTaosd() + tdSql.error("show databases") + + nodes.node2.startTaosd() + tdSql.error("show databases") + + nodes.node3.startTaosd() + tdSql.query("show databases") + tdSql.checkRows(count) + +ct = ClusterTestcase() +ct.run() diff --git a/tests/pytest/cluster/syncingTest.py b/tests/pytest/cluster/syncingTest.py new file mode 100644 index 0000000000000000000000000000000000000000..96be048d231e35f67e40fc4785d2e19337ed408b --- /dev/null +++ b/tests/pytest/cluster/syncingTest.py @@ -0,0 +1,50 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from clusterSetup import * +from util.sql import tdSql +from util.log import tdLog +import random + +class ClusterTestcase: + + ## test case 24, 25, 26, 27 ## + def run(self): + + nodes = Nodes() + ctest = ClusterTest(nodes.node1.hostName) + ctest.connectDB() + ctest.createSTable(1) + ctest.run() + tdSql.init(ctest.conn.cursor(), False) + + + tdSql.execute("use %s" % ctest.dbName) + tdSql.execute("alter database %s replica 3" % ctest.dbName) + + for i in range(100): + tdSql.execute("drop table t%d" % i) + + for i in range(100): + tdSql.execute("create table a%d using meters tags(1)" % i) + + tdSql.execute("alter table meters add col col5 int") + tdSql.execute("alter table meters drop col col5 int") + tdSql.execute("drop database %s" % ctest.dbName) + + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +ct = ClusterTestcase() +ct.run() diff --git a/tests/pytest/cluster/testcluster.sh b/tests/pytest/cluster/testcluster.sh new file mode 100644 index 0000000000000000000000000000000000000000..6e15a498c0a73db450699fe66d63d07c3b18dbe5 --- /dev/null +++ b/tests/pytest/cluster/testcluster.sh @@ -0,0 +1,12 @@ +python3 basicTest.py +python3 bananceTest.py +python3 changeReplicaTest.py +python3 dataFileRecoveryTest.py +python3 fullDnodesTest.py +python3 killAndRestartDnodesTest.py +python3 offlineThresholdTest.py +python3 oneReplicaOfflineTest.py +python3 queryTimeTest.py +python3 stopAllDnodesTest.py +python3 stopTwoDnodesTest.py +python3 syncingTest.py \ No newline at end of file diff --git a/tests/pytest/compress/compressChangeVersion.py b/tests/pytest/compress/compressChangeVersion.py new file mode 100644 index 0000000000000000000000000000000000000000..b7b9ebe6b35dc4729e0dcae705ac7d93c73010e7 --- /dev/null +++ b/tests/pytest/compress/compressChangeVersion.py @@ -0,0 +1,109 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import os +import sys +sys.path.insert(0, os.getcwd()) +from util.log import * +from util.sql import * +from util.dnodes import * +import taos +import threading +import subprocess +from random import choice + + +class TwoClients: + def initConnection(self): + self.host = "chenhaoran01" + self.user = "root" + self.password = "taosdata" + self.config = "/home/chr/cfg/single/" + self.port =6030 + self.rowNum = 10 + self.ts = 1537146000000 + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def run(self): + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + walFilePath = "/var/lib/taos/mnode_bak/wal/" + + # new taos client + conn1 = taos.connect(host=self.host, user=self.user, password=self.password, config=self.config ) + print(conn1) + cur1 = conn1.cursor() + tdSql.init(cur1, True) + + # create backgroud db and tb + tdSql.execute("drop database if exists db1") + os.system("%staosdemo -f compress/insertDataDb1.json -y " % binPath) + # create foreground db and tb + tdSql.execute("drop database if exists foredb") + tdSql.execute("create database foredb") + tdSql.execute("use foredb") + print("123test") + tdSql.execute("create stable if not exists stb (ts timestamp, dataInt int, dataDouble double,dataStr nchar(200)) tags(loc nchar(50),t1 int)") + tdSql.execute("create table tb1 using stb tags('beijing1', 10)") + tdSql.execute("insert into tb1 values(1614218412000,8635,98.861,'qazwsxedcrfvtgbyhnujmikolp1')(1614218422000,8636,98.862,'qazwsxedcrfvtgbyhnujmikolp2')") + tdSql.execute("create table tb2 using stb tags('beijing2', 11)") + tdSql.execute("insert into tb2 values(1614218432000,8647,98.863,'qazwsxedcrfvtgbyhnujmikolp3')") + tdSql.execute("insert into tb2 values(1614218442000,8648,98.864,'qazwsxedcrfvtgbyhnujmikolp4')") + + + # check data correct + tdSql.execute("use db1") + tdSql.query("select count(tbname) from stb0") + tdSql.checkData(0, 0, 50000) + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 5000000) + tdSql.execute("use foredb") + tdSql.query("select count (tbname) from stb") + tdSql.checkData(0, 0, 2) + tdSql.query("select count (*) from stb") + tdSql.checkData(0, 0, 4) + tdSql.query("select * from tb1 order by ts") + tdSql.checkData(0, 3, "qazwsxedcrfvtgbyhnujmikolp1") + tdSql.query("select * from tb2 order by ts") + tdSql.checkData(1, 3, "qazwsxedcrfvtgbyhnujmikolp4") + + + + # delete useless file + testcaseFilename = os.path.split(__file__)[-1] + os.system("rm -rf ./insert_res.txt") + # os.system("rm -rf compress/%s.sql" % testcaseFilename ) + +clients = TwoClients() +clients.initConnection() +# clients.getBuildPath() +clients.run() \ No newline at end of file diff --git a/tests/pytest/compress/insertDataDb1.json b/tests/pytest/compress/insertDataDb1.json new file mode 100644 index 0000000000000000000000000000000000000000..65cec71a65ff4ef3814bee4949def151c32945ee --- /dev/null +++ b/tests/pytest/compress/insertDataDb1.json @@ -0,0 +1,62 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db1", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 3650, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 50000, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 100, + "childtable_limit": 0, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"},{"type": "TINYINT"},{"type": "smallint"},{"type": "bool"},{"type": "bigint"},{"type": "float"},{"type": "double"}, {"type": "BINARY","len": 32}, {"type": "nchar","len": 32}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":1}] + }] + }] +} + diff --git a/tests/pytest/concurrent_inquiry.py b/tests/pytest/concurrent_inquiry.py new file mode 100644 index 0000000000000000000000000000000000000000..333c2a0a578f6f399e742b0967db0185a22b5fde --- /dev/null +++ b/tests/pytest/concurrent_inquiry.py @@ -0,0 +1,700 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- +import threading +import taos +import sys +import json +import time +import random +import requests +import argparse +import datetime +import string +from requests.auth import HTTPBasicAuth +func_list=['avg','count','twa','sum','stddev','leastsquares','min', +'max','first','last','top','bottom','percentile','apercentile', +'last_row','diff','spread'] +condition_list=[ + "where _c0 > now -10d ", + 'interval(10s)', + 'limit 10', + 'group by', + 'order by', + 'fill(null)' + +] +where_list = ['_c0>now-10d',' <50','like',' is null'] +class ConcurrentInquiry: + # def __init__(self,ts=1500000001000,host='127.0.0.1',user='root',password='taosdata',dbname='test', + # stb_prefix='st',subtb_prefix='t',n_Therads=10,r_Therads=10,probabilities=0.05,loop=5, + # stableNum = 2,subtableNum = 1000,insertRows = 100): + def __init__(self,ts,host,user,password,dbname, + stb_prefix,subtb_prefix,n_Therads,r_Therads,probabilities,loop, + stableNum ,subtableNum ,insertRows ,mix_table, replay): + self.n_numOfTherads = n_Therads + self.r_numOfTherads = r_Therads + self.ts=ts + self.host = host + self.user = user + self.password = password + self.dbname=dbname + self.stb_prefix = stb_prefix + self.subtb_prefix = subtb_prefix + self.stb_list=[] + self.subtb_list=[] + self.stb_stru_list=[] + self.subtb_stru_list=[] + self.stb_tag_list=[] + self.subtb_tag_list=[] + self.probabilities = [1-probabilities,probabilities] + self.ifjoin = [1,0] + self.loop = loop + self.stableNum = stableNum + self.subtableNum = subtableNum + self.insertRows = insertRows + self.mix_table = mix_table + self.max_ts = datetime.datetime.now() + self.min_ts = datetime.datetime.now() - datetime.timedelta(days=5) + self.replay = replay + def SetThreadsNum(self,num): + self.numOfTherads=num + + def ret_fcol(self,cl,sql): #返回结果的第一列 + cl.execute(sql) + fcol_list=[] + for data in cl: + fcol_list.append(data[0]) + return fcol_list + + def r_stb_list(self,cl): #返回超级表列表 + sql='show '+self.dbname+'.stables' + self.stb_list=self.ret_fcol(cl,sql) + + def r_subtb_list(self,cl,stablename): #每个超级表返回2个子表 + sql='select tbname from '+self.dbname+'.'+stablename+' limit 2;' + self.subtb_list+=self.ret_fcol(cl,sql) + + def cal_struct(self,cl,tbname): #查看表结构 + tb=[] + tag=[] + sql='describe '+self.dbname+'.'+tbname+';' + cl.execute(sql) + for data in cl: + if data[3]: + tag.append(data[0]) + else: + tb.append(data[0]) + return tb,tag + + def r_stb_stru(self,cl): #获取所有超级表的表结构 + for i in self.stb_list: + tb,tag=self.cal_struct(cl,i) + self.stb_stru_list.append(tb) + self.stb_tag_list.append(tag) + + def r_subtb_stru(self,cl): #返回所有子表的表结构 + for i in self.subtb_list: + tb,tag=self.cal_struct(cl,i) + self.subtb_stru_list.append(tb) + self.subtb_tag_list.append(tag) + + def get_timespan(self,cl): #获取时间跨度(仅第一个超级表) + sql = 'select first(_c0),last(_c0) from ' + self.dbname + '.' + self.stb_list[0] + ';' + print(sql) + cl.execute(sql) + for data in cl: + self.max_ts = data[1] + self.min_ts = data[0] + + def get_full(self): #获取所有的表、表结构 + host = self.host + user = self.user + password = self.password + conn = taos.connect( + host, + user, + password, + ) + cl = conn.cursor() + self.r_stb_list(cl) + for i in self.stb_list: + self.r_subtb_list(cl,i) + self.r_stb_stru(cl) + self.r_subtb_stru(cl) + self.get_timespan(cl) + cl.close() + conn.close() + + #query condition + def con_where(self,tlist,col_list,tag_list): + l=[] + for i in range(random.randint(0,len(tlist))): + c = random.choice(where_list) + if c == '_c0>now-10d': + rdate = self.min_ts + (self.max_ts - self.min_ts)/10 * random.randint(-11,11) + conlist = ' _c0 ' + random.choice(['<','>','>=','<=','<>']) + "'" + str(rdate) + "'" + if self.random_pick(): + l.append(conlist) + else: l.append(c) + elif '<50' in c: + conlist = ' ' + random.choice(tlist) + random.choice(['<','>','>=','<=','<>']) + str(random.randrange(-100,100)) + l.append(conlist) + elif 'is null' in c: + conlist = ' ' + random.choice(tlist) + random.choice([' is null',' is not null']) + l.append(conlist) + else: + s_all = string.ascii_letters + conlist = ' ' + random.choice(tlist) + " like \'%" + random.choice(s_all) + "%\' " + l.append(conlist) + return 'where '+random.choice([' and ',' or ']).join(l) + + def con_interval(self,tlist,col_list,tag_list): + interval = 'interval(' + str(random.randint(0,20)) + random.choice(['a','s','d','w','n','y']) + ')' + return interval + + def con_limit(self,tlist,col_list,tag_list): + rand1 = str(random.randint(0,1000)) + rand2 = str(random.randint(0,1000)) + return random.choice(['limit ' + rand1,'limit ' + rand1 + ' offset '+rand2, + ' slimit ' + rand1,' slimit ' + rand1 + ' offset ' + rand2,'limit '+rand1 + ' slimit '+ rand2, + 'limit '+ rand1 + ' offset' + rand2 + ' slimit '+ rand1 + ' soffset ' + rand2 ]) + + def con_fill(self,tlist,col_list,tag_list): + return random.choice(['fill(null)','fill(prev)','fill(none)','fill(LINEAR)']) + + def con_group(self,tlist,col_list,tag_list): + rand_tag = random.randint(0,5) + rand_col = random.randint(0,1) + return 'group by '+','.join(random.sample(col_list,rand_col) + random.sample(tag_list,rand_tag)) + + def con_order(self,tlist,col_list,tag_list): + return 'order by '+random.choice(tlist) + + def gen_query_sql(self): #生成查询语句 + tbi=random.randint(0,len(self.subtb_list)+len(self.stb_list)) #随机决定查询哪张表 + tbname='' + col_list=[] + tag_list=[] + is_stb=0 + if tbi>len(self.stb_list) : + tbi=tbi-len(self.stb_list) + tbname=self.subtb_list[tbi-1] + col_list=self.subtb_stru_list[tbi-1] + tag_list=self.subtb_tag_list[tbi-1] + else: + tbname=self.stb_list[tbi-1] + col_list=self.stb_stru_list[tbi-1] + tag_list=self.stb_tag_list[tbi-1] + is_stb=1 + tlist=col_list+tag_list+['abc'] #增加不存在的域'abc',是否会引起新bug + con_rand=random.randint(0,len(condition_list)) + func_rand=random.randint(0,len(func_list)) + col_rand=random.randint(0,len(col_list)) + tag_rand=random.randint(0,len(tag_list)) + t_rand=random.randint(0,len(tlist)) + sql='select ' #select + random.shuffle(col_list) + random.shuffle(func_list) + sel_col_list=[] + col_rand=random.randint(0,len(col_list)) + loop = 0 + for i,j in zip(col_list[0:col_rand],func_list): #决定每个被查询col的函数 + alias = ' as '+ 'taos%d ' % loop + loop += 1 + pick_func = '' + if j == 'leastsquares': + pick_func=j+'('+i+',1,1)' + elif j == 'top' or j == 'bottom' or j == 'percentile' or j == 'apercentile': + pick_func=j+'('+i+',1)' + else: + pick_func=j+'('+i+')' + if bool(random.getrandbits(1)): + pick_func+=alias + sel_col_list.append(pick_func) + if col_rand == 0: + sql = sql + '*' + else: + sql=sql+','.join(sel_col_list) #select col & func + if self.mix_table == 0: + sql = sql + ' from '+random.choice(self.stb_list+self.subtb_list)+' ' + elif self.mix_table == 1: + sql = sql + ' from '+random.choice(self.subtb_list)+' ' + else: + sql = sql + ' from '+random.choice(self.stb_list)+' ' + con_func=[self.con_where,self.con_interval,self.con_limit,self.con_group,self.con_order,self.con_fill] + sel_con=random.sample(con_func,random.randint(0,len(con_func))) + sel_con_list=[] + for i in sel_con: + sel_con_list.append(i(tlist,col_list,tag_list)) #获取对应的条件函数 + sql+=' '.join(sel_con_list) # condition + #print(sql) + return sql + + def gen_query_join(self): #生成join查询语句 + tbname = [] + col_list = [] + tag_list = [] + col_intersection = [] + tag_intersection = [] + subtable = None + if self.mix_table == 0: + if bool(random.getrandbits(1)): + subtable = True + tbname = random.sample(self.subtb_list,2) + for i in tbname: + col_list.append(self.subtb_stru_list[self.subtb_list.index(i)]) + tag_list.append(self.subtb_stru_list[self.subtb_list.index(i)]) + col_intersection = list(set(col_list[0]).intersection(set(col_list[1]))) + tag_intersection = list(set(tag_list[0]).intersection(set(tag_list[1]))) + else: + tbname = random.sample(self.stb_list,2) + for i in tbname: + col_list.append(self.stb_stru_list[self.stb_list.index(i)]) + tag_list.append(self.stb_stru_list[self.stb_list.index(i)]) + col_intersection = list(set(col_list[0]).intersection(set(col_list[1]))) + tag_intersection = list(set(tag_list[0]).intersection(set(tag_list[1]))) + elif self.mix_table == 1: + subtable = True + tbname = random.sample(self.subtb_list,2) + for i in tbname: + col_list.append(self.subtb_stru_list[self.subtb_list.index(i)]) + tag_list.append(self.subtb_stru_list[self.subtb_list.index(i)]) + col_intersection = list(set(col_list[0]).intersection(set(col_list[1]))) + tag_intersection = list(set(tag_list[0]).intersection(set(tag_list[1]))) + else: + tbname = random.sample(self.stb_list,2) + for i in tbname: + col_list.append(self.stb_stru_list[self.stb_list.index(i)]) + tag_list.append(self.stb_stru_list[self.stb_list.index(i)]) + col_intersection = list(set(col_list[0]).intersection(set(col_list[1]))) + tag_intersection = list(set(tag_list[0]).intersection(set(tag_list[1]))) + con_rand=random.randint(0,len(condition_list)) + col_rand=random.randint(0,len(col_list)) + tag_rand=random.randint(0,len(tag_list)) + sql='select ' #select + + sel_col_tag=[] + col_rand=random.randint(0,len(col_list)) + if bool(random.getrandbits(1)): + sql += '*' + else: + sel_col_tag.append('t1.' + str(random.choice(col_list[0] + tag_list[0]))) + sel_col_tag.append('t2.' + str(random.choice(col_list[1] + tag_list[1]))) + sel_col_list = [] + random.shuffle(func_list) + if self.random_pick(): + loop = 0 + for i,j in zip(sel_col_tag,func_list): #决定每个被查询col的函数 + alias = ' as '+ 'taos%d ' % loop + loop += 1 + pick_func = '' + if j == 'leastsquares': + pick_func=j+'('+i+',1,1)' + elif j == 'top' or j == 'bottom' or j == 'percentile' or j == 'apercentile': + pick_func=j+'('+i+',1)' + else: + pick_func=j+'('+i+')' + if bool(random.getrandbits(1)): + pick_func+=alias + sel_col_list.append(pick_func) + sql += ','.join(sel_col_list) + else: + sql += ','.join(sel_col_tag) + + sql = sql + ' from '+ str(tbname[0]) +' t1,' + str(tbname[1]) + ' t2 ' #select col & func + join_section = None + temp = None + if subtable: + temp = random.choices(col_intersection) + join_section = temp.pop() + sql += 'where t1._c0 = t2._c0 and ' + 't1.' + str(join_section) + '=t2.' + str(join_section) + else: + temp = random.choices(col_intersection+tag_intersection) + join_section = temp.pop() + sql += 'where t1._c0 = t2._c0 and ' + 't1.' + str(join_section) + '=t2.' + str(join_section) + return sql + + def random_pick(self): + x = random.uniform(0,1) + cumulative_probability = 0.0 + for item, item_probability in zip(self.ifjoin, self.probabilities): + cumulative_probability += item_probability + if x < cumulative_probability:break + return item + + def gen_data(self): + stableNum = self.stableNum + subtableNum = self.subtableNum + insertRows = self.insertRows + t0 = self.ts + host = self.host + user = self.user + password = self.password + conn = taos.connect( + host, + user, + password, + ) + cl = conn.cursor() + cl.execute("drop database if exists %s;" %self.dbname) + cl.execute("create database if not exists %s;" %self.dbname) + cl.execute("use %s" % self.dbname) + for k in range(stableNum): + sql="create table %s (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool,c8 binary(20),c9 nchar(20),c11 int unsigned,c12 smallint unsigned,c13 tinyint unsigned,c14 bigint unsigned) \ + tags(t1 int, t2 float, t3 bigint, t4 smallint, t5 tinyint, t6 double, t7 bool,t8 binary(20),t9 nchar(20), t11 int unsigned , t12 smallint unsigned , t13 tinyint unsigned , t14 bigint unsigned)" % (self.stb_prefix+str(k)) + cl.execute(sql) + for j in range(subtableNum): + if j % 100 == 0: + sql = "create table %s using %s tags(NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL)" % \ + (self.subtb_prefix+str(k)+'_'+str(j),self.stb_prefix+str(k)) + else: + sql = "create table %s using %s tags(%d,%d,%d,%d,%d,%d,%d,'%s','%s',%d,%d,%d,%d)" % \ + (self.subtb_prefix+str(k)+'_'+str(j),self.stb_prefix+str(k),j,j/2.0,j%41,j%51,j%53,j*1.0,j%2,'taos'+str(j),'涛思'+str(j), j%43, j%23 , j%17 , j%3167) + print(sql) + cl.execute(sql) + for i in range(insertRows): + if i % 100 == 0 : + ret = cl.execute( + "insert into %s values (%d , NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL)" % + (self.subtb_prefix+str(k)+'_'+str(j), t0+i)) + else: + ret = cl.execute( + "insert into %s values (%d , %d,%d,%d,%d,%d,%d,%d,'%s','%s',%d,%d,%d,%d)" % + (self.subtb_prefix+str(k)+'_'+str(j), t0+i, i%100, i/2.0, i%41, i%51, i%53, i*1.0, i%2,'taos'+str(i),'涛思'+str(i), i%43, i%23 , i%17 , i%3167)) + cl.close() + conn.close() + + def rest_query(self,sql): #rest 接口 + host = self.host + user = self.user + password = self.password + port =6041 + url = "http://{}:{}/rest/sql".format(host, port ) + try: + r = requests.post(url, + data = 'use %s' % self.dbname, + auth = HTTPBasicAuth('root', 'taosdata')) + r = requests.post(url, + data = sql, + auth = HTTPBasicAuth('root', 'taosdata')) + except: + print("REST API Failure (TODO: more info here)") + raise + rj = r.json() + if ('status' not in rj): + raise RuntimeError("No status in REST response") + + if rj['status'] == 'error': # clearly reported error + if ('code' not in rj): # error without code + raise RuntimeError("REST error return without code") + errno = rj['code'] # May need to massage this in the future + # print("Raising programming error with REST return: {}".format(rj)) + raise taos.error.ProgrammingError( + rj['desc'], errno) # todo: check existance of 'desc' + + if rj['status'] != 'succ': # better be this + raise RuntimeError( + "Unexpected REST return status: {}".format( + rj['status'])) + + nRows = rj['rows'] if ('rows' in rj) else 0 + return nRows + + + def query_thread_n(self,threadID): #使用原生python接口查询 + host = self.host + user = self.user + password = self.password + conn = taos.connect( + host, + user, + password, + ) + cl = conn.cursor() + cl.execute("use %s;" % self.dbname) + fo = open('bak_sql_n_%d'%threadID,'w+') + print("Thread %d: starting" % threadID) + loop = self.loop + while loop: + + try: + if self.random_pick(): + sql=self.gen_query_sql() + else: + sql=self.gen_query_join() + print("sql is ",sql) + fo.write(sql+'\n') + start = time.time() + cl.execute(sql) + cl.fetchall() + end = time.time() + print("time cost :",end-start) + except Exception as e: + print('-'*40) + print( + "Failure thread%d, sql: %s \nexception: %s" % + (threadID, str(sql),str(e))) + err_uec='Unable to establish connection' + if err_uec in str(e) and loop >0: + exit(-1) + loop -= 1 + if loop == 0: break + fo.close() + cl.close() + conn.close() + print("Thread %d: finishing" % threadID) + + def query_thread_nr(self,threadID): #使用原生python接口进行重放 + host = self.host + user = self.user + password = self.password + conn = taos.connect( + host, + user, + password, + ) + cl = conn.cursor() + cl.execute("use %s;" % self.dbname) + replay_sql = [] + with open('bak_sql_n_%d'%threadID,'r') as f: + replay_sql = f.readlines() + print("Replay Thread %d: starting" % threadID) + for sql in replay_sql: + try: + print("sql is ",sql) + start = time.time() + cl.execute(sql) + cl.fetchall() + end = time.time() + print("time cost :",end-start) + except Exception as e: + print('-'*40) + print( + "Failure thread%d, sql: %s \nexception: %s" % + (threadID, str(sql),str(e))) + err_uec='Unable to establish connection' + if err_uec in str(e) and loop >0: + exit(-1) + cl.close() + conn.close() + print("Replay Thread %d: finishing" % threadID) + + def query_thread_r(self,threadID): #使用rest接口查询 + print("Thread %d: starting" % threadID) + fo = open('bak_sql_r_%d'%threadID,'w+') + loop = self.loop + while loop: + try: + if self.random_pick(): + sql=self.gen_query_sql() + else: + sql=self.gen_query_join() + print("sql is ",sql) + fo.write(sql+'\n') + start = time.time() + self.rest_query(sql) + end = time.time() + print("time cost :",end-start) + except Exception as e: + print('-'*40) + print( + "Failure thread%d, sql: %s \nexception: %s" % + (threadID, str(sql),str(e))) + err_uec='Unable to establish connection' + if err_uec in str(e) and loop >0: + exit(-1) + loop -= 1 + if loop == 0: break + fo.close() + print("Thread %d: finishing" % threadID) + + def query_thread_rr(self,threadID): #使用rest接口重放 + print("Replay Thread %d: starting" % threadID) + replay_sql = [] + with open('bak_sql_r_%d'%threadID,'r') as f: + replay_sql = f.readlines() + + for sql in replay_sql: + try: + print("sql is ",sql) + start = time.time() + self.rest_query(sql) + end = time.time() + print("time cost :",end-start) + except Exception as e: + print('-'*40) + print( + "Failure thread%d, sql: %s \nexception: %s" % + (threadID, str(sql),str(e))) + err_uec='Unable to establish connection' + if err_uec in str(e) and loop >0: + exit(-1) + print("Replay Thread %d: finishing" % threadID) + + def run(self): + print(self.n_numOfTherads,self.r_numOfTherads) + threads = [] + if self.replay: #whether replay + for i in range(self.n_numOfTherads): + thread = threading.Thread(target=self.query_thread_nr, args=(i,)) + threads.append(thread) + thread.start() + for i in range(self.r_numOfTherads): + thread = threading.Thread(target=self.query_thread_rr, args=(i,)) + threads.append(thread) + thread.start() + else: + for i in range(self.n_numOfTherads): + thread = threading.Thread(target=self.query_thread_n, args=(i,)) + threads.append(thread) + thread.start() + for i in range(self.r_numOfTherads): + thread = threading.Thread(target=self.query_thread_r, args=(i,)) + threads.append(thread) + thread.start() + +parser = argparse.ArgumentParser() +parser.add_argument( + '-H', + '--host-name', + action='store', + default='127.0.0.1', + type=str, + help='host name to be connected (default: 127.0.0.1)') +parser.add_argument( + '-S', + '--ts', + action='store', + default=1500000000000, + type=int, + help='insert data from timestamp (default: 1500000000000)') +parser.add_argument( + '-d', + '--db-name', + action='store', + default='test', + type=str, + help='Database name to be created (default: test)') +parser.add_argument( + '-t', + '--number-of-native-threads', + action='store', + default=10, + type=int, + help='Number of native threads (default: 10)') +parser.add_argument( + '-T', + '--number-of-rest-threads', + action='store', + default=10, + type=int, + help='Number of rest threads (default: 10)') +parser.add_argument( + '-r', + '--number-of-records', + action='store', + default=100, + type=int, + help='Number of record to be created for each table (default: 100)') +parser.add_argument( + '-c', + '--create-table', + action='store', + default='0', + type=int, + help='whether gen data (default: 0)') +parser.add_argument( + '-p', + '--subtb-name-prefix', + action='store', + default='t', + type=str, + help='subtable-name-prefix (default: t)') +parser.add_argument( + '-P', + '--stb-name-prefix', + action='store', + default='st', + type=str, + help='stable-name-prefix (default: st)') +parser.add_argument( + '-b', + '--probabilities', + action='store', + default='0.05', + type=float, + help='probabilities of join (default: 0.05)') +parser.add_argument( + '-l', + '--loop-per-thread', + action='store', + default='100', + type=int, + help='loop per thread (default: 100)') +parser.add_argument( + '-u', + '--user', + action='store', + default='root', + type=str, + help='user name') +parser.add_argument( + '-w', + '--password', + action='store', + default='root', + type=str, + help='user name') +parser.add_argument( + '-n', + '--number-of-tables', + action='store', + default=1000, + type=int, + help='Number of subtales per stable (default: 1000)') +parser.add_argument( + '-N', + '--number-of-stables', + action='store', + default=2, + type=int, + help='Number of stables (default: 2)') +parser.add_argument( + '-m', + '--mix-stable-subtable', + action='store', + default=0, + type=int, + help='0:stable & substable ,1:subtable ,2:stable (default: 0)') +parser.add_argument( + '-R', + '--replay', + action='store', + default=0, + type=int, + help='0:not replay ,1:replay (default: 0)') + +args = parser.parse_args() +q = ConcurrentInquiry( + args.ts,args.host_name,args.user,args.password,args.db_name, + args.stb_name_prefix,args.subtb_name_prefix,args.number_of_native_threads,args.number_of_rest_threads, + args.probabilities,args.loop_per_thread,args.number_of_stables,args.number_of_tables ,args.number_of_records, + args.mix_stable_subtable, args.replay ) + +if args.create_table: + q.gen_data() +q.get_full() + +#q.gen_query_sql() +q.run() + diff --git a/tests/pytest/concurrent_inquiry.sh b/tests/pytest/concurrent_inquiry.sh new file mode 100755 index 0000000000000000000000000000000000000000..6ac15fb46fd727ca56b1aef7e7137ef822e5244a --- /dev/null +++ b/tests/pytest/concurrent_inquiry.sh @@ -0,0 +1,82 @@ +#!/bin/bash + +# This is the script for us to try to cause the TDengine server or client to crash +# +# PREPARATION +# +# 1. Build an compile the TDengine source code that comes with this script, in the same directory tree +# 2. Please follow the direction in our README.md, and build TDengine in the build/ directory +# 3. Adjust the configuration file if needed under build/test/cfg/taos.cfg +# 4. Run the TDengine server instance: cd build; ./build/bin/taosd -c test/cfg +# 5. Make sure you have a working Python3 environment: run /usr/bin/python3 --version, and you should get 3.6 or above +# 6. Make sure you have the proper Python packages: # sudo apt install python3-setuptools python3-pip python3-distutils +# +# RUNNING THIS SCRIPT +# +# This script assumes the source code directory is intact, and that the binaries has been built in the +# build/ directory, as such, will will load the Python libraries in the directory tree, and also load +# the TDengine client shared library (so) file, in the build/directory, as evidenced in the env +# variables below. +# +# Running the script is simple, no parameter is needed (for now, but will change in the future). +# +# Happy Crashing... + + +# Due to the heavy path name assumptions/usage, let us require that the user be in the current directory +EXEC_DIR=`dirname "$0"` +if [[ $EXEC_DIR != "." ]] +then + echo "ERROR: Please execute `basename "$0"` in its own directory (for now anyway, pardon the dust)" + exit -1 +fi + +CURR_DIR=`pwd` +IN_TDINTERNAL="community" +if [[ "$CURR_DIR" == *"$IN_TDINTERNAL"* ]]; then + TAOS_DIR=$CURR_DIR/../../.. + TAOSD_DIR=`find $TAOS_DIR -name "taosd"|grep bin|head -n1` + LIB_DIR=`echo $TAOSD_DIR|rev|cut -d '/' -f 3,4,5,6,7|rev`/lib +else + TAOS_DIR=$CURR_DIR/../.. + TAOSD_DIR=`find $TAOS_DIR -name "taosd"|grep bin|head -n1` + LIB_DIR=`echo $TAOSD_DIR|rev|cut -d '/' -f 3,4,5,6|rev`/lib +fi + +# Now getting ready to execute Python +# The following is the default of our standard dev env (Ubuntu 20.04), modify/adjust at your own risk +PYTHON_EXEC=python3.8 + +# First we need to set up a path for Python to find our own TAOS modules, so that "import" can work. +export PYTHONPATH=$(pwd)/../../src/connector/python:$(pwd) + +# Then let us set up the library path so that our compiled SO file can be loaded by Python +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LIB_DIR + +# Now we are all let, and let's see if we can find a crash. Note we pass all params +CONCURRENT_INQUIRY=concurrent_inquiry.py +if [[ $1 == '--valgrind' ]]; then + shift + export PYTHONMALLOC=malloc + VALGRIND_OUT=valgrind.out + VALGRIND_ERR=valgrind.err + # How to generate valgrind suppression file: https://stackoverflow.com/questions/17159578/generating-suppressions-for-memory-leaks + # valgrind --leak-check=full --gen-suppressions=all --log-fd=9 python3.8 ./concurrent_inquiry.py $@ 9>>memcheck.log + echo Executing under VALGRIND, with STDOUT/ERR going to $VALGRIND_OUT and $VALGRIND_ERR, please watch them from a different terminal. + valgrind \ + --leak-check=yes \ + --suppressions=crash_gen/valgrind_taos.supp \ + $PYTHON_EXEC \ + $CONCURRENT_INQUIRY $@ > $VALGRIND_OUT 2> $VALGRIND_ERR +elif [[ $1 == '--helgrind' ]]; then + shift + HELGRIND_OUT=helgrind.out + HELGRIND_ERR=helgrind.err + valgrind \ + --tool=helgrind \ + $PYTHON_EXEC \ + $CONCURRENT_INQUIRY $@ > $HELGRIND_OUT 2> $HELGRIND_ERR +else + $PYTHON_EXEC $CONCURRENT_INQUIRY $@ +fi + diff --git a/tests/pytest/connector/lua.py b/tests/pytest/connector/lua.py new file mode 100644 index 0000000000000000000000000000000000000000..23f0602e12fe378b97ebf493dcbdb0e9a0a9a8fd --- /dev/null +++ b/tests/pytest/connector/lua.py @@ -0,0 +1,73 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def isLuaInstalled(self): + if not which('lua'): + tdLog.exit("Lua not found!") + return False + else: + return True + + def run(self): + tdSql.prepare() +# tdLog.info("Check if Lua installed") +# if not self.isLuaInstalled(): +# sys.exit(1) + + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + + targetPath = buildPath + "/../tests/examples/lua" + tdLog.info(targetPath) + currentPath = os.getcwd() + os.chdir(targetPath) + os.system('./build.sh') + os.system('lua test.lua') + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +#tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/cq.py b/tests/pytest/cq.py new file mode 100644 index 0000000000000000000000000000000000000000..7778969619f2d0679c2596581d8d76101d41ed9f --- /dev/null +++ b/tests/pytest/cq.py @@ -0,0 +1,169 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- +import threading +import taos +import sys +import json +import time +import random +# query sql +query_sql = [ +# first supertable +"select count(*) from test.meters ;", +"select count(*) from test.meters where t3 > 2;", +"select count(*) from test.meters where ts <> '2020-05-13 10:00:00.002';", +"select count(*) from test.meters where t7 like 'taos_1%';", +"select count(*) from test.meters where t7 like '_____2';", +"select count(*) from test.meters where t8 like '%思%';", +"select count(*) from test.meters interval(1n) order by ts desc;", +#"select max(c0) from test.meters group by tbname", +"select first(ts) from test.meters where t5 >5000 and t5<5100;", +"select last(ts) from test.meters where t5 >5000 and t5<5100;", +"select last_row(*) from test.meters;", +"select twa(c1) from test.t1 where ts > 1500000001000 and ts < 1500000101000" , +"select avg(c1) from test.meters where t5 >5000 and t5<5100;", +"select bottom(c1, 2) from test.t1;", +"select diff(c1) from test.t1;", +"select leastsquares(c1, 1, 1) from test.t1 ;", +"select max(c1) from test.meters where t5 >5000 and t5<5100;", +"select min(c1) from test.meters where t5 >5000 and t5<5100;", +"select c1 + c2 + c1 / c5 + c4 + c2 from test.t1;", +"select percentile(c1, 50) from test.t1;", +"select spread(c1) from test.t1 ;", +"select stddev(c1) from test.t1;", +"select sum(c1) from test.meters where t5 >5000 and t5<5100;", +"select top(c1, 2) from test.meters where t5 >5000 and t5<5100;" +"select twa(c4) from test.t1 where ts > 1500000001000 and ts < 1500000101000" , +"select avg(c4) from test.meters where t5 >5000 and t5<5100;", +"select bottom(c4, 2) from test.t1 where t5 >5000 and t5<5100;", +"select diff(c4) from test.t1 where t5 >5000 and t5<5100;", +"select leastsquares(c4, 1, 1) from test.t1 ;", +"select max(c4) from test.meters where t5 >5000 and t5<5100;", +"select min(c4) from test.meters where t5 >5000 and t5<5100;", +"select c5 + c2 + c4 / c5 + c4 + c2 from test.t1 ;", +"select percentile(c5, 50) from test.t1;", +"select spread(c5) from test.t1 ;", +"select stddev(c5) from test.t1 where t5 >5000 and t5<5100;", +"select sum(c5) from test.meters where t5 >5000 and t5<5100;", +"select top(c5, 2) from test.meters where t5 >5000 and t5<5100;", +#all vnode +"select count(*) from test.meters where t5 >5000 and t5<5100", +"select max(c0),avg(c1) from test.meters where t5 >5000 and t5<5100", +"select sum(c5),avg(c1) from test.meters where t5 >5000 and t5<5100", +"select max(c0),min(c5) from test.meters where t5 >5000 and t5<5100", +"select min(c0),avg(c5) from test.meters where t5 >5000 and t5<5100", +# second supertable +"select count(*) from test.meters1 where t3 > 2;", +"select count(*) from test.meters1 where ts <> '2020-05-13 10:00:00.002';", +"select count(*) from test.meters where t7 like 'taos_1%';", +"select count(*) from test.meters where t7 like '_____2';", +"select count(*) from test.meters where t8 like '%思%';", +"select count(*) from test.meters1 interval(1n) order by ts desc;", +#"select max(c0) from test.meters1 group by tbname", +"select first(ts) from test.meters1 where t5 >5000 and t5<5100;", +"select last(ts) from test.meters1 where t5 >5000 and t5<5100;", +"select last_row(*) from test.meters1 ;", +"select twa(c1) from test.m1 where ts > 1500000001000 and ts < 1500000101000" , +"select avg(c1) from test.meters1 where t5 >5000 and t5<5100;", +"select bottom(c1, 2) from test.m1 where t5 >5000 and t5<5100;", +"select diff(c1) from test.m1 ;", +"select leastsquares(c1, 1, 1) from test.m1 ;", +"select max(c1) from test.meters1 where t5 >5000 and t5<5100;", +"select min(c1) from test.meters1 where t5 >5000 and t5<5100;", +"select c1 + c2 + c1 / c0 + c2 from test.m1 ;", +"select percentile(c1, 50) from test.m1;", +"select spread(c1) from test.m1 ;", +"select stddev(c1) from test.m1;", +"select sum(c1) from test.meters1 where t5 >5000 and t5<5100;", +"select top(c1, 2) from test.meters1 where t5 >5000 and t5<5100;", +"select twa(c5) from test.m1 where ts > 1500000001000 and ts < 1500000101000" , +"select avg(c5) from test.meters1 where t5 >5000 and t5<5100;", +"select bottom(c5, 2) from test.m1;", +"select diff(c5) from test.m1;", +"select leastsquares(c5, 1, 1) from test.m1 ;", +"select max(c5) from test.meters1 where t5 >5000 and t5<5100;", +"select min(c5) from test.meters1 where t5 >5000 and t5<5100;", +"select c5 + c2 + c4 / c5 + c0 from test.m1;", +"select percentile(c4, 50) from test.m1;", +"select spread(c4) from test.m1 ;", +"select stddev(c4) from test.m1;", +"select sum(c4) from test.meters1 where t5 >5100 and t5<5300;", +"select top(c4, 2) from test.meters1 where t5 >5100 and t5<5300;", +"select count(*) from test.meters1 where t5 >5100 and t5<5300", +#all vnode +"select count(*) from test.meters1 where t5 >5100 and t5<5300", +"select max(c0),avg(c1) from test.meters1 where t5 >5000 and t5<5100", +"select sum(c5),avg(c1) from test.meters1 where t5 >5000 and t5<5100", +"select max(c0),min(c5) from test.meters1 where t5 >5000 and t5<5100", +"select min(c0),avg(c5) from test.meters1 where t5 >5000 and t5<5100", +#join +# "select * from meters,meters1 where meters.ts = meters1.ts and meters.t5 = meters1.t5", +# "select * from meters,meters1 where meters.ts = meters1.ts and meters.t7 = meters1.t7", +# "select * from meters,meters1 where meters.ts = meters1.ts and meters.t8 = meters1.t8", +# "select meters.ts,meters1.c2 from meters,meters1 where meters.ts = meters1.ts and meters.t8 = meters1.t8" +] + +class ConcurrentInquiry: + def initConnection(self): + self.numOfTherads = 50 + self.ts=1500000001000 + + def SetThreadsNum(self,num): + self.numOfTherads=num + def query_thread(self,threadID): + host = "10.211.55.14" + user = "root" + password = "taosdata" + conn = taos.connect( + host, + user, + password, + ) + cl = conn.cursor() + cl.execute("use test;") + + print("Thread %d: starting" % threadID) + + while True: + ran_query_sql=query_sql + random.shuffle(ran_query_sql) + for i in ran_query_sql: + print("Thread %d : %s"% (threadID,i)) + try: + start = time.time() + cl.execute(i) + cl.fetchall() + end = time.time() + print("time cost :",end-start) + except Exception as e: + print( + "Failure thread%d, sql: %s,exception: %s" % + (threadID, str(i),str(e))) + exit(-1) + + + print("Thread %d: finishing" % threadID) + + + + def run(self): + + threads = [] + for i in range(self.numOfTherads): + thread = threading.Thread(target=self.query_thread, args=(i,)) + threads.append(thread) + thread.start() + +q = ConcurrentInquiry() +q.initConnection() +q.run() diff --git a/tests/pytest/crash_gen.sh b/tests/pytest/crash_gen.sh new file mode 100755 index 0000000000000000000000000000000000000000..127e13c5be1ea562cbe536bbb05f6ecd5844b0ea --- /dev/null +++ b/tests/pytest/crash_gen.sh @@ -0,0 +1,82 @@ +#!/bin/bash + +# This is the script for us to try to cause the TDengine server or client to crash +# +# PREPARATION +# +# 1. Build an compile the TDengine source code that comes with this script, in the same directory tree +# 2. Please follow the direction in our README.md, and build TDengine in the build/ directory +# 3. Adjust the configuration file if needed under build/test/cfg/taos.cfg +# 4. Run the TDengine server instance: cd build; ./build/bin/taosd -c test/cfg +# 5. Make sure you have a working Python3 environment: run /usr/bin/python3 --version, and you should get 3.6 or above +# 6. Make sure you have the proper Python packages: # sudo apt install python3-setuptools python3-pip python3-distutils +# +# RUNNING THIS SCRIPT +# +# This script assumes the source code directory is intact, and that the binaries has been built in the +# build/ directory, as such, will will load the Python libraries in the directory tree, and also load +# the TDengine client shared library (so) file, in the build/directory, as evidenced in the env +# variables below. +# +# Running the script is simple, no parameter is needed (for now, but will change in the future). +# +# Happy Crashing... + + +# Due to the heavy path name assumptions/usage, let us require that the user be in the current directory +EXEC_DIR=`dirname "$0"` +if [[ $EXEC_DIR != "." ]] +then + echo "ERROR: Please execute `basename "$0"` in its own directory (for now anyway, pardon the dust)" + exit -1 +fi + +CURR_DIR=`pwd` +IN_TDINTERNAL="community" +if [[ "$CURR_DIR" == *"$IN_TDINTERNAL"* ]]; then + TAOS_DIR=$CURR_DIR/../../.. + TAOSD_DIR=`find $TAOS_DIR -name "taosd"|grep bin|head -n1` + LIB_DIR=`echo $TAOSD_DIR|rev|cut -d '/' -f 3,4,5,6,7|rev`/lib +else + TAOS_DIR=$CURR_DIR/../.. + TAOSD_DIR=`find $TAOS_DIR -name "taosd"|grep bin|head -n1` + LIB_DIR=`echo $TAOSD_DIR|rev|cut -d '/' -f 3,4,5,6|rev`/lib +fi + +# Now getting ready to execute Python +# The following is the default of our standard dev env (Ubuntu 20.04), modify/adjust at your own risk +PYTHON_EXEC=python3.8 + +# First we need to set up a path for Python to find our own TAOS modules, so that "import" can work. +export PYTHONPATH=$(pwd)/../../src/connector/python:$(pwd) + +# Then let us set up the library path so that our compiled SO file can be loaded by Python +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LIB_DIR + +# Now we are all let, and let's see if we can find a crash. Note we pass all params +CRASH_GEN_EXEC=crash_gen_bootstrap.py +if [[ $1 == '--valgrind' ]]; then + shift + export PYTHONMALLOC=malloc + VALGRIND_OUT=valgrind.out + VALGRIND_ERR=valgrind.err + # How to generate valgrind suppression file: https://stackoverflow.com/questions/17159578/generating-suppressions-for-memory-leaks + # valgrind --leak-check=full --gen-suppressions=all --log-fd=9 python3.8 ./crash_gen.py $@ 9>>memcheck.log + echo Executing under VALGRIND, with STDOUT/ERR going to $VALGRIND_OUT and $VALGRIND_ERR, please watch them from a different terminal. + valgrind \ + --leak-check=yes \ + --suppressions=crash_gen/valgrind_taos.supp \ + $PYTHON_EXEC \ + $CRASH_GEN_EXEC $@ > $VALGRIND_OUT 2> $VALGRIND_ERR +elif [[ $1 == '--helgrind' ]]; then + shift + HELGRIND_OUT=helgrind.out + HELGRIND_ERR=helgrind.err + valgrind \ + --tool=helgrind \ + $PYTHON_EXEC \ + $CRASH_GEN_EXEC $@ > $HELGRIND_OUT 2> $HELGRIND_ERR +else + $PYTHON_EXEC $CRASH_GEN_EXEC $@ +fi + diff --git a/tests/pytest/crash_gen/README.md b/tests/pytest/crash_gen/README.md new file mode 100644 index 0000000000000000000000000000000000000000..8cdddd5b57c31d563b38d3e8769ab8dc19642347 --- /dev/null +++ b/tests/pytest/crash_gen/README.md @@ -0,0 +1,156 @@ +

User's Guide to the Crash_Gen Tool

+ +# Introduction + +To effectively test and debug our TDengine product, we have developed a simple tool to +exercise various functions of the system in a randomized fashion, hoping to expose +maximum number of problems, hopefully without a pre-determined scenario. + +# Features + +This tool can run as a test client with the following features: + +1. Any number of concurrent threads +1. Any number of test steps/loops +1. Auto-create and writing to multiple databases +1. Ignore specific error codes +1. Write small or large data blocks +1. Auto-generate out-of-sequence data, if needed +1. Verify the result of write operations +1. Concurrent writing to a shadow database for later data verification +1. User specified number of replicas to use, against clusters + +This tool can also use to start a TDengine service, either in stand-alone mode or +cluster mode. The features include: + +1. User specified number of D-Nodes to create/use. + +# Preparation + +To run this tool, please ensure the followed preparation work is done first. + +1. Fetch a copy of the TDengine source code, and build it successfully in the `build/` + directory +1. Ensure that the system has Python3.8 or above properly installed. We use + Ubuntu 20.04LTS as our own development environment, and suggest you also use such + an environment if possible. + +# Simple Execution as Client Test Tool + +To run the tool with the simplest method, follow the steps below: + +1. Open a terminal window, start the `taosd` service in the `build/` directory + (or however you prefer to start the `taosd` service) +1. Open another terminal window, go into the `tests/pytest/` directory, and + run `./crash_gen.sh -p -t 3 -s 10` (change the two parameters here as you wish) +1. Watch the output to the end and see if you get a `SUCCESS` or `FAILURE` + +That's it! + +# Running Server-side Clusters + +This tool also makes it easy to test/verify the clustering capabilities of TDengine. You +can start a cluster quite easily with the following command: + +``` +$ cd tests/pytest/ +$ rm -rf ../../build/cluster_dnode_?; ./crash_gen.sh -e -o 3 # first part optional +``` + +The `-e` option above tells the tool to start the service, and do not run any tests, while +the `-o 3` option tells the tool to start 3 DNodes and join them together in a cluster. +Obviously you can adjust the the number here. The `rm -rf` command line is optional +to clean up previous cluster data, so that we can start from a clean state with no data +at all. + +## Behind the Scenes + +When the tool runs a cluster, it users a number of directories, each holding the information +for a single DNode, see: + +``` +$ ls build/cluster* +build/cluster_dnode_0: +cfg data log + +build/cluster_dnode_1: +cfg data log + +build/cluster_dnode_2: +cfg data log +``` + +Therefore, when something goes wrong and you want to reset everything with the cluster, simple +erase all the files: + +``` +$ rm -rf build/cluster_dnode_* +``` + +## Addresses and Ports + +The DNodes in the cluster all binds the the `127.0.0.1` IP address (for now anyway), and +uses port 6030 for the first DNode, and 6130 for the 2nd one, and so on. + +## Testing Against a Cluster + +In a separate terminal window, you can invoke the tool in client mode and test against +a cluster, such as: + +``` +$ ./crash_gen.sh -p -t 10 -s 100 -i 3 +``` + +Here the `-i` option tells the tool to always create tables with 3 replicas, and run +all tests against such tables. + +# Additional Features + +The exhaustive features of the tool is available through the `-h` option: + +``` +$ ./crash_gen.sh -h +usage: crash_gen_bootstrap.py [-h] [-a] [-b MAX_DBS] [-c CONNECTOR_TYPE] [-d] [-e] [-g IGNORE_ERRORS] + [-i NUM_REPLICAS] [-k] [-l] [-m] [-n] + [-o NUM_DNODES] [-p] [-r] [-s MAX_STEPS] [-t NUM_THREADS] [-v] [-w] [-x] + +TDengine Auto Crash Generator (PLEASE NOTICE the Prerequisites Below) +--------------------------------------------------------------------- +1. You build TDengine in the top level ./build directory, as described in offical docs +2. You run the server there before this script: ./build/bin/taosd -c test/cfg + +optional arguments: + -h, --help show this help message and exit + -a, --auto-start-service + Automatically start/stop the TDengine service (default: false) + -b MAX_DBS, --max-dbs MAX_DBS + Maximum number of DBs to keep, set to disable dropping DB. (default: 0) + -c CONNECTOR_TYPE, --connector-type CONNECTOR_TYPE + Connector type to use: native, rest, or mixed (default: 10) + -d, --debug Turn on DEBUG mode for more logging (default: false) + -e, --run-tdengine Run TDengine service in foreground (default: false) + -g IGNORE_ERRORS, --ignore-errors IGNORE_ERRORS + Ignore error codes, comma separated, 0x supported (default: None) + -i NUM_REPLICAS, --num-replicas NUM_REPLICAS + Number (fixed) of replicas to use, when testing against clusters. (default: 1) + -k, --track-memory-leaks + Use Valgrind tool to track memory leaks (default: false) + -l, --larger-data Write larger amount of data during write operations (default: false) + -m, --mix-oos-data Mix out-of-sequence data into the test data stream (default: true) + -n, --dynamic-db-table-names + Use non-fixed names for dbs/tables, for -b, useful for multi-instance executions (default: false) + -o NUM_DNODES, --num-dnodes NUM_DNODES + Number of Dnodes to initialize, used with -e option. (default: 1) + -p, --per-thread-db-connection + Use a single shared db connection (default: false) + -r, --record-ops Use a pair of always-fsynced fils to record operations performing + performed, for power-off tests (default: false) + -s MAX_STEPS, --max-steps MAX_STEPS + Maximum number of steps to run (default: 100) + -t NUM_THREADS, --num-threads NUM_THREADS + Number of threads to run (default: 10) + -v, --verify-data Verify data written in a number of places by reading back (default: false) + -w, --use-shadow-db Use a shaddow database to verify data integrity (default: false) + -x, --continue-on-exception + Continue execution after encountering unexpected/disallowed errors/exceptions (default: false) +``` + diff --git a/tests/pytest/crash_gen/__init__.py b/tests/pytest/crash_gen/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..fe03bde35473600b27359b81aace21277224fac1 --- /dev/null +++ b/tests/pytest/crash_gen/__init__.py @@ -0,0 +1,2 @@ +# Helpful Ref: https://stackoverflow.com/questions/24100558/how-can-i-split-a-module-into-multiple-files-without-breaking-a-backwards-compa/24100645 +from crash_gen.service_manager import ServiceManager, TdeInstance, TdeSubProcess diff --git a/tests/pytest/crash_gen/crash_gen_main.py b/tests/pytest/crash_gen/crash_gen_main.py new file mode 100755 index 0000000000000000000000000000000000000000..b743eee2ef50c49da050cc78c77d0038acf0e507 --- /dev/null +++ b/tests/pytest/crash_gen/crash_gen_main.py @@ -0,0 +1,2597 @@ +# -----!/usr/bin/python3.7 +################################################################### +# Copyright (c) 2016-2021 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- +# For type hinting before definition, ref: +# https://stackoverflow.com/questions/33533148/how-do-i-specify-that-the-return-type-of-a-method-is-the-same-as-the-class-itsel +from __future__ import annotations + +from typing import Any, Set, Tuple +from typing import Dict +from typing import List +from typing import Optional # Type hinting, ref: https://stackoverflow.com/questions/19202633/python-3-type-hinting-for-none + +import textwrap +import time +import datetime +import random +import threading +import argparse + +import sys +import os +import io +import signal +import traceback +import requests +# from guppy import hpy +import gc +import taos + + +from .shared.types import TdColumns, TdTags + +# from crash_gen import ServiceManager, TdeInstance, TdeSubProcess +# from crash_gen import ServiceManager, Config, DbConn, DbConnNative, Dice, DbManager, Status, Logging, Helper, \ +# CrashGenError, Progress, MyTDSql, \ +# TdeInstance + +from .service_manager import ServiceManager, TdeInstance + +from .shared.config import Config +from .shared.db import DbConn, DbManager, DbConnNative, MyTDSql +from .shared.misc import Dice, Logging, Helper, Status, CrashGenError, Progress +from .shared.types import TdDataType + +# Config.init() + +# Require Python 3 +if sys.version_info[0] < 3: + raise Exception("Must be using Python 3") + +# Global variables, tried to keep a small number. + +# Command-line/Environment Configurations, will set a bit later +# ConfigNameSpace = argparse.Namespace +# gConfig: argparse.Namespace +gSvcMgr: Optional[ServiceManager] # TODO: refactor this hack, use dep injection +# logger: logging.Logger +gContainer: Container + +# def runThread(wt: WorkerThread): +# wt.run() + + +class WorkerThread: + def __init__(self, pool: ThreadPool, tid, tc: ThreadCoordinator): + """ + Note: this runs in the main thread context + """ + # self._curStep = -1 + self._pool = pool + self._tid = tid + self._tc = tc # type: ThreadCoordinator + # self.threadIdent = threading.get_ident() + # self._thread = threading.Thread(target=runThread, args=(self,)) + self._thread = threading.Thread(target=self.run) + self._stepGate = threading.Event() + + # Let us have a DB connection of our own + if (Config.getConfig().per_thread_db_connection): # type: ignore + # print("connector_type = {}".format(gConfig.connector_type)) + tInst = gContainer.defTdeInstance + if Config.getConfig().connector_type == 'native': + self._dbConn = DbConn.createNative(tInst.getDbTarget()) + elif Config.getConfig().connector_type == 'rest': + self._dbConn = DbConn.createRest(tInst.getDbTarget()) + elif Config.getConfig().connector_type == 'mixed': + if Dice.throw(2) == 0: # 1/2 chance + self._dbConn = DbConn.createNative(tInst.getDbTarget()) + else: + self._dbConn = DbConn.createRest(tInst.getDbTarget()) + else: + raise RuntimeError("Unexpected connector type: {}".format(Config.getConfig().connector_type)) + + # self._dbInUse = False # if "use db" was executed already + + def logDebug(self, msg): + Logging.debug(" TRD[{}] {}".format(self._tid, msg)) + + def logInfo(self, msg): + Logging.info(" TRD[{}] {}".format(self._tid, msg)) + + # def dbInUse(self): + # return self._dbInUse + + # def useDb(self): + # if (not self._dbInUse): + # self.execSql("use db") + # self._dbInUse = True + + def getTaskExecutor(self): + return self._tc.getTaskExecutor() + + def start(self): + self._thread.start() # AFTER the thread is recorded + + def run(self): + # initialization after thread starts, in the thread context + # self.isSleeping = False + Logging.info("Starting to run thread: {}".format(self._tid)) + + if (Config.getConfig().per_thread_db_connection): # type: ignore + Logging.debug("Worker thread openning database connection") + self._dbConn.open() + + self._doTaskLoop() + + # clean up + if (Config.getConfig().per_thread_db_connection): # type: ignore + if self._dbConn.isOpen: #sometimes it is not open + self._dbConn.close() + else: + Logging.warning("Cleaning up worker thread, dbConn already closed") + + def _doTaskLoop(self): + # while self._curStep < self._pool.maxSteps: + # tc = ThreadCoordinator(None) + while True: + tc = self._tc # Thread Coordinator, the overall master + try: + tc.crossStepBarrier() # shared barrier first, INCLUDING the last one + except threading.BrokenBarrierError as err: # main thread timed out + print("_bto", end="") + Logging.debug("[TRD] Worker thread exiting due to main thread barrier time-out") + break + + Logging.debug("[TRD] Worker thread [{}] exited barrier...".format(self._tid)) + self.crossStepGate() # then per-thread gate, after being tapped + Logging.debug("[TRD] Worker thread [{}] exited step gate...".format(self._tid)) + if not self._tc.isRunning(): + print("_wts", end="") + Logging.debug("[TRD] Thread Coordinator not running any more, worker thread now stopping...") + break + + + # Before we fetch the task and run it, let's ensure we properly "use" the database (not needed any more) + try: + if (Config.getConfig().per_thread_db_connection): # most likely TRUE + if not self._dbConn.isOpen: # might have been closed during server auto-restart + self._dbConn.open() + # self.useDb() # might encounter exceptions. TODO: catch + except taos.error.ProgrammingError as err: + errno = Helper.convertErrno(err.errno) + if errno in [0x383, 0x386, 0x00B, 0x014] : # invalid database, dropping, Unable to establish connection, Database not ready + # ignore + dummy = 0 + else: + print("\nCaught programming error. errno=0x{:X}, msg={} ".format(errno, err.msg)) + raise + + # Fetch a task from the Thread Coordinator + Logging.debug( "[TRD] Worker thread [{}] about to fetch task".format(self._tid)) + task = tc.fetchTask() + + # Execute such a task + Logging.debug("[TRD] Worker thread [{}] about to execute task: {}".format( + self._tid, task.__class__.__name__)) + task.execute(self) + tc.saveExecutedTask(task) + Logging.debug("[TRD] Worker thread [{}] finished executing task".format(self._tid)) + + # self._dbInUse = False # there may be changes between steps + # print("_wtd", end=None) # worker thread died + + def verifyThreadSelf(self): # ensure we are called by this own thread + if (threading.get_ident() != self._thread.ident): + raise RuntimeError("Unexpectly called from other threads") + + def verifyThreadMain(self): # ensure we are called by the main thread + if (threading.get_ident() != threading.main_thread().ident): + raise RuntimeError("Unexpectly called from other threads") + + def verifyThreadAlive(self): + if (not self._thread.is_alive()): + raise RuntimeError("Unexpected dead thread") + + # A gate is different from a barrier in that a thread needs to be "tapped" + def crossStepGate(self): + self.verifyThreadAlive() + self.verifyThreadSelf() # only allowed by ourselves + + # Wait again at the "gate", waiting to be "tapped" + Logging.debug( + "[TRD] Worker thread {} about to cross the step gate".format( + self._tid)) + self._stepGate.wait() + self._stepGate.clear() + + # self._curStep += 1 # off to a new step... + + def tapStepGate(self): # give it a tap, release the thread waiting there + # self.verifyThreadAlive() + self.verifyThreadMain() # only allowed for main thread + + if self._thread.is_alive(): + Logging.debug("[TRD] Tapping worker thread {}".format(self._tid)) + self._stepGate.set() # wake up! + time.sleep(0) # let the released thread run a bit + else: + print("_tad", end="") # Thread already dead + + def execSql(self, sql): # TODO: expose DbConn directly + return self.getDbConn().execute(sql) + + def querySql(self, sql): # TODO: expose DbConn directly + return self.getDbConn().query(sql) + + def getQueryResult(self): + return self.getDbConn().getQueryResult() + + def getDbConn(self) -> DbConn : + if (Config.getConfig().per_thread_db_connection): + return self._dbConn + else: + return self._tc.getDbManager().getDbConn() + + # def querySql(self, sql): # not "execute", since we are out side the DB context + # if ( gConfig.per_thread_db_connection ): + # return self._dbConn.query(sql) + # else: + # return self._tc.getDbState().getDbConn().query(sql) + +# The coordinator of all worker threads, mostly running in main thread + + +class ThreadCoordinator: + WORKER_THREAD_TIMEOUT = 120 # Normal: 120 + + def __init__(self, pool: ThreadPool, dbManager: DbManager): + self._curStep = -1 # first step is 0 + self._pool = pool + # self._wd = wd + self._te = None # prepare for every new step + self._dbManager = dbManager # type: Optional[DbManager] # may be freed + self._executedTasks: List[Task] = [] # in a given step + self._lock = threading.RLock() # sync access for a few things + + self._stepBarrier = threading.Barrier( + self._pool.numThreads + 1) # one barrier for all threads + self._execStats = ExecutionStats() + self._runStatus = Status.STATUS_RUNNING + self._initDbs() + self._stepStartTime = None # Track how long it takes to execute each step + + def getTaskExecutor(self): + if self._te is None: + raise CrashGenError("Unexpected empty TE") + return self._te + + def getDbManager(self) -> DbManager: + if self._dbManager is None: + raise ChildProcessError("Unexpected empty _dbManager") + return self._dbManager + + def crossStepBarrier(self, timeout=None): + self._stepBarrier.wait(timeout) + + def requestToStop(self): + self._runStatus = Status.STATUS_STOPPING + self._execStats.registerFailure("User Interruption") + + def _runShouldEnd(self, transitionFailed, hasAbortedTask, workerTimeout): + maxSteps = Config.getConfig().max_steps # type: ignore + if self._curStep >= (maxSteps - 1): # maxStep==10, last curStep should be 9 + return True + if self._runStatus != Status.STATUS_RUNNING: + return True + if transitionFailed: + return True + if hasAbortedTask: + return True + if workerTimeout: + return True + return False + + def _hasAbortedTask(self): # from execution of previous step + for task in self._executedTasks: + if task.isAborted(): + # print("Task aborted: {}".format(task)) + # hasAbortedTask = True + return True + return False + + def _releaseAllWorkerThreads(self, transitionFailed): + self._curStep += 1 # we are about to get into next step. TODO: race condition here! + # Now not all threads had time to go to sleep + Logging.debug( + "--\r\n\n--> Step {} starts with main thread waking up".format(self._curStep)) + + # A new TE for the new step + self._te = None # set to empty first, to signal worker thread to stop + if not transitionFailed: # only if not failed + self._te = TaskExecutor(self._curStep) + + Logging.debug("[TRD] Main thread waking up at step {}, tapping worker threads".format( + self._curStep)) # Now not all threads had time to go to sleep + # Worker threads will wake up at this point, and each execute it's own task + self.tapAllThreads() # release all worker thread from their "gates" + + def _syncAtBarrier(self): + # Now main thread (that's us) is ready to enter a step + # let other threads go past the pool barrier, but wait at the + # thread gate + Logging.debug("[TRD] Main thread about to cross the barrier") + self.crossStepBarrier(timeout=self.WORKER_THREAD_TIMEOUT) + self._stepBarrier.reset() # Other worker threads should now be at the "gate" + Logging.debug("[TRD] Main thread finished crossing the barrier") + + def _doTransition(self): + transitionFailed = False + try: + for x in self._dbs: + db = x # type: Database + sm = db.getStateMachine() + Logging.debug("[STT] starting transitions for DB: {}".format(db.getName())) + # at end of step, transiton the DB state + tasksForDb = db.filterTasks(self._executedTasks) + sm.transition(tasksForDb, self.getDbManager().getDbConn()) + Logging.debug("[STT] transition ended for DB: {}".format(db.getName())) + + # Due to limitation (or maybe not) of the TD Python library, + # we cannot share connections across threads + # Here we are in main thread, we cannot operate the connections created in workers + # Moving below to task loop + # if sm.hasDatabase(): + # for t in self._pool.threadList: + # Logging.debug("[DB] use db for all worker threads") + # t.useDb() + # t.execSql("use db") # main thread executing "use + # db" on behalf of every worker thread + + except taos.error.ProgrammingError as err: + if (err.msg == 'network unavailable'): # broken DB connection + Logging.info("DB connection broken, execution failed") + traceback.print_stack() + transitionFailed = True + self._te = None # Not running any more + self._execStats.registerFailure("Broken DB Connection") + # continue # don't do that, need to tap all threads at + # end, and maybe signal them to stop + if isinstance(err, CrashGenError): # our own transition failure + Logging.info("State transition error") + # TODO: saw an error here once, let's print out stack info for err? + traceback.print_stack() + transitionFailed = True + self._te = None # Not running any more + self._execStats.registerFailure("State transition error: {}".format(err)) + else: + raise + # return transitionFailed # Why did we have this??!! + + self.resetExecutedTasks() # clear the tasks after we are done + # Get ready for next step + Logging.debug("<-- Step {} finished, trasition failed = {}".format(self._curStep, transitionFailed)) + return transitionFailed + + def run(self): + self._pool.createAndStartThreads(self) + + # Coordinate all threads step by step + self._curStep = -1 # not started yet + + self._execStats.startExec() # start the stop watch + transitionFailed = False + hasAbortedTask = False + workerTimeout = False + while not self._runShouldEnd(transitionFailed, hasAbortedTask, workerTimeout): + if not Config.getConfig().debug: # print this only if we are not in debug mode + Progress.emit(Progress.STEP_BOUNDARY) + # print(".", end="", flush=True) + # if (self._curStep % 2) == 0: # print memory usage once every 10 steps + # memUsage = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss + # print("[m:{}]".format(memUsage), end="", flush=True) # print memory usage + # if (self._curStep % 10) == 3: + # h = hpy() + # print("\n") + # print(h.heap()) + + + try: + self._syncAtBarrier() # For now just cross the barrier + Progress.emit(Progress.END_THREAD_STEP) + if self._stepStartTime : + stepExecTime = time.time() - self._stepStartTime + Progress.emitStr('{:.3f}s/{}'.format(stepExecTime, DbConnNative.totalRequests)) + DbConnNative.resetTotalRequests() # reset to zero + except threading.BrokenBarrierError as err: + self._execStats.registerFailure("Aborted due to worker thread timeout") + Logging.error("\n") + Logging.error("Main loop aborted, caused by worker thread(s) time-out of {} seconds".format( + ThreadCoordinator.WORKER_THREAD_TIMEOUT)) + Logging.error("TAOS related threads blocked at (stack frames top-to-bottom):") + ts = ThreadStacks() + ts.print(filterInternal=True) + workerTimeout = True + + # Enable below for deadlock debugging, using gdb to attach to process + # while True: + # Logging.error("Deadlock detected") + # time.sleep(60.0) + + break + + # At this point, all threads should be pass the overall "barrier" and before the per-thread "gate" + # We use this period to do house keeping work, when all worker + # threads are QUIET. + hasAbortedTask = self._hasAbortedTask() # from previous step + if hasAbortedTask: + Logging.info("Aborted task encountered, exiting test program") + self._execStats.registerFailure("Aborted Task Encountered") + break # do transition only if tasks are error free + + # Ending previous step + try: + transitionFailed = self._doTransition() # To start, we end step -1 first + except taos.error.ProgrammingError as err: + transitionFailed = True + errno2 = Helper.convertErrno(err.errno) # correct error scheme + errMsg = "Transition failed: errno=0x{:X}, msg: {}".format(errno2, err) + Logging.info(errMsg) + traceback.print_exc() + self._execStats.registerFailure(errMsg) + + # Then we move on to the next step + Progress.emit(Progress.BEGIN_THREAD_STEP) + self._stepStartTime = time.time() + self._releaseAllWorkerThreads(transitionFailed) + + if hasAbortedTask or transitionFailed : # abnormal ending, workers waiting at "gate" + Logging.debug("Abnormal ending of main thraed") + elif workerTimeout: + Logging.debug("Abnormal ending of main thread, due to worker timeout") + else: # regular ending, workers waiting at "barrier" + Logging.debug("Regular ending, main thread waiting for all worker threads to stop...") + self._syncAtBarrier() + + self._te = None # No more executor, time to end + Logging.debug("Main thread tapping all threads one last time...") + self.tapAllThreads() # Let the threads run one last time + + Logging.debug("\r\n\n--> Main thread ready to finish up...") + Logging.debug("Main thread joining all threads") + self._pool.joinAll() # Get all threads to finish + Logging.info(". . . All worker threads finished") # No CR/LF before + self._execStats.endExec() + + def cleanup(self): # free resources + self._pool.cleanup() + + self._pool = None + self._te = None + self._dbManager = None + self._executedTasks = [] + self._lock = None + self._stepBarrier = None + self._execStats = None + self._runStatus = None + + + def printStats(self): + self._execStats.printStats() + + def isFailed(self): + return self._execStats.isFailed() + + def getExecStats(self): + return self._execStats + + def tapAllThreads(self): # in a deterministic manner + wakeSeq = [] + for i in range(self._pool.numThreads): # generate a random sequence + if Dice.throw(2) == 1: + wakeSeq.append(i) + else: + wakeSeq.insert(0, i) + Logging.debug( + "[TRD] Main thread waking up worker threads: {}".format( + str(wakeSeq))) + # TODO: set dice seed to a deterministic value + for i in wakeSeq: + # TODO: maybe a bit too deep?! + self._pool.threadList[i].tapStepGate() + time.sleep(0) # yield + + def isRunning(self): + return self._te is not None + + def _initDbs(self): + ''' Initialize multiple databases, invoked at __ini__() time ''' + self._dbs = [] # type: List[Database] + dbc = self.getDbManager().getDbConn() + if Config.getConfig().max_dbs == 0: + self._dbs.append(Database(0, dbc)) + else: + baseDbNumber = int(datetime.datetime.now().timestamp( # Don't use Dice/random, as they are deterministic + )*333) % 888 if Config.getConfig().dynamic_db_table_names else 0 + for i in range(Config.getConfig().max_dbs): + self._dbs.append(Database(baseDbNumber + i, dbc)) + + def pickDatabase(self): + idxDb = 0 + if Config.getConfig().max_dbs != 0 : + idxDb = Dice.throw(Config.getConfig().max_dbs) # 0 to N-1 + db = self._dbs[idxDb] # type: Database + return db + + def fetchTask(self) -> Task: + ''' The thread coordinator (that's us) is responsible for fetching a task + to be executed next. + ''' + if (not self.isRunning()): # no task + raise RuntimeError("Cannot fetch task when not running") + + # pick a task type for current state + db = self.pickDatabase() + taskType = db.getStateMachine().pickTaskType() # dynamic name of class + return taskType(self._execStats, db) # create a task from it + + def resetExecutedTasks(self): + self._executedTasks = [] # should be under single thread + + def saveExecutedTask(self, task): + with self._lock: + self._executedTasks.append(task) + +class ThreadPool: + def __init__(self, numThreads, maxSteps): + self.numThreads = numThreads + self.maxSteps = maxSteps + # Internal class variables + self.curStep = 0 + self.threadList = [] # type: List[WorkerThread] + + # starting to run all the threads, in locking steps + def createAndStartThreads(self, tc: ThreadCoordinator): + for tid in range(0, self.numThreads): # Create the threads + workerThread = WorkerThread(self, tid, tc) + self.threadList.append(workerThread) + workerThread.start() # start, but should block immediately before step 0 + + def joinAll(self): + for workerThread in self.threadList: + Logging.debug("Joining thread...") + workerThread._thread.join() + + def cleanup(self): + self.threadList = [] # maybe clean up each? + +# A queue of continguous POSITIVE integers, used by DbManager to generate continuous numbers +# for new table names + + +class LinearQueue(): + def __init__(self): + self.firstIndex = 1 # 1st ever element + self.lastIndex = 0 + self._lock = threading.RLock() # our functions may call each other + self.inUse = set() # the indexes that are in use right now + + def toText(self): + return "[{}..{}], in use: {}".format( + self.firstIndex, self.lastIndex, self.inUse) + + # Push (add new element, largest) to the tail, and mark it in use + def push(self): + with self._lock: + # if ( self.isEmpty() ): + # self.lastIndex = self.firstIndex + # return self.firstIndex + # Otherwise we have something + self.lastIndex += 1 + self.allocate(self.lastIndex) + # self.inUse.add(self.lastIndex) # mark it in use immediately + return self.lastIndex + + def pop(self): + with self._lock: + if (self.isEmpty()): + # raise RuntimeError("Cannot pop an empty queue") + return False # TODO: None? + + index = self.firstIndex + if (index in self.inUse): + return False + + self.firstIndex += 1 + return index + + def isEmpty(self): + return self.firstIndex > self.lastIndex + + def popIfNotEmpty(self): + with self._lock: + if (self.isEmpty()): + return 0 + return self.pop() + + def allocate(self, i): + with self._lock: + # Logging.debug("LQ allocating item {}".format(i)) + if (i in self.inUse): + raise RuntimeError( + "Cannot re-use same index in queue: {}".format(i)) + self.inUse.add(i) + + def release(self, i): + with self._lock: + # Logging.debug("LQ releasing item {}".format(i)) + self.inUse.remove(i) # KeyError possible, TODO: why? + + def size(self): + return self.lastIndex + 1 - self.firstIndex + + def pickAndAllocate(self): + if (self.isEmpty()): + return None + with self._lock: + cnt = 0 # counting the interations + while True: + cnt += 1 + if (cnt > self.size() * 10): # 10x iteration already + # raise RuntimeError("Failed to allocate LinearQueue element") + return None + ret = Dice.throwRange(self.firstIndex, self.lastIndex + 1) + if (ret not in self.inUse): + self.allocate(ret) + return ret + + +class AnyState: + STATE_INVALID = -1 + STATE_EMPTY = 0 # nothing there, no even a DB + STATE_DB_ONLY = 1 # we have a DB, but nothing else + STATE_TABLE_ONLY = 2 # we have a table, but totally empty + STATE_HAS_DATA = 3 # we have some data in the table + _stateNames = ["Invalid", "Empty", "DB_Only", "Table_Only", "Has_Data"] + + STATE_VAL_IDX = 0 + CAN_CREATE_DB = 1 + # For below, if we can "drop the DB", but strictly speaking + # only "under normal circumstances", as we may override it with the -b option + CAN_DROP_DB = 2 + CAN_CREATE_FIXED_SUPER_TABLE = 3 + CAN_DROP_FIXED_SUPER_TABLE = 4 + CAN_ADD_DATA = 5 + CAN_READ_DATA = 6 + + def __init__(self): + self._info = self.getInfo() + + def __str__(self): + # -1 hack to accomodate the STATE_INVALID case + return self._stateNames[self._info[self.STATE_VAL_IDX] + 1] + + # Each sub state tells us the "info", about itself, so we can determine + # on things like canDropDB() + def getInfo(self) -> List[Any]: + raise RuntimeError("Must be overriden by child classes") + + def equals(self, other): + if isinstance(other, int): + return self.getValIndex() == other + elif isinstance(other, AnyState): + return self.getValIndex() == other.getValIndex() + else: + raise RuntimeError( + "Unexpected comparison, type = {}".format( + type(other))) + + def verifyTasksToState(self, tasks, newState): + raise RuntimeError("Must be overriden by child classes") + + def getValIndex(self): + return self._info[self.STATE_VAL_IDX] + + def getValue(self): + return self._info[self.STATE_VAL_IDX] + + def canCreateDb(self): + return self._info[self.CAN_CREATE_DB] + + def canDropDb(self): + # If user requests to run up to a number of DBs, + # we'd then not do drop_db operations any more + if Config.getConfig().max_dbs > 0 or Config.getConfig().use_shadow_db : + return False + return self._info[self.CAN_DROP_DB] + + def canCreateFixedSuperTable(self): + return self._info[self.CAN_CREATE_FIXED_SUPER_TABLE] + + def canDropFixedSuperTable(self): + if Config.getConfig().use_shadow_db: # duplicate writes to shaddow DB, in which case let's disable dropping s-table + return False + return self._info[self.CAN_DROP_FIXED_SUPER_TABLE] + + def canAddData(self): + return self._info[self.CAN_ADD_DATA] + + def canReadData(self): + return self._info[self.CAN_READ_DATA] + + def assertAtMostOneSuccess(self, tasks, cls): + sCnt = 0 + for task in tasks: + if not isinstance(task, cls): + continue + if task.isSuccess(): + # task.logDebug("Task success found") + sCnt += 1 + if (sCnt >= 2): + raise CrashGenError( + "Unexpected more than 1 success with task: {}".format(cls)) + + def assertIfExistThenSuccess(self, tasks, cls): + sCnt = 0 + exists = False + for task in tasks: + if not isinstance(task, cls): + continue + exists = True # we have a valid instance + if task.isSuccess(): + sCnt += 1 + if (exists and sCnt <= 0): + raise CrashGenError("Unexpected zero success for task type: {}, from tasks: {}" + .format(cls, tasks)) + + def assertNoTask(self, tasks, cls): + for task in tasks: + if isinstance(task, cls): + raise CrashGenError( + "This task: {}, is not expected to be present, given the success/failure of others".format(cls.__name__)) + + def assertNoSuccess(self, tasks, cls): + for task in tasks: + if isinstance(task, cls): + if task.isSuccess(): + raise CrashGenError( + "Unexpected successful task: {}".format(cls)) + + def hasSuccess(self, tasks, cls): + for task in tasks: + if not isinstance(task, cls): + continue + if task.isSuccess(): + return True + return False + + def hasTask(self, tasks, cls): + for task in tasks: + if isinstance(task, cls): + return True + return False + + +class StateInvalid(AnyState): + def getInfo(self): + return [ + self.STATE_INVALID, + False, False, # can create/drop Db + False, False, # can create/drop fixed table + False, False, # can insert/read data with fixed table + ] + + # def verifyTasksToState(self, tasks, newState): + + +class StateEmpty(AnyState): + def getInfo(self): + return [ + self.STATE_EMPTY, + True, False, # can create/drop Db + False, False, # can create/drop fixed table + False, False, # can insert/read data with fixed table + ] + + def verifyTasksToState(self, tasks, newState): + if (self.hasSuccess(tasks, TaskCreateDb) + ): # at EMPTY, if there's succes in creating DB + if (not self.hasTask(tasks, TaskDropDb)): # and no drop_db tasks + # we must have at most one. TODO: compare numbers + self.assertAtMostOneSuccess(tasks, TaskCreateDb) + + +class StateDbOnly(AnyState): + def getInfo(self): + return [ + self.STATE_DB_ONLY, + False, True, + True, False, + False, False, + ] + + def verifyTasksToState(self, tasks, newState): + if (not self.hasTask(tasks, TaskCreateDb)): + # only if we don't create any more + self.assertAtMostOneSuccess(tasks, TaskDropDb) + + # TODO: restore the below, the problem exists, although unlikely in real-world + # if (gSvcMgr!=None) and gSvcMgr.isRestarting(): + # if (gSvcMgr == None) or (not gSvcMgr.isRestarting()) : + # self.assertIfExistThenSuccess(tasks, TaskDropDb) + + +class StateSuperTableOnly(AnyState): + def getInfo(self): + return [ + self.STATE_TABLE_ONLY, + False, True, + False, True, + True, True, + ] + + def verifyTasksToState(self, tasks, newState): + if (self.hasSuccess(tasks, TaskDropSuperTable) + ): # we are able to drop the table + #self.assertAtMostOneSuccess(tasks, TaskDropSuperTable) + # we must have had recreted it + self.hasSuccess(tasks, TaskCreateSuperTable) + + # self._state = self.STATE_DB_ONLY + # elif ( self.hasSuccess(tasks, AddFixedDataTask) ): # no success dropping the table, but added data + # self.assertNoTask(tasks, DropFixedTableTask) # not true in massively parrallel cases + # self._state = self.STATE_HAS_DATA + # elif ( self.hasSuccess(tasks, ReadFixedDataTask) ): # no success in prev cases, but was able to read data + # self.assertNoTask(tasks, DropFixedTableTask) + # self.assertNoTask(tasks, AddFixedDataTask) + # self._state = self.STATE_TABLE_ONLY # no change + # else: # did not drop table, did not insert data, did not read successfully, that is impossible + # raise RuntimeError("Unexpected no-success scenarios") + # TODO: need to revamp!! + + +class StateHasData(AnyState): + def getInfo(self): + return [ + self.STATE_HAS_DATA, + False, True, + False, True, + True, True, + ] + + def verifyTasksToState(self, tasks, newState): + if (newState.equals(AnyState.STATE_EMPTY)): + self.hasSuccess(tasks, TaskDropDb) + if (not self.hasTask(tasks, TaskCreateDb)): + self.assertAtMostOneSuccess(tasks, TaskDropDb) # TODO: dicy + elif (newState.equals(AnyState.STATE_DB_ONLY)): # in DB only + if (not self.hasTask(tasks, TaskCreateDb) + ): # without a create_db task + # we must have drop_db task + self.assertNoTask(tasks, TaskDropDb) + self.hasSuccess(tasks, TaskDropSuperTable) + # self.assertAtMostOneSuccess(tasks, DropFixedSuperTableTask) # TODO: dicy + # elif ( newState.equals(AnyState.STATE_TABLE_ONLY) ): # data deleted + # self.assertNoTask(tasks, TaskDropDb) + # self.assertNoTask(tasks, TaskDropSuperTable) + # self.assertNoTask(tasks, TaskAddData) + # self.hasSuccess(tasks, DeleteDataTasks) + else: # should be STATE_HAS_DATA + if (not self.hasTask(tasks, TaskCreateDb) + ): # only if we didn't create one + # we shouldn't have dropped it + self.assertNoTask(tasks, TaskDropDb) + if (not self.hasTask(tasks, TaskCreateSuperTable) + ): # if we didn't create the table + # we should not have a task that drops it + self.assertNoTask(tasks, TaskDropSuperTable) + # self.assertIfExistThenSuccess(tasks, ReadFixedDataTask) + + +class StateMechine: + def __init__(self, db: Database): + self._db = db + # transitition target probabilities, indexed with value of STATE_EMPTY, STATE_DB_ONLY, etc. + self._stateWeights = [1, 2, 10, 40] + + def init(self, dbc: DbConn): # late initailization, don't save the dbConn + try: + self._curState = self._findCurrentState(dbc) # starting state + except taos.error.ProgrammingError as err: + Logging.error("Failed to initialized state machine, cannot find current state: {}".format(err)) + traceback.print_stack() + raise # re-throw + + # TODO: seems no lnoger used, remove? + def getCurrentState(self): + return self._curState + + def hasDatabase(self): + return self._curState.canDropDb() # ha, can drop DB means it has one + + # May be slow, use cautionsly... + def getTaskTypes(self): # those that can run (directly/indirectly) from the current state + def typesToStrings(types) -> List: + ss = [] + for t in types: + ss.append(t.__name__) + return ss + + allTaskClasses = StateTransitionTask.__subclasses__() # all state transition tasks + firstTaskTypes = [] + for tc in allTaskClasses: + # t = tc(self) # create task object + if tc.canBeginFrom(self._curState): + firstTaskTypes.append(tc) + # now we have all the tasks that can begin directly from the current + # state, let's figure out the INDIRECT ones + taskTypes = firstTaskTypes.copy() # have to have these + for task1 in firstTaskTypes: # each task type gathered so far + endState = task1.getEndState() # figure the end state + if endState is None: # does not change end state + continue # no use, do nothing + for tc in allTaskClasses: # what task can further begin from there? + if tc.canBeginFrom(endState) and (tc not in firstTaskTypes): + taskTypes.append(tc) # gather it + + if len(taskTypes) <= 0: + raise RuntimeError( + "No suitable task types found for state: {}".format( + self._curState)) + Logging.debug( + "[OPS] Tasks found for state {}: {}".format( + self._curState, + typesToStrings(taskTypes))) + return taskTypes + + def _findCurrentState(self, dbc: DbConn): + ts = time.time() # we use this to debug how fast/slow it is to do the various queries to find the current DB state + dbName =self._db.getName() + if not dbc.existsDatabase(dbName): # dbc.hasDatabases(): # no database?! + Logging.debug( "[STT] empty database found, between {} and {}".format(ts, time.time())) + return StateEmpty() + # did not do this when openning connection, and this is NOT the worker + # thread, which does this on their own + dbc.use(dbName) + if not dbc.hasTables(): # no tables + Logging.debug("[STT] DB_ONLY found, between {} and {}".format(ts, time.time())) + return StateDbOnly() + + # For sure we have tables, which means we must have the super table. # TODO: are we sure? + sTable = self._db.getFixedSuperTable() + if sTable.hasRegTables(dbc): # no regular tables + Logging.debug("[STT] SUPER_TABLE_ONLY found, between {} and {}".format(ts, time.time())) + return StateSuperTableOnly() + else: # has actual tables + Logging.debug("[STT] HAS_DATA found, between {} and {}".format(ts, time.time())) + return StateHasData() + + # We transition the system to a new state by examining the current state itself + def transition(self, tasks, dbc: DbConn): + global gSvcMgr + + if (len(tasks) == 0): # before 1st step, or otherwise empty + Logging.debug("[STT] Starting State: {}".format(self._curState)) + return # do nothing + + # this should show up in the server log, separating steps + dbc.execute("show dnodes") + + # Generic Checks, first based on the start state + if self._curState.canCreateDb(): + self._curState.assertIfExistThenSuccess(tasks, TaskCreateDb) + # self.assertAtMostOneSuccess(tasks, CreateDbTask) # not really, in + # case of multiple creation and drops + + if self._curState.canDropDb(): + if gSvcMgr == None: # only if we are running as client-only + self._curState.assertIfExistThenSuccess(tasks, TaskDropDb) + # self.assertAtMostOneSuccess(tasks, DropDbTask) # not really in + # case of drop-create-drop + + # if self._state.canCreateFixedTable(): + # self.assertIfExistThenSuccess(tasks, CreateFixedTableTask) # Not true, DB may be dropped + # self.assertAtMostOneSuccess(tasks, CreateFixedTableTask) # not + # really, in case of create-drop-create + + # if self._state.canDropFixedTable(): + # self.assertIfExistThenSuccess(tasks, DropFixedTableTask) # Not True, the whole DB may be dropped + # self.assertAtMostOneSuccess(tasks, DropFixedTableTask) # not + # really in case of drop-create-drop + + # if self._state.canAddData(): + # self.assertIfExistThenSuccess(tasks, AddFixedDataTask) # not true + # actually + + # if self._state.canReadData(): + # Nothing for sure + + newState = self._findCurrentState(dbc) + Logging.debug("[STT] New DB state determined: {}".format(newState)) + # can old state move to new state through the tasks? + self._curState.verifyTasksToState(tasks, newState) + self._curState = newState + + def pickTaskType(self): + # all the task types we can choose from at curent state + taskTypes = self.getTaskTypes() + weights = [] + for tt in taskTypes: + endState = tt.getEndState() + if endState is not None: + # TODO: change to a method + weights.append(self._stateWeights[endState.getValIndex()]) + else: + # read data task, default to 10: TODO: change to a constant + weights.append(10) + i = self._weighted_choice_sub(weights) + # Logging.debug(" (weighted random:{}/{}) ".format(i, len(taskTypes))) + return taskTypes[i] + + # ref: + # https://eli.thegreenplace.net/2010/01/22/weighted-random-generation-in-python/ + def _weighted_choice_sub(self, weights) -> int: + # TODO: use our dice to ensure it being determinstic? + rnd = random.random() * sum(weights) + for i, w in enumerate(weights): + rnd -= w + if rnd < 0: + return i + raise CrashGenError("Unexpected no choice") + +class Database: + ''' We use this to represent an actual TDengine database inside a service instance, + possibly in a cluster environment. + + For now we use it to manage state transitions in that database + + TODO: consider moving, but keep in mind it contains "StateMachine" + ''' + _clsLock = threading.Lock() # class wide lock + _lastInt = 101 # next one is initial integer + _lastTick = None # Optional[datetime] + _lastLaggingTick = None # Optional[datetime] # lagging tick, for out-of-sequence (oos) data insertions + + def __init__(self, dbNum: int, dbc: DbConn): # TODO: remove dbc + self._dbNum = dbNum # we assign a number to databases, for our testing purpose + self._stateMachine = StateMechine(self) + self._stateMachine.init(dbc) + + self._lock = threading.RLock() + + def getStateMachine(self) -> StateMechine: + return self._stateMachine + + def getDbNum(self): + return self._dbNum + + def getName(self): + return "db_{}".format(self._dbNum) + + def filterTasks(self, inTasks: List[Task]): # Pick out those belonging to us + outTasks = [] + for task in inTasks: + if task.getDb().isSame(self): + outTasks.append(task) + return outTasks + + def isSame(self, other): + return self._dbNum == other._dbNum + + def exists(self, dbc: DbConn): + return dbc.existsDatabase(self.getName()) + + @classmethod + def getFixedSuperTableName(cls): + return "fs_table" + + def getFixedSuperTable(self) -> TdSuperTable: + return TdSuperTable(self.getFixedSuperTableName(), self.getName()) + + # We aim to create a starting time tick, such that, whenever we run our test here once + # We should be able to safely create 100,000 records, which will not have any repeated time stamp + # when we re-run the test in 3 minutes (180 seconds), basically we should expand time duration + # by a factor of 500. + # TODO: what if it goes beyond 10 years into the future + # TODO: fix the error as result of above: "tsdb timestamp is out of range" + @classmethod + def setupLastTick(cls): + t1 = datetime.datetime(2020, 6, 1) + t2 = datetime.datetime.now() + # maybe a very large number, takes 69 years to exceed Python int range + elSec = int(t2.timestamp() - t1.timestamp()) + elSec2 = (elSec % (8 * 12 * 30 * 24 * 60 * 60 / 500)) * \ + 500 # a number representing seconds within 10 years + # print("elSec = {}".format(elSec)) + t3 = datetime.datetime(2012, 1, 1) # default "keep" is 10 years + t4 = datetime.datetime.fromtimestamp( + t3.timestamp() + elSec2) # see explanation above + Logging.debug("Setting up TICKS to start from: {}".format(t4)) + return t4 + + @classmethod + def getNextTick(cls): + ''' + Fetch a timestamp tick, with some random factor, may not be unique. + ''' + with cls._clsLock: # prevent duplicate tick + if cls._lastLaggingTick is None or cls._lastTick is None : # not initialized + # 10k at 1/20 chance, should be enough to avoid overlaps + tick = cls.setupLastTick() + cls._lastTick = tick + cls._lastLaggingTick = tick + datetime.timedelta(0, -60*2) # lagging behind 2 minutes, should catch up fast + # if : # should be quite a bit into the future + + if Config.isSet('mix_oos_data') and Dice.throw(20) == 0: # if asked to do so, and 1 in 20 chance, return lagging tick + cls._lastLaggingTick += datetime.timedelta(0, 1) # pick the next sequence from the lagging tick sequence + return cls._lastLaggingTick + else: # regular + # add one second to it + cls._lastTick += datetime.timedelta(0, 1) + return cls._lastTick + + def getNextInt(self): + with self._lock: + self._lastInt += 1 + return self._lastInt + + def getNextBinary(self): + return "Beijing_Shanghai_Los_Angeles_New_York_San_Francisco_Chicago_Beijing_Shanghai_Los_Angeles_New_York_San_Francisco_Chicago_{}".format( + self.getNextInt()) + + def getNextFloat(self): + ret = 0.9 + self.getNextInt() + # print("Float obtained: {}".format(ret)) + return ret + + ALL_COLORS = ['red', 'white', 'blue', 'green', 'purple'] + + def getNextColor(self): + return random.choice(self.ALL_COLORS) + + +class TaskExecutor(): + class BoundedList: + def __init__(self, size=10): + self._size = size + self._list = [] + self._lock = threading.Lock() + + def add(self, n: int): + with self._lock: + if not self._list: # empty + self._list.append(n) + return + # now we should insert + nItems = len(self._list) + insPos = 0 + for i in range(nItems): + insPos = i + if n <= self._list[i]: # smaller than this item, time to insert + break # found the insertion point + insPos += 1 # insert to the right + + if insPos == 0: # except for the 1st item, # TODO: elimiate first item as gating item + return # do nothing + + # print("Inserting at postion {}, value: {}".format(insPos, n)) + self._list.insert(insPos, n) # insert + + newLen = len(self._list) + if newLen <= self._size: + return # do nothing + elif newLen == (self._size + 1): + del self._list[0] # remove the first item + else: + raise RuntimeError("Corrupt Bounded List") + + def __str__(self): + return repr(self._list) + + _boundedList = BoundedList() + + def __init__(self, curStep): + self._curStep = curStep + + @classmethod + def getBoundedList(cls): + return cls._boundedList + + def getCurStep(self): + return self._curStep + + def execute(self, task: Task, wt: WorkerThread): # execute a task on a thread + task.execute(wt) + + def recordDataMark(self, n: int): + # print("[{}]".format(n), end="", flush=True) + self._boundedList.add(n) + + # def logInfo(self, msg): + # Logging.info(" T[{}.x]: ".format(self._curStep) + msg) + + # def logDebug(self, msg): + # Logging.debug(" T[{}.x]: ".format(self._curStep) + msg) + + +class Task(): + ''' A generic "Task" to be executed. For now we decide that there is no + need to embed a DB connection here, we use whatever the Worker Thread has + instead. But a task is always associated with a DB + ''' + taskSn = 100 + _lock = threading.Lock() + _tableLocks: Dict[str, threading.Lock] = {} + + @classmethod + def allocTaskNum(cls): + Task.taskSn += 1 # IMPORTANT: cannot use cls.taskSn, since each sub class will have a copy + # Logging.debug("Allocating taskSN: {}".format(Task.taskSn)) + return Task.taskSn + + def __init__(self, execStats: ExecutionStats, db: Database): + self._workerThread = None + self._err: Optional[Exception] = None + self._aborted = False + self._curStep = None + self._numRows = None # Number of rows affected + + # Assign an incremental task serial number + self._taskNum = self.allocTaskNum() + # Logging.debug("Creating new task {}...".format(self._taskNum)) + + self._execStats = execStats + self._db = db # A task is always associated/for a specific DB + + + + def isSuccess(self): + return self._err is None + + def isAborted(self): + return self._aborted + + def clone(self): # TODO: why do we need this again? + newTask = self.__class__(self._execStats, self._db) + return newTask + + def getDb(self): + return self._db + + def logDebug(self, msg): + self._workerThread.logDebug( + "Step[{}.{}] {}".format( + self._curStep, self._taskNum, msg)) + + def logInfo(self, msg): + self._workerThread.logInfo( + "Step[{}.{}] {}".format( + self._curStep, self._taskNum, msg)) + + def _executeInternal(self, te: TaskExecutor, wt: WorkerThread): + raise RuntimeError( + "To be implemeted by child classes, class name: {}".format( + self.__class__.__name__)) + + def _isServiceStable(self): + if not gSvcMgr: + return True # we don't run service, so let's assume it's stable + return gSvcMgr.isStable() # otherwise let's examine the service + + def _isErrAcceptable(self, errno, msg): + if errno in [ + 0x05, # TSDB_CODE_RPC_NOT_READY + 0x0B, # Unable to establish connection, more details in TD-1648 + # 0x200, # invalid SQL, TODO: re-examine with TD-934 + 0x20F, # query terminated, possibly due to vnoding being dropped, see TD-1776 + 0x213, # "Disconnected from service", result of "kill connection ???" + 0x217, # "db not selected", client side defined error code + # 0x218, # "Table does not exist" client side defined error code + 0x360, # Table already exists + 0x362, + # 0x369, # tag already exists + 0x36A, 0x36B, 0x36D, + 0x381, + 0x380, # "db not selected" + 0x383, + 0x386, # DB is being dropped?! + 0x503, + 0x510, # vnode not in ready state + 0x14, # db not ready, errno changed + 0x600, # Invalid table ID, why? + 0x218, # Table does not exist + 1000 # REST catch-all error + ]: + return True # These are the ALWAYS-ACCEPTABLE ones + # This case handled below already. + # elif (errno in [ 0x0B ]) and Settings.getConfig().auto_start_service: + # return True # We may get "network unavilable" when restarting service + elif Config.getConfig().ignore_errors: # something is specified on command line + moreErrnos = [int(v, 0) for v in Config.getConfig().ignore_errors.split(',')] + if errno in moreErrnos: + return True + elif errno == 0x200 : # invalid SQL, we need to div in a bit more + if msg.find("invalid column name") != -1: + return True + elif msg.find("tags number not matched") != -1: # mismatched tags after modification + return True + elif msg.find("duplicated column names") != -1: # also alter table tag issues + return True + elif not self._isServiceStable(): # We are managing service, and ... + Logging.info("Ignoring error when service starting/stopping: errno = {}, msg = {}".format(errno, msg)) + return True + + return False # Not an acceptable error + + + def execute(self, wt: WorkerThread): + wt.verifyThreadSelf() + self._workerThread = wt # type: ignore + + te = wt.getTaskExecutor() + self._curStep = te.getCurStep() + self.logDebug( + "[-] executing task {}...".format(self.__class__.__name__)) + + self._err = None # TODO: type hint mess up? + self._execStats.beginTaskType(self.__class__.__name__) # mark beginning + errno2 = None + + # Now pick a database, and stick with it for the duration of the task execution + dbName = self._db.getName() + try: + self._executeInternal(te, wt) # TODO: no return value? + except taos.error.ProgrammingError as err: + errno2 = Helper.convertErrno(err.errno) + if (Config.getConfig().continue_on_exception): # user choose to continue + self.logDebug("[=] Continue after TAOS exception: errno=0x{:X}, msg: {}, SQL: {}".format( + errno2, err, wt.getDbConn().getLastSql())) + self._err = err + elif self._isErrAcceptable(errno2, err.__str__()): + self.logDebug("[=] Acceptable Taos library exception: errno=0x{:X}, msg: {}, SQL: {}".format( + errno2, err, wt.getDbConn().getLastSql())) + # print("_", end="", flush=True) + Progress.emit(Progress.ACCEPTABLE_ERROR) + self._err = err + else: # not an acceptable error + shortTid = threading.get_ident() % 10000 + errMsg = "[=] Unexpected Taos library exception ({}): errno=0x{:X}, thread={}, msg: {}, SQL: {}".format( + self.__class__.__name__, + errno2, + shortTid, + err, wt.getDbConn().getLastSql()) + self.logDebug(errMsg) + if Config.getConfig().debug: + # raise # so that we see full stack + traceback.print_exc() + print( + "\n\n----------------------------\nProgram ABORTED Due to Unexpected TAOS Error: \n\n{}\n".format(errMsg) + + "----------------------------\n") + # sys.exit(-1) + self._err = err + self._aborted = True + except Exception as e: + Logging.info("Non-TAOS exception encountered with: {}".format(self.__class__.__name__)) + self._err = e + self._aborted = True + traceback.print_exc() + except BaseException as e2: + self.logInfo("Python base exception encountered") + # self._err = e2 # Exception/BaseException incompatible! + self._aborted = True + traceback.print_exc() + # except BaseException: # TODO: what is this again??!! + # raise RuntimeError("Punt") + # self.logDebug( + # "[=] Unexpected exception, SQL: {}".format( + # wt.getDbConn().getLastSql())) + # raise + self._execStats.endTaskType(self.__class__.__name__, self.isSuccess()) + + self.logDebug("[X] task execution completed, {}, status: {}".format( + self.__class__.__name__, "Success" if self.isSuccess() else "Failure")) + # TODO: merge with above. + self._execStats.incExecCount(self.__class__.__name__, self.isSuccess(), errno2) + + # TODO: refactor away, just provide the dbConn + def execWtSql(self, wt: WorkerThread, sql): # execute an SQL on the worker thread + """ Haha """ + return wt.execSql(sql) + + def queryWtSql(self, wt: WorkerThread, sql): # execute an SQL on the worker thread + return wt.querySql(sql) + + def getQueryResult(self, wt: WorkerThread): # execute an SQL on the worker thread + return wt.getQueryResult() + + def lockTable(self, ftName): # full table name + # print(" <<" + ftName + '_', end="", flush=True) + with Task._lock: # SHORT lock! so we only protect lock creation + if not ftName in Task._tableLocks: # Create new lock and add to list, if needed + Task._tableLocks[ftName] = threading.Lock() + + # No lock protection, anybody can do this any time + lock = Task._tableLocks[ftName] + # Logging.info("Acquiring lock: {}, {}".format(ftName, lock)) + lock.acquire() + # Logging.info("Acquiring lock successful: {}".format(lock)) + + def unlockTable(self, ftName): + # print('_' + ftName + ">> ", end="", flush=True) + with Task._lock: + if not ftName in self._tableLocks: + raise RuntimeError("Corrupt state, no such lock") + lock = Task._tableLocks[ftName] + if not lock.locked(): + raise RuntimeError("Corrupte state, already unlocked") + + # Important note, we want to protect unlocking under the task level + # locking, because we don't want the lock to be deleted (maybe in the futur) + # while we unlock it + # Logging.info("Releasing lock: {}".format(lock)) + lock.release() + # Logging.info("Releasing lock successful: {}".format(lock)) + + +class ExecutionStats: + def __init__(self): + # total/success times for a task + self._execTimes: Dict[str, List[int]] = {} + self._tasksInProgress = 0 + self._lock = threading.Lock() + self._firstTaskStartTime = 0.0 + self._execStartTime = 0.0 + self._errors = {} + self._elapsedTime = 0.0 # total elapsed time + self._accRunTime = 0.0 # accumulated run time + + self._failed = False + self._failureReason = None + + def __str__(self): + return "[ExecStats: _failed={}, _failureReason={}".format( + self._failed, self._failureReason) + + def isFailed(self): + return self._failed + + def startExec(self): + self._execStartTime = time.time() + + def endExec(self): + self._elapsedTime = time.time() - self._execStartTime + + def incExecCount(self, klassName, isSuccess, eno=None): # TODO: add a lock here + if klassName not in self._execTimes: + self._execTimes[klassName] = [0, 0] + t = self._execTimes[klassName] # tuple for the data + t[0] += 1 # index 0 has the "total" execution times + if isSuccess: + t[1] += 1 # index 1 has the "success" execution times + if eno != None: + if klassName not in self._errors: + self._errors[klassName] = {} + errors = self._errors[klassName] + errors[eno] = errors[eno]+1 if eno in errors else 1 + + def beginTaskType(self, klassName): + with self._lock: + if self._tasksInProgress == 0: # starting a new round + self._firstTaskStartTime = time.time() # I am now the first task + self._tasksInProgress += 1 + + def endTaskType(self, klassName, isSuccess): + with self._lock: + self._tasksInProgress -= 1 + if self._tasksInProgress == 0: # all tasks have stopped + self._accRunTime += (time.time() - self._firstTaskStartTime) + self._firstTaskStartTime = 0.0 + + def registerFailure(self, reason): + self._failed = True + self._failureReason = reason + + def printStats(self): + Logging.info( + "----------------------------------------------------------------------") + Logging.info( + "| Crash_Gen test {}, with the following stats:". format( + "FAILED (reason: {})".format( + self._failureReason) if self._failed else "SUCCEEDED")) + Logging.info("| Task Execution Times (success/total):") + execTimesAny = 0.0 + for k, n in self._execTimes.items(): + execTimesAny += n[0] + errStr = None + if k in self._errors: + errors = self._errors[k] + # print("errors = {}".format(errors)) + errStrs = ["0x{:X}:{}".format(eno, n) for (eno, n) in errors.items()] + # print("error strings = {}".format(errStrs)) + errStr = ", ".join(errStrs) + Logging.info("| {0:<24}: {1}/{2} (Errors: {3})".format(k, n[1], n[0], errStr)) + + Logging.info( + "| Total Tasks Executed (success or not): {} ".format(execTimesAny)) + Logging.info( + "| Total Tasks In Progress at End: {}".format( + self._tasksInProgress)) + Logging.info( + "| Total Task Busy Time (elapsed time when any task is in progress): {:.3f} seconds".format( + self._accRunTime)) + Logging.info( + "| Average Per-Task Execution Time: {:.3f} seconds".format(self._accRunTime / execTimesAny)) + Logging.info( + "| Total Elapsed Time (from wall clock): {:.3f} seconds".format( + self._elapsedTime)) + Logging.info("| Top numbers written: {}".format(TaskExecutor.getBoundedList())) + Logging.info("| Active DB Native Connections (now): {}".format(DbConnNative.totalConnections)) + Logging.info("| Longest native query time: {:.3f} seconds, started: {}". + format(MyTDSql.longestQueryTime, + time.strftime("%x %X", time.localtime(MyTDSql.lqStartTime))) ) + Logging.info("| Longest native query: {}".format(MyTDSql.longestQuery)) + Logging.info( + "----------------------------------------------------------------------") + + +class StateTransitionTask(Task): + LARGE_NUMBER_OF_TABLES = 35 + SMALL_NUMBER_OF_TABLES = 3 + LARGE_NUMBER_OF_RECORDS = 50 + SMALL_NUMBER_OF_RECORDS = 3 + + _baseTableNumber = None + + _endState = None # TODO: no longter used? + + @classmethod + def getInfo(cls): # each sub class should supply their own information + raise RuntimeError("Overriding method expected") + + @classmethod + def getEndState(cls): # TODO: optimize by calling it fewer times + raise RuntimeError("Overriding method expected") + + # @classmethod + # def getBeginStates(cls): + # return cls.getInfo()[0] + + # @classmethod + # def getEndState(cls): # returning the class name + # return cls.getInfo()[0] + + @classmethod + def canBeginFrom(cls, state: AnyState): + # return state.getValue() in cls.getBeginStates() + raise RuntimeError("must be overriden") + + @classmethod + def getRegTableName(cls, i): + if ( StateTransitionTask._baseTableNumber is None): # Set it one time + StateTransitionTask._baseTableNumber = Dice.throw( + 999) if Config.getConfig().dynamic_db_table_names else 0 + return "reg_table_{}".format(StateTransitionTask._baseTableNumber + i) + + def execute(self, wt: WorkerThread): + super().execute(wt) + + +class TaskCreateDb(StateTransitionTask): + @classmethod + def getEndState(cls): + return StateDbOnly() + + @classmethod + def canBeginFrom(cls, state: AnyState): + return state.canCreateDb() + + # Actually creating the database(es) + def _executeInternal(self, te: TaskExecutor, wt: WorkerThread): + # was: self.execWtSql(wt, "create database db") + repStr = "" + if Config.getConfig().num_replicas != 1: + # numReplica = Dice.throw(Settings.getConfig().max_replicas) + 1 # 1,2 ... N + numReplica = Config.getConfig().num_replicas # fixed, always + repStr = "replica {}".format(numReplica) + updatePostfix = "update 1" if Config.getConfig().verify_data else "" # allow update only when "verify data" is active + dbName = self._db.getName() + self.execWtSql(wt, "create database {} {} {} ".format(dbName, repStr, updatePostfix ) ) + if dbName == "db_0" and Config.getConfig().use_shadow_db: + self.execWtSql(wt, "create database {} {} {} ".format("db_s", repStr, updatePostfix ) ) + +class TaskDropDb(StateTransitionTask): + @classmethod + def getEndState(cls): + return StateEmpty() + + @classmethod + def canBeginFrom(cls, state: AnyState): + return state.canDropDb() + + def _executeInternal(self, te: TaskExecutor, wt: WorkerThread): + self.execWtSql(wt, "drop database {}".format(self._db.getName())) + Logging.debug("[OPS] database dropped at {}".format(time.time())) + +class TaskCreateSuperTable(StateTransitionTask): + @classmethod + def getEndState(cls): + return StateSuperTableOnly() + + @classmethod + def canBeginFrom(cls, state: AnyState): + return state.canCreateFixedSuperTable() + + def _executeInternal(self, te: TaskExecutor, wt: WorkerThread): + if not self._db.exists(wt.getDbConn()): + Logging.debug("Skipping task, no DB yet") + return + + sTable = self._db.getFixedSuperTable() # type: TdSuperTable + # wt.execSql("use db") # should always be in place + + sTable.create(wt.getDbConn(), + {'ts': TdDataType.TIMESTAMP, 'speed': TdDataType.INT, 'color': TdDataType.BINARY16}, { + 'b': TdDataType.BINARY200, 'f': TdDataType.FLOAT}, + dropIfExists=True + ) + # self.execWtSql(wt,"create table db.{} (ts timestamp, speed int) tags (b binary(200), f float) ".format(tblName)) + # No need to create the regular tables, INSERT will do that + # automatically + + +class TdSuperTable: + def __init__(self, stName, dbName): + self._stName = stName + self._dbName = dbName + + def getName(self): + return self._stName + + def drop(self, dbc, skipCheck = False): + dbName = self._dbName + if self.exists(dbc) : # if myself exists + fullTableName = dbName + '.' + self._stName + dbc.execute("DROP TABLE {}".format(fullTableName)) + else: + if not skipCheck: + raise CrashGenError("Cannot drop non-existant super table: {}".format(self._stName)) + + def exists(self, dbc): + dbc.execute("USE " + self._dbName) + return dbc.existsSuperTable(self._stName) + + # TODO: odd semantic, create() method is usually static? + def create(self, dbc, cols: TdColumns, tags: TdTags, dropIfExists = False): + '''Creating a super table''' + + dbName = self._dbName + dbc.execute("USE " + dbName) + fullTableName = dbName + '.' + self._stName + if dbc.existsSuperTable(self._stName): + if dropIfExists: + dbc.execute("DROP TABLE {}".format(fullTableName)) + else: # error + raise CrashGenError("Cannot create super table, already exists: {}".format(self._stName)) + + # Now let's create + sql = "CREATE TABLE {} ({})".format( + fullTableName, + ",".join(['%s %s'%(k,v.value) for (k,v) in cols.items()])) + if tags : + sql += " TAGS ({})".format( + ",".join(['%s %s'%(k,v.value) for (k,v) in tags.items()]) + ) + else: + sql += " TAGS (dummy int) " + dbc.execute(sql) + + def getRegTables(self, dbc: DbConn): + dbName = self._dbName + try: + dbc.query("select TBNAME from {}.{}".format(dbName, self._stName)) # TODO: analyze result set later + except taos.error.ProgrammingError as err: + errno2 = Helper.convertErrno(err.errno) + Logging.debug("[=] Failed to get tables from super table: errno=0x{:X}, msg: {}".format(errno2, err)) + raise + + qr = dbc.getQueryResult() + return [v[0] for v in qr] # list transformation, ref: https://stackoverflow.com/questions/643823/python-list-transformation + + def hasRegTables(self, dbc: DbConn): + return dbc.query("SELECT * FROM {}.{}".format(self._dbName, self._stName)) > 0 + + def ensureRegTable(self, task: Optional[Task], dbc: DbConn, regTableName: str): + ''' + Make sure a regular table exists for this super table, creating it if necessary. + If there is an associated "Task" that wants to do this, "lock" this table so that + others don't access it while we create it. + ''' + dbName = self._dbName + sql = "select tbname from {}.{} where tbname in ('{}')".format(dbName, self._stName, regTableName) + if dbc.query(sql) >= 1 : # reg table exists already + return + + # acquire a lock first, so as to be able to *verify*. More details in TD-1471 + fullTableName = dbName + '.' + regTableName + if task is not None: # Somethime thie operation is requested on behalf of a "task" + # Logging.info("Locking table for creation: {}".format(fullTableName)) + task.lockTable(fullTableName) # in which case we'll lock this table to ensure serialized access + # Logging.info("Table locked for creation".format(fullTableName)) + Progress.emit(Progress.CREATE_TABLE_ATTEMPT) # ATTEMPT to create a new table + # print("(" + fullTableName[-3:] + ")", end="", flush=True) + try: + sql = "CREATE TABLE {} USING {}.{} tags ({})".format( + fullTableName, dbName, self._stName, self._getTagStrForSql(dbc) + ) + # Logging.info("Creating regular with SQL: {}".format(sql)) + dbc.execute(sql) + # Logging.info("Regular table created: {}".format(sql)) + finally: + if task is not None: + # Logging.info("Unlocking table after creation: {}".format(fullTableName)) + task.unlockTable(fullTableName) # no matter what + # Logging.info("Table unlocked after creation: {}".format(fullTableName)) + + def _getTagStrForSql(self, dbc) : + tags = self._getTags(dbc) + tagStrs = [] + for tagName in tags: + tagType = tags[tagName] + if tagType == 'BINARY': + tagStrs.append("'Beijing-Shanghai-LosAngeles'") + elif tagType == 'FLOAT': + tagStrs.append('9.9') + elif tagType == 'INT': + tagStrs.append('88') + else: + raise RuntimeError("Unexpected tag type: {}".format(tagType)) + return ", ".join(tagStrs) + + def _getTags(self, dbc) -> dict: + dbc.query("DESCRIBE {}.{}".format(self._dbName, self._stName)) + stCols = dbc.getQueryResult() + # print(stCols) + ret = {row[0]:row[1] for row in stCols if row[3]=='TAG'} # name:type + # print("Tags retrieved: {}".format(ret)) + return ret + + def addTag(self, dbc, tagName, tagType): + if tagName in self._getTags(dbc): # already + return + # sTable.addTag("extraTag", "int") + sql = "alter table {}.{} add tag {} {}".format( + self._dbName, self._stName, tagName, tagType) + dbc.execute(sql) + + def dropTag(self, dbc, tagName): + if not tagName in self._getTags(dbc): # don't have this tag + return + sql = "alter table {}.{} drop tag {}".format(self._dbName, self._stName, tagName) + dbc.execute(sql) + + def changeTag(self, dbc, oldTag, newTag): + tags = self._getTags(dbc) + if not oldTag in tags: # don't have this tag + return + if newTag in tags: # already have this tag + return + sql = "alter table {}.{} change tag {} {}".format(self._dbName, self._stName, oldTag, newTag) + dbc.execute(sql) + + def generateQueries(self, dbc: DbConn) -> List[SqlQuery]: + ''' Generate queries to test/exercise this super table ''' + ret = [] # type: List[SqlQuery] + + for rTbName in self.getRegTables(dbc): # regular tables + + filterExpr = Dice.choice([ # TODO: add various kind of WHERE conditions + None + ]) + + # Run the query against the regular table first + doAggr = (Dice.throw(2) == 0) # 1 in 2 chance + if not doAggr: # don't do aggregate query, just simple one + ret.append(SqlQuery( # reg table + "select {} from {}.{}".format('*', self._dbName, rTbName))) + ret.append(SqlQuery( # super table + "select {} from {}.{}".format('*', self._dbName, self.getName()))) + else: # Aggregate query + aggExpr = Dice.choice([ + 'count(*)', + 'avg(speed)', + # 'twa(speed)', # TODO: this one REQUIRES a where statement, not reasonable + 'sum(speed)', + 'stddev(speed)', + # SELECTOR functions + 'min(speed)', + 'max(speed)', + 'first(speed)', + 'last(speed)', + 'top(speed, 50)', # TODO: not supported? + 'bottom(speed, 50)', # TODO: not supported? + 'apercentile(speed, 10)', # TODO: TD-1316 + # 'last_row(speed)', # TODO: commented out per TD-3231, we should re-create + # Transformation Functions + # 'diff(speed)', # TODO: no supported?! + 'spread(speed)' + ]) # TODO: add more from 'top' + + + # if aggExpr not in ['stddev(speed)']: # STDDEV not valid for super tables?! (Done in TD-1049) + sql = "select {} from {}.{}".format(aggExpr, self._dbName, self.getName()) + if Dice.throw(3) == 0: # 1 in X chance + sql = sql + ' GROUP BY color' + Progress.emit(Progress.QUERY_GROUP_BY) + # Logging.info("Executing GROUP-BY query: " + sql) + ret.append(SqlQuery(sql)) + + return ret + +class TaskReadData(StateTransitionTask): + @classmethod + def getEndState(cls): + return None # meaning doesn't affect state + + @classmethod + def canBeginFrom(cls, state: AnyState): + return state.canReadData() + + # def _canRestartService(self): + # if not gSvcMgr: + # return True # always + # return gSvcMgr.isActive() # only if it's running TODO: race condition here + + def _reconnectIfNeeded(self, wt): + # 1 in 20 chance, simulate a broken connection, only if service stable (not restarting) + if random.randrange(20)==0: # and self._canRestartService(): # TODO: break connection in all situations + # Logging.info("Attempting to reconnect to server") # TODO: change to DEBUG + Progress.emit(Progress.SERVICE_RECONNECT_START) + try: + wt.getDbConn().close() + wt.getDbConn().open() + except ConnectionError as err: # may fail + if not gSvcMgr: + Logging.error("Failed to reconnect in client-only mode") + raise # Not OK if we are running in client-only mode + if gSvcMgr.isRunning(): # may have race conditon, but low prob, due to + Logging.error("Failed to reconnect when managed server is running") + raise # Not OK if we are running normally + + Progress.emit(Progress.SERVICE_RECONNECT_FAILURE) + # Logging.info("Ignoring DB reconnect error") + + # print("_r", end="", flush=True) + Progress.emit(Progress.SERVICE_RECONNECT_SUCCESS) + # The above might have taken a lot of time, service might be running + # by now, causing error below to be incorrectly handled due to timing issue + return # TODO: fix server restart status race condtion + + + def _executeInternal(self, te: TaskExecutor, wt: WorkerThread): + self._reconnectIfNeeded(wt) + + dbc = wt.getDbConn() + sTable = self._db.getFixedSuperTable() + + for q in sTable.generateQueries(dbc): # regular tables + try: + sql = q.getSql() + # if 'GROUP BY' in sql: + # Logging.info("Executing GROUP-BY query: " + sql) + dbc.execute(sql) + except taos.error.ProgrammingError as err: + errno2 = Helper.convertErrno(err.errno) + Logging.debug("[=] Read Failure: errno=0x{:X}, msg: {}, SQL: {}".format(errno2, err, dbc.getLastSql())) + raise + +class SqlQuery: + @classmethod + def buildRandom(cls, db: Database): + '''Build a random query against a certain database''' + + dbName = db.getName() + + def __init__(self, sql:str = None): + self._sql = sql + + def getSql(self): + return self._sql + +class TaskDropSuperTable(StateTransitionTask): + @classmethod + def getEndState(cls): + return StateDbOnly() + + @classmethod + def canBeginFrom(cls, state: AnyState): + return state.canDropFixedSuperTable() + + def _executeInternal(self, te: TaskExecutor, wt: WorkerThread): + # 1/2 chance, we'll drop the regular tables one by one, in a randomized sequence + if Dice.throw(2) == 0: + # print("_7_", end="", flush=True) + tblSeq = list(range( + 2 + (self.LARGE_NUMBER_OF_TABLES if Config.getConfig().larger_data else self.SMALL_NUMBER_OF_TABLES))) + random.shuffle(tblSeq) + tickOutput = False # if we have spitted out a "d" character for "drop regular table" + isSuccess = True + for i in tblSeq: + regTableName = self.getRegTableName(i) # "db.reg_table_{}".format(i) + try: + self.execWtSql(wt, "drop table {}.{}". + format(self._db.getName(), regTableName)) # nRows always 0, like MySQL + except taos.error.ProgrammingError as err: + # correcting for strange error number scheme + errno2 = Helper.convertErrno(err.errno) + if (errno2 in [0x362]): # mnode invalid table name + isSuccess = False + Logging.debug("[DB] Acceptable error when dropping a table") + continue # try to delete next regular table + + if (not tickOutput): + tickOutput = True # Print only one time + if isSuccess: + print("d", end="", flush=True) + else: + print("f", end="", flush=True) + + # Drop the super table itself + tblName = self._db.getFixedSuperTableName() + self.execWtSql(wt, "drop table {}.{}".format(self._db.getName(), tblName)) + + +class TaskAlterTags(StateTransitionTask): + @classmethod + def getEndState(cls): + return None # meaning doesn't affect state + + @classmethod + def canBeginFrom(cls, state: AnyState): + return state.canDropFixedSuperTable() # if we can drop it, we can alter tags + + def _executeInternal(self, te: TaskExecutor, wt: WorkerThread): + # tblName = self._dbManager.getFixedSuperTableName() + dbc = wt.getDbConn() + sTable = self._db.getFixedSuperTable() + dice = Dice.throw(4) + if dice == 0: + sTable.addTag(dbc, "extraTag", "int") + # sql = "alter table db.{} add tag extraTag int".format(tblName) + elif dice == 1: + sTable.dropTag(dbc, "extraTag") + # sql = "alter table db.{} drop tag extraTag".format(tblName) + elif dice == 2: + sTable.dropTag(dbc, "newTag") + # sql = "alter table db.{} drop tag newTag".format(tblName) + else: # dice == 3 + sTable.changeTag(dbc, "extraTag", "newTag") + # sql = "alter table db.{} change tag extraTag newTag".format(tblName) + +class TaskRestartService(StateTransitionTask): + _isRunning = False + _classLock = threading.Lock() + + @classmethod + def getEndState(cls): + return None # meaning doesn't affect state + + @classmethod + def canBeginFrom(cls, state: AnyState): + if Config.getConfig().auto_start_service: + return state.canDropFixedSuperTable() # Basicallly when we have the super table + return False # don't run this otherwise + + CHANCE_TO_RESTART_SERVICE = 200 + def _executeInternal(self, te: TaskExecutor, wt: WorkerThread): + if not Config.getConfig().auto_start_service: # only execute when we are in -a mode + print("_a", end="", flush=True) + return + + with self._classLock: + if self._isRunning: + Logging.info("Skipping restart task, another running already") + return + self._isRunning = True + + if Dice.throw(self.CHANCE_TO_RESTART_SERVICE) == 0: # 1 in N chance + dbc = wt.getDbConn() + dbc.execute("show databases") # simple delay, align timing with other workers + gSvcMgr.restart() + + self._isRunning = False + +class TaskAddData(StateTransitionTask): + # Track which table is being actively worked on + activeTable: Set[int] = set() + + # We use these two files to record operations to DB, useful for power-off tests + fAddLogReady = None # type: Optional[io.TextIOWrapper] + fAddLogDone = None # type: Optional[io.TextIOWrapper] + + @classmethod + def prepToRecordOps(cls): + if Config.getConfig().record_ops: + if (cls.fAddLogReady is None): + Logging.info( + "Recording in a file operations to be performed...") + cls.fAddLogReady = open("add_log_ready.txt", "w") + if (cls.fAddLogDone is None): + Logging.info("Recording in a file operations completed...") + cls.fAddLogDone = open("add_log_done.txt", "w") + + @classmethod + def getEndState(cls): + return StateHasData() + + @classmethod + def canBeginFrom(cls, state: AnyState): + return state.canAddData() + + def _lockTableIfNeeded(self, fullTableName, extraMsg = ''): + if Config.getConfig().verify_data: + # Logging.info("Locking table: {}".format(fullTableName)) + self.lockTable(fullTableName) + # Logging.info("Table locked {}: {}".format(extraMsg, fullTableName)) + # print("_w" + str(nextInt % 100), end="", flush=True) # Trace what was written + else: + # Logging.info("Skipping locking table") + pass + + def _unlockTableIfNeeded(self, fullTableName): + if Config.getConfig().verify_data: + # Logging.info("Unlocking table: {}".format(fullTableName)) + self.unlockTable(fullTableName) + # Logging.info("Table unlocked: {}".format(fullTableName)) + else: + pass + # Logging.info("Skipping unlocking table") + + def _addDataInBatch(self, db, dbc, regTableName, te: TaskExecutor): + numRecords = self.LARGE_NUMBER_OF_RECORDS if Config.getConfig().larger_data else self.SMALL_NUMBER_OF_RECORDS + + fullTableName = db.getName() + '.' + regTableName + self._lockTableIfNeeded(fullTableName, 'batch') + + sql = "INSERT INTO {} VALUES ".format(fullTableName) + for j in range(numRecords): # number of records per table + nextInt = db.getNextInt() + nextTick = db.getNextTick() + nextColor = db.getNextColor() + sql += "('{}', {}, '{}');".format(nextTick, nextInt, nextColor) + + # Logging.info("Adding data in batch: {}".format(sql)) + try: + dbc.execute(sql) + finally: + # Logging.info("Data added in batch: {}".format(sql)) + self._unlockTableIfNeeded(fullTableName) + + + + def _addData(self, db: Database, dbc, regTableName, te: TaskExecutor): # implied: NOT in batches + numRecords = self.LARGE_NUMBER_OF_RECORDS if Config.getConfig().larger_data else self.SMALL_NUMBER_OF_RECORDS + + for j in range(numRecords): # number of records per table + intToWrite = db.getNextInt() + nextTick = db.getNextTick() + nextColor = db.getNextColor() + if Config.getConfig().record_ops: + self.prepToRecordOps() + if self.fAddLogReady is None: + raise CrashGenError("Unexpected empty fAddLogReady") + self.fAddLogReady.write("Ready to write {} to {}\n".format(intToWrite, regTableName)) + self.fAddLogReady.flush() + os.fsync(self.fAddLogReady.fileno()) + + # TODO: too ugly trying to lock the table reliably, refactor... + fullTableName = db.getName() + '.' + regTableName + self._lockTableIfNeeded(fullTableName) # so that we are verify read-back. TODO: deal with exceptions before unlock + + try: + sql = "INSERT INTO {} VALUES ('{}', {}, '{}');".format( # removed: tags ('{}', {}) + fullTableName, + # ds.getFixedSuperTableName(), + # ds.getNextBinary(), ds.getNextFloat(), + nextTick, intToWrite, nextColor) + # Logging.info("Adding data: {}".format(sql)) + dbc.execute(sql) + # Logging.info("Data added: {}".format(sql)) + intWrote = intToWrite + + # Quick hack, attach an update statement here. TODO: create an "update" task + if (not Config.getConfig().use_shadow_db) and Dice.throw(5) == 0: # 1 in N chance, plus not using shaddow DB + intToUpdate = db.getNextInt() # Updated, but should not succeed + nextColor = db.getNextColor() + sql = "INSERt INTO {} VALUES ('{}', {}, '{}');".format( # "INSERt" means "update" here + fullTableName, + nextTick, intToUpdate, nextColor) + # sql = "UPDATE {} set speed={}, color='{}' WHERE ts='{}'".format( + # fullTableName, db.getNextInt(), db.getNextColor(), nextTick) + dbc.execute(sql) + intWrote = intToUpdate # We updated, seems TDengine non-cluster accepts this. + + except: # Any exception at all + self._unlockTableIfNeeded(fullTableName) + raise + + # Now read it back and verify, we might encounter an error if table is dropped + if Config.getConfig().verify_data: # only if command line asks for it + try: + readBack = dbc.queryScalar("SELECT speed from {}.{} WHERE ts='{}'". + format(db.getName(), regTableName, nextTick)) + if readBack != intWrote : + raise taos.error.ProgrammingError( + "Failed to read back same data, wrote: {}, read: {}" + .format(intWrote, readBack), 0x999) + except taos.error.ProgrammingError as err: + errno = Helper.convertErrno(err.errno) + if errno == CrashGenError.INVALID_EMPTY_RESULT: # empty result + raise taos.error.ProgrammingError( + "Failed to read back same data for tick: {}, wrote: {}, read: EMPTY" + .format(nextTick, intWrote), + errno) + elif errno == CrashGenError.INVALID_MULTIPLE_RESULT : # multiple results + raise taos.error.ProgrammingError( + "Failed to read back same data for tick: {}, wrote: {}, read: MULTIPLE RESULTS" + .format(nextTick, intWrote), + errno) + elif errno in [0x218, 0x362]: # table doesn't exist + # do nothing + pass + else: + # Re-throw otherwise + raise + finally: + self._unlockTableIfNeeded(fullTableName) # Quite ugly, refactor lock/unlock + # Done with read-back verification, unlock the table now + else: + self._unlockTableIfNeeded(fullTableName) + + # Successfully wrote the data into the DB, let's record it somehow + te.recordDataMark(intWrote) + + if Config.getConfig().record_ops: + if self.fAddLogDone is None: + raise CrashGenError("Unexpected empty fAddLogDone") + self.fAddLogDone.write("Wrote {} to {}\n".format(intWrote, regTableName)) + self.fAddLogDone.flush() + os.fsync(self.fAddLogDone.fileno()) + + def _executeInternal(self, te: TaskExecutor, wt: WorkerThread): + # ds = self._dbManager # Quite DANGEROUS here, may result in multi-thread client access + db = self._db + dbc = wt.getDbConn() + numTables = self.LARGE_NUMBER_OF_TABLES if Config.getConfig().larger_data else self.SMALL_NUMBER_OF_TABLES + numRecords = self.LARGE_NUMBER_OF_RECORDS if Config.getConfig().larger_data else self.SMALL_NUMBER_OF_RECORDS + tblSeq = list(range(numTables )) + random.shuffle(tblSeq) # now we have random sequence + for i in tblSeq: + if (i in self.activeTable): # wow already active + # print("x", end="", flush=True) # concurrent insertion + Progress.emit(Progress.CONCURRENT_INSERTION) + else: + self.activeTable.add(i) # marking it active + + dbName = db.getName() + sTable = db.getFixedSuperTable() + regTableName = self.getRegTableName(i) # "db.reg_table_{}".format(i) + fullTableName = dbName + '.' + regTableName + # self._lockTable(fullTableName) # "create table" below. Stop it if the table is "locked" + sTable.ensureRegTable(self, wt.getDbConn(), regTableName) # Ensure the table exists + # self._unlockTable(fullTableName) + + if Dice.throw(1) == 0: # 1 in 2 chance + self._addData(db, dbc, regTableName, te) + else: + self._addDataInBatch(db, dbc, regTableName, te) + + self.activeTable.discard(i) # not raising an error, unlike remove + + +class ThreadStacks: # stack info for all threads + def __init__(self): + self._allStacks = {} + allFrames = sys._current_frames() # All current stack frames + for th in threading.enumerate(): # For each thread + if th.ident is None: + continue + stack = traceback.extract_stack(allFrames[th.ident]) # Get stack for a thread + shortTid = th.ident % 10000 + self._allStacks[shortTid] = stack # Was using th.native_id + + def print(self, filteredEndName = None, filterInternal = False): + for tIdent, stack in self._allStacks.items(): # for each thread, stack frames top to bottom + lastFrame = stack[-1] + if filteredEndName: # we need to filter out stacks that match this name + if lastFrame.name == filteredEndName : # end did not match + continue + if filterInternal: + if lastFrame.name in ['wait', 'invoke_excepthook', + '_wait', # The Barrier exception + 'svcOutputReader', # the svcMgr thread + '__init__']: # the thread that extracted the stack + continue # ignore + # Now print + print("\n<----- Thread Info for LWP/ID: {} (most recent call last) <-----".format(tIdent)) + stackFrame = 0 + for frame in stack: # was using: reversed(stack) + # print(frame) + print("[{sf}] File {filename}, line {lineno}, in {name}".format( + sf=stackFrame, filename=frame.filename, lineno=frame.lineno, name=frame.name)) + print(" {}".format(frame.line)) + stackFrame += 1 + print("-----> End of Thread Info ----->\n") + +class ClientManager: + def __init__(self): + Logging.info("Starting service manager") + # signal.signal(signal.SIGTERM, self.sigIntHandler) + # signal.signal(signal.SIGINT, self.sigIntHandler) + + self._status = Status.STATUS_RUNNING + self.tc = None + + self.inSigHandler = False + + def sigIntHandler(self, signalNumber, frame): + if self._status != Status.STATUS_RUNNING: + print("Repeated SIGINT received, forced exit...") + # return # do nothing if it's already not running + sys.exit(-1) + self._status = Status.STATUS_STOPPING # immediately set our status + + print("ClientManager: Terminating program...") + self.tc.requestToStop() + + def _doMenu(self): + choice = "" + while True: + print("\nInterrupting Client Program, Choose an Action: ") + print("1: Resume") + print("2: Terminate") + print("3: Show Threads") + # Remember to update the if range below + # print("Enter Choice: ", end="", flush=True) + while choice == "": + choice = input("Enter Choice: ") + if choice != "": + break # done with reading repeated input + if choice in ["1", "2", "3"]: + break # we are done with whole method + print("Invalid choice, please try again.") + choice = "" # reset + return choice + + def sigUsrHandler(self, signalNumber, frame): + print("Interrupting main thread execution upon SIGUSR1") + if self.inSigHandler: # already + print("Ignoring repeated SIG_USR1...") + return # do nothing if it's already not running + self.inSigHandler = True + + choice = self._doMenu() + if choice == "1": + print("Resuming execution...") + time.sleep(1.0) + elif choice == "2": + print("Not implemented yet") + time.sleep(1.0) + elif choice == "3": + ts = ThreadStacks() + ts.print() + else: + raise RuntimeError("Invalid menu choice: {}".format(choice)) + + self.inSigHandler = False + + # TODO: need to revise how we verify data durability + # def _printLastNumbers(self): # to verify data durability + # dbManager = DbManager() + # dbc = dbManager.getDbConn() + # if dbc.query("show databases") <= 1: # no database (we have a default called "log") + # return + # dbc.execute("use db") + # if dbc.query("show tables") == 0: # no tables + # return + + # sTbName = dbManager.getFixedSuperTableName() + + # # get all regular tables + # # TODO: analyze result set later + # dbc.query("select TBNAME from db.{}".format(sTbName)) + # rTables = dbc.getQueryResult() + + # bList = TaskExecutor.BoundedList() + # for rTbName in rTables: # regular tables + # dbc.query("select speed from db.{}".format(rTbName[0])) + # numbers = dbc.getQueryResult() + # for row in numbers: + # # print("<{}>".format(n), end="", flush=True) + # bList.add(row[0]) + + # print("Top numbers in DB right now: {}".format(bList)) + # print("TDengine client execution is about to start in 2 seconds...") + # time.sleep(2.0) + # dbManager = None # release? + + def run(self, svcMgr): + # self._printLastNumbers() + # global gConfig + + # Prepare Tde Instance + global gContainer + tInst = gContainer.defTdeInstance = TdeInstance() # "subdir to hold the instance" + + cfg = Config.getConfig() + dbManager = DbManager(cfg.connector_type, tInst.getDbTarget()) # Regular function + thPool = ThreadPool(cfg.num_threads, cfg.max_steps) + self.tc = ThreadCoordinator(thPool, dbManager) + + Logging.info("Starting client instance: {}".format(tInst)) + self.tc.run() + # print("exec stats: {}".format(self.tc.getExecStats())) + # print("TC failed = {}".format(self.tc.isFailed())) + if svcMgr: # gConfig.auto_start_service: + svcMgr.stopTaosServices() + svcMgr = None + + + # Release global variables + # gConfig = None + Config.clearConfig() + gSvcMgr = None + logger = None + + thPool = None + dbManager.cleanUp() # destructor wouldn't run in time + dbManager = None + + # Print exec status, etc., AFTER showing messages from the server + self.conclude() + # print("TC failed (2) = {}".format(self.tc.isFailed())) + # Linux return code: ref https://shapeshed.com/unix-exit-codes/ + ret = 1 if self.tc.isFailed() else 0 + self.tc.cleanup() + # Release variables here + self.tc = None + + gc.collect() # force garbage collection + # h = hpy() + # print("\n----- Final Python Heap -----\n") + # print(h.heap()) + + return ret + + def conclude(self): + # self.tc.getDbManager().cleanUp() # clean up first, so we can show ZERO db connections + self.tc.printStats() + +class MainExec: + def __init__(self): + self._clientMgr = None + self._svcMgr = None # type: Optional[ServiceManager] + + signal.signal(signal.SIGTERM, self.sigIntHandler) + signal.signal(signal.SIGINT, self.sigIntHandler) + signal.signal(signal.SIGUSR1, self.sigUsrHandler) # different handler! + + def sigUsrHandler(self, signalNumber, frame): + if self._clientMgr: + self._clientMgr.sigUsrHandler(signalNumber, frame) + elif self._svcMgr: # Only if no client mgr, we are running alone + self._svcMgr.sigUsrHandler(signalNumber, frame) + + def sigIntHandler(self, signalNumber, frame): + if self._svcMgr: + self._svcMgr.sigIntHandler(signalNumber, frame) + if self._clientMgr: + self._clientMgr.sigIntHandler(signalNumber, frame) + + def runClient(self): + global gSvcMgr + if Config.getConfig().auto_start_service: + gSvcMgr = self._svcMgr = ServiceManager(1) # hack alert + gSvcMgr.startTaosServices() # we start, don't run + + self._clientMgr = ClientManager() + ret = None + try: + ret = self._clientMgr.run(self._svcMgr) # stop TAOS service inside + except requests.exceptions.ConnectionError as err: + Logging.warning("Failed to open REST connection to DB: {}".format(err)) + # don't raise + return ret + + def runService(self): + global gSvcMgr + gSvcMgr = self._svcMgr = ServiceManager(Config.getConfig().num_dnodes) # save it in a global variable TODO: hack alert + + gSvcMgr.run() # run to some end state + gSvcMgr = self._svcMgr = None + + def _buildCmdLineParser(self): + parser = argparse.ArgumentParser( + formatter_class=argparse.RawDescriptionHelpFormatter, + description=textwrap.dedent('''\ + TDengine Auto Crash Generator (PLEASE NOTICE the Prerequisites Below) + --------------------------------------------------------------------- + 1. You build TDengine in the top level ./build directory, as described in offical docs + 2. You run the server there before this script: ./build/bin/taosd -c test/cfg + + ''')) + + parser.add_argument( + '-a', + '--auto-start-service', + action='store_true', + help='Automatically start/stop the TDengine service (default: false)') + parser.add_argument( + '-b', + '--max-dbs', + action='store', + default=0, + type=int, + help='Number of DBs to use, set to disable dropping DB. (default: 0)') + parser.add_argument( + '-c', + '--connector-type', + action='store', + default='native', + type=str, + help='Connector type to use: native, rest, or mixed (default: 10)') + parser.add_argument( + '-d', + '--debug', + action='store_true', + help='Turn on DEBUG mode for more logging (default: false)') + parser.add_argument( + '-e', + '--run-tdengine', + action='store_true', + help='Run TDengine service in foreground (default: false)') + parser.add_argument( + '-g', + '--ignore-errors', + action='store', + default=None, + type=str, + help='Ignore error codes, comma separated, 0x supported (default: None)') + parser.add_argument( + '-i', + '--num-replicas', + action='store', + default=1, + type=int, + help='Number (fixed) of replicas to use, when testing against clusters. (default: 1)') + parser.add_argument( + '-k', + '--track-memory-leaks', + action='store_true', + help='Use Valgrind tool to track memory leaks (default: false)') + parser.add_argument( + '-l', + '--larger-data', + action='store_true', + help='Write larger amount of data during write operations (default: false)') + parser.add_argument( + '-m', + '--mix-oos-data', + action='store_false', + help='Mix out-of-sequence data into the test data stream (default: true)') + parser.add_argument( + '-n', + '--dynamic-db-table-names', + action='store_true', + help='Use non-fixed names for dbs/tables, for -b, useful for multi-instance executions (default: false)') + parser.add_argument( + '-o', + '--num-dnodes', + action='store', + default=1, + type=int, + help='Number of Dnodes to initialize, used with -e option. (default: 1)') + parser.add_argument( + '-p', + '--per-thread-db-connection', + action='store_true', + help='Use a single shared db connection (default: false)') + parser.add_argument( + '-r', + '--record-ops', + action='store_true', + help='Use a pair of always-fsynced fils to record operations performing + performed, for power-off tests (default: false)') + parser.add_argument( + '-s', + '--max-steps', + action='store', + default=1000, + type=int, + help='Maximum number of steps to run (default: 100)') + parser.add_argument( + '-t', + '--num-threads', + action='store', + default=5, + type=int, + help='Number of threads to run (default: 10)') + parser.add_argument( + '-v', + '--verify-data', + action='store_true', + help='Verify data written in a number of places by reading back (default: false)') + parser.add_argument( + '-w', + '--use-shadow-db', + action='store_true', + help='Use a shaddow database to verify data integrity (default: false)') + parser.add_argument( + '-x', + '--continue-on-exception', + action='store_true', + help='Continue execution after encountering unexpected/disallowed errors/exceptions (default: false)') + + return parser + + + def init(self): # TODO: refactor + global gContainer + gContainer = Container() # micky-mouse DI + + global gSvcMgr # TODO: refactor away + gSvcMgr = None + + parser = self._buildCmdLineParser() + Config.init(parser) + + # Sanity check for arguments + if Config.getConfig().use_shadow_db and Config.getConfig().max_dbs>1 : + raise CrashGenError("Cannot combine use-shadow-db with max-dbs of more than 1") + + Logging.clsInit(Config.getConfig().debug) + + Dice.seed(0) # initial seeding of dice + + def run(self): + if Config.getConfig().run_tdengine: # run server + try: + self.runService() + return 0 # success + except ConnectionError as err: + Logging.error("Failed to make DB connection, please check DB instance manually") + return -1 # failure + else: + return self.runClient() + + +class Container(): + _propertyList = {'defTdeInstance'} + + def __init__(self): + self._cargo = {} # No cargo at the beginning + + def _verifyValidProperty(self, name): + if not name in self._propertyList: + raise CrashGenError("Invalid container property: {}".format(name)) + + # Called for an attribute, when other mechanisms fail (compare to __getattribute__) + def __getattr__(self, name): + self._verifyValidProperty(name) + return self._cargo[name] # just a simple lookup + + def __setattr__(self, name, value): + if name == '_cargo' : # reserved vars + super().__setattr__(name, value) + return + self._verifyValidProperty(name) + self._cargo[name] = value + diff --git a/tests/pytest/crash_gen/service_manager.py b/tests/pytest/crash_gen/service_manager.py new file mode 100644 index 0000000000000000000000000000000000000000..ea31e4fc807701b73fc7d06747c42043095e996f --- /dev/null +++ b/tests/pytest/crash_gen/service_manager.py @@ -0,0 +1,955 @@ +from __future__ import annotations + +import os +import io +import sys +from enum import Enum +import threading +import signal +import logging +import time +from subprocess import PIPE, Popen, TimeoutExpired +from typing import BinaryIO, Generator, IO, List, NewType, Optional +import typing + +try: + import psutil +except: + print("Psutil module needed, please install: sudo pip3 install psutil") + sys.exit(-1) +from queue import Queue, Empty + +from .shared.config import Config +from .shared.db import DbTarget, DbConn +from .shared.misc import Logging, Helper, CrashGenError, Status, Progress, Dice +from .shared.types import DirPath, IpcStream + +# from crash_gen.misc import CrashGenError, Dice, Helper, Logging, Progress, Status +# from crash_gen.db import DbConn, DbTarget +# from crash_gen.settings import Config +# from crash_gen.types import DirPath + +class TdeInstance(): + """ + A class to capture the *static* information of a TDengine instance, + including the location of the various files/directories, and basica + configuration. + """ + + @classmethod + def _getBuildPath(cls): + selfPath = os.path.dirname(os.path.realpath(__file__)) + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("communit")] + else: + projPath = selfPath[:selfPath.find("tests")] + + buildPath = None + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + if buildPath == None: + raise RuntimeError("Failed to determine buildPath, selfPath={}, projPath={}" + .format(selfPath, projPath)) + return buildPath + + @classmethod + def prepareGcovEnv(cls, env): + # Ref: https://gcc.gnu.org/onlinedocs/gcc/Cross-profiling.html + bPath = cls._getBuildPath() # build PATH + numSegments = len(bPath.split('/')) # "/x/TDengine/build" should yield 3 + # numSegments += 2 # cover "/src" after build + # numSegments = numSegments - 1 # DEBUG only + env['GCOV_PREFIX'] = bPath + '/src_s' # Server side source + env['GCOV_PREFIX_STRIP'] = str(numSegments) # Strip every element, plus, ENV needs strings + # VERY VERY important note: GCOV data collection NOT effective upon SIG_KILL + Logging.info("Preparing GCOV environement to strip {} elements and use path: {}".format( + numSegments, env['GCOV_PREFIX'] )) + + def __init__(self, subdir='test', tInstNum=0, port=6030, fepPort=6030): + self._buildDir = self._getBuildPath() + self._subdir = '/' + subdir # TODO: tolerate "/" + self._port = port # TODO: support different IP address too + self._fepPort = fepPort + + self._tInstNum = tInstNum + + # An "Tde Instance" will *contain* a "sub process" object, with will/may use a thread internally + # self._smThread = ServiceManagerThread() + self._subProcess = None # type: Optional[TdeSubProcess] + + def getDbTarget(self): + return DbTarget(self.getCfgDir(), self.getHostAddr(), self._port) + + def getPort(self): + return self._port + + def __repr__(self): + return "[TdeInstance: {}, subdir={}]".format( + self._buildDir, Helper.getFriendlyPath(self._subdir)) + + def generateCfgFile(self): + # print("Logger = {}".format(logger)) + # buildPath = self.getBuildPath() + # taosdPath = self._buildPath + "/build/bin/taosd" + + cfgDir = self.getCfgDir() + cfgFile = cfgDir + "/taos.cfg" # TODO: inquire if this is fixed + if os.path.exists(cfgFile): + if os.path.isfile(cfgFile): + Logging.warning("Config file exists already, skip creation: {}".format(cfgFile)) + return # cfg file already exists, nothing to do + else: + raise CrashGenError("Invalid config file: {}".format(cfgFile)) + # Now that the cfg file doesn't exist + if os.path.exists(cfgDir): + if not os.path.isdir(cfgDir): + raise CrashGenError("Invalid config dir: {}".format(cfgDir)) + # else: good path + else: + os.makedirs(cfgDir, exist_ok=True) # like "mkdir -p" + # Now we have a good cfg dir + cfgValues = { + 'runDir': self.getRunDir(), + 'ip': '127.0.0.1', # TODO: change to a network addressable ip + 'port': self._port, + 'fepPort': self._fepPort, + } + cfgTemplate = """ +dataDir {runDir}/data +logDir {runDir}/log + +charset UTF-8 + +firstEp {ip}:{fepPort} +fqdn {ip} +serverPort {port} + +# was all 135 below +dDebugFlag 135 +cDebugFlag 135 +rpcDebugFlag 135 +qDebugFlag 135 +# httpDebugFlag 143 +asyncLog 0 +debugflag 143 +# tables 10 +maxtablesPerVnode 10 +rpcMaxTime 101 +# cache 2 +keep 36500 +# walLevel 2 +walLevel 1 +# +# maxConnections 100 +quorum 2 +""" + cfgContent = cfgTemplate.format_map(cfgValues) + f = open(cfgFile, "w") + f.write(cfgContent) + f.close() + + def rotateLogs(self): + logPath = self.getLogDir() + # ref: https://stackoverflow.com/questions/1995373/deleting-all-files-in-a-directory-with-python/1995397 + if os.path.exists(logPath): + logPathSaved = logPath + "_" + time.strftime('%Y-%m-%d-%H-%M-%S') + Logging.info("Saving old log files to: {}".format(logPathSaved)) + os.rename(logPath, logPathSaved) + # os.mkdir(logPath) # recreate, no need actually, TDengine will auto-create with proper perms + + + def getExecFile(self): # .../taosd + return self._buildDir + "/build/bin/taosd" + + def getRunDir(self) -> DirPath : # TODO: rename to "root dir" ?! + return DirPath(self._buildDir + self._subdir) + + def getCfgDir(self) -> DirPath : # path, not file + return DirPath(self.getRunDir() + "/cfg") + + def getLogDir(self) -> DirPath : + return DirPath(self.getRunDir() + "/log") + + def getHostAddr(self): + return "127.0.0.1" + + def getServiceCmdLine(self): # to start the instance + if Config.getConfig().track_memory_leaks: + Logging.info("Invoking VALGRIND on service...") + return ['exec valgrind', '--leak-check=yes', self.getExecFile(), '-c', self.getCfgDir()] + else: + # TODO: move "exec -c" into Popen(), we can both "use shell" and NOT fork so ask to lose kill control + return ["exec " + self.getExecFile(), '-c', self.getCfgDir()] # used in subproce.Popen() + + def _getDnodes(self, dbc): + dbc.query("show dnodes") + cols = dbc.getQueryResult() # id,end_point,vnodes,cores,status,role,create_time,offline reason + return {c[1]:c[4] for c in cols} # {'xxx:6030':'ready', 'xxx:6130':'ready'} + + def createDnode(self, dbt: DbTarget): + """ + With a connection to the "first" EP, let's create a dnode for someone else who + wants to join. + """ + dbc = DbConn.createNative(self.getDbTarget()) + dbc.open() + + if dbt.getEp() in self._getDnodes(dbc): + Logging.info("Skipping DNode creation for: {}".format(dbt)) + dbc.close() + return + + sql = "CREATE DNODE \"{}\"".format(dbt.getEp()) + dbc.execute(sql) + dbc.close() + + def getStatus(self): + # return self._smThread.getStatus() + if self._subProcess is None: + return Status(Status.STATUS_EMPTY) + return self._subProcess.getStatus() + + # def getSmThread(self): + # return self._smThread + + def start(self): + if self.getStatus().isActive(): + raise CrashGenError("Cannot start instance from status: {}".format(self.getStatus())) + + Logging.info("Starting TDengine instance: {}".format(self)) + self.generateCfgFile() # service side generates config file, client does not + self.rotateLogs() + + # self._smThread.start(self.getServiceCmdLine(), self.getLogDir()) # May raise exceptions + self._subProcess = TdeSubProcess(self.getServiceCmdLine(), self.getLogDir()) + + def stop(self): + self._subProcess.stop() + self._subProcess = None + + def isFirst(self): + return self._tInstNum == 0 + + def printFirst10Lines(self): + if self._subProcess is None: + Logging.warning("Incorrect TI status for procIpcBatch-10 operation") + return + self._subProcess.procIpcBatch(trimToTarget=10, forceOutput=True) + + def procIpcBatch(self): + if self._subProcess is None: + Logging.warning("Incorrect TI status for procIpcBatch operation") + return + self._subProcess.procIpcBatch() # may enounter EOF and change status to STOPPED + if self._subProcess.getStatus().isStopped(): + self._subProcess.stop() + self._subProcess = None + +class TdeSubProcess: + """ + A class to to represent the actual sub process that is the run-time + of a TDengine instance. + + It takes a TdeInstance object as its parameter, with the rationale being + "a sub process runs an instance". + + We aim to ensure that this object has exactly the same life-cycle as the + underlying sub process. + """ + + # RET_ALREADY_STOPPED = -1 + # RET_TIME_OUT = -3 + # RET_SUCCESS = -4 + + def __init__(self, cmdLine: List[str], logDir: DirPath): + # Create the process + managing thread immediately + + Logging.info("Attempting to start TAOS sub process...") + self._popen = self._start(cmdLine) # the actual sub process + self._smThread = ServiceManagerThread(self, logDir) # A thread to manage the sub process, mostly to process the IO + Logging.info("Successfully started TAOS process: {}".format(self)) + + + + def __repr__(self): + # if self.subProcess is None: + # return '[TdeSubProc: Empty]' + return '[TdeSubProc: pid = {}, status = {}]'.format( + self.getPid(), self.getStatus() ) + + def getIpcStdOut(self) -> IpcStream : + if self._popen.universal_newlines : # alias of text_mode + raise CrashGenError("We need binary mode for STDOUT IPC") + # Logging.info("Type of stdout is: {}".format(type(self._popen.stdout))) + return typing.cast(IpcStream, self._popen.stdout) + + def getIpcStdErr(self) -> IpcStream : + if self._popen.universal_newlines : # alias of text_mode + raise CrashGenError("We need binary mode for STDERR IPC") + return typing.cast(IpcStream, self._popen.stderr) + + # Now it's always running, since we matched the life cycle + # def isRunning(self): + # return self.subProcess is not None + + def getPid(self): + return self._popen.pid + + def _start(self, cmdLine) -> Popen : + ON_POSIX = 'posix' in sys.builtin_module_names + + # Prepare environment variables for coverage information + # Ref: https://stackoverflow.com/questions/2231227/python-subprocess-popen-with-a-modified-environment + myEnv = os.environ.copy() + TdeInstance.prepareGcovEnv(myEnv) + + # print(myEnv) + # print("Starting TDengine with env: ", myEnv.items()) + print("Starting TDengine: {}".format(cmdLine)) + + ret = Popen( + ' '.join(cmdLine), # ' '.join(cmdLine) if useShell else cmdLine, + shell=True, # Always use shell, since we need to pass ENV vars + stdout=PIPE, + stderr=PIPE, + close_fds=ON_POSIX, + env=myEnv + ) # had text=True, which interferred with reading EOF + time.sleep(0.01) # very brief wait, then let's check if sub process started successfully. + if ret.poll(): + raise CrashGenError("Sub process failed to start with command line: {}".format(cmdLine)) + return ret + + STOP_SIGNAL = signal.SIGINT # signal.SIGKILL/SIGINT # What signal to use (in kill) to stop a taosd process? + SIG_KILL_RETCODE = 137 # ref: https://stackoverflow.com/questions/43268156/process-finished-with-exit-code-137-in-pycharm + + def stop(self): + """ + Stop a sub process, DO NOT return anything, process all conditions INSIDE. + + Calling function should immediately delete/unreference the object + + Common POSIX signal values (from man -7 signal): + SIGHUP 1 + SIGINT 2 + SIGQUIT 3 + SIGILL 4 + SIGTRAP 5 + SIGABRT 6 + SIGIOT 6 + SIGBUS 7 + SIGEMT - + SIGFPE 8 + SIGKILL 9 + SIGUSR1 10 + SIGSEGV 11 + SIGUSR2 12 + """ + # self._popen should always be valid. + + Logging.info("Terminating TDengine service running as the sub process...") + if self.getStatus().isStopped(): + Logging.info("Service already stopped") + return + if self.getStatus().isStopping(): + Logging.info("Service is already being stopped, pid: {}".format(self.getPid())) + return + + self.setStatus(Status.STATUS_STOPPING) + + retCode = self._popen.poll() # ret -N means killed with signal N, otherwise it's from exit(N) + if retCode: # valid return code, process ended + # retCode = -retCode # only if valid + Logging.warning("TSP.stop(): process ended itself") + # self.subProcess = None + return + + # process still alive, let's interrupt it + self._stopForSure(self._popen, self.STOP_SIGNAL) # success if no exception + + # sub process should end, then IPC queue should end, causing IO thread to end + self._smThread.stop() # stop for sure too + + self.setStatus(Status.STATUS_STOPPED) + + @classmethod + def _stopForSure(cls, proc: Popen, sig: int): + ''' + Stop a process and all sub processes with a singal, and SIGKILL if necessary + ''' + def doKillTdService(proc: Popen, sig: int): + Logging.info("Killing sub-sub process {} with signal {}".format(proc.pid, sig)) + proc.send_signal(sig) + try: + retCode = proc.wait(20) + if (- retCode) == signal.SIGSEGV: # Crashed + Logging.warning("Process {} CRASHED, please check CORE file!".format(proc.pid)) + elif (- retCode) == sig : + Logging.info("TD service terminated with expected return code {}".format(sig)) + else: + Logging.warning("TD service terminated, EXPECTING ret code {}, got {}".format(sig, -retCode)) + return True # terminated successfully + except TimeoutExpired as err: + Logging.warning("Failed to kill sub-sub process {} with signal {}".format(proc.pid, sig)) + return False # failed to terminate + + + def doKillChild(child: psutil.Process, sig: int): + Logging.info("Killing sub-sub process {} with signal {}".format(child.pid, sig)) + child.send_signal(sig) + try: + retCode = child.wait(20) # type: ignore + if (- retCode) == signal.SIGSEGV: # type: ignore # Crashed + Logging.warning("Process {} CRASHED, please check CORE file!".format(child.pid)) + elif (- retCode) == sig : # type: ignore + Logging.info("Sub-sub process terminated with expected return code {}".format(sig)) + else: + Logging.warning("Process terminated, EXPECTING ret code {}, got {}".format(sig, -retCode)) # type: ignore + return True # terminated successfully + except psutil.TimeoutExpired as err: + Logging.warning("Failed to kill sub-sub process {} with signal {}".format(child.pid, sig)) + return False # did not terminate + + def doKill(proc: Popen, sig: int): + pid = proc.pid + try: + topSubProc = psutil.Process(pid) # Now that we are doing "exec -c", should not have children any more + for child in topSubProc.children(recursive=True): # or parent.children() for recursive=False + Logging.warning("Unexpected child to be killed") + doKillChild(child, sig) + except psutil.NoSuchProcess as err: + Logging.info("Process not found, can't kill, pid = {}".format(pid)) + + return doKillTdService(proc, sig) + # TODO: re-examine if we need to kill the top process, which is always the SHELL for now + # try: + # proc.wait(1) # SHELL process here, may throw subprocess.TimeoutExpired exception + # # expRetCode = self.SIG_KILL_RETCODE if sig==signal.SIGKILL else (-sig) + # # if retCode == expRetCode: + # # Logging.info("Process terminated with expected return code {}".format(retCode)) + # # else: + # # Logging.warning("Process terminated, EXPECTING ret code {}, got {}".format(expRetCode, retCode)) + # # return True # success + # except subprocess.TimeoutExpired as err: + # Logging.warning("Failed to kill process {} with signal {}".format(pid, sig)) + # return False # failed to kill + + def softKill(proc, sig): + return doKill(proc, sig) + + def hardKill(proc): + return doKill(proc, signal.SIGKILL) + + pid = proc.pid + Logging.info("Terminate running processes under {}, with SIG #{} and wait...".format(pid, sig)) + if softKill(proc, sig): + return # success + if sig != signal.SIGKILL: # really was soft above + if hardKill(proc): + return + raise CrashGenError("Failed to stop process, pid={}".format(pid)) + + def getStatus(self): + return self._smThread.getStatus() + + def setStatus(self, status): + self._smThread.setStatus(status) + + def procIpcBatch(self, trimToTarget=0, forceOutput=False): + self._smThread.procIpcBatch(trimToTarget, forceOutput) + +class ServiceManager: + PAUSE_BETWEEN_IPC_CHECK = 1.2 # seconds between checks on STDOUT of sub process + + def __init__(self, numDnodes): # >1 when we run a cluster + Logging.info("TDengine Service Manager (TSM) created") + self._numDnodes = numDnodes # >1 means we have a cluster + self._lock = threading.Lock() + # signal.signal(signal.SIGTERM, self.sigIntHandler) # Moved to MainExec + # signal.signal(signal.SIGINT, self.sigIntHandler) + # signal.signal(signal.SIGUSR1, self.sigUsrHandler) # different handler! + + self.inSigHandler = False + # self._status = MainExec.STATUS_RUNNING # set inside + # _startTaosService() + self._runCluster = (numDnodes > 1) + self._tInsts : List[TdeInstance] = [] + for i in range(0, numDnodes): + ti = self._createTdeInstance(i) # construct tInst + self._tInsts.append(ti) + + # self.svcMgrThreads : List[ServiceManagerThread] = [] + # for i in range(0, numDnodes): + # thread = self._createThread(i) # construct tInst + # self.svcMgrThreads.append(thread) + + def _createTdeInstance(self, dnIndex): + if not self._runCluster: # single instance + subdir = 'test' + else: # Create all threads in a cluster + subdir = 'cluster_dnode_{}'.format(dnIndex) + fepPort= 6030 # firstEP Port + port = fepPort + dnIndex * 100 + return TdeInstance(subdir, dnIndex, port, fepPort) + # return ServiceManagerThread(dnIndex, ti) + + def _doMenu(self): + choice = "" + while True: + print("\nInterrupting Service Program, Choose an Action: ") + print("1: Resume") + print("2: Terminate") + print("3: Restart") + # Remember to update the if range below + # print("Enter Choice: ", end="", flush=True) + while choice == "": + choice = input("Enter Choice: ") + if choice != "": + break # done with reading repeated input + if choice in ["1", "2", "3"]: + break # we are done with whole method + print("Invalid choice, please try again.") + choice = "" # reset + return choice + + def sigUsrHandler(self, signalNumber, frame): + print("Interrupting main thread execution upon SIGUSR1") + if self.inSigHandler: # already + print("Ignoring repeated SIG...") + return # do nothing if it's already not running + self.inSigHandler = True + + choice = self._doMenu() + if choice == "1": + self.sigHandlerResume() # TODO: can the sub-process be blocked due to us not reading from queue? + elif choice == "2": + self.stopTaosServices() + elif choice == "3": # Restart + self.restart() + else: + raise RuntimeError("Invalid menu choice: {}".format(choice)) + + self.inSigHandler = False + + def sigIntHandler(self, signalNumber, frame): + print("ServiceManager: INT Signal Handler starting...") + if self.inSigHandler: + print("Ignoring repeated SIG_INT...") + return + self.inSigHandler = True + + self.stopTaosServices() + print("ServiceManager: INT Signal Handler returning...") + self.inSigHandler = False + + def sigHandlerResume(self): + print("Resuming TDengine service manager (main thread)...\n\n") + + # def _updateThreadStatus(self): + # if self.svcMgrThread: # valid svc mgr thread + # if self.svcMgrThread.isStopped(): # done? + # self.svcMgrThread.procIpcBatch() # one last time. TODO: appropriate? + # self.svcMgrThread = None # no more + + def isActive(self): + """ + Determine if the service/cluster is active at all, i.e. at least + one instance is active + """ + for ti in self._tInsts: + if ti.getStatus().isActive(): + return True + return False + + def isRunning(self): + for ti in self._tInsts: + if not ti.getStatus().isRunning(): + return False + return True + + + # def isRestarting(self): + # """ + # Determine if the service/cluster is being "restarted", i.e., at least + # one thread is in "restarting" status + # """ + # for thread in self.svcMgrThreads: + # if thread.isRestarting(): + # return True + # return False + + def isStable(self): + """ + Determine if the service/cluster is "stable", i.e. all of the + threads are in "stable" status. + """ + for ti in self._tInsts: + if not ti.getStatus().isStable(): + return False + return True + + def _procIpcAll(self): + while self.isActive(): + Progress.emit(Progress.SERVICE_HEART_BEAT) + for ti in self._tInsts: # all thread objects should always be valid + # while self.isRunning() or self.isRestarting() : # for as long as the svc mgr thread is still here + status = ti.getStatus() + if status.isRunning(): + # th = ti.getSmThread() + ti.procIpcBatch() # regular processing, + if status.isStopped(): + ti.procIpcBatch() # one last time? + # self._updateThreadStatus() + + time.sleep(self.PAUSE_BETWEEN_IPC_CHECK) # pause, before next round + # raise CrashGenError("dummy") + Logging.info("Service Manager Thread (with subprocess) ended, main thread exiting...") + + def _getFirstInstance(self): + return self._tInsts[0] + + def startTaosServices(self): + with self._lock: + if self.isActive(): + raise RuntimeError("Cannot start TAOS service(s) when one/some may already be running") + + # Find if there's already a taosd service, and then kill it + for proc in psutil.process_iter(): + if proc.name() == 'taosd' or proc.name() == 'memcheck-amd64-': # Regular or under Valgrind + Logging.info("Killing an existing TAOSD process in 2 seconds... press CTRL-C to interrupt") + time.sleep(2.0) + proc.kill() + # print("Process: {}".format(proc.name())) + + # self.svcMgrThread = ServiceManagerThread() # create the object + + for ti in self._tInsts: + ti.start() + if not ti.isFirst(): + tFirst = self._getFirstInstance() + tFirst.createDnode(ti.getDbTarget()) + ti.printFirst10Lines() + # ti.getSmThread().procIpcBatch(trimToTarget=10, forceOutput=True) # for printing 10 lines + + def stopTaosServices(self): + with self._lock: + if not self.isActive(): + Logging.warning("Cannot stop TAOS service(s), already not active") + return + + for ti in self._tInsts: + ti.stop() + + def run(self): + self.startTaosServices() + self._procIpcAll() # pump/process all the messages, may encounter SIG + restart + if self.isActive(): # if sig handler hasn't destroyed it by now + self.stopTaosServices() # should have started already + + def restart(self): + if not self.isStable(): + Logging.warning("Cannot restart service/cluster, when not stable") + return + + # self._isRestarting = True + if self.isActive(): + self.stopTaosServices() + else: + Logging.warning("Service not active when restart requested") + + self.startTaosServices() + # self._isRestarting = False + + # def isRunning(self): + # return self.svcMgrThread != None + + # def isRestarting(self): + # return self._isRestarting + +class ServiceManagerThread: + """ + A class representing a dedicated thread which manages the "sub process" + of the TDengine service, interacting with its STDOUT/ERR. + + It takes a TdeInstance parameter at creation time, or create a default + """ + MAX_QUEUE_SIZE = 10000 + + def __init__(self, subProc: TdeSubProcess, logDir: str): + # Set the sub process + # self._tdeSubProcess = None # type: TdeSubProcess + + # Arrange the TDengine instance + # self._tInstNum = tInstNum # instance serial number in cluster, ZERO based + # self._tInst = tInst or TdeInstance() # Need an instance + + # self._thread = None # type: Optional[threading.Thread] # The actual thread, # type: threading.Thread + # self._thread2 = None # type: Optional[threading.Thread] Thread # watching stderr + self._status = Status(Status.STATUS_STOPPED) # The status of the underlying service, actually. + + self._start(subProc, logDir) + + def __repr__(self): + raise CrashGenError("SMT status moved to TdeSubProcess") + # return "[SvcMgrThread: status={}, subProc={}]".format( + # self.getStatus(), self._tdeSubProcess) + + def getStatus(self): + ''' + Get the status of the process being managed. (misnomer alert!) + ''' + return self._status + + def setStatus(self, statusVal: int): + self._status.set(statusVal) + + # Start the thread (with sub process), and wait for the sub service + # to become fully operational + def _start(self, subProc :TdeSubProcess, logDir: str): + ''' + Request the manager thread to start a new sub process, and manage it. + + :param cmdLine: the command line to invoke + :param logDir: the logging directory, to hold stdout/stderr files + ''' + # if self._thread: + # raise RuntimeError("Unexpected _thread") + # if self._tdeSubProcess: + # raise RuntimeError("TDengine sub process already created/running") + + # Moved to TdeSubProcess + # Logging.info("Attempting to start TAOS service: {}".format(self)) + + self._status.set(Status.STATUS_STARTING) + # self._tdeSubProcess = TdeSubProcess.start(cmdLine) # TODO: verify process is running + + self._ipcQueue = Queue() # type: Queue + self._thread = threading.Thread( # First thread captures server OUTPUT + target=self.svcOutputReader, + args=(subProc.getIpcStdOut(), self._ipcQueue, logDir)) + self._thread.daemon = True # thread dies with the program + self._thread.start() + time.sleep(0.01) + if not self._thread.is_alive(): # What happened? + Logging.info("Failed to start process to monitor STDOUT") + self.stop() + raise CrashGenError("Failed to start thread to monitor STDOUT") + Logging.info("Successfully started process to monitor STDOUT") + + self._thread2 = threading.Thread( # 2nd thread captures server ERRORs + target=self.svcErrorReader, + args=(subProc.getIpcStdErr(), self._ipcQueue, logDir)) + self._thread2.daemon = True # thread dies with the program + self._thread2.start() + time.sleep(0.01) + if not self._thread2.is_alive(): + self.stop() + raise CrashGenError("Failed to start thread to monitor STDERR") + + # wait for service to start + for i in range(0, 100): + time.sleep(1.0) + # self.procIpcBatch() # don't pump message during start up + Progress.emit(Progress.SERVICE_START_NAP) + # print("_zz_", end="", flush=True) + if self._status.isRunning(): + Logging.info("[] TDengine service READY to process requests: pid={}".format(subProc.getPid())) + # Logging.info("[] TAOS service started: {}".format(self)) + # self._verifyDnode(self._tInst) # query and ensure dnode is ready + # Logging.debug("[] TAOS Dnode verified: {}".format(self)) + return # now we've started + # TODO: handle failure-to-start better? + self.procIpcBatch(100, True) # display output before cronking out, trim to last 20 msgs, force output + raise RuntimeError("TDengine service DID NOT achieve READY status: pid={}".format(subProc.getPid())) + + def _verifyDnode(self, tInst: TdeInstance): + dbc = DbConn.createNative(tInst.getDbTarget()) + dbc.open() + dbc.query("show dnodes") + # dbc.query("DESCRIBE {}.{}".format(dbName, self._stName)) + cols = dbc.getQueryResult() # id,end_point,vnodes,cores,status,role,create_time,offline reason + # ret = {row[0]:row[1] for row in stCols if row[3]=='TAG'} # name:type + isValid = False + for col in cols: + # print("col = {}".format(col)) + ep = col[1].split(':') # 10.1.30.2:6030 + print("Found ep={}".format(ep)) + if tInst.getPort() == int(ep[1]): # That's us + # print("Valid Dnode matched!") + isValid = True # now we are valid + break + if not isValid: + print("Failed to start dnode, sleep for a while") + time.sleep(10.0) + raise RuntimeError("Failed to start Dnode, expected port not found: {}". + format(tInst.getPort())) + dbc.close() + + def stop(self): + # can be called from both main thread or signal handler + + # Linux will send Control-C generated SIGINT to the TDengine process already, ref: + # https://unix.stackexchange.com/questions/176235/fork-and-how-signals-are-delivered-to-processes + + self.join() # stop the thread, status change moved to TdeSubProcess + + # Check if it's really stopped + outputLines = 10 # for last output + if self.getStatus().isStopped(): + self.procIpcBatch(outputLines) # one last time + Logging.debug("End of TDengine Service Output") + Logging.info("----- TDengine Service (managed by SMT) is now terminated -----\n") + else: + print("WARNING: SMT did not terminate as expected") + + def join(self): + # TODO: sanity check + s = self.getStatus() + if s.isStopping() or s.isStopped(): # we may be stopping ourselves, or have been stopped/killed by others + if self._thread or self._thread2 : + if self._thread: + self._thread.join() + self._thread = None + if self._thread2: # STD ERR thread + self._thread2.join() + self._thread2 = None + else: + Logging.warning("Joining empty thread, doing nothing") + else: + raise RuntimeError( + "SMT.Join(): Unexpected status: {}".format(self._status)) + + def _trimQueue(self, targetSize): + if targetSize <= 0: + return # do nothing + q = self._ipcQueue + if (q.qsize() <= targetSize): # no need to trim + return + + Logging.debug("Triming IPC queue to target size: {}".format(targetSize)) + itemsToTrim = q.qsize() - targetSize + for i in range(0, itemsToTrim): + try: + q.get_nowait() + except Empty: + break # break out of for loop, no more trimming + + TD_READY_MSG = "TDengine is initialized successfully" + + def procIpcBatch(self, trimToTarget=0, forceOutput=False): + ''' + Process a batch of STDOUT/STDERR data, until we read EMPTY from + the queue. + ''' + self._trimQueue(trimToTarget) # trim if necessary + # Process all the output generated by the underlying sub process, + # managed by IO thread + print("<", end="", flush=True) + while True: + try: + line = self._ipcQueue.get_nowait() # getting output at fast speed + self._printProgress("_o") + except Empty: + # time.sleep(2.3) # wait only if there's no output + # no more output + print(".>", end="", flush=True) + return # we are done with THIS BATCH + else: # got line, printing out + if forceOutput: + Logging.info('[TAOSD] ' + line) + else: + Logging.debug('[TAOSD] ' + line) + print(">", end="", flush=True) + + _ProgressBars = ["--", "//", "||", "\\\\"] + + def _printProgress(self, msg): # TODO: assuming 2 chars + print(msg, end="", flush=True) + pBar = self._ProgressBars[Dice.throw(4)] + print(pBar, end="", flush=True) + print('\b\b\b\b', end="", flush=True) + + BinaryChunk = NewType('BinaryChunk', bytes) # line with binary data, directly from STDOUT, etc. + TextChunk = NewType('TextChunk', str) # properly decoded, suitable for printing, etc. + + @classmethod + def _decodeBinaryChunk(cls, bChunk: bytes) -> Optional[TextChunk] : + try: + tChunk = bChunk.decode("utf-8").rstrip() + return cls.TextChunk(tChunk) + except UnicodeError: + print("\nNon-UTF8 server output: {}\n".format(bChunk.decode('cp437'))) + return None + + def _textChunkGenerator(self, streamIn: IpcStream, logDir: str, logFile: str + ) -> Generator[TextChunk, None, None]: + ''' + Take an input stream with binary data (likely from Popen), produced a generator of decoded + "text chunks". + + Side effect: it also save the original binary data in a log file. + ''' + os.makedirs(logDir, exist_ok=True) + logF = open(os.path.join(logDir, logFile), 'wb') + if logF is None: + Logging.error("Failed to open log file (binary write): {}/{}".format(logDir, logFile)) + return + for bChunk in iter(streamIn.readline, b''): + logF.write(bChunk) # Write to log file immediately + tChunk = self._decodeBinaryChunk(bChunk) # decode + if tChunk is not None: + yield tChunk # TODO: split into actual text lines + + # At the end... + streamIn.close() # Close the incoming stream + logF.close() # Close the log file + + def svcOutputReader(self, ipcStdOut: IpcStream, queue, logDir: str): + ''' + The infinite routine that processes the STDOUT stream for the sub process being managed. + + :param ipcStdOut: the IO stream object used to fetch the data from + :param queue: the queue where we dump the roughly parsed chunk-by-chunk text data + :param logDir: where we should dump a verbatim output file + ''' + + # Important Reference: https://stackoverflow.com/questions/375427/non-blocking-read-on-a-subprocess-pipe-in-python + # print("This is the svcOutput Reader...") + # stdOut.readline() # Skip the first output? TODO: remove? + for tChunk in self._textChunkGenerator(ipcStdOut, logDir, 'stdout.log') : + queue.put(tChunk) # tChunk garanteed not to be None + self._printProgress("_i") + + if self._status.isStarting(): # we are starting, let's see if we have started + if tChunk.find(self.TD_READY_MSG) != -1: # found + Logging.info("Waiting for the service to become FULLY READY") + time.sleep(1.0) # wait for the server to truly start. TODO: remove this + Logging.info("Service is now FULLY READY") # TODO: more ID info here? + self._status.set(Status.STATUS_RUNNING) + + # Trim the queue if necessary: TODO: try this 1 out of 10 times + self._trimQueue(self.MAX_QUEUE_SIZE * 9 // 10) # trim to 90% size + + if self._status.isStopping(): # TODO: use thread status instead + # WAITING for stopping sub process to finish its outptu + print("_w", end="", flush=True) + + # queue.put(line) + # stdOut has no more data, meaning sub process must have died + Logging.info("EOF found TDengine STDOUT, marking the process as terminated") + self.setStatus(Status.STATUS_STOPPED) + + def svcErrorReader(self, ipcStdErr: IpcStream, queue, logDir: str): + # os.makedirs(logDir, exist_ok=True) + # logFile = os.path.join(logDir,'stderr.log') + # fErr = open(logFile, 'wb') + # for line in iter(err.readline, b''): + for tChunk in self._textChunkGenerator(ipcStdErr, logDir, 'stderr.log') : + queue.put(tChunk) # tChunk garanteed not to be None + # fErr.write(line) + Logging.info("TDengine STDERR: {}".format(tChunk)) + Logging.info("EOF for TDengine STDERR") diff --git a/tests/pytest/crash_gen/shared/config.py b/tests/pytest/crash_gen/shared/config.py new file mode 100644 index 0000000000000000000000000000000000000000..7b9f7c3873a3b5d30cc36384bf7a486454c864cb --- /dev/null +++ b/tests/pytest/crash_gen/shared/config.py @@ -0,0 +1,42 @@ +from __future__ import annotations +import argparse + +from typing import Optional + +from .misc import CrashGenError + +# from crash_gen.misc import CrashGenError + +# gConfig: Optional[argparse.Namespace] + +class Config: + _config = None # type Optional[argparse.Namespace] + + @classmethod + def init(cls, parser: argparse.ArgumentParser): + if cls._config is not None: + raise CrashGenError("Config can only be initialized once") + cls._config = parser.parse_args() + # print(cls._config) + + @classmethod + def setConfig(cls, config: argparse.Namespace): + cls._config = config + + @classmethod + # TODO: check items instead of exposing everything + def getConfig(cls) -> argparse.Namespace: + if cls._config is None: + raise CrashGenError("invalid state") + return cls._config + + @classmethod + def clearConfig(cls): + cls._config = None + + @classmethod + def isSet(cls, cfgKey): + cfg = cls.getConfig() + if cfgKey not in cfg: + return False + return cfg.__getattribute__(cfgKey) \ No newline at end of file diff --git a/tests/pytest/crash_gen/shared/db.py b/tests/pytest/crash_gen/shared/db.py new file mode 100644 index 0000000000000000000000000000000000000000..75931ace48ed65708c7dfa97d01a426a0baa8203 --- /dev/null +++ b/tests/pytest/crash_gen/shared/db.py @@ -0,0 +1,474 @@ +from __future__ import annotations + +import sys +import os +import datetime +import time +import threading +import requests +from requests.auth import HTTPBasicAuth + + +import taos +from util.sql import * +from util.cases import * +from util.dnodes import * +from util.log import * + +import traceback +# from .service_manager import TdeInstance + +from .config import Config +from .misc import Logging, CrashGenError, Helper +from .types import QueryResult + +class DbConn: + TYPE_NATIVE = "native-c" + TYPE_REST = "rest-api" + TYPE_INVALID = "invalid" + + @classmethod + def create(cls, connType, dbTarget): + if connType == cls.TYPE_NATIVE: + return DbConnNative(dbTarget) + elif connType == cls.TYPE_REST: + return DbConnRest(dbTarget) + else: + raise RuntimeError( + "Unexpected connection type: {}".format(connType)) + + @classmethod + def createNative(cls, dbTarget) -> DbConn: + return cls.create(cls.TYPE_NATIVE, dbTarget) + + @classmethod + def createRest(cls, dbTarget) -> DbConn: + return cls.create(cls.TYPE_REST, dbTarget) + + def __init__(self, dbTarget): + self.isOpen = False + self._type = self.TYPE_INVALID + self._lastSql = None + self._dbTarget = dbTarget + + def __repr__(self): + return "[DbConn: type={}, target={}]".format(self._type, self._dbTarget) + + def getLastSql(self): + return self._lastSql + + def open(self): + if (self.isOpen): + raise RuntimeError("Cannot re-open an existing DB connection") + + # below implemented by child classes + self.openByType() + + Logging.debug("[DB] data connection opened: {}".format(self)) + self.isOpen = True + + def close(self): + raise RuntimeError("Unexpected execution, should be overriden") + + def queryScalar(self, sql) -> int: + return self._queryAny(sql) + + def queryString(self, sql) -> str: + return self._queryAny(sql) + + def _queryAny(self, sql): # actual query result as an int + if (not self.isOpen): + raise RuntimeError("Cannot query database until connection is open") + nRows = self.query(sql) + if nRows != 1: + raise CrashGenError( + "Unexpected result for query: {}, rows = {}".format(sql, nRows), + (CrashGenError.INVALID_EMPTY_RESULT if nRows==0 else CrashGenError.INVALID_MULTIPLE_RESULT) + ) + if self.getResultRows() != 1 or self.getResultCols() != 1: + raise RuntimeError("Unexpected result set for query: {}".format(sql)) + return self.getQueryResult()[0][0] + + def use(self, dbName): + self.execute("use {}".format(dbName)) + + def existsDatabase(self, dbName: str): + ''' Check if a certain database exists ''' + self.query("show databases") + dbs = [v[0] for v in self.getQueryResult()] # ref: https://stackoverflow.com/questions/643823/python-list-transformation + # ret2 = dbName in dbs + # print("dbs = {}, str = {}, ret2={}, type2={}".format(dbs, dbName,ret2, type(dbName))) + return dbName in dbs # TODO: super weird type mangling seen, once here + + def existsSuperTable(self, stName): + self.query("show stables") + sts = [v[0] for v in self.getQueryResult()] + return stName in sts + + def hasTables(self): + return self.query("show tables") > 0 + + def execute(self, sql): + ''' Return the number of rows affected''' + raise RuntimeError("Unexpected execution, should be overriden") + + def safeExecute(self, sql): + '''Safely execute any SQL query, returning True/False upon success/failure''' + try: + self.execute(sql) + return True # ignore num of results, return success + except taos.error.Error as err: + return False # failed, for whatever TAOS reason + # Not possile to reach here, non-TAOS exception would have been thrown + + def query(self, sql) -> int: # return num rows returned + ''' Return the number of rows affected''' + raise RuntimeError("Unexpected execution, should be overriden") + + def openByType(self): + raise RuntimeError("Unexpected execution, should be overriden") + + def getQueryResult(self) -> QueryResult : + raise RuntimeError("Unexpected execution, should be overriden") + + def getResultRows(self): + raise RuntimeError("Unexpected execution, should be overriden") + + def getResultCols(self): + raise RuntimeError("Unexpected execution, should be overriden") + +# Sample: curl -u root:taosdata -d "show databases" localhost:6020/rest/sql + + +class DbConnRest(DbConn): + REST_PORT_INCREMENT = 11 + + def __init__(self, dbTarget: DbTarget): + super().__init__(dbTarget) + self._type = self.TYPE_REST + restPort = dbTarget.port + 11 + self._url = "http://{}:{}/rest/sql".format( + dbTarget.hostAddr, dbTarget.port + self.REST_PORT_INCREMENT) + self._result = None + + def openByType(self): # Open connection + pass # do nothing, always open + + def close(self): + if (not self.isOpen): + raise RuntimeError("Cannot clean up database until connection is open") + # Do nothing for REST + Logging.debug("[DB] REST Database connection closed") + self.isOpen = False + + def _doSql(self, sql): + self._lastSql = sql # remember this, last SQL attempted + try: + r = requests.post(self._url, + data = sql, + auth = HTTPBasicAuth('root', 'taosdata')) + except: + print("REST API Failure (TODO: more info here)") + raise + rj = r.json() + # Sanity check for the "Json Result" + if ('status' not in rj): + raise RuntimeError("No status in REST response") + + if rj['status'] == 'error': # clearly reported error + if ('code' not in rj): # error without code + raise RuntimeError("REST error return without code") + errno = rj['code'] # May need to massage this in the future + # print("Raising programming error with REST return: {}".format(rj)) + raise taos.error.ProgrammingError( + rj['desc'], errno) # todo: check existance of 'desc' + + if rj['status'] != 'succ': # better be this + raise RuntimeError( + "Unexpected REST return status: {}".format( + rj['status'])) + + nRows = rj['rows'] if ('rows' in rj) else 0 + self._result = rj + return nRows + + def execute(self, sql): + if (not self.isOpen): + raise RuntimeError( + "Cannot execute database commands until connection is open") + Logging.debug("[SQL-REST] Executing SQL: {}".format(sql)) + nRows = self._doSql(sql) + Logging.debug( + "[SQL-REST] Execution Result, nRows = {}, SQL = {}".format(nRows, sql)) + return nRows + + def query(self, sql): # return rows affected + return self.execute(sql) + + def getQueryResult(self): + return self._result['data'] + + def getResultRows(self): + print(self._result) + raise RuntimeError("TBD") # TODO: finish here to support -v under -c rest + # return self._tdSql.queryRows + + def getResultCols(self): + print(self._result) + raise RuntimeError("TBD") + + # Duplicate code from TDMySQL, TODO: merge all this into DbConnNative + + +class MyTDSql: + # Class variables + _clsLock = threading.Lock() # class wide locking + longestQuery = '' # type: str + longestQueryTime = 0.0 # seconds + lqStartTime = 0.0 + # lqEndTime = 0.0 # Not needed, as we have the two above already + + def __init__(self, hostAddr, cfgPath): + # Make the DB connection + self._conn = taos.connect(host=hostAddr, config=cfgPath) + self._cursor = self._conn.cursor() + + self.queryRows = 0 + self.queryCols = 0 + self.affectedRows = 0 + + # def init(self, cursor, log=True): + # self.cursor = cursor + # if (log): + # caller = inspect.getframeinfo(inspect.stack()[1][0]) + # self.cursor.log(caller.filename + ".sql") + + def close(self): + self._cursor.close() # can we double close? + self._conn.close() # TODO: very important, cursor close does NOT close DB connection! + self._cursor.close() + + def _execInternal(self, sql): + startTime = time.time() + # Logging.debug("Executing SQL: " + sql) + # ret = None # TODO: use strong type here + # try: # Let's not capture the error, and let taos.error.ProgrammingError pass through + ret = self._cursor.execute(sql) + # except taos.error.ProgrammingError as err: + # Logging.warning("Taos SQL execution error: {}, SQL: {}".format(err.msg, sql)) + # raise CrashGenError(err.msg) + + # print("\nSQL success: {}".format(sql)) + queryTime = time.time() - startTime + # Record the query time + cls = self.__class__ + if queryTime > (cls.longestQueryTime + 0.01) : + with cls._clsLock: + cls.longestQuery = sql + cls.longestQueryTime = queryTime + cls.lqStartTime = startTime + + # Now write to the shadow database + if Config.isSet('use_shadow_db'): + if sql[:11] == "INSERT INTO": + if sql[:16] == "INSERT INTO db_0": + sql2 = "INSERT INTO db_s" + sql[16:] + self._cursor.execute(sql2) + else: + raise CrashGenError("Did not find db_0 in INSERT statement: {}".format(sql)) + else: # not an insert statement + pass + + if sql[:12] == "CREATE TABLE": + if sql[:17] == "CREATE TABLE db_0": + sql2 = sql.replace('db_0', 'db_s') + self._cursor.execute(sql2) + else: + raise CrashGenError("Did not find db_0 in CREATE TABLE statement: {}".format(sql)) + else: # not an insert statement + pass + + return ret + + def query(self, sql): + self.sql = sql + try: + self._execInternal(sql) + self.queryResult = self._cursor.fetchall() + self.queryRows = len(self.queryResult) + self.queryCols = len(self._cursor.description) + except Exception as e: + # caller = inspect.getframeinfo(inspect.stack()[1][0]) + # args = (caller.filename, caller.lineno, sql, repr(e)) + # tdLog.exit("%s(%d) failed: sql:%s, %s" % args) + raise + return self.queryRows + + def execute(self, sql): + self.sql = sql + try: + self.affectedRows = self._execInternal(sql) + except Exception as e: + # caller = inspect.getframeinfo(inspect.stack()[1][0]) + # args = (caller.filename, caller.lineno, sql, repr(e)) + # tdLog.exit("%s(%d) failed: sql:%s, %s" % args) + raise + return self.affectedRows + +class DbTarget: + def __init__(self, cfgPath, hostAddr, port): + self.cfgPath = cfgPath + self.hostAddr = hostAddr + self.port = port + + def __repr__(self): + return "[DbTarget: cfgPath={}, host={}:{}]".format( + Helper.getFriendlyPath(self.cfgPath), self.hostAddr, self.port) + + def getEp(self): + return "{}:{}".format(self.hostAddr, self.port) + +class DbConnNative(DbConn): + # Class variables + _lock = threading.Lock() + # _connInfoDisplayed = False # TODO: find another way to display this + totalConnections = 0 # Not private + totalRequests = 0 + + def __init__(self, dbTarget): + super().__init__(dbTarget) + self._type = self.TYPE_NATIVE + self._conn = None + # self._cursor = None + + @classmethod + def resetTotalRequests(cls): + with cls._lock: # force single threading for opening DB connections. # TODO: whaaat??!!! + cls.totalRequests = 0 + + def openByType(self): # Open connection + # global gContainer + # tInst = tInst or gContainer.defTdeInstance # set up in ClientManager, type: TdeInstance + # cfgPath = self.getBuildPath() + "/test/cfg" + # cfgPath = tInst.getCfgDir() + # hostAddr = tInst.getHostAddr() + + cls = self.__class__ # Get the class, to access class variables + with cls._lock: # force single threading for opening DB connections. # TODO: whaaat??!!! + dbTarget = self._dbTarget + # if not cls._connInfoDisplayed: + # cls._connInfoDisplayed = True # updating CLASS variable + Logging.debug("Initiating TAOS native connection to {}".format(dbTarget)) + # Make the connection + # self._conn = taos.connect(host=hostAddr, config=cfgPath) # TODO: make configurable + # self._cursor = self._conn.cursor() + # Record the count in the class + self._tdSql = MyTDSql(dbTarget.hostAddr, dbTarget.cfgPath) # making DB connection + cls.totalConnections += 1 + + self._tdSql.execute('reset query cache') + # self._cursor.execute('use db') # do this at the beginning of every + + # Open connection + # self._tdSql = MyTDSql() + # self._tdSql.init(self._cursor) + + def close(self): + if (not self.isOpen): + raise RuntimeError("Cannot clean up database until connection is open") + self._tdSql.close() + # Decrement the class wide counter + cls = self.__class__ # Get the class, to access class variables + with cls._lock: + cls.totalConnections -= 1 + + Logging.debug("[DB] Database connection closed") + self.isOpen = False + + def execute(self, sql): + if (not self.isOpen): + traceback.print_stack() + raise CrashGenError( + "Cannot exec SQL unless db connection is open", CrashGenError.DB_CONNECTION_NOT_OPEN) + Logging.debug("[SQL] Executing SQL: {}".format(sql)) + self._lastSql = sql + nRows = self._tdSql.execute(sql) + cls = self.__class__ + cls.totalRequests += 1 + Logging.debug( + "[SQL] Execution Result, nRows = {}, SQL = {}".format( + nRows, sql)) + return nRows + + def query(self, sql): # return rows affected + if (not self.isOpen): + traceback.print_stack() + raise CrashGenError( + "Cannot query database until connection is open, restarting?", CrashGenError.DB_CONNECTION_NOT_OPEN) + Logging.debug("[SQL] Executing SQL: {}".format(sql)) + self._lastSql = sql + nRows = self._tdSql.query(sql) + cls = self.__class__ + cls.totalRequests += 1 + Logging.debug( + "[SQL] Query Result, nRows = {}, SQL = {}".format( + nRows, sql)) + return nRows + # results are in: return self._tdSql.queryResult + + def getQueryResult(self): + return self._tdSql.queryResult + + def getResultRows(self): + return self._tdSql.queryRows + + def getResultCols(self): + return self._tdSql.queryCols + + +class DbManager(): + ''' This is a wrapper around DbConn(), to make it easier to use. + + TODO: rename this to DbConnManager + ''' + def __init__(self, cType, dbTarget): + # self.tableNumQueue = LinearQueue() # TODO: delete? + # self.openDbServerConnection() + self._dbConn = DbConn.createNative(dbTarget) if ( + cType == 'native') else DbConn.createRest(dbTarget) + try: + self._dbConn.open() # may throw taos.error.ProgrammingError: disconnected + Logging.debug("DbManager opened DB connection...") + except taos.error.ProgrammingError as err: + # print("Error type: {}, msg: {}, value: {}".format(type(err), err.msg, err)) + if (err.msg == 'client disconnected'): # cannot open DB connection + print( + "Cannot establish DB connection, please re-run script without parameter, and follow the instructions.") + sys.exit(2) + else: + print("Failed to connect to DB, errno = {}, msg: {}" + .format(Helper.convertErrno(err.errno), err.msg)) + raise + except BaseException: + print("[=] Unexpected exception") + raise + + # Do this after dbConn is in proper shape + # Moved to Database() + # self._stateMachine = StateMechine(self._dbConn) + + def __del__(self): + ''' Release the underlying DB connection upon deletion of DbManager ''' + self.cleanUp() + + def getDbConn(self) -> DbConn : + if self._dbConn is None: + raise CrashGenError("Unexpected empty DbConn") + return self._dbConn + + def cleanUp(self): + if self._dbConn: + self._dbConn.close() + self._dbConn = None + Logging.debug("DbManager closed DB connection...") + diff --git a/tests/pytest/crash_gen/shared/misc.py b/tests/pytest/crash_gen/shared/misc.py new file mode 100644 index 0000000000000000000000000000000000000000..78923bcc29ebb52df1c1a44d5e24ea5159962486 --- /dev/null +++ b/tests/pytest/crash_gen/shared/misc.py @@ -0,0 +1,209 @@ +import threading +import random +import logging +import os +import sys +from typing import Optional + +import taos + + +class CrashGenError(taos.error.ProgrammingError): + INVALID_EMPTY_RESULT = 0x991 + INVALID_MULTIPLE_RESULT = 0x992 + DB_CONNECTION_NOT_OPEN = 0x993 + # def __init__(self, msg=None, errno=None): + # self.msg = msg + # self.errno = errno + + # def __str__(self): + # return self.msg + pass + + +class LoggingFilter(logging.Filter): + def filter(self, record: logging.LogRecord): + if (record.levelno >= logging.INFO): + return True # info or above always log + + # Commenting out below to adjust... + + # if msg.startswith("[TRD]"): + # return False + return True + + +class MyLoggingAdapter(logging.LoggerAdapter): + def process(self, msg, kwargs): + shortTid = threading.get_ident() % 10000 + return "[{:04d}] {}".format(shortTid, msg), kwargs + # return '[%s] %s' % (self.extra['connid'], msg), kwargs + + +class Logging: + logger = None # type: Optional[MyLoggingAdapter] + + @classmethod + def getLogger(cls): + return cls.logger + + @classmethod + def clsInit(cls, debugMode: bool): + if cls.logger: + return + + # Logging Stuff + # global misc.logger + _logger = logging.getLogger('CrashGen') # real logger + _logger.addFilter(LoggingFilter()) + ch = logging.StreamHandler(sys.stdout) # Ref: https://stackoverflow.com/questions/14058453/making-python-loggers-output-all-messages-to-stdout-in-addition-to-log-file + _logger.addHandler(ch) + + # Logging adapter, to be used as a logger + # print("setting logger variable") + # global logger + cls.logger = MyLoggingAdapter(_logger, {}) + cls.logger.setLevel(logging.DEBUG if debugMode else logging.INFO) # default seems to be INFO + + @classmethod + def info(cls, msg): + cls.logger.info(msg) + + @classmethod + def debug(cls, msg): + cls.logger.debug(msg) + + @classmethod + def warning(cls, msg): + cls.logger.warning(msg) + + @classmethod + def error(cls, msg): + cls.logger.error(msg) + +class Status: + STATUS_EMPTY = 99 + STATUS_STARTING = 1 + STATUS_RUNNING = 2 + STATUS_STOPPING = 3 + STATUS_STOPPED = 4 + + def __init__(self, status): + self.set(status) + + def __repr__(self): + return "[Status: v={}]".format(self._status) + + def set(self, status: int): + self._status = status + + def get(self): + return self._status + + def isEmpty(self): + ''' Empty/Undefined ''' + return self._status == Status.STATUS_EMPTY + + def isStarting(self): + return self._status == Status.STATUS_STARTING + + def isRunning(self): + # return self._thread and self._thread.is_alive() + return self._status == Status.STATUS_RUNNING + + def isStopping(self): + return self._status == Status.STATUS_STOPPING + + def isStopped(self): + return self._status == Status.STATUS_STOPPED + + def isStable(self): + return self.isRunning() or self.isStopped() + + def isActive(self): + return self.isStarting() or self.isRunning() or self.isStopping() + +# Deterministic random number generator +class Dice(): + seeded = False # static, uninitialized + + @classmethod + def seed(cls, s): # static + if (cls.seeded): + raise RuntimeError( + "Cannot seed the random generator more than once") + cls.verifyRNG() + random.seed(s) + cls.seeded = True # TODO: protect against multi-threading + + @classmethod + def verifyRNG(cls): # Verify that the RNG is determinstic + random.seed(0) + x1 = random.randrange(0, 1000) + x2 = random.randrange(0, 1000) + x3 = random.randrange(0, 1000) + if (x1 != 864 or x2 != 394 or x3 != 776): + raise RuntimeError("System RNG is not deterministic") + + @classmethod + def throw(cls, stop): # get 0 to stop-1 + return cls.throwRange(0, stop) + + @classmethod + def throwRange(cls, start, stop): # up to stop-1 + if (not cls.seeded): + raise RuntimeError("Cannot throw dice before seeding it") + return random.randrange(start, stop) + + @classmethod + def choice(cls, cList): + return random.choice(cList) + +class Helper: + @classmethod + def convertErrno(cls, errno): + return errno if (errno > 0) else 0x80000000 + errno + + @classmethod + def getFriendlyPath(cls, path): # returns .../xxx/yyy + ht1 = os.path.split(path) + ht2 = os.path.split(ht1[0]) + return ".../" + ht2[1] + '/' + ht1[1] + + +class Progress: + STEP_BOUNDARY = 0 + BEGIN_THREAD_STEP = 1 + END_THREAD_STEP = 2 + SERVICE_HEART_BEAT= 3 + SERVICE_RECONNECT_START = 4 + SERVICE_RECONNECT_SUCCESS = 5 + SERVICE_RECONNECT_FAILURE = 6 + SERVICE_START_NAP = 7 + CREATE_TABLE_ATTEMPT = 8 + QUERY_GROUP_BY = 9 + CONCURRENT_INSERTION = 10 + ACCEPTABLE_ERROR = 11 + + tokens = { + STEP_BOUNDARY: '.', + BEGIN_THREAD_STEP: ' [', + END_THREAD_STEP: ']', + SERVICE_HEART_BEAT: '.Y.', + SERVICE_RECONNECT_START: '', + SERVICE_RECONNECT_FAILURE: '.xr>', + SERVICE_START_NAP: '_zz', + CREATE_TABLE_ATTEMPT: 'c', + QUERY_GROUP_BY: 'g', + CONCURRENT_INSERTION: 'x', + ACCEPTABLE_ERROR: '_', + } + + @classmethod + def emit(cls, token): + print(cls.tokens[token], end="", flush=True) + + @classmethod + def emitStr(cls, str): + print('({})'.format(str), end="", flush=True) diff --git a/tests/pytest/crash_gen/shared/types.py b/tests/pytest/crash_gen/shared/types.py new file mode 100644 index 0000000000000000000000000000000000000000..42fd2a1617cf729e4f23fc61a685027f738bc4a3 --- /dev/null +++ b/tests/pytest/crash_gen/shared/types.py @@ -0,0 +1,30 @@ +from typing import Any, BinaryIO, List, Dict, NewType +from enum import Enum + +DirPath = NewType('DirPath', str) + +QueryResult = NewType('QueryResult', List[List[Any]]) + +class TdDataType(Enum): + ''' + Use a Python Enum types of represent all the data types in TDengine. + + Ref: https://www.taosdata.com/cn/documentation/taos-sql#data-type + ''' + TIMESTAMP = 'TIMESTAMP' + INT = 'INT' + BIGINT = 'BIGINT' + FLOAT = 'FLOAT' + DOUBLE = 'DOUBLE' + BINARY = 'BINARY' + BINARY16 = 'BINARY(16)' # TODO: get rid of this hack + BINARY200 = 'BINARY(200)' + SMALLINT = 'SMALLINT' + TINYINT = 'TINYINT' + BOOL = 'BOOL' + NCHAR = 'NCHAR' + +TdColumns = Dict[str, TdDataType] +TdTags = Dict[str, TdDataType] + +IpcStream = NewType('IpcStream', BinaryIO) \ No newline at end of file diff --git a/tests/pytest/crash_gen/valgrind_taos.supp b/tests/pytest/crash_gen/valgrind_taos.supp new file mode 100644 index 0000000000000000000000000000000000000000..1ec87d91b9b54c35cf643962b60f7b95923b9ed3 --- /dev/null +++ b/tests/pytest/crash_gen/valgrind_taos.supp @@ -0,0 +1,18250 @@ +{ + + Memcheck:Cond + fun:PyUnicode_Decode + fun:PyUnicode_FromEncodedObject + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + fun:PyObject_GetAttr + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyFloat_FromDouble + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyFloat_FromDouble + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyFloat_FromDouble + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + fun:PyObject_GetAttr + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyLong_FromLong + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyLong_FromLong + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyLong_FromLong + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyLong_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyBytes_FromStringAndSize + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyLong_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyBytes_FromStringAndSize + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyBytes_FromStringAndSize + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyBytes_FromStringAndSize + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyBytes_FromStringAndSize + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PySequence_Tuple + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyUnicode_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyUnicode_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyUnicode_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:_PyLong_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:_PyFloat_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyHamt_Init + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyHamt_Init + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyHamt_Init + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyHamt_Init + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyHamt_Init + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyHamt_Init + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyHamt_Init + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:_PyErr_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyModuleDef_Init + fun:_PyModule_CreateInitialized + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyObject_SetAttr + obj:/usr/bin/python3.8 + fun:PyModule_AddFunctions + fun:_PyModule_CreateInitialized + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:PyThread_GetInfo + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + obj:/usr/bin/python3.8 + fun:_PyObject_LookupSpecial + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__thread + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__thread + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__thread + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__thread + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:PyInit__thread + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + fun:PyObject_CallFunctionObjArgs + fun:_PyErr_NormalizeException + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyStructSequence_NewType + fun:PyInit_posix + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyStructSequence_NewType + fun:PyInit_posix + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyStructSequence_NewType + fun:PyInit_posix + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyStructSequence_NewType + fun:PyInit_posix + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyStructSequence_NewType + fun:PyInit_posix + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit_posix + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit_posix + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:PyInit_time + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_CallMethodIdObjArgs + fun:PyImport_ImportModuleLevelObject + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__abc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + obj:/usr/bin/python3.8 + fun:PyObject_LengthHint + fun:PySequence_List + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__operator + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__operator + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__operator + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_StringFlags + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_FileExFlags + fun:PyRun_SimpleFileExFlags + fun:Py_RunMain +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyList_AsTuple + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_FileExFlags + fun:PyRun_SimpleFileExFlags + fun:Py_RunMain +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_FileExFlags + fun:PyRun_SimpleFileExFlags +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_FileExFlags + fun:PyRun_SimpleFileExFlags +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_FileExFlags +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__datetime + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__datetime + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__datetime + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__datetime + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__datetime + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__datetime + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_CallMethodIdObjArgs + fun:PyImport_ImportModuleLevelObject +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:_PyStack_UnpackDict + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__sre + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__sre + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__sre + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyErr_NewException + fun:PyErr_NewExceptionWithDoc + fun:PyInit__queue + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__queue + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyErr_NewException + fun:PyInit__socket + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyErr_NewException + fun:PyInit__socket + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyErr_NewException + fun:PyInit__socket + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + fun:PyObject_CallFunctionObjArgs + fun:PyErr_Format + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__random + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__ssl + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__ssl + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__ssl + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__ssl + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_FromSpecWithBases + fun:PyInit__ssl + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__hashlib + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__blake2 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__blake2 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__sha3 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__sha3 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__sha3 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__sha3 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__sha3 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__sha3 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit_zlib + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit_zlib + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyErr_NewException + fun:PyInit_zlib + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyErr_NewException + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__bz2 + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__bz2 + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyErr_NewException + fun:PyErr_NewExceptionWithDoc + fun:PyInit__lzma + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__lzma + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__lzma + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:PyInit_grp + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__decimal + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__decimal + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__decimal + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__decimal + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_CallMethodIdObjArgs + fun:PyImport_ImportModuleLevelObject + obj:/usr/bin/python3.8 + fun:PyCFunction_Call + fun:_PyObject_MakeTpCall + fun:PyObject_CallFunction +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__speedups + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__speedups + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:fsb_dx_nybitset_init + fun:PyInit_setsc + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:fsb_dx_nybitset_init + fun:PyInit_setsc + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:fsb_dx_nybitset_init + fun:PyInit_setsc + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:fsb_dx_nybitset_init + fun:PyInit_setsc + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:fsb_dx_nynodeset_init + fun:PyInit_setsc + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:fsb_dx_nynodeset_init + fun:PyInit_setsc + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:fsb_dx_nynodeset_init + fun:PyInit_setsc + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:fsb_dx_nynodeset_init + fun:PyInit_setsc + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:fsb_dx_nynodeset_init + fun:PyInit_setsc + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyFloat_FromDouble + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:PyCapsule_New + fun:fsb_dx_nybitset_init + fun:PyInit_setsc + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:PyCapsule_New + fun:fsb_dx_nynodeset_init + fun:PyInit_setsc + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:PyCapsule_New + fun:PyInit_setsc + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:PyObject_Call + fun:_PyCodec_Lookup + obj:/usr/bin/python3.8 + fun:_PyUnicode_InitEncodings + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_InitMain + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_FromNodeObject + fun:PyParser_ASTFromStringObject + fun:PyRun_StringFlags + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_FromNodeObject + fun:PyParser_ASTFromFileObject + fun:PyRun_FileExFlags + fun:PyRun_SimpleFileExFlags +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyDict_SetItemId + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyDict_SetItemId + fun:_PySys_SetPreliminaryStderr + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_InitMain + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyDict_SetItemId + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyBytes_FromStringAndSize + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyList_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyUnicode_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyUnicode_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyUnicode_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyHamt_Init + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyHamt_Init + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyHamt_Init + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyHamt_Init + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyHamt_Init + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyHamt_Init + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyHamt_Init + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyContext_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyModuleDef_Init + fun:_PyModule_CreateInitialized + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyObject_SetAttr + obj:/usr/bin/python3.8 + fun:PyModule_AddFunctions + fun:_PyModule_CreateInitialized + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + fun:PyImport_ImportFrozenModuleObject +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + obj:/usr/bin/python3.8 + fun:_PyObject_LookupSpecial + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__thread + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__thread + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:PyModule_AddObject + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + obj:/usr/bin/python3.8 + fun:PyObject_LengthHint + fun:PySequence_List + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__operator + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__collections + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_FromNodeObject + fun:PyParser_ASTFromFileObject + fun:PyRun_FileExFlags + fun:PyRun_SimpleFileExFlags +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_FileExFlags +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_FileExFlags + fun:PyRun_SimpleFileExFlags +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_FileExFlags +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_FileExFlags + fun:PyRun_SimpleFileExFlags + fun:Py_RunMain +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyType_GenericNew + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:PyObject_CallFunctionObjArgs + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__ssl + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__ssl + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__ssl + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__sha3 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__sha3 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__sha3 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__sha3 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyCFunction_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__speedups + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyUnicode_InternFromString + obj:/usr/bin/python3.8 + fun:_PyWarnings_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:PyModule_AddObject + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyImportHooks_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_InitMain + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_SetPreliminaryStderr + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyImportHooks_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_InitMain + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:PyModule_AddObject + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyModule_AddFunctions + fun:_PyModule_CreateInitialized + fun:PyInit__imp + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_InitMain + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_InitMain + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_InitMain + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:PyModule_AddObject + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyType_Ready + fun:PyInit__ctypes + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:PyModule_AddObject + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyModule_AddFunctions + fun:_PyModule_CreateInitialized + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_InitMain + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:PyModule_AddObject + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:PyModule_AddObject + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:PyModule_AddObject + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:PyModule_AddObject + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyBytes_FromStringAndSize + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + fun:PyUnicode_InternInPlace + fun:PyUnicode_InternFromString + obj:/usr/bin/python3.8 + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyTypes_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:_PyLong_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:_PyFloat_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:_PyErr_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + fun:PyType_Ready + fun:PyModuleDef_Init + fun:_PyModule_CreateInitialized + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + fun:PyModule_NewObject + fun:PyModule_New + fun:_PyModule_CreateInitialized + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:PyThread_GetInfo + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + fun:PyModule_NewObject + fun:PyModule_New + fun:_PyModule_CreateInitialized + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + fun:_PyWarnings_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:_PyDict_NewPresized + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + fun:PyType_Ready + fun:PyInit__thread + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + obj:/usr/bin/python3.8 + fun:PyObject_SetAttr + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_CallMethodIdObjArgs + fun:PyImport_ImportModuleLevelObject +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:PyModule_AddObject + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:PyObject_GetAttr + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + fun:PyInit_posix + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + obj:/usr/bin/python3.8 + fun:PyObject_SetAttr + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:_PyObject_SetAttrId + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyObject_CallFunction_SizeT + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyObject_CallMethodId_SizeT + fun:PyFile_OpenCodeObject + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + fun:PyModule_NewObject + fun:PyModule_New + fun:_PyModule_CreateInitialized + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_Copy + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyCFunction_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyObject_SetAttr + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PySymtable_BuildObject + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_StringFlags + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_StringFlags + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_StringFlags + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_StringFlags + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_StringFlags + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_StringFlags + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_StringFlags + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_FileExFlags +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyObject_CallMethod + fun:PyInit__openssl + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyContextVar_New + fun:PyInit__decimal + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:realloc + fun:_PyObject_GC_Resize + fun:_PyTuple_Resize + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyObject_CallMethod + fun:PyInit__decimal +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyCFunction_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:PyObject_CallFunction + fun:PyInit__decimal + fun:_PyImport_LoadDynamicModuleWithSpec +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:fsb_dx_nybitset_init + fun:PyInit_setsc + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:fsb_dx_nybitset_init + fun:PyInit_setsc + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:fsb_dx_nynodeset_init + fun:PyInit_setsc + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:fsb_dx_nynodeset_init + fun:PyInit_setsc + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_InitMain + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_InitMain + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyType_Ready + fun:PyInit__thread + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyImportHooks_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyModule_AddIntConstant + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyBytes_FromStringAndSize + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + fun:PyObject_CallFunctionObjArgs + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:PyModule_AddObject + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyBytes_FromStringAndSize + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:PyInit__imp + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyObject_Call + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyFloat_FromDouble + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:_PyBuiltins_AddExceptions + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:_PyWarnings_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:_PyWarnings_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:_PyWarnings_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:_PyWarnings_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:_PyWarnings_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + obj:/usr/bin/python3.8 + fun:PyContextVar_New + fun:PyInit__decimal + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:_PyExc_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + fun:PyInit__functools + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyUnicode_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:PyImport_Cleanup + fun:Py_FinalizeEx + fun:Py_Exit + obj:/usr/bin/python3.8 + fun:PyErr_PrintEx + fun:PyRun_SimpleFileExFlags + fun:Py_RunMain + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyObject_CallMethod + fun:PyInit__constant_time + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyObject_CallMethod + fun:PyInit__openssl + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PySequence_List + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_FileExFlags +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyType_GenericAlloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + fun:PyObject_CallFunctionObjArgs + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyObject_SetAttr + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + obj:/usr/bin/python3.8 + fun:PySymtable_BuildObject + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_StringFlags + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PySymtable_BuildObject + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_FileExFlags + fun:PyRun_SimpleFileExFlags + fun:Py_RunMain +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + fun:PyObject_CallFunctionObjArgs + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:PyObject_CallFunction + fun:PyImport_Import + fun:PyImport_ImportModule + fun:PyFile_OpenCodeObject + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItem + fun:PyType_Ready + fun:PyStructSequence_InitType2 + fun:_PyErr_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItem + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyDict_SetItemId + obj:/usr/bin/python3.8 + fun:PyModule_NewObject + fun:PyModule_New + fun:_PyModule_CreateInitialized + fun:PyInit__imp + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItem + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItem + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItem + fun:PyType_Ready + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyDict_Copy + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyCFunction_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyDict_Copy + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyCFunction_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyStack_AsDict + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PySymtable_BuildObject + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_StringFlags + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItem + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PySymtable_BuildObject + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_StringFlags + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_StringFlags + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PySymtable_BuildObject + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_FileExFlags + fun:PyRun_SimpleFileExFlags +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItem + fun:PyType_Ready + fun:PyInit__cffi_backend + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyBytes_FromStringAndSize + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + fun:PyObject_CallFunctionObjArgs + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyCode_NewWithPosOnlyArgs + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyCode_NewWithPosOnlyArgs + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyCode_NewWithPosOnlyArgs + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + obj:/usr/bin/python3.8 + fun:PyObject_SetAttr + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_Copy + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:PyObject_CallFunction + fun:PyErr_NewException + fun:PyInit__decimal + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyObject_CallFunction_SizeT + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyObject_CallMethodId_SizeT + fun:PyFile_OpenCodeObject + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyObject_CallMethod + fun:PyInit__openssl + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyList_AsTuple + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyErr_NewException + fun:PyInit__decimal + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_Copy + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_New + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + obj:/usr/bin/python3.8 + fun:PyObject_GetAttr + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyType_GenericAlloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + fun:PyObject_CallFunctionObjArgs + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:_PyObject_GC_New + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyObject_CallMethod + fun:PyInit__constant_time + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_FileExFlags +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + obj:/usr/bin/python3.8 + fun:PyObject_GenericGetDict + obj:/usr/bin/python3.8 + fun:PyObject_GetAttr + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_Copy + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:PyObject_CallFunction + fun:PyErr_NewException + fun:PyInit__decimal + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyDict_Copy + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyCFunction_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItem + fun:PyObject_SetAttr + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:_PyStack_UnpackDict + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_FileExFlags +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + fun:PyObject_GetAttr + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyBytes_FromStringAndSize + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + fun:PyObject_CallFunctionObjArgs + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_Copy + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyCFunction_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:PyObject_GetAttr + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_CallMethodIdObjArgs +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + fun:PyImport_ImportFrozenModuleObject + fun:PyImport_ImportFrozenModule +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyFunction_Vectorcall + fun:PyObject_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:PyObject_CallFunctionObjArgs + obj:/usr/bin/python3.8 + fun:PyObject_SetAttr + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + obj:/usr/bin/python3.8 + fun:PyObject_GetAttr + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyObject_CallFunctionObjArgs + fun:PyObject_IsSubclass + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:PyType_Ready + obj:/usr/bin/python3.8 + fun:PyObject_GetAttr + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyObject_CallMethodIdObjArgs + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_CallMethodIdObjArgs + fun:PyImport_ImportModuleLevelObject +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + fun:PyObject_GetAttr + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyModule_AddFunctions + fun:_PyModule_CreateInitialized + fun:PyInit__ctypes + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_CallMethodIdObjArgs + fun:PyImport_ImportModuleLevelObject + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItem + fun:_PyObject_SetAttrId + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyObject_CallFunction_SizeT + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyObject_CallMethodId_SizeT + fun:PyFile_OpenCodeObject + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItem + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyErr_NewException + fun:PyInit__decimal + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_CallMethodIdObjArgs +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:PyObject_Call + fun:_PyCodec_Lookup +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:PyType_Ready + fun:PyInit_itertools + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItem + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyDict_Copy + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_FileExFlags +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyType_GenericAlloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + fun:PyObject_CallFunctionObjArgs + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyDict_Copy + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:PyObject_CallFunction + fun:PyErr_NewException + fun:PyInit__decimal + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + fun:PyObject_CallFunctionObjArgs + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + obj:/usr/bin/python3.8 + fun:PyObject_GetAttr + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PySequence_List + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_CallMethodIdObjArgs + fun:PyImport_ImportModuleLevelObject + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + fun:PyObject_CallFunctionObjArgs + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_NewVar + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + fun:_PyObject_CallMethodIdObjArgs + fun:PyImport_ImportModuleLevelObject + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:PyModule_AddObject + fun:PyInit__io + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyMarshal_ReadObjectFromString + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyDict_Copy + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/bin/python3.8 + fun:PyInit_setsc + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyAST_CompileObject + obj:/usr/bin/python3.8 + fun:PyRun_FileExFlags +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:PyDict_Copy + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:PyObject_CallFunction + fun:PyErr_NewException + fun:PyInit__decimal + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyModule_AddFunctions + fun:_PyModule_CreateInitialized + fun:_PyBuiltin_Init + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + fun:_PyObject_GC_New + fun:PyObject_SetAttr + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItem + fun:PyObject_SetAttr + obj:/usr/bin/python3.8 + fun:PyModule_AddFunctions + fun:_PyModule_CreateInitialized + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + fun:PyModule_AddObject + fun:PyInit__ctypes + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyModule_AddFunctions + fun:_PyModule_CreateInitialized + fun:_PySys_Create + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItemString + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_InitializeFromConfig + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyImport_Cleanup + fun:Py_FinalizeEx + fun:Py_Exit + obj:/usr/bin/python3.8 + fun:PyErr_PrintEx + fun:PyRun_SimpleFileExFlags + fun:Py_RunMain + fun:Py_BytesMain + fun:(below main) +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItem + fun:PyObject_SetAttr + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetItem + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + fun:PyObject_GetAttr +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + fun:PyObject_GetAttr + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + fun:PyObject_GetAttr + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + fun:PyObject_GetAttr + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: possible + fun:malloc + obj:/usr/bin/python3.8 + fun:PyDict_SetDefault + fun:PyUnicode_InternInPlace + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/lib/python3/dist-packages/_cffi_backend.cpython-38-x86_64-linux-gnu.so + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyObject_CallMethod + fun:PyInit__openssl + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:lib_build_and_cache_attr + fun:lib_getattr + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:lib_build_and_cache_attr + fun:lib_getattr + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:_my_Py_InitModule + fun:lib_getattr + fun:b_init_cffi_1_0_external_module + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyObject_CallMethod + fun:_cffi_init + fun:PyInit__bcrypt + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:_PyObject_GC_New + fun:lib_getattr + fun:ffi_internal_new + fun:b_init_cffi_1_0_external_module + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyObject_CallMethod + fun:_cffi_init + fun:PyInit__bcrypt + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:lib_build_cpython_func.isra.87 + fun:lib_build_and_cache_attr + fun:lib_getattr + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:lib_build_and_cache_attr + fun:lib_getattr + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:_my_Py_InitModule + fun:b_init_cffi_1_0_external_module + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyObject_CallMethod + fun:_cffi_init + fun:PyInit__bcrypt + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:_my_Py_InitModule + fun:b_init_cffi_1_0_external_module + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyObject_CallMethod + fun:PyInit__openssl + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:_PyObject_GC_New + fun:ffi_internal_new + fun:b_init_cffi_1_0_external_module + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyObject_CallMethod + fun:_cffi_init + fun:PyInit__bcrypt + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:__libc_alloc_buffer_allocate + fun:alloc_buffer_allocate + fun:__resolv_conf_allocate + fun:__resolv_conf_load + fun:__resolv_conf_get_current + fun:__res_vinit + fun:maybe_init + fun:context_get + fun:context_get + fun:__resolv_context_get + fun:gaih_inet.constprop.0 + fun:getaddrinfo + fun:taosGetFqdn + fun:taosCheckGlobalCfg + fun:taos_init_imp +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:__pyx_pymod_exec_mtrand + fun:PyModule_ExecDef + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:PyCode_NewWithPosOnlyArgs + fun:PyCode_New + fun:__Pyx_InitCachedConstants + fun:__pyx_pymod_exec__generator + fun:PyModule_ExecDef + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:__pyx_pymod_exec_bit_generator + fun:PyModule_ExecDef + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:__pyx_pymod_exec__common + fun:PyModule_ExecDef + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:__pyx_pymod_exec__bounded_integers + fun:PyModule_ExecDef + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:__pyx_pymod_exec__mt19937 + fun:PyModule_ExecDef + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:__pyx_pymod_exec__philox + fun:PyModule_ExecDef + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:__pyx_pymod_exec__pcg64 + fun:PyModule_ExecDef + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:__pyx_pymod_exec__sfc64 + fun:PyModule_ExecDef + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + fun:__Pyx_InitCachedConstants + fun:__pyx_pymod_exec__generator + fun:PyModule_ExecDef + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:PyCode_NewWithPosOnlyArgs + fun:PyCode_New + fun:__pyx_pymod_exec_mtrand + fun:PyModule_ExecDef + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:PyCode_NewWithPosOnlyArgs + fun:PyCode_New + fun:__pyx_pymod_exec_bit_generator + fun:PyModule_ExecDef + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:__libc_alloc_buffer_allocate + fun:alloc_buffer_allocate + fun:__resolv_conf_allocate + fun:__resolv_conf_load + fun:__resolv_conf_get_current + fun:__res_vinit + fun:maybe_init + fun:context_get + fun:__resolv_context_get + fun:gaih_inet.constprop.7 + fun:getaddrinfo + fun:taosGetFqdn + fun:taosCheckGlobalCfg + fun:taos_init_imp +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + obj:/usr/bin/python3.8 + fun:PyObject_GetItem + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:PyCode_NewWithPosOnlyArgs + fun:PyCode_New + obj:/usr/local/lib/python3.8/dist-packages/pandas/_libs/tslibs/parsing.cpython-38-x86_64-linux-gnu.so + obj:/usr/local/lib/python3.8/dist-packages/pandas/_libs/tslibs/parsing.cpython-38-x86_64-linux-gnu.so + fun:PyModule_ExecDef + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + obj:/usr/local/lib/python3.8 + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun: malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + obj:/usr/local/lib/python3.8/dist-packages/pandas/_libs/interval.cpython-38-x86_64-linux-gnu.so + fun:PyModule_ExecDef + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun: malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + obj:/usr/bin/python3.8 + fun:PyObject_CallFunctionObjArgs + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyObject_GetAttr + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8) + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8) + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8) + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/bin/python3.8) + fun:PyTuple_Pack + obj:/usr/local/lib/python3.8/dist-packages/pandas/_libs/interval.cpython-38-x86_64-linux-gnu.so + fun:PyModule_ExecDef + obj:/usr/bin/python3.8) + obj:/usr/bin/python3.8) + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + obj:/usr/local/lib/python3.8/dist-packages/pandas/_libs/tslibs/np_datetime.cpython-38-x86_64-linux-gnu.so + fun:PyModule_ExecDef + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + obj:/usr/local/lib/python3.8/dist-packages/pandas/_libs/tslibs/ccalendar.cpython-38-x86_64-linux-gnu.so + fun:PyModule_ExecDef + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + obj:/usr/local/lib/python3.8/dist-packages/pandas/_libs/interval.cpython-38-x86_64-linux-gnu.so + fun:PyModule_ExecDef + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_Pack + obj:/usr/local/lib/python3.8/dist-packages/pandas/_libs/hashtable.cpython-38-x86_64-linux-gnu.so + obj:/usr/local/lib/python3.8/dist-packages/pandas/_libs/hashtable.cpython-38-x86_64-linux-gnu.so + fun:PyModule_ExecDef + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: definite + ... + obj:/usr/local/lib/python3.8/dist-packages/pandas/* + ... +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:PyObject_GetAttr + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/bin/python3.8 + fun:PyTuple_New + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:_PyFunction_Vectorcall +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:lib_build_and_cache_attr + fun:lib_getattr + fun:PyObject_GetAttr + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:lib_build_and_cache_attr + fun:lib_getattr + fun:PyObject_GetAttr + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:_my_Py_InitModule + fun:b_init_cffi_1_0_external_module + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyObject_CallMethod + fun:PyInit__constant_time + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:lib_build_cpython_func.isra.87 + fun:lib_build_and_cache_attr + fun:lib_getattr + fun:PyObject_GetAttr + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:_my_Py_InitModule + fun:b_init_cffi_1_0_external_module + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyObject_CallMethod + fun:PyInit__openssl + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:_PyObject_GC_New + fun:ffi_internal_new + fun:b_init_cffi_1_0_external_module + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyObject_CallMethod + fun:PyInit__constant_time + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:_buffer_get_info + fun:array_getbuffer + fun:__Pyx__GetBufferAndValidate.constprop.64 + fun:__pyx_f_5numpy_6random_13bit_generator_12SeedSequence_mix_entropy + fun:__pyx_pw_5numpy_6random_13bit_generator_12SeedSequence_1__init__ + obj:/usr/bin/python3.8 + fun:__Pyx__PyObject_CallOneArg + fun:__Pyx_PyObject_CallOneArg + fun:__pyx_pw_5numpy_6random_13bit_generator_12BitGenerator_1__init__ + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyObject_MakeTpCall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} \ No newline at end of file diff --git a/tests/pytest/crash_gen_bootstrap.py b/tests/pytest/crash_gen_bootstrap.py new file mode 100644 index 0000000000000000000000000000000000000000..de2d9b0780f3654424d8e077a4dda9ac5ac0ed50 --- /dev/null +++ b/tests/pytest/crash_gen_bootstrap.py @@ -0,0 +1,23 @@ +# -----!/usr/bin/python3.7 +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +import sys +from crash_gen.crash_gen_main import MainExec + +if __name__ == "__main__": + + mExec = MainExec() + mExec.init() + exitCode = mExec.run() + + print("\nCrash_Gen is now exiting with status code: {}".format(exitCode)) + sys.exit(exitCode) diff --git a/tests/pytest/dbmgmt/__init__.py b/tests/pytest/dbmgmt/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/pytest/dbmgmt/createTableAndDropDnodes.py b/tests/pytest/dbmgmt/createTableAndDropDnodes.py new file mode 100644 index 0000000000000000000000000000000000000000..6e29c023abac3d46f873ec85ed79809f28c26d03 --- /dev/null +++ b/tests/pytest/dbmgmt/createTableAndDropDnodes.py @@ -0,0 +1,151 @@ +# -*- coding: utf-8 -*- + +import sys +import taos +import threading +import traceback +import random +import datetime +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + + def init(self): + tdLog.debug("start to execute %s" % __file__) + tdLog.info("prepare cluster") + tdDnodes.stopAll() + tdDnodes.deploy(1) + tdDnodes.start(1) + + self.conn = taos.connect(config=tdDnodes.getSimCfgPath()) + tdSql.init(self.conn.cursor()) + tdSql.execute('reset query cache') + tdSql.execute('create dnode 192.168.0.2') + tdDnodes.deploy(2) + tdDnodes.start(2) + tdSql.execute('create dnode 192.168.0.3') + tdDnodes.deploy(3) + tdDnodes.start(3) + time.sleep(3) + + self.db = "db" + self.stb = "stb" + self.tbPrefix = "tb" + self.tbNum = 100000 + self.count = 0 + # self.conn = taos.connect(config=tdDnodes.getSimCfgPath()) + self.threadNum = 1 + # threadLock = threading.Lock() + # global counter for number of tables created by all threads + self.global_counter = 0 + + tdSql.init(self.conn.cursor()) + + def _createTable(self, threadId): + print("Thread%d : createTable" % (threadId)) + conn = taos.connect(config=tdDnodes.getSimCfgPath()) + cursor = conn.cursor() + i = 0 + try: + sql = "use %s" % (self.db) + cursor.execute(sql) + while i < self.tbNum: + if (i % self.threadNum == threadId): + cursor.execute( + "create table tb%d using %s tags(%d)" % + (i + 1, self.stb, i + 1)) + with threading.Lock(): + self.global_counter += 1 + i += 1 + except Exception as e: + tdLog.info( + "Failure when creating table tb%d, exception: %s" % + (i + 1, str(e))) + finally: + cursor.close() + conn.close() + + def _interfereDnodes(self, threadId, dnodeId): + conn = taos.connect(config=tdDnodes.getSimCfgPath()) + cursor = conn.cursor() + # interfere dnode while creating table + print("Thread%d to interfere dnode%d" % (threadId, dnodeId)) + while self.global_counter < self.tbNum * 0.05: + time.sleep(0.2) + cursor.execute("drop dnode 192.168.0.%d" % (dnodeId)) + while self.global_counter < self.tbNum * 0.15: + time.sleep(0.2) + cursor.execute("create dnode 192.168.0.%d" % (dnodeId)) + while self.global_counter < self.tbNum * 0.35: + time.sleep(0.2) + cursor.execute("drop dnode 192.168.0.%d" % (dnodeId)) + while self.global_counter < self.tbNum * 0.45: + time.sleep(0.2) + cursor.execute("create dnode 192.168.0.%d" % (dnodeId)) + while self.global_counter < self.tbNum * 0.65: + time.sleep(0.2) + cursor.execute("drop dnode 192.168.0.%d" % (dnodeId)) + while self.global_counter < self.tbNum * 0.85: + time.sleep(0.2) + cursor.execute("create dnode 192.168.0.%d" % (dnodeId)) + + def run(self): + tdLog.info("================= creating database with replica 2") + threadId = 0 + threads = [] + try: + tdSql.execute("drop database if exists %s" % (self.db)) + tdSql.execute( + "create database %s replica 2 cache 2048 ablocks 2.0 tblocks 10 tables 2000" % + (self.db)) + tdLog.sleep(3) + tdSql.execute("use %s" % (self.db)) + tdSql.execute( + "create table %s (ts timestamp, c1 bigint, stime timestamp) tags(tg1 bigint)" % + (self.stb)) + tdLog.info("Start to create tables") + while threadId < self.threadNum: + tdLog.info("Thread-%d starts to create tables" % (threadId)) + cThread = threading.Thread( + target=self._createTable, + name="thread-%d" % + (threadId), + args=( + threadId, + )) + cThread.start() + threads.append(cThread) + threadId += 1 + + except Exception as e: + tdLog.info("Failed to create tb%d, exception: %s" % (i, str(e))) + # tdDnodes.stopAll() + finally: + time.sleep(1) + + threading.Thread( + target=self._interfereDnodes, + name="thread-interfereDnode%d" % + (3), + args=( + 1, + 3, + )).start() + for t in range(len(threads)): + tdLog.info("Join threads") + # threads[t].start() + threads[t].join() + + tdSql.query("show stables") + tdSql.checkData(0, 4, self.tbNum) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addCluster(__file__, TDTestCase()) diff --git a/tests/pytest/dbmgmt/createTableAndKillDnodes.py b/tests/pytest/dbmgmt/createTableAndKillDnodes.py new file mode 100644 index 0000000000000000000000000000000000000000..7772ecdc68e2b85206a5f9e64c10021afef38279 --- /dev/null +++ b/tests/pytest/dbmgmt/createTableAndKillDnodes.py @@ -0,0 +1,172 @@ +# -*- coding: utf-8 -*- + +import sys +import taos +import threading +import traceback +import random +import datetime +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + + def init(self): + tdLog.debug("start to execute %s" % __file__) + tdLog.info("prepare cluster") + tdDnodes.stopAll() + tdDnodes.deploy(1) + tdDnodes.start(1) + + self.conn = taos.connect(config=tdDnodes.getSimCfgPath()) + tdSql.init(self.conn.cursor()) + tdSql.execute('reset query cache') + tdSql.execute('create dnode 192.168.0.2') + tdDnodes.deploy(2) + tdDnodes.start(2) + tdSql.execute('create dnode 192.168.0.3') + tdDnodes.deploy(3) + tdDnodes.start(3) + time.sleep(3) + + self.db = "db" + self.stb = "stb" + self.tbPrefix = "tb" + self.tbNum = 100000 + self.count = 0 + # self.conn = taos.connect(config=tdDnodes.getSimCfgPath()) + self.threadNum = 1 + # threadLock = threading.Lock() + # global counter for number of tables created by all threads + self.global_counter = 0 + + tdSql.init(self.conn.cursor()) + + def _createTable(self, threadId): + print("Thread%d : createTable" % (threadId)) + conn = taos.connect(config=tdDnodes.getSimCfgPath()) + cursor = conn.cursor() + i = 0 + try: + sql = "use %s" % (self.db) + cursor.execute(sql) + while i < self.tbNum: + if (i % self.threadNum == threadId): + cursor.execute( + "create table tb%d using %s tags(%d)" % + (i + 1, self.stb, i + 1)) + with threading.Lock(): + self.global_counter += 1 + time.sleep(0.01) + i += 1 + except Exception as e: + tdLog.info( + "Failure when creating table tb%d, exception: %s" % + (i + 1, str(e))) + finally: + cursor.close() + conn.close() + + def _interfereDnodes(self, threadId, dnodeId): + # interfere dnode while creating table + print("Thread%d to interfere dnode%d" % (threadId, dnodeId)) + percent = 0.05 + loop = int(1 / (2 * percent)) + for t in range(1, loop): + while self.global_counter < self.tbNum * (t * percent): + time.sleep(0.2) + tdDnodes.forcestop(dnodeId) + while self.global_counter < self.tbNum * ((t + 1) * percent): + time.sleep(0.2) + tdDnodes.start(dnodeId) + + # while self.global_counter < self.tbNum * 0.05: + # time.sleep(0.2) + # tdDnodes.forcestop(dnodeId) + # while self.global_counter < self.tbNum * 0.10: + # time.sleep(0.2) + # tdDnodes.start(dnodeId) + # while self.global_counter < self.tbNum * 0.15: + # time.sleep(0.2) + # tdDnodes.forcestop(dnodeId) + # while self.global_counter < self.tbNum * 0.20: + # time.sleep(0.2) + # tdDnodes.start(dnodeId) + # while self.global_counter < self.tbNum * 0.25: + # time.sleep(0.2) + # tdDnodes.forcestop(dnodeId) + # while self.global_counter < self.tbNum * 0.30: + # time.sleep(0.2) + # tdDnodes.start(dnodeId) + # while self.global_counter < self.tbNum * 0.35: + # time.sleep(0.2) + # tdDnodes.forcestop(dnodeId) + # while self.global_counter < self.tbNum * 0.40: + # time.sleep(0.2) + # tdDnodes.start(dnodeId) + # while self.global_counter < self.tbNum * 0.45: + # time.sleep(0.2) + # tdDnodes.forcestop(dnodeId) + # while self.global_counter < self.tbNum * 0.50: + # time.sleep(0.2) + # tdDnodes.start(dnodeId) + + def run(self): + tdLog.info("================= creating database with replica 2") + threadId = 0 + threads = [] + try: + tdSql.execute("drop database if exists %s" % (self.db)) + tdSql.execute( + "create database %s replica 2 cache 1024 ablocks 2.0 tblocks 4 tables 1000" % + (self.db)) + tdLog.sleep(3) + tdSql.execute("use %s" % (self.db)) + tdSql.execute( + "create table %s (ts timestamp, c1 bigint, stime timestamp) tags(tg1 bigint)" % + (self.stb)) + tdLog.info("Start to create tables") + while threadId < self.threadNum: + tdLog.info("Thread-%d starts to create tables" % (threadId)) + cThread = threading.Thread( + target=self._createTable, + name="thread-%d" % + (threadId), + args=( + threadId, + )) + cThread.start() + threads.append(cThread) + threadId += 1 + + except Exception as e: + tdLog.info("Failed to create tb%d, exception: %s" % (i, str(e))) + # tdDnodes.stopAll() + finally: + time.sleep(1) + + threading.Thread( + target=self._interfereDnodes, + name="thread-interfereDnode%d" % + (3), + args=( + 1, + 3, + )).start() + for t in range(len(threads)): + tdLog.info("Join threads") + # threads[t].start() + threads[t].join() + + tdSql.query("show stables") + tdSql.checkData(0, 4, self.tbNum) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addCluster(__file__, TDTestCase()) diff --git a/tests/pytest/dbmgmt/database-name-boundary.py b/tests/pytest/dbmgmt/database-name-boundary.py new file mode 100644 index 0000000000000000000000000000000000000000..df3b027ba7ea8f315060be2820e8bea2c17fa8cc --- /dev/null +++ b/tests/pytest/dbmgmt/database-name-boundary.py @@ -0,0 +1,70 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import datetime +import string +import random +import subprocess + +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + + chars = string.ascii_uppercase + string.ascii_lowercase + + getDbNameLen = "grep -w '#define TSDB_DB_NAME_LEN' ../../src/inc/taosdef.h|awk '{print $3}'" + dbNameMaxLen = int(subprocess.check_output(getDbNameLen, shell=True)) + tdLog.info("DB name max length is %d" % dbNameMaxLen) + + tdLog.info("=============== step1") + db_name = ''.join(random.choices(chars, k=(dbNameMaxLen + 1))) + tdLog.info('db_name length %d' % len(db_name)) + tdLog.info('create database %s' % db_name) + tdSql.error('create database %s' % db_name) + + tdLog.info("=============== step2") + db_name = ''.join(random.choices(chars, k=dbNameMaxLen)) + tdLog.info('db_name length %d' % len(db_name)) + tdLog.info('create database %s' % db_name) + tdSql.execute('create database %s' % db_name) + + tdSql.query('show databases') + tdSql.checkRows(1) + tdSql.checkData(0, 0, db_name.lower()) + + tdLog.info("=============== step3") + db_name = ''.join(random.choices(chars, k=(dbNameMaxLen - 1))) + tdLog.info('db_name length %d' % len(db_name)) + tdLog.info('create database %s' % db_name) + tdSql.execute('create database %s' % db_name) + + tdSql.query('show databases') + tdSql.checkRows(2) + tdSql.checkData(0, 0, db_name.lower()) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/dbmgmt/dropDB_memory_test.py b/tests/pytest/dbmgmt/dropDB_memory_test.py new file mode 100644 index 0000000000000000000000000000000000000000..0f0925c2688f524d88701ec6cf0e3b302e6a519d --- /dev/null +++ b/tests/pytest/dbmgmt/dropDB_memory_test.py @@ -0,0 +1,67 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + tbNum = 10000 + insertRows = 1 + db = "db" + loop = 2 + tdSql.execute("drop database if exists %s" % (db)) + tdSql.execute("reset query cache") + tdLog.sleep(1) + for k in range(1, loop + 1): + tdLog.info("===========Loop%d starts============" % (k)) + tdSql.execute( + "create database %s cache 163840 ablocks 40 maxtables 5000 wal 0" % + (db)) + tdSql.execute("use %s" % (db)) + tdSql.execute( + "create table stb (ts timestamp, c1 int) tags(t1 bigint, t2 double)") + for j in range(1, tbNum): + tdSql.execute( + "create table tb%d using stb tags(%d, %d)" % + (j, j, j)) + + for j in range(1, tbNum): + for i in range(0, insertRows): + tdSql.execute( + "insert into tb%d values (now + %dm, %d)" % + (j, i, i)) + tdSql.query("select * from tb%d" % (j)) + tdSql.checkRows(insertRows) + tdLog.info("insert %d rows into tb%d" % (insertRows, j)) + # tdSql.sleep(3) + tdSql.execute("drop database %s" % (db)) + tdLog.sleep(2) + tdLog.info("===========Loop%d completed!=============" % (k)) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +#tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/dbmgmt/nanoSecondCheck.py b/tests/pytest/dbmgmt/nanoSecondCheck.py new file mode 100644 index 0000000000000000000000000000000000000000..a5e9adacee53a9172a2d8990ccc4d83feb983bdd --- /dev/null +++ b/tests/pytest/dbmgmt/nanoSecondCheck.py @@ -0,0 +1,219 @@ +# ################################################################# +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. + +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao + +# ################################################################# + +# -*- coding: utf-8 -*- + +# TODO: after TD-4518 and TD-4510 is resolved, add the exception test case for these situations + +import sys +from util.log import * +from util.cases import * +from util.sql import * +import time +from datetime import datetime +import os + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db precision "ns";') + tdSql.query('show databases;') + tdSql.checkData(0,16,'ns') + tdSql.execute('use db') + + tdLog.debug('testing nanosecond support in 1st timestamp') + tdSql.execute('create table tb (ts timestamp, speed int)') + tdSql.execute('insert into tb values(\'2021-06-10 0:00:00.100000001\', 1);') + tdSql.execute('insert into tb values(1623254400150000000, 2);') + tdSql.execute('import into tb values(1623254400300000000, 3);') + tdSql.execute('import into tb values(1623254400299999999, 4);') + tdSql.execute('insert into tb values(1623254400300000001, 5);') + tdSql.execute('insert into tb values(1623254400999999999, 7);') + + + tdSql.query('select * from tb;') + tdSql.checkData(0,0,'2021-06-10 0:00:00.100000001') + tdSql.checkData(1,0,'2021-06-10 0:00:00.150000000') + tdSql.checkData(2,0,'2021-06-10 0:00:00.299999999') + tdSql.checkData(3,1,3) + tdSql.checkData(4,1,5) + tdSql.checkData(5,1,7) + tdSql.checkRows(6) + tdSql.query('select count(*) from tb where ts > 1623254400100000000 and ts < 1623254400100000002;') + tdSql.checkData(0,0,1) + tdSql.query('select count(*) from tb where ts > \'2021-06-10 0:00:00.100000001\' and ts < \'2021-06-10 0:00:00.160000000\';') + tdSql.checkData(0,0,1) + + tdSql.query('select count(*) from tb where ts > 1623254400100000000 and ts < 1623254400150000000;') + tdSql.checkData(0,0,1) + tdSql.query('select count(*) from tb where ts > \'2021-06-10 0:00:00.100000000\' and ts < \'2021-06-10 0:00:00.150000000\';') + tdSql.checkData(0,0,1) + + tdSql.query('select count(*) from tb where ts > 1623254400400000000;') + tdSql.checkData(0,0,1) + tdSql.query('select count(*) from tb where ts < \'2021-06-10 00:00:00.400000000\';') + tdSql.checkData(0,0,5) + + tdSql.query('select count(*) from tb where ts > now + 400000000b;') + tdSql.checkRows(0) + + tdSql.query('select count(*) from tb where ts >= \'2021-06-10 0:00:00.100000001\';') + tdSql.checkData(0,0,6) + + tdSql.query('select count(*) from tb where ts <= 1623254400300000000;') + tdSql.checkData(0,0,4) + + tdSql.query('select count(*) from tb where ts = \'2021-06-10 0:00:00.000000000\';') + tdSql.checkRows(0) + + tdSql.query('select count(*) from tb where ts = 1623254400150000000;') + tdSql.checkData(0,0,1) + + tdSql.query('select count(*) from tb where ts = \'2021-06-10 0:00:00.100000001\';') + tdSql.checkData(0,0,1) + + tdSql.query('select count(*) from tb where ts between 1623254400000000000 and 1623254400400000000;') + tdSql.checkData(0,0,5) + + tdSql.query('select count(*) from tb where ts between \'2021-06-10 0:00:00.299999999\' and \'2021-06-10 0:00:00.300000001\';') + tdSql.checkData(0,0,3) + + tdSql.query('select avg(speed) from tb interval(5000000000b);') + tdSql.checkRows(1) + + tdSql.query('select avg(speed) from tb interval(100000000b)') + tdSql.checkRows(4) + + tdSql.error('select avg(speed) from tb interval(1b);') + tdSql.error('select avg(speed) from tb interval(999b);') + + tdSql.query('select avg(speed) from tb interval(1000b);') + tdSql.checkRows(5) + + tdSql.query('select avg(speed) from tb interval(1u);') + tdSql.checkRows(5) + + tdSql.query('select avg(speed) from tb interval(100000000b) sliding (100000000b);') + tdSql.checkRows(4) + + tdSql.query('select last(*) from tb') + tdSql.checkData(0,0, '2021-06-10 0:00:00.999999999') + tdSql.checkData(0,0, 1623254400999999999) + + tdSql.query('select first(*) from tb') + tdSql.checkData(0,0, 1623254400100000001) + tdSql.checkData(0,0, '2021-06-10 0:00:00.100000001') + + tdSql.execute('insert into tb values(now + 500000000b, 6);') + tdSql.query('select * from tb;') + tdSql.checkRows(7) + + tdLog.debug('testing nanosecond support in other timestamps') + tdSql.execute('create table tb2 (ts timestamp, speed int, ts2 timestamp);') + tdSql.execute('insert into tb2 values(\'2021-06-10 0:00:00.100000001\', 1, \'2021-06-11 0:00:00.100000001\');') + tdSql.execute('insert into tb2 values(1623254400150000000, 2, 1623340800150000000);') + tdSql.execute('import into tb2 values(1623254400300000000, 3, 1623340800300000000);') + tdSql.execute('import into tb2 values(1623254400299999999, 4, 1623340800299999999);') + tdSql.execute('insert into tb2 values(1623254400300000001, 5, 1623340800300000001);') + tdSql.execute('insert into tb2 values(1623254400999999999, 7, 1623513600999999999);') + + tdSql.query('select * from tb2;') + tdSql.checkData(0,0,'2021-06-10 0:00:00.100000001') + tdSql.checkData(1,0,'2021-06-10 0:00:00.150000000') + tdSql.checkData(2,1,4) + tdSql.checkData(3,1,3) + tdSql.checkData(4,2,'2021-06-11 00:00:00.300000001') + tdSql.checkData(5,2,'2021-06-13 00:00:00.999999999') + tdSql.checkRows(6) + tdSql.query('select count(*) from tb2 where ts2 > 1623340800000000000 and ts2 < 1623340800150000000;') + tdSql.checkData(0,0,1) + tdSql.query('select count(*) from tb2 where ts2 > \'2021-06-11 0:00:00.100000000\' and ts2 < \'2021-06-11 0:00:00.100000002\';') + tdSql.checkData(0,0,1) + + tdSql.query('select count(*) from tb2 where ts2 > 1623340800500000000;') + tdSql.checkData(0,0,1) + tdSql.query('select count(*) from tb2 where ts2 < \'2021-06-11 0:00:00.400000000\';') + tdSql.checkData(0,0,5) + + tdSql.query('select count(*) from tb2 where ts2 > now + 400000000b;') + tdSql.checkRows(0) + + tdSql.query('select count(*) from tb2 where ts2 >= \'2021-06-11 0:00:00.100000001\';') + tdSql.checkData(0,0,6) + + tdSql.query('select count(*) from tb2 where ts2 <= 1623340800400000000;') + tdSql.checkData(0,0,5) + + tdSql.query('select count(*) from tb2 where ts2 = \'2021-06-11 0:00:00.000000000\';') + tdSql.checkRows(0) + + tdSql.query('select count(*) from tb2 where ts2 = \'2021-06-11 0:00:00.300000001\';') + tdSql.checkData(0,0,1) + + tdSql.query('select count(*) from tb2 where ts2 = 1623340800300000001;') + tdSql.checkData(0,0,1) + + tdSql.query('select count(*) from tb2 where ts2 between 1623340800000000000 and 1623340800450000000;') + tdSql.checkData(0,0,5) + + tdSql.query('select count(*) from tb2 where ts2 between \'2021-06-11 0:00:00.299999999\' and \'2021-06-11 0:00:00.300000001\';') + tdSql.checkData(0,0,3) + + tdSql.query('select count(*) from tb2 where ts2 <> 1623513600999999999;') + tdSql.checkData(0,0,5) + + tdSql.query('select count(*) from tb2 where ts2 <> \'2021-06-11 0:00:00.100000001\';') + tdSql.checkData(0,0,5) + + tdSql.query('select count(*) from tb2 where ts2 <> \'2021-06-11 0:00:00.100000000\';') + tdSql.checkData(0,0,6) + + tdSql.query('select count(*) from tb2 where ts2 != 1623513600999999999;') + tdSql.checkData(0,0,5) + + tdSql.query('select count(*) from tb2 where ts2 != \'2021-06-11 0:00:00.100000001\';') + tdSql.checkData(0,0,5) + + tdSql.query('select count(*) from tb2 where ts2 != \'2021-06-11 0:00:00.100000000\';') + tdSql.checkData(0,0,6) + + tdSql.execute('insert into tb2 values(now + 500000000b, 6, now +2d);') + tdSql.query('select * from tb2;') + tdSql.checkRows(7) + + tdLog.debug('testing ill nanosecond format handling') + tdSql.execute('create table tb3 (ts timestamp, speed int);') + + tdSql.error('insert into tb3 values(16232544001500000, 2);') + tdSql.execute('insert into tb3 values(\'2021-06-10 0:00:00.123456\', 2);') + tdSql.query('select * from tb3 where ts = \'2021-06-10 0:00:00.123456000\';') + tdSql.checkRows(1) + + tdSql.execute('insert into tb3 values(\'2021-06-10 0:00:00.123456789000\', 2);') + tdSql.query('select * from tb3 where ts = \'2021-06-10 0:00:00.123456789\';') + tdSql.checkRows(1) + + os.system('sudo timedatectl set-ntp on') + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/dockerCluster/Dockerfile b/tests/pytest/dockerCluster/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..437dbc65e6430deb20faa16fc78ddc07005c15ac --- /dev/null +++ b/tests/pytest/dockerCluster/Dockerfile @@ -0,0 +1,45 @@ +FROM ubuntu:latest AS builder + +ARG PACKAGE=TDengine-server-1.6.5.10-Linux-x64.tar.gz +ARG EXTRACTDIR=TDengine-enterprise-server +ARG TARBITRATORPKG=TDengine-tarbitrator-1.6.5.10-Linux-x64.tar.gz +ARG EXTRACTDIR2=TDengine-enterprise-arbitrator +ARG CONTENT=taos.tar.gz + +WORKDIR /root + +COPY ${PACKAGE} . +COPY ${TARBITRATORPKG} . + +RUN tar -zxf ${PACKAGE} +RUN tar -zxf ${TARBITRATORPKG} +RUN mv ${EXTRACTDIR}/driver ./lib +RUN tar -zxf ${EXTRACTDIR}/${CONTENT} +RUN mv ${EXTRACTDIR2}/bin/* /root/bin + +FROM ubuntu:latest + +WORKDIR /root + +RUN apt-get update +RUN apt-get install -y vim tmux net-tools +RUN echo 'alias ll="ls -l --color=auto"' >> /root/.bashrc +RUN ulimit -c unlimited + +COPY --from=builder /root/bin/taosd /usr/bin +COPY --from=builder /root/bin/tarbitrator /usr/bin +COPY --from=builder /root/bin/taosdemo /usr/bin +COPY --from=builder /root/bin/taosdump /usr/bin +COPY --from=builder /root/bin/taos /usr/bin +COPY --from=builder /root/cfg/taos.cfg /etc/taos/ +COPY --from=builder /root/lib/libtaos.so.* /usr/lib/libtaos.so.1 + +ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib" +ENV LC_CTYPE=en_US.UTF-8 +ENV LANG=en_US.UTF-8 + +EXPOSE 6030-6042/tcp 6060/tcp 6030-6039/udp + +# VOLUME [ "/var/lib/taos", "/var/log/taos", "/etc/taos" ] + +CMD [ "bash" ] \ No newline at end of file diff --git a/tests/pytest/dockerCluster/OneMnodeMultipleVnodesTest.py b/tests/pytest/dockerCluster/OneMnodeMultipleVnodesTest.py new file mode 100644 index 0000000000000000000000000000000000000000..43e281f43769f59c2384fed43d00868c10a05342 --- /dev/null +++ b/tests/pytest/dockerCluster/OneMnodeMultipleVnodesTest.py @@ -0,0 +1,38 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +from basic import * + +class TDTestCase: + + def init(self): + # tdLog.debug("start to execute %s" % __file__) + + self.numOfNodes = 5 + self.dockerDir = "/data" + cluster.init(self.numOfNodes, self.dockerDir) + cluster.prepardBuild() + for i in range(self.numOfNodes): + if i == 0: + cluster.cfg("role", "1", i + 1) + else: + cluster.cfg("role", "2", i + 1) + cluster.run() + +td = TDTestCase() +td.init() + + +## usage: python3 OneMnodeMultipleVnodesTest.py + + diff --git a/tests/pytest/dockerCluster/__init__.py b/tests/pytest/dockerCluster/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/pytest/dockerCluster/basic.py b/tests/pytest/dockerCluster/basic.py new file mode 100644 index 0000000000000000000000000000000000000000..871d69790d328f3dcea9fdfdac27a6abc3bb14bd --- /dev/null +++ b/tests/pytest/dockerCluster/basic.py @@ -0,0 +1,165 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import os +import taos + +class BuildDockerCluser: + + def init(self, numOfNodes, dockerDir): + self.numOfNodes = numOfNodes + self.dockerDir = dockerDir + + self.hostName = "tdnode1" + self.user = "root" + self.password = "taosdata" + self.configDir = "/etc/taos" + self.dirs = ["data", "cfg", "log", "core"] + self.cfgDict = { + "numOfLogLines":"100000000", + "mnodeEqualVnodeNum":"0", + "walLevel":"1", + "numOfThreadsPerCore":"2.0", + "monitor":"0", + "vnodeBak":"1", + "dDebugFlag":"135", + "mDebugFlag":"135", + "sdbDebugFlag":"135", + "rpcDebugFlag":"135", + "tmrDebugFlag":"131", + "cDebugFlag":"135", + "httpDebugFlag":"135", + "monitorDebugFlag":"135", + "udebugFlag":"135", + "jnidebugFlag":"135", + "qdebugFlag":"135", + "maxSQLLength":"1048576" + } + cmd = "mkdir -p %s" % self.dockerDir + self.execCmd(cmd) + + cmd = "cp *.yml %s" % self.dockerDir + self.execCmd(cmd) + + cmd = "cp Dockerfile %s" % self.dockerDir + self.execCmd(cmd) + + + # execute command, and return the output + # ref: https://blog.csdn.net/wowocpp/article/details/80775650 + def execCmdAndGetOutput(self, cmd): + r = os.popen(cmd) + text = r.read() + r.close() + return text + + def execCmd(self, cmd): + if os.system(cmd) != 0: + quit() + + def getTaosdVersion(self): + cmd = "taosd -V |grep version|awk '{print $3}'" + taosdVersion = self.execCmdAndGetOutput(cmd) + cmd = "find %s -name '*server*.tar.gz' | awk -F- '{print $(NF-2)}'|sort|awk 'END {print}'" % self.dockerDir + packageVersion = self.execCmdAndGetOutput(cmd) + + if (taosdVersion is None or taosdVersion.isspace()) and (packageVersion is None or packageVersion.isspace()): + print("Please install taosd or have a install package ready") + quit() + else: + self.version = taosdVersion if taosdVersion >= packageVersion else packageVersion + return self.version.strip() + + def getConnection(self): + self.conn = taos.connect( + host = self.hostName, + user = self.user, + password = self.password, + config = self.configDir) + + def removeFile(self, rootDir, index, dir): + cmd = "rm -rf %s/node%d/%s/*" % (rootDir, index, dir) + self.execCmd(cmd) + + def clearEnv(self): + cmd = "cd %s && docker-compose down --remove-orphans" % self.dockerDir + self.execCmd(cmd) + for i in range(1, self.numOfNodes + 1): + self.removeFile(self.dockerDir, i, self.dirs[0]) + self.removeFile(self.dockerDir, i, self.dirs[1]) + self.removeFile(self.dockerDir, i, self.dirs[2]) + + def createDir(self, rootDir, index, dir): + cmd = "mkdir -p %s/node%d/%s" % (rootDir, index, dir) + self.execCmd(cmd) + + def createDirs(self): + for i in range(1, self.numOfNodes + 1): + for j in range(len(self.dirs)): + self.createDir(self.dockerDir, i, self.dirs[j]) + + def addExtraCfg(self, option, value): + self.cfgDict.update({option: value}) + + def cfg(self, option, value, nodeIndex): + cfgPath = "%s/node%d/cfg/taos.cfg" % (self.dockerDir, nodeIndex) + cmd = "echo '%s %s' >> %s" % (option, value, cfgPath) + self.execCmd(cmd) + + def updateLocalhosts(self): + cmd = "grep '172.27.0.7 *tdnode1' /etc/hosts | sed 's: ::g'" + result = self.execCmdAndGetOutput(cmd) + print(result) + if result is None or result.isspace(): + print("==========") + cmd = "echo '172.27.0.7 tdnode1' >> /etc/hosts" + display = "echo %s" % cmd + self.execCmd(display) + self.execCmd(cmd) + + def deploy(self): + self.clearEnv() + self.createDirs() + for i in range(1, self.numOfNodes + 1): + self.cfg("firstEp", "tdnode1:6030", i) + + for key, value in self.cfgDict.items(): + self.cfg(key, value, i) + + def createDondes(self): + self.cursor = self.conn.cursor() + for i in range(2, self.numOfNodes + 1): + self.cursor.execute("create dnode tdnode%d" % i) + + def startArbitrator(self): + for i in range(1, self.numOfNodes + 1): + self.cfg("arbitrator", "tdnode1:6042", i) + cmd = "docker exec -d $(docker ps|grep tdnode1|awk '{print $1}') tarbitrator" + self.execCmd(cmd) + + def prepardBuild(self): + if self.numOfNodes < 2 or self.numOfNodes > 10: + print("the number of nodes must be between 2 and 10") + exit(0) + self.updateLocalhosts() + self.deploy() + + def run(self): + cmd = "./buildClusterEnv.sh -n %d -v %s -d %s" % (self.numOfNodes, self.getTaosdVersion(), self.dockerDir) + display = "echo %s" % cmd + self.execCmd(display) + self.execCmd(cmd) + self.getConnection() + self.createDondes() + +cluster = BuildDockerCluser() \ No newline at end of file diff --git a/tests/pytest/dockerCluster/buildClusterEnv.sh b/tests/pytest/dockerCluster/buildClusterEnv.sh new file mode 100755 index 0000000000000000000000000000000000000000..7bd92cad72c4180d5405364ebe2fbd81a8a20386 --- /dev/null +++ b/tests/pytest/dockerCluster/buildClusterEnv.sh @@ -0,0 +1,127 @@ +#!/bin/bash +echo "Executing buildClusterEnv.sh" +CURR_DIR=`pwd` +IN_TDINTERNAL="community" + +if [ $# != 6 ]; then + echo "argument list need input : " + echo " -n numOfNodes" + echo " -v version" + echo " -d docker dir" + exit 1 +fi + +NUM_OF_NODES= +VERSION= +DOCKER_DIR= +while getopts "n:v:d:" arg +do + case $arg in + n) + NUM_OF_NODES=$OPTARG + ;; + v) + VERSION=$OPTARG + ;; + d) + DOCKER_DIR=$OPTARG + ;; + ?) + echo "unkonwn argument" + ;; + esac +done + +function prepareBuild { + + if [ -d $CURR_DIR/../../../release ]; then + echo release exists + rm -rf $CURR_DIR/../../../release/* + fi + + cd $CURR_DIR/../../../packaging + + if [[ "$CURR_DIR" == *"$IN_TDINTERNAL"* ]]; then + if [ ! -e $DOCKER_DIR/TDengine-enterprise-server-$VERSION-Linux-x64.tar.gz ] || [ ! -e $DOCKER_DIR/TDengine-enterprise-arbitrator-$VERSION-Linux-x64.tar.gz ]; then + + echo "generating TDeninge enterprise packages" + ./release.sh -v cluster -n $VERSION >> /dev/null 2>&1 + + if [ ! -e $CURR_DIR/../../../release/TDengine-enterprise-server-$VERSION-Linux-x64.tar.gz ]; then + echo "no TDengine install package found" + exit 1 + fi + + if [ ! -e $CURR_DIR/../../../release/TDengine-enterprise-arbitrator-$VERSION-Linux-x64.tar.gz ]; then + echo "no arbitrator install package found" + exit 1 + fi + + cd $CURR_DIR/../../../release + mv TDengine-enterprise-server-$VERSION-Linux-x64.tar.gz $DOCKER_DIR + mv TDengine-enterprise-arbitrator-$VERSION-Linux-x64.tar.gz $DOCKER_DIR + fi + else + if [ ! -e $DOCKER_DIR/TDengine-server-$VERSION-Linux-x64.tar.gz ] || [ ! -e $DOCKER_DIR/TDengine-arbitrator-$VERSION-Linux-x64.tar.gz ]; then + + echo "generating TDeninge community packages" + ./release.sh -v edge -n $VERSION >> /dev/null 2>&1 + + if [ ! -e $CURR_DIR/../../../release/TDengine-server-$VERSION-Linux-x64.tar.gz ]; then + echo "no TDengine install package found" + exit 1 + fi + + if [ ! -e $CURR_DIR/../../../release/TDengine-arbitrator-$VERSION-Linux-x64.tar.gz ]; then + echo "no arbitrator install package found" + exit 1 + fi + + cd $CURR_DIR/../../../release + mv TDengine-server-$VERSION-Linux-x64.tar.gz $DOCKER_DIR + mv TDengine-arbitrator-$VERSION-Linux-x64.tar.gz $DOCKER_DIR + fi + fi + + rm -rf $DOCKER_DIR/*.yml + cd $CURR_DIR + + cp *.yml $DOCKER_DIR + cp Dockerfile $DOCKER_DIR +} + +function clusterUp { + echo "docker compose start" + + cd $DOCKER_DIR + + if [[ "$CURR_DIR" == *"$IN_TDINTERNAL"* ]]; then + docker_run="PACKAGE=TDengine-enterprise-server-$VERSION-Linux-x64.tar.gz TARBITRATORPKG=TDengine-enterprise-arbitrator-$VERSION-Linux-x64.tar.gz DIR=TDengine-enterprise-server-$VERSION DIR2=TDengine-enterprise-arbitrator-$VERSION VERSION=$VERSION DATADIR=$DOCKER_DIR docker-compose -f docker-compose.yml " + else + docker_run="PACKAGE=TDengine-server-$VERSION-Linux-x64.tar.gz TARBITRATORPKG=TDengine-arbitrator-$VERSION-Linux-x64.tar.gz DIR=TDengine-server-$VERSION DIR2=TDengine-arbitrator-$VERSION VERSION=$VERSION DATADIR=$DOCKER_DIR docker-compose -f docker-compose.yml " + fi + + if [ $NUM_OF_NODES -ge 2 ];then + echo "create $NUM_OF_NODES dnodes" + for((i=3;i<=$NUM_OF_NODES;i++)) + do + if [ ! -f node$i.yml ];then + echo "node$i.yml not exist" + cp node3.yml node$i.yml + sed -i "s/td2.0-node3/td2.0-node$i/g" node$i.yml + sed -i "s/'tdnode3'/'tdnode$i'/g" node$i.yml + sed -i "s#/node3/#/node$i/#g" node$i.yml + sed -i "s#hostname: tdnode3#hostname: tdnode$i#g" node$i.yml + sed -i "s#ipv4_address: 172.27.0.9#ipv4_address: 172.27.0.`expr $i + 6`#g" node$i.yml + fi + docker_run=$docker_run" -f node$i.yml " + done + docker_run=$docker_run" up -d" + fi + echo $docker_run |sh + + echo "docker compose finish" +} + +prepareBuild +clusterUp \ No newline at end of file diff --git a/tests/pytest/dockerCluster/docker-compose.yml b/tests/pytest/dockerCluster/docker-compose.yml new file mode 100644 index 0000000000000000000000000000000000000000..7855f3013687406f407cfb9a5aec27e0da78a5f5 --- /dev/null +++ b/tests/pytest/dockerCluster/docker-compose.yml @@ -0,0 +1,131 @@ +version: '3.7' + +services: + td2.0-node1: + build: + context: . + args: + - PACKAGE=${PACKAGE} + - TARBITRATORPKG=${TARBITRATORPKG} + - EXTRACTDIR=${DIR} + - EXTRACTDIR2=${DIR2} + - DATADIR=${DATADIR} + image: 'tdengine:${VERSION}' + container_name: 'tdnode1' + cap_add: + - ALL + stdin_open: true + tty: true + environment: + TZ: "Asia/Shanghai" + command: > + sh -c "ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && + echo $TZ > /etc/timezone && + mkdir /coredump && + echo 'kernel.core_pattern=/coredump/core_%e_%p' >> /etc/sysctl.conf && + sysctl -p && + exec my-main-application" + extra_hosts: + - "tdnode2:172.27.0.8" + - "tdnode3:172.27.0.9" + - "tdnode4:172.27.0.10" + - "tdnode5:172.27.0.11" + - "tdnode6:172.27.0.12" + - "tdnode7:172.27.0.13" + - "tdnode8:172.27.0.14" + - "tdnode9:172.27.0.15" + - "tdnode10:172.27.0.16" + volumes: + # bind data directory + - type: bind + source: ${DATADIR}/node1/data + target: /var/lib/taos + # bind log directory + - type: bind + source: ${DATADIR}/node1/log + target: /var/log/taos + # bind configuration + - type: bind + source: ${DATADIR}/node1/cfg + target: /etc/taos + # bind core dump path + - type: bind + source: ${DATADIR}/node1/core + target: /coredump + - type: bind + source: ${DATADIR} + target: /root + hostname: tdnode1 + networks: + taos_update_net: + ipv4_address: 172.27.0.7 + command: taosd + + td2.0-node2: + build: + context: . + args: + - PACKAGE=${PACKAGE} + - TARBITRATORPKG=${TARBITRATORPKG} + - EXTRACTDIR=${DIR} + - EXTRACTDIR2=${DIR2} + - DATADIR=${DATADIR} + image: 'tdengine:${VERSION}' + container_name: 'tdnode2' + cap_add: + - ALL + stdin_open: true + tty: true + environment: + TZ: "Asia/Shanghai" + command: > + sh -c "ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && + echo $TZ > /etc/timezone && + mkdir /coredump && + echo 'kernel.core_pattern=/coredump/core_%e_%p' >> /etc/sysctl.conf && + sysctl -p && + exec my-main-application" + extra_hosts: + - "tdnode1:172.27.0.7" + - "tdnode3:172.27.0.9" + - "tdnode4:172.27.0.10" + - "tdnode5:172.27.0.11" + - "tdnode6:172.27.0.12" + - "tdnode7:172.27.0.13" + - "tdnode8:172.27.0.14" + - "tdnode9:172.27.0.15" + - "tdnode10:172.27.0.16" + volumes: + # bind data directory + - type: bind + source: ${DATADIR}/node2/data + target: /var/lib/taos + # bind log directory + - type: bind + source: ${DATADIR}/node2/log + target: /var/log/taos + # bind configuration + - type: bind + source: ${DATADIR}/node2/cfg + target: /etc/taos + # bind core dump path + - type: bind + source: ${DATADIR}/node2/core + target: /coredump + - type: bind + source: ${DATADIR} + target: /root + hostname: tdnode2 + networks: + taos_update_net: + ipv4_address: 172.27.0.8 + command: taosd + + +networks: + taos_update_net: +# external: true + ipam: + driver: default + config: + - subnet: "172.27.0.0/24" diff --git a/tests/pytest/dockerCluster/insert.json b/tests/pytest/dockerCluster/insert.json new file mode 100644 index 0000000000000000000000000000000000000000..60def7be5e28f5167f168735666a08db1e25ccf0 --- /dev/null +++ b/tests/pytest/dockerCluster/insert.json @@ -0,0 +1,53 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 1, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "no", + "replica": 1, + "days": 2, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb", + "child_table_exists":"no", + "childtable_count": 1, + "childtable_prefix": "stb_", + "auto_create_table": "no", + "data_source": "rand", + "insert_mode": "taosc", + "insert_rate": 0, + "insert_rows": 100000, + "interlace_rows": 100, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":10}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/dockerCluster/node3.yml b/tests/pytest/dockerCluster/node3.yml new file mode 100644 index 0000000000000000000000000000000000000000..86e37c2f308cdc240178cd3e660f4e31bef55b6e --- /dev/null +++ b/tests/pytest/dockerCluster/node3.yml @@ -0,0 +1,63 @@ +version: '3.7' + +services: + td2.0-node3: + build: + context: . + args: + - PACKAGE=${PACKAGE} + - TARBITRATORPKG=${TARBITRATORPKG} + - EXTRACTDIR=${DIR} + - EXTRACTDIR2=${DIR2} + - DATADIR=${DATADIR} + image: 'tdengine:${VERSION}' + container_name: 'tdnode3' + cap_add: + - ALL + stdin_open: true + tty: true + environment: + TZ: "Asia/Shanghai" + command: > + sh -c "ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && + echo $TZ > /etc/timezone && + mkdir /coredump && + echo 'kernel.core_pattern=/coredump/core_%e_%p' >> /etc/sysctl.conf && + sysctl -p && + exec my-main-application" + extra_hosts: + - "tdnode1:172.27.0.7" + - "tdnode2:172.27.0.8" + - "tdnode3:172.27.0.9" + - "tdnode4:172.27.0.10" + - "tdnode5:172.27.0.11" + - "tdnode6:172.27.0.12" + - "tdnode7:172.27.0.13" + - "tdnode8:172.27.0.14" + - "tdnode9:172.27.0.15" + - "tdnode10:172.27.0.16" + volumes: + # bind data directory + - type: bind + source: ${DATADIR}/node3/data + target: /var/lib/taos + # bind log directory + - type: bind + source: ${DATADIR}/node3/log + target: /var/log/taos + # bind configuration + - type: bind + source: ${DATADIR}/node3/cfg + target: /etc/taos + # bind core dump path + - type: bind + source: ${DATADIR}/node3/core + target: /coredump + - type: bind + source: ${DATADIR} + target: /root + hostname: tdnode3 + networks: + taos_update_net: + ipv4_address: 172.27.0.9 + command: taosd \ No newline at end of file diff --git a/tests/pytest/dockerCluster/taosdemoWrapper.py b/tests/pytest/dockerCluster/taosdemoWrapper.py new file mode 100644 index 0000000000000000000000000000000000000000..457dd4ee5aa5919951adbcea834d34cd367d3080 --- /dev/null +++ b/tests/pytest/dockerCluster/taosdemoWrapper.py @@ -0,0 +1,142 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import os +import random +import argparse + +class taosdemoWrapper: + + def __init__(self, host, metadata, database, tables, threads, configDir, replica, + columnType, columnsPerTable, rowsPerTable, disorderRatio, disorderRange, charTypeLen): + self.host = host + self.metadata = metadata + self.database = database + self.tables = tables + self.threads = threads + self.configDir = configDir + self.replica = replica + self.columnType = columnType + self.columnsPerTable = columnsPerTable + self.rowsPerTable = rowsPerTable + self.disorderRatio = disorderRatio + self.disorderRange = disorderRange + self.charTypeLen = charTypeLen + + def run(self): + if self.metadata is None: + os.system("taosdemo -h %s -d %s -t %d -T %d -c %s -a %d -b %s -n %d -t %d -O %d -R %d -w %d -x -y" + % (self.host, self.database, self.tables, self.threads, self.configDir, self.replica, self.columnType, + self.rowsPerTable, self.disorderRatio, self.disorderRange, self.charTypeLen)) + else: + os.system("taosdemo -f %s" % self.metadata) + + +parser = argparse.ArgumentParser() +parser.add_argument( + '-H', + '--host-name', + action='store', + default='tdnode1', + type=str, + help='host name to be connected (default: tdnode1)') +parser.add_argument( + '-f', + '--metadata', + action='store', + default=None, + type=str, + help='The meta data to execution procedure, if use -f, all other options invalid, Default is NULL') +parser.add_argument( + '-d', + '--db-name', + action='store', + default='test', + type=str, + help='Database name to be created (default: test)') +parser.add_argument( + '-t', + '--num-of-tables', + action='store', + default=10, + type=int, + help='Number of tables (default: 10000)') +parser.add_argument( + '-T', + '--num-of-threads', + action='store', + default=10, + type=int, + help='Number of rest threads (default: 10)') +parser.add_argument( + '-c', + '--config-dir', + action='store', + default='/etc/taos/', + type=str, + help='Configuration directory. (Default is /etc/taos/)') +parser.add_argument( + '-a', + '--replica', + action='store', + default=100, + type=int, + help='Set the replica parameters of the database (default: 1, min: 1, max: 3)') +parser.add_argument( + '-b', + '--column-type', + action='store', + default='int', + type=str, + help='the data_type of columns (default: TINYINT,SMALLINT,INT,BIGINT,FLOAT,DOUBLE,BINARY,NCHAR,BOOL,TIMESTAMP)') +parser.add_argument( + '-l', + '--num-of-cols', + action='store', + default=10, + type=int, + help='The number of columns per record (default: 10)') +parser.add_argument( + '-n', + '--num-of-rows', + action='store', + default=1000, + type=int, + help='Number of subtales per stable (default: 1000)') +parser.add_argument( + '-O', + '--disorder-ratio', + action='store', + default=0, + type=int, + help=' (0: in order, > 0: disorder ratio, default: 0)') +parser.add_argument( + '-R', + '--disorder-range', + action='store', + default=0, + type=int, + help='Out of order datas range, ms (default: 1000)') +parser.add_argument( + '-w', + '--char-type-length', + action='store', + default=16, + type=int, + help='Out of order datas range, ms (default: 16)') + +args = parser.parse_args() +taosdemo = taosdemoWrapper(args.host_name, args.metadata, args.db_name, args.num_of_tables, + args.num_of_threads, args.config_dir, args.replica, args.column_type, args.num_of_cols, + args.num_of_rows, args.disorder_ratio, args.disorder_range, args.char_type_length) +taosdemo.run() diff --git a/tests/pytest/fulltest.bat b/tests/pytest/fulltest.bat new file mode 100644 index 0000000000000000000000000000000000000000..535aafe2d4692f4dc85756256390502c5fd96efd --- /dev/null +++ b/tests/pytest/fulltest.bat @@ -0,0 +1,21 @@ +python .\test.py -f insert\basic.py +python .\test.py -f insert\int.py +python .\test.py -f insert\float.py +python .\test.py -f insert\bigint.py +python .\test.py -f insert\bool.py +python .\test.py -f insert\double.py +python .\test.py -f insert\smallint.py +python .\test.py -f insert\tinyint.py +python .\test.py -f insert\date.py +python .\test.py -f insert\binary.py +python .\test.py -f insert\nchar.py + +python .\test.py -f query\filter.py +python .\test.py -f query\filterCombo.py +python .\test.py -f query\queryNormal.py +python .\test.py -f query\queryError.py +python .\test.py -f query\filterAllIntTypes.py +python .\test.py -f query\filterFloatAndDouble.py +python .\test.py -f query\filterOtherTypes.py +python .\test.py -f query\querySort.py +python .\test.py -f query\queryJoin.py diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh new file mode 100755 index 0000000000000000000000000000000000000000..abd710eae4ca34a7af3d1e09f1a320326f65981e --- /dev/null +++ b/tests/pytest/fulltest.sh @@ -0,0 +1,421 @@ +#!/bin/bash +ulimit -c unlimited +#======================p1-start=============== + +python3 ./test.py -f insert/basic.py +python3 ./test.py -f insert/int.py +python3 ./test.py -f insert/float.py +python3 ./test.py -f insert/bigint.py +python3 ./test.py -f insert/bool.py +python3 ./test.py -f insert/double.py +python3 ./test.py -f insert/smallint.py +python3 ./test.py -f insert/tinyint.py +python3 ./test.py -f insert/date.py +python3 ./test.py -f insert/binary.py +python3 ./test.py -f insert/nchar.py +#python3 ./test.py -f insert/nchar-boundary.py +python3 ./test.py -f insert/nchar-unicode.py +python3 ./test.py -f insert/multi.py +python3 ./test.py -f insert/randomNullCommit.py +python3 insert/retentionpolicy.py +python3 ./test.py -f insert/alterTableAndInsert.py +python3 ./test.py -f insert/insertIntoTwoTables.py +python3 ./test.py -f insert/before_1970.py +python3 ./test.py -f insert/special_character_show.py +python3 bug2265.py +python3 ./test.py -f insert/bug3654.py +python3 ./test.py -f insert/insertDynamicColBeforeVal.py +python3 ./test.py -f insert/in_function.py +python3 ./test.py -f insert/modify_column.py +python3 ./test.py -f insert/line_insert.py +python3 ./test.py -f insert/specialSql.py +python3 ./test.py -f insert/timestamp.py + +#table +python3 ./test.py -f table/alter_wal0.py +python3 ./test.py -f table/column_name.py +python3 ./test.py -f table/column_num.py +python3 ./test.py -f table/db_table.py +python3 ./test.py -f table/create_sensitive.py +python3 ./test.py -f table/tablename-boundary.py +python3 ./test.py -f table/max_table_length.py +python3 ./test.py -f table/alter_column.py +python3 ./test.py -f table/boundary.py +python3 ./test.py -f table/create.py +python3 ./test.py -f table/del_stable.py +python3 ./test.py -f table/create_db_from_normal_db.py + +#stable +python3 ./test.py -f stable/insert.py +python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertWithJsonStmt.py + +# tag +python3 ./test.py -f tag_lite/filter.py +python3 ./test.py -f tag_lite/create-tags-boundary.py +python3 ./test.py -f tag_lite/3.py +python3 ./test.py -f tag_lite/4.py +python3 ./test.py -f tag_lite/5.py +python3 ./test.py -f tag_lite/6.py +python3 ./test.py -f tag_lite/add.py +python3 ./test.py -f tag_lite/bigint.py +python3 ./test.py -f tag_lite/binary_binary.py +python3 ./test.py -f tag_lite/binary.py +python3 ./test.py -f tag_lite/bool_binary.py +python3 ./test.py -f tag_lite/bool_int.py +python3 ./test.py -f tag_lite/bool.py +python3 ./test.py -f tag_lite/change.py +python3 ./test.py -f tag_lite/column.py +python3 ./test.py -f tag_lite/commit.py +python3 ./test.py -f tag_lite/create.py +python3 ./test.py -f tag_lite/datatype.py +python3 ./test.py -f tag_lite/datatype-without-alter.py +python3 ./test.py -f tag_lite/delete.py +python3 ./test.py -f tag_lite/double.py +python3 ./test.py -f tag_lite/float.py +python3 ./test.py -f tag_lite/int_binary.py +python3 ./test.py -f tag_lite/int_float.py +python3 ./test.py -f tag_lite/int.py +python3 ./test.py -f tag_lite/set.py +python3 ./test.py -f tag_lite/smallint.py +python3 ./test.py -f tag_lite/tinyint.py +python3 ./test.py -f tag_lite/timestamp.py +python3 ./test.py -f tag_lite/TestModifyTag.py + +#python3 ./test.py -f dbmgmt/database-name-boundary.py +python3 test.py -f dbmgmt/nanoSecondCheck.py + +python3 ./test.py -f import_merge/importBlock1HO.py +python3 ./test.py -f import_merge/importBlock1HPO.py +python3 ./test.py -f import_merge/importBlock1H.py +python3 ./test.py -f import_merge/importBlock1S.py +python3 ./test.py -f import_merge/importBlock1Sub.py +python3 ./test.py -f import_merge/importBlock1TO.py +python3 ./test.py -f import_merge/importBlock1TPO.py +python3 ./test.py -f import_merge/importBlock1T.py +python3 ./test.py -f import_merge/importBlock2HO.py +python3 ./test.py -f import_merge/importBlock2HPO.py +python3 ./test.py -f import_merge/importBlock2H.py +python3 ./test.py -f import_merge/importBlock2S.py +python3 ./test.py -f import_merge/importBlock2Sub.py +python3 ./test.py -f import_merge/importBlock2TO.py +python3 ./test.py -f import_merge/importBlock2TPO.py +python3 ./test.py -f import_merge/importBlock2T.py +python3 ./test.py -f import_merge/importBlockbetween.py +python3 ./test.py -f import_merge/importCacheFileHO.py +python3 ./test.py -f import_merge/importCacheFileHPO.py +python3 ./test.py -f import_merge/importCacheFileH.py +python3 ./test.py -f import_merge/importCacheFileS.py +python3 ./test.py -f import_merge/importCacheFileSub.py +python3 ./test.py -f import_merge/importCacheFileTO.py +python3 ./test.py -f import_merge/importCacheFileTPO.py +python3 ./test.py -f import_merge/importCacheFileT.py +python3 ./test.py -f import_merge/importDataH2.py +python3 ./test.py -f import_merge/importDataHO2.py +python3 ./test.py -f import_merge/importDataHO.py +python3 ./test.py -f import_merge/importDataHPO.py +python3 ./test.py -f import_merge/importDataLastHO.py +python3 ./test.py -f import_merge/importDataLastHPO.py +python3 ./test.py -f import_merge/importDataLastH.py +python3 ./test.py -f import_merge/importDataLastS.py +python3 ./test.py -f import_merge/importDataLastSub.py +python3 ./test.py -f import_merge/importDataLastTO.py +python3 ./test.py -f import_merge/importDataLastTPO.py +python3 ./test.py -f import_merge/importDataLastT.py +python3 ./test.py -f import_merge/importDataS.py +python3 ./test.py -f import_merge/importDataSub.py +python3 ./test.py -f import_merge/importDataTO.py +python3 ./test.py -f import_merge/importDataTPO.py +python3 ./test.py -f import_merge/importDataT.py +python3 ./test.py -f import_merge/importHeadOverlap.py +python3 ./test.py -f import_merge/importHeadPartOverlap.py +python3 ./test.py -f import_merge/importHead.py +python3 ./test.py -f import_merge/importHORestart.py +python3 ./test.py -f import_merge/importHPORestart.py +python3 ./test.py -f import_merge/importHRestart.py +python3 ./test.py -f import_merge/importLastHO.py +python3 ./test.py -f import_merge/importLastHPO.py +python3 ./test.py -f import_merge/importLastH.py +python3 ./test.py -f import_merge/importLastS.py +python3 ./test.py -f import_merge/importLastSub.py +python3 ./test.py -f import_merge/importLastTO.py +python3 ./test.py -f import_merge/importLastTPO.py +python3 ./test.py -f import_merge/importLastT.py +python3 ./test.py -f import_merge/importSpan.py +python3 ./test.py -f import_merge/importSRestart.py +python3 ./test.py -f import_merge/importSubRestart.py +python3 ./test.py -f import_merge/importTailOverlap.py +python3 ./test.py -f import_merge/importTailPartOverlap.py +python3 ./test.py -f import_merge/importTail.py +python3 ./test.py -f import_merge/importToCommit.py +python3 ./test.py -f import_merge/importTORestart.py +python3 ./test.py -f import_merge/importTPORestart.py +python3 ./test.py -f import_merge/importTRestart.py +python3 ./test.py -f import_merge/importInsertThenImport.py +python3 ./test.py -f import_merge/importCSV.py +python3 ./test.py -f import_merge/import_update_0.py +python3 ./test.py -f import_merge/import_update_1.py +python3 ./test.py -f import_merge/import_update_2.py +python3 ./test.py -f update/merge_commit_data.py +python3 ./test.py -f update/updateWithClientMerge.py +#======================p1-end=============== +#======================p2-start=============== +# tools +python3 test.py -f tools/taosdumpTest.py +python3 test.py -f tools/taosdumpTest2.py + +python3 test.py -f tools/taosdemoTest.py +python3 test.py -f tools/taosdemoTestWithoutMetric.py +python3 test.py -f tools/taosdemoTestWithJson.py +python3 test.py -f tools/taosdemoTestLimitOffset.py +python3 test.py -f tools/taosdemoTestTblAlt.py +python3 test.py -f tools/taosdemoTestSampleData.py +python3 test.py -f tools/taosdemoTestInterlace.py +python3 test.py -f tools/taosdemoTestQuery.py + +# restful test for python +python3 test.py -f restful/restful_bind_db1.py +python3 test.py -f restful/restful_bind_db2.py + +# nano support +python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoInsert.py +python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoQuery.py +python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanosubscribe.py +python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestInsertTime_step.py +python3 test.py -f tools/taosdumpTestNanoSupport.py + +# update +python3 ./test.py -f update/allow_update.py +python3 ./test.py -f update/allow_update-0.py +python3 ./test.py -f update/append_commit_data.py +python3 ./test.py -f update/append_commit_last-0.py +python3 ./test.py -f update/append_commit_last.py + + +python3 ./test.py -f update/merge_commit_data2.py +python3 ./test.py -f update/merge_commit_data2_update0.py +python3 ./test.py -f update/merge_commit_last-0.py +python3 ./test.py -f update/merge_commit_last.py +python3 ./test.py -f update/update_options.py + +#======================p2-end=============== +#======================p3-start=============== + + +# user +python3 ./test.py -f user/user_create.py +python3 ./test.py -f user/pass_len.py + +# stable +python3 ./test.py -f stable/query_after_reset.py + +# perfbenchmark +python3 ./test.py -f perfbenchmark/bug3433.py +#python3 ./test.py -f perfbenchmark/bug3589.py +python3 ./test.py -f perfbenchmark/taosdemoInsert.py + +#taosdemo +python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertWithJson.py +python3 test.py -f tools/taosdemoAllTest/taosdemoTestQueryWithJson.py + +#query +python3 ./test.py -f query/queryBase.py +python3 ./test.py -f query/filter.py +python3 ./test.py -f query/filterCombo.py +python3 ./test.py -f query/queryNormal.py +python3 ./test.py -f query/queryError.py +python3 ./test.py -f query/filterAllIntTypes.py +python3 ./test.py -f query/filterFloatAndDouble.py +python3 ./test.py -f query/filterOtherTypes.py +python3 ./test.py -f query/querySort.py +python3 ./test.py -f query/queryJoin.py +python3 ./test.py -f query/select_last_crash.py +python3 ./test.py -f query/queryNullValueTest.py +python3 ./test.py -f query/queryInsertValue.py +python3 ./test.py -f query/queryConnection.py +python3 ./test.py -f query/queryCountCSVData.py +python3 ./test.py -f query/natualInterval.py +python3 ./test.py -f query/bug1471.py +#python3 ./test.py -f query/dataLossTest.py +python3 ./test.py -f query/bug1874.py +python3 ./test.py -f query/bug1875.py +python3 ./test.py -f query/bug1876.py +python3 ./test.py -f query/bug2218.py +python3 ./test.py -f query/bug2117.py +python3 ./test.py -f query/bug2118.py +python3 ./test.py -f query/bug2143.py +python3 ./test.py -f query/sliding.py +python3 ./test.py -f query/unionAllTest.py +python3 ./test.py -f query/bug2281.py +python3 ./test.py -f query/udf.py +python3 ./test.py -f query/bug2119.py +python3 ./test.py -f query/isNullTest.py +python3 ./test.py -f query/queryWithTaosdKilled.py +python3 ./test.py -f query/floatCompare.py +python3 ./test.py -f query/query1970YearsAf.py +python3 ./test.py -f query/bug3351.py +python3 ./test.py -f query/bug3375.py +python3 ./test.py -f query/queryJoin10tables.py +python3 ./test.py -f query/queryStddevWithGroupby.py +python3 ./test.py -f query/querySecondtscolumnTowherenow.py +python3 ./test.py -f query/queryFilterTswithDateUnit.py +python3 ./test.py -f query/queryTscomputWithNow.py +python3 ./test.py -f query/queryStableJoin.py +python3 ./test.py -f query/computeErrorinWhere.py +python3 ./test.py -f query/queryTsisNull.py +python3 ./test.py -f query/subqueryFilter.py +python3 ./test.py -f query/nestedQuery/queryInterval.py +python3 ./test.py -f query/queryStateWindow.py +# python3 ./test.py -f query/nestedQuery/queryWithOrderLimit.py +python3 ./test.py -f query/nestquery_last_row.py +python3 ./test.py -f query/nestedQuery/nestedQuery.py +python3 ./test.py -f query/nestedQuery/nestedQuery_datacheck.py +python3 ./test.py -f query/queryCnameDisplay.py +python3 ./test.py -f query/operator_cost.py +python3 test.py -f query/nestedQuery/queryWithSpread.py +python3 ./test.py -f query/bug6586.py +python3 ./test.py -f query/ts_2016.py +# python3 ./test.py -f query/bug5903.py +python3 ./test.py -f query/queryLimit.py +python3 ./test.py -f query/queryPriKey.py + +#stream +python3 ./test.py -f stream/metric_1.py +python3 ./test.py -f stream/metric_n.py +python3 ./test.py -f stream/new.py +python3 ./test.py -f stream/stream1.py +python3 ./test.py -f stream/stream2.py +#python3 ./test.py -f stream/parser.py +python3 ./test.py -f stream/history.py +#python3 ./test.py -f stream/sys.py +python3 ./test.py -f stream/table_1.py +python3 ./test.py -f stream/table_n.py +python3 ./test.py -f stream/showStreamExecTimeisNull.py +python3 ./test.py -f stream/cqSupportBefore1970.py + +#alter table +python3 ./test.py -f alter/alter_table_crash.py +python3 ./test.py -f alter/alterTabAddTagWithNULL.py +python3 ./test.py -f alter/alterTimestampColDataProcess.py + +# client +python3 ./test.py -f client/client.py +python3 ./test.py -f client/version.py +python3 ./test.py -f client/alterDatabase.py +python3 ./test.py -f client/noConnectionErrorTest.py +python3 ./test.py -f client/taoshellCheckCase.py +# python3 test.py -f client/change_time_1_1.py +# python3 test.py -f client/change_time_1_2.py + +# Misc +python3 testCompress.py +python3 testNoCompress.py +python3 testMinTablesPerVnode.py + + +python3 queryCount.py +python3 ./test.py -f query/queryGroupbyWithInterval.py +python3 client/twoClients.py +python3 ./test.py -f query/query.py +python3 test.py -f query/queryInterval.py +python3 test.py -f query/queryFillTest.py + +# subscribe +python3 test.py -f subscribe/singlemeter.py +#python3 test.py -f subscribe/stability.py +python3 test.py -f subscribe/supertable.py + +# topic +python3 ./test.py -f topic/topicQuery.py + +#======================p3-end=============== +#======================p4-start=============== + +python3 ./test.py -f update/merge_commit_data-0.py +# wal +python3 ./test.py -f wal/addOldWalTest.py +python3 ./test.py -f wal/sdbComp.py + +# function +python3 ./test.py -f functions/all_null_value.py +# functions +python3 ./test.py -f functions/function_avg.py -r 1 +python3 ./test.py -f functions/function_bottom.py -r 1 +python3 ./test.py -f functions/function_count.py -r 1 +python3 ./test.py -f functions/function_count_last_stab.py +python3 ./test.py -f functions/function_diff.py -r 1 +python3 ./test.py -f functions/function_first.py -r 1 +python3 ./test.py -f functions/function_last.py -r 1 +python3 ./test.py -f functions/function_last_row.py -r 1 +python3 ./test.py -f functions/function_leastsquares.py -r 1 +python3 ./test.py -f functions/function_max.py -r 1 +python3 ./test.py -f functions/function_min.py -r 1 +python3 ./test.py -f functions/function_operations.py -r 1 +python3 ./test.py -f functions/function_percentile.py -r 1 +python3 ./test.py -f functions/function_spread.py -r 1 +python3 ./test.py -f functions/function_stddev.py -r 1 +python3 ./test.py -f functions/function_sum.py -r 1 +python3 ./test.py -f functions/function_top.py -r 1 +python3 ./test.py -f functions/function_twa.py -r 1 +python3 ./test.py -f functions/function_twa_test2.py +python3 ./test.py -f functions/function_stddev_td2555.py +python3 ./test.py -f functions/showOfflineThresholdIs864000.py +python3 ./test.py -f functions/function_interp.py +python3 ./test.py -f insert/metadataUpdate.py +python3 ./test.py -f query/last_cache.py +python3 ./test.py -f query/last_row_cache.py +python3 ./test.py -f account/account_create.py +python3 ./test.py -f alter/alter_table.py +python3 ./test.py -f query/queryGroupbySort.py +#python3 ./test.py -f functions/queryTestCases.py +python3 ./test.py -f functions/function_stateWindow.py +python3 ./test.py -f functions/function_derivative.py +python3 ./test.py -f functions/function_irate.py + +python3 ./test.py -f insert/unsignedInt.py +python3 ./test.py -f insert/unsignedBigint.py +python3 ./test.py -f insert/unsignedSmallint.py +python3 ./test.py -f insert/unsignedTinyint.py +python3 ./test.py -f insert/insertFromCSV.py +python3 ./test.py -f query/filterAllUnsignedIntTypes.py + +python3 ./test.py -f tag_lite/unsignedInt.py +python3 ./test.py -f tag_lite/unsignedBigint.py +python3 ./test.py -f tag_lite/unsignedSmallint.py +python3 ./test.py -f tag_lite/unsignedTinyint.py + +python3 ./test.py -f functions/function_percentile2.py +python3 ./test.py -f insert/boundary2.py +python3 ./test.py -f insert/insert_locking.py +python3 ./test.py -f alter/alter_debugFlag.py +python3 ./test.py -f query/queryBetweenAnd.py +python3 ./test.py -f tag_lite/alter_tag.py + + +python3 test.py -f tools/taosdemoAllTest/TD-4985/query-limit-offset.py +python3 test.py -f tools/taosdemoAllTest/TD-5213/insert4096columns_not_use_taosdemo.py +python3 test.py -f tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.py +python3 ./test.py -f tag_lite/drop_auto_create.py +python3 test.py -f insert/insert_before_use_db.py +python3 test.py -f alter/alter_keep.py +python3 test.py -f alter/alter_cacheLastRow.py +python3 ./test.py -f query/querySession.py +python3 test.py -f alter/alter_create_exception.py +python3 ./test.py -f insert/flushwhiledrop.py +python3 ./test.py -f insert/schemalessInsert.py +python3 ./test.py -f alter/alterColMultiTimes.py +python3 ./test.py -f query/queryWildcardLength.py +python3 ./test.py -f query/queryTbnameUpperLower.py +python3 ./test.py -f query/queryGroupTbname.py +python3 ./test.py -f insert/verifyMemToDiskCrash.py +python3 ./test.py -f functions/variable_httpDbNameMandatory.py + +#======================p4-end=============== + + + + + + + + + diff --git a/tests/pytest/functions/all_null_value.py b/tests/pytest/functions/all_null_value.py new file mode 100644 index 0000000000000000000000000000000000000000..64791831107de4720ea43f26c250ebfb3da7195d --- /dev/null +++ b/tests/pytest/functions/all_null_value.py @@ -0,0 +1,90 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.prepare() + + tdSql.execute("create table st(ts timestamp, c1 int, c2 int)") + for i in range(self.rowNum): + tdSql.execute("insert into st values(%d, null, null)" % (self.ts + i)) + + tdSql.query("select avg(c1) from st") + tdSql.checkRows(0) + + tdSql.query("select max(c1) from st") + tdSql.checkRows(0) + + tdSql.query("select min(c1) from st") + tdSql.checkRows(0) + + tdSql.query("select bottom(c1, 1) from st") + tdSql.checkRows(0) + + tdSql.query("select top(c1, 1) from st") + tdSql.checkRows(0) + + tdSql.query("select diff(c1) from st") + tdSql.checkRows(0) + + tdSql.query("select first(c1) from st") + tdSql.checkRows(0) + + tdSql.query("select last(c1) from st") + tdSql.checkRows(0) + + tdSql.query("select last_row(c1) from st") + tdSql.checkRows(1) + tdSql.checkData(0, 0, None) + + tdSql.query("select count(c1) from st") + tdSql.checkRows(0) + + tdSql.query("select leastsquares(c1, 1, 1) from st") + tdSql.checkRows(0) + + tdSql.query("select c1 + c2 from st") + tdSql.checkRows(10) + + tdSql.query("select spread(c1) from st") + tdSql.checkRows(0) + + tdSql.query("select stddev(c1) from st") + tdSql.checkRows(0) + + tdSql.query("select sum(c1) from st") + tdSql.checkRows(0) + + tdSql.query("select twa(c1) from st") + tdSql.checkRows(0) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_arithmetic.py b/tests/pytest/functions/function_arithmetic.py new file mode 100644 index 0000000000000000000000000000000000000000..a74ed1a8f7a4151454a8b799844676347badac7c --- /dev/null +++ b/tests/pytest/functions/function_arithmetic.py @@ -0,0 +1,88 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.prepare() + + tdSql.execute('''create table test(ts timestamp, col1 int, col2 int) tags(loc nchar(20))''') + tdSql.execute("create table test1 using test tags('beijing')") + tdSql.execute("create table test2 using test tags('shanghai')") + for i in range(self.rowNum): + tdSql.execute("insert into test1 values(%d, %d, %d)" % (self.ts + i, i + 1, i + 1)) + tdSql.execute("insert into test2 values(%d, %d, %d)" % (self.ts + i, i + 1, i + 1)) + + # arithmetic verifacation + tdSql.query("select 0.1 + 0.1 from test") + tdSql.checkRows(self.rowNum * 2) + for i in range(self.rowNum * 2): + tdSql.checkData(0, 0, 0.20000000) + + tdSql.query("select 4 * avg(col1) from test") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 22) + + tdSql.query("select 4 * sum(col1) from test") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 440) + + tdSql.query("select 4 * avg(col1) * sum(col2) from test") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 2420) + + tdSql.query("select 4 * avg(col1) * sum(col2) from test group by loc") + tdSql.checkRows(2) + tdSql.checkData(0, 0, 1210) + tdSql.checkData(1, 0, 1210) + + tdSql.error("select avg(col1 * 2)from test group by loc") + + # add testcases for TD-10515---> test arithmetic function with blank table + tdSql.execute("create table test3 using test tags('heilongjiang')") + sql_list = [ + "select 0.1 + 0.1 from test3", + "select 0.1 - 0.1 from test3", + "select 0.1 * 0.1 from test3", + "select 0.1 / 0.1 from test3", + "select 4 * avg(col1) from test3", + "select 4 * sum(col1) from test3", + "select 4 * avg(col1) * sum(col2) from test3", + "select max(col1) / 4 from test3", + "select min(col1) - 4 from test3", + "select min(col1) + max(col1) * avg(col1) / sum(col1) + 4 from test3" + ] + for sql in sql_list: + tdSql.query(sql) + tdSql.checkRows(0) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_avg.py b/tests/pytest/functions/function_avg.py new file mode 100644 index 0000000000000000000000000000000000000000..c8a1cca77b1568b760b0208e0fa71583ae2e3645 --- /dev/null +++ b/tests/pytest/functions/function_avg.py @@ -0,0 +1,81 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.prepare() + + intData = [] + floatData = [] + + tdSql.execute('''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''') + tdSql.execute("create table test1 using test tags('beijing')") + for i in range(self.rowNum): + tdSql.execute("insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) + intData.append(i + 1) + floatData.append(i + 0.1) + + # average verifacation + tdSql.error("select avg(ts) from test") + tdSql.error("select avg(ts) from test1") + tdSql.error("select avg(col7) from test") + tdSql.error("select avg(col7) from test1") + tdSql.error("select avg(col8) from test") + tdSql.error("select avg(col8) from test1") + tdSql.error("select avg(col9) from test") + tdSql.error("select avg(col9) from test1") + + tdSql.query("select avg(col1) from test") + tdSql.checkData(0, 0, np.average(intData)) + tdSql.query("select avg(col2) from test") + tdSql.checkData(0, 0, np.average(intData)) + tdSql.query("select avg(col3) from test") + tdSql.checkData(0, 0, np.average(intData)) + tdSql.query("select avg(col4) from test") + tdSql.checkData(0, 0, np.average(intData)) + tdSql.query("select avg(col5) from test") + tdSql.checkData(0, 0, np.average(floatData)) + tdSql.query("select avg(col6) from test") + tdSql.checkData(0, 0, np.average(floatData)) + tdSql.query("select avg(col11) from test") + tdSql.checkData(0, 0, np.average(intData)) + tdSql.query("select avg(col12) from test") + tdSql.checkData(0, 0, np.average(intData)) + tdSql.query("select avg(col13) from test") + tdSql.checkData(0, 0, np.average(intData)) + tdSql.query("select avg(col14) from test") + tdSql.checkData(0, 0, np.average(intData)) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_avg_restart.py b/tests/pytest/functions/function_avg_restart.py new file mode 100644 index 0000000000000000000000000000000000000000..60f3ba7d4e2708053425b4866e072516b5ff961c --- /dev/null +++ b/tests/pytest/functions/function_avg_restart.py @@ -0,0 +1,81 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.execute("use db") + + intData = [] + floatData = [] + + #tdSql.execute('''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + # col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''') + #tdSql.execute("create table test1 using test tags('beijing')") + for i in range(self.rowNum): + #tdSql.execute("insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + # % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) + intData.append(i + 1) + floatData.append(i + 0.1) + + # average verifacation + tdSql.error("select avg(ts) from test") + tdSql.error("select avg(ts) from test1") + tdSql.error("select avg(col7) from test") + tdSql.error("select avg(col7) from test1") + tdSql.error("select avg(col8) from test") + tdSql.error("select avg(col8) from test1") + tdSql.error("select avg(col9) from test") + tdSql.error("select avg(col9) from test1") + + tdSql.query("select avg(col1) from test") + tdSql.checkData(0, 0, np.average(intData)) + tdSql.query("select avg(col2) from test") + tdSql.checkData(0, 0, np.average(intData)) + tdSql.query("select avg(col3) from test") + tdSql.checkData(0, 0, np.average(intData)) + tdSql.query("select avg(col4) from test") + tdSql.checkData(0, 0, np.average(intData)) + tdSql.query("select avg(col5) from test") + tdSql.checkData(0, 0, np.average(floatData)) + tdSql.query("select avg(col6) from test") + tdSql.checkData(0, 0, np.average(floatData)) + tdSql.query("select avg(col11) from test") + tdSql.checkData(0, 0, np.average(intData)) + tdSql.query("select avg(col12) from test") + tdSql.checkData(0, 0, np.average(intData)) + tdSql.query("select avg(col13) from test") + tdSql.checkData(0, 0, np.average(intData)) + tdSql.query("select avg(col14) from test") + tdSql.checkData(0, 0, np.average(intData)) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_bottom.py b/tests/pytest/functions/function_bottom.py new file mode 100644 index 0000000000000000000000000000000000000000..e9e5003f6f96a9d04bb70b3a867c3cba239d8bff --- /dev/null +++ b/tests/pytest/functions/function_bottom.py @@ -0,0 +1,144 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.prepare() + + tdSql.execute('''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''') + tdSql.execute("create table test1 using test tags('beijing')") + for i in range(self.rowNum): + tdSql.execute("insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) + + # bottom verifacation + tdSql.error("select bottom(ts, 10) from test") + tdSql.error("select bottom(col1, 0) from test") + tdSql.error("select bottom(col1, 101) from test") + tdSql.error("select bottom(col2, 0) from test") + tdSql.error("select bottom(col2, 101) from test") + tdSql.error("select bottom(col3, 0) from test") + tdSql.error("select bottom(col3, 101) from test") + tdSql.error("select bottom(col4, 0) from test") + tdSql.error("select bottom(col4, 101) from test") + tdSql.error("select bottom(col5, 0) from test") + tdSql.error("select bottom(col5, 101) from test") + tdSql.error("select bottom(col6, 0) from test") + tdSql.error("select bottom(col6, 101) from test") + tdSql.error("select bottom(col7, 10) from test") + tdSql.error("select bottom(col8, 10) from test") + tdSql.error("select bottom(col9, 10) from test") + + tdSql.query("select bottom(col1, 2) from test") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 2) + + tdSql.query("select bottom(col2, 2) from test") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 2) + + tdSql.query("select bottom(col3, 2) from test") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 2) + + tdSql.query("select bottom(col4, 2) from test") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 2) + + tdSql.query("select bottom(col5, 2) from test") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 0.1) + tdSql.checkData(1, 1, 1.1) + + tdSql.query("select bottom(col6, 2) from test") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 0.1) + tdSql.checkData(1, 1, 1.1) + + tdSql.query("select bottom(col11, 2) from test") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 2) + + tdSql.query("select bottom(col12, 2) from test") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 2) + + tdSql.query("select bottom(col13, 2) from test") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 2) + + tdSql.query("select bottom(col14, 2) from test") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 2) + + tdSql.query("select ts,bottom(col1, 2),ts from test1") + tdSql.checkRows(2) + tdSql.checkData(0, 0, "2018-09-17 09:00:00.000") + tdSql.checkData(0, 1, "2018-09-17 09:00:00.000") + tdSql.checkData(1, 0, "2018-09-17 09:00:00.001") + tdSql.checkData(1, 3, "2018-09-17 09:00:00.001") + + + tdSql.query("select ts,bottom(col1, 2),ts from test group by tbname") + tdSql.checkRows(2) + tdSql.checkData(0, 0, "2018-09-17 09:00:00.000") + tdSql.checkData(0, 1, "2018-09-17 09:00:00.000") + tdSql.checkData(1, 0, "2018-09-17 09:00:00.001") + tdSql.checkData(1, 3, "2018-09-17 09:00:00.001") + + #TD-2457 bottom + interval + order by + tdSql.error('select top(col2,1) from test interval(1y) order by col2;') + + #TD-2563 top + super_table + interval + tdSql.execute("create table meters(ts timestamp, c int) tags (d int)") + tdSql.execute("create table t1 using meters tags (1)") + sql = 'insert into t1 values ' + for i in range(20000): + sql = sql + '(%d, %d)' % (self.ts + i , i % 47) + if i % 2000 == 0: + tdSql.execute(sql) + sql = 'insert into t1 values ' + tdSql.execute(sql) + tdSql.query('select bottom(c,1) from meters interval(10a)') + tdSql.checkData(0,1,0) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_bottom_restart.py b/tests/pytest/functions/function_bottom_restart.py new file mode 100644 index 0000000000000000000000000000000000000000..b4d987975c3660e2ea875a03f3406eaebcafea6d --- /dev/null +++ b/tests/pytest/functions/function_bottom_restart.py @@ -0,0 +1,113 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.execute("use db") + + #tdSql.execute('''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + # col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''') + #tdSql.execute("create table test1 using test tags('beijing')") + #for i in range(self.rowNum): + # tdSql.execute("insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + # % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) + + # bottom verifacation + tdSql.error("select bottom(ts, 10) from test") + tdSql.error("select bottom(col1, 0) from test") + tdSql.error("select bottom(col1, 101) from test") + tdSql.error("select bottom(col2, 0) from test") + tdSql.error("select bottom(col2, 101) from test") + tdSql.error("select bottom(col3, 0) from test") + tdSql.error("select bottom(col3, 101) from test") + tdSql.error("select bottom(col4, 0) from test") + tdSql.error("select bottom(col4, 101) from test") + tdSql.error("select bottom(col5, 0) from test") + tdSql.error("select bottom(col5, 101) from test") + tdSql.error("select bottom(col6, 0) from test") + tdSql.error("select bottom(col6, 101) from test") + tdSql.error("select bottom(col7, 10) from test") + tdSql.error("select bottom(col8, 10) from test") + tdSql.error("select bottom(col9, 10) from test") + + tdSql.query("select bottom(col1, 2) from test") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 2) + + tdSql.query("select bottom(col2, 2) from test") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 2) + + tdSql.query("select bottom(col3, 2) from test") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 2) + + tdSql.query("select bottom(col4, 2) from test") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 2) + + tdSql.query("select bottom(col11, 2) from test") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 2) + + tdSql.query("select bottom(col12, 2) from test") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 2) + + tdSql.query("select bottom(col13, 2) from test") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 2) + + tdSql.query("select bottom(col14, 2) from test") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 2) + + tdSql.query("select bottom(col5, 2) from test") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 0.1) + tdSql.checkData(1, 1, 1.1) + + tdSql.query("select bottom(col6, 2) from test") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 0.1) + tdSql.checkData(1, 1, 1.1) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_count.py b/tests/pytest/functions/function_count.py new file mode 100644 index 0000000000000000000000000000000000000000..a05b2b072090fb03a86015616ea138fb9df9ae75 --- /dev/null +++ b/tests/pytest/functions/function_count.py @@ -0,0 +1,107 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.prepare() + + tdSql.execute('''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''') + tdSql.execute("create table test1 using test tags('beijing')") + for i in range(self.rowNum): + tdSql.execute("insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) + + # Count verifacation + tdSql.query("select count(*) from test") + tdSql.checkData(0, 0, 10) + + tdSql.query("select count(ts) from test") + tdSql.checkData(0, 0, 10) + tdSql.query("select count(col1) from test") + tdSql.checkData(0, 0, 10) + tdSql.query("select count(col2) from test") + tdSql.checkData(0, 0, 10) + tdSql.query("select count(col3) from test") + tdSql.checkData(0, 0, 10) + tdSql.query("select count(col4) from test") + tdSql.checkData(0, 0, 10) + tdSql.query("select count(col5) from test") + tdSql.checkData(0, 0, 10) + tdSql.query("select count(col6) from test") + tdSql.checkData(0, 0, 10) + tdSql.query("select count(col7) from test") + tdSql.checkData(0, 0, 10) + tdSql.query("select count(col8) from test") + tdSql.checkData(0, 0, 10) + tdSql.query("select count(col9) from test") + tdSql.checkData(0, 0, 10) + + tdSql.query("select count(col11) from test") + tdSql.checkData(0, 0, 10) + tdSql.query("select count(col12) from test") + tdSql.checkData(0, 0, 10) + tdSql.query("select count(col13) from test") + tdSql.checkData(0, 0, 10) + tdSql.query("select count(col14) from test") + tdSql.checkData(0, 0, 10) + + tdSql.execute("alter table test add column col10 int") + tdSql.query("select count(col10) from test") + tdSql.checkRows(0) + + #TS-653 forbidden count(tbname) to mix up with agg, proj etc. + tdSql.error("select count(*),count(tbname) from test") + tdSql.error("select col11,count(tbname) from test;") + tdSql.error("select count(tbname),count(*) from test") + tdSql.error("select count(tbname),col11 from test;") + func_list=['avg','count','twa','sum','stddev','leastsquares','min', + 'max','first','last','top','bottom','percentile','apercentile', + 'last_row','diff','spread' + ] + for j in func_list: + if j == 'leastsquares': + pick_func=j+'(col1,1,1)' + elif j == 'top' or j == 'bottom' or j == 'percentile' or j == 'apercentile': + pick_func=j+'(col1,1)' + else: + pick_func=j+'(col)' + tdSql.error("select {0},count(tbname) from test".format(pick_func)) + tdSql.error("select count(tbname),{0} from test".format(pick_func)) + + tdSql.execute("insert into test1 values(now, 1, 2, 3, 4, 1.1, 2.2, false, 'test', 'test' , 1, 1, 1, 1, 1)") + tdSql.query("select count(col10) from test") + tdSql.checkData(0, 0, 1) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_count_last_stab.py b/tests/pytest/functions/function_count_last_stab.py new file mode 100644 index 0000000000000000000000000000000000000000..cd0a9b17c2fd8c98544dca09f6a7008929225ece --- /dev/null +++ b/tests/pytest/functions/function_count_last_stab.py @@ -0,0 +1,70 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.prepare() + + tdSql.execute('''create stable stest(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''') + tdSql.execute("create table test1 using stest tags('beijing')") + tdSql.execute("insert into test1(ts) values(%d)" % (self.ts - 1)) + + + # last verifacation + for i in range(self.rowNum): + tdSql.execute("insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + % (self.ts + i, i + 1, 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) + + tdSql.query("select count(*),last(*) from stest group by col1") + tdSql.checkRows(11) + tdSql.checkData(1, 0, 1) + tdSql.checkData(2, 2, 2) + tdSql.checkData(2, 3, 1) + + tdSql.query("select count(*),last(*) from stest group by col2") + tdSql.checkRows(2) + tdSql.checkData(1, 0, 10) + tdSql.checkData(1, 2, 10) + tdSql.checkData(1, 3, 1) + + tdSql.query("select count(*),last(ts,stest.*) from stest group by col1") + tdSql.checkRows(11) + tdSql.checkData(1, 0, 1) + tdSql.checkData(1, 2, "2018-09-17 09:00:00") + tdSql.checkData(2, 4, 1) + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) + diff --git a/tests/pytest/functions/function_count_restart.py b/tests/pytest/functions/function_count_restart.py new file mode 100644 index 0000000000000000000000000000000000000000..565d85f4c0712b436e2dc24335aa13f60d3c87dd --- /dev/null +++ b/tests/pytest/functions/function_count_restart.py @@ -0,0 +1,88 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.execute("use db") + + #tdSql.execute('''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + # col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''') + #tdSql.execute("create table test1 using test tags('beijing')") + #for i in range(self.rowNum): + # tdSql.execute("insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + # % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) + + # Count verifacation + tdSql.query("select count(*) from test") + tdSql.checkData(0, 0, 11) + + tdSql.query("select count(ts) from test") + tdSql.checkData(0, 0, 11) + tdSql.query("select count(col1) from test") + tdSql.checkData(0, 0, 11) + tdSql.query("select count(col2) from test") + tdSql.checkData(0, 0, 11) + tdSql.query("select count(col3) from test") + tdSql.checkData(0, 0, 11) + tdSql.query("select count(col4) from test") + tdSql.checkData(0, 0, 11) + tdSql.query("select count(col5) from test") + tdSql.checkData(0, 0, 11) + tdSql.query("select count(col6) from test") + tdSql.checkData(0, 0, 11) + tdSql.query("select count(col7) from test") + tdSql.checkData(0, 0, 11) + tdSql.query("select count(col8) from test") + tdSql.checkData(0, 0, 11) + tdSql.query("select count(col9) from test") + tdSql.checkData(0, 0, 11) + + tdSql.query("select count(col11) from test") + tdSql.checkData(0, 0, 11) + tdSql.query("select count(col12) from test") + tdSql.checkData(0, 0, 11) + tdSql.query("select count(col13) from test") + tdSql.checkData(0, 0, 11) + tdSql.query("select count(col14) from test") + tdSql.checkData(0, 0, 11) + + #tdSql.execute("alter table test add column col10 int") + #tdSql.query("select count(col10) from test") + #tdSql.checkRows(0) + + ##tdSql.execute("insert into test1 values(now, 1, 2, 3, 4, 1.1, 2.2, false, 'test', 'test' 1)") + tdSql.query("select count(col10) from test") + tdSql.checkData(0, 0, 1) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_derivative.py b/tests/pytest/functions/function_derivative.py new file mode 100644 index 0000000000000000000000000000000000000000..3b79726ed80c206338392cecb8f3d2adf4588e2a --- /dev/null +++ b/tests/pytest/functions/function_derivative.py @@ -0,0 +1,172 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def insertAndCheckData(self): + types = ["tinyint", "tinyint unsigned", "smallint", "smallint unsigned", "int", "int unsigned", "bigint", "bigint unsigned", "float", "double", "bool", "binary(20)", "nchar(20)"] + + for type in types: + print("============== create table using %s type ================" % type) + tdSql.execute("drop table if exists stb") + tdSql.execute("create table stb(ts timestamp, col %s) tags (id int)" % type) + tdSql.execute("create table tb1 using stb tags(1)") + tdSql.execute("create table tb2 using stb tags(2)") + + if type == "tinyint" or type == "smallint" or type == "int" or type == "bigint": + tdSql.execute("insert into tb1 values(%d, 1)(%d, 11)(%d, 21)" % (self.ts, self.ts + 10000, self.ts + 20000)) + tdSql.execute("insert into tb1 values(%d, -1)(%d, -11)(%d, -21)" % (self.ts + 30000, self.ts + 40000, self.ts + 50000)) + tdSql.execute("insert into tb2 values(%d, 10)(%d, 20)(%d, 30)" % (self.ts + 60000, self.ts + 70000, self.ts + 80000)) + tdSql.execute("insert into tb2 values(%d, -10)(%d, -20)(%d, -30)" % (self.ts + 90000, self.ts + 1000000, self.ts + 1100000)) + + tdSql.execute("insert into tb3 using stb tags(3) values(%d, 10)" % (self.ts + 1200000)) + + tdSql.query("select derivative(col, 1s, 1) from stb group by tbname") + tdSql.checkRows(4) + + tdSql.query("select derivative(col, 10s, 1) from stb group by tbname") + tdSql.checkRows(4) + + tdSql.query("select derivative(col, 10s, 0) from stb group by tbname") + tdSql.checkRows(10) + + tdSql.query("select ts,derivative(col, 10s, 1),ts from stb group by tbname") + tdSql.checkRows(4) + tdSql.checkData(0, 0, "2018-09-17 09:00:10.000") + tdSql.checkData(0, 1, "2018-09-17 09:00:10.000") + tdSql.checkData(0, 3, "2018-09-17 09:00:10.000") + tdSql.checkData(3, 0, "2018-09-17 09:01:20.000") + tdSql.checkData(3, 1, "2018-09-17 09:01:20.000") + tdSql.checkData(3, 3, "2018-09-17 09:01:20.000") + + tdSql.query("select ts,derivative(col, 10s, 1),ts from tb1") + tdSql.checkRows(2) + tdSql.checkData(0, 0, "2018-09-17 09:00:10.000") + tdSql.checkData(0, 1, "2018-09-17 09:00:10.000") + tdSql.checkData(0, 3, "2018-09-17 09:00:10.000") + tdSql.checkData(1, 0, "2018-09-17 09:00:20.000") + tdSql.checkData(1, 1, "2018-09-17 09:00:20.000") + tdSql.checkData(1, 3, "2018-09-17 09:00:20.000") + + tdSql.query("select ts from(select ts,derivative(col, 10s, 0) from stb group by tbname)") + + tdSql.checkData(0, 0, "2018-09-17 09:00:10.000") + + tdSql.error("select derivative(col, 10s, 0) from tb1 group by tbname") + + tdSql.query("select derivative(col, 10s, 1) from tb1") + tdSql.checkRows(2) + + tdSql.query("select derivative(col, 10s, 0) from tb1") + tdSql.checkRows(5) + + tdSql.query("select derivative(col, 10s, 1) from tb2") + tdSql.checkRows(2) + + tdSql.query("select derivative(col, 10s, 0) from tb2") + tdSql.checkRows(5) + + tdSql.query("select derivative(col, 10s, 0) from tb3") + tdSql.checkRows(0) + + elif type == "tinyint unsigned" or type == "smallint unsigned" or type == "int unsigned" or type == "bigint unsigned": + tdSql.execute("insert into tb1 values(%d, 1)(%d, 11)(%d, 21)" % (self.ts, self.ts + 10000, self.ts + 20000)) + tdSql.execute("insert into tb2 values(%d, 10)(%d, 20)(%d, 30)" % (self.ts + 60000, self.ts + 70000, self.ts + 80000)) + + tdSql.error("select derivative(col, 1s, 1) from tb1") + tdSql.error("select derivative(col, 10s, 0) from tb1") + tdSql.error("select derivative(col, 999ms, 0) from tb1") + tdSql.error("select derivative(col, 1s, 1) from tb2") + tdSql.error("select derivative(col, 10s, 0) from tb2") + tdSql.error("select derivative(col, 999ms, 0) from tb2") + + elif type == "float" or type == "double": + tdSql.execute("insert into tb1 values(%d, 1.0)(%d, 11.0)(%d, 21.0)" % (self.ts, self.ts + 10000, self.ts + 20000)) + tdSql.execute("insert into tb2 values(%d, 3.0)(%d, 4.0)(%d, 5.0)" % (self.ts + 60000, self.ts + 70000, self.ts + 80000)) + + tdSql.query("select derivative(col, 10s, 1) from tb1") + tdSql.checkRows(2) + + tdSql.query("select derivative(col, 10s, 0) from tb1") + tdSql.checkRows(2) + + tdSql.query("select derivative(col, 10s, 1) from tb2") + tdSql.checkRows(2) + + tdSql.query("select derivative(col, 10s, 0) from tb2") + tdSql.checkRows(2) + + elif type == "bool": + tdSql.execute("insert into tb1 values(%d, true)(%d, false)(%d, true)" % (self.ts, self.ts + 10000, self.ts + 20000)) + tdSql.execute("insert into tb2 values(%d, false)(%d, true)(%d, true)" % (self.ts + 60000, self.ts + 70000, self.ts + 80000)) + + tdSql.error("select derivative(col, 1s, 1) from tb1") + tdSql.error("select derivative(col, 10s, 0) from tb1") + tdSql.error("select derivative(col, 999ms, 0) from tb1") + tdSql.error("select derivative(col, 1s, 1) from tb2") + tdSql.error("select derivative(col, 10s, 0) from tb2") + tdSql.error("select derivative(col, 999ms, 0) from tb2") + + else: + tdSql.execute("insert into tb1 values(%d, 'test01')(%d, 'test01')(%d, 'test01')" % (self.ts, self.ts + 10000, self.ts + 20000)) + tdSql.execute("insert into tb2 values(%d, 'test01')(%d, 'test01')(%d, 'test01')" % (self.ts + 60000, self.ts + 70000, self.ts + 80000)) + + tdSql.error("select derivative(col, 1s, 1) from tb1") + tdSql.error("select derivative(col, 10s, 0) from tb1") + tdSql.error("select derivative(col, 999ms, 0) from tb1") + tdSql.error("select derivative(col, 1s, 1) from tb2") + tdSql.error("select derivative(col, 10s, 0) from tb2") + tdSql.error("select derivative(col, 999ms, 0) from tb2") + + tdSql.error("select derivative(col, 10s, 1) from stb") + tdSql.error("select derivative(col, 10s, 1) from stb group by col") + tdSql.error("select derivative(col, 10s, 1) from stb group by id") + tdSql.error("select derivative(col, 999ms, 1) from stb group by id") + tdSql.error("select derivative(col, 10s, 2) from stb group by id") + tdSql.error("select derivative(col, -106752999999999922222d, 0) from stb group by tbname"); #overflow error + tdSql.error("select derivative(col, 10y, 0) from stb group by tbname") #TD-10399, DB error: syntax error near '10y, 0) from stb group by tbname;' + tdSql.error("select derivative(col, -106752d, 0) from stb group by tbname") #TD-10398 overflow tips + tdSql.error("select derivative(col, 106751991168d, 0) from stb group by tbname") #TD-10398 overflow tips + + def run(self): + tdSql.prepare() + self.insertAndCheckData() + + tdSql.execute("create table st(ts timestamp, c1 int, c2 int) tags(id int)") + tdSql.execute("insert into dev1(ts, c1) using st tags(1) values(now, 1)") + + tdSql.error("select derivative(c1, 10s, 0) from (select c1 from st)") + tdSql.query("select diff(c1) from (select derivative(c1, 1s, 0) c1 from dev1)") + tdSql.checkRows(0) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_diff.py b/tests/pytest/functions/function_diff.py new file mode 100644 index 0000000000000000000000000000000000000000..cd5894c165c9676ae67fdd315d467c2168f84a90 --- /dev/null +++ b/tests/pytest/functions/function_diff.py @@ -0,0 +1,147 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + self.perfix = 'dev' + self.tables = 10 + + def insertData(self): + print("==============step1") + tdSql.execute( + "create table if not exists st (ts timestamp, col int) tags(dev nchar(50))") + + for i in range(self.tables): + tdSql.execute("create table %s%d using st tags(%d)" % (self.perfix, i, i)) + rows = 15 + i + for j in range(rows): + tdSql.execute("insert into %s%d values(%d, %d)" %(self.perfix, i, self.ts + i * 20 * 10000 + j * 10000, j)) + + def run(self): + tdSql.prepare() + + tdSql.execute('''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''') + tdSql.execute("create table test1 using test tags('beijing')") + tdSql.execute("insert into test1 values(%d, 0, 0, 0, 0, 0.0, 0.0, False, ' ', ' ', 0, 0, 0, 0)" % (self.ts - 1)) + + # diff verifacation + tdSql.query("select diff(col1) from test1") + tdSql.checkRows(0) + + tdSql.query("select diff(col2) from test1") + tdSql.checkRows(0) + + tdSql.query("select diff(col3) from test1") + tdSql.checkRows(0) + + tdSql.query("select diff(col4) from test1") + tdSql.checkRows(0) + + tdSql.query("select diff(col5) from test1") + tdSql.checkRows(0) + + tdSql.query("select diff(col6) from test1") + tdSql.checkRows(0) + + for i in range(self.rowNum): + tdSql.execute("insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) + + tdSql.error("select diff(ts) from test") + tdSql.error("select diff(ts) from test1") + tdSql.error("select diff(col1) from test") + tdSql.error("select diff(col2) from test") + tdSql.error("select diff(col3) from test") + tdSql.error("select diff(col4) from test") + tdSql.error("select diff(col5) from test") + tdSql.error("select diff(col6) from test") + tdSql.error("select diff(col7) from test") + tdSql.error("select diff(col7) from test1") + tdSql.error("select diff(col8) from test") + tdSql.error("select diff(col8) from test1") + tdSql.error("select diff(col9) from test") + tdSql.error("select diff(col9) from test1") + tdSql.error("select diff(col11) from test1") + tdSql.error("select diff(col12) from test1") + tdSql.error("select diff(col13) from test1") + tdSql.error("select diff(col14) from test1") + tdSql.error("select diff(col11) from test") + tdSql.error("select diff(col12) from test") + tdSql.error("select diff(col13) from test") + tdSql.error("select diff(col14) from test") + + tdSql.query("select ts,diff(col1),ts from test1") + tdSql.checkRows(10) + tdSql.checkData(0, 0, "2018-09-17 09:00:00.000") + tdSql.checkData(0, 1, "2018-09-17 09:00:00.000") + tdSql.checkData(0, 3, "2018-09-17 09:00:00.000") + tdSql.checkData(9, 0, "2018-09-17 09:00:00.009") + tdSql.checkData(9, 1, "2018-09-17 09:00:00.009") + tdSql.checkData(9, 3, "2018-09-17 09:00:00.009") + + tdSql.query("select ts,diff(col1),ts from test group by tbname") + tdSql.checkRows(10) + tdSql.checkData(0, 0, "2018-09-17 09:00:00.000") + tdSql.checkData(0, 1, "2018-09-17 09:00:00.000") + tdSql.checkData(0, 3, "2018-09-17 09:00:00.000") + tdSql.checkData(9, 0, "2018-09-17 09:00:00.009") + tdSql.checkData(9, 1, "2018-09-17 09:00:00.009") + tdSql.checkData(9, 3, "2018-09-17 09:00:00.009") + + tdSql.query("select diff(col1) from test1") + tdSql.checkRows(10) + + tdSql.query("select diff(col2) from test1") + tdSql.checkRows(10) + + tdSql.query("select diff(col3) from test1") + tdSql.checkRows(10) + + tdSql.query("select diff(col4) from test1") + tdSql.checkRows(10) + + tdSql.query("select diff(col5) from test1") + tdSql.checkRows(10) + + tdSql.query("select diff(col6) from test1") + tdSql.checkRows(10) + + self.insertData() + + tdSql.query("select diff(col) from st group by tbname") + tdSql.checkRows(185) + + tdSql.error("select diff(col) from st group by dev") + + tdSql.error("select diff(col) from st group by col") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_diff_restart.py b/tests/pytest/functions/function_diff_restart.py new file mode 100644 index 0000000000000000000000000000000000000000..1e00309860d0c6fc1867f067e5124b8077c314c4 --- /dev/null +++ b/tests/pytest/functions/function_diff_restart.py @@ -0,0 +1,112 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.execute("use db") + + #tdSql.execute('''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + # col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''') + #tdSql.execute("create table test1 using test tags('beijing')") + #tdSql.execute("insert into test1 values(%d, 0, 0, 0, 0, 0.0, 0.0, False, ' ', ' ')" % (self.ts - 1)) + + # diff verifacation + #tdSql.query("select diff(col1) from test1") + #tdSql.checkRows(0) + # + #tdSql.query("select diff(col2) from test1") + #tdSql.checkRows(0) + + #tdSql.query("select diff(col3) from test1") + #tdSql.checkRows(0) + + #tdSql.query("select diff(col4) from test1") + #tdSql.checkRows(0) + + #tdSql.query("select diff(col5) from test1") + #tdSql.checkRows(0) + + #tdSql.query("select diff(col6) from test1") + #tdSql.checkRows(0) + + #for i in range(self.rowNum): + # tdSql.execute("insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + # % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) + + tdSql.error("select diff(ts) from test") + tdSql.error("select diff(ts) from test1") + tdSql.error("select diff(col1) from test") + tdSql.error("select diff(col2) from test") + tdSql.error("select diff(col3) from test") + tdSql.error("select diff(col4) from test") + tdSql.error("select diff(col5) from test") + tdSql.error("select diff(col6) from test") + tdSql.error("select diff(col7) from test") + tdSql.error("select diff(col7) from test1") + tdSql.error("select diff(col8) from test") + tdSql.error("select diff(col8) from test1") + tdSql.error("select diff(col9) from test") + tdSql.error("select diff(col11) from test1") + tdSql.error("select diff(col12) from test1") + tdSql.error("select diff(col13) from test1") + tdSql.error("select diff(col14) from test1") + tdSql.error("select diff(col11) from test") + tdSql.error("select diff(col12) from test") + tdSql.error("select diff(col13) from test") + tdSql.error("select diff(col14) from test") + + tdSql.query("select diff(col1) from test1") + tdSql.checkRows(10) + + tdSql.query("select diff(col2) from test1") + tdSql.checkRows(10) + + tdSql.query("select diff(col3) from test1") + tdSql.checkRows(10) + + tdSql.query("select diff(col4) from test1") + tdSql.checkRows(10) + + tdSql.query("select diff(col5) from test1") + tdSql.checkRows(10) + + tdSql.query("select diff(col6) from test1") + tdSql.checkRows(10) + + tdSql.query("select diff(col) from st group by tbname") + tdSql.checkRows(185) + + tdSql.error("select diff(col) from st group by dev") + tdSql.error("select diff(col) from st group by col") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_first.py b/tests/pytest/functions/function_first.py new file mode 100644 index 0000000000000000000000000000000000000000..f1a916b168271e67d0001c5d4444966f8c07a2d1 --- /dev/null +++ b/tests/pytest/functions/function_first.py @@ -0,0 +1,151 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.prepare() + + tdSql.execute('''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''') + tdSql.execute("create table test1 using test tags('beijing')") + tdSql.execute("insert into test1(ts) values(%d)" % (self.ts - 1)) + + # first verifacation + tdSql.query("select first(*) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 1, None) + + tdSql.query("select first(col1) from test1") + tdSql.checkRows(0) + + tdSql.query("select first(col2) from test1") + tdSql.checkRows(0) + + tdSql.query("select first(col3) from test1") + tdSql.checkRows(0) + + tdSql.query("select first(col4) from test1") + tdSql.checkRows(0) + + tdSql.query("select first(col11) from test1") + tdSql.checkRows(0) + + tdSql.query("select first(col12) from test1") + tdSql.checkRows(0) + + tdSql.query("select first(col13) from test1") + tdSql.checkRows(0) + + tdSql.query("select first(col14) from test1") + tdSql.checkRows(0) + + tdSql.query("select first(col5) from test1") + tdSql.checkRows(0) + + tdSql.query("select first(col6) from test1") + tdSql.checkRows(0) + + tdSql.query("select first(col7) from test1") + tdSql.checkRows(0) + + tdSql.query("select first(col8) from test1") + tdSql.checkRows(0) + + tdSql.query("select first(col9) from test1") + tdSql.checkRows(0) + + for i in range(self.rowNum): + tdSql.execute("insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) + + tdSql.query("select first(*) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 1, 1) + + tdSql.query("select first(col1) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query("select first(col2) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query("select first(col3) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query("select first(col4) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query("select first(col11) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query("select first(col12) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query("select first(col13) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query("select first(col14) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query("select first(col5) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0.1) + + tdSql.query("select first(col6) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0.1) + + tdSql.query("select first(col7) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, False) + + tdSql.query("select first(col8) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 'taosdata1') + + tdSql.query("select first(col9) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, '涛思数据1') + + # TD-2607 first,last + where none exist condition + interval + tdSql.query("select first(*),last(*) from test1 where ts < 23 interval(1s)") + tdSql.checkRows(0) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_first_restart.py b/tests/pytest/functions/function_first_restart.py new file mode 100644 index 0000000000000000000000000000000000000000..31904c3cde6e1237472aac5767037e5e53e08a47 --- /dev/null +++ b/tests/pytest/functions/function_first_restart.py @@ -0,0 +1,78 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.execute("use db") + + tdSql.query("select first(*) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 1, 1) + + tdSql.query("select first(col1) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query("select first(col2) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query("select first(col3) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query("select first(col4) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query("select first(col5) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0.1) + + tdSql.query("select first(col6) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0.1) + + tdSql.query("select first(col7) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, False) + + tdSql.query("select first(col8) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 'taosdata1') + + tdSql.query("select first(col9) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, '涛思数据1') + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_interp.py b/tests/pytest/functions/function_interp.py new file mode 100644 index 0000000000000000000000000000000000000000..c7a56d59d9c1d33e32e892cb5c6d8746e926bd30 --- /dev/null +++ b/tests/pytest/functions/function_interp.py @@ -0,0 +1,123 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.dnodes import * +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537100000000 + + def run(self): + tdSql.prepare() + tdSql.execute("create table ap1 (ts timestamp, pav float)") + tdSql.execute("insert into ap1 values ('2021-07-25 02:19:54.119', 2.90799)") + tdSql.execute("insert into ap1 values ('2021-07-25 02:19:54.317', 3.07399)") + tdSql.execute("insert into ap1 values ('2021-07-25 02:19:54.517', 0.58117)") + tdSql.execute("insert into ap1 values ('2021-07-25 02:19:54.717', 0.16150)") + tdSql.execute("insert into ap1 values ('2021-07-25 02:19:54.918', 1.47885)") + tdSql.execute("insert into ap1 values ('2021-07-25 02:19:56.569', 1.76472)") + tdSql.execute("insert into ap1 values ('2021-07-25 02:19:57.381', 2.13722)") + tdSql.execute("insert into ap1 values ('2021-07-25 02:19:57.574', 4.10256)") + tdSql.execute("insert into ap1 values ('2021-07-25 02:19:57.776', 3.55345)") + tdSql.execute("insert into ap1 values ('2021-07-25 02:19:57.976', 1.46624)") + tdSql.execute("insert into ap1 values ('2021-07-25 02:19:58.187', 0.17943)") + tdSql.execute("insert into ap1 values ('2021-07-25 02:19:58.372', 2.04101)") + tdSql.execute("insert into ap1 values ('2021-07-25 02:19:58.573', 3.20924)") + tdSql.execute("insert into ap1 values ('2021-07-25 02:19:58.768', 1.71807)") + tdSql.execute("insert into ap1 values ('2021-07-25 02:19:58.964', 4.60900)") + tdSql.execute("insert into ap1 values ('2021-07-25 02:19:59.155', 4.33907)") + tdSql.execute("insert into ap1 values ('2021-07-25 02:19:59.359', 0.76940)") + tdSql.execute("insert into ap1 values ('2021-07-25 02:19:59.553', 0.06458)") + tdSql.execute("insert into ap1 values ('2021-07-25 02:19:59.742', 4.59857)") + tdSql.execute("insert into ap1 values ('2021-07-25 02:19:59.938', 1.55081)") + + tdSql.query("select interp(pav) from ap1 where ts = '2021-07-25 02:19:54' FILL (PREV)") + tdSql.checkRows(0) + tdSql.query("select interp(pav) from ap1 where ts = '2021-07-25 02:19:54' FILL (NEXT)") + tdSql.checkRows(0) + tdSql.query("select interp(pav) from ap1 where ts = '2021-07-25 02:19:54' FILL (LINEAR)") + tdSql.checkRows(0) + tdSql.query("select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:20:00' every(1000a) FILL (LINEAR)") + tdSql.checkRows(6) + tdSql.query("select interp(pav) from ap1 where ts>= '2021-07-25 02:19:54' and ts<'2021-07-25 02:20:00' every(1000a) FILL (NEXT)") + tdSql.checkRows(6) + tdSql.checkData(0,1,2.90799) + tdSql.query("select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts <= '2021-07-25 02:20:00' every(1000a) FILL (PREV)") + tdSql.checkRows(7) + tdSql.checkData(1,1,1.47885) + tdSql.query("select interp(pav) from ap1 where ts>= '2021-07-25 02:19:54' and ts <= '2021-07-25 02:20:00' every(1000a) FILL (LINEAR)") + tdSql.checkRows(7) + + # check desc order + tdSql.error("select interp(pav) from ap1 where ts = '2021-07-25 02:19:54' FILL (PREV) order by ts desc") + tdSql.query("select interp(pav) from ap1 where ts = '2021-07-25 02:19:54' FILL (NEXT) order by ts desc") + tdSql.checkRows(0) + tdSql.query("select interp(pav) from ap1 where ts = '2021-07-25 02:19:54' FILL (LINEAR) order by ts desc") + tdSql.checkRows(0) + tdSql.query("select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:20:00' every(1000a) FILL (LINEAR) order by ts desc") + tdSql.checkRows(6) + tdSql.query("select interp(pav) from ap1 where ts>= '2021-07-25 02:19:54' and ts<'2021-07-25 02:20:00' every(1000a) FILL (NEXT) order by ts desc") + tdSql.checkRows(6) + tdSql.checkData(0,1,4.60900) + tdSql.error("select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts <= '2021-07-25 02:20:00' every(1000a) FILL (PREV) order by ts desc") + tdSql.query("select interp(pav) from ap1 where ts>= '2021-07-25 02:19:54' and ts <= '2021-07-25 02:20:00' every(1000a) FILL (LINEAR) order by ts desc") + tdSql.checkRows(7) + + # check exception + tdSql.error("select interp(*) from ap1") + tdSql.error("select interp(*) from ap1 FILL(NEXT)") + tdSql.error("select interp(*) from ap1 ts >= '2021-07-25 02:19:54' FILL(NEXT)") + tdSql.error("select interp(*) from ap1 ts <= '2021-07-25 02:19:54' FILL(NEXT)") + tdSql.error("select interp(*) from ap1 where ts >'2021-07-25 02:19:59.938' and ts < now every(1s) fill(next)") + + # test case for https://jira.taosdata.com:18080/browse/TS-241 + tdSql.execute("create database test minrows 10") + tdSql.execute("use test") + tdSql.execute("create table st(ts timestamp, c1 int) tags(id int)") + tdSql.execute("create table t1 using st tags(1)") + + for i in range(10): + for j in range(10): + tdSql.execute("insert into t1 values(%d, %d)" % (self.ts + i * 3600000 + j, j)) + tdSql.query("select interp(c1) from st where ts >= '2018-09-16 20:00:00.000' and ts <= '2018-09-17 06:00:00.000' every(1h) fill(linear)") + if i==0: + tdSql.checkRows(0) + else: + tdSql.checkRows(11) + + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select interp(c1) from st where ts >= '2018-09-16 20:00:00.000' and ts <= '2018-09-17 06:00:00.000' every(1h) fill(linear)") + if i==0: + tdSql.checkRows(0) + else: + tdSql.checkRows(11) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_irate.py b/tests/pytest/functions/function_irate.py new file mode 100644 index 0000000000000000000000000000000000000000..4e876cc270b98e3bb5186e07d30b6cf60c5ee298 --- /dev/null +++ b/tests/pytest/functions/function_irate.py @@ -0,0 +1,261 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 100 + self.ts = 1537146000000 + self.ts1 = 1537146000000000 + self.ts2 = 1597146000000 + + + def run(self): + # db precison ms + tdSql.prepare() + tdSql.execute('''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20), tag1 int)''') + tdSql.execute("create table test1 using test tags('beijing', 10)") + tdSql.execute("create table test2 using test tags('tianjing', 20)") + tdSql.execute("create table test3 using test tags('shanghai', 20)") + tdSql.execute("create table gtest1 (ts timestamp, col1 float)") + tdSql.execute("create table gtest2 (ts timestamp, col1 tinyint)") + tdSql.execute("create table gtest3 (ts timestamp, col1 tinyint)") + tdSql.execute("create table gtest4 (ts timestamp, col1 tinyint)") + tdSql.execute("create table gtest5 (ts timestamp, col1 tinyint)") + tdSql.execute("create table gtest6 (ts timestamp, col1 tinyint)") + tdSql.execute("create table gtest7 (ts timestamp, col1 tinyint)") + tdSql.execute("create table gtest8 (ts timestamp, col1 tinyint)") + + + for i in range(self.rowNum): + tdSql.execute("insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + % (self.ts + i*1000, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) + tdSql.execute("insert into test2 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + % (self.ts2 + i*1000, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) + tdSql.execute("insert into test3 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + % (self.ts2 + i*1000, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) + + tdSql.execute("insert into gtest1 values(1537146000000,0);") + tdSql.execute("insert into gtest1 values(1537146001100,1.2);") + tdSql.execute("insert into gtest2 values(1537146001001,1);") + tdSql.execute("insert into gtest2 values(1537146001101,2);") + tdSql.execute("insert into gtest3 values(1537146001101,2);") + tdSql.execute("insert into gtest4(ts) values(1537146001101);") + tdSql.execute("insert into gtest5 values(1537146001002,4);") + tdSql.execute("insert into gtest5 values(1537146002202,4);") + tdSql.execute("insert into gtest6 values(1537146000000,5);") + tdSql.execute("insert into gtest6 values(1537146001000,2);") + tdSql.execute("insert into gtest7 values(1537146001000,1);") + tdSql.execute("insert into gtest7 values(1537146008000,2);") + tdSql.execute("insert into gtest7 values(1537146009000,6);") + tdSql.execute("insert into gtest7 values(1537146012000,3);") + tdSql.execute("insert into gtest7 values(1537146015000,3);") + tdSql.execute("insert into gtest7 values(1537146017000,1);") + tdSql.execute("insert into gtest7 values(1537146019000,3);") + tdSql.execute("insert into gtest8 values(1537146000002,4);") + tdSql.execute("insert into gtest8 values(1537146002202,4);") + + # irate verifacation --child table'query + tdSql.query("select irate(col1) from test1;") + tdSql.checkData(0, 0, 1) + tdSql.query("select irate(col1) from test1 interval(10s);") + tdSql.checkData(0, 1, 1) + tdSql.query("select irate(col1) from test1;") + tdSql.checkData(0, 0, 1) + tdSql.query("select irate(col2) from test1;") + tdSql.checkData(0, 0, 1) + tdSql.query("select irate(col3) from test1;") + tdSql.checkData(0, 0, 1) + tdSql.query("select irate(col4) from test1;") + tdSql.checkData(0, 0, 1) + tdSql.query("select irate(col5) from test1;") + tdSql.checkData(0, 0, 1) + tdSql.query("select irate(col6) from test1;") + tdSql.checkData(0, 0, 1) + tdSql.query("select irate(col11) from test1;") + tdSql.checkData(0, 0, 1) + tdSql.query("select irate(col12) from test1;") + tdSql.checkData(0, 0, 1) + tdSql.query("select irate(col13) from test1;") + tdSql.checkData(0, 0, 1) + tdSql.query("select irate(col14) from test1;") + tdSql.checkData(0, 0, 1) + tdSql.query("select irate(col2) from test1;") + tdSql.checkData(0, 0, 1) + tdSql.query("select irate(col2) from test1;") + tdSql.checkData(0, 0, 1) + + # irate verifacation --super table'query + tdSql.query("select irate(col1) from test group by tbname,loc,tag1;") + tdSql.checkData(0, 0, 1) + tdSql.checkData(1, 1, "test2") + tdSql.checkData(2, 2, "shanghai") + + # add function testcase of twa: query from super table + tdSql.query("select twa(col1) from test group by tbname,loc,tag1;") + tdSql.checkData(0, 0, 50.5) + tdSql.checkData(1, 1, "test2") + tdSql.checkData(2, 2, "shanghai") + + # error: function of irate and twa has invalid operation + tdSql.error("select irate(col7) from test group by tbname,loc,tag1;") + tdSql.error("select irate(col7) from test group by tbname;") + tdSql.error("select irate(col1) from test group by loc,tbname,tag1;") + # tdSql.error("select irate(col1) from test group by tbname,col7;") + tdSql.error("select irate(col1) from test group by col7,tbname;") + tdSql.error("select twa(col7) from test group by tbname,loc,tag1;") + tdSql.error("select twa(col7) from test group by tbname;") + tdSql.error("select twa(col1) from test group by loc,tbname,tag1;") + # tdSql.error("select twa(col1) from test group by tbname,col7;") + tdSql.error("select twa(col1) from test group by col7,tbname;") + + + # general table'query + tdSql.query("select irate(col1) from gtest1;") + tdSql.checkData(0, 0, 1.2/1.1) + tdSql.query("select irate(col1) from gtest2;") + tdSql.checkData(0, 0, 10) + tdSql.query("select irate(col1) from gtest3;") + tdSql.checkData(0, 0, 0) + tdSql.query("select irate(col1) from gtest4;") + tdSql.checkRows(0) + tdSql.query("select irate(col1) from gtest5;") + tdSql.checkData(0, 0, 0) + tdSql.query("select irate(col1) from gtest6;") + tdSql.checkData(0, 0, 2) + tdSql.query("select irate(col1) from gtest7;") + tdSql.checkData(0, 0, 1) + tdSql.query("select irate(col1) from gtest7 interval(5s) order by ts asc;") + tdSql.checkData(1, 1, 4) + tdSql.checkData(2, 1, 0) + tdSql.checkData(3, 1, 1) + tdSql.query("select irate(col1) from gtest7 interval(5s) order by ts desc ;") + tdSql.checkData(1, 1, 0) + tdSql.checkData(2, 1, 4) + tdSql.checkData(3, 1, 0) + + #error + tdSql.error("select irate(col1) from test") + tdSql.error("select irate(ts) from test1") + tdSql.error("select irate(col7) from test1") + tdSql.error("select irate(col8) from test1") + tdSql.error("select irate(col9) from test1") + tdSql.error("select irate(loc) from test1") + tdSql.error("select irate(tag1) from test1") + + # use db1 precision us + tdSql.execute("create database db1 precision 'us' keep 3650 UPDATE 1") + tdSql.execute("use db1 ") + tdSql.execute('''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''') + tdSql.execute("create table test1 using test tags('beijing')") + tdSql.execute("create table gtest1 (ts timestamp, col1 float)") + tdSql.execute("create table gtest2 (ts timestamp, col1 tinyint)") + tdSql.execute("create table gtest3 (ts timestamp, col1 tinyint)") + tdSql.execute("create table gtest4 (ts timestamp, col1 tinyint)") + tdSql.execute("create table gtest5 (ts timestamp, col1 tinyint)") + tdSql.execute("create table gtest6 (ts timestamp, col1 tinyint)") + tdSql.execute("create table gtest7 (ts timestamp, col1 tinyint)") + tdSql.execute("create table gtest8 (ts timestamp, col1 tinyint)") + tdSql.execute("create table gtest9 (ts timestamp, col1 tinyint)") + + for i in range(self.rowNum): + tdSql.execute("insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + % (self.ts1 + i*1000000, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) + + tdSql.execute("insert into gtest1 values(1537146000000000,0);") + tdSql.execute("insert into gtest1 values(1537146001100000,1.2);") + tdSql.execute("insert into gtest2 values(1537146001001000,1);") + tdSql.execute("insert into gtest2 values(1537146001101000,2);") + tdSql.execute("insert into gtest3 values(1537146001101000,2);") + tdSql.execute("insert into gtest4(ts) values(1537146001101000);") + tdSql.execute("insert into gtest5 values(1537146001002000,4);") + tdSql.execute("insert into gtest5 values(1537146002202000,4);") + tdSql.execute("insert into gtest6 values(1537146000000000,5);") + tdSql.execute("insert into gtest6 values(1537146001000000,2);") + tdSql.execute("insert into gtest7 values(1537146001000000,1);") + tdSql.execute("insert into gtest7 values(1537146008000000,2);") + tdSql.execute("insert into gtest7 values(1537146009000000,6);") + tdSql.execute("insert into gtest7 values(1537146012000000,3);") + tdSql.execute("insert into gtest7 values(1537146015000000,3);") + tdSql.execute("insert into gtest7 values(1537146017000000,1);") + tdSql.execute("insert into gtest7 values(1537146019000000,3);") + tdSql.execute("insert into gtest8 values(1537146000002000,3);") + tdSql.execute("insert into gtest8 values(1537146001003000,4);") + tdSql.execute("insert into gtest9 values(1537146000000000,4);") + tdSql.execute("insert into gtest9 values(1537146000000001,5);") + + + # irate verifacation + tdSql.query("select irate(col1) from test1;") + tdSql.checkData(0, 0, 1) + tdSql.query("select irate(col1) from test1 interval(10s);") + tdSql.checkData(0, 1, 1) + tdSql.query("select irate(col1) from test1;") + tdSql.checkData(0, 0, 1) + tdSql.query("select irate(col1) from gtest1;") + tdSql.checkData(0, 0, 1.2/1.1) + tdSql.query("select irate(col1) from gtest2;") + tdSql.checkData(0, 0, 10) + tdSql.query("select irate(col1) from gtest3;") + tdSql.checkData(0, 0, 0) + tdSql.query("select irate(col1) from gtest4;") + tdSql.checkRows(0) + tdSql.query("select irate(col1) from gtest5;") + tdSql.checkData(0, 0, 0) + tdSql.query("select irate(col1) from gtest6;") + tdSql.checkData(0, 0, 2) + tdSql.query("select irate(col1) from gtest7;") + tdSql.checkData(0, 0, 1) + tdSql.query("select irate(col1) from gtest7 interval(5s) order by ts asc;") + tdSql.checkData(1, 1, 4) + tdSql.checkData(2, 1, 0) + tdSql.checkData(3, 1, 1) + tdSql.query("select irate(col1) from gtest7 interval(5s) order by ts desc ;") + tdSql.checkData(1, 1, 0) + tdSql.checkData(2, 1, 4) + tdSql.checkData(3, 1, 0) + tdSql.query("select irate(col1) from gtest8;") + tdSql.checkData(0, 0, 1/1.001) + tdSql.query("select irate(col1) from gtest9;") + tdSql.checkData(0, 0, 1000000) + + #error + tdSql.error("select irate(col1) from test") + tdSql.error("select irate(ts) from test1") + tdSql.error("select irate(col7) from test1") + tdSql.error("select irate(col8) from test1") + tdSql.error("select irate(col9) from test1") + tdSql.error("select irate(loc) from test1") + tdSql.error("select irate(tag1) from test1") + + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_last.py b/tests/pytest/functions/function_last.py new file mode 100644 index 0000000000000000000000000000000000000000..991ac96a800803440a2e662c163622af95c556e3 --- /dev/null +++ b/tests/pytest/functions/function_last.py @@ -0,0 +1,147 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.prepare() + + tdSql.execute('''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''') + tdSql.execute("create table test1 using test tags('beijing')") + tdSql.execute("insert into test1(ts) values(%d)" % (self.ts - 1)) + + # last verifacation + tdSql.query("select last(*) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 1, None) + + tdSql.query("select last(col1) from test1") + tdSql.checkRows(0) + + tdSql.query("select last(col2) from test1") + tdSql.checkRows(0) + + tdSql.query("select last(col3) from test1") + tdSql.checkRows(0) + + tdSql.query("select last(col4) from test1") + tdSql.checkRows(0) + + tdSql.query("select last(col11) from test1") + tdSql.checkRows(0) + + tdSql.query("select last(col12) from test1") + tdSql.checkRows(0) + + tdSql.query("select last(col13) from test1") + tdSql.checkRows(0) + + tdSql.query("select last(col14) from test1") + tdSql.checkRows(0) + + tdSql.query("select last(col5) from test1") + tdSql.checkRows(0) + + tdSql.query("select last(col6) from test1") + tdSql.checkRows(0) + + tdSql.query("select last(col7) from test1") + tdSql.checkRows(0) + + tdSql.query("select last(col8) from test1") + tdSql.checkRows(0) + + tdSql.query("select last(col9) from test1") + tdSql.checkRows(0) + + for i in range(self.rowNum): + tdSql.execute("insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) + + tdSql.query("select last(*) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 1, 10) + + tdSql.query("select last(col1) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select last(col2) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select last(col3) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select last(col4) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select last(col11) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select last(col12) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select last(col13) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select last(col14) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select last(col5) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 9.1) + + tdSql.query("select last(col6) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 9.1) + + tdSql.query("select last(col7) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, True) + + tdSql.query("select last(col8) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 'taosdata10') + + tdSql.query("select last(col9) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, '涛思数据10') + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_last_restart.py b/tests/pytest/functions/function_last_restart.py new file mode 100644 index 0000000000000000000000000000000000000000..69a588d28de7081da4469e9a407be1b68d07f82a --- /dev/null +++ b/tests/pytest/functions/function_last_restart.py @@ -0,0 +1,78 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.execute("use db") + + tdSql.query("select last(*) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 1, 10) + + tdSql.query("select last(col1) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select last(col2) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select last(col3) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select last(col4) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select last(col5) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 9.1) + + tdSql.query("select last(col6) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 9.1) + + tdSql.query("select last(col7) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, True) + + tdSql.query("select last(col8) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 'taosdata10') + + tdSql.query("select last(col9) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, '涛思数据10') + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_last_row.py b/tests/pytest/functions/function_last_row.py new file mode 100644 index 0000000000000000000000000000000000000000..d075eeeca55c7e6575ab9bd526ddb6177bf61791 --- /dev/null +++ b/tests/pytest/functions/function_last_row.py @@ -0,0 +1,160 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.prepare() + + tdSql.execute('''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''') + tdSql.execute("create table test1 using test tags('beijing')") + tdSql.execute("insert into test1(ts) values(%d)" % (self.ts - 1)) + + # last_row verifacation + tdSql.query("select last_row(*) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 1, None) + + tdSql.query("select last_row(col1) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, None) + + tdSql.query("select last_row(col2) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, None) + + tdSql.query("select last_row(col3) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, None) + + tdSql.query("select last_row(col4) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, None) + + tdSql.query("select last_row(col11) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, None) + + tdSql.query("select last_row(col12) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, None) + + tdSql.query("select last_row(col13) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, None) + + tdSql.query("select last_row(col14) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, None) + + tdSql.query("select last_row(col5) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, None) + + tdSql.query("select last_row(col6) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, None) + + tdSql.query("select last_row(col7) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, None) + + tdSql.query("select last_row(col8) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, None) + + tdSql.query("select last_row(col9) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, None) + + for i in range(self.rowNum): + tdSql.execute("insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) + + tdSql.query("select last_row(*) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 1, 10) + + tdSql.query("select last_row(col1) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select last_row(col2) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select last_row(col3) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select last_row(col4) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select last_row(col11) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select last_row(col12) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select last_row(col13) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select last_row(col14) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select last_row(col5) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 9.1) + + tdSql.query("select last_row(col6) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 9.1) + + tdSql.query("select last_row(col7) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, True) + + tdSql.query("select last_row(col8) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 'taosdata10') + + tdSql.query("select last_row(col9) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, '涛思数据10') + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_last_row_restart.py b/tests/pytest/functions/function_last_row_restart.py new file mode 100644 index 0000000000000000000000000000000000000000..1043a8809d640d5b57f808d83799f1f497776233 --- /dev/null +++ b/tests/pytest/functions/function_last_row_restart.py @@ -0,0 +1,78 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.execute("use db") + + tdSql.query("select last_row(*) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 1, 10) + + tdSql.query("select last_row(col1) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select last_row(col2) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select last_row(col3) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select last_row(col4) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select last_row(col5) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 9.1) + + tdSql.query("select last_row(col6) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 9.1) + + tdSql.query("select last_row(col7) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, True) + + tdSql.query("select last_row(col8) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 'taosdata10') + + tdSql.query("select last_row(col9) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, '涛思数据10') + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_leastsquares.py b/tests/pytest/functions/function_leastsquares.py new file mode 100644 index 0000000000000000000000000000000000000000..3b2a8486d5e6d8bbc2464b8ee391181e10e6a285 --- /dev/null +++ b/tests/pytest/functions/function_leastsquares.py @@ -0,0 +1,91 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.prepare() + + tdSql.execute('''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''') + tdSql.execute("create table test1 using test tags('beijing')") + for i in range(self.rowNum): + tdSql.execute("insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) + + # leastsquares verifacation + tdSql.error("select leastsquares(ts, 1, 1) from test1") + tdSql.error("select leastsquares(col1, 1, 1) from test") + tdSql.error("select leastsquares(col2, 1, 1) from test") + tdSql.error("select leastsquares(col3, 1, 1) from test") + tdSql.error("select leastsquares(col4, 1, 1) from test") + tdSql.error("select leastsquares(col5, 1, 1) from test") + tdSql.error("select leastsquares(col6, 1, 1) from test") + tdSql.error("select leastsquares(col7, 1, 1) from test1") + tdSql.error("select leastsquares(col8, 1, 1) from test1") + tdSql.error("select leastsquares(col9, 1, 1) from test1") + tdSql.error("select leastsquares(col11, 1, 1) from test") + tdSql.error("select leastsquares(col12, 1, 1) from test") + tdSql.error("select leastsquares(col13, 1, 1) from test") + tdSql.error("select leastsquares(col14, 1, 1) from test") + + tdSql.query("select leastsquares(col1, 1, 1) from test1") + tdSql.checkData(0, 0, '{slop:1.000000, intercept:0.000000}') + + tdSql.query("select leastsquares(col2, 1, 1) from test1") + tdSql.checkData(0, 0, '{slop:1.000000, intercept:0.000000}') + + tdSql.query("select leastsquares(col3, 1, 1) from test1") + tdSql.checkData(0, 0, '{slop:1.000000, intercept:0.000000}') + + tdSql.query("select leastsquares(col4, 1, 1) from test1") + tdSql.checkData(0, 0, '{slop:1.000000, intercept:0.000000}') + + tdSql.query("select leastsquares(col11, 1, 1) from test1") + tdSql.checkData(0, 0, '{slop:1.000000, intercept:0.000000}') + + tdSql.query("select leastsquares(col12, 1, 1) from test1") + tdSql.checkData(0, 0, '{slop:1.000000, intercept:0.000000}') + + tdSql.query("select leastsquares(col13, 1, 1) from test1") + tdSql.checkData(0, 0, '{slop:1.000000, intercept:0.000000}') + + tdSql.query("select leastsquares(col14, 1, 1) from test1") + tdSql.checkData(0, 0, '{slop:1.000000, intercept:0.000000}') + + tdSql.query("select leastsquares(col5, 1, 1) from test1") + tdSql.checkData(0, 0, '{slop:1.000000, intercept:-0.900000}') + + tdSql.query("select leastsquares(col6, 1, 1) from test1") + tdSql.checkData(0, 0, '{slop:1.000000, intercept:-0.900000}') + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_leastsquares_restart.py b/tests/pytest/functions/function_leastsquares_restart.py new file mode 100644 index 0000000000000000000000000000000000000000..8c38d5dd95ccd4537af623253b08fb2253e4d140 --- /dev/null +++ b/tests/pytest/functions/function_leastsquares_restart.py @@ -0,0 +1,80 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.execute("use db") + + # leastsquares verifacation + tdSql.error("select leastsquares(ts, 1, 1) from test1") + tdSql.error("select leastsquares(col1, 1, 1) from test") + tdSql.error("select leastsquares(col2, 1, 1) from test") + tdSql.error("select leastsquares(col3, 1, 1) from test") + tdSql.error("select leastsquares(col4, 1, 1) from test") + tdSql.error("select leastsquares(col5, 1, 1) from test") + tdSql.error("select leastsquares(col6, 1, 1) from test") + tdSql.error("select leastsquares(col7, 1, 1) from test1") + tdSql.error("select leastsquares(col8, 1, 1) from test1") + tdSql.error("select leastsquares(col9, 1, 1) from test1") + + tdSql.query("select leastsquares(col1, 1, 1) from test1") + tdSql.checkData(0, 0, '{slop:1.000000, intercept:0.000000}') + + tdSql.query("select leastsquares(col2, 1, 1) from test1") + tdSql.checkData(0, 0, '{slop:1.000000, intercept:0.000000}') + + tdSql.query("select leastsquares(col3, 1, 1) from test1") + tdSql.checkData(0, 0, '{slop:1.000000, intercept:0.000000}') + + tdSql.query("select leastsquares(col4, 1, 1) from test1") + tdSql.checkData(0, 0, '{slop:1.000000, intercept:0.000000}') + + tdSql.query("select leastsquares(col11, 1, 1) from test1") + tdSql.checkData(0, 0, '{slop:1.000000, intercept:0.000000}') + + tdSql.query("select leastsquares(col12, 1, 1) from test1") + tdSql.checkData(0, 0, '{slop:1.000000, intercept:0.000000}') + + tdSql.query("select leastsquares(col13, 1, 1) from test1") + tdSql.checkData(0, 0, '{slop:1.000000, intercept:0.000000}') + + tdSql.query("select leastsquares(col14, 1, 1) from test1") + tdSql.checkData(0, 0, '{slop:1.000000, intercept:0.000000}') + + tdSql.query("select leastsquares(col5, 1, 1) from test1") + tdSql.checkData(0, 0, '{slop:1.000000, intercept:-0.900000}') + + tdSql.query("select leastsquares(col6, 1, 1) from test1") + tdSql.checkData(0, 0, '{slop:1.000000, intercept:-0.900000}') + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_max.py b/tests/pytest/functions/function_max.py new file mode 100644 index 0000000000000000000000000000000000000000..c322b6af26362949f7e8b45a58e4c9cef3d9de19 --- /dev/null +++ b/tests/pytest/functions/function_max.py @@ -0,0 +1,99 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.prepare() + + intData = [] + floatData = [] + + tdSql.execute('''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''') + tdSql.execute("create table test1 using test tags('beijing')") + for i in range(self.rowNum): + tdSql.execute("insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) + intData.append(i + 1) + floatData.append(i + 0.1) + + # max verifacation + tdSql.error("select max(ts) from test") + tdSql.error("select max(ts) from test1") + tdSql.error("select max(col7) from test") + tdSql.error("select max(col7) from test1") + tdSql.error("select max(col8) from test") + tdSql.error("select max(col8) from test1") + tdSql.error("select max(col9) from test") + tdSql.error("select max(col9) from test1") + + tdSql.query("select max(col1) from test1") + tdSql.checkData(0, 0, np.max(intData)) + + tdSql.query("select max(col2) from test1") + tdSql.checkData(0, 0, np.max(intData)) + + tdSql.query("select max(col3) from test1") + tdSql.checkData(0, 0, np.max(intData)) + + tdSql.query("select max(col4) from test1") + tdSql.checkData(0, 0, np.max(intData)) + + tdSql.query("select max(col11) from test1") + tdSql.checkData(0, 0, np.max(intData)) + + tdSql.query("select max(col12) from test1") + tdSql.checkData(0, 0, np.max(intData)) + + tdSql.query("select max(col13) from test1") + tdSql.checkData(0, 0, np.max(intData)) + + tdSql.query("select max(col14) from test1") + tdSql.checkData(0, 0, np.max(intData)) + + tdSql.query("select max(col5) from test1") + tdSql.checkData(0, 0, np.max(floatData)) + + tdSql.query("select max(col6) from test1") + tdSql.checkData(0, 0, np.max(floatData)) + + # test case: https://jira.taosdata.com:18080/browse/TD-2583 + tdSql.execute("create database test days 2") + tdSql.execute("create table car(ts timestamp, speed int)") + tdSql.execute("insert into car values(now, -1)") + tdSql.execute("insert into car values(now-10d, null)") + + tdSql.query("select max(speed) from car") + tdSql.checkData(0, 0, -1) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_max_restart.py b/tests/pytest/functions/function_max_restart.py new file mode 100644 index 0000000000000000000000000000000000000000..a04fcedd8b908b030932d5d182b8cf20c28e2685 --- /dev/null +++ b/tests/pytest/functions/function_max_restart.py @@ -0,0 +1,88 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.execute("use db") + + intData = [] + floatData = [] + + #tdSql.execute('''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + # col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''') + #tdSql.execute("create table test1 using test tags('beijing')") + for i in range(self.rowNum): + intData.append(i + 1) + floatData.append(i + 0.1) + + # max verifacation + tdSql.error("select max(ts) from test") + tdSql.error("select max(ts) from test1") + tdSql.error("select max(col7) from test") + tdSql.error("select max(col7) from test1") + tdSql.error("select max(col8) from test") + tdSql.error("select max(col8) from test1") + tdSql.error("select max(col9) from test") + tdSql.error("select max(col9) from test1") + + tdSql.query("select max(col1) from test1") + tdSql.checkData(0, 0, np.max(intData)) + + tdSql.query("select max(col2) from test1") + tdSql.checkData(0, 0, np.max(intData)) + + tdSql.query("select max(col3) from test1") + tdSql.checkData(0, 0, np.max(intData)) + + tdSql.query("select max(col4) from test1") + tdSql.checkData(0, 0, np.max(intData)) + + tdSql.query("select max(col11) from test1") + tdSql.checkData(0, 0, np.max(intData)) + + tdSql.query("select max(col12) from test1") + tdSql.checkData(0, 0, np.max(intData)) + + tdSql.query("select max(col13) from test1") + tdSql.checkData(0, 0, np.max(intData)) + + tdSql.query("select max(col14) from test1") + tdSql.checkData(0, 0, np.max(intData)) + + tdSql.query("select max(col5) from test1") + tdSql.checkData(0, 0, np.max(floatData)) + + tdSql.query("select max(col6) from test1") + tdSql.checkData(0, 0, np.max(floatData)) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_min.py b/tests/pytest/functions/function_min.py new file mode 100644 index 0000000000000000000000000000000000000000..b4d6d58f7ce01b97dd7f5f569409a0288fb0389b --- /dev/null +++ b/tests/pytest/functions/function_min.py @@ -0,0 +1,99 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.prepare() + + intData = [] + floatData = [] + + tdSql.execute('''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''') + tdSql.execute("create table test1 using test tags('beijing')") + for i in range(self.rowNum): + tdSql.execute("insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) + intData.append(i + 1) + floatData.append(i + 0.1) + + # min verifacation + tdSql.error("select min(ts) from test") + tdSql.error("select min(ts) from test1") + tdSql.error("select min(col7) from test") + tdSql.error("select min(col7) from test1") + tdSql.error("select min(col8) from test") + tdSql.error("select min(col8) from test1") + tdSql.error("select min(col9) from test") + tdSql.error("select min(col9) from test1") + + tdSql.query("select min(col1) from test1") + tdSql.checkData(0, 0, np.min(intData)) + + tdSql.query("select min(col2) from test1") + tdSql.checkData(0, 0, np.min(intData)) + + tdSql.query("select min(col3) from test1") + tdSql.checkData(0, 0, np.min(intData)) + + tdSql.query("select min(col4) from test1") + tdSql.checkData(0, 0, np.min(intData)) + + tdSql.query("select min(col11) from test1") + tdSql.checkData(0, 0, np.min(intData)) + + tdSql.query("select min(col12) from test1") + tdSql.checkData(0, 0, np.min(intData)) + + tdSql.query("select min(col13) from test1") + tdSql.checkData(0, 0, np.min(intData)) + + tdSql.query("select min(col14) from test1") + tdSql.checkData(0, 0, np.min(intData)) + + tdSql.query("select min(col5) from test1") + tdSql.checkData(0, 0, np.min(floatData)) + + tdSql.query("select min(col6) from test1") + tdSql.checkData(0, 0, np.min(floatData)) + + # test case: https://jira.taosdata.com:18080/browse/TD-2583 + tdSql.execute("create database test days 2") + tdSql.execute("create table car(ts timestamp, speed int)") + tdSql.execute("insert into car values(now, 1)") + tdSql.execute("insert into car values(now-10d, null)") + + tdSql.query("select min(speed) from car") + tdSql.checkData(0, 0, 1) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_min_restart.py b/tests/pytest/functions/function_min_restart.py new file mode 100644 index 0000000000000000000000000000000000000000..fc2cb761cae164c8c04992768133d1e00a16fccb --- /dev/null +++ b/tests/pytest/functions/function_min_restart.py @@ -0,0 +1,85 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.execute("use db") + + intData = [] + floatData = [] + + for i in range(self.rowNum): + intData.append(i + 1) + floatData.append(i + 0.1) + + # min verifacation + tdSql.error("select min(ts) from test") + tdSql.error("select min(ts) from test1") + tdSql.error("select min(col7) from test") + tdSql.error("select min(col7) from test1") + tdSql.error("select min(col8) from test") + tdSql.error("select min(col8) from test1") + tdSql.error("select min(col9) from test") + tdSql.error("select min(col9) from test1") + + tdSql.query("select min(col1) from test1") + tdSql.checkData(0, 0, np.min(intData)) + + tdSql.query("select min(col2) from test1") + tdSql.checkData(0, 0, np.min(intData)) + + tdSql.query("select min(col3) from test1") + tdSql.checkData(0, 0, np.min(intData)) + + tdSql.query("select min(col4) from test1") + tdSql.checkData(0, 0, np.min(intData)) + + tdSql.query("select min(col11) from test1") + tdSql.checkData(0, 0, np.min(intData)) + + tdSql.query("select min(col12) from test1") + tdSql.checkData(0, 0, np.min(intData)) + + tdSql.query("select min(col13) from test1") + tdSql.checkData(0, 0, np.min(intData)) + + tdSql.query("select min(col14) from test1") + tdSql.checkData(0, 0, np.min(intData)) + + tdSql.query("select min(col5) from test1") + tdSql.checkData(0, 0, np.min(floatData)) + + tdSql.query("select min(col6) from test1") + tdSql.checkData(0, 0, np.min(floatData)) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_operations.py b/tests/pytest/functions/function_operations.py new file mode 100644 index 0000000000000000000000000000000000000000..3e90d1d3eab8288fb9b6b0bb293250e6cf7ae2a1 --- /dev/null +++ b/tests/pytest/functions/function_operations.py @@ -0,0 +1,110 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +#import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.prepare() + + tdSql.execute('''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''') + tdSql.execute("create table test1 using test tags('beijing')") + for i in range(self.rowNum): + tdSql.execute("insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) + + # min verifacation + tdSql.error("select ts + col1 from test") + tdSql.error("select ts + col1 from test1") + tdSql.error("select col1 + col7 from test") + tdSql.error("select col1 + col7 from test1") + tdSql.error("select col1 + col8 from test") + tdSql.error("select col1 + col8 from test1") + tdSql.error("select col1 + col9 from test") + tdSql.error("select col1 + col9 from test1") + + tdSql.query("select col1 + col2 from test1") + tdSql.checkRows(10) + tdSql.checkData(0, 0, 2.0) + + tdSql.query("select col1 + col2 * col3 + col3 / col4 + col5 + col6 + col11 + col12 + col13 + col14 from test1") + tdSql.checkRows(10) + tdSql.checkData(0, 0, 7.2) + + tdSql.execute("insert into test1(ts, col1) values(%d, 11)" % (self.ts + 11)) + tdSql.query("select col1 + col2 from test1") + tdSql.checkRows(11) + tdSql.checkData(10, 0, None) + + tdSql.query("select col1 + col2 * col3 from test1") + tdSql.checkRows(11) + tdSql.checkData(10, 0, None) + + tdSql.query("select col1 + col2 * col3 + col3 / col4 + col5 + col6 + col11 + col12 + col13 + col14 from test1") + tdSql.checkRows(11) + tdSql.checkData(10, 0, None) + + # test for tarithoperator.c coverage + tdSql.execute("insert into test1 values(1537146000010,1,NULL,9,8,1.2,1.3,0,1,1,5,4,3,2)") + tdSql.execute("insert into test1 values(1537146000011,2,1,NULL,9,1.2,1.3,1,2,2,6,5,4,3)") + tdSql.execute("insert into test1 values(1537146000012,3,2,1,NULL,1.2,1.3,0,3,3,7,6,5,4)") + tdSql.execute("insert into test1 values(1537146000013,4,3,2,1,1.2,1.3,1,4,4,8,7,6,5)") + tdSql.execute("insert into test1 values(1537146000014,5,4,3,2,1.2,1.3,0,5,5,9,8,7,6)") + tdSql.execute("insert into test1 values(1537146000015,6,5,4,3,1.2,1.3,1,6,6,NULL,9,8,7)") + tdSql.execute("insert into test1 values(1537146000016,7,6,5,4,1.2,1.3,0,7,7,1,NULL,9,8)") + tdSql.execute("insert into test1 values(1537146000017,8,7,6,5,1.2,1.3,1,8,8,2,1,NULL,9)") + tdSql.execute("insert into test1 values(1537146000018,9,8,7,6,1.2,1.3,0,9,9,3,2,1,NULL)") + tdSql.execute("insert into test1 values(1537146000019,NULL,9,8,7,1.2,1.3,1,10,10,4,3,2,1)") + + self.ts = self.ts + self.rowNum + 10 + + tdSql.execute("insert into test1 values(%d, 1, 1, 1, 1, 1.1, 1.1, 1, NULL, '涛思数据3', 254, 65534, 4294967294, 18446744073709551614)" % ( self.ts + self.rowNum + 1 )) + tdSql.execute("insert into test1 values(%d, 1, 1, 1, 1, 1.1, 1.1, 1, 'taosdata', NULL, 1, 1, 1, 1)" % ( self.ts + self.rowNum + 2 )) + tdSql.execute("insert into test1 values(%d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)" % ( self.ts + self.rowNum + 3 )) + tdSql.execute("insert into test1 values(%d, 1, 1, 1, 1, NULL, 1.1, 1, NULL, '涛思数据3', 1, 1, 1, 1)" % ( self.ts + self.rowNum + 4 )) + tdSql.execute("insert into test1 values(%d, 1, 1, 1, 1, 1.1, NULL, 1, 'taosdata', NULL, 1, 1, 1, 1)" % ( self.ts + self.rowNum + 5 )) + self.rowNum = self.rowNum + 5 + + col_list = [ 'col1' , 'col2' , 'col3' , 'col4' , 'col5' , 'col6' , 'col7' , 'col8' , 'col9' , 'col11' , 'col12' , 'col13' , 'col14' , '1' , '1.1' , 'NULL' , '18446744073709551614' ] + op_list = [ '+' , '-' , '*' , '/' , '%' ] + err_list = [ 'col7' , 'col8' , 'col9' , 'NULL' ] + order_lsit = [ ' order by ts ', ' order by ts desc ', ' order by ts asc '] + for i in col_list : + for j in col_list : + for k in op_list : + for l in order_lsit : + sql = " select %s %s %s from test1 %s" % ( i , k , j , l ) + if i in err_list or j in err_list: + tdSql.error(sql) + else: + tdSql.query(sql) + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_operations_restart.py b/tests/pytest/functions/function_operations_restart.py new file mode 100644 index 0000000000000000000000000000000000000000..3ba787a4a0f3f8af74f461f4e668078d726a428d --- /dev/null +++ b/tests/pytest/functions/function_operations_restart.py @@ -0,0 +1,70 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.execute("use db") + + # min verifacation + tdSql.error("select ts + col1 from test") + tdSql.error("select ts + col1 from test1") + tdSql.error("select col1 + col7 from test") + tdSql.error("select col1 + col7 from test1") + tdSql.error("select col1 + col8 from test") + tdSql.error("select col1 + col8 from test1") + tdSql.error("select col1 + col9 from test") + tdSql.error("select col1 + col9 from test1") + + tdSql.query("select col1 + col2 from test1") + tdSql.checkRows(25) + tdSql.checkData(0, 0, 2.0) + + tdSql.query("select col1 + col2 * col3 + col3 / col4 + col5 + col6 + col11 + col12 + col13 + col14 from test1") + tdSql.checkRows(25) + tdSql.checkData(0, 0, 7.2) + + #tdSql.execute("insert into test1(ts, col1) values(%d, 11)" % (self.ts + 11)) + tdSql.query("select col1 + col2 from test1") + tdSql.checkRows(25) + tdSql.checkData(10, 0, None) + + tdSql.query("select col1 + col2 * col3 from test1") + tdSql.checkRows(25) + tdSql.checkData(10, 0, None) + + tdSql.query("select col1 + col2 * col3 + col3 / col4 + col5 + col6 + col11 + col12 + col13 + col14 from test1") + tdSql.checkRows(25) + tdSql.checkData(10, 0, None) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_percentile.py b/tests/pytest/functions/function_percentile.py new file mode 100644 index 0000000000000000000000000000000000000000..9b5e209d33d1f8e97c5baf83898dd62746c11dd8 --- /dev/null +++ b/tests/pytest/functions/function_percentile.py @@ -0,0 +1,213 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.prepare() + + intData = [] + floatData = [] + + tdSql.execute('''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned)''') + for i in range(self.rowNum): + tdSql.execute("insert into test values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) + intData.append(i + 1) + floatData.append(i + 0.1) + + # percentile verifacation + tdSql.error("select percentile(ts 20) from test") + tdSql.error("select apercentile(ts 20) from test") + tdSql.error("select percentile(col7 20) from test") + tdSql.error("select apercentile(col7 20) from test") + tdSql.error("select percentile(col8 20) from test") + tdSql.error("select apercentile(col8 20) from test") + tdSql.error("select percentile(col9 20) from test") + tdSql.error("select apercentile(col9 20) from test") + + tdSql.query("select percentile(col1, 0) from test") + tdSql.checkData(0, 0, np.percentile(intData, 0)) + tdSql.query("select apercentile(col1, 0) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col1, 50) from test") + tdSql.checkData(0, 0, np.percentile(intData, 50)) + tdSql.query("select apercentile(col1, 50) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col1, 100) from test") + tdSql.checkData(0, 0, np.percentile(intData, 100)) + tdSql.query("select apercentile(col1, 100) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + + tdSql.query("select percentile(col2, 0) from test") + tdSql.checkData(0, 0, np.percentile(intData, 0)) + tdSql.query("select apercentile(col2, 0) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col2, 50) from test") + tdSql.checkData(0, 0, np.percentile(intData, 50)) + tdSql.query("select apercentile(col2, 50) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col2, 100) from test") + tdSql.checkData(0, 0, np.percentile(intData, 100)) + tdSql.query("select apercentile(col2, 100) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + + tdSql.query("select percentile(col3, 0) from test") + tdSql.checkData(0, 0, np.percentile(intData, 0)) + tdSql.query("select apercentile(col3, 0) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col3, 50) from test") + tdSql.checkData(0, 0, np.percentile(intData, 50)) + tdSql.query("select apercentile(col3, 50) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col3, 100) from test") + tdSql.checkData(0, 0, np.percentile(intData, 100)) + tdSql.query("select apercentile(col3, 100) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + + tdSql.query("select percentile(col4, 0) from test") + tdSql.checkData(0, 0, np.percentile(intData, 0)) + tdSql.query("select apercentile(col4, 0) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col4, 50) from test") + tdSql.checkData(0, 0, np.percentile(intData, 50)) + tdSql.query("select apercentile(col4, 50) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col4, 100) from test") + tdSql.checkData(0, 0, np.percentile(intData, 100)) + tdSql.query("select apercentile(col4, 100) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + + tdSql.query("select percentile(col11, 0) from test") + tdSql.checkData(0, 0, np.percentile(intData, 0)) + tdSql.query("select apercentile(col11, 0) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col11, 50) from test") + tdSql.checkData(0, 0, np.percentile(intData, 50)) + tdSql.query("select apercentile(col11, 50) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col11, 100) from test") + tdSql.checkData(0, 0, np.percentile(intData, 100)) + tdSql.query("select apercentile(col11, 100) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + + tdSql.query("select percentile(col12, 0) from test") + tdSql.checkData(0, 0, np.percentile(intData, 0)) + tdSql.query("select apercentile(col12, 0) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col12, 50) from test") + tdSql.checkData(0, 0, np.percentile(intData, 50)) + tdSql.query("select apercentile(col12, 50) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col12, 100) from test") + tdSql.checkData(0, 0, np.percentile(intData, 100)) + tdSql.query("select apercentile(col12, 100) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + + tdSql.query("select percentile(col13, 0) from test") + tdSql.checkData(0, 0, np.percentile(intData, 0)) + tdSql.query("select apercentile(col13, 0) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col13, 50) from test") + tdSql.checkData(0, 0, np.percentile(intData, 50)) + tdSql.query("select apercentile(col13, 50) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col13, 100) from test") + tdSql.checkData(0, 0, np.percentile(intData, 100)) + tdSql.query("select apercentile(col13, 100) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + + tdSql.query("select percentile(col14, 0) from test") + tdSql.checkData(0, 0, np.percentile(intData, 0)) + tdSql.query("select apercentile(col14, 0) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col14, 50) from test") + tdSql.checkData(0, 0, np.percentile(intData, 50)) + tdSql.query("select apercentile(col14, 50) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col14, 100) from test") + tdSql.checkData(0, 0, np.percentile(intData, 100)) + tdSql.query("select apercentile(col14, 100) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + + tdSql.query("select percentile(col5, 0) from test") + print("query result: %s" % tdSql.getData(0, 0)) + print("array result: %s" % np.percentile(floatData, 0)) + tdSql.query("select apercentile(col5, 0) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col5, 50) from test") + print("query result: %s" % tdSql.getData(0, 0)) + print("array result: %s" % np.percentile(floatData, 50)) + tdSql.query("select apercentile(col5, 50) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col5, 100) from test") + print("query result: %s" % tdSql.getData(0, 0)) + print("array result: %s" % np.percentile(floatData, 100)) + tdSql.query("select apercentile(col5, 100) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + + tdSql.query("select percentile(col6, 0) from test") + tdSql.checkData(0, 0, np.percentile(floatData, 0)) + tdSql.query("select apercentile(col6, 0) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col6, 50) from test") + tdSql.checkData(0, 0, np.percentile(floatData, 50)) + tdSql.query("select apercentile(col6, 50) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col6, 100) from test") + tdSql.checkData(0, 0, np.percentile(floatData, 100)) + tdSql.query("select apercentile(col6, 100) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + + tdSql.execute("create table meters (ts timestamp, voltage int) tags(loc nchar(20))") + tdSql.execute("create table t0 using meters tags('beijing')") + tdSql.execute("create table t1 using meters tags('shanghai')") + for i in range(self.rowNum): + tdSql.execute("insert into t0 values(%d, %d)" % (self.ts + i, i + 1)) + tdSql.execute("insert into t1 values(%d, %d)" % (self.ts + i, i + 1)) + + tdSql.error("select percentile(voltage, 20) from meters") + tdSql.query("select apercentile(voltage, 20) from meters") + print("apercentile result: %s" % tdSql.getData(0, 0)) + + # Test case for: https://jira.taosdata.com:18080/browse/TD-2609 + + # modified for : https://jira.taosdata.com:18080/browse/TD-2627 + tdSql.execute("create table st(ts timestamp, k int)") + tdSql.execute("insert into st values(now, -100)(now+1a,-99)") + tdSql.query("select apercentile(k, 20) from st") + tdSql.checkData(0, 0, -100.00) + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_percentile2.py b/tests/pytest/functions/function_percentile2.py new file mode 100644 index 0000000000000000000000000000000000000000..227a3cbe0307a8a198fed2e981eba2890f1e5664 --- /dev/null +++ b/tests/pytest/functions/function_percentile2.py @@ -0,0 +1,63 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 1000000 + self.ts = 1537146000000 + + def run(self): + tdSql.prepare() + + tdSql.execute("create table test(ts timestamp, col1 int, col2 float, col3 double)") + for i in range(1000): + sql = "insert into test values" + batchSize = int (self.rowNum / 1000) + for j in range (batchSize): + currTime = self.ts + batchSize * i + j + sql += "(%d, 1, 2.37, 3.1415926)" % currTime + tdSql.execute(sql) + + tdSql.query("select percentile(col1, 20) from test") + tdSql.checkData(0, 0, 1) + + tdSql.query("select percentile(col2, 20) from test") + tdSql.checkData(0, 0, 2.3699998) + + tdSql.query("select percentile(col3, 20) from test") + tdSql.checkData(0, 0, 3.1415926) + + tdSql.query("select apercentile(col1, 20) from test") + tdSql.checkData(0, 0, 1) + + tdSql.query("select apercentile(col2, 20) from test") + tdSql.checkData(0, 0, 2.3699998) + + tdSql.query("select apercentile(col3, 20) from test") + tdSql.checkData(0, 0, 3.1415926) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_percentile_restart.py b/tests/pytest/functions/function_percentile_restart.py new file mode 100644 index 0000000000000000000000000000000000000000..5e6898784b55bbffb5e01946fff9dc60e281ebff --- /dev/null +++ b/tests/pytest/functions/function_percentile_restart.py @@ -0,0 +1,188 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.execute("use db") + + intData = [] + floatData = [] + + for i in range(self.rowNum): + intData.append(i + 1) + floatData.append(i + 0.1) + + # percentile verifacation + tdSql.error("select percentile(ts 20) from test") + tdSql.error("select apercentile(ts 20) from test") + tdSql.error("select percentile(col7 20) from test") + tdSql.error("select apercentile(col7 20) from test") + tdSql.error("select percentile(col8 20) from test") + tdSql.error("select apercentile(col8 20) from test") + tdSql.error("select percentile(col9 20) from test") + tdSql.error("select apercentile(col9 20) from test") + + tdSql.query("select percentile(col1, 0) from test") + tdSql.checkData(0, 0, np.percentile(intData, 0)) + tdSql.query("select apercentile(col1, 0) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col1, 50) from test") + tdSql.checkData(0, 0, np.percentile(intData, 50)) + tdSql.query("select apercentile(col1, 50) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col1, 100) from test") + tdSql.checkData(0, 0, np.percentile(intData, 100)) + tdSql.query("select apercentile(col1, 100) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + + tdSql.query("select percentile(col2, 0) from test") + tdSql.checkData(0, 0, np.percentile(intData, 0)) + tdSql.query("select apercentile(col2, 0) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col2, 50) from test") + tdSql.checkData(0, 0, np.percentile(intData, 50)) + tdSql.query("select apercentile(col2, 50) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col2, 100) from test") + tdSql.checkData(0, 0, np.percentile(intData, 100)) + tdSql.query("select apercentile(col2, 100) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + + tdSql.query("select percentile(col3, 0) from test") + tdSql.checkData(0, 0, np.percentile(intData, 0)) + tdSql.query("select apercentile(col3, 0) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col3, 50) from test") + tdSql.checkData(0, 0, np.percentile(intData, 50)) + tdSql.query("select apercentile(col3, 50) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col3, 100) from test") + tdSql.checkData(0, 0, np.percentile(intData, 100)) + tdSql.query("select apercentile(col3, 100) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + + tdSql.query("select percentile(col4, 0) from test") + tdSql.checkData(0, 0, np.percentile(intData, 0)) + tdSql.query("select apercentile(col4, 0) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col4, 50) from test") + tdSql.checkData(0, 0, np.percentile(intData, 50)) + tdSql.query("select apercentile(col4, 50) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col4, 100) from test") + tdSql.checkData(0, 0, np.percentile(intData, 100)) + tdSql.query("select apercentile(col4, 100) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + + tdSql.query("select percentile(col11, 0) from test") + tdSql.checkData(0, 0, np.percentile(intData, 0)) + tdSql.query("select apercentile(col11, 0) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col11, 50) from test") + tdSql.checkData(0, 0, np.percentile(intData, 50)) + tdSql.query("select apercentile(col11, 50) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col11, 100) from test") + tdSql.checkData(0, 0, np.percentile(intData, 100)) + tdSql.query("select apercentile(col11, 100) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + + tdSql.query("select percentile(col12, 0) from test") + tdSql.checkData(0, 0, np.percentile(intData, 0)) + tdSql.query("select apercentile(col12, 0) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col12, 50) from test") + tdSql.checkData(0, 0, np.percentile(intData, 50)) + tdSql.query("select apercentile(col12, 50) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col12, 100) from test") + tdSql.checkData(0, 0, np.percentile(intData, 100)) + tdSql.query("select apercentile(col12, 100) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + + tdSql.query("select percentile(col13, 0) from test") + tdSql.checkData(0, 0, np.percentile(intData, 0)) + tdSql.query("select apercentile(col13, 0) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col13, 50) from test") + tdSql.checkData(0, 0, np.percentile(intData, 50)) + tdSql.query("select apercentile(col13, 50) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col13, 100) from test") + tdSql.checkData(0, 0, np.percentile(intData, 100)) + tdSql.query("select apercentile(col13, 100) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + + tdSql.query("select percentile(col14, 0) from test") + tdSql.checkData(0, 0, np.percentile(intData, 0)) + tdSql.query("select apercentile(col14, 0) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col14, 50) from test") + tdSql.checkData(0, 0, np.percentile(intData, 50)) + tdSql.query("select apercentile(col14, 50) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col14, 100) from test") + tdSql.checkData(0, 0, np.percentile(intData, 100)) + tdSql.query("select apercentile(col14, 100) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + + tdSql.query("select percentile(col5, 0) from test") + print("query result: %s" % tdSql.getData(0, 0)) + print("array result: %s" % np.percentile(floatData, 0)) + tdSql.query("select apercentile(col5, 0) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col5, 50) from test") + print("query result: %s" % tdSql.getData(0, 0)) + print("array result: %s" % np.percentile(floatData, 50)) + tdSql.query("select apercentile(col5, 50) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col5, 100) from test") + print("query result: %s" % tdSql.getData(0, 0)) + print("array result: %s" % np.percentile(floatData, 100)) + tdSql.query("select apercentile(col5, 100) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + + tdSql.query("select percentile(col6, 0) from test") + tdSql.checkData(0, 0, np.percentile(floatData, 0)) + tdSql.query("select apercentile(col6, 0) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col6, 50) from test") + tdSql.checkData(0, 0, np.percentile(floatData, 50)) + tdSql.query("select apercentile(col6, 50) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + tdSql.query("select percentile(col6, 100) from test") + tdSql.checkData(0, 0, np.percentile(floatData, 100)) + tdSql.query("select apercentile(col6, 100) from test") + print("apercentile result: %s" % tdSql.getData(0, 0)) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_spread.py b/tests/pytest/functions/function_spread.py new file mode 100644 index 0000000000000000000000000000000000000000..b40f57b78da0f937e06bd304764c6b660f82488e --- /dev/null +++ b/tests/pytest/functions/function_spread.py @@ -0,0 +1,138 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.prepare() + + tdSql.execute('''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''') + tdSql.execute("create table test1 using test tags('beijing')") + tdSql.execute("insert into test1 values(%d, 0, 0, 0, 0, 0.0, 0.0, False, ' ', ' ', 0, 0, 0, 0)" % (self.ts - 1)) + + # spread verifacation + tdSql.query("select spread(ts) from test1") + tdSql.checkRows(1) + + tdSql.query("select spread(col1) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + tdSql.query("select spread(col2) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + tdSql.query("select spread(col3) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + tdSql.query("select spread(col4) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + tdSql.query("select spread(col11) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + tdSql.query("select spread(col12) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + tdSql.query("select spread(col13) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + tdSql.query("select spread(col14) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + tdSql.query("select spread(col5) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + tdSql.query("select spread(col6) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + for i in range(self.rowNum): + tdSql.execute("insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) + + tdSql.error("select spread(col7) from test") + tdSql.error("select spread(col7) from test1") + tdSql.error("select spread(col8) from test") + tdSql.error("select spread(col8) from test1") + tdSql.error("select spread(col9) from test") + tdSql.error("select spread(col9) from test1") + + tdSql.query("select spread(col1) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select spread(col2) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select spread(col3) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select spread(col4) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select spread(col11) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select spread(col12) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select spread(col13) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select spread(col14) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select spread(col5) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 9.1) + + tdSql.query("select spread(col6) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 9.1) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_spread_restart.py b/tests/pytest/functions/function_spread_restart.py new file mode 100644 index 0000000000000000000000000000000000000000..134d92c9c38c1ae37e9ea1a0a91d0e93957a7e2a --- /dev/null +++ b/tests/pytest/functions/function_spread_restart.py @@ -0,0 +1,86 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.execute("use db") + + tdSql.error("select spread(col7) from test") + tdSql.error("select spread(col7) from test1") + tdSql.error("select spread(col8) from test") + tdSql.error("select spread(col8) from test1") + tdSql.error("select spread(col9) from test") + tdSql.error("select spread(col9) from test1") + + tdSql.query("select spread(col1) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select spread(col2) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select spread(col3) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select spread(col4) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select spread(col11) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select spread(col12) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select spread(col13) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + tdSql.query("select spread(col14) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 10) + + + tdSql.query("select spread(col5) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 9.1) + + tdSql.query("select spread(col6) from test1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 9.1) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_stateWindow.py b/tests/pytest/functions/function_stateWindow.py new file mode 100644 index 0000000000000000000000000000000000000000..8f05b321643516f6701db23965278de17f3ca1e9 --- /dev/null +++ b/tests/pytest/functions/function_stateWindow.py @@ -0,0 +1,109 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +#import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.prepare() + + tdSql.execute('''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''') + tdSql.execute("create table test1 using test tags('beijing')") + col0 = 0 + for i in range(self.rowNum): + tdSql.execute("insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + % (self.ts + i, col0, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) + + # operation not allowed on super table + tdSql.error("select count(*) from test session(ts, 1s)") + # operation not allowde on col pro + tdSql.error("select * from test1 session(ts, 1s)") + # operation not allowed on col except primary ts + tdSql.error("select * from test1 session(col1, 1s)") + + tdSql.query("select count(*) from test1 state_window(col1)") + + tdSql.checkRows(1) + tdSql.checkData(0, 0, self.rowNum) + # append more data + + col0 = col0 + 1 + for i in range(self.rowNum): + tdSql.execute("insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + % (self.ts + i + 10000, col0, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) + + tdSql.query("select count(*) from test1 state_window(col1)") + + tdSql.checkRows(2) + tdSql.checkData(0, 0, self.rowNum) + tdSql.checkData(1, 0, self.rowNum) + + + tdSql.query("select first(col1) from test1 state_window(col1)") + tdSql.checkRows(2) + col0 = col0 - 1 + tdSql.checkData(0, 0, col0) + col0 = col0 + 1 + tdSql.checkData(1, 0, col0) + + tdSql.query("select first(col2) from test1 state_window(col1)") + tdSql.checkRows(2) + tdSql.checkData(0, 0, 1) + tdSql.checkData(1, 0, 1) + + tdSql.query("select count(col1), first(col2) from test1 state_window(col1)") + tdSql.checkRows(2) + tdSql.checkData(0, 0, 10) + tdSql.checkData(0, 1, 1) + + tdSql.checkData(1, 0, 10) + tdSql.checkData(1, 1, 1) + + + #tdSql.query("select count(*) from test1 session(ts, 1m)") + #tdSql.checkRows(1) + #tdSql.checkData(0, 1, 11) + + #tdSql.query("select first(col1) from test1 session(ts, 1s)") + #tdSql.checkRows(2) + #tdSql.checkData(0, 1, 1) + #tdSql.checkData(1, 1, 1) + + #tdSql.query("select first(col1), last(col2) from test1 session(ts, 1s)") + #tdSql.checkRows(2) + #tdSql.checkData(0, 1, 1) + #tdSql.checkData(0, 2, 10) + #tdSql.checkData(1, 1, 1) + #tdSql.checkData(1, 1, 1) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_stddev.py b/tests/pytest/functions/function_stddev.py new file mode 100644 index 0000000000000000000000000000000000000000..b8b0b79739e310eac90833c8ab07289baa008538 --- /dev/null +++ b/tests/pytest/functions/function_stddev.py @@ -0,0 +1,159 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + self.stb_prefix = 's' + self.subtb_prefix = 't' + + def run(self): + tdSql.prepare() + + intData = [] + floatData = [] + + tdSql.execute('''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''') + tdSql.execute("create table test1 using test tags('beijing')") + for i in range(self.rowNum): + tdSql.execute("insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) + intData.append(i + 1) + floatData.append(i + 0.1) + + # stddev verifacation + tdSql.error("select stddev(ts) from test1") + + # stddev support super table now + # tdSql.error("select stddev(col1) from test") + # tdSql.error("select stddev(col2) from test") + # tdSql.error("select stddev(col3) from test") + # tdSql.error("select stddev(col4) from test") + # tdSql.error("select stddev(col5) from test") + # tdSql.error("select stddev(col6) from test") + tdSql.error("select stddev(col7) from test1") + tdSql.error("select stddev(col8) from test1") + tdSql.error("select stddev(col9) from test1") + + tdSql.query("select stddev(col1) from test1") + tdSql.checkData(0, 0, np.std(intData)) + + tdSql.query("select stddev(col2) from test1") + tdSql.checkData(0, 0, np.std(intData)) + + tdSql.query("select stddev(col3) from test1") + tdSql.checkData(0, 0, np.std(intData)) + + tdSql.query("select stddev(col4) from test1") + tdSql.checkData(0, 0, np.std(intData)) + + tdSql.query("select stddev(col11) from test1") + tdSql.checkData(0, 0, np.std(intData)) + + tdSql.query("select stddev(col12) from test1") + tdSql.checkData(0, 0, np.std(intData)) + + tdSql.query("select stddev(col13) from test1") + tdSql.checkData(0, 0, np.std(intData)) + + tdSql.query("select stddev(col14) from test1") + tdSql.checkData(0, 0, np.std(intData)) + + tdSql.query("select stddev(col5) from test1") + tdSql.checkData(0, 0, np.std(floatData)) + + tdSql.query("select stddev(col6) from test1") + tdSql.checkData(0, 0, np.std(floatData)) + + #add for td-3276 + sql="create table s (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool,c8 binary(20),c9 nchar(20),c11 int unsigned,c12 smallint unsigned,c13 tinyint unsigned,c14 bigint unsigned) \ + tags(t1 int, t2 float, t3 bigint, t4 smallint, t5 tinyint, t6 double, t7 bool,t8 binary(20),t9 nchar(20), t10 int unsigned , t11 smallint unsigned , t12 tinyint unsigned , t13 bigint unsigned)" + tdSql.execute(sql) + for j in range(2): + if j % 2 == 0: + sql = "create table %s using %s tags(NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL)" % \ + (self.subtb_prefix+str(j)+'_'+str(j),self.stb_prefix) + else: + sql = "create table %s using %s tags(%d,%d,%d,%d,%d,%d,%d,'%s','%s',%d,%d,%d,%d)" % \ + (self.subtb_prefix+str(j)+'_'+str(j),self.stb_prefix,j,j/2.0,j%41,j%51,j%53,j*1.0,j%2,'taos'+str(j),'涛思'+str(j), j%43, j%23 , j%17 , j%3167) + tdSql.execute(sql) + for i in range(10): + if i % 5 == 0 : + ret = tdSql.execute( + "insert into %s values (%d , NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL)" % + (self.subtb_prefix+str(j)+'_'+str(j), self.ts+i)) + else: + ret = tdSql.execute( + "insert into %s values (%d , %d,%d,%d,%d,%d,%d,%d,'%s','%s',%d,%d,%d,%d)" % + (self.subtb_prefix+str(j)+'_'+str(j), self.ts+i, i%100, i/2.0, i%41, i%51, i%53, i*1.0, i%2,'taos'+str(i),'涛思'+str(i), i%43, i%23 , i%17 , i%3167)) + + for i in range(13): + tdSql.query('select stddev(c4) from s group by t%s' % str(i+1) ) + + #add for td-3223 + for i in range(13): + if i == 1 or i == 5 or i == 6 or i == 7 or i == 9 or i == 8 :continue + tdSql.query('select stddev(c%d),stddev(c%d) from s group by c%d' %( i+1 , i+1 , i+1 ) ) + + #add for TD-3318 + tdSql.execute('create table t1(ts timestamp, k int, b binary(12));') + tdSql.execute("insert into t1 values(now, 1, 'abc');") + tdLog.info("select stddev(k) from t1 where b <> 'abc' interval(1s);") + tdSql.query("select stddev(k) from t1 where b <> 'abc' interval(1s);") + + #add for TD-11459 + tdSql.execute("create table stdtable(ts timestamp, col1 int) tags(loc nchar(64))") + tdSql.execute("create table std1 using stdtable tags('beijing')") + tdSql.execute("create table std2 using stdtable tags('shanghai')") + tdSql.execute("create table std3 using stdtable tags('河南')") + tdSql.execute("insert into std1 values(now + 1s, 1)") + tdSql.execute("insert into std1 values(now + 2s, 2);") + tdSql.execute("insert into std2 values(now + 3s, 1);") + tdSql.execute("insert into std2 values(now + 4s, 2);") + tdSql.execute("insert into std3 values(now + 5s, 4);") + tdSql.execute("insert into std3 values(now + 6s, 8);") + tdSql.query("select stddev(col1) from stdtable group by loc;") + tdSql.checkData(0, 0, 2.0) + tdSql.checkData(1, 0, 0.5) + tdSql.checkData(2, 0, 0.5) + + tdSql.execute("create table stdtableint(ts timestamp, col1 int) tags(num int)") + tdSql.execute("create table stdint1 using stdtableint tags(1)") + tdSql.execute("create table stdint2 using stdtableint tags(2)") + tdSql.execute("insert into stdint1 values(now + 1s, 1)") + tdSql.execute("insert into stdint1 values(now + 2s, 2);") + tdSql.execute("insert into stdint2 values(now + 3s, 1);") + tdSql.execute("insert into stdint2 values(now + 4s, 2);") + tdSql.query("select stddev(col1) from stdtableint group by num") + tdSql.checkData(0, 0, 0.5) + tdSql.checkData(1, 0, 0.5) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_stddev_restart.py b/tests/pytest/functions/function_stddev_restart.py new file mode 100644 index 0000000000000000000000000000000000000000..48f9821d89473b66134b5ece06f1d0c417c24b36 --- /dev/null +++ b/tests/pytest/functions/function_stddev_restart.py @@ -0,0 +1,81 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.execute("use db") + + intData = [] + floatData = [] + + for i in range(self.rowNum): + intData.append(i + 1) + floatData.append(i + 0.1) + + # stddev verifacation + tdSql.error("select stddev(ts) from test1") + tdSql.error("select stddev(col7) from test1") + tdSql.error("select stddev(col8) from test1") + tdSql.error("select stddev(col9) from test1") + + tdSql.query("select stddev(col1) from test1") + tdSql.checkData(0, 0, np.std(intData)) + + tdSql.query("select stddev(col2) from test1") + tdSql.checkData(0, 0, np.std(intData)) + + tdSql.query("select stddev(col3) from test1") + tdSql.checkData(0, 0, np.std(intData)) + + tdSql.query("select stddev(col4) from test1") + tdSql.checkData(0, 0, np.std(intData)) + + tdSql.query("select stddev(col11) from test1") + tdSql.checkData(0, 0, np.std(intData)) + + tdSql.query("select stddev(col12) from test1") + tdSql.checkData(0, 0, np.std(intData)) + + tdSql.query("select stddev(col13) from test1") + tdSql.checkData(0, 0, np.std(intData)) + + tdSql.query("select stddev(col14) from test1") + tdSql.checkData(0, 0, np.std(intData)) + + tdSql.query("select stddev(col5) from test1") + tdSql.checkData(0, 0, np.std(floatData)) + + tdSql.query("select stddev(col6) from test1") + tdSql.checkData(0, 0, np.std(floatData)) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_stddev_td2555.py b/tests/pytest/functions/function_stddev_td2555.py new file mode 100644 index 0000000000000000000000000000000000000000..d7c820c37644397d18cc090afb1ee82efeaecf6c --- /dev/null +++ b/tests/pytest/functions/function_stddev_td2555.py @@ -0,0 +1,105 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 100 + self.ts = 1537146000000 + self.clist1 = [] + self.clist2 = [] + self.clist3 = [] + self.clist4 = [] + self.clist5 = [] + self.clist6 = [] + self.clist11 = [] + self.clist12 = [] + self.clist13 = [] + self.clist14 = [] + + def getData(self): + for i in range(tdSql.queryRows): + for j in range(6): + exec('self.clist{}.append(tdSql.queryResult[i][j+1])'.format(j+1)) + for j in range(11,15): + exec('self.clist{}.append(tdSql.queryResult[i][j-1])'.format(j)) + + def run(self): + tdSql.prepare() + + tdSql.execute('''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(cid int,gbid binary(20),loc nchar(20))''') + tdSql.execute("create table test1 using test tags(1,'beijing','北京')") + tdSql.execute("create table test2 using test tags(2,'shanghai','深圳')") + tdSql.execute("create table test3 using test tags(2,'shenzhen','深圳')") + tdSql.execute("create table test4 using test tags(1,'shanghai','上海')") + for j in range(4): + for i in range(self.rowNum): + tdSql.execute("insert into test%d values(now-%dh, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + % (j+1,i, i + 1, i + 1, i + 1, i + 1, i + i * 0.1, i * 1.5, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) + + # stddev verifacation + tdSql.error("select stddev(ts) from test") + tdSql.error("select stddev(col7) from test") + tdSql.error("select stddev(col8) from test") + tdSql.error("select stddev(col9) from test") + + con_list = [ + ' where cid = 1 and ts >=now - 1d and ts =now - 1d and ts =now - 1d and ts =now - 1d and ts =now - 1d and ts %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + tdSql.query("select twa(col1) from test1 where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + + tdSql.error("select twa(col2) from test where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + tdSql.query("select twa(col2) from test1 where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + + tdSql.error("select twa(col3) from test where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + tdSql.query("select twa(col3) from test1 where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + + tdSql.error("select twa(col4) from test where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + tdSql.query("select twa(col4) from test1 where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + + tdSql.error("select twa(col11) from test where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + tdSql.query("select twa(col11) from test1 where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + + tdSql.error("select twa(col12) from test where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + tdSql.query("select twa(col12) from test1 where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + + tdSql.error("select twa(col13) from test where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + tdSql.query("select twa(col13) from test1 where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + + tdSql.error("select twa(col14) from test where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + tdSql.query("select twa(col14) from test1 where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + + tdSql.error("select twa(col5) from test where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + tdSql.query("select twa(col5) from test1 where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + + tdSql.error("select twa(col6) from test where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + tdSql.query("select twa(col6) from test1 where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_twa_restart.py b/tests/pytest/functions/function_twa_restart.py new file mode 100644 index 0000000000000000000000000000000000000000..a066a5a8f3a4e7f28c577fec0ace725c920d5911 --- /dev/null +++ b/tests/pytest/functions/function_twa_restart.py @@ -0,0 +1,113 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.prepare() + + intData = [] + floatData = [] + + tdSql.execute('''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''') + tdSql.execute("create table test1 using test tags('beijing')") + for i in range(self.rowNum): + tdSql.execute("insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) + intData.append(i + 1) + floatData.append(i + 0.1) + + # twa verifacation + tdSql.error("select twa(ts) from test") + tdSql.error("select twa(ts) from test1") + + tdSql.error("select twa(col1) from test") + + tdSql.error("select twa(col2) from test") + + tdSql.error("select twa(col3) from test") + + tdSql.error("select twa(col4) from test") + + tdSql.error("select twa(col11) from test") + + tdSql.error("select twa(col12) from test") + + tdSql.error("select twa(col13) from test") + + tdSql.error("select twa(col14) from test") + + tdSql.error("select twa(col5) from test") + + tdSql.error("select twa(col6) from test") + + tdSql.error("select twa(col7) from test") + tdSql.error("select twa(col7) from test1") + + tdSql.error("select twa(col8) from test") + tdSql.error("select twa(col8) from test1") + + tdSql.error("select twa(col9) from test") + tdSql.error("select twa(col9) from test1") + + tdSql.error("select twa(col1) from test where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + tdSql.query("select twa(col1) from test1 where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + + tdSql.error("select twa(col2) from test where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + tdSql.query("select twa(col2) from test1 where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + + tdSql.error("select twa(col3) from test where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + tdSql.query("select twa(col3) from test1 where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + + tdSql.error("select twa(col4) from test where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + tdSql.query("select twa(col4) from test1 where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + + tdSql.error("select twa(col11) from test where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + tdSql.query("select twa(col11) from test1 where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + + tdSql.error("select twa(col12) from test where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + tdSql.query("select twa(col12) from test1 where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + + tdSql.error("select twa(col13) from test where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + tdSql.query("select twa(col13) from test1 where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + + tdSql.error("select twa(col14) from test where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + tdSql.query("select twa(col14) from test1 where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + + tdSql.error("select twa(col5) from test where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + tdSql.query("select twa(col5) from test1 where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + + tdSql.error("select twa(col6) from test where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + tdSql.query("select twa(col6) from test1 where ts > %d and ts < %d" % (self.ts, self.ts + self.rowNum)) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/functions/function_twa_test2.py b/tests/pytest/functions/function_twa_test2.py new file mode 100644 index 0000000000000000000000000000000000000000..b20f14357e22d38162b5d69cc3ae643f700f8754 --- /dev/null +++ b/tests/pytest/functions/function_twa_test2.py @@ -0,0 +1,157 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.prepare() + + tdSql.execute("create table t1(ts timestamp, c int)") + for i in range(self.rowNum): + tdSql.execute("insert into t1 values(%d, %d)" % (self.ts + i * 10000, i + 1)) + + # twa verifacation + tdSql.query("select twa(c) from t1 where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-09-17 09:01:30.000' ") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 5.5) + + tdSql.query("select twa(c) from t1") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 5.5) + + tdSql.query("select twa(c) from t1 where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-09-17 09:01:30.000' interval(10s)") + tdSql.checkRows(10) + tdSql.checkData(0, 1, 1.49995) + tdSql.checkData(1, 1, 2.49995) + tdSql.checkData(2, 1, 3.49995) + tdSql.checkData(3, 1, 4.49995) + tdSql.checkData(4, 1, 5.49995) + tdSql.checkData(5, 1, 6.49995) + tdSql.checkData(6, 1, 7.49995) + tdSql.checkData(7, 1, 8.49995) + tdSql.checkData(8, 1, 9.49995) + tdSql.checkData(9, 1, 10) + + tdSql.query("select twa(c) from t1 where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-09-17 09:01:30.000' interval(10s) sliding(5s)") + tdSql.checkRows(20) + tdSql.checkData(0, 1, 1.24995) + tdSql.checkData(1, 1, 1.49995) + tdSql.checkData(2, 1, 1.99995) + tdSql.checkData(3, 1, 2.49995) + tdSql.checkData(4, 1, 2.99995) + tdSql.checkData(5, 1, 3.49995) + tdSql.checkData(6, 1, 3.99995) + tdSql.checkData(7, 1, 4.49995) + tdSql.checkData(8, 1, 4.99995) + tdSql.checkData(9, 1, 5.49995) + tdSql.checkData(10, 1, 5.99995) + tdSql.checkData(11, 1, 6.49995) + tdSql.checkData(12, 1, 6.99995) + tdSql.checkData(13, 1, 7.49995) + tdSql.checkData(14, 1, 7.99995) + tdSql.checkData(15, 1, 8.49995) + tdSql.checkData(16, 1, 8.99995) + tdSql.checkData(17, 1, 9.49995) + tdSql.checkData(18, 1, 9.75000) + tdSql.checkData(19, 1, 10) + + tdSql.execute("create table t2(ts timestamp, c int)") + tdSql.execute("insert into t2 values(%d, 1)" % (self.ts + 3000)) + tdSql.query("select twa(c) from t2 where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-09-17 09:01:30.000' ") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query("select twa(c) from t2 where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-09-17 09:01:30.000' interval(2s) ") + tdSql.checkRows(1) + tdSql.checkData(0, 1, 1) + + tdSql.query("select twa(c) from t2 where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-09-17 09:01:30.000' interval(2s) sliding(1s) ") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 1) + + tdSql.query("select twa(c) from t2 where ts >= '2018-09-17 09:00:04.000' and ts <= '2018-09-17 09:01:30.000' ") + tdSql.checkRows(0) + + tdSql.query("select twa(c) from t2 where ts >= '2018-09-17 08:00:00.000' and ts <= '2018-09-17 09:00:00.000' ") + tdSql.checkRows(0) + + tdSql.execute("create table t3(ts timestamp, c int)") + tdSql.execute("insert into t3 values(%d, 1)" % (self.ts)) + tdSql.execute("insert into t3 values(%d, -2)" % (self.ts + 3000)) + + tdSql.query("select twa(c) from t3 where ts >= '2018-09-17 08:59:00.000' and ts <= '2018-09-17 09:01:30.000'") + tdSql.checkRows(1) + tdSql.checkData(0, 0, -0.5) + + tdSql.query("select twa(c) from t3 where ts >= '2018-09-17 08:59:00.000' and ts <= '2018-09-17 09:01:30.000' interval(1s)") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 0.5005) + tdSql.checkData(1, 1, -2) + + tdSql.query("select twa(c) from t3 where ts >= '2018-09-17 08:59:00.000' and ts <= '2018-09-17 09:01:30.000' interval(2s) sliding(1s)") + tdSql.checkRows(4) + tdSql.checkData(0, 1, 0.5005) + tdSql.checkData(1, 1, 0.0005) + tdSql.checkData(2, 1, -1.5) + tdSql.checkData(3, 1, -2) + + #TD-2533 twa+interval with large records + tdSql.execute("create table t4(ts timestamp, c int)") + sql = 'insert into t4 values ' + for i in range(20000): + sql = sql + '(%d, %d)' % (self.ts + i * 500, i + 1) + if i % 2000 == 0: + tdSql.execute(sql) + sql = 'insert into t4 values ' + tdSql.execute(sql) + tdSql.query('select twa(c) from t4 interval(10s)') + tdSql.checkData(0,1,10.999) + + # Test case: https://jira.taosdata.com:18080/browse/TD-2624 + tdSql.execute("create database test keep 7300") + tdSql.execute("use test") + tdSql.execute("create table st(ts timestamp, k int)") + tdSql.execute("insert into st values('2011-01-02 18:42:45.326', -1)") + tdSql.execute("insert into st values('2020-07-30 17:44:06.283', 0)") + tdSql.execute("insert into st values('2020-07-30 17:44:19.578', 9999999)") + tdSql.execute("insert into st values('2020-07-30 17:46:06.417', NULL)") + tdSql.execute("insert into st values('2020-11-09 18:42:25.538', 0)") + tdSql.execute("insert into st values('2020-12-29 17:43:11.641', 0)") + tdSql.execute("insert into st values('2020-12-29 18:43:17.129', 0)") + tdSql.execute("insert into st values('2020-12-29 18:46:19.109', NULL)") + tdSql.execute("insert into st values('2021-01-03 18:40:40.065', 0)") + + tdSql.query("select twa(k),first(ts) as taos1 from st where k <50 interval(17s)") + tdSql.checkRows(6) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/queryTestCases.py b/tests/pytest/functions/queryTestCases.py new file mode 100644 index 0000000000000000000000000000000000000000..8bdbee09e7f715384f048028e7cccd0010e5642b --- /dev/null +++ b/tests/pytest/functions/queryTestCases.py @@ -0,0 +1,1596 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import subprocess +import random +import math +import numpy as np +import inspect + +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug(f"start to execute {__file__}") + tdSql.init(conn.cursor(), logSql) + + def getBuildPath(self) -> str: + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/debug/build/bin")] + break + return buildPath + + def getCfgDir(self) -> str: + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + cfgDir = self.getBuildPath() + "/community/sim/dnode1/cfg" + else: + cfgDir = self.getBuildPath() + "/sim/dnode1/cfg" + return cfgDir + + def getCfgFile(self) -> str: + return self.getCfgDir()+"/taos.cfg" + + def td3690(self): + tdLog.printNoPrefix("==========TD-3690==========") + + tdSql.prepare() + + tdSql.execute("show variables") + res_off = tdSql.cursor.fetchall() + resList = np.array(res_off) + index = np.where(resList == "offlineThreshold") + index_value = np.dstack((index[0])).squeeze() + tdSql.query("show variables") + tdSql.checkData(index_value, 1, 864000) + + def td4082(self): + tdLog.printNoPrefix("==========TD-4082==========") + tdSql.prepare() + + cfgfile = self.getCfgFile() + max_compressMsgSize = 100000000 + + tdSql.execute("show variables") + res_com = tdSql.cursor.fetchall() + rescomlist = np.array(res_com) + cpms_index = np.where(rescomlist == "compressMsgSize") + index_value = np.dstack((cpms_index[0])).squeeze() + + tdSql.query("show variables") + tdSql.checkData(index_value, 1, 524288) + + tdSql.query("show dnodes") + index = tdSql.getData(0, 0) + + tdDnodes.stop(index) + cmd = f"sed -i '$a compressMSgSize {max_compressMsgSize}' {cfgfile} " + try: + _ = subprocess.check_output(cmd, shell=True).decode("utf-8") + except Exception as e: + raise e + + tdDnodes.start(index) + tdSql.query("show variables") + tdSql.checkData(index_value, 1, 100000000) + + tdDnodes.stop(index) + cmd = f"sed -i '$s/{max_compressMsgSize}/{max_compressMsgSize+10}/g' {cfgfile} " + try: + _ = subprocess.check_output(cmd, shell=True).decode("utf-8") + except Exception as e: + raise e + + tdDnodes.start(index) + tdSql.query("show variables") + tdSql.checkData(index_value, 1, -1) + + tdDnodes.stop(index) + cmd = f"sed -i '$d' {cfgfile}" + try: + _ = subprocess.check_output(cmd, shell=True).decode("utf-8") + except Exception as e: + raise e + + tdDnodes.start(index) + + def td4097(self): + tdLog.printNoPrefix("==========TD-4097==========") + tdSql.execute("drop database if exists db") + tdSql.execute("drop database if exists db1") + tdSql.execute("create database if not exists db keep 3650") + tdSql.execute("create database if not exists db1 keep 3650") + tdSql.execute("create database if not exists new keep 3650") + tdSql.execute("create database if not exists private keep 3650") + tdSql.execute("create database if not exists db2 keep 3650") + + tdSql.execute("create stable db.stb1 (ts timestamp, c1 int) tags(t1 int)") + tdSql.execute("create stable db.stb2 (ts timestamp, c1 int) tags(t1 int)") + tdSql.execute("create stable db1.stb3 (ts timestamp, c1 int) tags(t1 int)") + + tdSql.execute("create table db.t10 using db.stb1 tags(1)") + tdSql.execute("create table db.t11 using db.stb1 tags(2)") + tdSql.execute("create table db.t20 using db.stb2 tags(3)") + tdSql.execute("create table db1.t30 using db1.stb3 tags(4)") + + # tdLog.printNoPrefix("==========TD-4097==========") + # 插入数据,然后进行show create 操作 + + # p1 不进入指定数据库 + tdSql.query("show create database db") + tdSql.checkRows(1) + tdSql.query("show create database db1") + tdSql.checkRows(1) + tdSql.query("show create database db2") + tdSql.checkRows(1) + tdSql.query("show create database new") + tdSql.checkRows(1) + tdSql.query("show create database private") + tdSql.checkRows(1) + tdSql.error("show create database ") + tdSql.error("show create databases db ") + tdSql.error("show create database db.stb1") + tdSql.error("show create database db0") + tdSql.error("show create database db db1") + tdSql.error("show create database db, db1") + tdSql.error("show create database stb1") + tdSql.error("show create database * ") + + tdSql.query("show create stable db.stb1") + tdSql.checkRows(1) + tdSql.error("show create stable db.t10") + tdSql.error("show create stable db.stb0") + tdSql.error("show create stable stb1") + tdSql.error("show create stable ") + tdSql.error("show create stable *") + tdSql.error("show create stable db.stb1 db.stb2") + tdSql.error("show create stable db.stb1, db.stb2") + + tdSql.query("show create table db.stb1") + tdSql.checkRows(1) + tdSql.query("show create table db.t10") + tdSql.checkRows(1) + tdSql.error("show create table db.stb0") + tdSql.error("show create table stb1") + tdSql.error("show create table ") + tdSql.error("show create table *") + tdSql.error("show create table db.stb1 db.stb2") + tdSql.error("show create table db.stb1, db.stb2") + + # p2 进入指定数据库 + tdSql.execute("use db") + + tdSql.query("show create database db") + tdSql.checkRows(1) + tdSql.query("show create database db1") + tdSql.checkRows(1) + tdSql.error("show create database ") + tdSql.error("show create databases db ") + tdSql.error("show create database db.stb1") + tdSql.error("show create database db0") + tdSql.error("show create database db db1") + tdSql.error("show create database db, db1") + tdSql.error("show create database stb1") + tdSql.error("show create database * ") + + tdSql.query("show create stable db.stb1") + tdSql.checkRows(1) + tdSql.query("show create stable stb1") + tdSql.checkRows(1) + tdSql.query("show create stable db1.stb3") + tdSql.checkRows(1) + tdSql.error("show create stable db.t10") + tdSql.error("show create stable db") + tdSql.error("show create stable t10") + tdSql.error("show create stable db.stb0") + tdSql.error("show create stables stb1") + tdSql.error("show create stable ") + tdSql.error("show create stable *") + tdSql.error("show create stable db.stb1 db.stb2") + tdSql.error("show create stable stb1 stb2") + tdSql.error("show create stable db.stb1, db.stb2") + tdSql.error("show create stable stb1, stb2") + + tdSql.query("show create table db.stb1") + tdSql.checkRows(1) + tdSql.query("show create table stb1") + tdSql.checkRows(1) + tdSql.query("show create table db.t10") + tdSql.checkRows(1) + tdSql.query("show create table t10") + tdSql.checkRows(1) + tdSql.query("show create table db1.t30") + tdSql.checkRows(1) + tdSql.error("show create table t30") + tdSql.error("show create table db.stb0") + tdSql.error("show create table db.t0") + tdSql.error("show create table db") + tdSql.error("show create tables stb1") + tdSql.error("show create tables t10") + tdSql.error("show create table ") + tdSql.error("show create table *") + tdSql.error("show create table db.stb1 db.stb2") + tdSql.error("show create table db.t11 db.t10") + tdSql.error("show create table db.stb1, db.stb2") + tdSql.error("show create table db.t11, db.t10") + tdSql.error("show create table stb1 stb2") + tdSql.error("show create table t11 t10") + tdSql.error("show create table stb1, stb2") + tdSql.error("show create table t11, t10") + + # p3 删库删表后进行查询 + tdSql.execute("drop table if exists t11") + + tdSql.error("show create table t11") + tdSql.error("show create table db.t11") + tdSql.query("show create stable stb1") + tdSql.checkRows(1) + tdSql.query("show create table t10") + tdSql.checkRows(1) + + tdSql.execute("drop stable if exists stb2") + + tdSql.error("show create table stb2") + tdSql.error("show create table db.stb2") + tdSql.error("show create stable stb2") + tdSql.error("show create stable db.stb2") + tdSql.error("show create stable db.t20") + tdSql.query("show create database db") + tdSql.checkRows(1) + tdSql.query("show create stable db.stb1") + tdSql.checkRows(1) + + tdSql.execute("drop database if exists db1") + tdSql.error("show create database db1") + tdSql.error("show create stable db1.t31") + tdSql.error("show create stable db1.stb3") + tdSql.query("show create database db") + tdSql.checkRows(1) + tdSql.query("show create stable db.stb1") + tdSql.checkRows(1) + + tdSql.execute("drop database if exists db") + tdSql.execute("drop database if exists db1") + tdSql.execute("drop database if exists new") + tdSql.execute("drop database if exists db2") + tdSql.execute("drop database if exists private") + + def td4153(self): + tdLog.printNoPrefix("==========TD-4153==========") + + pass + + def td4288(self): + tdLog.printNoPrefix("==========TD-4288==========") + # keep ~ [days,365000] + tdSql.execute("drop database if exists db") + tdSql.execute("create database if not exists db") + + tdSql.execute("show variables") + res_kp = tdSql.cursor.fetchall() + resList = np.array(res_kp) + keep_index = np.where(resList == "keep") + index_value = np.dstack((keep_index[0])).squeeze() + + tdSql.query("show variables") + tdSql.checkData(index_value, 1, 3650) + + tdSql.query("show databases") + selfPath = os.path.dirname(os.path.realpath(__file__)) + if ("community" in selfPath): + tdSql.checkData(0, 7, "3650,3650,3650") + else: + tdSql.checkData(0, 7, 3650) + + days = tdSql.getData(0, 6) + tdSql.error("alter database db keep 3650001") + tdSql.error("alter database db keep 9") + tdSql.error("alter database db keep 0b") + tdSql.error("alter database db keep 3650,9,36500") + tdSql.error("alter database db keep 3650,3650,365001") + tdSql.error("alter database db keep 36500,a,36500") + tdSql.error("alter database db keep (36500,3650,3650)") + tdSql.error("alter database db keep [36500,3650,36500]") + tdSql.error("alter database db keep 36500,0xff,3650") + tdSql.error("alter database db keep 36500,0o365,3650") + tdSql.error("alter database db keep 36500,0A3Ch,3650") + tdSql.error("alter database db keep") + tdSql.error("alter database db keep0 36500") + + tdSql.execute("alter database db keep 36500") + tdSql.query("show databases") + if ("community" in selfPath): + tdSql.checkData(0, 7, "36500,36500,36500") + else: + tdSql.checkData(0, 7, 36500) + + tdSql.execute("drop database if exists db") + tdSql.execute("create database if not exists db1") + tdSql.query("show databases") + if ("community" in selfPath): + tdSql.checkData(0, 7, "3650,3650,3650") + else: + tdSql.checkData(0, 7, 3650) + + tdSql.query("show variables") + tdSql.checkData(index_value, 1, 3650) + + tdSql.execute("alter database db1 keep 365") + tdSql.execute("drop database if exists db1") + + + pass + + def td4724(self): + tdLog.printNoPrefix("==========TD-4724==========") + cfgfile = self.getCfgFile() + minTablesPerVnode = 5 + maxTablesPerVnode = 10 + maxVgroupsPerDb = 100 + + tdSql.query("show dnodes") + index = tdSql.getData(0, 0) + + tdDnodes.stop(index) + vnode_cmd = f"sed -i '$a maxVgroupsPerDb {maxVgroupsPerDb}' {cfgfile} " + min_cmd = f"sed -i '$a minTablesPerVnode {minTablesPerVnode}' {cfgfile} " + max_cmd = f"sed -i '$a maxTablesPerVnode {maxTablesPerVnode}' {cfgfile} " + try: + _ = subprocess.check_output(vnode_cmd, shell=True).decode("utf-8") + _ = subprocess.check_output(min_cmd, shell=True).decode("utf-8") + _ = subprocess.check_output(max_cmd, shell=True).decode("utf-8") + except Exception as e: + raise e + + tdDnodes.start(index) + tdSql.execute("drop database if exists db") + tdSql.execute("create database if not exists db keep 3650") + tdSql.execute("use db") + tdSql.execute("create stable db.stb1 (ts timestamp, c1 int) tags(t1 int)") + insert_sql = "insert into " + for i in range(100): + tdSql.execute(f"create table db.t1{i} using db.stb1 tags({i})") + insert_sql += f" t1{i} values({1604298064000 + i*1000}, {i})" + tdSql.query("show dnodes") + vnode_count = tdSql.getData(0, 2) + if vnode_count <= 1: + tdLog.exit("vnode is less than 2") + + tdSql.execute(insert_sql) + tdDnodes.stop(index) + cmd = f"sed -i '$d' {cfgfile}" + try: + _ = subprocess.check_output(cmd, shell=True).decode("utf-8") + _ = subprocess.check_output(cmd, shell=True).decode("utf-8") + _ = subprocess.check_output(cmd, shell=True).decode("utf-8") + except Exception as e: + raise e + + tdDnodes.start(index) + + pass + + def td4889(self): + tdLog.printNoPrefix("==========TD-4889==========") + cfg = { + 'minRowsPerFileBlock': '10', + 'maxRowsPerFileBlock': '200', + 'minRows': '10', + 'maxRows': '200', + 'maxVgroupsPerDb': '100', + 'maxTablesPerVnode': '1200', + } + tdSql.query("show dnodes") + dnode_index = tdSql.getData(0,0) + tdDnodes.stop(dnode_index) + tdDnodes.deploy(dnode_index, cfg) + tdDnodes.start(dnode_index) + + tdSql.execute("drop database if exists db") + tdSql.execute("create database if not exists db keep 3650 blocks 3 minrows 10 maxrows 200") + + tdSql.execute("use db") + tdSql.execute("create stable db.stb1 (ts timestamp, c1 int) tags(t1 int)") + + nowtime = int(round(time.time() * 1000)) + for i in range(1000): + tdSql.execute(f"create table db.t1{i} using db.stb1 tags({i})") + sql = f"insert into db.t1{i} values" + for j in range(260): + sql += f"({nowtime-1000*i-j}, {i+j})" + # tdSql.execute(f"insert into db.t1{i} values (now-100d, {i+j})") + tdSql.execute(sql) + + # tdDnodes.stop(dnode_index) + # tdDnodes.start(dnode_index) + + tdSql.query("show vgroups") + index = tdSql.getData(0,0) + tdSql.checkData(0, 6, 0) + tdSql.execute(f"compact vnodes in({index})") + start_time = time.time() + while True: + tdSql.query("show vgroups") + if tdSql.getData(0, 6) != 0: + tdLog.printNoPrefix("show vgroups row:0 col:6 data:1 == expect:1") + break + run_time = time.time()-start_time + if run_time > 3: + tdLog.exit("compacting not occured") + # time.sleep(0.1) + + pass + + def td5168insert(self): + tdSql.execute("drop database if exists db") + tdSql.execute("create database if not exists db keep 3650") + + tdSql.execute("use db") + tdSql.execute("create stable db.stb1 (ts timestamp, c1 float, c2 float, c3 double, c4 double) tags(t1 int)") + tdSql.execute("create table db.t1 using db.stb1 tags(1)") + + for i in range(5): + c1 = 1001.11 + i*0.1 + c2 = 1001.11 + i*0.1 + 1*0.01 + c3 = 1001.11 + i*0.1 + 2*0.01 + c4 = 1001.11 + i*0.1 + 3*0.01 + tdSql.execute(f"insert into db.t1 values ('2021-07-01 08:00:0{i}.000', {c1}, {c2}, {c3}, {c4})") + + # tdSql.execute("insert into db.t1 values ('2021-07-01 08:00:00.000', 1001.11, 1001.12, 1001.13, 1001.14)") + # tdSql.execute("insert into db.t1 values ('2021-07-01 08:00:01.000', 1001.21, 1001.22, 1001.23, 1001.24)") + # tdSql.execute("insert into db.t1 values ('2021-07-01 08:00:02.000', 1001.31, 1001.32, 1001.33, 1001.34)") + # tdSql.execute("insert into db.t1 values ('2021-07-01 08:00:03.000', 1001.41, 1001.42, 1001.43, 1001.44)") + # tdSql.execute("insert into db.t1 values ('2021-07-01 08:00:04.000', 1001.51, 1001.52, 1001.53, 1001.54)") + + # for i in range(1000000): + for i in range(10000): + random1 = random.uniform(1000,1001) + random2 = random.uniform(1000,1001) + random3 = random.uniform(1000,1001) + random4 = random.uniform(1000,1001) + tdSql.execute(f"insert into db.t1 values (now+{i}a, {random1}, {random2},{random3}, {random4})") + + pass + + def td5168(self): + tdLog.printNoPrefix("==========TD-5168==========") + # 插入小范围内的随机数 + tdLog.printNoPrefix("=====step0: 默认情况下插入数据========") + self.td5168insert() + + # 获取五个时间点的数据作为基准数值,未压缩情况下精准匹配 + for i in range(5): + tdSql.query(f"select * from db.t1 where ts='2021-07-01 08:00:0{i}.000' ") + # c1, c2, c3, c4 = tdSql.getData(0, 1), tdSql.getData(0, 2), tdSql.getData(0, 3), tdSql.getData(0, 4) + for j in range(4): + locals()["f" + str(j) + str(i)] = tdSql.getData(0, j+1) + print(f"f{j}{i}:", locals()["f" + str(j) + str(i)]) + tdSql.checkData(0, j+1, locals()["f" + str(j) + str(i)]) + + # tdSql.query("select * from db.t1 limit 100,1") + # f10, f11, f12, f13 = tdSql.getData(0,1), tdSql.getData(0,2), tdSql.getData(0,3), tdSql.getData(0,4) + # + # tdSql.query("select * from db.t1 limit 1000,1") + # f20, f21, f22, f23 = tdSql.getData(0,1), tdSql.getData(0,2), tdSql.getData(0,3), tdSql.getData(0,4) + # + # tdSql.query("select * from db.t1 limit 10000,1") + # f30, f31, f32, f33 = tdSql.getData(0,1), tdSql.getData(0,2), tdSql.getData(0,3), tdSql.getData(0,4) + # + # tdSql.query("select * from db.t1 limit 100000,1") + # f40, f41, f42, f43 = tdSql.getData(0,1), tdSql.getData(0,2), tdSql.getData(0,3), tdSql.getData(0,4) + # + # tdSql.query("select * from db.t1 limit 1000000,1") + # f50, f51, f52, f53 = tdSql.getData(0,1), tdSql.getData(0,2), tdSql.getData(0,3), tdSql.getData(0,4) + + # 关闭服务并获取未开启压缩情况下的数据容量 + tdSql.query("show dnodes") + index = tdSql.getData(0, 0) + tdDnodes.stop(index) + + cfgdir = self.getCfgDir() + cfgfile = self.getCfgFile() + + lossy_cfg_cmd=f"grep lossyColumns {cfgfile}|awk '{{print $2}}'" + data_size_cmd = f"du -s {cfgdir}/../data/vnode/ | awk '{{print $1}}'" + dsize_init = int(subprocess.check_output(data_size_cmd,shell=True).decode("utf-8")) + lossy_args = subprocess.check_output(lossy_cfg_cmd, shell=True).decode("utf-8") + tdLog.printNoPrefix(f"close the lossyColumns,data size is: {dsize_init};the lossyColumns line is: {lossy_args}") + + ################################################### + float_lossy = "float" + double_lossy = "double" + float_double_lossy = "float|double" + no_loosy = "" + + double_precision_cmd = f"sed -i '$a dPrecision 0.000001' {cfgfile}" + _ = subprocess.check_output(double_precision_cmd, shell=True).decode("utf-8") + + lossy_float_cmd = f"sed -i '$a lossyColumns {float_lossy}' {cfgfile} " + lossy_double_cmd = f"sed -i '$d' {cfgfile} && sed -i '$a lossyColumns {double_lossy}' {cfgfile} " + lossy_float_double_cmd = f"sed -i '$d' {cfgfile} && sed -i '$a lossyColumns {float_double_lossy}' {cfgfile} " + lossy_no_cmd = f"sed -i '$a lossyColumns {no_loosy}' {cfgfile} " + + ################################################### + + # 开启有损压缩,参数float,并启动服务插入数据 + tdLog.printNoPrefix("=====step1: lossyColumns设置为float========") + lossy_float = subprocess.check_output(lossy_float_cmd, shell=True).decode("utf-8") + tdDnodes.start(index) + self.td5168insert() + + # 查询前面所述5个时间数据并与基准数值进行比较 + for i in range(5): + tdSql.query(f"select * from db.t1 where ts='2021-07-01 08:00:0{i}.000' ") + # c1, c2, c3, c4 = tdSql.getData(0, 1), tdSql.getData(0, 2), tdSql.getData(0, 3), tdSql.getData(0, 4) + for j in range(4): + # locals()["f" + str(j) + str(i)] = tdSql.getData(0, j+1) + # print(f"f{j}{i}:", locals()["f" + str(j) + str(i)]) + tdSql.checkData(0, j+1, locals()["f" + str(j) + str(i)]) + + # 关闭服务并获取压缩参数为float情况下的数据容量 + tdDnodes.stop(index) + dsize_float = int(subprocess.check_output(data_size_cmd,shell=True).decode("utf-8")) + lossy_args = subprocess.check_output(lossy_cfg_cmd, shell=True).decode("utf-8") + tdLog.printNoPrefix(f"open the lossyColumns, data size is:{dsize_float};the lossyColumns line is: {lossy_args}") + + # 修改有损压缩,参数double,并启动服务 + tdLog.printNoPrefix("=====step2: lossyColumns设置为double========") + lossy_double = subprocess.check_output(lossy_double_cmd, shell=True).decode("utf-8") + tdDnodes.start(index) + self.td5168insert() + + # 查询前面所述5个时间数据并与基准数值进行比较 + for i in range(5): + tdSql.query(f"select * from db.t1 where ts='2021-07-01 08:00:0{i}.000' ") + for j in range(4): + tdSql.checkData(0, j+1, locals()["f" + str(j) + str(i)]) + + # 关闭服务并获取压缩参数为double情况下的数据容量 + tdDnodes.stop(index) + dsize_double = int(subprocess.check_output(data_size_cmd, shell=True).decode("utf-8")) + lossy_args = subprocess.check_output(lossy_cfg_cmd, shell=True).decode("utf-8") + tdLog.printNoPrefix(f"open the lossyColumns, data size is:{dsize_double};the lossyColumns line is: {lossy_args}") + + # 修改有损压缩,参数 float&&double ,并启动服务 + tdLog.printNoPrefix("=====step3: lossyColumns设置为 float&&double ========") + lossy_float_double = subprocess.check_output(lossy_float_double_cmd, shell=True).decode("utf-8") + tdDnodes.start(index) + self.td5168insert() + + # 查询前面所述5个时间数据并与基准数值进行比较 + for i in range(5): + tdSql.query(f"select * from db.t1 where ts='2021-07-01 08:00:0{i}.000' ") + for j in range(4): + tdSql.checkData(0, j+1, locals()["f" + str(j) + str(i)]) + + # 关闭服务并获取压缩参数为 float&&double 情况下的数据容量 + tdDnodes.stop(index) + dsize_float_double = int(subprocess.check_output(data_size_cmd, shell=True).decode("utf-8")) + lossy_args = subprocess.check_output(lossy_cfg_cmd, shell=True).decode("utf-8") + tdLog.printNoPrefix(f"open the lossyColumns, data size is:{dsize_float_double};the lossyColumns line is: {lossy_args}") + + if not ((dsize_float_double < dsize_init) and (dsize_double < dsize_init) and (dsize_float < dsize_init)) : + tdLog.printNoPrefix(f"When lossyColumns value is float, data size is: {dsize_float}") + tdLog.printNoPrefix(f"When lossyColumns value is double, data size is: {dsize_double}") + tdLog.printNoPrefix(f"When lossyColumns value is float and double, data size is: {dsize_float_double}") + tdLog.printNoPrefix(f"When lossyColumns is closed, data size is: {dsize_init}") + tdLog.exit("压缩未生效") + else: + tdLog.printNoPrefix(f"When lossyColumns value is float, data size is: {dsize_float}") + tdLog.printNoPrefix(f"When lossyColumns value is double, data size is: {dsize_double}") + tdLog.printNoPrefix(f"When lossyColumns value is float and double, data size is: {dsize_float_double}") + tdLog.printNoPrefix(f"When lossyColumns is closed, data size is: {dsize_init}") + tdLog.printNoPrefix("压缩生效") + + pass + + def td5433(self): + tdLog.printNoPrefix("==========TD-5433==========") + tdSql.execute("drop database if exists db") + tdSql.execute("create database if not exists db keep 3650") + + tdSql.execute("use db") + tdSql.execute("create stable db.stb1 (ts timestamp, c1 int) tags(t0 tinyint, t1 int)") + tdSql.execute("create stable db.stb2 (ts timestamp, c1 int) tags(t0 binary(16), t1 binary(16))") + numtab=20000 + for i in range(numtab): + sql = f"create table db.t{i} using db.stb1 tags({i%128}, {100+i})" + tdSql.execute(sql) + tdSql.execute(f"insert into db.t{i} values (now-10d, {i})") + tdSql.execute(f"insert into db.t{i} values (now-9d, {i*2})") + tdSql.execute(f"insert into db.t{i} values (now-8d, {i*3})") + + tdSql.execute("create table db.t01 using db.stb2 tags('1', '100')") + tdSql.execute("create table db.t02 using db.stb2 tags('2', '200')") + tdSql.execute("create table db.t03 using db.stb2 tags('3', '300')") + tdSql.execute("create table db.t04 using db.stb2 tags('4', '400')") + tdSql.execute("create table db.t05 using db.stb2 tags('5', '500')") + + tdSql.query("select distinct t1 from stb1 where t1 != '150'") + tdSql.checkRows(numtab-1) + tdSql.query("select distinct t1 from stb1 where t1 != 150") + tdSql.checkRows(numtab-1) + tdSql.query("select distinct t1 from stb1 where t1 = 150") + tdSql.checkRows(1) + tdSql.query("select distinct t1 from stb1 where t1 = '150'") + tdSql.checkRows(1) + tdSql.query("select distinct t1 from stb1") + tdSql.checkRows(numtab) + + tdSql.query("select distinct t0 from stb1 where t0 != '2'") + tdSql.checkRows(127) + tdSql.query("select distinct t0 from stb1 where t0 != 2") + tdSql.checkRows(127) + tdSql.query("select distinct t0 from stb1 where t0 = 2") + tdSql.checkRows(1) + tdSql.query("select distinct t0 from stb1 where t0 = '2'") + tdSql.checkRows(1) + tdSql.query("select distinct t0 from stb1") + tdSql.checkRows(128) + + tdSql.query("select distinct t1 from stb2 where t1 != '200'") + tdSql.checkRows(4) + tdSql.query("select distinct t1 from stb2 where t1 != 200") + tdSql.checkRows(4) + tdSql.query("select distinct t1 from stb2 where t1 = 200") + tdSql.checkRows(1) + tdSql.query("select distinct t1 from stb2 where t1 = '200'") + tdSql.checkRows(1) + tdSql.query("select distinct t1 from stb2") + tdSql.checkRows(5) + + tdSql.query("select distinct t0 from stb2 where t0 != '2'") + tdSql.checkRows(4) + tdSql.query("select distinct t0 from stb2 where t0 != 2") + tdSql.checkRows(4) + tdSql.query("select distinct t0 from stb2 where t0 = 2") + tdSql.checkRows(1) + tdSql.query("select distinct t0 from stb2 where t0 = '2'") + tdSql.checkRows(1) + tdSql.query("select distinct t0 from stb2") + tdSql.checkRows(5) + + pass + + def td5798(self): + tdLog.printNoPrefix("==========TD-5798 + TD-5810==========") + tdSql.execute("drop database if exists db") + tdSql.execute("create database if not exists db keep 3650") + + tdSql.execute("use db") + tdSql.execute("create stable db.stb1 (ts timestamp, c1 int, c2 int) tags(t0 tinyint, t1 int, t2 int)") + tdSql.execute("create stable db.stb2 (ts timestamp, c2 int, c3 binary(16)) tags(t2 binary(16), t3 binary(16), t4 int)") + maxRemainderNum=7 + tbnum=101 + for i in range(tbnum-1): + sql = f"create table db.t{i} using db.stb1 tags({i%maxRemainderNum}, {(i-1)%maxRemainderNum}, {i%2})" + tdSql.execute(sql) + tdSql.execute(f"insert into db.t{i} values (now-10d, {i}, {i%3})") + tdSql.execute(f"insert into db.t{i} values (now-9d, {i}, {(i-1)%3})") + tdSql.execute(f"insert into db.t{i} values (now-8d, {i}, {(i-2)%3})") + tdSql.execute(f"insert into db.t{i} (ts )values (now-7d)") + + tdSql.execute(f"create table db.t0{i} using db.stb2 tags('{i%maxRemainderNum}', '{(i-1)%maxRemainderNum}', {i%3})") + tdSql.execute(f"insert into db.t0{i} values (now-10d, {i}, '{(i+1)%3}')") + tdSql.execute(f"insert into db.t0{i} values (now-9d, {i}, '{(i+2)%3}')") + tdSql.execute(f"insert into db.t0{i} values (now-8d, {i}, '{(i)%3}')") + tdSql.execute(f"insert into db.t0{i} (ts )values (now-7d)") + tdSql.execute("create table db.t100num using db.stb1 tags(null, null, null)") + tdSql.execute("create table db.t0100num using db.stb2 tags(null, null, null)") + tdSql.execute(f"insert into db.t100num values (now-10d, {tbnum-1}, 1)") + tdSql.execute(f"insert into db.t100num values (now-9d, {tbnum-1}, 0)") + tdSql.execute(f"insert into db.t100num values (now-8d, {tbnum-1}, 2)") + tdSql.execute(f"insert into db.t100num (ts )values (now-7d)") + tdSql.execute(f"insert into db.t0100num values (now-10d, {tbnum-1}, 1)") + tdSql.execute(f"insert into db.t0100num values (now-9d, {tbnum-1}, 0)") + tdSql.execute(f"insert into db.t0100num values (now-8d, {tbnum-1}, 2)") + tdSql.execute(f"insert into db.t0100num (ts )values (now-7d)") + + #========== TD-5810 suport distinct multi-data-coloumn ========== + tdSql.query(f"select distinct c1 from stb1 where c1 <{tbnum}") + tdSql.checkRows(tbnum) + tdSql.query(f"select distinct c2 from stb1") + tdSql.checkRows(4) + tdSql.query(f"select distinct c1,c2 from stb1 where c1 <{tbnum}") + tdSql.checkRows(tbnum*3) + tdSql.query(f"select distinct c1,c1 from stb1 where c1 <{tbnum}") + tdSql.checkRows(tbnum) + tdSql.query(f"select distinct c1,c2 from stb1 where c1 <{tbnum} limit 3") + tdSql.checkRows(3) + tdSql.query(f"select distinct c1,c2 from stb1 where c1 <{tbnum} limit 3 offset {tbnum*3-2}") + tdSql.checkRows(2) + + tdSql.query(f"select distinct c1 from t1 where c1 <{tbnum}") + tdSql.checkRows(1) + tdSql.query(f"select distinct c2 from t1") + tdSql.checkRows(4) + tdSql.query(f"select distinct c1,c2 from t1 where c1 <{tbnum}") + tdSql.checkRows(3) + tdSql.query(f"select distinct c1,c1 from t1 ") + tdSql.checkRows(2) + tdSql.query(f"select distinct c1,c1 from t1 where c1 <{tbnum}") + tdSql.checkRows(1) + tdSql.query(f"select distinct c1,c2 from t1 where c1 <{tbnum} limit 3") + tdSql.checkRows(3) + tdSql.query(f"select distinct c1,c2 from t1 where c1 <{tbnum} limit 3 offset 2") + tdSql.checkRows(1) + + tdSql.query(f"select distinct c3 from stb2 where c2 <{tbnum} ") + tdSql.checkRows(3) + tdSql.query(f"select distinct c3, c2 from stb2 where c2 <{tbnum} limit 2") + tdSql.checkRows(2) + + tdSql.error("select distinct c5 from stb1") + tdSql.error("select distinct c5 from t1") + tdSql.error("select distinct c1 from db.*") + tdSql.error("select c2, distinct c1 from stb1") + tdSql.error("select c2, distinct c1 from t1") + tdSql.error("select distinct c2 from ") + tdSql.error("distinct c2 from stb1") + tdSql.error("distinct c2 from t1") + tdSql.error("select distinct c1, c2, c3 from stb1") + tdSql.error("select distinct c1, c2, c3 from t1") + tdSql.error("select distinct stb1.c1, stb1.c2, stb2.c2, stb2.c3 from stb1") + tdSql.error("select distinct stb1.c1, stb1.c2, stb2.c2, stb2.c3 from t1") + tdSql.error("select distinct t1.c1, t1.c2, t2.c1, t2.c2 from t1") + tdSql.query(f"select distinct c1 c2, c2 c3 from stb1 where c1 <{tbnum}") + tdSql.checkRows(tbnum*3) + tdSql.query(f"select distinct c1 c2, c2 c3 from t1 where c1 <{tbnum}") + tdSql.checkRows(3) + tdSql.error("select distinct c1, c2 from stb1 order by ts") + tdSql.error("select distinct c1, c2 from t1 order by ts") + tdSql.error("select distinct c1, ts from stb1 group by c2") + tdSql.error("select distinct c1, ts from t1 group by c2") + tdSql.error("select distinct c1, max(c2) from stb1 ") + tdSql.error("select distinct c1, max(c2) from t1 ") + tdSql.error("select max(c2), distinct c1 from stb1 ") + tdSql.error("select max(c2), distinct c1 from t1 ") + tdSql.error("select distinct c1, c2 from stb1 where c1 > 3 group by t0") + tdSql.error("select distinct c1, c2 from t1 where c1 > 3 group by t0") + tdSql.error("select distinct c1, c2 from stb1 where c1 > 3 interval(1d) ") + tdSql.error("select distinct c1, c2 from t1 where c1 > 3 interval(1d) ") + tdSql.error("select distinct c1, c2 from stb1 where c1 > 3 interval(1d) fill(next)") + tdSql.error("select distinct c1, c2 from t1 where c1 > 3 interval(1d) fill(next)") + tdSql.error("select distinct c1, c2 from stb1 where ts > now-10d and ts < now interval(1d) fill(next)") + tdSql.error("select distinct c1, c2 from t1 where ts > now-10d and ts < now interval(1d) fill(next)") + tdSql.error("select distinct c1, c2 from stb1 where c1 > 3 slimit 1") + tdSql.error("select distinct c1, c2 from t1 where c1 > 3 slimit 1") + tdSql.query(f"select distinct c1, c2 from stb1 where c1 between {tbnum-2} and {tbnum} ") + tdSql.checkRows(6) + tdSql.query("select distinct c1, c2 from stb1 where c1 in (1,2,3,4,5)") + tdSql.checkRows(15) + tdSql.query("select distinct c1, c2 from stb1 where c1 in (100,1000,10000)") + tdSql.checkRows(3) + + tdSql.query(f"select distinct c1,c2 from (select * from stb1 where c1 > {tbnum-2}) ") + tdSql.checkRows(3) + tdSql.query(f"select distinct c1,c2 from (select * from t1 where c1 < {tbnum}) ") + tdSql.checkRows(3) + tdSql.query(f"select distinct c1,c2 from (select * from stb1 where t2 !=0 and t2 != 1) ") + tdSql.checkRows(0) + tdSql.error("select distinct c1, c2 from (select distinct c1, c2 from stb1 where t0 > 2 and t1 < 3) ") + tdSql.error("select c1, c2 from (select distinct c1, c2 from stb1 where t0 > 2 and t1 < 3) ") + tdSql.query("select distinct c1, c2 from (select c2, c1 from stb1 where c1 > 2 ) where c1 < 4") + tdSql.checkRows(3) + tdSql.error("select distinct c1, c2 from (select c1 from stb1 where t0 > 2 ) where t1 < 3") + tdSql.error("select distinct c1, c2 from (select c2, c1 from stb1 where c1 > 2 order by ts)") + # tdSql.error("select distinct c1, c2 from (select c2, c1 from t1 where c1 > 2 order by ts)") + tdSql.error("select distinct c1, c2 from (select c2, c1 from stb1 where c1 > 2 group by c1)") + # tdSql.error("select distinct c1, c2 from (select max(c1) c1, max(c2) c2 from stb1 group by c1)") + # tdSql.error("select distinct c1, c2 from (select max(c1) c1, max(c2) c2 from t1 group by c1)") + tdSql.query("select distinct c1, c2 from (select max(c1) c1, max(c2) c2 from stb1 )") + tdSql.checkRows(1) + tdSql.query("select distinct c1, c2 from (select max(c1) c1, max(c2) c2 from t1 )") + tdSql.checkRows(1) + tdSql.error("select distinct stb1.c1, stb1.c2 from stb1 , stb2 where stb1.ts=stb2.ts and stb1.t2=stb2.t4") + tdSql.error("select distinct t1.c1, t1.c2 from t1 , t2 where t1.ts=t2.ts ") + + # tdSql.error("select distinct c1, c2 from (select count(c1) c1, count(c2) c2 from stb1 group by ts)") + # tdSql.error("select distinct c1, c2 from (select count(c1) c1, count(c2) c2 from t1 group by ts)") + + + + #========== TD-5798 suport distinct multi-tags-coloumn ========== + tdSql.query("select distinct t1 from stb1") + tdSql.checkRows(maxRemainderNum+1) + tdSql.query("select distinct t0, t1 from stb1") + tdSql.checkRows(maxRemainderNum+1) + tdSql.query("select distinct t1, t0 from stb1") + tdSql.checkRows(maxRemainderNum+1) + tdSql.query("select distinct t1, t2 from stb1") + tdSql.checkRows(maxRemainderNum*2+1) + tdSql.query("select distinct t0, t1, t2 from stb1") + tdSql.checkRows(maxRemainderNum*2+1) + tdSql.query("select distinct t0 t1, t1 t2 from stb1") + tdSql.checkRows(maxRemainderNum+1) + tdSql.query("select distinct t0, t0, t0 from stb1") + tdSql.checkRows(maxRemainderNum+1) + tdSql.query("select distinct t0, t1 from t1") + tdSql.checkRows(1) + tdSql.query("select distinct t0, t1 from t100num") + tdSql.checkRows(1) + + tdSql.query("select distinct t3 from stb2") + tdSql.checkRows(maxRemainderNum+1) + tdSql.query("select distinct t2, t3 from stb2") + tdSql.checkRows(maxRemainderNum+1) + tdSql.query("select distinct t3, t2 from stb2") + tdSql.checkRows(maxRemainderNum+1) + tdSql.query("select distinct t4, t2 from stb2") + tdSql.checkRows(maxRemainderNum*3+1) + tdSql.query("select distinct t2, t3, t4 from stb2") + tdSql.checkRows(maxRemainderNum*3+1) + tdSql.query("select distinct t2 t1, t3 t2 from stb2") + tdSql.checkRows(maxRemainderNum+1) + tdSql.query("select distinct t3, t3, t3 from stb2") + tdSql.checkRows(maxRemainderNum+1) + tdSql.query("select distinct t2, t3 from t01") + tdSql.checkRows(1) + tdSql.query("select distinct t3, t4 from t0100num") + tdSql.checkRows(1) + + + ########## should be error ######### + tdSql.error("select distinct from stb1") + tdSql.error("select distinct t3 from stb1") + tdSql.error("select distinct t1 from db.*") + tdSql.error("select distinct t2 from ") + tdSql.error("distinct t2 from stb1") + tdSql.error("select distinct stb1") + tdSql.error("select distinct t0, t1, t2, t3 from stb1") + tdSql.error("select distinct stb1.t0, stb1.t1, stb2.t2, stb2.t3 from stb1") + + tdSql.error("select dist t0 from stb1") + tdSql.error("select distinct stb2.t2, stb2.t3 from stb1") + tdSql.error("select distinct stb2.t2 t1, stb2.t3 t2 from stb1") + + tdSql.error("select distinct t0, t1 from t1 where t0 < 7") + + ########## add where condition ########## + tdSql.query("select distinct t0, t1 from stb1 where t1 > 3") + tdSql.checkRows(3) + tdSql.query("select distinct t0, t1 from stb1 where t1 > 3 limit 2") + tdSql.checkRows(2) + tdSql.query("select distinct t0, t1 from stb1 where t1 > 3 limit 2 offset 2") + tdSql.checkRows(1) + tdSql.query("select distinct t0, t1 from stb1 where t1 > 3 slimit 2") + tdSql.checkRows(3) + tdSql.error("select distinct t0, t1 from stb1 where c1 > 2") + tdSql.query("select distinct t0, t1 from stb1 where t1 > 3 and t1 < 5") + tdSql.checkRows(1) + tdSql.error("select distinct stb1.t0, stb1.t1 from stb1, stb2 where stb1.t2=stb2.t4") + tdSql.error("select distinct t0, t1 from stb1 where stb2.t4 > 2") + tdSql.error("select distinct t0, t1 from stb1 where t1 > 3 group by t0") + tdSql.error("select distinct t0, t1 from stb1 where t1 > 3 interval(1d) ") + tdSql.error("select distinct t0, t1 from stb1 where t1 > 3 interval(1d) fill(next)") + tdSql.error("select distinct t0, t1 from stb1 where ts > now-10d and ts < now interval(1d) fill(next)") + + tdSql.error("select max(c1), distinct t0 from stb1 where t0 > 2") + tdSql.error("select distinct t0, max(c1) from stb1 where t0 > 2") + tdSql.error("select distinct t0 from stb1 where t0 in (select t0 from stb1 where t0 > 2)") + tdSql.query("select distinct t0, t1 from stb1 where t0 in (1,2,3,4,5)") + tdSql.checkRows(5) + tdSql.query("select distinct t1 from (select t0, t1 from stb1 where t0 > 2) ") + tdSql.checkRows(4) + tdSql.error("select distinct t1 from (select distinct t0, t1 from stb1 where t0 > 2 and t1 < 3) ") + tdSql.error("select distinct t1 from (select distinct t0, t1 from stb1 where t0 > 2 ) where t1 < 3") + tdSql.query("select distinct t1 from (select t0, t1 from stb1 where t0 > 2 ) where t1 < 3") + tdSql.checkRows(1) + tdSql.error("select distinct t1, t0 from (select t1 from stb1 where t0 > 2 ) where t1 < 3") + tdSql.error("select distinct t1, t0 from (select max(t1) t1, max(t0) t0 from stb1 group by t1)") + tdSql.error("select distinct t1, t0 from (select max(t1) t1, max(t0) t0 from stb1)") + tdSql.query("select distinct t1, t0 from (select t1,t0 from stb1 where t0 > 2 ) where t1 < 3") + tdSql.checkRows(1) + tdSql.error(" select distinct t1, t0 from (select t1,t0 from stb1 where t0 > 2 order by ts) where t1 < 3") + tdSql.error("select t1, t0 from (select distinct t1,t0 from stb1 where t0 > 2 ) where t1 < 3") + tdSql.error(" select distinct t1, t0 from (select t1,t0 from stb1 where t0 > 2 group by ts) where t1 < 3") + tdSql.error("select distinct stb1.t1, stb1.t2 from stb1 , stb2 where stb1.ts=stb2.ts and stb1.t2=stb2.t4") + tdSql.error("select distinct t1.t1, t1.t2 from t1 , t2 where t1.ts=t2.ts ") + + pass + + def td5935(self): + tdLog.printNoPrefix("==========TD-5935==========") + tdSql.execute("drop database if exists db") + tdSql.execute("create database if not exists db keep 3650") + + tdSql.execute("use db") + tdSql.execute("create stable db.stb1 (ts timestamp, c1 int, c2 float) tags(t1 int, t2 int)") + nowtime=int(round((time.time()*1000))) + for i in range(100): + sql = f"create table db.t{i} using db.stb1 tags({i % 7}, {i % 2})" + tdSql.execute(sql) + for j in range(1000): + tdSql.execute(f"insert into db.t{i} values ({nowtime-j*10}, {1000-j}, {round(random.random()*j,3)})") + tdSql.execute(f"insert into db.t{i} (ts) values ({nowtime-10000}) ") + + ########### TD-5933 verify the bug of "function stddev with interval return 0 rows" is fixed ########## + stddevAndIntervalSql=f"select last(*) from t0 where ts>={nowtime-10000} interval(10a) limit 10" + tdSql.query(stddevAndIntervalSql) + tdSql.checkRows(10) + + ########## TD-5978 verify the bug of "when start row is null, result by fill(next) is 0 " is fixed ########## + fillsql=f"select last(*) from t0 where ts>={nowtime-10000} and ts<{nowtime} interval(10a) fill(next) limit 10" + tdSql.query(fillsql) + fillResult=False + if (tdSql.getData(0,2) != 0) and (tdSql.getData(0, 2) is not None): + fillResult=True + if fillResult: + tdLog.success(f"sql is :{fillsql}, fill(next) is correct") + else: + tdLog.exit("fill(next) is wrong") + + pass + + def td6068(self): + tdLog.printNoPrefix("==========TD-6068==========") + tdSql.execute("drop database if exists db") + tdSql.execute("create database if not exists db keep 3650") + tdSql.execute("use db") + + tdSql.execute("create stable db.stb1 (ts timestamp, c1 int, c2 float, c3 timestamp, c4 binary(16), c5 double, c6 bool) tags(t1 int)") + + for i in range(100): + sql = f"create table db.t{i} using db.stb1 tags({i})" + tdSql.execute(sql) + tdSql.execute(f"insert into db.t{i} values (now-10h, {i}, {i+random.random()}, now-10h, 'a_{i}', '{i-random.random()}', True)") + tdSql.execute(f"insert into db.t{i} values (now-9h, {i+random.randint(1,10)}, {i+random.random()}, now-9h, 'a_{i}', '{i-random.random()}', FALSE )") + tdSql.execute(f"insert into db.t{i} values (now-8h, {i+random.randint(1,10)}, {i+random.random()}, now-8h, 'b_{i}', '{i-random.random()}', True)") + tdSql.execute(f"insert into db.t{i} values (now-7h, {i+random.randint(1,10)}, {i+random.random()}, now-7h, 'b_{i}', '{i-random.random()}', FALSE )") + tdSql.execute(f"insert into db.t{i} values (now-6h, {i+random.randint(1,10)}, {i+random.random()}, now-6h, 'c_{i}', '{i-random.random()}', True)") + tdSql.execute(f"insert into db.t{i} values (now-5h, {i+random.randint(1,10)}, {i+random.random()}, now-5h, 'c_{i}', '{i-random.random()}', FALSE )") + tdSql.execute(f"insert into db.t{i} (ts)values (now-4h)") + tdSql.execute(f"insert into db.t{i} (ts)values (now-11h)") + tdSql.execute(f"insert into db.t{i} (ts)values (now-450m)") + + tdSql.query("select ts as t,derivative(c1, 10m, 0) from t1") + tdSql.checkRows(5) + tdSql.checkCols(3) + for i in range(5): + data=tdSql.getData(i, 0) + tdSql.checkData(i, 1, data) + tdSql.query("select ts as t, derivative(c1, 1h, 0) from stb1 group by tbname") + tdSql.checkRows(500) + tdSql.checkCols(4) + tdSql.query("select ts as t, derivative(c1, 1s, 0) from t1") + tdSql.query("select ts as t, derivative(c1, 1d, 0) from t1") + tdSql.error("select ts as t, derivative(c1, 1h, 0) from stb1") + tdSql.query("select ts as t, derivative(c2, 1h, 0) from t1") + tdSql.checkRows(5) + tdSql.error("select ts as t, derivative(c3, 1h, 0) from t1") + tdSql.error("select ts as t, derivative(c4, 1h, 0) from t1") + tdSql.query("select ts as t, derivative(c5, 1h, 0) from t1") + tdSql.checkRows(5) + tdSql.error("select ts as t, derivative(c6, 1h, 0) from t1") + tdSql.error("select ts as t, derivative(t1, 1h, 0) from t1") + + tdSql.query("select ts as t, diff(c1) from t1") + tdSql.checkRows(5) + tdSql.checkCols(3) + for i in range(5): + data=tdSql.getData(i, 0) + tdSql.checkData(i, 1, data) + tdSql.query("select ts as t, diff(c1) from stb1 group by tbname") + tdSql.checkRows(500) + tdSql.checkCols(4) + tdSql.query("select ts as t, diff(c1) from t1") + tdSql.query("select ts as t, diff(c1) from t1") + tdSql.error("select ts as t, diff(c1) from stb1") + tdSql.query("select ts as t, diff(c2) from t1") + tdSql.checkRows(5) + tdSql.error("select ts as t, diff(c3) from t1") + tdSql.error("select ts as t, diff(c4) from t1") + tdSql.query("select ts as t, diff(c5) from t1") + tdSql.checkRows(5) + tdSql.error("select ts as t, diff(c6) from t1") + tdSql.error("select ts as t, diff(t1) from t1") + tdSql.error("select ts as t, diff(c1, c2) from t1") + + tdSql.error("select ts as t, bottom(c1, 0) from t1") + tdSql.query("select ts as t, bottom(c1, 5) from t1") + tdSql.checkRows(5) + tdSql.checkCols(3) + for i in range(5): + data=tdSql.getData(i, 0) + tdSql.checkData(i, 1, data) + tdSql.query("select ts as t, bottom(c1, 5) from stb1") + tdSql.checkRows(5) + tdSql.query("select ts as t, bottom(c1, 5) from stb1 group by tbname") + tdSql.checkRows(500) + tdSql.query("select ts as t, bottom(c1, 8) from t1") + tdSql.checkRows(6) + tdSql.query("select ts as t, bottom(c2, 8) from t1") + tdSql.checkRows(6) + tdSql.error("select ts as t, bottom(c3, 5) from t1") + tdSql.error("select ts as t, bottom(c4, 5) from t1") + tdSql.query("select ts as t, bottom(c5, 8) from t1") + tdSql.checkRows(6) + tdSql.error("select ts as t, bottom(c6, 5) from t1") + tdSql.error("select ts as t, bottom(c5, 8) as b from t1 order by b") + tdSql.error("select ts as t, bottom(t1, 1) from t1") + tdSql.error("select ts as t, bottom(t1, 1) from stb1") + tdSql.error("select ts as t, bottom(t1, 3) from stb1 order by c3") + tdSql.error("select ts as t, bottom(t1, 3) from t1 order by c3") + + + tdSql.error("select ts as t, top(c1, 0) from t1") + tdSql.query("select ts as t, top(c1, 5) from t1") + tdSql.checkRows(5) + tdSql.checkCols(3) + for i in range(5): + data=tdSql.getData(i, 0) + tdSql.checkData(i, 1, data) + tdSql.query("select ts as t, top(c1, 5) from stb1") + tdSql.checkRows(5) + tdSql.query("select ts as t, top(c1, 5) from stb1 group by tbname") + tdSql.checkRows(500) + tdSql.query("select ts as t, top(c1, 8) from t1") + tdSql.checkRows(6) + tdSql.query("select ts as t, top(c2, 8) from t1") + tdSql.checkRows(6) + tdSql.error("select ts as t, top(c3, 5) from t1") + tdSql.error("select ts as t, top(c4, 5) from t1") + tdSql.query("select ts as t, top(c5, 8) from t1") + tdSql.checkRows(6) + tdSql.error("select ts as t, top(c6, 5) from t1") + tdSql.error("select ts as t, top(c5, 8) as b from t1 order by b") + tdSql.error("select ts as t, top(t1, 1) from t1") + tdSql.error("select ts as t, top(t1, 1) from stb1") + tdSql.error("select ts as t, top(t1, 3) from stb1 order by c3") + tdSql.error("select ts as t, top(t1, 3) from t1 order by c3") + + tdDnodes.stop(1) + tdDnodes.start(1) + + tdSql.query("select ts as t, diff(c1) from t1") + tdSql.checkRows(5) + tdSql.checkCols(3) + for i in range(5): + data=tdSql.getData(i, 0) + tdSql.checkData(i, 1, data) + tdSql.query("select ts as t, diff(c1) from stb1 group by tbname") + tdSql.checkRows(500) + tdSql.checkCols(4) + tdSql.query("select ts as t, diff(c1) from t1") + tdSql.query("select ts as t, diff(c1) from t1") + tdSql.error("select ts as t, diff(c1) from stb1") + tdSql.query("select ts as t, diff(c2) from t1") + tdSql.checkRows(5) + tdSql.error("select ts as t, diff(c3) from t1") + tdSql.error("select ts as t, diff(c4) from t1") + tdSql.query("select ts as t, diff(c5) from t1") + tdSql.checkRows(5) + tdSql.error("select ts as t, diff(c6) from t1") + tdSql.error("select ts as t, diff(t1) from t1") + tdSql.error("select ts as t, diff(c1, c2) from t1") + + tdSql.error("select ts as t, bottom(c1, 0) from t1") + tdSql.query("select ts as t, bottom(c1, 5) from t1") + tdSql.checkRows(5) + tdSql.checkCols(3) + for i in range(5): + data=tdSql.getData(i, 0) + tdSql.checkData(i, 1, data) + tdSql.query("select ts as t, bottom(c1, 5) from stb1") + tdSql.checkRows(5) + tdSql.query("select ts as t, bottom(c1, 5) from stb1 group by tbname") + tdSql.checkRows(500) + tdSql.query("select ts as t, bottom(c1, 8) from t1") + tdSql.checkRows(6) + tdSql.query("select ts as t, bottom(c2, 8) from t1") + tdSql.checkRows(6) + tdSql.error("select ts as t, bottom(c3, 5) from t1") + tdSql.error("select ts as t, bottom(c4, 5) from t1") + tdSql.query("select ts as t, bottom(c5, 8) from t1") + tdSql.checkRows(6) + tdSql.error("select ts as t, bottom(c6, 5) from t1") + tdSql.error("select ts as t, bottom(c5, 8) as b from t1 order by b") + tdSql.error("select ts as t, bottom(t1, 1) from t1") + tdSql.error("select ts as t, bottom(t1, 1) from stb1") + tdSql.error("select ts as t, bottom(t1, 3) from stb1 order by c3") + tdSql.error("select ts as t, bottom(t1, 3) from t1 order by c3") + + + tdSql.error("select ts as t, top(c1, 0) from t1") + tdSql.query("select ts as t, top(c1, 5) from t1") + tdSql.checkRows(5) + tdSql.checkCols(3) + for i in range(5): + data=tdSql.getData(i, 0) + tdSql.checkData(i, 1, data) + tdSql.query("select ts as t, top(c1, 5) from stb1") + tdSql.checkRows(5) + tdSql.query("select ts as t, top(c1, 5) from stb1 group by tbname") + tdSql.checkRows(500) + tdSql.query("select ts as t, top(c1, 8) from t1") + tdSql.checkRows(6) + tdSql.query("select ts as t, top(c2, 8) from t1") + tdSql.checkRows(6) + tdSql.error("select ts as t, top(c3, 5) from t1") + tdSql.error("select ts as t, top(c4, 5) from t1") + tdSql.query("select ts as t, top(c5, 8) from t1") + tdSql.checkRows(6) + tdSql.error("select ts as t, top(c6, 5) from t1") + tdSql.error("select ts as t, top(c5, 8) as b from t1 order by b") + tdSql.error("select ts as t, top(t1, 1) from t1") + tdSql.error("select ts as t, top(t1, 1) from stb1") + tdSql.error("select ts as t, top(t1, 3) from stb1 order by c3") + tdSql.error("select ts as t, top(t1, 3) from t1 order by c3") + pass + + def apercentile_query_form(self, col="c1", p=0, com=',', algo="'t-digest'", alias="", table_expr="t1", condition=""): + + ''' + apercentile function: + :param col: string, column name, required parameters; + :param p: float, percentile interval, [0,100], required parameters; + :param algo: string, alforithm, real form like: ', algorithm' , algorithm: {type:int, data:[0, 1]}; + :param alias: string, result column another name; + :param table_expr: string or expression, data source(eg,table/stable name, result set), required parameters; + :param condition: expression; + :param args: other funtions,like: ', last(col)' + :return: apercentile query statement,default: select apercentile(c1, 0, 1) from t1 + ''' + + return f"select apercentile({col}, {p}{com} {algo}) {alias} from {table_expr} {condition}" + + def checkapert(self,col="c1", p=0, com=',', algo='"t-digest"', alias="", table_expr="t1", condition="" ): + + tdSql.query(f"select count({col}) from {table_expr} {condition}") + if tdSql.queryRows == 0: + tdSql.query(self.apercentile_query_form( + col=col, p=p, com=com, algo=algo, alias=alias, table_expr=table_expr, condition=condition + )) + tdSql.checkRows(0) + return + + pset = [0, 40, 60, 100] + if p not in pset: + pset.append(p) + + if "stb" in table_expr: + tdSql.query(f"select spread({col}) from stb1") + else: + tdSql.query(f"select avg(c1) from (select spread({col.split('.')[-1]}) c1 from stb1 group by tbname)") + spread_num = tdSql.getData(0, 0) + + for pi in pset: + + if "group" in condition: + tdSql.query(f"select last_row({col}) from {table_expr} {condition}") + query_result = tdSql.queryResult + query_rows = tdSql.queryRows + for i in range(query_rows): + pre_condition = condition.replace("slimit",'limit').replace("group by tbname", "").split("soffset")[0] + tbname = query_result[i][-1] + tdSql.query(f"select percentile({col}, {pi}) {alias} from {tbname} {pre_condition}") + print(tdSql.sql) + pre_data = tdSql.getData(0, 0) + tdSql.query(self.apercentile_query_form( + col=col, p=pi, com=com, algo='"t-digest"', alias=alias, table_expr=table_expr, condition=condition + )) + if abs(tdSql.getData(i, 0)) >= (spread_num*0.02): + tdSql.checkDeviaRation(i, 0, pre_data, 0.1) + else: + devia = abs((tdSql.getData(i, 0) - pre_data) / (spread_num * 0.02)) + if devia < 0.5: + tdLog.info(f"sql:{tdSql.sql}, result data:{tdSql.getData(i, 0)}, expect data:{pre_data}, " + f"actual deviation:{devia} <= expect deviation: 0.01") + else: + tdLog.exit( + f"[{inspect.getframeinfo(inspect.stack()[1][0]).lineno}],check failed:sql:{tdSql.sql}, " + f"result data:{tdSql.getData(i, 0)}, expect data:{pre_data}, " + f"actual deviation:{devia} > expect deviation: 0.01") + + # if "group" in condition: + # tdSql.query(self.apercentile_query_form( + # col=col, p=pi, com=com, algo='"default"', alias=alias, table_expr=table_expr, condition=condition + # )) + # query_result = tdSql.queryResult + # query_rows = tdSql.queryRows + # tdSql.query(self.apercentile_query_form( + # col=col, p=pi, com=com, algo='"t-digest"', alias=alias, table_expr=table_expr, condition=condition + # )) + # for i in range(query_rows): + # if abs(tdSql.getData(i, 0)) >= (spread_num*0.02): + # tdSql.checkDeviaRation(i, 0, query_result[i][0], 0.1) + # else: + # devia = abs((tdSql.getData(i, 0) - query_result[i][0]) / (spread_num * 0.02)) + # if devia < 0.5: + # tdLog.info(f"sql:{tdSql.sql}, result data:{tdSql.getData(i, 0)}, expect data:{tdSql.queryResult[i][0]}, " + # f"actual deviation:{devia} <= expect deviation: 0.01") + # else: + # tdLog.exit( + # f"[{inspect.getframeinfo(inspect.stack()[1][0]).lineno}],check failed:sql:{tdSql.sql}, " + # f"result data:{tdSql.getData(i, 0)}, expect data:{tdSql.queryResult[i][0]}, " + # f"actual deviation:{devia} > expect deviation: 0.01") + + else: + if ',' in alias or not alias: + tdSql.query(f"select {col} from {table_expr} {condition}") + elif "stb" not in table_expr: + tdSql.query(f"select percentile({col}, {pi}) {alias} from {table_expr} {condition}") + else: + tdSql.query(self.apercentile_query_form( + col=col, p=pi, com=com, algo='"default"', alias=alias, table_expr=table_expr, condition=condition + )) + query_result = np.array(tdSql.queryResult)[np.array(tdSql.queryResult) != None] + tdSql.query(self.apercentile_query_form( + col=col, p=pi, com=com, algo=algo, alias=alias, table_expr=table_expr, condition=condition + )) + + if abs(tdSql.getData(0, 0)) >= (spread_num * 0.02): + tdSql.checkDeviaRation(0, 0, np.percentile(query_result, pi), 0.1) + else: + devia = abs((tdSql.getData(0, 0) - np.percentile(query_result, pi)) / (spread_num * 0.02)) + if devia < 0.5: + tdLog.info( + f"sql:{tdSql.sql}, result data:{tdSql.getData(0, 0)}, expect data:{np.percentile(query_result, pi)}, " + f"actual deviation:{devia} <= expect deviation: 0.01") + else: + tdLog.exit( + f"[{inspect.getframeinfo(inspect.stack()[1][0]).lineno}],check failed:sql:{tdSql.sql}, " + f"result data:{tdSql.getData(0, 0)}, expect data:{np.percentile(query_result, pi)}, " + f"actual deviation:{devia} > expect deviation: 0.01") + + + def apercentile_query(self): + + # table schema :ts timestamp, c1 int, c2 float, c3 timestamp, c4 binary(16), c5 double, c6 bool + # c7 bigint, c8 smallint, c9 tinyint, c10 nchar(16) + + # case1: int col + self.checkapert() + # case2: float col + case2 = {'col':'c2'} + self.checkapert(**case2) + # case3: double col + case3 = {'col':'c5'} + self.checkapert(**case3) + # case4: bigint col + case4 = {'col':'c7'} + self.checkapert(**case4) + # case5: smallint col + case5 = {'col':'c8'} + self.checkapert(**case5) + # case6: tinyint col + case6 = {'col':'c9'} + self.checkapert(**case6) + # case7: stable + case7 = {'table_expr':'stb1'} + self.checkapert(**case7) + # case8: nest query, outquery + case8 = {'table_expr':'(select c1 from t1)'} + self.checkapert(**case8) + # case9: nest query, inquery and out query + case9 = {'table_expr':'(select apercentile(c1, 0) as c1 from t1)'} + self.checkapert(**case9) + + # case10: nest query, inquery + tdSql.query("select * from (select c1 from stb1)") + if tdSql.queryRows == 0: + tdSql.query("select * from (select apercentile(c1,0) c1 from stb1)") + tdSql.checkRows(0) + else: + query_result = np.array(tdSql.queryResult)[np.array(tdSql.queryResult) != None] + tdSql.query("select * from (select apercentile(c1, 0) c1 from stb1)") + tdSql.checkDeviaRation(0, 0, np.percentile(query_result, 0), 0.1) + tdSql.query("select * from (select apercentile(c1,100) c1 from stb1)") + tdSql.checkDeviaRation(0, 0, np.percentile(query_result, 100), 0.1) + tdSql.query("select * from (select apercentile(c1,40) c1 from stb1)") + tdSql.checkDeviaRation(0, 0, np.percentile(query_result, 40), 0.1) + + # case11: no algorithm = algo:0 + case11 = {'com':'', 'algo': ''} + self.checkapert(**case11) + + # case12~14: p: bin/oct/hex + case12 = {'p': 0b1100100} + self.checkapert(**case12) + case13 = {'algo':'"T-DIGEST"'} + self.checkapert(**case13) + case14 = {'p':0x32, 'algo':'"DEFAULT"'} + self.checkapert(**case14) + + # case15~21: mix with aggregate function + case15 = {'alias':', count(*)'} + self.checkapert(**case15) + case16 = {'alias':', avg(c1)'} + self.checkapert(**case16) + case17 = {'alias':', twa(c1)'} + self.checkapert(**case17) + case18 = {'alias':', irate(c1)'} + self.checkapert(**case18) + case19 = {'alias':', sum(c1)'} + self.checkapert(**case19) + case20 = {'alias':', stddev(c1)'} + self.checkapert(**case20) + case21 = {'alias':', leastsquares(c1, 1, 1)'} + self.checkapert(**case21) + + # case22~27:mix with selector function + case22 = {'alias':', min(c1)'} + self.checkapert(**case22) + case23 = {'alias':', max(c1)'} + self.checkapert(**case23) + case24 = {'alias':', first(c1)'} + self.checkapert(**case24) + case25 = {'alias':', last(c1)'} + self.checkapert(**case25) + case26 = {'alias':', percentile(c1, 0)'} + self.checkapert(**case26) + case27 = {'alias':', apercentile(c1, 0, "t-digest")'} + self.checkapert(**case27) + + # case28~29: mix with computing function + case28 = {'alias':', spread(c1)'} + self.checkapert(**case28) + # case29: mix with four operation + case29 = {'alias':'+ spread(c1)'} + self.checkapert(**case29) + + # case30~36: with condition + case30 = {'condition':'where ts > now'} + self.checkapert(**case30) + case31 = {'condition':'where c1 between 1 and 200'} + self.checkapert(**case31) + case32 = {'condition':f'where c1 in {tuple(i for i in range(200))}'} + self.checkapert(**case32) + case33 = {'condition':'where c1>100 and c2<100'} + self.checkapert(**case33) + case34 = {'condition':'where c1 is not null'} + self.checkapert(**case34) + case35 = {'condition':'where c4 like "_inary%"'} + self.checkapert(**case35) + case36 = {'table_expr':'stb1' ,'condition':'where tbname like "t_"'} + self.checkapert(**case36) + + # case37~38: with join + case37 = {'col':'t1.c1','table_expr':'t1, t2 ','condition':'where t1.ts=t2.ts'} + self.checkapert(**case37) + case38 = {'col':'stb1.c1', 'table_expr':'stb1, stb2', 'condition':'where stb1.ts=stb2.ts and stb1.st1=stb2.st2'} + self.checkapert(**case38) + + # case39: with group by + case39 = {'table_expr':'stb1', 'condition':'group by tbname'} + self.checkapert(**case39) + + # case40: with slimit + case40 = {'table_expr':'stb1', 'condition':'group by tbname slimit 1'} + self.checkapert(**case40) + + # case41: with soffset + case41 = {'table_expr':'stb1', 'condition':'group by tbname slimit 1 soffset 1'} + self.checkapert(**case41) + + # case42: with order by + case42 = {'table_expr':'stb1' ,'condition':'order by ts'} + self.checkapert(**case42) + case43 = {'table_expr':'t1' ,'condition':'order by ts'} + self.checkapert(**case43) + + # case44: with limit offset + case44 = {'table_expr':'stb1', 'condition':'group by tbname limit 1'} + self.checkapert(**case44) + case45 = {'table_expr':'stb1', 'condition':'group by tbname limit 1 offset 1'} + self.checkapert(**case45) + + pass + + def error_apercentile(self): + + # unusual test + # + # table schema :ts timestamp, c1 int, c2 float, c3 timestamp, c4 binary(16), c5 double, c6 bool + # c7 bigint, c8 smallint, c9 tinyint, c10 nchar(16) + # + # form test + tdSql.error(self.apercentile_query_form(col="",com='',algo='')) # no col , no algorithm + tdSql.error(self.apercentile_query_form(col="")) # no col , algorithm + tdSql.error(self.apercentile_query_form(p='',com='',algo='')) # no p , no algorithm + tdSql.error(self.apercentile_query_form(p='')) # no p , algorithm + tdSql.error("apercentile( c1, 100) from t1") # no select + tdSql.error("select apercentile from t1") # no algorithm condition + tdSql.error("select apercentile c1,0 from t1") # no brackets + tdSql.error("select apercentile (c1,0) t1") # no from + tdSql.error(self.apercentile_query_form(col='(c1,0)',p='',com='',algo='')) # no p , no algorithm + tdSql.error("select apercentile( (c1,0) ) from t1") # no table_expr + tdSql.error("select apercentile{ (c1,0) } from t1") # sql form error 1 + tdSql.error("select apercentile[ (c1,0) ] from t1") # sql form error 2 + tdSql.error("select [apercentile(c1,0) ] from t1") # sql form error 3 + tdSql.error("select apercentile((c1, 0), 'default') from t1") # sql form error 5 + tdSql.error("select apercentile(c1, (0, 'default')) from t1") # sql form error 6 + tdSql.error("select apercentile(c1, (0), 1) from t1") # sql form error 7 + tdSql.error("select apercentile([c1, 0], 'default') from t1") # sql form error 8 + tdSql.error("select apercentile(c1, [0, 'default']) from t1") # sql form error 9 + tdSql.error("select apercentile(c1, {0, 'default'}) from t1") # sql form error 10 + tdSql.error("select apercentile([c1, 0]) from t1") # sql form error 11 + tdSql.error("select apercentile({c1, 0}) from t1") # sql form error 12 + tdSql.error("select apercentile(c1) from t1") # agrs: 1 + tdSql.error("select apercentile(c1, 0, 'default', 0) from t1") # agrs: 4 + tdSql.error("select apercentile(c1, 0, 0, 'default') from t1") # agrs: 4 + tdSql.error("select apercentile() from t1") # agrs: null 1 + tdSql.error("select apercentile from t1") # agrs: null 2 + tdSql.error("select apercentile( , , ) from t1") # agrs: null 3 + tdSql.error(self.apercentile_query_form(col='', p='', algo='')) # agrs: null 4 + tdSql.error(self.apercentile_query_form(col="st1")) # col:tag column + tdSql.error(self.apercentile_query_form(col=123)) # col:numerical + tdSql.error(self.apercentile_query_form(col=True)) # col:bool + tdSql.error(self.apercentile_query_form(col='')) # col:'' + tdSql.error(self.apercentile_query_form(col="last(c1)")) # col:expr + tdSql.error(self.apercentile_query_form(col="t%")) # col:non-numerical + tdSql.error(self.apercentile_query_form(col="c3")) # col-type: timestamp + tdSql.error(self.apercentile_query_form(col="c4")) # col-type: binary + tdSql.error(self.apercentile_query_form(col="c6")) # col-type: bool + tdSql.error(self.apercentile_query_form(col="c10")) # col-type: nchar + tdSql.error(self.apercentile_query_form(p=True)) # p:bool + tdSql.error(self.apercentile_query_form(p='a')) # p:str + tdSql.error(self.apercentile_query_form(p='last(*)')) # p:expr + tdSql.error(self.apercentile_query_form(p="2021-08-01 00:00:00.000")) # p:timestamp + tdSql.error(self.apercentile_query_form(algo='t-digest')) # algorithm:str + tdSql.error(self.apercentile_query_form(algo='"t_digest"')) # algorithm:str + tdSql.error(self.apercentile_query_form(algo='"t-digest0"')) # algorithm:str + tdSql.error(self.apercentile_query_form(algo='"t-digest."')) # algorithm:str + tdSql.error(self.apercentile_query_form(algo='"t-digest%"')) # algorithm:str + tdSql.error(self.apercentile_query_form(algo='"t-digest*"')) # algorithm:str + tdSql.error(self.apercentile_query_form(algo='tdigest')) # algorithm:str + tdSql.error(self.apercentile_query_form(algo=2.0)) # algorithm:float + tdSql.error(self.apercentile_query_form(algo=1.9999)) # algorithm:float + tdSql.error(self.apercentile_query_form(algo=-0.9999)) # algorithm:float + tdSql.error(self.apercentile_query_form(algo=-1.0)) # algorithm:float + tdSql.error(self.apercentile_query_form(algo=0b1)) # algorithm:float + tdSql.error(self.apercentile_query_form(algo=0x1)) # algorithm:float + tdSql.error(self.apercentile_query_form(algo=0o1)) # algorithm:float + tdSql.error(self.apercentile_query_form(algo=True)) # algorithm:bool + tdSql.error(self.apercentile_query_form(algo="True")) # algorithm:bool + tdSql.error(self.apercentile_query_form(algo='2021-08-01 00:00:00.000')) # algorithm:timestamp + tdSql.error(self.apercentile_query_form(algo='last(c1)')) # algorithm:expr + + # boundary test + tdSql.error(self.apercentile_query_form(p=-1)) # p left out of [0, 100] + tdSql.error(self.apercentile_query_form(p=-9223372036854775809)) # p left out of bigint + tdSql.error(self.apercentile_query_form(p=100.1)) # p right out of [0, 100] + tdSql.error(self.apercentile_query_form(p=18446744073709551616)) # p right out of unsigned-bigint + tdSql.error(self.apercentile_query_form(algo=-1)) # algorithm left out of [0, 1] + tdSql.error(self.apercentile_query_form(algo=-9223372036854775809)) # algorithm left out of unsigned-bigint + tdSql.error(self.apercentile_query_form(algo=2)) # algorithm right out of [0, 1] + tdSql.error(self.apercentile_query_form(algo=18446744073709551616)) # algorithm right out of unsigned-bigint + + # mix function test + tdSql.error(self.apercentile_query_form(alias=', top(c1,1)')) # mix with top function + tdSql.error(self.apercentile_query_form(alias=', top(c1,1)')) # mix with bottom function + tdSql.error(self.apercentile_query_form(alias=', last_row(c1)')) # mix with last_row function + tdSql.error(self.apercentile_query_form(alias=', distinct c1 ')) # mix with distinct function + tdSql.error(self.apercentile_query_form(alias=', *')) # mix with * + tdSql.error(self.apercentile_query_form(alias=', diff(c1)')) # mix with diff function + tdSql.error(self.apercentile_query_form(alias=', interp(c1)', condition='ts="2021-10-10 00:00:00.000"')) # mix with interp function + tdSql.error(self.apercentile_query_form(alias=', derivative(c1, 10m, 0)')) # mix with derivative function + tdSql.error(self.apercentile_query_form(alias=', diff(c1)')) # mix with diff function + tdSql.error(self.apercentile_query_form(alias='+ c1)')) # mix with four operation + + def apercentile_data(self, tbnum, data_row, basetime): + for i in range(tbnum): + for j in range(data_row): + tdSql.execute( + f"insert into t{i} values (" + f"{basetime + j*10}, {random.randint(-200, -1)}, {random.uniform(200, -1)}, {basetime + random.randint(-200, -1)}, " + f"'binary_{j}', {random.uniform(-200, -1)}, {random.choice([0,1])}, {random.randint(-200,-1)}, " + f"{random.randint(-200, -1)}, {random.randint(-127, -1)}, 'nchar_{j}' )" + ) + + tdSql.execute( + f"insert into t{i} values (" + f"{basetime - (j+1) * 10}, {random.randint(1, 200)}, {random.uniform(1, 200)}, {basetime - random.randint(1, 200)}, " + f"'binary_{j}_1', {random.uniform(1, 200)}, {random.choice([0, 1])}, {random.randint(1,200)}, " + f"{random.randint(1,200)}, {random.randint(1,127)}, 'nchar_{j}_1' )" + ) + tdSql.execute( + f"insert into tt{i} values ( {basetime-(j+1) * 10}, {random.randint(1, 200)} )" + ) + + pass + + def td6108(self): + tdLog.printNoPrefix("==========TD-6108==========") + tdSql.execute("drop database if exists db") + tdSql.execute("create database if not exists db keep 3650") + tdSql.execute("use db") + + tdSql.execute( + "create stable db.stb1 (\ + ts timestamp, c1 int, c2 float, c3 timestamp, c4 binary(16), c5 double, c6 bool, \ + c7 bigint, c8 smallint, c9 tinyint, c10 nchar(16)\ + ) \ + tags(st1 int)" + ) + tdSql.execute( + "create stable db.stb2 (ts timestamp, c1 int) tags(st2 int)" + ) + tbnum = 10 + for i in range(tbnum): + tdSql.execute(f"create table t{i} using stb1 tags({i})") + tdSql.execute(f"create table tt{i} using stb2 tags({i})") + + tdLog.printNoPrefix("######## no data test:") + self.apercentile_query() + self.error_apercentile() + + tdLog.printNoPrefix("######## insert data test:") + nowtime = int(round(time.time() * 1000)) + per_table_rows = 1000 + self.apercentile_data(tbnum, per_table_rows, nowtime) + self.apercentile_query() + self.error_apercentile() + + tdLog.printNoPrefix("######## insert data with NULL test:") + tdSql.execute(f"insert into t1(ts) values ({nowtime-5})") + tdSql.execute(f"insert into t1(ts) values ({nowtime+5})") + self.apercentile_query() + self.error_apercentile() + + tdLog.printNoPrefix("######## check after WAL test:") + tdSql.query("show dnodes") + index = tdSql.getData(0, 0) + tdDnodes.stop(index) + tdDnodes.start(index) + + self.apercentile_query() + self.error_apercentile() + + + def run(self): + + self.td4097() + + # master branch + self.td3690() + # self.td4082() + self.td4288() + self.td4724() + self.td5935() + self.td6068() + + # self.td5168() + # self.td5433() + # self.td5798() + + # develop branch + # self.td4889() In the scenario that with vnode/wal/wal* but without meta/data in vnode, the status is reset to 0 right now. + self.td5798() + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) + + + diff --git a/tests/pytest/functions/showOfflineThresholdIs864000.py b/tests/pytest/functions/showOfflineThresholdIs864000.py new file mode 100644 index 0000000000000000000000000000000000000000..7462d4cd72f600674fcb82aa1224019787d23fd5 --- /dev/null +++ b/tests/pytest/functions/showOfflineThresholdIs864000.py @@ -0,0 +1,47 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import numpy as np + +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug(f"start to execute {__file__}") + tdSql.init(conn.cursor(), logSql) + + def run(self): + # tdSql.query("show variables") + # tdSql.checkData(54, 1, 864000) + tdSql.execute("show variables") + res = tdSql.cursor.fetchall() + resList = np.array(res) + index = np.where(resList == "offlineThreshold") + index_value = np.dstack((index[0])).squeeze() + tdSql.query("show variables") + tdSql.checkData(index_value, 1, 864000) + pass + + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/variable_httpDbNameMandatory.py b/tests/pytest/functions/variable_httpDbNameMandatory.py new file mode 100644 index 0000000000000000000000000000000000000000..1cd2516ec9303f2f038bc22a69afcd01bce3a930 --- /dev/null +++ b/tests/pytest/functions/variable_httpDbNameMandatory.py @@ -0,0 +1,152 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import subprocess +import random +import math +import numpy as np +import inspect + +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +from requests.auth import HTTPBasicAuth +import requests +import json + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug(f"start to execute {__file__}") + tdSql.init(conn.cursor(), logSql) + + def getBuildPath(self) -> str: + selfPath = os.path.dirname(os.path.realpath(__file__)) + global cfgPath + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + cfgPath = projPath + "/community/sim/dnode1/cfg" + else: + projPath = selfPath[:selfPath.find("tests")] + cfgPath = projPath + "/sim/dnode1/cfg" + + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/debug/build/bin")] + break + return buildPath + + def getCfgDir(self) -> str: + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + cfgDir = self.getBuildPath() + "/community/sim/dnode1/cfg" + + else: + cfgDir = self.getBuildPath() + "/sim/dnode1/cfg" + + return cfgDir + + def getCfgFile(self) -> str: + return self.getCfgDir()+"/taos.cfg" + + def rest_query(self,sql,db=''): + host = '127.0.0.1' + user = 'root' + password = 'taosdata' + port =6041 + if db == '': + url = "http://{}:{}/rest/sql".format(host, port ) + else: + url = "http://{}:{}/rest/sql/{}".format(host, port, db ) + try: + r = requests.post(url, + data = 'use db' , + auth = HTTPBasicAuth('root', 'taosdata')) + r = requests.post(url, + data = sql, + auth = HTTPBasicAuth('root', 'taosdata')) + except: + print("REST API Failure (TODO: more info here)") + raise + rj = dict(r.json()['data']) + return rj + + def TS834(self): + tdLog.printNoPrefix("==========TS-782==========") + tdSql.prepare() + buildPath = self.getBuildPath() + cfgfile = cfgPath + "/taos.cfg" + + tdSql.execute("show variables") + res_com = tdSql.cursor.fetchall() + rescomlist = np.array(res_com) + cpms_index = np.where(rescomlist == "httpDbNameMandatory") + index_value = np.dstack((cpms_index[0])).squeeze() + + tdSql.query("show variables") + tdSql.checkData(index_value, 1, 0) + + rj = self.rest_query("show variables") + if 'httpDbNameMandatory' not in rj: + tdLog.info('has no httpDbNameMandatory shown') + tdLog.exit(1) + if rj['httpDbNameMandatory'] != '0': + tdLog.info('httpDbNameMandatory data:%s == expect:0'%rj['httpDbNameMandatory']) + tdLog.exit(1) + tdLog.info("httpDbNameMandatory by restful query data:%s == expect:0" % (rj['httpDbNameMandatory'])) + + tdSql.query("show dnodes") + index = tdSql.getData(0, 0) + tdLog.info("restart taosd ") + tdDnodes.stop(index) + cmd = f"echo 'httpDbNameMandatory 1' >> {cfgfile} " + try: + _ = subprocess.check_output(cmd, shell=True).decode("utf-8") + except Exception as e: + raise e + + tdDnodes.start(index) + tdSql.query("show variables") + tdSql.checkData(index_value, 1, 1) + + rj = self.rest_query("show variables", 'db') + if 'httpDbNameMandatory' not in rj: + tdLog.info('has no httpDbNameMandatory shown') + tdLog.exit(1) + if rj['httpDbNameMandatory'] != '1': + tdLog.info('httpDbNameMandatory data:%s == expect:0'%rj['httpDbNameMandatory']) + tdLog.exit(1) + tdLog.info("httpDbNameMandatory by restful query data:%s == expect:1" % (rj['httpDbNameMandatory'])) + + def run(self): + + #TS-834 https://jira.taosdata.com:18080/browse/TS-834 + self.TS834() + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) + + + diff --git a/tests/pytest/handle_crash_gen_val_log.sh b/tests/pytest/handle_crash_gen_val_log.sh new file mode 100755 index 0000000000000000000000000000000000000000..01cc62aaf88d5567135e539bc460ee46a5d4e3e9 --- /dev/null +++ b/tests/pytest/handle_crash_gen_val_log.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# Color setting +RED='\033[0;31m' +GREEN='\033[1;32m' +GREEN_DARK='\033[0;32m' +GREEN_UNDERLINE='\033[4;32m' +NC='\033[0m' +IN_TDINTERNAL="community" +TDIR=`pwd` +if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then + cd ../.. +else + cd ../../.. +fi +TOP_DIR=`pwd` +TAOSD_DIR=`find . -name "taosd"|grep -v community|head -n1` +nohup $TAOSD_DIR >/dev/null & +cd - +./crash_gen.sh --valgrind -p -t 10 -s 1000 -b 4 +pidof taosd|xargs kill -9 +grep 'start to execute\|ERROR SUMMARY' valgrind.err|grep -v 'grep'|uniq|tee crash_gen_mem_err.log + +for memError in `grep 'ERROR SUMMARY' crash_gen_mem_err.log | awk '{print $4}'` +do +memError=(${memError//,/}) +if [ -n "$memError" ]; then + if [ "$memError" -gt 12 ]; then + echo -e "${RED} ## Memory errors number valgrind reports is $memError.\ + More than our threshold! ## ${NC}" + fi +fi +done + +grep 'start to execute\|definitely lost:' valgrind.err|grep -v 'grep'|uniq|tee crash_gen-definitely-lost-out.log +for defiMemError in `grep 'definitely lost:' crash_gen-definitely-lost-out.log | awk '{print $7}'` +do +defiMemError=(${defiMemError//,/}) +if [ -n "$defiMemError" ]; then + if [ "$defiMemError" -gt 0 ]; then + cat valgrind.err + echo -e "${RED} ## Memory errors number valgrind reports \ + Definitely lost is $defiMemError. More than our threshold! ## ${NC}" + exit 8 + fi +fi +done diff --git a/tests/pytest/handle_taosd_val_log.sh b/tests/pytest/handle_taosd_val_log.sh new file mode 100755 index 0000000000000000000000000000000000000000..829bc682258ce051da17c265bb4634712c6cd0e8 --- /dev/null +++ b/tests/pytest/handle_taosd_val_log.sh @@ -0,0 +1,63 @@ +#!/bin/bash +# Color setting +RED='\033[0;31m' +GREEN='\033[1;32m' +GREEN_DARK='\033[0;32m' +GREEN_UNDERLINE='\033[4;32m' +NC='\033[0m' +IN_TDINTERNAL="community" +TDIR=`pwd` +if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then + cd ../.. +else + cd ../../.. +fi +TOP_DIR=`pwd` +TAOSD_DIR=`find . -name "taosd"|grep -v community|grep debug|head -n1` +VALGRIND_OUT=taosd_valgrind.out +VALGRIND_ERR=taosd_valgrind.err +rm -rf /var/lib/taos/* +# nohup valgrind --tool=memcheck --leak-check=yes $TAOSD_DIR > $TDIR/$VALGRIND_OUT 2> $TDIR/$VALGRIND_ERR & +nohup valgrind --leak-check=yes $TAOSD_DIR > $TDIR/$VALGRIND_OUT 2> $TDIR/$VALGRIND_ERR & +sleep 20 +cd - +./crash_gen.sh -p -t 10 -s 1000 +ps -ef |grep valgrind|grep -v grep|awk '{print $2}'|xargs kill -term +while true +do + monitoring=` ps -ef|grep valgrind |grep -v grep| wc -l` + if [ $monitoring -eq 0 ] + then + echo "Manipulator is not running " + break + else + sleep 1 + fi +done + +grep 'start to execute\|ERROR SUMMARY' $VALGRIND_ERR | grep -v 'grep' | uniq | tee taosd_mem_err.log + +for memError in `grep 'ERROR SUMMARY' taosd_mem_err.log | awk '{print $4}'` +do +memError=(${memError//,/}) +if [ -n "$memError" ]; then + if [ "$memError" -gt 12 ]; then + echo -e "${RED} ## Memory errors number valgrind reports is $memError.\ + More than our threshold! ## ${NC}" + fi +fi +done + +grep 'start to execute\|definitely lost:' $VALGRIND_ERR|grep -v 'grep'|uniq|tee taosd-definitely-lost-out.log +for defiMemError in `grep 'definitely lost:' taosd-definitely-lost-out.log | awk '{print $7}'` +do +defiMemError=(${defiMemError//,/}) +if [ -n "$defiMemError" ]; then + if [ "$defiMemError" -gt 0 ]; then + cat $VALGRIND_ERR + echo -e "${RED} ## Memory errors number valgrind reports \ + Definitely lost is $defiMemError. More than our threshold! ## ${NC}" + exit 8 + fi +fi +done diff --git a/tests/pytest/handle_val_log.sh b/tests/pytest/handle_val_log.sh new file mode 100755 index 0000000000000000000000000000000000000000..142cf1074552256d712bcef891fff74d4f4396b0 --- /dev/null +++ b/tests/pytest/handle_val_log.sh @@ -0,0 +1,29 @@ +# Color setting +RED='\033[0;31m' +GREEN='\033[1;32m' +GREEN_DARK='\033[0;32m' +GREEN_UNDERLINE='\033[4;32m' +NC='\033[0m' + +grep 'start to execute\|ERROR SUMMARY' mem-error-out.log|grep -v 'grep'|uniq|tee uniq-mem-error-out.log + +for memError in `grep 'ERROR SUMMARY' uniq-mem-error-out.log | awk '{print $4}'` +do +if [ -n "$memError" ]; then + if [ "$memError" -gt 12 ]; then + echo -e "${RED} ## Memory errors number valgrind reports is $memError.\ + More than our threshold! ## ${NC}" + fi +fi +done + +grep 'start to execute\|definitely lost:' mem-error-out.log|grep -v 'grep'|uniq|tee uniq-definitely-lost-out.log +for defiMemError in `grep 'definitely lost:' uniq-definitely-lost-out.log | awk '{print $7}'` +do +if [ -n "$defiMemError" ]; then + if [ "$defiMemError" -gt 13 ]; then + echo -e "${RED} ## Memory errors number valgrind reports \ + Definitely lost is $defiMemError. More than our threshold! ## ${NC}" + fi +fi +done \ No newline at end of file diff --git a/tests/pytest/hivemq-extension-test.py b/tests/pytest/hivemq-extension-test.py new file mode 100644 index 0000000000000000000000000000000000000000..9d293ea5edfc02ba4f22ee06c57735c62249f496 --- /dev/null +++ b/tests/pytest/hivemq-extension-test.py @@ -0,0 +1,249 @@ +#!/usr/bin/python3 +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### +# install pip +# pip install src/connector/python/ +import sys +import os +import os.path +import time +import glob +import getopt +import subprocess +from shutil import which +from multipledispatch import dispatch + + +@dispatch(str, str) +def v_print(msg: str, arg: str): + if verbose: + print(msg % arg) + + +@dispatch(str, int) +def v_print(msg: str, arg: int): + if verbose: + print(msg % int(arg)) + + +@dispatch(str, int, int) +def v_print(msg: str, arg1: int, arg2: int): + if verbose: + print(msg % (int(arg1), int(arg2))) + + +@dispatch(str, int, int, int) +def v_print(msg: str, arg1: int, arg2: int, arg3: int): + if verbose: + print(msg % (int(arg1), int(arg2), int(arg3))) + + +@dispatch(str, int, int, int, int) +def v_print(msg: str, arg1: int, arg2: int, arg3: int, arg4: int): + if verbose: + print(msg % (int(arg1), int(arg2), int(arg3), int(arg4))) + + +def isHiveMQInstalled(): + v_print("%s", "Check if HiveMQ installed") + defaultHiveMQPath = "/opt/hivemq*" + hiveMQDir = glob.glob(defaultHiveMQPath) + if (len(hiveMQDir) == 0): + v_print("%s", "ERROR: HiveMQ NOT found") + return False + else: + v_print("HiveMQ installed at %s", hiveMQDir[0]) + return True + + +def isMosquittoInstalled(): + v_print("%s", "Check if mosquitto installed") + if not which('mosquitto_pub'): + v_print("%s", "ERROR: mosquitto is NOT installed") + return False + else: + return True + + +def installExtension(): + currentDir = os.getcwd() + extDir = 'src/connector/hivemq-tdengine-extension' + os.chdir('../..') + os.system('git submodule update --init -- %s' % extDir) + os.chdir(extDir) + v_print("%s", "build extension..") + os.system('mvn clean package') + + tdExtensionZip = 'target/hivemq-tdengine-extension*.zip' + tdExtensionZipDir = glob.glob(tdExtensionZip) + + defaultHiveMQPath = "/opt/hivemq*" + hiveMQDir = glob.glob(defaultHiveMQPath) + extPath = hiveMQDir[0] + '/extensions' + + tdExtDir = glob.glob(extPath + '/hivemq-tdengine-extension') + if len(tdExtDir): + v_print("%s", "delete exist extension..") + os.system('rm -rf %s' % tdExtDir[0]) + + v_print("%s", "unzip extension..") + os.system('unzip %s -d %s' % (tdExtensionZipDir[0], extPath)) + + os.chdir(currentDir) + + +def stopProgram(prog: str): + psCmd = "ps ax|grep -w %s| grep -v grep | awk '{print $1}'" % prog + + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + while(processID): + killCmd = "kill -TERM %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + pass + + +def stopHiveMQ(): + stopProgram("hivemq.jar") + v_print("%s", "ERROR: HiveMQ is NOT running") + + +def checkProgramRunning(prog: str): + psCmd = "ps ax|grep -w %s| grep -v grep | awk '{print $1}'" % prog + + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + if not processID: + v_print("ERROR: %s is NOT running", prog) + return False + else: + return True + + +def runHiveMQ(): + defaultHiveMQPath = "/opt/hivemq*" + hiveMQDir = glob.glob(defaultHiveMQPath) + runPath = hiveMQDir[0] + '/bin/run.sh > /dev/null &' + os.system(runPath) + time.sleep(10) + + if not checkProgramRunning("hivemq.jar"): + return False + else: + v_print("%s", "hivemq is running") + return True + + +def getBuildPath(): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + binPath = '' + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + binPath = root[:len(root) - len("/build/bin")] + break + return binPath + + +def runTDengine(): + stopProgram("taosd") + + buildPath = getBuildPath() + + if (buildPath == ""): + v_print("%s", "ERROR: taosd NOT found!") + sys.exit(1) + else: + v_print("%s", "taosd found in %s" % buildPath) + + binPath = buildPath + "/build/bin/taosd" + + os.system('%s > /dev/null &' % binPath) + time.sleep(10) + if not checkProgramRunning("taosd"): + return False + else: + v_print("%s", "TDengine is running") + return True + + + +def reCreateDatabase(): + buildPath = getBuildPath() + binPath = buildPath + "/build/bin/taos" + + os.system('%s -s "DROP DATABASE IF EXISTS hivemq"' % binPath) + os.system('%s -s "CREATE DATABASE IF NOT EXISTS hivemq"' % binPath) + + +def sendMqttMsg(topic: str, payload: str): + testStr = 'mosquitto_pub -t %s -m "%s"' % (topic, payload) + os.system(testStr) + time.sleep(3) + + +def checkTDengineData(topic: str, payload: str): + buildPath = getBuildPath() + binPath = buildPath + "/build/bin/taos" + + output = subprocess.check_output( + '%s -s "select * from hivemq.mqtt_payload"' % + binPath, shell=True).decode('utf-8') + if (topic in output) and (payload in output): + v_print("%s", output) + return True + else: + v_print("%s", "ERROR: mqtt topic or payload NOT found") + return False + + +if __name__ == "__main__": + verbose = True + testTopic = 'test' + testPayload = 'hello world' + + if not isHiveMQInstalled(): + sys.exit(1) + + if not isMosquittoInstalled(): + sys.exit(1) + + stopHiveMQ() + + installExtension() + + if not runTDengine(): + sys.exit(1) + + reCreateDatabase() + + if not runHiveMQ(): + sys.exit(1) + + sendMqttMsg(testTopic, testPayload) + + if not checkTDengineData(testTopic, testPayload): + sys.exit(1) + + sys.exit(0) diff --git a/tests/pytest/import_merge/__init__.py b/tests/pytest/import_merge/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/pytest/import_merge/importBlock1H.py b/tests/pytest/import_merge/importBlock1H.py new file mode 100644 index 0000000000000000000000000000000000000000..fca37ff1b1e3a1f9129e9498076fc995ba8f0918 --- /dev/null +++ b/tests/pytest/import_merge/importBlock1H.py @@ -0,0 +1,72 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db cache 128') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info("one block can import 38 records") + + tdLog.info("================= step2") + tdLog.info("import 38 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 39): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(38) + + tdLog.info("================= step4") + tdLog.info("import 1 data before") + startTime = self.startTime - 1 + tdSql.execute('import into tb1 values(%ld, %d)' % (startTime, rid)) + + tdLog.info("================= step5") + tdSql.query('select * from tb1') + tdSql.checkRows(39) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importBlock1HO.py b/tests/pytest/import_merge/importBlock1HO.py new file mode 100644 index 0000000000000000000000000000000000000000..c853d3a6afe216c9de3bc2f19eabbed56bce2bb2 --- /dev/null +++ b/tests/pytest/import_merge/importBlock1HO.py @@ -0,0 +1,75 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db cache 128') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info("one block can import 38 records") + + tdLog.info("================= step2") + tdLog.info("import 38 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 39): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(38) + + tdLog.info("================= step4") + tdLog.info("import 10 data before with overlap") + startTime = self.startTime - 5 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 11): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step5") + tdSql.query('select * from tb1') + tdSql.checkRows(43) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importBlock1HPO.py b/tests/pytest/import_merge/importBlock1HPO.py new file mode 100644 index 0000000000000000000000000000000000000000..968f21f50f0d11f7e70c8b4fb809690ab04c6982 --- /dev/null +++ b/tests/pytest/import_merge/importBlock1HPO.py @@ -0,0 +1,77 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db cache 128') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info("one block can import 38 records") + + tdLog.info("================= step2") + tdLog.info("import 38 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 11): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + for rid in range(15, 43): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(38) + + tdLog.info("================= step4") + tdLog.info("import 20 data before with partly overlap") + startTime = self.startTime - 5 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 21): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step5") + tdSql.query('select * from tb1') + tdSql.checkRows(47) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importBlock1S.py b/tests/pytest/import_merge/importBlock1S.py new file mode 100644 index 0000000000000000000000000000000000000000..6a0ce18edfe96512d84c3132b465c253769ff38c --- /dev/null +++ b/tests/pytest/import_merge/importBlock1S.py @@ -0,0 +1,75 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db cache 128') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info("one block can import 38 records") + + tdLog.info("================= step2") + tdLog.info("import 38 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 39): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(38) + + tdLog.info("================= step4") + tdLog.info("import 50 data covering existing data") + startTime = self.startTime - 5 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 51): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step5") + tdSql.query('select * from tb1') + tdSql.checkRows(50) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importBlock1Sub.py b/tests/pytest/import_merge/importBlock1Sub.py new file mode 100644 index 0000000000000000000000000000000000000000..2eaf5fc26e0f901ba5dc2b0439f80c00bdada940 --- /dev/null +++ b/tests/pytest/import_merge/importBlock1Sub.py @@ -0,0 +1,75 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db cache 128') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info("one block can import 38 records") + + tdLog.info("================= step2") + tdLog.info("import 38 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 39): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(38) + + tdLog.info("================= step4") + tdLog.info("import 10 data totally repetitive") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 11): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step5") + tdSql.query('select * from tb1') + tdSql.checkRows(38) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importBlock1T.py b/tests/pytest/import_merge/importBlock1T.py new file mode 100644 index 0000000000000000000000000000000000000000..ffac67a7e11b7e5d26c14fe3b6a97769d9bf8322 --- /dev/null +++ b/tests/pytest/import_merge/importBlock1T.py @@ -0,0 +1,72 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db cache 128') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info("one block can import 38 records") + + tdLog.info("================= step2") + tdLog.info("import 38 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 39): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(38) + + tdLog.info("================= step4") + tdLog.info("import 1 data after") + startTime = self.startTime + 38 + tdSql.execute('import into tb1 values(%ld, %d)' % (startTime + 1, rid)) + + tdLog.info("================= step5") + tdSql.query('select * from tb1') + tdSql.checkRows(39) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importBlock1TO.py b/tests/pytest/import_merge/importBlock1TO.py new file mode 100644 index 0000000000000000000000000000000000000000..5d6c6624d94f21a4ad9252da227dd846e2363e76 --- /dev/null +++ b/tests/pytest/import_merge/importBlock1TO.py @@ -0,0 +1,75 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db cache 128') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info("one block can import 38 records") + + tdLog.info("================= step2") + tdLog.info("import 38 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 39): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(38) + + tdLog.info("================= step4") + tdLog.info("import 10 data later with overlap") + startTime = self.startTime + 30 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 11): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step5") + tdSql.query('select * from tb1') + tdSql.checkRows(40) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importBlock1TPO.py b/tests/pytest/import_merge/importBlock1TPO.py new file mode 100644 index 0000000000000000000000000000000000000000..e7807e892a4f0b889515674a2cde634d6cc7add9 --- /dev/null +++ b/tests/pytest/import_merge/importBlock1TPO.py @@ -0,0 +1,77 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db cache 128') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info("one block can import 38 records") + + tdLog.info("================= step2") + tdLog.info("import 38 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 31): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + for rid in range(35, 43): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(38) + + tdLog.info("================= step4") + tdLog.info("import 30 data later with partly overlap") + startTime = self.startTime + 25 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 31): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step5") + tdSql.query('select * from tb1') + tdSql.checkRows(55) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importBlock2H.py b/tests/pytest/import_merge/importBlock2H.py new file mode 100644 index 0000000000000000000000000000000000000000..eea1e4bcf809a5561fb4f93bf2e92832824f9d74 --- /dev/null +++ b/tests/pytest/import_merge/importBlock2H.py @@ -0,0 +1,72 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db cache 128') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info("one block can import 38 records") + + tdLog.info("================= step2") + tdLog.info("import 76 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 77): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(76) + + tdLog.info("================= step4") + tdLog.info("import 1 data before") + startTime = self.startTime - 1 + tdSql.execute('import into tb1 values(%ld, %d)' % (startTime, rid)) + + tdLog.info("================= step5") + tdSql.query('select * from tb1') + tdSql.checkRows(77) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importBlock2HO.py b/tests/pytest/import_merge/importBlock2HO.py new file mode 100644 index 0000000000000000000000000000000000000000..99a9662f1c3bc38c1cb08084eeebd9fd9a8cd20a --- /dev/null +++ b/tests/pytest/import_merge/importBlock2HO.py @@ -0,0 +1,75 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db cache 128') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info("one block can import 38 records") + + tdLog.info("================= step2") + tdLog.info("import 76 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 77): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(76) + + tdLog.info("================= step4") + tdLog.info("import 10 data before with overlap") + startTime = self.startTime - 5 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 11): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step5") + tdSql.query('select * from tb1') + tdSql.checkRows(81) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importBlock2HPO.py b/tests/pytest/import_merge/importBlock2HPO.py new file mode 100644 index 0000000000000000000000000000000000000000..54afef6c06d4beff95a8a5e8a5e9048d5b856529 --- /dev/null +++ b/tests/pytest/import_merge/importBlock2HPO.py @@ -0,0 +1,77 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db cache 128') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info("one block can import 38 records") + + tdLog.info("================= step2") + tdLog.info("import 76 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 11): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + for rid in range(15, 81): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(76) + + tdLog.info("================= step4") + tdLog.info("import 20 data before with partly overlap") + startTime = self.startTime - 5 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 21): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step5") + tdSql.query('select * from tb1') + tdSql.checkRows(85) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importBlock2S.py b/tests/pytest/import_merge/importBlock2S.py new file mode 100644 index 0000000000000000000000000000000000000000..9d4757709a7b58dcdecbe652c374169381f54112 --- /dev/null +++ b/tests/pytest/import_merge/importBlock2S.py @@ -0,0 +1,75 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db cache 128') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info("one block can import 38 records") + + tdLog.info("================= step2") + tdLog.info("import 76 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 77): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(76) + + tdLog.info("================= step4") + tdLog.info("import 90 data covering existing data") + startTime = self.startTime - 5 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 91): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step5") + tdSql.query('select * from tb1') + tdSql.checkRows(90) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importBlock2Sub.py b/tests/pytest/import_merge/importBlock2Sub.py new file mode 100644 index 0000000000000000000000000000000000000000..db43a492bcd5ee5fea81867d1887d47e83cc8f18 --- /dev/null +++ b/tests/pytest/import_merge/importBlock2Sub.py @@ -0,0 +1,75 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db cache 128') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info("one block can import 38 records") + + tdLog.info("================= step2") + tdLog.info("import 76 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 77): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(76) + + tdLog.info("================= step4") + tdLog.info("import 10 data totally repetitive") + startTime = self.startTime + 10 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 11): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step5") + tdSql.query('select * from tb1') + tdSql.checkRows(76) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importBlock2T.py b/tests/pytest/import_merge/importBlock2T.py new file mode 100644 index 0000000000000000000000000000000000000000..c0d85fa3b07d341f90a32d14cb1a62c7467cc4c2 --- /dev/null +++ b/tests/pytest/import_merge/importBlock2T.py @@ -0,0 +1,72 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db cache 128') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info("one block can import 38 records") + + tdLog.info("================= step2") + tdLog.info("import 76 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 77): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(76) + + tdLog.info("================= step4") + tdLog.info("import 1 data after") + startTime = self.startTime + 76 + tdSql.execute('import into tb1 values(%ld, %d)' % (startTime + 1, rid)) + + tdLog.info("================= step5") + tdSql.query('select * from tb1') + tdSql.checkRows(77) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importBlock2TO.py b/tests/pytest/import_merge/importBlock2TO.py new file mode 100644 index 0000000000000000000000000000000000000000..05692c336de67d48a0f973f5c296cfff6dc0f00e --- /dev/null +++ b/tests/pytest/import_merge/importBlock2TO.py @@ -0,0 +1,75 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db cache 128') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info("one block can import 38 records") + + tdLog.info("================= step2") + tdLog.info("import 76 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 77): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(76) + + tdLog.info("================= step4") + tdLog.info("import 10 data later with overlap") + startTime = self.startTime + 70 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 11): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step5") + tdSql.query('select * from tb1') + tdSql.checkRows(80) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importBlock2TPO.py b/tests/pytest/import_merge/importBlock2TPO.py new file mode 100644 index 0000000000000000000000000000000000000000..817d2db3827b7484d0134094aa2c6fb6aee61857 --- /dev/null +++ b/tests/pytest/import_merge/importBlock2TPO.py @@ -0,0 +1,77 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db cache 128') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info("one block can import 38 records") + + tdLog.info("================= step2") + tdLog.info("import 76 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 61): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + for rid in range(65, 81): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(76) + + tdLog.info("================= step4") + tdLog.info("import 30 data later with partly overlap") + startTime = self.startTime + 55 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 31): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step5") + tdSql.query('select * from tb1') + tdSql.checkRows(85) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importBlockbetween.py b/tests/pytest/import_merge/importBlockbetween.py new file mode 100644 index 0000000000000000000000000000000000000000..2e4ac8a7370af0c0645b0ff15aba62ff18be3ced --- /dev/null +++ b/tests/pytest/import_merge/importBlockbetween.py @@ -0,0 +1,78 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db cache 128') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info("one block can import 38 records") + + tdLog.info("================= step2") + tdLog.info("import 76 sequential data with gap between 2 blocks") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 39): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + for rid in range(40, 78): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(76) + + tdLog.info("================= step4") + tdLog.info("import data into the gap between 2 blocks") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(39, 40): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step5") + tdSql.query('select * from tb1') + tdSql.checkRows(77) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importCSV.py b/tests/pytest/import_merge/importCSV.py new file mode 100644 index 0000000000000000000000000000000000000000..24ebffd48530e20a9a4f0cc13d4784e997ba4a75 --- /dev/null +++ b/tests/pytest/import_merge/importCSV.py @@ -0,0 +1,96 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +import csv +import random +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self.csvfile = "/tmp/file.csv" + self.rows = 10000 + self.ntables = 1 + self.startTime = 1520000010000 + def genRandomStr(self, maxLen): + H = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' + salt = '' + if maxLen <= 1: + maxLen = 2 + l = random.randint(1,maxLen) + for i in range(l): + salt += random.choice(H) + return salt + def createCSVFile(self): + f = open(self.csvfile,'w',encoding='utf-8') + csv_writer = csv.writer(f, quoting=csv.QUOTE_NONNUMERIC) + for i in range(self.rows): + csv_writer.writerow([self.startTime + i, + self.genRandomStr(5), + self.genRandomStr(6), + self.genRandomStr(7), + self.genRandomStr(8), + self.genRandomStr(9), + self.genRandomStr(10), + self.genRandomStr(11), + self.genRandomStr(12), + self.genRandomStr(13), + self.genRandomStr(14)]) + f.close() + def destroyCSVFile(self): + os.remove(self.csvfile) + def run(self): + self.createCSVFile() + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db') + tdSql.execute('use db') + tdSql.execute('''create table tbx (ts TIMESTAMP, + collect_area NCHAR(5), + device_id BINARY(6), + imsi BINARY(7), + imei BINARY(8), + mdn BINARY(9), + net_type BINARY(10), + mno NCHAR(11), + province NCHAR(12), + city NCHAR(13), + alarm BINARY(14))''') + + tdSql.execute("import into tbx file \'%s\'"%(self.csvfile)) + tdSql.query('select * from tbx') + tdSql.checkRows(self.rows) + #TD-4447 import the same csv twice + tdSql.execute("import into tbx file \'%s\'"%(self.csvfile)) + + def stop(self): + self.destroyCSVFile() + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + tdDnodes.stop(1) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importCacheFileH.py b/tests/pytest/import_merge/importCacheFileH.py new file mode 100644 index 0000000000000000000000000000000000000000..33724dfa6889903a34836844271f5843c7cb36e4 --- /dev/null +++ b/tests/pytest/import_merge/importCacheFileH.py @@ -0,0 +1,88 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + + tdLog.info("================= step2") + tdLog.info("import 10 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 11): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(10) + + tdLog.info("================= step4") + tdDnodes.stop(1) + #tdLog.sleep(5) + tdDnodes.start(1) + + tdLog.info("================= step5") + tdLog.info("import 10 data again") + startTime = self.startTime + 10 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 11): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(20) + + tdLog.info("================= step7") + tdLog.info("import 1 data before") + startTime = self.startTime - 1 + tdSql.execute('import into tb1 values(%ld, %d)' % (startTime, rid)) + + tdLog.info("================= step8") + tdSql.query('select * from tb1') + tdSql.checkRows(21) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importCacheFileHO.py b/tests/pytest/import_merge/importCacheFileHO.py new file mode 100644 index 0000000000000000000000000000000000000000..9f552978f9bb5b0be72eb7cba7ebd073114e740b --- /dev/null +++ b/tests/pytest/import_merge/importCacheFileHO.py @@ -0,0 +1,91 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + + tdLog.info("================= step2") + tdLog.info("import 10 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 11): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(10) + + tdLog.info("================= step4") + tdDnodes.stop(1) + #tdLog.sleep(5) + tdDnodes.start(1) + + tdLog.info("================= step5") + tdLog.info("import 10 data again") + startTime = self.startTime + 10 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 11): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(20) + + tdLog.info("================= step7") + tdLog.info("import 10 data before with overlap") + startTime = self.startTime - 5 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 11): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step8") + tdSql.query('select * from tb1') + tdSql.checkRows(25) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importCacheFileHPO.py b/tests/pytest/import_merge/importCacheFileHPO.py new file mode 100644 index 0000000000000000000000000000000000000000..f2d0a3ddbfb4c0a2a111aab423e32c0ed4683e47 --- /dev/null +++ b/tests/pytest/import_merge/importCacheFileHPO.py @@ -0,0 +1,95 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + + tdLog.info("================= step2") + tdLog.info("import 9 sequential data with gap") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 11): + if (rid == 5): + continue + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(9) + + tdLog.info("================= step4") + tdDnodes.stop(1) + #tdLog.sleep(5) + tdDnodes.start(1) + + tdLog.info("================= step5") + tdLog.info("import 9 data again with gap") + startTime = self.startTime + 10 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 11): + if (rid == 5): + continue + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(18) + + tdLog.info("================= step7") + tdLog.info("import 20 data before with partly overlap") + startTime = self.startTime - 3 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 21): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step8") + tdSql.query('select * from tb1') + tdSql.checkRows(23) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importCacheFileS.py b/tests/pytest/import_merge/importCacheFileS.py new file mode 100644 index 0000000000000000000000000000000000000000..250952b2377f9d164c16801b6ead5f695d4f7c43 --- /dev/null +++ b/tests/pytest/import_merge/importCacheFileS.py @@ -0,0 +1,91 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + + tdLog.info("================= step2") + tdLog.info("import 10 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 11): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(10) + + tdLog.info("================= step4") + tdDnodes.stop(1) + #tdLog.sleep(5) + tdDnodes.start(1) + + tdLog.info("================= step5") + tdLog.info("import 10 data again") + startTime = self.startTime + 10 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 11): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(20) + + tdLog.info("================= step7") + tdLog.info("import 30 data covering existing data") + startTime = self.startTime - 5 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 31): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step8") + tdSql.query('select * from tb1') + tdSql.checkRows(30) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importCacheFileSub.py b/tests/pytest/import_merge/importCacheFileSub.py new file mode 100644 index 0000000000000000000000000000000000000000..663bdcd6351c02a91da309502e0a7f5ec9878086 --- /dev/null +++ b/tests/pytest/import_merge/importCacheFileSub.py @@ -0,0 +1,91 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + + tdLog.info("================= step2") + tdLog.info("import 10 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 11): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(10) + + tdLog.info("================= step4") + tdDnodes.stop(1) + #tdLog.sleep(5) + tdDnodes.start(1) + + tdLog.info("================= step5") + tdLog.info("import 10 data again") + startTime = self.startTime + 10 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 11): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(20) + + tdLog.info("================= step7") + tdLog.info("import 10 data totally repetitive") + startTime = self.startTime + 5 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 11): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step8") + tdSql.query('select * from tb1') + tdSql.checkRows(20) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importCacheFileT.py b/tests/pytest/import_merge/importCacheFileT.py new file mode 100644 index 0000000000000000000000000000000000000000..f2feeeacff11a4c8a2d65feaa08cd1b57264e0c9 --- /dev/null +++ b/tests/pytest/import_merge/importCacheFileT.py @@ -0,0 +1,88 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + + tdLog.info("================= step2") + tdLog.info("import 10 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 11): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(10) + + tdLog.info("================= step4") + tdDnodes.stop(1) + #tdLog.sleep(5) + tdDnodes.start(1) + + tdLog.info("================= step5") + tdLog.info("import 10 data again") + startTime = self.startTime + 10 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 11): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(20) + + tdLog.info("================= step7") + tdLog.info("import 1 data later") + startTime = self.startTime + 20 + tdSql.execute('import into tb1 values(%ld, %d)' % (startTime + 1, rid)) + + tdLog.info("================= step8") + tdSql.query('select * from tb1') + tdSql.checkRows(21) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importCacheFileTO.py b/tests/pytest/import_merge/importCacheFileTO.py new file mode 100644 index 0000000000000000000000000000000000000000..421ca6a755425690e7ec76d9a932ce11a65cb141 --- /dev/null +++ b/tests/pytest/import_merge/importCacheFileTO.py @@ -0,0 +1,91 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + + tdLog.info("================= step2") + tdLog.info("import 10 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 11): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(10) + + tdLog.info("================= step4") + tdDnodes.stop(1) + #tdLog.sleep(5) + tdDnodes.start(1) + + tdLog.info("================= step5") + tdLog.info("import 10 data again") + startTime = self.startTime + 10 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 11): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(20) + + tdLog.info("================= step7") + tdLog.info("import 10 data later with overlap") + startTime = self.startTime + 15 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 11): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step8") + tdSql.query('select * from tb1') + tdSql.checkRows(25) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importCacheFileTPO.py b/tests/pytest/import_merge/importCacheFileTPO.py new file mode 100644 index 0000000000000000000000000000000000000000..ca582d7d5aad8106d7c3d12439001fda84d5004c --- /dev/null +++ b/tests/pytest/import_merge/importCacheFileTPO.py @@ -0,0 +1,95 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + + tdLog.info("================= step2") + tdLog.info("import 9 sequential data with gap") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 11): + if (rid == 7): + continue + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(9) + + tdLog.info("================= step4") + tdDnodes.stop(1) + #tdLog.sleep(5) + tdDnodes.start(1) + + tdLog.info("================= step5") + tdLog.info("import 9 data again with gap") + startTime = self.startTime + 10 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 11): + if (rid == 7): + continue + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(18) + + tdLog.info("================= step7") + tdLog.info("import 20 data later with partly overlap") + startTime = self.startTime + 5 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 21): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step8") + tdSql.query('select * from tb1') + tdSql.checkRows(25) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importDataH2.py b/tests/pytest/import_merge/importDataH2.py new file mode 100644 index 0000000000000000000000000000000000000000..4de567d943a1fe843ec16dd4589054ebcef76488 --- /dev/null +++ b/tests/pytest/import_merge/importDataH2.py @@ -0,0 +1,94 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + self.maxrows = 200 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db maxrows %d' % self.maxrows) + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info( + "More than 10 rows less than %d rows will go to data file" % + self.maxrows) + + tdLog.info("================= step2") + tdLog.info("import %d sequential data" % (self.maxrows // 2)) + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, self.maxrows // 2 + 1): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(self.maxrows // 2) + + tdLog.info("================= step4") + tdDnodes.stop(1) + #tdLog.sleep(5) + tdDnodes.start(1) + + tdLog.info("================= step5") + tdLog.info("import 1 data before") + startTime = self.startTime - 1 + tdSql.execute('import into tb1 values(%ld, %d)' % (startTime + 1, 1)) + + tdLog.info("================= step7") + tdSql.execute('reset query cache') + tdSql.query('select * from tb1 order by ts desc') + tdSql.checkRows(self.maxrows // 2 + 1) + + tdLog.info("================= step8") + tdLog.info("import 10 data in batch before") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 11): + sqlcmd.append('(%ld, %d)' % (startTime - rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step9") + tdSql.execute('reset query cache') + tdSql.query('select * from tb1 order by ts desc') + tdSql.checkRows(self.maxrows // 2 + 11) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importDataHO.py b/tests/pytest/import_merge/importDataHO.py new file mode 100644 index 0000000000000000000000000000000000000000..f40de71d6d3967aac6d851deae2810aed63bc3c8 --- /dev/null +++ b/tests/pytest/import_merge/importDataHO.py @@ -0,0 +1,84 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + self.maxrows = 200 + self.rowsPerTable = 20 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db maxrows %d' % self.maxrows) + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info( + "More than 10 rows less than %d rows will go to data file" % + self.maxrows) + + tdLog.info("================= step2") + tdLog.info("import %d sequential data" % self.rowsPerTable) + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, self.rowsPerTable + 1): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select count(*) from tb1') + tdSql.checkData(0, 0, self.rowsPerTable) + + tdLog.info("================= step4") + tdDnodes.stop(1) + #tdLog.sleep(5) + tdDnodes.start(1) + + tdLog.info("================= step5") + tdLog.info("import 6 data before with overlap") + startTime = self.startTime - 3 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 7): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step6") + tdSql.query('select * from tb1 order by ts desc') + tdSql.checkRows(self.rowsPerTable + 3) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importDataHO2.py b/tests/pytest/import_merge/importDataHO2.py new file mode 100644 index 0000000000000000000000000000000000000000..518975e0b727db0d51bd6f5b68e690356988e2fe --- /dev/null +++ b/tests/pytest/import_merge/importDataHO2.py @@ -0,0 +1,84 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + self.maxrows = 200 + self.rowsPerTable = 100 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db maxrows %d' % self.maxrows) + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info( + "More than 10 rows less than %d rows will go to data file" % + self.maxrows) + + tdLog.info("================= step2") + tdLog.info("import %d sequential data" % self.rowsPerTable) + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, self.rowsPerTable + 1): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select count(*) from tb1') + tdSql.checkData(0, 0, self.rowsPerTable) + + tdLog.info("================= step4") + tdDnodes.stop(1) + #tdLog.sleep(5) + tdDnodes.start(1) + + tdLog.info("================= step5") + tdLog.info("import 6 data before with overlap") + startTime = self.startTime - 3 + sqlcmd = ['import into tb1 values'] + for rid in range(6, 0, -1): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step6") + tdSql.query('select * from tb1 order by ts desc') + tdSql.checkRows(self.rowsPerTable + 3) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importDataHPO.py b/tests/pytest/import_merge/importDataHPO.py new file mode 100644 index 0000000000000000000000000000000000000000..c7f0625d4bf09de49066c9ea19d4936bdd00e811 --- /dev/null +++ b/tests/pytest/import_merge/importDataHPO.py @@ -0,0 +1,86 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + self.maxrows = 200 + self.rowsPerTable = 20 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db maxrows %d' % self.maxrows) + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info( + "More than 10 rows less than %d rows will go to data file" % + self.maxrows) + + tdLog.info("================= step2") + tdLog.info("import %d sequential data" % self.rowsPerTable) + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 10): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + for rid in range(14, self.rowsPerTable + 5): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select count(*) from tb1') + tdSql.checkData(0, 0, self.rowsPerTable) + + tdLog.info("================= step4") + tdDnodes.stop(1) + #tdLog.sleep(5) + tdDnodes.start(1) + + tdLog.info("================= step5") + tdLog.info("import 20 data before with partly overlap") + startTime = self.startTime - 4 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 21): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(self.rowsPerTable + 8) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importDataLastH.py b/tests/pytest/import_merge/importDataLastH.py new file mode 100644 index 0000000000000000000000000000000000000000..f736cb925a405c8588d01faad0b08759127962b4 --- /dev/null +++ b/tests/pytest/import_merge/importDataLastH.py @@ -0,0 +1,80 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + self.maxrows = 200 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db maxrows %d' % self.maxrows) + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info( + "More than %d rows less than %d rows will go to data and last file" % + (self.maxrows, 10 + self.maxrows)) + + tdLog.info("================= step2") + tdLog.info("import 205 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 206): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(205) + + tdLog.info("================= step4") + tdDnodes.stop(1) + #tdLog.sleep(5) + tdDnodes.start(1) + + tdLog.info("================= step5") + tdLog.info("import 1 data before") + startTime = self.startTime - 1 + tdSql.execute('import into tb1 values(%ld, %d)' % (startTime + 1, 1)) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(206) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importDataLastHO.py b/tests/pytest/import_merge/importDataLastHO.py new file mode 100644 index 0000000000000000000000000000000000000000..b1eebfdd47ed1fbb5185b7547927ea50a29bc64e --- /dev/null +++ b/tests/pytest/import_merge/importDataLastHO.py @@ -0,0 +1,83 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + self.maxrows = 200 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db maxrows %d' % self.maxrows) + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info( + "More than %d rows less than %d rows will go to data and last file" % + (self.maxrows, 10 + self.maxrows)) + + tdLog.info("================= step2") + tdLog.info("import 205 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 206): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(205) + + tdLog.info("================= step4") + tdDnodes.stop(1) + #tdLog.sleep(5) + tdDnodes.start(1) + + tdLog.info("================= step5") + tdLog.info("import 5 data before with overlap") + startTime = self.startTime - 2 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 6): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(207) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importDataLastHPO.py b/tests/pytest/import_merge/importDataLastHPO.py new file mode 100644 index 0000000000000000000000000000000000000000..9aa8127f50799039ceaa48dee957cdb903b890f0 --- /dev/null +++ b/tests/pytest/import_merge/importDataLastHPO.py @@ -0,0 +1,85 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + self.maxrows = 200 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db maxrows %d' % self.maxrows) + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info( + "More than %d rows less than %d rows will go to data and last file" % + (self.maxrows, 10 + self.maxrows)) + + tdLog.info("================= step2") + tdLog.info("import 205 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 11): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + for rid in range(14, 209): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(205) + + tdLog.info("================= step4") + tdDnodes.stop(1) + #tdLog.sleep(5) + tdDnodes.start(1) + + tdLog.info("================= step5") + tdLog.info("import 20 data before with partly overlap") + startTime = self.startTime - 2 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 21): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(210) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importDataLastS.py b/tests/pytest/import_merge/importDataLastS.py new file mode 100644 index 0000000000000000000000000000000000000000..4e5701deb1785819f915d9a51cbf4b9b5fc56bab --- /dev/null +++ b/tests/pytest/import_merge/importDataLastS.py @@ -0,0 +1,83 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + self.maxrows = 200 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db maxrows %d' % self.maxrows) + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info( + "More than %d rows less than %d rows will go to data and last file" % + (self.maxrows, 10 + self.maxrows)) + + tdLog.info("================= step2") + tdLog.info("import 205 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 206): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select count(*) from tb1') + tdSql.checkData(0, 0, 205) + + tdLog.info("================= step4") + tdDnodes.stop(1) + #tdLog.sleep(5) + tdDnodes.start(1) + + tdLog.info("================= step5") + tdLog.info("import 250 data covering the existing data") + startTime = self.startTime - 15 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 251): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step6") + tdSql.query('select count(*) from tb1') + tdSql.checkData(0, 0, 250) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importDataLastSub.py b/tests/pytest/import_merge/importDataLastSub.py new file mode 100644 index 0000000000000000000000000000000000000000..415d1fcba27921267832323e6c3177678a215c9b --- /dev/null +++ b/tests/pytest/import_merge/importDataLastSub.py @@ -0,0 +1,85 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + self.maxrows = 200 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + #tdLog.sleep(5) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db maxrows %d' % self.maxrows) + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info( + "More than %d rows less than %d rows will go to data and last file" % + (self.maxrows, 10 + self.maxrows)) + + tdLog.info("================= step2") + tdLog.info("import 205 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 206): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(205) + + tdLog.info("================= step4") + tdDnodes.stop(1) + #tdLog.sleep(5) + tdDnodes.start(1) + #tdLog.sleep(5) + + tdLog.info("================= step5") + tdLog.info("import 10 data totally repetitive") + startTime = self.startTime + 10 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 11): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(205) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importDataLastT.py b/tests/pytest/import_merge/importDataLastT.py new file mode 100644 index 0000000000000000000000000000000000000000..839320cc22352f1009d0d786aa58cf8827fc8ff6 --- /dev/null +++ b/tests/pytest/import_merge/importDataLastT.py @@ -0,0 +1,76 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + self.maxrows = 200 + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db maxrows %d' % self.maxrows) + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info( + "More than %d rows less than %d rows will go to data and last file" % + (self.maxrows, 10 + self.maxrows)) + + tdLog.info("================= step2") + tdLog.info("import 205 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 206): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(205) + + tdLog.info("================= step4") + tdDnodes.stop(1) + #tdLog.sleep(5) + tdDnodes.start(1) + + tdLog.info("================= step5") + tdLog.info("import 1 data later") + startTime = self.startTime + 205 + tdSql.execute('import into tb1 values(%ld, %d)' % (startTime + 1, 1)) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(206) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importDataLastTO.py b/tests/pytest/import_merge/importDataLastTO.py new file mode 100644 index 0000000000000000000000000000000000000000..0c35519fcf76e7d2faab3a2cb2c4cc702fe93f0b --- /dev/null +++ b/tests/pytest/import_merge/importDataLastTO.py @@ -0,0 +1,79 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + self.maxrows = 200 + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db maxrows %d' % self.maxrows) + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info( + "More than %d rows less than %d rows will go to data and last file" % + (self.maxrows, 10 + self.maxrows)) + + tdLog.info("================= step2") + tdLog.info("import 205 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 206): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(205) + + tdLog.info("================= step4") + tdDnodes.stop(1) + #tdLog.sleep(5) + tdDnodes.start(1) + + tdLog.info("================= step5") + tdLog.info("import 5 data later with overlap") + startTime = self.startTime + 203 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 6): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(208) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importDataLastTPO.py b/tests/pytest/import_merge/importDataLastTPO.py new file mode 100644 index 0000000000000000000000000000000000000000..c7864ae14d68a3ef8860125920b3286921f65356 --- /dev/null +++ b/tests/pytest/import_merge/importDataLastTPO.py @@ -0,0 +1,81 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + self.maxrows = 200 + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db maxrows %d' % self.maxrows) + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info( + "More than %d rows less than %d rows will go to data and last file" % + (self.maxrows, 10 + self.maxrows)) + + tdLog.info("================= step2") + tdLog.info("import 205 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 196): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + for rid in range(200, 210): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(205) + + tdLog.info("================= step4") + tdDnodes.stop(1) + #tdLog.sleep(5) + tdDnodes.start(1) + + tdLog.info("================= step5") + tdLog.info("import 20 data later with partly overlap") + startTime = self.startTime + 192 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 21): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(212) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importDataS.py b/tests/pytest/import_merge/importDataS.py new file mode 100644 index 0000000000000000000000000000000000000000..f0d56a5016fe5b059e1b51719b799d801219c2ca --- /dev/null +++ b/tests/pytest/import_merge/importDataS.py @@ -0,0 +1,79 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + self.maxrows = 200 + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db maxrows %d' % self.maxrows) + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info( + "More than 10 rows less than %d rows will go to data file" % + self.maxrows) + + tdLog.info("================= step2") + tdLog.info("import 20 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 21): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(20) + + tdLog.info("================= step4") + tdDnodes.stop(1) + #tdLog.sleep(5) + tdDnodes.start(1) + + tdLog.info("================= step5") + tdLog.info("import 30 data covering the existing data") + startTime = self.startTime - 5 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 31): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(30) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importDataSub.py b/tests/pytest/import_merge/importDataSub.py new file mode 100644 index 0000000000000000000000000000000000000000..1643cc89155507be6c5fa2c072755a8439b21aab --- /dev/null +++ b/tests/pytest/import_merge/importDataSub.py @@ -0,0 +1,85 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + self.maxrows = 200 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db maxrows %d' % self.maxrows) + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info( + "More than 10 rows less than %d rows will go to data file" % + self.maxrows) + + tdLog.info("================= step2") + tdLog.info("import %d sequential data" % (self.maxrows // 2)) + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, self.maxrows // 2 + 1): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(self.maxrows // 2) + + tdLog.info("================= step4") + tdDnodes.stop(1) + #tdLog.sleep(5) + tdDnodes.start(1) + + tdLog.info("================= step5") + tdLog.info("import 10 data totally repetitive") + startTime = self.startTime + 10 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 11): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step9") + tdSql.execute('reset query cache') + tdSql.query('select * from tb1 order by ts desc') + tdSql.checkRows(self.maxrows // 2) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importDataT.py b/tests/pytest/import_merge/importDataT.py new file mode 100644 index 0000000000000000000000000000000000000000..c23ad9a60533d94d34d11c70ea2743a1b8ab5c01 --- /dev/null +++ b/tests/pytest/import_merge/importDataT.py @@ -0,0 +1,76 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + self.maxrows = 200 + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db maxrows %d' % self.maxrows) + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info( + "More than 10 rows less than %d rows will go to data file" % + self.maxrows) + + tdLog.info("================= step2") + tdLog.info("import 20 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 21): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(20) + + tdLog.info("================= step4") + tdDnodes.stop(1) + #tdLog.sleep(5) + tdDnodes.start(1) + + tdLog.info("================= step5") + tdLog.info("import 1 data later") + startTime = self.startTime + 20 + tdSql.execute('import into tb1 values(%ld, %d)' % (startTime + 1, 1)) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(21) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importDataTO.py b/tests/pytest/import_merge/importDataTO.py new file mode 100644 index 0000000000000000000000000000000000000000..b4c0d1a8adb6d4a3751d5a4a6547d0d03eab793b --- /dev/null +++ b/tests/pytest/import_merge/importDataTO.py @@ -0,0 +1,79 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + self.maxrows = 200 + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db maxrows %d' % self.maxrows) + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info( + "More than 10 rows less than %d rows will go to data file" % + self.maxrows) + + tdLog.info("================= step2") + tdLog.info("import 20 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 21): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(20) + + tdLog.info("================= step4") + tdDnodes.stop(1) + #tdLog.sleep(5) + tdDnodes.start(1) + + tdLog.info("================= step5") + tdLog.info("import 6 data later with overlap") + startTime = self.startTime + 18 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 7): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(24) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importDataTPO.py b/tests/pytest/import_merge/importDataTPO.py new file mode 100644 index 0000000000000000000000000000000000000000..38e8cfe9096135f1f9301d89bc8c6269d045e78f --- /dev/null +++ b/tests/pytest/import_merge/importDataTPO.py @@ -0,0 +1,82 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + self.maxrows = 200 + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db maxrows %d' % self.maxrows) + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info( + "More than 10 rows less than %d rows will go to data file" % + self.maxrows) + + tdLog.info("================= step2") + tdLog.info("import 20 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 18): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + for rid in range(22, 25): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(20) + + tdLog.info("================= step4") + tdDnodes.stop(1) + #tdLog.sleep(5) + tdDnodes.start(1) + #tdLog.sleep(5) + + tdLog.info("================= step5") + tdLog.info("import 20 data later with partly overlap") + startTime = self.startTime + 15 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 21): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(35) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importHORestart.py b/tests/pytest/import_merge/importHORestart.py new file mode 100644 index 0000000000000000000000000000000000000000..05b5b42afff14c695690b7651bd385ee78f3bafb --- /dev/null +++ b/tests/pytest/import_merge/importHORestart.py @@ -0,0 +1,72 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdSql.prepare() + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, i int)') + + tdLog.info("================= step2") + tdLog.info("import 10 sequential data") + startTime = self.startTime + for rid in range(1, 11): + tdSql.execute( + 'import into tb1 values(%ld, %d)' % + (startTime + rid, rid)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(10) + + tdLog.info("================= step4") + tdLog.info("import 5 data before with overlap") + startTime = self.startTime - 2 + for rid in range(1, 11): + tdSql.execute( + 'import into tb1 values(%ld, %d)' % + (startTime + rid, rid)) + + tdLog.info("================= step5") + tdDnodes.forcestop(1) + tdDnodes.start(1) + #tdLog.sleep(10) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(12) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importHPORestart.py b/tests/pytest/import_merge/importHPORestart.py new file mode 100644 index 0000000000000000000000000000000000000000..f9167709130d67b2909d3e9efd1acc482638836d --- /dev/null +++ b/tests/pytest/import_merge/importHPORestart.py @@ -0,0 +1,77 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdSql.prepare() + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, i int)') + + tdLog.info("================= step2") + tdLog.info("import 8 sequential data with gap") + startTime = self.startTime + for rid in range(1, 4): + tdSql.execute( + 'import into tb1 values(%ld, %d)' % + (startTime + rid, rid)) + for rid in range(6, 11): + tdSql.execute( + 'import into tb1 values(%ld, %d)' % + (startTime + rid, rid)) + startTime += 1 + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(8) + + tdLog.info("================= step4") + tdLog.info("import 8 data before with partly overlap") + startTime = self.startTime - 2 + for rid in range(1, 9): + tdSql.execute( + 'import into tb1 values(%ld, %d)' % + (startTime + rid, rid)) + + tdLog.info("================= step5") + tdDnodes.forcestop(1) + tdDnodes.start(1) + #tdLog.sleep(10) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(12) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importHRestart.py b/tests/pytest/import_merge/importHRestart.py new file mode 100644 index 0000000000000000000000000000000000000000..c1d50378b20a11b4d562b408d7bec07364969d19 --- /dev/null +++ b/tests/pytest/import_merge/importHRestart.py @@ -0,0 +1,69 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdSql.prepare() + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, i int)') + + tdLog.info("================= step2") + tdLog.info("import 10 sequential data") + startTime = self.startTime + for rid in range(1, 11): + tdSql.execute( + 'import into tb1 values(%ld, %d)' % + (startTime + rid, rid)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(10) + + tdLog.info("================= step4") + tdLog.info("import 1 data before") + startTime = self.startTime - 1 + tdSql.execute('import into tb1 values(%ld, %d)' % (startTime, rid)) + + tdLog.info("================= step5") + tdDnodes.forcestop(1) + tdDnodes.start(1) + #tdLog.sleep(10) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(11) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importHead.py b/tests/pytest/import_merge/importHead.py new file mode 100644 index 0000000000000000000000000000000000000000..80e6d92c69f2328bd35a43af820ca16658daf63b --- /dev/null +++ b/tests/pytest/import_merge/importHead.py @@ -0,0 +1,70 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + + tdLog.info("================= step2") + tdLog.info("import 10 sequential data") + startTime = self.startTime + for rid in range(1, 11): + tdSql.execute('import into tb1 values(%ld, %d)' % (startTime, rid)) + startTime += 1 + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(10) + + tdLog.info("================= step4") + tdLog.info("import 1 data before") + startTime = self.startTime - 1 + tdSql.execute('import into tb1 values(%ld, %d)' % (startTime, rid)) + + tdLog.info("================= step5") + tdSql.query('select * from tb1') + tdSql.checkRows(11) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importHeadOverlap.py b/tests/pytest/import_merge/importHeadOverlap.py new file mode 100644 index 0000000000000000000000000000000000000000..535c0c285960c4657dc1cefeb0dd2cf128a2434f --- /dev/null +++ b/tests/pytest/import_merge/importHeadOverlap.py @@ -0,0 +1,65 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdSql.prepare() + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + + tdLog.info("================= step2") + tdLog.info("import 10 sequential data") + startTime = self.startTime + for rid in range(1, 11): + tdSql.execute('import into tb1 values(%ld, %d)' % (startTime, rid)) + startTime += 1 + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(10) + + tdLog.info("================= step4") + tdLog.info("import 5 data before with overlap") + startTime = self.startTime - 2 + for rid in range(1, 11): + tdSql.execute('import into tb1 values(%ld, %d)' % (startTime, rid)) + startTime += 1 + + tdLog.info("================= step5") + tdSql.query('select * from tb1') + tdSql.checkRows(12) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importHeadPartOverlap.py b/tests/pytest/import_merge/importHeadPartOverlap.py new file mode 100644 index 0000000000000000000000000000000000000000..85ddd64f0a66c5b962d1f33d517c1d28f9521d0a --- /dev/null +++ b/tests/pytest/import_merge/importHeadPartOverlap.py @@ -0,0 +1,69 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdSql.prepare() + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, i int)') + + tdLog.info("================= step2") + tdLog.info("import 8 sequential data with gap") + startTime = self.startTime + for rid in range(1, 4): + tdSql.execute('import into tb1 values(%ld, %d)' % (startTime, rid)) + startTime += 1 + startTime += 2 + for rid in range(6, 11): + tdSql.execute('import into tb1 values(%ld, %d)' % (startTime, rid)) + startTime += 1 + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(8) + + tdLog.info("================= step4") + tdLog.info("import 8 data before with partly overlap") + startTime = self.startTime - 2 + for rid in range(1, 9): + tdSql.execute('import into tb1 values(%ld, %d)' % (startTime, rid)) + startTime += 1 + + tdLog.info("================= step5") + tdSql.query('select * from tb1') + tdSql.checkRows(12) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importInsertThenImport.py b/tests/pytest/import_merge/importInsertThenImport.py new file mode 100644 index 0000000000000000000000000000000000000000..1372177de36c1f67ab85ba4a63c26553ee4a7de4 --- /dev/null +++ b/tests/pytest/import_merge/importInsertThenImport.py @@ -0,0 +1,85 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdSql.prepare() + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, i int)') + + tdLog.info("================= step2") + tdLog.info("insert 100 sequential data") + startTime = self.startTime + for rid in range(1, 101): + tdSql.execute( + 'insert into tb1 values(%ld, %d)' % + (startTime + rid, rid)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(100) + + tdLog.info("================= step4") + tdLog.info("import 100 sequential data") + startTime = self.startTime + for rid in range(1, 101): + tdSql.execute( + 'import into tb1 values(%ld, %d)' % + (startTime + rid, 100 + rid)) + + tdSql.query('select * from tb1') + tdSql.checkRows(100) + tdSql.checkData(0, 1, 1) + + tdLog.info("================= step5") + tdDnodes.stop(1) + tdDnodes.start(1) + #tdLog.sleep(10) + + tdLog.info("================= step6") + tdLog.info("import 100 sequential data again") + startTime = self.startTime + for rid in range(1, 101): + tdSql.execute( + 'import into tb1 values(%ld, %d)' % + (startTime + rid, 100 + rid)) + + tdLog.info("================= step7") + tdSql.query('select * from tb1') + tdSql.checkRows(100) + tdSql.checkData(0, 1, 1) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importLastH.py b/tests/pytest/import_merge/importLastH.py new file mode 100644 index 0000000000000000000000000000000000000000..2887c71e040b7ea89e42da69e597bcb843a2df5c --- /dev/null +++ b/tests/pytest/import_merge/importLastH.py @@ -0,0 +1,74 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + self.maxrows = 200 + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db maxrows %d' % self.maxrows) + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info("less than 10 rows will go to last file") + + tdLog.info("================= step2") + tdLog.info("import 5 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 6): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(5) + + tdLog.info("================= step4") + tdDnodes.stop(1) + #tdLog.sleep(5) + tdDnodes.start(1) + + tdLog.info("================= step5") + tdLog.info("import 1 data before") + startTime = self.startTime - 1 + tdSql.execute('import into tb1 values(%ld, %d)' % (startTime + 1, 1)) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(6) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importLastHO.py b/tests/pytest/import_merge/importLastHO.py new file mode 100644 index 0000000000000000000000000000000000000000..1681212b6b8c5d002e6f3d2b5853534382bb4d10 --- /dev/null +++ b/tests/pytest/import_merge/importLastHO.py @@ -0,0 +1,77 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + self.maxrows = 200 + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db maxrows %d' % self.maxrows) + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info("less than 10 rows will go to last file") + + tdLog.info("================= step2") + tdLog.info("import 5 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 6): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(5) + + tdLog.info("================= step4") + tdDnodes.stop(1) + #tdLog.sleep(5) + tdDnodes.start(1) + + tdLog.info("================= step5") + tdLog.info("import 4 data before with overlap") + startTime = self.startTime - 2 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 5): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(7) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importLastHPO.py b/tests/pytest/import_merge/importLastHPO.py new file mode 100644 index 0000000000000000000000000000000000000000..389b3c11ed04b0359564a41c7b383e37e9bcabdd --- /dev/null +++ b/tests/pytest/import_merge/importLastHPO.py @@ -0,0 +1,79 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + self.maxrows = 200 + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db maxrows %d' % self.maxrows) + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info("less than 10 rows will go to last file") + + tdLog.info("================= step2") + tdLog.info("import 6 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 4): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + for rid in range(6, 9): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(6) + + tdLog.info("================= step4") + tdDnodes.stop(1) + #tdLog.sleep(5) + tdDnodes.start(1) + + tdLog.info("================= step5") + tdLog.info("import 8 data before with partly overlap") + startTime = self.startTime - 2 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 9): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(10) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importLastS.py b/tests/pytest/import_merge/importLastS.py new file mode 100644 index 0000000000000000000000000000000000000000..e6393bbfae2f41efd1ff740f4e542715f23f8adf --- /dev/null +++ b/tests/pytest/import_merge/importLastS.py @@ -0,0 +1,76 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + self.maxrows = 200 + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db maxrows %d' % self.maxrows) + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info("less than 10 rows will go to last file") + + tdLog.info("================= step2") + tdLog.info("import 5 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 6): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(5) + + tdLog.info("================= step4") + tdDnodes.stop(1) + #tdLog.sleep(5) + tdDnodes.start(1) + + tdLog.info("================= step5") + tdLog.info("import 20 data covering existing data") + startTime = self.startTime - 10 + for rid in range(1, 21): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(20) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importLastSub.py b/tests/pytest/import_merge/importLastSub.py new file mode 100644 index 0000000000000000000000000000000000000000..4ff6cf27bdf582040360e40ce13d28df7dfc8949 --- /dev/null +++ b/tests/pytest/import_merge/importLastSub.py @@ -0,0 +1,77 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + self.maxrows = 200 + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db maxrows %d' % self.maxrows) + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info("less than 10 rows will go to last file") + + tdLog.info("================= step2") + tdLog.info("import 5 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 6): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(5) + + tdLog.info("================= step4") + tdDnodes.stop(1) + #tdLog.sleep(5) + tdDnodes.start(1) + + tdLog.info("================= step5") + tdLog.info("import 3 data totally repetitive") + startTime = self.startTime + 1 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 4): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(5) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importLastT.py b/tests/pytest/import_merge/importLastT.py new file mode 100644 index 0000000000000000000000000000000000000000..145b1bd69097804728020ea1b3b8a0ccf7e86d27 --- /dev/null +++ b/tests/pytest/import_merge/importLastT.py @@ -0,0 +1,78 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + self.maxrows = 200 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db maxrows %d' % self.maxrows) + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info("less than 10 rows will go to last file") + + tdLog.info("================= step2") + tdLog.info("import 5 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 6): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(5) + + tdLog.info("================= step4") + tdDnodes.stop(1) + #tdLog.sleep(5) + tdDnodes.start(1) + + tdLog.info("================= step5") + tdLog.info("import 1 data later") + startTime = self.startTime + 5 + tdSql.execute('import into tb1 values(%ld, %d)' % (startTime + 1, 1)) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(6) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importLastTO.py b/tests/pytest/import_merge/importLastTO.py new file mode 100644 index 0000000000000000000000000000000000000000..a159dac4acea9c1c278025e157ff3fe09487e858 --- /dev/null +++ b/tests/pytest/import_merge/importLastTO.py @@ -0,0 +1,81 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + self.maxrows = 200 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db maxrows %d' % self.maxrows) + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info("less than 10 rows will go to last file") + + tdLog.info("================= step2") + tdLog.info("import 5 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 6): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(5) + + tdLog.info("================= step4") + tdDnodes.stop(1) + #tdLog.sleep(5) + tdDnodes.start(1) + + tdLog.info("================= step5") + tdLog.info("import 4 data later with overlap") + startTime = self.startTime + 3 + sqlcmd = ['import into tb1 values'] + for rid in range(1, 5): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(7) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importLastTPO.py b/tests/pytest/import_merge/importLastTPO.py new file mode 100644 index 0000000000000000000000000000000000000000..453b922a68bc7a051aa60d51943ffb759444ee5b --- /dev/null +++ b/tests/pytest/import_merge/importLastTPO.py @@ -0,0 +1,82 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + self.maxrows = 200 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db maxrows %d' % self.maxrows) + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + tdLog.info("less than 10 rows will go to last file") + + tdLog.info("================= step2") + tdLog.info("import 6 sequential data") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(1, 4): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + for rid in range(6, 9): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(6) + + tdLog.info("================= step4") + tdDnodes.stop(1) + #tdLog.sleep(5) + tdDnodes.start(1) + + tdLog.info("================= step5") + tdLog.info("import 8 data later with partly overlap") + startTime = self.startTime + 2 + for rid in range(1, 9): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(10) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importSRestart.py b/tests/pytest/import_merge/importSRestart.py new file mode 100644 index 0000000000000000000000000000000000000000..58f0f60e0af0660e4550966c2f0b1741aefbc33c --- /dev/null +++ b/tests/pytest/import_merge/importSRestart.py @@ -0,0 +1,79 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, i int)') + + tdLog.info("================= step2") + tdLog.info("import 10 sequential data") + startTime = self.startTime + for rid in range(1, 11): + tdSql.execute( + 'import into tb1 values(%ld, %d)' % + (startTime + rid, rid)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(10) + + tdLog.info("================= step4") + tdLog.info("import 20 data cover existing data") + startTime = self.startTime - 5 + for rid in range(1, 21): + tdSql.execute( + 'import into tb1 values(%ld, %d)' % + (startTime + rid, rid)) + + tdLog.info("================= step5") + tdDnodes.forcestop(1) + tdDnodes.start(1) + #tdLog.sleep(10) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(20) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importSpan.py b/tests/pytest/import_merge/importSpan.py new file mode 100644 index 0000000000000000000000000000000000000000..4e20e9754f86b287328aacb3e96f9ac0e7c4eee6 --- /dev/null +++ b/tests/pytest/import_merge/importSpan.py @@ -0,0 +1,74 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + + tdLog.info("================= step2") + tdLog.info("import 10 sequential data") + startTime = self.startTime + for rid in range(1, 11): + tdSql.execute( + 'import into tb1 values(%ld, %d)' % + (startTime + rid, rid)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(10) + + tdLog.info("================= step4") + tdLog.info("import 20 data cover existing data") + startTime = self.startTime - 5 + for rid in range(1, 21): + tdSql.execute( + 'import into tb1 values(%ld, %d)' % + (startTime + rid, rid)) + + tdLog.info("================= step5") + tdSql.query('select * from tb1') + tdSql.checkRows(20) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importSubRestart.py b/tests/pytest/import_merge/importSubRestart.py new file mode 100644 index 0000000000000000000000000000000000000000..85594e1772409f7c24a5d2ce8aa25b6ba7567a5d --- /dev/null +++ b/tests/pytest/import_merge/importSubRestart.py @@ -0,0 +1,79 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, i int)') + + tdLog.info("================= step2") + tdLog.info("import 20 sequential data") + startTime = self.startTime + for rid in range(1, 21): + tdSql.execute( + 'import into tb1 values(%ld, %d)' % + (startTime + rid, rid)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(20) + + tdLog.info("================= step4") + tdLog.info("import 10 data totally repetitive") + startTime = self.startTime + 5 + for rid in range(1, 11): + tdSql.execute( + 'import into tb1 values(%ld, %d)' % + (startTime + rid, rid)) + + tdLog.info("================= step5") + tdDnodes.forcestop(1) + tdDnodes.start(1) + #tdLog.sleep(10) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(20) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importTORestart.py b/tests/pytest/import_merge/importTORestart.py new file mode 100644 index 0000000000000000000000000000000000000000..10ac77d759192de329ab0818b79610259d05b7d7 --- /dev/null +++ b/tests/pytest/import_merge/importTORestart.py @@ -0,0 +1,79 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, i int)') + + tdLog.info("================= step2") + tdLog.info("import 10 sequential data") + startTime = self.startTime + for rid in range(1, 11): + tdSql.execute( + 'import into tb1 values(%ld, %d)' % + (startTime + rid, rid)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(10) + + tdLog.info("================= step4") + tdLog.info("import 6 data after with overlap") + startTime = self.startTime + 8 + for rid in range(1, 7): + tdSql.execute( + 'import into tb1 values(%ld, %d)' % + (startTime + rid, rid)) + + tdLog.info("================= step5") + tdDnodes.forcestop(1) + tdDnodes.start(1) + #tdLog.sleep(10) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(14) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importTPORestart.py b/tests/pytest/import_merge/importTPORestart.py new file mode 100644 index 0000000000000000000000000000000000000000..ab86a0247f179bd6dab397a069ca9b4aaf4da61f --- /dev/null +++ b/tests/pytest/import_merge/importTPORestart.py @@ -0,0 +1,83 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, i int)') + + tdLog.info("================= step2") + tdLog.info("import 8 sequential data with gap") + startTime = self.startTime + for rid in range(1, 6): + tdSql.execute( + 'import into tb1 values(%ld, %d)' % + (startTime + rid, rid)) + for rid in range(8, 11): + tdSql.execute( + 'import into tb1 values(%ld, %d)' % + (startTime + rid, rid)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(8) + + tdLog.info("================= step4") + tdLog.info("import 8 data after with partly overlap") + startTime = self.startTime + 3 + for rid in range(1, 9): + tdSql.execute( + 'import into tb1 values(%ld, %d)' % + (startTime + rid, rid)) + + tdLog.info("================= step5") + tdDnodes.forcestop(1) + tdDnodes.start(1) + #tdLog.sleep(10) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(11) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importTRestart.py b/tests/pytest/import_merge/importTRestart.py new file mode 100644 index 0000000000000000000000000000000000000000..6106bdd75310369d53ce8148f937655301b64c12 --- /dev/null +++ b/tests/pytest/import_merge/importTRestart.py @@ -0,0 +1,76 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, i int)') + + tdLog.info("================= step2") + tdLog.info("import 10 sequential data") + startTime = self.startTime + for rid in range(1, 11): + tdSql.execute( + 'import into tb1 values(%ld, %d)' % + (startTime + rid, rid)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(10) + + tdLog.info("================= step4") + tdLog.info("import 1 data after") + startTime = self.startTime + 11 + tdSql.execute('import into tb1 values(%ld, %d)' % (startTime, rid)) + + tdLog.info("================= step5") + tdDnodes.forcestop(1) + tdDnodes.start(1) + #tdLog.sleep(10) + + tdLog.info("================= step6") + tdSql.query('select * from tb1') + tdSql.checkRows(11) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importTail.py b/tests/pytest/import_merge/importTail.py new file mode 100644 index 0000000000000000000000000000000000000000..a552edb2449d8c8360403561398070279b7143c9 --- /dev/null +++ b/tests/pytest/import_merge/importTail.py @@ -0,0 +1,70 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + + tdLog.info("================= step2") + tdLog.info("import 10 sequential data") + startTime = self.startTime + for rid in range(1, 11): + tdSql.execute('import into tb1 values(%ld, %d)' % (startTime, rid)) + startTime += 1 + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(10) + + tdLog.info("================= step4") + tdLog.info("import 1 data after") + startTime += 1 + tdSql.execute('import into tb1 values(%ld, %d)' % (startTime, rid)) + + tdLog.info("================= step5") + tdSql.query('select * from tb1') + tdSql.checkRows(11) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importTailOverlap.py b/tests/pytest/import_merge/importTailOverlap.py new file mode 100644 index 0000000000000000000000000000000000000000..78e51f93f92ab510d56b55201c801cc53fbded12 --- /dev/null +++ b/tests/pytest/import_merge/importTailOverlap.py @@ -0,0 +1,72 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + + tdLog.info("================= step2") + tdLog.info("import 10 sequential data") + startTime = self.startTime + for rid in range(1, 11): + tdSql.execute('import into tb1 values(%ld, %d)' % (startTime, rid)) + startTime += 1 + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(10) + + tdLog.info("================= step4") + tdLog.info("import 6 data after with overlap") + startTime = self.startTime + 8 + for rid in range(1, 7): + tdSql.execute('import into tb1 values(%ld, %d)' % (startTime, rid)) + startTime += 1 + + tdLog.info("================= step5") + tdSql.query('select * from tb1') + tdSql.checkRows(14) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importTailPartOverlap.py b/tests/pytest/import_merge/importTailPartOverlap.py new file mode 100644 index 0000000000000000000000000000000000000000..e433cb66f37102a085c0faebbd85122b163c9c47 --- /dev/null +++ b/tests/pytest/import_merge/importTailPartOverlap.py @@ -0,0 +1,78 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, speed int)') + + tdLog.info("================= step2") + tdLog.info("import 8 sequential data with gap") + startTime = self.startTime + for rid in range(1, 6): + tdSql.execute( + 'import into tb1 values(%ld, %d)' % + (startTime + rid, rid)) + for rid in range(8, 11): + tdSql.execute( + 'import into tb1 values(%ld, %d)' % + (startTime + rid, rid)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(8) + + tdLog.info("================= step4") + tdLog.info("import 8 data after with partly overlap") + startTime = self.startTime + 3 + for rid in range(1, 9): + tdSql.execute( + 'import into tb1 values(%ld, %d)' % + (startTime + rid, rid)) + + tdLog.info("================= step5") + tdSql.query('select * from tb1') + tdSql.checkRows(11) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/importToCommit.py b/tests/pytest/import_merge/importToCommit.py new file mode 100644 index 0000000000000000000000000000000000000000..7bec5fcd5d3124e588b4d6d0910e1dafc1a991bb --- /dev/null +++ b/tests/pytest/import_merge/importToCommit.py @@ -0,0 +1,85 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db cache 128') + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, i int)') + tdLog.info( + "one block can import 38 records and totally there are 40 blocks") + + tdLog.info("================= step2") + tdLog.info('insert data until the first commit') + dnodesDir = tdDnodes.getDnodesRootDir() + dataDir = dnodesDir + '/dnode1/data/vnode' + startTime = self.startTime + rid0 = 1 + while (True): + sqlcmd = 'insert into tb1 values(%ld, %d)' % ( + startTime + rid0 * 2, rid0) + tdSql.execute(sqlcmd) + rid0 += 1 + vnodes = os.listdir(dataDir) + if (len(vnodes) > 0): + tdLog.info("data is committed, stop inserting") + break + + tdLog.info("================= step5") + tdLog.info("import 1 data before ") + startTime = self.startTime + sqlcmd = ['import into tb1 values'] + for rid in range(3, 4): + sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + + tdLog.info("================= step6") + tdSql.execute('reset query cache') + tdSql.query('select * from tb1 order by ts desc') + tdSql.checkRows(rid0 - 1 + 1) + + tdLog.info("================= step7") + tdSql.execute('reset query cache') + tdSql.query('select count(*) from tb1') + tdSql.checkData(0, 0, rid0 - 1 + 1) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/import_update_0.py b/tests/pytest/import_merge/import_update_0.py new file mode 100644 index 0000000000000000000000000000000000000000..f24a4739644fffe14fd9273ee4501d91a3447cfb --- /dev/null +++ b/tests/pytest/import_merge/import_update_0.py @@ -0,0 +1,1913 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +from util.dnodes import * +import random +import time + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.ts = 1600000000000 + self.num = 50 + self.num4096 = 5 + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def run(self): + tdSql.prepare() + # test case for https://jira.taosdata.com:18080/browse/TD-5062 + + startTime = time.time() + + tdSql.execute('''drop database if exists test_updata_0 ;''') + # update 0 不更新 ; update 1 覆盖更新 ;update 2 合并更新 + tdLog.info("========== test database updata = 0 ==========") + tdSql.execute('''create database test_updata_0 update 0 minrows 10 maxrows 200 keep 36500;;''') + tdSql.execute('''use test_updata_0;''') + tdSql.execute('''create stable stable_1 + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint, + q_bool bool , q_binary binary(10) , q_nchar nchar(10) , q_float float , q_double double , q_ts timestamp) + tags(loc nchar(20) , t_int int);''') + tdSql.execute('''create table table_1 using stable_1 tags('table_1' , '1' )''') + tdSql.execute('''create table table_2 using stable_1 tags('table_2' , '2' )''') + tdSql.execute('''create table table_3 using stable_1 tags('table_3' , '3' )''') + + #regular table + tdSql.execute('''create table regular_table_1 + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint, + q_bool bool , q_binary binary(10) , q_nchar nchar(10) , q_float float , q_double double , q_ts timestamp) ;''') + tdSql.execute('''create table regular_table_2 + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint, + q_bool bool , q_binary binary(10) , q_nchar nchar(10) , q_float float , q_double double , q_ts timestamp) ;''') + tdSql.execute('''create table regular_table_3 + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint, + q_bool bool , q_binary binary(10) , q_nchar nchar(10) , q_float float , q_double double , q_ts timestamp) ;''') + + + tdLog.info("========== test1.1 : insert data , check data==========") + tdLog.info("========== regular_table ==========") + tdSql.execute('''insert into regular_table_1 values( %d , 0, 0, 0, 0, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 200)) + sql = '''select * from regular_table_1 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.execute('''insert into regular_table_1 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 200)) + sql = '''select * from regular_table_1 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into regular_table_1 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts - 500)) + sql = '''select * from regular_table_1 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into regular_table_1 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 500)) + sql = '''select * from regular_table_1 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdLog.info("========== stable ==========") + tdSql.execute('''insert into table_1 values( %d , 0, 0, 0, 0, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 200)) + sql = '''select * from table_1 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + sql = '''select * from stable_1 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.execute('''insert into table_1 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 200)) + sql = '''select * from table_1 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into table_1 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts - 500)) + sql = '''select * from table_1 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into table_1 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 500)) + sql = '''select * from table_1 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + + tdLog.info("========== 4096 regular_table ==========") + sql = "create table regular_table_4096_1 (ts timestamp, " + for i in range(500): + sql += "int_%d int, " % (i + 1) + for i in range(500,1000): + sql += "smallint_%d smallint, " % (i + 1) + for i in range(1000,1500): + sql += "tinyint_%d tinyint, " % (i + 1) + for i in range(1500,2000): + sql += "double_%d double, " % (i + 1) + for i in range(2000,2500): + sql += "float_%d float, " % (i + 1) + for i in range(2500,3000): + sql += "bool_%d bool, " % (i + 1) + for i in range(3000,3500): + sql += "bigint_%d bigint, " % (i + 1) + for i in range(3500,3800): + sql += "nchar_%d nchar(4), " % (i + 1) + for i in range(3800,4090): + sql += "binary_%d binary(10), " % (i + 1) + for i in range(4090,4094): + sql += "timestamp_%d timestamp, " % (i + 1) + sql += "col4095 binary(22))" + tdLog.info(len(sql)) + tdSql.execute(sql) + + for i in range(self.num4096): + sql = "insert into regular_table_4096_1 values(%d, " + for j in range(4090): + str = "'%s', " % 'NULL' + sql += str + for j in range(4090,4094): + str = "%s, " % (self.ts + j) + sql += str + sql += "'%s')" % (self.ts + i) + tdSql.execute(sql % (self.ts + i)) + tdSql.query('''select * from regular_table_4096_1 where ts = %d ;''' %(self.ts)) + tdSql.checkCols(4096) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4095,'1600000000000') + + sql = '''insert into regular_table_4096_1 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4095 ) + values('2020-09-10 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-10 20:26:44.090','1500000000000');''' + tdSql.execute(sql) + tdSql.query("select * from regular_table_4096_1 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4095,'1500000000000') + + tdLog.info("========== 4096 stable ==========") + sql = "create stable stable_4096_1 (ts timestamp, " + for i in range(500): + sql += "int_%d int, " % (i + 1) + for i in range(500,1000): + sql += "smallint_%d smallint, " % (i + 1) + for i in range(1000,1500): + sql += "tinyint_%d tinyint, " % (i + 1) + for i in range(1500,2000): + sql += "double_%d double, " % (i + 1) + for i in range(2000,2500): + sql += "float_%d float, " % (i + 1) + for i in range(2500,3000): + sql += "bool_%d bool, " % (i + 1) + for i in range(3000,3500): + sql += "bigint_%d bigint, " % (i + 1) + for i in range(3500,3800): + sql += "nchar_%d nchar(4), " % (i + 1) + for i in range(3800,4090): + sql += "binary_%d binary(10), " % (i + 1) + for i in range(4090,4092): + sql += "timestamp_%d timestamp, " % (i + 1) + sql += " col4093 binary(22)) " + sql += " tags (loc nchar(20),tag_1 int) " + tdLog.info(len(sql)) + tdSql.execute(sql) + + sql = " create table table_4096_1 using stable_4096_1 tags ('table_4096_1',1); " + tdSql.execute(sql) + + for i in range(self.num4096): + sql = "insert into table_4096_1 values(%d, " + for j in range(4090): + str = "'%s', " % 'NULL' + sql += str + for j in range(4090,4092): + str = "%s, " % (self.ts + j) + sql += str + sql += "'%s')" % (self.ts + i) + tdSql.execute(sql % (self.ts + i)) + tdSql.query('''select * from table_4096_1 where ts = %d ;''' %(self.ts)) + tdSql.checkCols(4094) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + tdSql.query('''select * from stable_4096_1 where ts = %d ;''' %(self.ts)) + tdSql.checkCols(4096) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + + sql = '''insert into table_4096_1 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4093 ) + values('2020-09-10 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-10 20:26:44.090','1500000000000');''' + tdSql.execute(sql) + tdSql.query("select * from table_4096_1 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4094) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4093,'1500000000000') + tdSql.query("select * from stable_4096_1 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4093,'1500000000000') + + # minrows 10 maxrows 200 + for i in range(self.num): + tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, 0, 'binary.%s', 'nchar.%s', %f, %f, %d)''' + % (self.ts -100 + i, i, i, i, i, i, i, i, i, self.ts -100 + i)) + tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, false, 'binary%s', 'nchar%s', %f, %f, %d)''' + % (self.ts + i, random.randint(-2147483647, 2147483647), + random.randint(-9223372036854775807, 9223372036854775807), random.randint(-32767, 32767), + random.randint(-127, 127), random.randint(-99, 99), random.randint(-9999, 9999), + random.uniform(-100000,100000), random.uniform(-1000000000,1000000000), self.ts + i)) + + tdSql.execute('''insert into table_1 values(%d, %d, %d, %d, %d, 0, 'binary.%s', 'nchar.%s', %f, %f, %d)''' + % (self.ts -100 + i, i, i, i, i, i, i, i, i, self.ts -100 + i)) + tdSql.execute('''insert into table_1 values(%d, %d, %d, %d, %d, false, 'binary%s', 'nchar%s', %f, %f, %d)''' + % (self.ts + i, random.randint(-2147483647, 2147483647), + random.randint(-9223372036854775807, 9223372036854775807), random.randint(-32767, 32767), + random.randint(-127, 127), random.randint(-99, 99), random.randint(-9999, 9999), + random.uniform(-100000,100000), random.uniform(-1000000000,1000000000), self.ts + i)) + + tdLog.info("========== regular_table ==========") + tdSql.execute('''insert into regular_table_1 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts - 200)) + sql = '''select * from regular_table_1 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.execute('''insert into regular_table_1 values( %d , 0, 0, 0, 0, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 200)) + sql = '''select * from regular_table_1 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.error('''insert into regular_table_1 values( %d , -2147483648, -9223372036854775807, -32767, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into regular_table_1 values( %d , -2147483647, -9223372036854775808, -32767, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into regular_table_1 values( %d , -2147483647, -9223372036854775807, -32768, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into regular_table_1 values( %d , -2147483647, -9223372036854775807, -32767, -128, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into regular_table_1 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-0123', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into regular_table_1 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-0', 'nchar-01234', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + + tdSql.execute('''insert into regular_table_1 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-012', 'nchar-0123', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + sql = '''select * from regular_table_1 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.error('''insert into regular_table_1 values( %d , 2147483648, 9223372036854775807, 32767, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into regular_table_1 values( %d , 2147483647, 9223372036854775808, 32767, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into regular_table_1 values( %d , 2147483647, 9223372036854775807, 32768, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into regular_table_1 values( %d , 2147483647, 9223372036854775807, 32767, 128, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into regular_table_1 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+0123', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into regular_table_1 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+0', 'nchar+01234', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + + tdSql.execute('''insert into regular_table_1 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+012', 'nchar+0123', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + sql = '''select * from regular_table_1 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdLog.info("========== stable ==========") + tdSql.execute('''insert into table_1 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts - 200)) + sql = '''select * from table_1 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + sql = '''select * from stable_1 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.execute('''insert into table_1 values( %d , 0, 0, 0, 0, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 200)) + sql = '''select * from table_1 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.error('''insert into table_1 values( %d , -2147483648, -9223372036854775807, -32767, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_1 values( %d , -2147483647, -9223372036854775808, -32767, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_1 values( %d , -2147483647, -9223372036854775807, -32768, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_1 values( %d , -2147483647, -9223372036854775807, -32767, -128, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_1 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-0123', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_1 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-0', 'nchar-01234', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + + tdSql.execute('''insert into table_1 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-012', 'nchar-0123', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + sql = '''select * from table_1 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.error('''insert into table_1 values( %d , 2147483648, 9223372036854775807, 32767, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_1 values( %d , 2147483647, 9223372036854775808, 32767, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_1 values( %d , 2147483647, 9223372036854775807, 32768, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_1 values( %d , 2147483647, 9223372036854775807, 32767, 128, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_1 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+0123', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_1 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+0', 'nchar+01234', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + + tdSql.execute('''insert into table_1 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+012', 'nchar+0123', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + sql = '''select * from table_1 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdLog.info("========== 4096 regular_table ==========") + sql = '''insert into regular_table_4096_1 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4095 ) + values('2020-09-13 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-13 20:26:44.090','1600000000000');''' + tdSql.execute(sql) + tdSql.query("select * from regular_table_4096_1 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4095,'1600000000000') + + sql = '''insert into regular_table_4096_1 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4095 ) + values('2020-09-10 20:26:40.000' , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL);''' + tdSql.execute(sql) + tdSql.query("select * from regular_table_4096_1 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4095,'1500000000000') + + tdLog.info("========== 4096 stable ==========") + sql = '''insert into table_4096_1 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4093 ) + values('2020-09-13 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-13 20:26:44.090','1600000000000');''' + tdSql.execute(sql) + tdSql.query("select * from table_4096_1 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4094) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + tdSql.query("select * from stable_4096_1 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + + sql = '''insert into table_4096_1 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4093 ) + values('2020-09-10 20:26:40.000' , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL);''' + tdSql.execute(sql) + tdSql.query("select * from table_4096_1 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4094) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4093,'1500000000000') + tdSql.query("select * from stable_4096_1 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4093,'1500000000000') + + + tdLog.info("========== test1.2 : insert data , taosdemo force data dropping disk , check data==========") + tdLog.info("========== regular_table ==========") + tdSql.execute('''insert into regular_table_2 values( %d , 0, 0, 0, 0, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 200)) + sql = '''select * from regular_table_2 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.execute('''insert into regular_table_2 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 200)) + sql = '''select * from regular_table_2 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into regular_table_2 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts - 500)) + sql = '''select * from regular_table_2 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into regular_table_2 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 500)) + sql = '''select * from regular_table_2 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + + tdLog.info("========== stable ==========") + tdSql.execute('''insert into table_2 values( %d , 0, 0, 0, 0, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 200)) + sql = '''select * from table_2 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + sql = '''select * from stable_1 where loc = 'table_2' and ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.execute('''insert into table_2 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 200)) + sql = '''select * from table_2 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where loc = 'table_2' and ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into table_2 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts - 500)) + sql = '''select * from table_2 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where loc = 'table_2' and ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into table_2 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 500)) + sql = '''select * from table_2 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where loc = 'table_2' and ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + + tdLog.info("========== 4096 regular_table ==========") + sql = "create table regular_table_4096_2 (ts timestamp, " + for i in range(500): + sql += "int_%d int, " % (i + 1) + for i in range(500,1000): + sql += "smallint_%d smallint, " % (i + 1) + for i in range(1000,1500): + sql += "tinyint_%d tinyint, " % (i + 1) + for i in range(1500,2000): + sql += "double_%d double, " % (i + 1) + for i in range(2000,2500): + sql += "float_%d float, " % (i + 1) + for i in range(2500,3000): + sql += "bool_%d bool, " % (i + 1) + for i in range(3000,3500): + sql += "bigint_%d bigint, " % (i + 1) + for i in range(3500,3800): + sql += "nchar_%d nchar(4), " % (i + 1) + for i in range(3800,4090): + sql += "binary_%d binary(10), " % (i + 1) + for i in range(4090,4094): + sql += "timestamp_%d timestamp, " % (i + 1) + sql += "col4095 binary(22))" + tdLog.info(len(sql)) + tdSql.execute(sql) + + for i in range(self.num4096): + sql = "insert into regular_table_4096_2 values(%d, " + for j in range(4090): + str = "'%s', " % 'NULL' + sql += str + for j in range(4090,4094): + str = "%s, " % (self.ts + j) + sql += str + sql += "'%s')" % (self.ts + i) + tdSql.execute(sql % (self.ts + i)) + tdSql.query('''select * from regular_table_4096_2 where ts = %d ;''' %(self.ts)) + tdSql.checkCols(4096) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4095,'1600000000000') + + sql = '''insert into regular_table_4096_2 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4095 ) + values('2020-09-10 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-10 20:26:44.090','1500000000000');''' + tdSql.execute(sql) + tdSql.query("select * from regular_table_4096_2 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4095,'1500000000000') + + tdLog.info("========== 4096 stable ==========") + sql = "create stable stable_4096_2 (ts timestamp, " + for i in range(500): + sql += "int_%d int, " % (i + 1) + for i in range(500,1000): + sql += "smallint_%d smallint, " % (i + 1) + for i in range(1000,1500): + sql += "tinyint_%d tinyint, " % (i + 1) + for i in range(1500,2000): + sql += "double_%d double, " % (i + 1) + for i in range(2000,2500): + sql += "float_%d float, " % (i + 1) + for i in range(2500,3000): + sql += "bool_%d bool, " % (i + 1) + for i in range(3000,3500): + sql += "bigint_%d bigint, " % (i + 1) + for i in range(3500,3800): + sql += "nchar_%d nchar(4), " % (i + 1) + for i in range(3800,4090): + sql += "binary_%d binary(10), " % (i + 1) + for i in range(4090,4092): + sql += "timestamp_%d timestamp, " % (i + 1) + sql += " col4093 binary(22)) " + sql += " tags (loc nchar(20),tag_1 int) " + tdLog.info(len(sql)) + tdSql.execute(sql) + + sql = " create table table_4096_2 using stable_4096_2 tags ('table_4096_2',1); " + tdSql.execute(sql) + + for i in range(self.num4096): + sql = "insert into table_4096_2 values(%d, " + for j in range(4090): + str = "'%s', " % 'NULL' + sql += str + for j in range(4090,4092): + str = "%s, " % (self.ts + j) + sql += str + sql += "'%s')" % (self.ts + i) + tdSql.execute(sql % (self.ts + i)) + tdSql.query('''select * from table_4096_2 where ts = %d ;''' %(self.ts)) + tdSql.checkCols(4094) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + tdSql.query('''select * from stable_4096_2 where ts = %d ;''' %(self.ts)) + tdSql.checkCols(4096) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + + sql = '''insert into table_4096_2 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4093 ) + values('2020-09-10 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-10 20:26:44.090','1500000000000');''' + tdSql.execute(sql) + tdSql.query("select * from table_4096_2 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4094) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4093,'1500000000000') + tdSql.query("select * from stable_4096_2 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4093,'1500000000000') + + + # taosdemo force data dropping disk + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + os.system("%staosdemo -N -d taosdemo -t 100 -n 100 -l 1000 -y" % binPath) + + tdSql.execute('''insert into table_2 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts - 200)) + sql = '''select * from table_2 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + sql = '''select * from stable_1 where loc = 'table_2' and ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.execute('''insert into table_2 values( %d , 0, 0, 0, 0, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 200)) + sql = '''select * from table_2 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where loc = 'table_2' and ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.error('''insert into table_2 values( %d , -2147483648, -9223372036854775807, -32767, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_2 values( %d , -2147483647, -9223372036854775808, -32767, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_2 values( %d , -2147483647, -9223372036854775807, -32768, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_2 values( %d , -2147483647, -9223372036854775807, -32767, -128, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_2 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-0123', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_2 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-0', 'nchar-01234', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + + tdSql.execute('''insert into table_2 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-012', 'nchar-0123', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + sql = '''select * from table_2 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where loc = 'table_2' and ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.error('''insert into table_2 values( %d , 2147483648, 9223372036854775807, 32767, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_2 values( %d , 2147483647, 9223372036854775808, 32767, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_2 values( %d , 2147483647, 9223372036854775807, 32768, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_2 values( %d , 2147483647, 9223372036854775807, 32767, 128, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_2 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+0123', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_2 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+0', 'nchar+01234', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + + tdSql.execute('''insert into table_2 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+012', 'nchar+0123', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + sql = '''select * from table_2 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where loc = 'table_2' and ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdLog.info("========== 4096 regular_table ==========") + sql = '''insert into regular_table_4096_2 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4095 ) + values('2020-09-13 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-13 20:26:44.090','1600000000000');''' + tdSql.execute(sql) + tdSql.query("select * from regular_table_4096_2 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4095,'1600000000000') + + sql = '''insert into regular_table_4096_2 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4095 ) + values('2020-09-10 20:26:40.000' , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL);''' + tdSql.execute(sql) + tdSql.query("select * from regular_table_4096_2 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4095,'1500000000000') + + tdLog.info("========== 4096 stable ==========") + sql = '''insert into table_4096_2 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4093 ) + values('2020-09-13 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-13 20:26:44.090','1600000000000');''' + tdSql.execute(sql) + tdSql.query("select * from table_4096_2 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4094) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + tdSql.query("select * from stable_4096_2 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + + sql = '''insert into table_4096_2 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4093 ) + values('2020-09-10 20:26:40.000' , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL);''' + tdSql.execute(sql) + tdSql.query("select * from table_4096_2 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4094) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4093,'1500000000000') + tdSql.query("select * from stable_4096_2 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4093,'1500000000000') + + tdLog.info("========== test1.3 : insert data , tdDnodes restart force data dropping disk , check data==========") + tdLog.info("========== regular_table ==========") + tdSql.execute('''insert into regular_table_3 values( %d , 0, 0, 0, 0, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 200)) + sql = '''select * from regular_table_3 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.execute('''insert into regular_table_3 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 200)) + sql = '''select * from regular_table_3 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into regular_table_3 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts - 500)) + sql = '''select * from regular_table_3 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into regular_table_3 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 500)) + sql = '''select * from regular_table_3 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdLog.info("========== stable ==========") + tdSql.execute('''insert into table_3 values( %d , 0, 0, 0, 0, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 200)) + sql = '''select * from table_3 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + sql = '''select * from stable_1 where loc = 'table_3' and ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.execute('''insert into table_3 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 200)) + sql = '''select * from table_3 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where loc = 'table_3' and ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into table_3 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts - 500)) + sql = '''select * from table_3 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where loc = 'table_3' and ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into table_3 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 500)) + sql = '''select * from table_3 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where loc = 'table_3' and ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + + tdLog.info("========== 4096 regular_table ==========") + sql = "create table regular_table_4096_3 (ts timestamp, " + for i in range(500): + sql += "int_%d int, " % (i + 1) + for i in range(500,1000): + sql += "smallint_%d smallint, " % (i + 1) + for i in range(1000,1500): + sql += "tinyint_%d tinyint, " % (i + 1) + for i in range(1500,2000): + sql += "double_%d double, " % (i + 1) + for i in range(2000,2500): + sql += "float_%d float, " % (i + 1) + for i in range(2500,3000): + sql += "bool_%d bool, " % (i + 1) + for i in range(3000,3500): + sql += "bigint_%d bigint, " % (i + 1) + for i in range(3500,3800): + sql += "nchar_%d nchar(4), " % (i + 1) + for i in range(3800,4090): + sql += "binary_%d binary(10), " % (i + 1) + for i in range(4090,4094): + sql += "timestamp_%d timestamp, " % (i + 1) + sql += "col4095 binary(22))" + tdLog.info(len(sql)) + tdSql.execute(sql) + + for i in range(self.num4096): + sql = "insert into regular_table_4096_3 values(%d, " + for j in range(4090): + str = "'%s', " % 'NULL' + sql += str + for j in range(4090,4094): + str = "%s, " % (self.ts + j) + sql += str + sql += "'%s')" % (self.ts + i) + tdSql.execute(sql % (self.ts + i)) + tdSql.query('''select * from regular_table_4096_3 where ts = %d ;''' %(self.ts)) + tdSql.checkCols(4096) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4095,'1600000000000') + + sql = '''insert into regular_table_4096_3 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4095 ) + values('2020-09-10 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-10 20:26:44.090','1500000000000');''' + tdSql.execute(sql) + tdSql.query("select * from regular_table_4096_3 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4095,'1500000000000') + + tdLog.info("========== 4096 stable ==========") + sql = "create stable stable_4096_3 (ts timestamp, " + for i in range(500): + sql += "int_%d int, " % (i + 1) + for i in range(500,1000): + sql += "smallint_%d smallint, " % (i + 1) + for i in range(1000,1500): + sql += "tinyint_%d tinyint, " % (i + 1) + for i in range(1500,2000): + sql += "double_%d double, " % (i + 1) + for i in range(2000,2500): + sql += "float_%d float, " % (i + 1) + for i in range(2500,3000): + sql += "bool_%d bool, " % (i + 1) + for i in range(3000,3500): + sql += "bigint_%d bigint, " % (i + 1) + for i in range(3500,3800): + sql += "nchar_%d nchar(4), " % (i + 1) + for i in range(3800,4090): + sql += "binary_%d binary(10), " % (i + 1) + for i in range(4090,4092): + sql += "timestamp_%d timestamp, " % (i + 1) + sql += " col4093 binary(22)) " + sql += " tags (loc nchar(20),tag_1 int) " + tdLog.info(len(sql)) + tdSql.execute(sql) + + sql = " create table table_4096_3 using stable_4096_3 tags ('table_4096_3',1); " + tdSql.execute(sql) + + for i in range(self.num4096): + sql = "insert into table_4096_3 values(%d, " + for j in range(4090): + str = "'%s', " % 'NULL' + sql += str + for j in range(4090,4092): + str = "%s, " % (self.ts + j) + sql += str + sql += "'%s')" % (self.ts + i) + tdSql.execute(sql % (self.ts + i)) + tdSql.query('''select * from table_4096_3 where ts = %d ;''' %(self.ts)) + tdSql.checkCols(4094) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + tdSql.query('''select * from stable_4096_3 where ts = %d ;''' %(self.ts)) + tdSql.checkCols(4096) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + + sql = '''insert into table_4096_3 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4093 ) + values('2020-09-10 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-10 20:26:44.090','1500000000000');''' + tdSql.execute(sql) + tdSql.query("select * from table_4096_3 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4094) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4093,'1500000000000') + tdSql.query("select * from stable_4096_3 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4093,'1500000000000') + + # tdDnodes restart force data dropping disk + tdDnodes.stop(1) + tdDnodes.start(1) + + tdLog.info("========== regular_table ==========") + tdSql.execute('''insert into regular_table_3 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts - 200)) + sql = '''select * from regular_table_3 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.execute('''insert into regular_table_3 values( %d , 0, 0, 0, 0, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 200)) + sql = '''select * from regular_table_3 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.error('''insert into regular_table_3 values( %d , -2147483648, -9223372036854775807, -32767, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into regular_table_3 values( %d , -2147483647, -9223372036854775808, -32767, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into regular_table_3 values( %d , -2147483647, -9223372036854775807, -32768, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into regular_table_3 values( %d , -2147483647, -9223372036854775807, -32767, -128, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into regular_table_3 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-0123', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into regular_table_3 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-0', 'nchar-01234', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + + tdSql.execute('''insert into regular_table_3 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-012', 'nchar-0123', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + sql = '''select * from regular_table_3 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.error('''insert into regular_table_3 values( %d , 2147483648, 9223372036854775807, 32767, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into regular_table_3 values( %d , 2147483647, 9223372036854775808, 32767, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into regular_table_3 values( %d , 2147483647, 9223372036854775807, 32768, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into regular_table_3 values( %d , 2147483647, 9223372036854775807, 32767, 128, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into regular_table_3 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+0123', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into regular_table_3 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+0', 'nchar+01234', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + + tdSql.execute('''insert into regular_table_3 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+012', 'nchar+0123', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + sql = '''select * from regular_table_3 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdLog.info("========== stable ==========") + tdSql.execute('''insert into table_3 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts - 200)) + sql = '''select * from table_3 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + sql = '''select * from stable_1 where loc = 'table_3' and ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.execute('''insert into table_3 values( %d , 0, 0, 0, 0, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 200)) + sql = '''select * from table_3 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where loc = 'table_3' and ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.error('''insert into table_3 values( %d , -2147483648, -9223372036854775807, -32767, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_3 values( %d , -2147483647, -9223372036854775808, -32767, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_3 values( %d , -2147483647, -9223372036854775807, -32768, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_3 values( %d , -2147483647, -9223372036854775807, -32767, -128, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_3 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-0123', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_3 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-0', 'nchar-01234', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + + tdSql.execute('''insert into table_3 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-012', 'nchar-0123', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + sql = '''select * from table_3 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where loc = 'table_3' and ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.error('''insert into table_3 values( %d , 2147483648, 9223372036854775807, 32767, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_3 values( %d , 2147483647, 9223372036854775808, 32767, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_3 values( %d , 2147483647, 9223372036854775807, 32768, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_3 values( %d , 2147483647, 9223372036854775807, 32767, 128, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_3 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+0123', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_3 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+0', 'nchar+01234', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + + tdSql.execute('''insert into table_3 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+012', 'nchar+0123', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + sql = '''select * from table_3 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where loc = 'table_3' and ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + + tdLog.info("========== 4096 regular_table ==========") + sql = '''insert into regular_table_4096_3 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4095 ) + values('2020-09-13 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-13 20:26:44.090','1600000000000');''' + tdSql.execute(sql) + tdSql.query("select * from regular_table_4096_3 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4095,'1600000000000') + + sql = '''insert into regular_table_4096_3 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4095 ) + values('2020-09-10 20:26:40.000' , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL);''' + tdSql.execute(sql) + tdSql.query("select * from regular_table_4096_3 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4095,'1500000000000') + + tdLog.info("========== 4096 stable ==========") + sql = '''insert into table_4096_3 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4093 ) + values('2020-09-13 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-13 20:26:44.090','1600000000000');''' + tdSql.execute(sql) + tdSql.query("select * from table_4096_3 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4094) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + tdSql.query("select * from stable_4096_3 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + + sql = '''insert into table_4096_3 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4093 ) + values('2020-09-10 20:26:40.000' , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL);''' + tdSql.execute(sql) + tdSql.query("select * from table_4096_3 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4094) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4093,'1500000000000') + tdSql.query("select * from stable_4096_3 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4093,'1500000000000') + + endTime = time.time() + print("total time %ds" % (endTime - startTime)) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/import_update_1.py b/tests/pytest/import_merge/import_update_1.py new file mode 100644 index 0000000000000000000000000000000000000000..b3f4b46e11549f934069e32349c0f72050ae21f8 --- /dev/null +++ b/tests/pytest/import_merge/import_update_1.py @@ -0,0 +1,1913 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +from util.dnodes import * +import random +import time + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.ts = 1600000000000 + self.num = 50 + self.num4096 = 5 + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def run(self): + tdSql.prepare() + # test case for https://jira.taosdata.com:18080/browse/TD-5062 + + startTime = time.time() + + tdSql.execute('''drop database if exists test_updata_1 ;''') + # update 0 不更新 ; update 1 覆盖更新 ;update 2 合并更新 + tdLog.info("========== test database updata = 1 ==========") + tdSql.execute('''create database test_updata_1 update 1 minrows 10 maxrows 200 keep 36500;''') + tdSql.execute('''use test_updata_1;''') + tdSql.execute('''create stable stable_1 + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint, + q_bool bool , q_binary binary(10) , q_nchar nchar(10) , q_float float , q_double double , q_ts timestamp) + tags(loc nchar(20) , t_int int);''') + tdSql.execute('''create table table_1 using stable_1 tags('table_1' , '1' )''') + tdSql.execute('''create table table_2 using stable_1 tags('table_2' , '2' )''') + tdSql.execute('''create table table_3 using stable_1 tags('table_3' , '3' )''') + + #regular table + tdSql.execute('''create table regular_table_1 + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint, + q_bool bool , q_binary binary(10) , q_nchar nchar(10) , q_float float , q_double double , q_ts timestamp) ;''') + tdSql.execute('''create table regular_table_2 + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint, + q_bool bool , q_binary binary(10) , q_nchar nchar(10) , q_float float , q_double double , q_ts timestamp) ;''') + tdSql.execute('''create table regular_table_3 + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint, + q_bool bool , q_binary binary(10) , q_nchar nchar(10) , q_float float , q_double double , q_ts timestamp) ;''') + + + tdLog.info("========== test1.1 : insert data , check data==========") + tdLog.info("========== regular_table ==========") + tdSql.execute('''insert into regular_table_1 values( %d , 0, 0, 0, 0, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 200)) + sql = '''select * from regular_table_1 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.execute('''insert into regular_table_1 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 200)) + sql = '''select * from regular_table_1 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into regular_table_1 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts - 500)) + sql = '''select * from regular_table_1 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into regular_table_1 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 500)) + sql = '''select * from regular_table_1 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdLog.info("========== stable ==========") + tdSql.execute('''insert into table_1 values( %d , 0, 0, 0, 0, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 200)) + sql = '''select * from table_1 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + sql = '''select * from stable_1 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.execute('''insert into table_1 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 200)) + sql = '''select * from table_1 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into table_1 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts - 500)) + sql = '''select * from table_1 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into table_1 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 500)) + sql = '''select * from table_1 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + + tdLog.info("========== 4096 regular_table ==========") + sql = "create table regular_table_4096_1 (ts timestamp, " + for i in range(500): + sql += "int_%d int, " % (i + 1) + for i in range(500,1000): + sql += "smallint_%d smallint, " % (i + 1) + for i in range(1000,1500): + sql += "tinyint_%d tinyint, " % (i + 1) + for i in range(1500,2000): + sql += "double_%d double, " % (i + 1) + for i in range(2000,2500): + sql += "float_%d float, " % (i + 1) + for i in range(2500,3000): + sql += "bool_%d bool, " % (i + 1) + for i in range(3000,3500): + sql += "bigint_%d bigint, " % (i + 1) + for i in range(3500,3800): + sql += "nchar_%d nchar(4), " % (i + 1) + for i in range(3800,4090): + sql += "binary_%d binary(10), " % (i + 1) + for i in range(4090,4094): + sql += "timestamp_%d timestamp, " % (i + 1) + sql += "col4095 binary(22))" + tdLog.info(len(sql)) + tdSql.execute(sql) + + for i in range(self.num4096): + sql = "insert into regular_table_4096_1 values(%d, " + for j in range(4090): + str = "'%s', " % 'NULL' + sql += str + for j in range(4090,4094): + str = "%s, " % (self.ts + j) + sql += str + sql += "'%s')" % (self.ts + i) + tdSql.execute(sql % (self.ts + i)) + tdSql.query('''select * from regular_table_4096_1 where ts = %d ;''' %(self.ts)) + tdSql.checkCols(4096) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4095,'1600000000000') + + sql = '''insert into regular_table_4096_1 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4095 ) + values('2020-09-10 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-10 20:26:44.090','1500000000000');''' + tdSql.execute(sql) + tdSql.query("select * from regular_table_4096_1 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4095,'1500000000000') + + tdLog.info("========== 4096 stable ==========") + sql = "create stable stable_4096_1 (ts timestamp, " + for i in range(500): + sql += "int_%d int, " % (i + 1) + for i in range(500,1000): + sql += "smallint_%d smallint, " % (i + 1) + for i in range(1000,1500): + sql += "tinyint_%d tinyint, " % (i + 1) + for i in range(1500,2000): + sql += "double_%d double, " % (i + 1) + for i in range(2000,2500): + sql += "float_%d float, " % (i + 1) + for i in range(2500,3000): + sql += "bool_%d bool, " % (i + 1) + for i in range(3000,3500): + sql += "bigint_%d bigint, " % (i + 1) + for i in range(3500,3800): + sql += "nchar_%d nchar(4), " % (i + 1) + for i in range(3800,4090): + sql += "binary_%d binary(10), " % (i + 1) + for i in range(4090,4092): + sql += "timestamp_%d timestamp, " % (i + 1) + sql += " col4093 binary(22)) " + sql += " tags (loc nchar(20),tag_1 int) " + tdLog.info(len(sql)) + tdSql.execute(sql) + + sql = " create table table_4096_1 using stable_4096_1 tags ('table_4096_1',1); " + tdSql.execute(sql) + + for i in range(self.num4096): + sql = "insert into table_4096_1 values(%d, " + for j in range(4090): + str = "'%s', " % 'NULL' + sql += str + for j in range(4090,4092): + str = "%s, " % (self.ts + j) + sql += str + sql += "'%s')" % (self.ts + i) + tdSql.execute(sql % (self.ts + i)) + tdSql.query('''select * from table_4096_1 where ts = %d ;''' %(self.ts)) + tdSql.checkCols(4094) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + tdSql.query('''select * from stable_4096_1 where ts = %d ;''' %(self.ts)) + tdSql.checkCols(4096) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + + sql = '''insert into table_4096_1 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4093 ) + values('2020-09-10 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-10 20:26:44.090','1500000000000');''' + tdSql.execute(sql) + tdSql.query("select * from table_4096_1 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4094) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4093,'1500000000000') + tdSql.query("select * from stable_4096_1 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4093,'1500000000000') + + # minrows 10 maxrows 200 + for i in range(self.num): + tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, 0, 'binary.%s', 'nchar.%s', %f, %f, %d)''' + % (self.ts -100 + i, i, i, i, i, i, i, i, i, self.ts -100 + i)) + tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, false, 'binary%s', 'nchar%s', %f, %f, %d)''' + % (self.ts + i, random.randint(-2147483647, 2147483647), + random.randint(-9223372036854775807, 9223372036854775807), random.randint(-32767, 32767), + random.randint(-127, 127), random.randint(-99, 99), random.randint(-9999, 9999), + random.uniform(-100000,100000), random.uniform(-1000000000,1000000000), self.ts + i)) + + tdSql.execute('''insert into table_1 values(%d, %d, %d, %d, %d, 0, 'binary.%s', 'nchar.%s', %f, %f, %d)''' + % (self.ts -100 + i, i, i, i, i, i, i, i, i, self.ts -100 + i)) + tdSql.execute('''insert into table_1 values(%d, %d, %d, %d, %d, false, 'binary%s', 'nchar%s', %f, %f, %d)''' + % (self.ts + i, random.randint(-2147483647, 2147483647), + random.randint(-9223372036854775807, 9223372036854775807), random.randint(-32767, 32767), + random.randint(-127, 127), random.randint(-99, 99), random.randint(-9999, 9999), + random.uniform(-100000,100000), random.uniform(-1000000000,1000000000), self.ts + i)) + + tdLog.info("========== regular_table ==========") + tdSql.execute('''insert into regular_table_1 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts - 200)) + sql = '''select * from regular_table_1 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into regular_table_1 values( %d , 0, 0, 0, 0, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 200)) + sql = '''select * from regular_table_1 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+0') + tdSql.checkData(0,7,'nchar+0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.error('''insert into regular_table_1 values( %d , -2147483648, -9223372036854775807, -32767, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into regular_table_1 values( %d , -2147483647, -9223372036854775808, -32767, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into regular_table_1 values( %d , -2147483647, -9223372036854775807, -32768, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into regular_table_1 values( %d , -2147483647, -9223372036854775807, -32767, -128, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into regular_table_1 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-0123', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into regular_table_1 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-0', 'nchar-01234', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + + tdSql.execute('''insert into regular_table_1 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-012', 'nchar-0123', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + sql = '''select * from regular_table_1 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,-2147483647) + tdSql.checkData(0,2,-9223372036854775807) + tdSql.checkData(0,3,-32767) + tdSql.checkData(0,4,-127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-012') + tdSql.checkData(0,7,'nchar-0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.error('''insert into regular_table_1 values( %d , 2147483648, 9223372036854775807, 32767, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into regular_table_1 values( %d , 2147483647, 9223372036854775808, 32767, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into regular_table_1 values( %d , 2147483647, 9223372036854775807, 32768, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into regular_table_1 values( %d , 2147483647, 9223372036854775807, 32767, 128, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into regular_table_1 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+0123', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into regular_table_1 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+0', 'nchar+01234', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + + tdSql.execute('''insert into regular_table_1 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+012', 'nchar+0123', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + sql = '''select * from regular_table_1 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,2147483647) + tdSql.checkData(0,2,9223372036854775807) + tdSql.checkData(0,3,32767) + tdSql.checkData(0,4,127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+012') + tdSql.checkData(0,7,'nchar+0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdLog.info("========== stable ==========") + tdSql.execute('''insert into table_1 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts - 200)) + sql = '''select * from table_1 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into table_1 values( %d , 0, 0, 0, 0, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 200)) + sql = '''select * from table_1 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+0') + tdSql.checkData(0,7,'nchar+0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + sql = '''select * from stable_1 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+0') + tdSql.checkData(0,7,'nchar+0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.error('''insert into table_1 values( %d , -2147483648, -9223372036854775807, -32767, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_1 values( %d , -2147483647, -9223372036854775808, -32767, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_1 values( %d , -2147483647, -9223372036854775807, -32768, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_1 values( %d , -2147483647, -9223372036854775807, -32767, -128, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_1 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-0123', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_1 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-0', 'nchar-01234', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + + tdSql.execute('''insert into table_1 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-012', 'nchar-0123', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + sql = '''select * from table_1 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,-2147483647) + tdSql.checkData(0,2,-9223372036854775807) + tdSql.checkData(0,3,-32767) + tdSql.checkData(0,4,-127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-012') + tdSql.checkData(0,7,'nchar-0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + sql = '''select * from stable_1 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,-2147483647) + tdSql.checkData(0,2,-9223372036854775807) + tdSql.checkData(0,3,-32767) + tdSql.checkData(0,4,-127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-012') + tdSql.checkData(0,7,'nchar-0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.error('''insert into table_1 values( %d , 2147483648, 9223372036854775807, 32767, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_1 values( %d , 2147483647, 9223372036854775808, 32767, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_1 values( %d , 2147483647, 9223372036854775807, 32768, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_1 values( %d , 2147483647, 9223372036854775807, 32767, 128, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_1 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+0123', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_1 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+0', 'nchar+01234', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + + tdSql.execute('''insert into table_1 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+012', 'nchar+0123', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + sql = '''select * from table_1 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,2147483647) + tdSql.checkData(0,2,9223372036854775807) + tdSql.checkData(0,3,32767) + tdSql.checkData(0,4,127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+012') + tdSql.checkData(0,7,'nchar+0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + sql = '''select * from stable_1 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,2147483647) + tdSql.checkData(0,2,9223372036854775807) + tdSql.checkData(0,3,32767) + tdSql.checkData(0,4,127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+012') + tdSql.checkData(0,7,'nchar+0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdLog.info("========== 4096 regular_table ==========") + sql = '''insert into regular_table_4096_1 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4095 ) + values('2020-09-13 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-13 20:26:44.090','1600000000000');''' + tdSql.execute(sql) + tdSql.query("select * from regular_table_4096_1 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4095,'1600000000000') + + sql = '''insert into regular_table_4096_1 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4095 ) + values('2020-09-10 20:26:40.000' , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL);''' + tdSql.execute(sql) + tdSql.query("select * from regular_table_4096_1 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,None) + tdSql.checkData(0,3801,None) + tdSql.checkData(0,4091,None) + tdSql.checkData(0,4095,None) + + tdLog.info("========== 4096 stable ==========") + sql = '''insert into table_4096_1 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4093 ) + values('2020-09-13 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-13 20:26:44.090','1600000000000');''' + tdSql.execute(sql) + tdSql.query("select * from table_4096_1 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4094) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + tdSql.query("select * from stable_4096_1 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + + sql = '''insert into table_4096_1 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4093 ) + values('2020-09-10 20:26:40.000' , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL);''' + tdSql.execute(sql) + tdSql.query("select * from table_4096_1 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4094) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,None) + tdSql.checkData(0,3801,None) + tdSql.checkData(0,4091,None) + tdSql.checkData(0,4093,None) + tdSql.query("select * from stable_4096_1 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,None) + tdSql.checkData(0,3801,None) + tdSql.checkData(0,4091,None) + tdSql.checkData(0,4093,None) + + + tdLog.info("========== test1.2 : insert data , taosdemo force data dropping disk , check data==========") + tdLog.info("========== regular_table ==========") + tdSql.execute('''insert into regular_table_2 values( %d , 0, 0, 0, 0, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 200)) + sql = '''select * from regular_table_2 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.execute('''insert into regular_table_2 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 200)) + sql = '''select * from regular_table_2 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into regular_table_2 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts - 500)) + sql = '''select * from regular_table_2 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into regular_table_2 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 500)) + sql = '''select * from regular_table_2 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + + tdLog.info("========== stable ==========") + tdSql.execute('''insert into table_2 values( %d , 0, 0, 0, 0, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 200)) + sql = '''select * from table_2 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + sql = '''select * from stable_1 where loc = 'table_2' and ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.execute('''insert into table_2 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 200)) + sql = '''select * from table_2 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where loc = 'table_2' and ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into table_2 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts - 500)) + sql = '''select * from table_2 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where loc = 'table_2' and ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into table_2 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 500)) + sql = '''select * from table_2 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where loc = 'table_2' and ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + + tdLog.info("========== 4096 regular_table ==========") + sql = "create table regular_table_4096_2 (ts timestamp, " + for i in range(500): + sql += "int_%d int, " % (i + 1) + for i in range(500,1000): + sql += "smallint_%d smallint, " % (i + 1) + for i in range(1000,1500): + sql += "tinyint_%d tinyint, " % (i + 1) + for i in range(1500,2000): + sql += "double_%d double, " % (i + 1) + for i in range(2000,2500): + sql += "float_%d float, " % (i + 1) + for i in range(2500,3000): + sql += "bool_%d bool, " % (i + 1) + for i in range(3000,3500): + sql += "bigint_%d bigint, " % (i + 1) + for i in range(3500,3800): + sql += "nchar_%d nchar(4), " % (i + 1) + for i in range(3800,4090): + sql += "binary_%d binary(10), " % (i + 1) + for i in range(4090,4094): + sql += "timestamp_%d timestamp, " % (i + 1) + sql += "col4095 binary(22))" + tdLog.info(len(sql)) + tdSql.execute(sql) + + for i in range(self.num4096): + sql = "insert into regular_table_4096_2 values(%d, " + for j in range(4090): + str = "'%s', " % 'NULL' + sql += str + for j in range(4090,4094): + str = "%s, " % (self.ts + j) + sql += str + sql += "'%s')" % (self.ts + i) + tdSql.execute(sql % (self.ts + i)) + tdSql.query('''select * from regular_table_4096_2 where ts = %d ;''' %(self.ts)) + tdSql.checkCols(4096) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4095,'1600000000000') + + sql = '''insert into regular_table_4096_2 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4095 ) + values('2020-09-10 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-10 20:26:44.090','1500000000000');''' + tdSql.execute(sql) + tdSql.query("select * from regular_table_4096_2 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4095,'1500000000000') + + tdLog.info("========== 4096 stable ==========") + sql = "create stable stable_4096_2 (ts timestamp, " + for i in range(500): + sql += "int_%d int, " % (i + 1) + for i in range(500,1000): + sql += "smallint_%d smallint, " % (i + 1) + for i in range(1000,1500): + sql += "tinyint_%d tinyint, " % (i + 1) + for i in range(1500,2000): + sql += "double_%d double, " % (i + 1) + for i in range(2000,2500): + sql += "float_%d float, " % (i + 1) + for i in range(2500,3000): + sql += "bool_%d bool, " % (i + 1) + for i in range(3000,3500): + sql += "bigint_%d bigint, " % (i + 1) + for i in range(3500,3800): + sql += "nchar_%d nchar(4), " % (i + 1) + for i in range(3800,4090): + sql += "binary_%d binary(10), " % (i + 1) + for i in range(4090,4092): + sql += "timestamp_%d timestamp, " % (i + 1) + sql += " col4093 binary(22)) " + sql += " tags (loc nchar(20),tag_1 int) " + tdLog.info(len(sql)) + tdSql.execute(sql) + + sql = " create table table_4096_2 using stable_4096_2 tags ('table_4096_2',1); " + tdSql.execute(sql) + + for i in range(self.num4096): + sql = "insert into table_4096_2 values(%d, " + for j in range(4090): + str = "'%s', " % 'NULL' + sql += str + for j in range(4090,4092): + str = "%s, " % (self.ts + j) + sql += str + sql += "'%s')" % (self.ts + i) + tdSql.execute(sql % (self.ts + i)) + tdSql.query('''select * from table_4096_2 where ts = %d ;''' %(self.ts)) + tdSql.checkCols(4094) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + tdSql.query('''select * from stable_4096_2 where ts = %d ;''' %(self.ts)) + tdSql.checkCols(4096) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + + sql = '''insert into table_4096_2 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4093 ) + values('2020-09-10 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-10 20:26:44.090','1500000000000');''' + tdSql.execute(sql) + tdSql.query("select * from table_4096_2 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4094) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4093,'1500000000000') + tdSql.query("select * from stable_4096_2 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4093,'1500000000000') + + + # taosdemo force data dropping disk + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + os.system("%staosdemo -N -d taosdemo -t 100 -n 100 -l 1000 -y" % binPath) + + tdSql.execute('''insert into table_2 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts - 200)) + sql = '''select * from table_2 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where loc = 'table_2' and ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into table_2 values( %d , 0, 0, 0, 0, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 200)) + sql = '''select * from table_2 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+0') + tdSql.checkData(0,7,'nchar+0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + sql = '''select * from stable_1 where loc = 'table_2' and ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+0') + tdSql.checkData(0,7,'nchar+0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.error('''insert into table_2 values( %d , -2147483648, -9223372036854775807, -32767, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_2 values( %d , -2147483647, -9223372036854775808, -32767, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_2 values( %d , -2147483647, -9223372036854775807, -32768, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_2 values( %d , -2147483647, -9223372036854775807, -32767, -128, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_2 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-0123', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_2 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-0', 'nchar-01234', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + + tdSql.execute('''insert into table_2 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-012', 'nchar-0123', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + sql = '''select * from table_2 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,-2147483647) + tdSql.checkData(0,2,-9223372036854775807) + tdSql.checkData(0,3,-32767) + tdSql.checkData(0,4,-127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-012') + tdSql.checkData(0,7,'nchar-0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:44.090') + sql = '''select * from stable_1 where loc = 'table_2' and ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,-2147483647) + tdSql.checkData(0,2,-9223372036854775807) + tdSql.checkData(0,3,-32767) + tdSql.checkData(0,4,-127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-012') + tdSql.checkData(0,7,'nchar-0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:44.090') + + tdSql.error('''insert into table_2 values( %d , 2147483648, 9223372036854775807, 32767, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_2 values( %d , 2147483647, 9223372036854775808, 32767, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_2 values( %d , 2147483647, 9223372036854775807, 32768, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_2 values( %d , 2147483647, 9223372036854775807, 32767, 128, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_2 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+0123', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_2 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+0', 'nchar+01234', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + + tdSql.execute('''insert into table_2 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+012', 'nchar+0123', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + sql = '''select * from table_2 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,2147483647) + tdSql.checkData(0,2,9223372036854775807) + tdSql.checkData(0,3,32767) + tdSql.checkData(0,4,127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+012') + tdSql.checkData(0,7,'nchar+0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:44.090') + sql = '''select * from stable_1 where loc = 'table_2' and ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,2147483647) + tdSql.checkData(0,2,9223372036854775807) + tdSql.checkData(0,3,32767) + tdSql.checkData(0,4,127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+012') + tdSql.checkData(0,7,'nchar+0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:44.090') + + tdLog.info("========== 4096 regular_table ==========") + sql = '''insert into regular_table_4096_2 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4095 ) + values('2020-09-13 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-13 20:26:44.090','1600000000000');''' + tdSql.execute(sql) + tdSql.query("select * from regular_table_4096_2 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4095,'1600000000000') + + sql = '''insert into regular_table_4096_2 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4095 ) + values('2020-09-10 20:26:40.000' , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL);''' + tdSql.execute(sql) + tdSql.query("select * from regular_table_4096_2 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,None) + tdSql.checkData(0,3801,None) + tdSql.checkData(0,4091,None) + tdSql.checkData(0,4095,None) + + tdLog.info("========== 4096 stable ==========") + sql = '''insert into table_4096_2 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4093 ) + values('2020-09-13 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-13 20:26:44.090','1600000000000');''' + tdSql.execute(sql) + tdSql.query("select * from table_4096_2 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4094) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + tdSql.query("select * from stable_4096_2 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + + sql = '''insert into table_4096_2 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4093 ) + values('2020-09-10 20:26:40.000' , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL);''' + tdSql.execute(sql) + tdSql.query("select * from table_4096_2 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4094) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,None) + tdSql.checkData(0,3801,None) + tdSql.checkData(0,4091,None) + tdSql.checkData(0,4093,None) + tdSql.query("select * from stable_4096_2 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,None) + tdSql.checkData(0,3801,None) + tdSql.checkData(0,4091,None) + tdSql.checkData(0,4093,None) + + tdLog.info("========== test1.3 : insert data , tdDnodes restart force data dropping disk , check data==========") + tdLog.info("========== regular_table ==========") + tdSql.execute('''insert into regular_table_3 values( %d , 0, 0, 0, 0, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 200)) + sql = '''select * from regular_table_3 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.execute('''insert into regular_table_3 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 200)) + sql = '''select * from regular_table_3 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into regular_table_3 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts - 500)) + sql = '''select * from regular_table_3 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into regular_table_3 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 500)) + sql = '''select * from regular_table_3 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdLog.info("========== stable ==========") + tdSql.execute('''insert into table_3 values( %d , 0, 0, 0, 0, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 200)) + sql = '''select * from table_3 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + sql = '''select * from stable_1 where loc = 'table_3' and ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.execute('''insert into table_3 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 200)) + sql = '''select * from table_3 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where loc = 'table_3' and ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into table_3 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts - 500)) + sql = '''select * from table_3 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where loc = 'table_3' and ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into table_3 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 500)) + sql = '''select * from table_3 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where loc = 'table_3' and ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + + tdLog.info("========== 4096 regular_table ==========") + sql = "create table regular_table_4096_3 (ts timestamp, " + for i in range(500): + sql += "int_%d int, " % (i + 1) + for i in range(500,1000): + sql += "smallint_%d smallint, " % (i + 1) + for i in range(1000,1500): + sql += "tinyint_%d tinyint, " % (i + 1) + for i in range(1500,2000): + sql += "double_%d double, " % (i + 1) + for i in range(2000,2500): + sql += "float_%d float, " % (i + 1) + for i in range(2500,3000): + sql += "bool_%d bool, " % (i + 1) + for i in range(3000,3500): + sql += "bigint_%d bigint, " % (i + 1) + for i in range(3500,3800): + sql += "nchar_%d nchar(4), " % (i + 1) + for i in range(3800,4090): + sql += "binary_%d binary(10), " % (i + 1) + for i in range(4090,4094): + sql += "timestamp_%d timestamp, " % (i + 1) + sql += "col4095 binary(22))" + tdLog.info(len(sql)) + tdSql.execute(sql) + + for i in range(self.num4096): + sql = "insert into regular_table_4096_3 values(%d, " + for j in range(4090): + str = "'%s', " % 'NULL' + sql += str + for j in range(4090,4094): + str = "%s, " % (self.ts + j) + sql += str + sql += "'%s')" % (self.ts + i) + tdSql.execute(sql % (self.ts + i)) + tdSql.query('''select * from regular_table_4096_3 where ts = %d ;''' %(self.ts)) + tdSql.checkCols(4096) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4095,'1600000000000') + + sql = '''insert into regular_table_4096_3 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4095 ) + values('2020-09-10 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-10 20:26:44.090','1500000000000');''' + tdSql.execute(sql) + tdSql.query("select * from regular_table_4096_3 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4095,'1500000000000') + + tdLog.info("========== 4096 stable ==========") + sql = "create stable stable_4096_3 (ts timestamp, " + for i in range(500): + sql += "int_%d int, " % (i + 1) + for i in range(500,1000): + sql += "smallint_%d smallint, " % (i + 1) + for i in range(1000,1500): + sql += "tinyint_%d tinyint, " % (i + 1) + for i in range(1500,2000): + sql += "double_%d double, " % (i + 1) + for i in range(2000,2500): + sql += "float_%d float, " % (i + 1) + for i in range(2500,3000): + sql += "bool_%d bool, " % (i + 1) + for i in range(3000,3500): + sql += "bigint_%d bigint, " % (i + 1) + for i in range(3500,3800): + sql += "nchar_%d nchar(4), " % (i + 1) + for i in range(3800,4090): + sql += "binary_%d binary(10), " % (i + 1) + for i in range(4090,4092): + sql += "timestamp_%d timestamp, " % (i + 1) + sql += " col4093 binary(22)) " + sql += " tags (loc nchar(20),tag_1 int) " + tdLog.info(len(sql)) + tdSql.execute(sql) + + sql = " create table table_4096_3 using stable_4096_3 tags ('table_4096_3',1); " + tdSql.execute(sql) + + for i in range(self.num4096): + sql = "insert into table_4096_3 values(%d, " + for j in range(4090): + str = "'%s', " % 'NULL' + sql += str + for j in range(4090,4092): + str = "%s, " % (self.ts + j) + sql += str + sql += "'%s')" % (self.ts + i) + tdSql.execute(sql % (self.ts + i)) + tdSql.query('''select * from table_4096_3 where ts = %d ;''' %(self.ts)) + tdSql.checkCols(4094) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + tdSql.query('''select * from stable_4096_3 where ts = %d ;''' %(self.ts)) + tdSql.checkCols(4096) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + + sql = '''insert into table_4096_3 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4093 ) + values('2020-09-10 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-10 20:26:44.090','1500000000000');''' + tdSql.execute(sql) + tdSql.query("select * from table_4096_3 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4094) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4093,'1500000000000') + tdSql.query("select * from stable_4096_3 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4093,'1500000000000') + + # tdDnodes restart force data dropping disk + tdDnodes.stop(1) + tdDnodes.start(1) + + tdLog.info("========== regular_table ==========") + tdSql.execute('''insert into regular_table_3 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts - 200)) + sql = '''select * from regular_table_3 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into regular_table_3 values( %d , 0, 0, 0, 0, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 200)) + sql = '''select * from regular_table_3 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+0') + tdSql.checkData(0,7,'nchar+0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.error('''insert into regular_table_3 values( %d , -2147483648, -9223372036854775807, -32767, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into regular_table_3 values( %d , -2147483647, -9223372036854775808, -32767, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into regular_table_3 values( %d , -2147483647, -9223372036854775807, -32768, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into regular_table_3 values( %d , -2147483647, -9223372036854775807, -32767, -128, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into regular_table_3 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-0123', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into regular_table_3 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-0', 'nchar-01234', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + + tdSql.execute('''insert into regular_table_3 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-012', 'nchar-0123', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + sql = '''select * from regular_table_3 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,-2147483647) + tdSql.checkData(0,2,-9223372036854775807) + tdSql.checkData(0,3,-32767) + tdSql.checkData(0,4,-127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-012') + tdSql.checkData(0,7,'nchar-0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:44.090') + + tdSql.error('''insert into regular_table_3 values( %d , 2147483648, 9223372036854775807, 32767, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into regular_table_3 values( %d , 2147483647, 9223372036854775808, 32767, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into regular_table_3 values( %d , 2147483647, 9223372036854775807, 32768, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into regular_table_3 values( %d , 2147483647, 9223372036854775807, 32767, 128, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into regular_table_3 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+0123', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into regular_table_3 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+0', 'nchar+01234', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + + tdSql.execute('''insert into regular_table_3 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+012', 'nchar+0123', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + sql = '''select * from regular_table_3 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,2147483647) + tdSql.checkData(0,2,9223372036854775807) + tdSql.checkData(0,3,32767) + tdSql.checkData(0,4,127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+012') + tdSql.checkData(0,7,'nchar+0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:44.090') + + tdLog.info("========== stable ==========") + tdSql.execute('''insert into table_3 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts - 200)) + sql = '''select * from table_3 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where loc = 'table_3' and ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into table_3 values( %d , 0, 0, 0, 0, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 200)) + sql = '''select * from table_3 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+0') + tdSql.checkData(0,7,'nchar+0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + sql = '''select * from stable_1 where loc = 'table_3' and ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+0') + tdSql.checkData(0,7,'nchar+0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.error('''insert into table_3 values( %d , -2147483648, -9223372036854775807, -32767, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_3 values( %d , -2147483647, -9223372036854775808, -32767, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_3 values( %d , -2147483647, -9223372036854775807, -32768, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_3 values( %d , -2147483647, -9223372036854775807, -32767, -128, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_3 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-0123', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_3 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-0', 'nchar-01234', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + + tdSql.execute('''insert into table_3 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-012', 'nchar-0123', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + sql = '''select * from table_3 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,-2147483647) + tdSql.checkData(0,2,-9223372036854775807) + tdSql.checkData(0,3,-32767) + tdSql.checkData(0,4,-127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-012') + tdSql.checkData(0,7,'nchar-0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:44.090') + sql = '''select * from stable_1 where loc = 'table_3' and ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,-2147483647) + tdSql.checkData(0,2,-9223372036854775807) + tdSql.checkData(0,3,-32767) + tdSql.checkData(0,4,-127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-012') + tdSql.checkData(0,7,'nchar-0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:44.090') + + tdSql.error('''insert into table_3 values( %d , 2147483648, 9223372036854775807, 32767, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_3 values( %d , 2147483647, 9223372036854775808, 32767, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_3 values( %d , 2147483647, 9223372036854775807, 32768, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_3 values( %d , 2147483647, 9223372036854775807, 32767, 128, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_3 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+0123', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_3 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+0', 'nchar+01234', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + + tdSql.execute('''insert into table_3 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+012', 'nchar+0123', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + sql = '''select * from table_3 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,2147483647) + tdSql.checkData(0,2,9223372036854775807) + tdSql.checkData(0,3,32767) + tdSql.checkData(0,4,127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+012') + tdSql.checkData(0,7,'nchar+0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:44.090') + sql = '''select * from stable_1 where loc = 'table_3' and ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,2147483647) + tdSql.checkData(0,2,9223372036854775807) + tdSql.checkData(0,3,32767) + tdSql.checkData(0,4,127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+012') + tdSql.checkData(0,7,'nchar+0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:44.090') + + + tdLog.info("========== 4096 regular_table ==========") + sql = '''insert into regular_table_4096_3 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4095 ) + values('2020-09-13 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-13 20:26:44.090','1600000000000');''' + tdSql.execute(sql) + tdSql.query("select * from regular_table_4096_3 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4095,'1600000000000') + + sql = '''insert into regular_table_4096_3 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4095 ) + values('2020-09-10 20:26:40.000' , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL);''' + tdSql.execute(sql) + tdSql.query("select * from regular_table_4096_3 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,None) + tdSql.checkData(0,3801,None) + tdSql.checkData(0,4091,None) + tdSql.checkData(0,4095,None) + + tdLog.info("========== 4096 stable ==========") + sql = '''insert into table_4096_3 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4093 ) + values('2020-09-13 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-13 20:26:44.090','1600000000000');''' + tdSql.execute(sql) + tdSql.query("select * from table_4096_3 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4094) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + tdSql.query("select * from stable_4096_3 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + + sql = '''insert into table_4096_3 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4093 ) + values('2020-09-10 20:26:40.000' , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL);''' + tdSql.execute(sql) + tdSql.query("select * from table_4096_3 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4094) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,None) + tdSql.checkData(0,3801,None) + tdSql.checkData(0,4091,None) + tdSql.checkData(0,4093,None) + tdSql.query("select * from stable_4096_3 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,None) + tdSql.checkData(0,3801,None) + tdSql.checkData(0,4091,None) + tdSql.checkData(0,4093,None) + + endTime = time.time() + print("total time %ds" % (endTime - startTime)) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/import_merge/import_update_2.py b/tests/pytest/import_merge/import_update_2.py new file mode 100644 index 0000000000000000000000000000000000000000..16328956c3dcea62125cd9fe3817aa68d79362f3 --- /dev/null +++ b/tests/pytest/import_merge/import_update_2.py @@ -0,0 +1,2273 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +from util.dnodes import * +import random +import time + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.ts = 1600000000000 + self.num = 50 + self.num4096 = 5 + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def run(self): + tdSql.prepare() + # test case for https://jira.taosdata.com:18080/browse/TD-5062 + + startTime = time.time() + + tdSql.execute('''drop database if exists test_updata_2 ;''') + # update 0 不更新 ; update 1 覆盖更新 ;update 2 合并更新 + tdLog.info("========== test database updata = 2 ==========") + tdSql.execute('''create database test_updata_2 update 2 minrows 10 maxrows 200 keep 36500;''') + tdSql.execute('''use test_updata_2;''') + tdSql.execute('''create stable stable_1 + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint, + q_bool bool , q_binary binary(10) , q_nchar nchar(10) , q_float float , q_double double , q_ts timestamp) + tags(loc nchar(20) , t_int int);''') + tdSql.execute('''create table table_1 using stable_1 tags('table_1' , '1' )''') + tdSql.execute('''create table table_2 using stable_1 tags('table_2' , '2' )''') + tdSql.execute('''create table table_3 using stable_1 tags('table_3' , '3' )''') + + #regular table + tdSql.execute('''create table regular_table_1 + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint, + q_bool bool , q_binary binary(10) , q_nchar nchar(10) , q_float float , q_double double , q_ts timestamp) ;''') + tdSql.execute('''create table regular_table_2 + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint, + q_bool bool , q_binary binary(10) , q_nchar nchar(10) , q_float float , q_double double , q_ts timestamp) ;''') + tdSql.execute('''create table regular_table_3 + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint, + q_bool bool , q_binary binary(10) , q_nchar nchar(10) , q_float float , q_double double , q_ts timestamp) ;''') + + + tdLog.info("========== test1.1 : insert data , check data==========") + tdLog.info("========== regular_table ==========") + tdSql.execute('''insert into regular_table_1 values( %d , 0, 0, 0, 0, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 200)) + sql = '''select * from regular_table_1 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.execute('''insert into regular_table_1 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 200)) + sql = '''select * from regular_table_1 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into regular_table_1 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts - 500)) + sql = '''select * from regular_table_1 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into regular_table_1 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 500)) + sql = '''select * from regular_table_1 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdLog.info("========== stable ==========") + tdSql.execute('''insert into table_1 values( %d , 0, 0, 0, 0, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 200)) + sql = '''select * from table_1 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + sql = '''select * from stable_1 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.execute('''insert into table_1 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 200)) + sql = '''select * from table_1 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into table_1 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts - 500)) + sql = '''select * from table_1 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into table_1 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 500)) + sql = '''select * from table_1 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + + tdLog.info("========== 4096 regular_table ==========") + sql = "create table regular_table_4096_1 (ts timestamp, " + for i in range(500): + sql += "int_%d int, " % (i + 1) + for i in range(500,1000): + sql += "smallint_%d smallint, " % (i + 1) + for i in range(1000,1500): + sql += "tinyint_%d tinyint, " % (i + 1) + for i in range(1500,2000): + sql += "double_%d double, " % (i + 1) + for i in range(2000,2500): + sql += "float_%d float, " % (i + 1) + for i in range(2500,3000): + sql += "bool_%d bool, " % (i + 1) + for i in range(3000,3500): + sql += "bigint_%d bigint, " % (i + 1) + for i in range(3500,3800): + sql += "nchar_%d nchar(4), " % (i + 1) + for i in range(3800,4090): + sql += "binary_%d binary(10), " % (i + 1) + for i in range(4090,4094): + sql += "timestamp_%d timestamp, " % (i + 1) + sql += "col4095 binary(22))" + tdLog.info(len(sql)) + tdSql.execute(sql) + + for i in range(self.num4096): + sql = "insert into regular_table_4096_1 values(%d, " + for j in range(4090): + str = "'%s', " % 'NULL' + sql += str + for j in range(4090,4094): + str = "%s, " % (self.ts + j) + sql += str + sql += "'%s')" % (self.ts + i) + tdSql.execute(sql % (self.ts + i)) + tdSql.query('''select * from regular_table_4096_1 where ts = %d ;''' %(self.ts)) + tdSql.checkCols(4096) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4095,'1600000000000') + + sql = '''insert into regular_table_4096_1 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4095 ) + values('2020-09-10 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-10 20:26:44.090','1500000000000');''' + tdSql.execute(sql) + tdSql.query("select * from regular_table_4096_1 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4095,'1500000000000') + + tdLog.info("========== 4096 stable ==========") + sql = "create stable stable_4096_1 (ts timestamp, " + for i in range(500): + sql += "int_%d int, " % (i + 1) + for i in range(500,1000): + sql += "smallint_%d smallint, " % (i + 1) + for i in range(1000,1500): + sql += "tinyint_%d tinyint, " % (i + 1) + for i in range(1500,2000): + sql += "double_%d double, " % (i + 1) + for i in range(2000,2500): + sql += "float_%d float, " % (i + 1) + for i in range(2500,3000): + sql += "bool_%d bool, " % (i + 1) + for i in range(3000,3500): + sql += "bigint_%d bigint, " % (i + 1) + for i in range(3500,3800): + sql += "nchar_%d nchar(4), " % (i + 1) + for i in range(3800,4090): + sql += "binary_%d binary(10), " % (i + 1) + for i in range(4090,4092): + sql += "timestamp_%d timestamp, " % (i + 1) + sql += " col4093 binary(22)) " + sql += " tags (loc nchar(20),tag_1 int) " + tdLog.info(len(sql)) + tdSql.execute(sql) + + sql = " create table table_4096_1 using stable_4096_1 tags ('table_4096_1',1); " + tdSql.execute(sql) + + for i in range(self.num4096): + sql = "insert into table_4096_1 values(%d, " + for j in range(4090): + str = "'%s', " % 'NULL' + sql += str + for j in range(4090,4092): + str = "%s, " % (self.ts + j) + sql += str + sql += "'%s')" % (self.ts + i) + tdSql.execute(sql % (self.ts + i)) + tdSql.query('''select * from table_4096_1 where ts = %d ;''' %(self.ts)) + tdSql.checkCols(4094) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + tdSql.query('''select * from stable_4096_1 where ts = %d ;''' %(self.ts)) + tdSql.checkCols(4096) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + + sql = '''insert into table_4096_1 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4093 ) + values('2020-09-10 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-10 20:26:44.090','1500000000000');''' + tdSql.execute(sql) + tdSql.query("select * from table_4096_1 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4094) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4093,'1500000000000') + tdSql.query("select * from stable_4096_1 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4093,'1500000000000') + + # minrows 10 maxrows 200 + for i in range(self.num): + tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, 0, 'binary.%s', 'nchar.%s', %f, %f, %d)''' + % (self.ts -100 + i, i, i, i, i, i, i, i, i, self.ts -100 + i)) + tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, false, 'binary%s', 'nchar%s', %f, %f, %d)''' + % (self.ts + i, random.randint(-2147483647, 2147483647), + random.randint(-9223372036854775807, 9223372036854775807), random.randint(-32767, 32767), + random.randint(-127, 127), random.randint(-99, 99), random.randint(-9999, 9999), + random.uniform(-100000,100000), random.uniform(-1000000000,1000000000), self.ts + i)) + + tdSql.execute('''insert into table_1 values(%d, %d, %d, %d, %d, 0, 'binary.%s', 'nchar.%s', %f, %f, %d)''' + % (self.ts -100 + i, i, i, i, i, i, i, i, i, self.ts -100 + i)) + tdSql.execute('''insert into table_1 values(%d, %d, %d, %d, %d, false, 'binary%s', 'nchar%s', %f, %f, %d)''' + % (self.ts + i, random.randint(-2147483647, 2147483647), + random.randint(-9223372036854775807, 9223372036854775807), random.randint(-32767, 32767), + random.randint(-127, 127), random.randint(-99, 99), random.randint(-9999, 9999), + random.uniform(-100000,100000), random.uniform(-1000000000,1000000000), self.ts + i)) + + tdLog.info("========== regular_table ==========") + tdSql.execute('''insert into regular_table_1 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts - 200)) + sql = '''select * from regular_table_1 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.execute('''insert into regular_table_1 values( %d , 0, 0, 0, 0, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 200)) + sql = '''select * from regular_table_1 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+0') + tdSql.checkData(0,7,'nchar+0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + tdSql.execute('''insert into regular_table_1 values( %d , 1, 1, 1, 1, 1, 'binary+1', 'nchar+1', 1.000000, 1.000000, 1600000001000);''' %(self.ts + 200)) + sql = '''select * from regular_table_1 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,1) + tdSql.checkData(0,2,1) + tdSql.checkData(0,3,1) + tdSql.checkData(0,4,1) + tdSql.checkData(0,5,'True') + tdSql.checkData(0,6,'binary+1') + tdSql.checkData(0,7,'nchar+1') + tdSql.checkData(0,8,1) + tdSql.checkData(0,9,1) + tdSql.checkData(0,10,'2020-09-13 20:26:41.000') + + tdSql.error('''insert into regular_table_1 values( %d , -2147483648, -9223372036854775807, -32767, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into regular_table_1 values( %d , -2147483647, -9223372036854775808, -32767, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into regular_table_1 values( %d , -2147483647, -9223372036854775807, -32768, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into regular_table_1 values( %d , -2147483647, -9223372036854775807, -32767, -128, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into regular_table_1 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-0123', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into regular_table_1 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-0', 'nchar-01234', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + + tdSql.execute('''insert into regular_table_1 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-012', 'nchar-0123', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + sql = '''select * from regular_table_1 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,-2147483647) + tdSql.checkData(0,2,-9223372036854775807) + tdSql.checkData(0,3,-32767) + tdSql.checkData(0,4,-127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-012') + tdSql.checkData(0,7,'nchar-0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.error('''insert into regular_table_1 values( %d , 2147483648, 9223372036854775807, 32767, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into regular_table_1 values( %d , 2147483647, 9223372036854775808, 32767, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into regular_table_1 values( %d , 2147483647, 9223372036854775807, 32768, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into regular_table_1 values( %d , 2147483647, 9223372036854775807, 32767, 128, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into regular_table_1 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+0123', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into regular_table_1 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+0', 'nchar+01234', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + + tdSql.execute('''insert into regular_table_1 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+012', 'nchar+0123', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + sql = '''select * from regular_table_1 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,2147483647) + tdSql.checkData(0,2,9223372036854775807) + tdSql.checkData(0,3,32767) + tdSql.checkData(0,4,127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+012') + tdSql.checkData(0,7,'nchar+0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + tdSql.execute('''insert into regular_table_1 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-012', 'nchar-0123', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + sql = '''select * from regular_table_1 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,-2147483647) + tdSql.checkData(0,2,-9223372036854775807) + tdSql.checkData(0,3,-32767) + tdSql.checkData(0,4,-127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-012') + tdSql.checkData(0,7,'nchar-0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdLog.info("========== stable ==========") + tdSql.execute('''insert into table_1 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts - 200)) + sql = '''select * from table_1 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + sql = '''select * from stable_1 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.execute('''insert into table_1 values( %d , 0, 0, 0, 0, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 200)) + sql = '''select * from table_1 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+0') + tdSql.checkData(0,7,'nchar+0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + sql = '''select * from stable_1 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+0') + tdSql.checkData(0,7,'nchar+0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.execute('''insert into table_1 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 200)) + sql = '''select * from table_1 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+0') + tdSql.checkData(0,7,'nchar+0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + sql = '''select * from stable_1 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+0') + tdSql.checkData(0,7,'nchar+0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.error('''insert into table_1 values( %d , -2147483648, -9223372036854775807, -32767, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_1 values( %d , -2147483647, -9223372036854775808, -32767, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_1 values( %d , -2147483647, -9223372036854775807, -32768, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_1 values( %d , -2147483647, -9223372036854775807, -32767, -128, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_1 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-0123', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_1 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-0', 'nchar-01234', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + + tdSql.execute('''insert into table_1 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-012', 'nchar-0123', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + sql = '''select * from table_1 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,-2147483647) + tdSql.checkData(0,2,-9223372036854775807) + tdSql.checkData(0,3,-32767) + tdSql.checkData(0,4,-127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-012') + tdSql.checkData(0,7,'nchar-0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + sql = '''select * from stable_1 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,-2147483647) + tdSql.checkData(0,2,-9223372036854775807) + tdSql.checkData(0,3,-32767) + tdSql.checkData(0,4,-127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-012') + tdSql.checkData(0,7,'nchar-0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.error('''insert into table_1 values( %d , 2147483648, 9223372036854775807, 32767, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_1 values( %d , 2147483647, 9223372036854775808, 32767, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_1 values( %d , 2147483647, 9223372036854775807, 32768, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_1 values( %d , 2147483647, 9223372036854775807, 32767, 128, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_1 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+0123', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_1 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+0', 'nchar+01234', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + + tdSql.execute('''insert into table_1 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+012', 'nchar+0123', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + sql = '''select * from table_1 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,2147483647) + tdSql.checkData(0,2,9223372036854775807) + tdSql.checkData(0,3,32767) + tdSql.checkData(0,4,127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+012') + tdSql.checkData(0,7,'nchar+0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + sql = '''select * from stable_1 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,2147483647) + tdSql.checkData(0,2,9223372036854775807) + tdSql.checkData(0,3,32767) + tdSql.checkData(0,4,127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+012') + tdSql.checkData(0,7,'nchar+0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + tdSql.execute('''insert into table_1 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-012', 'nchar-0123', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + sql = '''select * from table_1 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,-2147483647) + tdSql.checkData(0,2,-9223372036854775807) + tdSql.checkData(0,3,-32767) + tdSql.checkData(0,4,-127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-012') + tdSql.checkData(0,7,'nchar-0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + sql = '''select * from stable_1 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,-2147483647) + tdSql.checkData(0,2,-9223372036854775807) + tdSql.checkData(0,3,-32767) + tdSql.checkData(0,4,-127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-012') + tdSql.checkData(0,7,'nchar-0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdLog.info("========== 4096 regular_table ==========") + sql = '''insert into regular_table_4096_1 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4095 ) + values('2020-09-13 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-13 20:26:44.090','1600000000000');''' + tdSql.execute(sql) + tdSql.query("select * from regular_table_4096_1 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4095,'1600000000000') + + sql = '''insert into regular_table_4096_1 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4095 ) + values('2020-09-10 20:26:40.000' , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL);''' + tdSql.execute(sql) + tdSql.query("select * from regular_table_4096_1 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4095,'1500000000000') + + sql = '''insert into regular_table_4096_1 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4095 ) + values('2020-09-13 20:26:40.000' , 2 , 502 , 102 , 1502 , 2002 , 0 , 3002 , '3502' , '3802' ,'2020-09-13 20:26:44.092','1600000002000');''' + tdSql.execute(sql) + tdSql.query("select * from regular_table_4096_1 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,2) + tdSql.checkData(0,501,502) + tdSql.checkData(0,1001,102) + tdSql.checkData(0,1501,1502) + tdSql.checkData(0,2001,2002) + tdSql.checkData(0,2501,'False') + tdSql.checkData(0,3001,3002) + tdSql.checkData(0,3501,'3502') + tdSql.checkData(0,3801,'3802') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.092') + tdSql.checkData(0,4095,'1600000002000') + + tdLog.info("========== 4096 stable ==========") + sql = '''insert into table_4096_1 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4093 ) + values('2020-09-13 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-13 20:26:44.090','1600000000000');''' + tdSql.execute(sql) + tdSql.query("select * from table_4096_1 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4094) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + tdSql.query("select * from stable_4096_1 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + + sql = '''insert into table_4096_1 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4093 ) + values('2020-09-10 20:26:40.000' , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL);''' + tdSql.execute(sql) + tdSql.query("select * from table_4096_1 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4094) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4093,'1500000000000') + tdSql.query("select * from stable_4096_1 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4093,'1500000000000') + + sql = '''insert into table_4096_1 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4093 ) + values('2020-09-13 20:26:40.000' , 2 , 502 , 102 , 1502 , 2002 , 0 , 3002 , '3502' , '3802' ,'2020-09-13 20:26:44.092','1600000002000');''' + tdSql.execute(sql) + tdSql.query("select * from table_4096_1 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4094) + tdSql.checkData(0,1,2) + tdSql.checkData(0,501,502) + tdSql.checkData(0,1001,102) + tdSql.checkData(0,1501,1502) + tdSql.checkData(0,2001,2002) + tdSql.checkData(0,2501,'False') + tdSql.checkData(0,3001,3002) + tdSql.checkData(0,3501,'3502') + tdSql.checkData(0,3801,'3802') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.092') + tdSql.checkData(0,4093,'1600000002000') + tdSql.query("select * from stable_4096_1 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,2) + tdSql.checkData(0,501,502) + tdSql.checkData(0,1001,102) + tdSql.checkData(0,1501,1502) + tdSql.checkData(0,2001,2002) + tdSql.checkData(0,2501,'False') + tdSql.checkData(0,3001,3002) + tdSql.checkData(0,3501,'3502') + tdSql.checkData(0,3801,'3802') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.092') + tdSql.checkData(0,4093,'1600000002000') + + + tdLog.info("========== test1.2 : insert data , taosdemo force data dropping disk , check data==========") + tdLog.info("========== regular_table ==========") + tdSql.execute('''insert into regular_table_2 values( %d , 0, 0, 0, 0, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 200)) + sql = '''select * from regular_table_2 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.execute('''insert into regular_table_2 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 200)) + sql = '''select * from regular_table_2 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into regular_table_2 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts - 500)) + sql = '''select * from regular_table_2 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into regular_table_2 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 500)) + sql = '''select * from regular_table_2 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + + tdLog.info("========== stable ==========") + tdSql.execute('''insert into table_2 values( %d , 0, 0, 0, 0, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 200)) + sql = '''select * from table_2 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + sql = '''select * from stable_1 where loc = 'table_2' and ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.execute('''insert into table_2 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 200)) + sql = '''select * from table_2 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where loc = 'table_2' and ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into table_2 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts - 500)) + sql = '''select * from table_2 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where loc = 'table_2' and ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into table_2 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 500)) + sql = '''select * from table_2 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where loc = 'table_2' and ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + + tdLog.info("========== 4096 regular_table ==========") + sql = "create table regular_table_4096_2 (ts timestamp, " + for i in range(500): + sql += "int_%d int, " % (i + 1) + for i in range(500,1000): + sql += "smallint_%d smallint, " % (i + 1) + for i in range(1000,1500): + sql += "tinyint_%d tinyint, " % (i + 1) + for i in range(1500,2000): + sql += "double_%d double, " % (i + 1) + for i in range(2000,2500): + sql += "float_%d float, " % (i + 1) + for i in range(2500,3000): + sql += "bool_%d bool, " % (i + 1) + for i in range(3000,3500): + sql += "bigint_%d bigint, " % (i + 1) + for i in range(3500,3800): + sql += "nchar_%d nchar(4), " % (i + 1) + for i in range(3800,4090): + sql += "binary_%d binary(10), " % (i + 1) + for i in range(4090,4094): + sql += "timestamp_%d timestamp, " % (i + 1) + sql += "col4095 binary(22))" + tdLog.info(len(sql)) + tdSql.execute(sql) + + for i in range(self.num4096): + sql = "insert into regular_table_4096_2 values(%d, " + for j in range(4090): + str = "'%s', " % 'NULL' + sql += str + for j in range(4090,4094): + str = "%s, " % (self.ts + j) + sql += str + sql += "'%s')" % (self.ts + i) + tdSql.execute(sql % (self.ts + i)) + tdSql.query('''select * from regular_table_4096_2 where ts = %d ;''' %(self.ts)) + tdSql.checkCols(4096) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4095,'1600000000000') + + sql = '''insert into regular_table_4096_2 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4095 ) + values('2020-09-10 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-10 20:26:44.090','1500000000000');''' + tdSql.execute(sql) + tdSql.query("select * from regular_table_4096_2 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4095,'1500000000000') + + tdLog.info("========== 4096 stable ==========") + sql = "create stable stable_4096_2 (ts timestamp, " + for i in range(500): + sql += "int_%d int, " % (i + 1) + for i in range(500,1000): + sql += "smallint_%d smallint, " % (i + 1) + for i in range(1000,1500): + sql += "tinyint_%d tinyint, " % (i + 1) + for i in range(1500,2000): + sql += "double_%d double, " % (i + 1) + for i in range(2000,2500): + sql += "float_%d float, " % (i + 1) + for i in range(2500,3000): + sql += "bool_%d bool, " % (i + 1) + for i in range(3000,3500): + sql += "bigint_%d bigint, " % (i + 1) + for i in range(3500,3800): + sql += "nchar_%d nchar(4), " % (i + 1) + for i in range(3800,4090): + sql += "binary_%d binary(10), " % (i + 1) + for i in range(4090,4092): + sql += "timestamp_%d timestamp, " % (i + 1) + sql += " col4093 binary(22)) " + sql += " tags (loc nchar(20),tag_1 int) " + tdLog.info(len(sql)) + tdSql.execute(sql) + + sql = " create table table_4096_2 using stable_4096_2 tags ('table_4096_2',1); " + tdSql.execute(sql) + + for i in range(self.num4096): + sql = "insert into table_4096_2 values(%d, " + for j in range(4090): + str = "'%s', " % 'NULL' + sql += str + for j in range(4090,4092): + str = "%s, " % (self.ts + j) + sql += str + sql += "'%s')" % (self.ts + i) + tdSql.execute(sql % (self.ts + i)) + tdSql.query('''select * from table_4096_2 where ts = %d ;''' %(self.ts)) + tdSql.checkCols(4094) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + tdSql.query('''select * from stable_4096_2 where ts = %d ;''' %(self.ts)) + tdSql.checkCols(4096) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + + sql = '''insert into table_4096_2 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4093 ) + values('2020-09-10 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-10 20:26:44.090','1500000000000');''' + tdSql.execute(sql) + tdSql.query("select * from table_4096_2 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4094) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4093,'1500000000000') + tdSql.query("select * from stable_4096_2 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4093,'1500000000000') + + + # taosdemo force data dropping disk + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + os.system("%staosdemo -N -d taosdemo -t 100 -n 100 -l 1000 -y" % binPath) + + tdLog.info("========== stable ==========") + tdSql.execute('''insert into table_2 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts - 200)) + sql = '''select * from table_2 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + sql = '''select * from stable_1 where loc = 'table_2' and ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.execute('''insert into table_2 values( %d , 0, 0, 0, 0, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 200)) + sql = '''select * from table_2 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+0') + tdSql.checkData(0,7,'nchar+0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + sql = '''select * from stable_1 where loc = 'table_2' and ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+0') + tdSql.checkData(0,7,'nchar+0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.execute('''insert into table_2 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 200)) + sql = '''select * from table_1 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+0') + tdSql.checkData(0,7,'nchar+0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + sql = '''select * from stable_1 where loc = 'table_2' and ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+0') + tdSql.checkData(0,7,'nchar+0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + + tdSql.error('''insert into table_2 values( %d , -2147483648, -9223372036854775807, -32767, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_2 values( %d , -2147483647, -9223372036854775808, -32767, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_2 values( %d , -2147483647, -9223372036854775807, -32768, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_2 values( %d , -2147483647, -9223372036854775807, -32767, -128, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_2 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-0123', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_2 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-0', 'nchar-01234', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + + tdSql.execute('''insert into table_2 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-012', 'nchar-0123', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + sql = '''select * from table_2 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,-2147483647) + tdSql.checkData(0,2,-9223372036854775807) + tdSql.checkData(0,3,-32767) + tdSql.checkData(0,4,-127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-012') + tdSql.checkData(0,7,'nchar-0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:44.090') + sql = '''select * from stable_1 where loc = 'table_2' and ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,-2147483647) + tdSql.checkData(0,2,-9223372036854775807) + tdSql.checkData(0,3,-32767) + tdSql.checkData(0,4,-127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-012') + tdSql.checkData(0,7,'nchar-0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:44.090') + + tdSql.error('''insert into table_2 values( %d , 2147483648, 9223372036854775807, 32767, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_2 values( %d , 2147483647, 9223372036854775808, 32767, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_2 values( %d , 2147483647, 9223372036854775807, 32768, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_2 values( %d , 2147483647, 9223372036854775807, 32767, 128, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_2 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+0123', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_2 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+0', 'nchar+01234', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + + tdSql.execute('''insert into table_2 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+012', 'nchar+0123', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + sql = '''select * from table_2 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,2147483647) + tdSql.checkData(0,2,9223372036854775807) + tdSql.checkData(0,3,32767) + tdSql.checkData(0,4,127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+012') + tdSql.checkData(0,7,'nchar+0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:44.090') + sql = '''select * from stable_1 where loc = 'table_2' and ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,2147483647) + tdSql.checkData(0,2,9223372036854775807) + tdSql.checkData(0,3,32767) + tdSql.checkData(0,4,127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+012') + tdSql.checkData(0,7,'nchar+0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:44.090') + tdSql.execute('''insert into table_2 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-012', 'nchar-0123', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + sql = '''select * from table_1 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,-2147483647) + tdSql.checkData(0,2,-9223372036854775807) + tdSql.checkData(0,3,-32767) + tdSql.checkData(0,4,-127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-012') + tdSql.checkData(0,7,'nchar-0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + sql = '''select * from stable_1 where loc = 'table_2' and ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,-2147483647) + tdSql.checkData(0,2,-9223372036854775807) + tdSql.checkData(0,3,-32767) + tdSql.checkData(0,4,-127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-012') + tdSql.checkData(0,7,'nchar-0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + + tdLog.info("========== 4096 regular_table ==========") + sql = '''insert into regular_table_4096_2 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4095 ) + values('2020-09-13 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-13 20:26:44.090','1600000000000');''' + tdSql.execute(sql) + tdSql.query("select * from regular_table_4096_2 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4095,'1600000000000') + + sql = '''insert into regular_table_4096_2 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4095 ) + values('2020-09-10 20:26:40.000' , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL);''' + tdSql.execute(sql) + tdSql.query("select * from regular_table_4096_2 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4095,'1500000000000') + + sql = '''insert into regular_table_4096_2 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4095 ) + values('2020-09-13 20:26:40.000' , 2 , 502 , 102 , 1502 , 2002 , 0 , 3002 , '3502' , '3802' ,'2020-09-13 20:26:44.092','1600000002000');''' + tdSql.execute(sql) + tdSql.query("select * from regular_table_4096_2 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,2) + tdSql.checkData(0,501,502) + tdSql.checkData(0,1001,102) + tdSql.checkData(0,1501,1502) + tdSql.checkData(0,2001,2002) + tdSql.checkData(0,2501,'False') + tdSql.checkData(0,3001,3002) + tdSql.checkData(0,3501,'3502') + tdSql.checkData(0,3801,'3802') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.092') + tdSql.checkData(0,4095,'1600000002000') + + + tdLog.info("========== 4096 stable ==========") + sql = '''insert into table_4096_2 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4093 ) + values('2020-09-13 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-13 20:26:44.090','1600000000000');''' + tdSql.execute(sql) + tdSql.query("select * from table_4096_2 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4094) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + tdSql.query("select * from stable_4096_2 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + + sql = '''insert into table_4096_2 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4093 ) + values('2020-09-10 20:26:40.000' , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL);''' + tdSql.execute(sql) + tdSql.query("select * from table_4096_2 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4094) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4093,'1500000000000') + tdSql.query("select * from stable_4096_2 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4093,'1500000000000') + + sql = '''insert into table_4096_2 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4093 ) + values('2020-09-13 20:26:40.000' , 2 , 502 , 102 , 1502 , 2002 , 0 , 3002 , '3502' , '3802' ,'2020-09-13 20:26:44.092','1600000002000');''' + tdSql.execute(sql) + tdSql.query("select * from table_4096_2 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4094) + tdSql.checkData(0,1,2) + tdSql.checkData(0,501,502) + tdSql.checkData(0,1001,102) + tdSql.checkData(0,1501,1502) + tdSql.checkData(0,2001,2002) + tdSql.checkData(0,2501,'False') + tdSql.checkData(0,3001,3002) + tdSql.checkData(0,3501,'3502') + tdSql.checkData(0,3801,'3802') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.092') + tdSql.checkData(0,4093,'1600000002000') + tdSql.query("select * from stable_4096_2 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,2) + tdSql.checkData(0,501,502) + tdSql.checkData(0,1001,102) + tdSql.checkData(0,1501,1502) + tdSql.checkData(0,2001,2002) + tdSql.checkData(0,2501,'False') + tdSql.checkData(0,3001,3002) + tdSql.checkData(0,3501,'3502') + tdSql.checkData(0,3801,'3802') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.092') + tdSql.checkData(0,4093,'1600000002000') + + + tdLog.info("========== test1.3 : insert data , tdDnodes restart force data dropping disk , check data==========") + tdLog.info("========== regular_table ==========") + tdSql.execute('''insert into regular_table_3 values( %d , 0, 0, 0, 0, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 200)) + sql = '''select * from regular_table_3 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.execute('''insert into regular_table_3 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 200)) + sql = '''select * from regular_table_3 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into regular_table_3 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts - 500)) + sql = '''select * from regular_table_3 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into regular_table_3 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 500)) + sql = '''select * from regular_table_3 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdLog.info("========== stable ==========") + tdSql.execute('''insert into table_3 values( %d , 0, 0, 0, 0, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 200)) + sql = '''select * from table_3 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + sql = '''select * from stable_1 where loc = 'table_3' and ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.execute('''insert into table_3 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 200)) + sql = '''select * from table_3 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where loc = 'table_3' and ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into table_3 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts - 500)) + sql = '''select * from table_3 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where loc = 'table_3' and ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + tdSql.execute('''insert into table_3 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 500)) + sql = '''select * from table_3 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + sql = '''select * from stable_1 where loc = 'table_3' and ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,None) + tdSql.checkData(0,2,None) + tdSql.checkData(0,3,None) + tdSql.checkData(0,4,None) + tdSql.checkData(0,5,None) + tdSql.checkData(0,6,None) + tdSql.checkData(0,7,None) + tdSql.checkData(0,8,None) + tdSql.checkData(0,9,None) + tdSql.checkData(0,10,None) + + + tdLog.info("========== 4096 regular_table ==========") + sql = "create table regular_table_4096_3 (ts timestamp, " + for i in range(500): + sql += "int_%d int, " % (i + 1) + for i in range(500,1000): + sql += "smallint_%d smallint, " % (i + 1) + for i in range(1000,1500): + sql += "tinyint_%d tinyint, " % (i + 1) + for i in range(1500,2000): + sql += "double_%d double, " % (i + 1) + for i in range(2000,2500): + sql += "float_%d float, " % (i + 1) + for i in range(2500,3000): + sql += "bool_%d bool, " % (i + 1) + for i in range(3000,3500): + sql += "bigint_%d bigint, " % (i + 1) + for i in range(3500,3800): + sql += "nchar_%d nchar(4), " % (i + 1) + for i in range(3800,4090): + sql += "binary_%d binary(10), " % (i + 1) + for i in range(4090,4094): + sql += "timestamp_%d timestamp, " % (i + 1) + sql += "col4095 binary(22))" + tdLog.info(len(sql)) + tdSql.execute(sql) + + for i in range(self.num4096): + sql = "insert into regular_table_4096_3 values(%d, " + for j in range(4090): + str = "'%s', " % 'NULL' + sql += str + for j in range(4090,4094): + str = "%s, " % (self.ts + j) + sql += str + sql += "'%s')" % (self.ts + i) + tdSql.execute(sql % (self.ts + i)) + tdSql.query('''select * from regular_table_4096_3 where ts = %d ;''' %(self.ts)) + tdSql.checkCols(4096) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4095,'1600000000000') + + sql = '''insert into regular_table_4096_3 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4095 ) + values('2020-09-10 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-10 20:26:44.090','1500000000000');''' + tdSql.execute(sql) + tdSql.query("select * from regular_table_4096_3 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4095,'1500000000000') + + tdLog.info("========== 4096 stable ==========") + sql = "create stable stable_4096_3 (ts timestamp, " + for i in range(500): + sql += "int_%d int, " % (i + 1) + for i in range(500,1000): + sql += "smallint_%d smallint, " % (i + 1) + for i in range(1000,1500): + sql += "tinyint_%d tinyint, " % (i + 1) + for i in range(1500,2000): + sql += "double_%d double, " % (i + 1) + for i in range(2000,2500): + sql += "float_%d float, " % (i + 1) + for i in range(2500,3000): + sql += "bool_%d bool, " % (i + 1) + for i in range(3000,3500): + sql += "bigint_%d bigint, " % (i + 1) + for i in range(3500,3800): + sql += "nchar_%d nchar(4), " % (i + 1) + for i in range(3800,4090): + sql += "binary_%d binary(10), " % (i + 1) + for i in range(4090,4092): + sql += "timestamp_%d timestamp, " % (i + 1) + sql += " col4093 binary(22)) " + sql += " tags (loc nchar(20),tag_1 int) " + tdLog.info(len(sql)) + tdSql.execute(sql) + + sql = " create table table_4096_3 using stable_4096_3 tags ('table_4096_3',1); " + tdSql.execute(sql) + + for i in range(self.num4096): + sql = "insert into table_4096_3 values(%d, " + for j in range(4090): + str = "'%s', " % 'NULL' + sql += str + for j in range(4090,4092): + str = "%s, " % (self.ts + j) + sql += str + sql += "'%s')" % (self.ts + i) + tdSql.execute(sql % (self.ts + i)) + tdSql.query('''select * from table_4096_3 where ts = %d ;''' %(self.ts)) + tdSql.checkCols(4094) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + tdSql.query('''select * from stable_4096_3 where ts = %d ;''' %(self.ts)) + tdSql.checkCols(4096) + tdSql.checkData(0,1,None) + tdSql.checkData(0,501,None) + tdSql.checkData(0,1001,None) + tdSql.checkData(0,1501,None) + tdSql.checkData(0,2001,None) + tdSql.checkData(0,2501,None) + tdSql.checkData(0,3001,None) + tdSql.checkData(0,3501,'NULL') + tdSql.checkData(0,3801,'NULL') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + + sql = '''insert into table_4096_3 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4093 ) + values('2020-09-10 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-10 20:26:44.090','1500000000000');''' + tdSql.execute(sql) + tdSql.query("select * from table_4096_3 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4094) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4093,'1500000000000') + tdSql.query("select * from stable_4096_3 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4093,'1500000000000') + + # tdDnodes restart force data dropping disk + tdDnodes.stop(1) + tdDnodes.start(1) + + tdLog.info("========== regular_table ==========") + tdSql.execute('''insert into regular_table_3 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts - 200)) + sql = '''select * from regular_table_3 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.execute('''insert into regular_table_3 values( %d , 0, 0, 0, 0, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 200)) + sql = '''select * from regular_table_3 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+0') + tdSql.checkData(0,7,'nchar+0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + tdSql.execute('''insert into regular_table_3 values( %d , 1, 1, 1, 1, 1, 'binary+1', 'nchar+1', 1.000000, 1.000000, 1600000001000);''' %(self.ts + 200)) + sql = '''select * from regular_table_3 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,1) + tdSql.checkData(0,2,1) + tdSql.checkData(0,3,1) + tdSql.checkData(0,4,1) + tdSql.checkData(0,5,'True') + tdSql.checkData(0,6,'binary+1') + tdSql.checkData(0,7,'nchar+1') + tdSql.checkData(0,8,1) + tdSql.checkData(0,9,1) + tdSql.checkData(0,10,'2020-09-13 20:26:41.000') + + tdSql.error('''insert into regular_table_3 values( %d , -2147483648, -9223372036854775807, -32767, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into regular_table_3 values( %d , -2147483647, -9223372036854775808, -32767, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into regular_table_3 values( %d , -2147483647, -9223372036854775807, -32768, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into regular_table_3 values( %d , -2147483647, -9223372036854775807, -32767, -128, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into regular_table_3 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-0123', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into regular_table_3 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-0', 'nchar-01234', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + + tdSql.execute('''insert into regular_table_3 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-012', 'nchar-0123', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + sql = '''select * from regular_table_3 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,-2147483647) + tdSql.checkData(0,2,-9223372036854775807) + tdSql.checkData(0,3,-32767) + tdSql.checkData(0,4,-127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-012') + tdSql.checkData(0,7,'nchar-0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:44.090') + + tdSql.error('''insert into regular_table_3 values( %d , 2147483648, 9223372036854775807, 32767, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into regular_table_3 values( %d , 2147483647, 9223372036854775808, 32767, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into regular_table_3 values( %d , 2147483647, 9223372036854775807, 32768, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into regular_table_3 values( %d , 2147483647, 9223372036854775807, 32767, 128, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into regular_table_3 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+0123', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into regular_table_3 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+0', 'nchar+01234', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + + tdSql.execute('''insert into regular_table_3 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+012', 'nchar+0123', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + sql = '''select * from regular_table_3 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,2147483647) + tdSql.checkData(0,2,9223372036854775807) + tdSql.checkData(0,3,32767) + tdSql.checkData(0,4,127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+012') + tdSql.checkData(0,7,'nchar+0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:44.090') + tdSql.execute('''insert into regular_table_3 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-012', 'nchar-0123', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + sql = '''select * from regular_table_3 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,-2147483647) + tdSql.checkData(0,2,-9223372036854775807) + tdSql.checkData(0,3,-32767) + tdSql.checkData(0,4,-127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-012') + tdSql.checkData(0,7,'nchar-0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdLog.info("========== stable ==========") + tdSql.execute('''insert into table_3 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts - 200)) + sql = '''select * from table_3 where ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + sql = '''select * from stable_1 where loc = 'table_3' and ts = %d ;''' %(self.ts - 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-0') + tdSql.checkData(0,7,'nchar-0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.execute('''insert into table_3 values( %d , 0, 0, 0, 0, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 200)) + sql = '''select * from table_3 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+0') + tdSql.checkData(0,7,'nchar+0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + sql = '''select * from stable_1 where loc = 'table_3' and ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+0') + tdSql.checkData(0,7,'nchar+0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.execute('''insert into table_3 values( %d , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);''' %(self.ts + 200)) + sql = '''select * from table_3 where ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+0') + tdSql.checkData(0,7,'nchar+0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + sql = '''select * from stable_1 where loc = 'table_3' and ts = %d ;''' %(self.ts + 200) + tdSql.query(sql) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+0') + tdSql.checkData(0,7,'nchar+0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + tdSql.error('''insert into table_3 values( %d , -2147483648, -9223372036854775807, -32767, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_3 values( %d , -2147483647, -9223372036854775808, -32767, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_3 values( %d , -2147483647, -9223372036854775807, -32768, -127, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_3 values( %d , -2147483647, -9223372036854775807, -32767, -128, 0, 'binary-0', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_3 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-0123', 'nchar-0', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + tdSql.error('''insert into table_3 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-0', 'nchar-01234', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + + tdSql.execute('''insert into table_3 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-012', 'nchar-0123', 0.000000, 0.000000, 1600000000000);''' %(self.ts - 500)) + sql = '''select * from table_3 where ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,-2147483647) + tdSql.checkData(0,2,-9223372036854775807) + tdSql.checkData(0,3,-32767) + tdSql.checkData(0,4,-127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-012') + tdSql.checkData(0,7,'nchar-0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:44.090') + sql = '''select * from stable_1 where loc = 'table_3' and ts = %d ;''' %(self.ts - 500) + tdSql.query(sql) + tdSql.checkData(0,1,-2147483647) + tdSql.checkData(0,2,-9223372036854775807) + tdSql.checkData(0,3,-32767) + tdSql.checkData(0,4,-127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-012') + tdSql.checkData(0,7,'nchar-0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:44.090') + + tdSql.error('''insert into table_3 values( %d , 2147483648, 9223372036854775807, 32767, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_3 values( %d , 2147483647, 9223372036854775808, 32767, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_3 values( %d , 2147483647, 9223372036854775807, 32768, 127, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_3 values( %d , 2147483647, 9223372036854775807, 32767, 128, 0, 'binary+0', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_3 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+0123', 'nchar+0', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + tdSql.error('''insert into table_3 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+0', 'nchar+01234', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + + tdSql.execute('''insert into table_3 values( %d , 2147483647, 9223372036854775807, 32767, 127, 0, 'binary+012', 'nchar+0123', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + sql = '''select * from table_3 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,2147483647) + tdSql.checkData(0,2,9223372036854775807) + tdSql.checkData(0,3,32767) + tdSql.checkData(0,4,127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+012') + tdSql.checkData(0,7,'nchar+0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:44.090') + sql = '''select * from stable_1 where loc = 'table_3' and ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,2147483647) + tdSql.checkData(0,2,9223372036854775807) + tdSql.checkData(0,3,32767) + tdSql.checkData(0,4,127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary+012') + tdSql.checkData(0,7,'nchar+0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:44.090') + tdSql.execute('''insert into table_3 values( %d , -2147483647, -9223372036854775807, -32767, -127, 0, 'binary-012', 'nchar-0123', 0.000000, 0.000000, 1600000000000);''' %(self.ts + 500)) + sql = '''select * from table_3 where ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,-2147483647) + tdSql.checkData(0,2,-9223372036854775807) + tdSql.checkData(0,3,-32767) + tdSql.checkData(0,4,-127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-012') + tdSql.checkData(0,7,'nchar-0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + sql = '''select * from stable_1 where loc = 'table_3' and ts = %d ;''' %(self.ts + 500) + tdSql.query(sql) + tdSql.checkData(0,1,-2147483647) + tdSql.checkData(0,2,-9223372036854775807) + tdSql.checkData(0,3,-32767) + tdSql.checkData(0,4,-127) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary-012') + tdSql.checkData(0,7,'nchar-0123') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2020-09-13 20:26:40.000') + + + + tdLog.info("========== 4096 regular_table ==========") + sql = '''insert into regular_table_4096_3 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4095 ) + values('2020-09-13 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-13 20:26:44.090','1600000000000');''' + tdSql.execute(sql) + tdSql.query("select * from regular_table_4096_3 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4095,'1600000000000') + + sql = '''insert into regular_table_4096_3 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4095 ) + values('2020-09-10 20:26:40.000' , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL);''' + tdSql.execute(sql) + tdSql.query("select * from regular_table_4096_3 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4095,'1500000000000') + + sql = '''insert into regular_table_4096_3 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4095 ) + values('2020-09-13 20:26:40.000' , 2 , 502 , 102 , 1502 , 2002 , 0 , 3002 , '3502' , '3802' ,'2020-09-13 20:26:44.092','1600000002000');''' + tdSql.execute(sql) + tdSql.query("select * from regular_table_4096_3 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,2) + tdSql.checkData(0,501,502) + tdSql.checkData(0,1001,102) + tdSql.checkData(0,1501,1502) + tdSql.checkData(0,2001,2002) + tdSql.checkData(0,2501,'False') + tdSql.checkData(0,3001,3002) + tdSql.checkData(0,3501,'3502') + tdSql.checkData(0,3801,'3802') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.092') + tdSql.checkData(0,4095,'1600000002000') + + + tdLog.info("========== 4096 stable ==========") + sql = '''insert into table_4096_3 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4093 ) + values('2020-09-13 20:26:40.000' , 1 , 501 , 101 , 1501 , 2001 , 1 , 3001 , '3501' , '3801' ,'2020-09-13 20:26:44.090','1600000000000');''' + tdSql.execute(sql) + tdSql.query("select * from table_4096_3 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4094) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + tdSql.query("select * from stable_4096_3 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.090') + tdSql.checkData(0,4093,'1600000000000') + + sql = '''insert into table_4096_3 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4093 ) + values('2020-09-10 20:26:40.000' , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL);''' + tdSql.execute(sql) + tdSql.query("select * from table_4096_3 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4094) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4093,'1500000000000') + tdSql.query("select * from stable_4096_3 where ts ='2020-09-10 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,1) + tdSql.checkData(0,501,501) + tdSql.checkData(0,1001,101) + tdSql.checkData(0,1501,1501) + tdSql.checkData(0,2001,2001) + tdSql.checkData(0,2501,'True') + tdSql.checkData(0,3001,3001) + tdSql.checkData(0,3501,'3501') + tdSql.checkData(0,3801,'3801') + tdSql.checkData(0,4091,'2020-09-10 20:26:44.090') + tdSql.checkData(0,4093,'1500000000000') + + sql = '''insert into table_4096_3 (ts , int_1,smallint_501 , tinyint_1001 , double_1501 , float_2001 , bool_2501 , + bigint_3001 , nchar_3501 , binary_3801 , timestamp_4091 , col4093 ) + values('2020-09-13 20:26:40.000' , 2 , 502 , 102 , 1502 , 2002 , 0 , 3002 , '3502' , '3802' ,'2020-09-13 20:26:44.092','1600000002000');''' + tdSql.execute(sql) + tdSql.query("select * from table_4096_3 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4094) + tdSql.checkData(0,1,2) + tdSql.checkData(0,501,502) + tdSql.checkData(0,1001,102) + tdSql.checkData(0,1501,1502) + tdSql.checkData(0,2001,2002) + tdSql.checkData(0,2501,'False') + tdSql.checkData(0,3001,3002) + tdSql.checkData(0,3501,'3502') + tdSql.checkData(0,3801,'3802') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.092') + tdSql.checkData(0,4093,'1600000002000') + tdSql.query("select * from stable_4096_3 where ts ='2020-09-13 20:26:40.000';") + tdSql.checkCols(4096) + tdSql.checkData(0,1,2) + tdSql.checkData(0,501,502) + tdSql.checkData(0,1001,102) + tdSql.checkData(0,1501,1502) + tdSql.checkData(0,2001,2002) + tdSql.checkData(0,2501,'False') + tdSql.checkData(0,3001,3002) + tdSql.checkData(0,3501,'3502') + tdSql.checkData(0,3801,'3802') + tdSql.checkData(0,4091,'2020-09-13 20:26:44.092') + tdSql.checkData(0,4093,'1600000002000') + + + endTime = time.time() + print("total time %ds" % (endTime - startTime)) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/__init__.py b/tests/pytest/insert/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/pytest/insert/alterTableAndInsert.py b/tests/pytest/insert/alterTableAndInsert.py new file mode 100644 index 0000000000000000000000000000000000000000..a0447704f3cfa594f3bda01cb0dd14b2e795bb5f --- /dev/null +++ b/tests/pytest/insert/alterTableAndInsert.py @@ -0,0 +1,40 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdSql.execute("create table cars(ts timestamp, speed int) tags(id int)") + tdSql.execute("create table car0 using cars tags(0)") + tdSql.execute("insert into car0 values(now, 1)") + tdSql.execute("alter table cars add column c2 int") + tdSql.execute("insert into car0(ts, 'speed') values(now, 2)") + tdSql.checkAffectedRows(1) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/basic.py b/tests/pytest/insert/basic.py new file mode 100644 index 0000000000000000000000000000000000000000..f23f38651aa57590a14824077e003812ea10d8bd --- /dev/null +++ b/tests/pytest/insert/basic.py @@ -0,0 +1,55 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + ret = tdSql.execute('create table tb (ts timestamp, speed int)') + + insertRows = 10 + tdLog.info("insert %d rows" % (insertRows)) + for i in range(0, insertRows): + ret = tdSql.execute( + 'insert into tb values (now + %dm, %d)' % + (i, i)) + + tdLog.info("insert earlier data") + tdSql.execute('insert into tb values (now - 5m , 10)') + tdSql.execute('insert into tb values (now - 6m , 10)') + tdSql.execute('insert into tb values (now - 7m , 10)') + tdSql.execute('insert into tb values (now - 8m , 10)') + + tdSql.query("select * from tb") + tdSql.checkRows(insertRows + 4) + + # test case for https://jira.taosdata.com:18080/browse/TD-3716: + tdSql.error("insert into tb(now, 1)") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/basic_unsigned.py b/tests/pytest/insert/basic_unsigned.py new file mode 100644 index 0000000000000000000000000000000000000000..ff7e0e5e4ad57a35d574d88ea179f713c8a8b611 --- /dev/null +++ b/tests/pytest/insert/basic_unsigned.py @@ -0,0 +1,56 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + ret = tdSql.execute( + 'create table tb (ts timestamp, speed tinyint unsigned)') + + insertRows = 10 + tdLog.info("insert %d rows" % (insertRows)) + for i in range(0, insertRows): + ret = tdSql.execute( + 'insert into tb values (now + %dm, %d)' % + (i, i)) + + tdLog.info("insert earlier data") + tdSql.execute('insert into tb values (now - 5m , NULL)') + tdSql.execute('insert into tb values (now - 6m , 10)') + tdSql.execute('insert into tb values (now - 7m , NULL)') + tdSql.execute('insert into tb values (now - 8m , 254)') + + tdSql.error('insert into tb values (now - 9m, -1)') + tdSql.error('insert into tb values (now - 9m, 255)') + + tdSql.query("select * from tb") + tdSql.checkRows(insertRows + 4) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/before_1970.py b/tests/pytest/insert/before_1970.py new file mode 100644 index 0000000000000000000000000000000000000000..b2c4dc57c7a37b4b119308335d326521fe986f08 --- /dev/null +++ b/tests/pytest/insert/before_1970.py @@ -0,0 +1,80 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +from util.dnodes import tdDnodes + + +class TDTestCase: + """ + add test data before 1970s + """ + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + print("==============step1") + tdSql.execute("create database if not exists demo keep 36500;"); + print("==============create db demo keep 365000 days") + tdSql.execute("use demo;") + tdSql.execute("CREATE table if not exists test (ts timestamp, f1 int);") + print("==============create table test") + + print("==============step2") + #TODO : should add more testcases + tdSql.execute("insert into test values('1930-12-12 01:19:20.345', 1);") + tdSql.execute("insert into test values('1969-12-30 23:59:59.999', 2);") + tdSql.execute("insert into test values(-3600001, 3);") + tdSql.execute("insert into test values('2020-10-20 14:02:53.770', 4);") + print("==============insert data") + + # tdSql.query("select * from test;") + # + # tdSql.checkRows(3) + # + # tdSql.checkData(0,0,'1969-12-12 01:19:20.345000') + # tdSql.checkData(1,0,'1970-01-01 07:00:00.000000') + # tdSql.checkData(2,0,'2020-10-20 14:02:53.770000') + print("==============step3") + tdDnodes.stopAll() + tdDnodes.start(1) + print("==============restart taosd") + + + print("==============step4") + tdSql.execute("use demo;") + tdSql.query("select * from test;") + print(tdSql.queryResult) + tdSql.checkRows(4) + tdSql.checkData(0,0,'1930-12-12 01:19:20.345000') + tdSql.checkData(1,0,'1969-12-30 23:59:59.999000') + tdSql.checkData(2,0,'1970-01-01 06:59:59.999000') + tdSql.checkData(3,0,'2020-10-20 14:02:53.770000') + print("==============check data") + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/bigint.py b/tests/pytest/insert/bigint.py new file mode 100644 index 0000000000000000000000000000000000000000..7c7d2d0f9507e8688dd73bcefe88632361c80c70 --- /dev/null +++ b/tests/pytest/insert/bigint.py @@ -0,0 +1,69 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdLog.info('=============== step1') + tdLog.info('create table tb (ts timestamp, speed bigint)') + tdSql.execute('create table tb (ts timestamp, speed bigint)') + tdLog.info("insert into tb values (now, -9223372036854770000)") + tdSql.execute("insert into tb values (now, -9223372036854770000)") + tdLog.info('select * from tb') + tdSql.query('select * from tb') + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + tdLog.info('tdSql.checkData(0, 1, -9223372036854770000)') + tdSql.checkData(0, 1, -9223372036854770000) + tdLog.info('=============== step2') + tdLog.info("insert into tb values (now+1a, -9223372036854770000)") + tdSql.execute("insert into tb values (now+1a, -9223372036854770000)") + tdLog.info('select * from tb') + tdSql.query('select * from tb') + tdLog.info('tdSql.checkRow(2)') + tdSql.checkRows(2) + tdLog.info('tdSql.checkData(0, 1, -9223372036854770000)') + tdSql.checkData(0, 1, -9223372036854770000) + tdLog.info('=============== step3') + tdLog.info("insert into tb values (now+2a, 9223372036854770000)") + tdSql.execute("insert into tb values (now+2a, 9223372036854770000)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(3)') + tdSql.checkRows(3) + tdLog.info('tdSql.checkData(0, 1, 9223372036854770000)') + tdSql.checkData(0, 1, 9223372036854770000) + tdLog.info('=============== step4') + tdLog.info("insert into tb values (now+3a, 9223372036854770000)") + tdSql.execute("insert into tb values (now+3a, 9223372036854770000)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(4)') + tdSql.checkRows(4) + tdLog.info('tdSql.checkData(0, 1, 9223372036854770000)') + tdSql.checkData(0, 1, 9223372036854770000) + tdLog.info('drop database db') + tdSql.execute('drop database db') + tdLog.info('show databases') + tdSql.query('show databases') + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/binary-boundary.py b/tests/pytest/insert/binary-boundary.py new file mode 100644 index 0000000000000000000000000000000000000000..bb86ddf61c3abcd56d2bb27f7f7da5f1d22069ee --- /dev/null +++ b/tests/pytest/insert/binary-boundary.py @@ -0,0 +1,148 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdLog.info('=============== step1') + tdLog.info('create table tb (ts timestamp, speed binary(4089))') + tdSql.error('create table tb (ts timestamp, speed binary(4089))') + tdLog.info('create table tb (ts timestamp, speed binary(4088))') + tdSql.error('create table tb (ts timestamp, speed binary(4088))') + tdLog.info('create table tb (ts timestamp, speed binary(4084))') + tdSql.execute('create table tb (ts timestamp, speed binary(4084))') + tdLog.info("insert into tb values (now, ) -x step1") + tdSql.error("insert into tb values (now, )") + + with open("../../README.md", "r") as inputFile: + data = inputFile.read(4084).replace( + "\n", + " ").replace( + "\\", + " ").replace( + "\'", + " ").replace( + "\"", + " ").replace( + "[", + " ").replace( + "]", + " ").replace( + "!", + " ") + + tdLog.info("insert %d length data: %s" % (len(data), data)) + + tdLog.info("insert into tb values (now+2a, data)") + tdSql.execute("insert into tb values (now+2a, '%s')" % data) + tdLog.info('select speed from tb order by ts desc') + tdSql.query('select speed from tb order by ts desc') + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + tdLog.info('==> $data01') + tdLog.info("tdSql.checkData(0, 1, '%s')" % data) + tdSql.checkData(0, 1, data) + + tdLog.info( + 'create table tb2 (ts timestamp, speed binary(2040), temp binary(2044))') + tdSql.execute( + 'create table tb2 (ts timestamp, speed binary(2040), temp binary(2044))') + speed = inputFile.read(2044).replace( + "\n", + " ").replace( + "\\", + " ").replace( + "\'", + " ").replace( + "\"", + " ").replace( + "[", + " ").replace( + "]", + " ").replace( + "!", + " ") + temp = inputFile.read(2040).replace( + "\n", + " ").replace( + "\\", + " ").replace( + "\'", + " ").replace( + "\"", + " ").replace( + "[", + " ").replace( + "]", + " ").replace( + "!", + " ") + tdLog.info("insert into tb values (now+3a, speed, temp)") + tdSql.error( + "insert into tb values (now+3a, '%s', '%s')" % + (speed, temp)) + + speed = inputFile.read(2040).replace( + "\n", + " ").replace( + "\\", + " ").replace( + "\'", + " ").replace( + "\"", + " ").replace( + "[", + " ").replace( + "]", + " ").replace( + "!", + " ") + temp = inputFile.read(2044).replace( + "\n", + " ").replace( + "\\", + " ").replace( + "\'", + " ").replace( + "\"", + " ").replace( + "[", + " ").replace( + "]", + " ").replace( + "!", + " ") + tdLog.info("insert into tb values (now+4a, speed, temp)") + tdSql.error( + "insert into tb values (now+4a, '%s', '%s')" % + (speed, temp)) + + tdLog.info('tdSql.checkRow(2)') + tdSql.checkRows(2) + tdLog.info('==> $data11') + tdLog.info("tdSql.checkData(1, 1, '%s')" % speed) + tdSql.checkData(1, 1, speed) + + tdLog.info('==> $data12') + tdLog.info("tdSql.checkData(1, 2, '%s')" % temp) + tdSql.checkData(1, 1, temp) + + inputFile.close() + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/binary.py b/tests/pytest/insert/binary.py new file mode 100644 index 0000000000000000000000000000000000000000..e91a20e65cd04dd64a88af88259e8e25eebf595c --- /dev/null +++ b/tests/pytest/insert/binary.py @@ -0,0 +1,75 @@ +# -*- coding: utf-8 -*- + +import platform +import sys +from util.log import * +from util.cases import * +from util.sql import * +import subprocess +import os + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdLog.info('=============== step1') + tdLog.info('create table tb (ts timestamp, speed binary(5))') + tdSql.execute('create table tb (ts timestamp, speed binary(5))') + tdLog.info("insert into tb values (now, ) -x step1") + tdSql.error("insert into tb values (now, )") + tdLog.info('=============== step2') + tdLog.info("insert into tb values (now+1a, '1234')") + tdSql.execute("insert into tb values (now+1a, '1234')") + tdLog.info('select speed from tb order by ts desc') + tdSql.query('select speed from tb order by ts desc') + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + tdLog.info("tdSql.checkData(0, 0, '1234')") + tdSql.checkData(0, 0, '1234') + tdLog.info('=============== step3') + tdLog.info("insert into tb values (now+2a, '23456')") + tdSql.execute("insert into tb values (now+2a, '23456')") + tdLog.info('select speed from tb order by ts desc') + tdSql.query('select speed from tb order by ts desc') + tdLog.info('tdSql.checkRow(2)') + tdSql.checkRows(2) + tdLog.info('==> $data00') + tdLog.info("tdSql.checkData(0, 0, '23456')") + tdSql.checkData(0, 0, '23456') + tdLog.info('=============== step4') + tdLog.info("insert into tb values (now+3a, '345678')") + tdSql.error("insert into tb values (now+3a, '345678')") + tdLog.info("insert into tb values (now+3a, '34567')") + tdSql.execute("insert into tb values (now+3a, '34567')") + tdLog.info('select speed from tb order by ts desc') + tdSql.query('select speed from tb order by ts desc') + tdLog.info('tdSql.checkRow(3)') + tdSql.checkRows(3) + tdLog.info('==> $data00') + tdLog.info("tdSql.checkData(0, 0, '34567')") + tdSql.checkData(0, 0, '34567') + tdLog.info("insert into tb values (now+4a, \"'';\")") + if platform.system() == "Linux": + config_dir = subprocess.check_output(str("ps -ef |grep dnode1|grep -v grep |awk '{print $NF}'"), stderr=subprocess.STDOUT, shell=True).decode('utf-8').replace('\n', '') + result = ''.join(os.popen(r"""taos -s "insert into db.tb values (now+4a, \"'';\")" -c %s"""%(config_dir)).readlines()) + if "Query OK" not in result: tdLog.exit("err:insert '';") + tdLog.info('drop database db') + tdSql.execute('drop database db') + tdLog.info('show databases') + tdSql.query('show databases') + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/bool.py b/tests/pytest/insert/bool.py new file mode 100644 index 0000000000000000000000000000000000000000..1412567cd75721d99308ddadfe7b35032207faaa --- /dev/null +++ b/tests/pytest/insert/bool.py @@ -0,0 +1,77 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdLog.info('=============== step1') + tdLog.info('create table tb (ts timestamp, speed bool)') + tdSql.execute('create table tb (ts timestamp, speed bool)') + tdLog.info("insert into tb values (now, true)") + tdSql.execute("insert into tb values (now, true)") + tdLog.info('select * from tb') + tdSql.query('select * from tb') + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + tdLog.info('=============== step2') + tdLog.info("insert into tb values (now+1m, 1)") + tdSql.execute("insert into tb values (now+1m, 1)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(2)') + tdSql.checkRows(2) + tdLog.info('=============== step3') + tdLog.info("insert into tb values (now+2m, 2)") + tdSql.execute("insert into tb values (now+2m, 2)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(3)') + tdSql.checkRows(3) + tdLog.info('=============== step4') + tdLog.info("insert into tb values (now+3m, 0)") + tdSql.execute("insert into tb values (now+3m, 0)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(4)') + tdSql.checkRows(4) + tdLog.info('=============== step5') + tdLog.info("insert into tb values (now+4m, -1)") + tdSql.execute("insert into tb values (now+4m, -1)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + tdLog.info('=============== step6') + tdLog.info("insert into tb values (now+5m, false)") + tdSql.execute("insert into tb values (now+5m, false)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(6)') + tdSql.checkRows(6) + tdLog.info('=============== step7') + tdLog.info("insert into tb values (now+6m, true)") + tdSql.execute("insert into tb values (now+5m, true)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(7)') + tdSql.checkRows(7) +# convert end +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/boundary2.py b/tests/pytest/insert/boundary2.py new file mode 100644 index 0000000000000000000000000000000000000000..e3623b72672029ca71a4c0ce6d82d7428511b8f3 --- /dev/null +++ b/tests/pytest/insert/boundary2.py @@ -0,0 +1,80 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import random +import string +import time +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +from util.dnodes import tdDnodes + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.ts = 1538548685000 + + def get_random_string(self, length): + letters = string.ascii_lowercase + result_str = ''.join(random.choice(letters) for i in range(length)) + return result_str + + def run(self): + tdSql.prepare() + + startTime = time.time() + print("==============step1") + sql = "create table stb(ts timestamp, " + for i in range(15): + sql += "col%d binary(1022), " % (i + 1) + sql += "col1023 binary(1014))" + tdSql.execute(sql) + + for i in range(4096): + sql = "insert into stb values(%d, " + for j in range(15): + str = "'%s', " % self.get_random_string(1022) + sql += str + sql += "'%s')" % self.get_random_string(1014) + tdSql.execute(sql % (self.ts + i)) + + time.sleep(10) + tdSql.query("select count(*) from stb") + tdSql.checkData(0, 0, 4096) + + tdDnodes.stop(1) + tdDnodes.start(1) + + time.sleep(1) + tdSql.query("select count(*) from stb") + tdSql.checkData(0, 0, 4096) + + sql = "create table stb(ts timestamp, " + for i in range(15): + sql += "col%d binary(1022), " % (i + 1) + sql += "col1023 binary(1015))" + tdSql.error(sql) + + endTime = time.time() + + print("total time %ds" % (endTime - startTime)) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/bug3654.py b/tests/pytest/insert/bug3654.py new file mode 100644 index 0000000000000000000000000000000000000000..41bedf771b16f09e5e75cf64805fcc04e7a5ed5b --- /dev/null +++ b/tests/pytest/insert/bug3654.py @@ -0,0 +1,53 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import taos +import sys + +from util.log import * +from util.sql import * +from util.cases import * + +class TDTestCase: + + def init(self, conn, logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + + def run(self): + tdSql.prepare() + + tdLog.printNoPrefix("==========step1:create table") + tdSql.execute("drop database if exists db") + tdSql.execute("create database db keep 36500,36500,36500") + tdSql.execute("use db") + tdSql.execute("create stable if not exists stb1 (ts timestamp, c1 int) tags(t11 int)") + tdSql.execute("create table t10 using stb1 tags(1)") + gapdate = (datetime.datetime.now() - datetime.datetime(1970, 1, 1, 8, 0, 0)).days + + tdLog.printNoPrefix("==========step2:insert data") + tdSql.execute(f"insert into t10 values (now-{gapdate}d, 1)") + tdSql.execute(f"insert into t10 values (now-{gapdate + 1}d, 2)") + + tdLog.printNoPrefix("==========step3:query") + tdSql.query("select * from t10 where c1=1") + tdSql.checkRows(1) + tdSql.query("select * from t10 where c1=2") + tdSql.checkRows(1) + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/insert/date.py b/tests/pytest/insert/date.py new file mode 100644 index 0000000000000000000000000000000000000000..6e22e5b72ee465bfd32b9fd839c8ab0deba9267c --- /dev/null +++ b/tests/pytest/insert/date.py @@ -0,0 +1,193 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: system sh/ip.sh -i 1 -s up + # TSIM: system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: $i = 0 + # TSIM: $dbPrefix = lm_da_db + # TSIM: $tbPrefix = lm_da_tb + # TSIM: $db = $dbPrefix . $i + # TSIM: $tb = $tbPrefix . $i + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: + # TSIM: sql create table $tb (ts timestamp, speed int) + tdLog.info("create table tb0 (ts timestamp, speed int)") + tdSql.execute('create table tb0 (ts timestamp, speed int)') + # TSIM: sql insert into $tb values ('2017-01-01 08:00:00.001', 1) + tdLog.info("insert into tb0 values ('2017-01-01 08:00:00.001', 1)") + tdSql.execute("insert into tb0 values ('2017-01-01 08:00:00.001', 1)") + # TSIM: sql select ts from $tb + tdLog.info('select ts from tb0') + tdSql.query('select ts from tb0') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data00 != @17-01-01 08:00:00.001@ then + tdLog.info("tdSql.checkData(0, 0, 17-01-01 08:00:00.001)") + expectedData = datetime.datetime.strptime( + "17-01-01 08:00:00.001", "%y-%m-%d %H:%M:%S.%f") + tdSql.checkData(0, 0, expectedData) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sql insert into $tb values ('2017-08-28 00:23:46.429+ 1a', 2) + tdLog.info("insert into tb0 values ('2017-08-28 00:23:46.429+ 1a', 2)") + tdSql.execute( + "insert into tb0 values ('2017-08-28 00:23:46.429+ 1a', 2)") + # TSIM: #sql insert into $tb values ('2017-08-28 00:23:46cd .429', 2) + # TSIM: sql select ts from $tb + tdLog.info('select ts from tb0') + tdSql.query('select ts from tb0') + # TSIM: if $rows != 2 then + tdLog.info('tdSql.checkRow(2)') + tdSql.checkRows(2) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: #sql insert into $tb values ('1970-01-01 08:00:00.000', 3) + # TSIM: #sql insert into $tb values ('1970-01-01 08:00:00.000', 3) + # TSIM: sql select ts from $tb + tdLog.info('select ts from tb0') + tdSql.query('select ts from tb0') + # TSIM: if $rows != 2 then + tdLog.info('tdSql.checkRow(2)') + tdSql.checkRows(2) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql insert into $tb values(now, 4); + tdLog.info("insert into tb0 values(now, 4);") + tdSql.execute("insert into tb0 values(now, 4);") + # TSIM: sql insert into $tb values(now+1a, 5); + tdLog.info("insert into tb0 values(now+1a, 5);") + tdSql.execute("insert into tb0 values(now+1a, 5);") + # TSIM: sql insert into $tb values(now+1s, 6); + tdLog.info("insert into tb0 values(now+1s, 6);") + tdSql.execute("insert into tb0 values(now+1s, 6);") + # TSIM: sql insert into $tb values(now+1m, 7); + tdLog.info("insert into tb0 values(now+1m, 7);") + tdSql.execute("insert into tb0 values(now+1m, 7);") + # TSIM: sql insert into $tb values(now+1h, 8); + tdLog.info("insert into tb0 values(now+1h, 8);") + tdSql.execute("insert into tb0 values(now+1h, 8);") + # TSIM: sql insert into $tb values(now+1d, 9); + tdLog.info("insert into tb0 values(now+1d, 9);") + tdSql.execute("insert into tb0 values(now+1d, 9);") + # TSIM: sql_error insert into $tb values(now+3w, 10); + tdLog.info("insert into tb0 values(now+3w, 10);") + tdSql.error("insert into tb0 values(now+3w, 10);") + # TSIM: sql_error insert into $tb values(now+1n, 11); + tdLog.info("insert into tb0 values(now+1n, 11);") + tdSql.error("insert into tb0 values(now+1n, 11);") + # TSIM: sql_error insert into $tb values(now+1y, 12); + tdLog.info("insert into tb0 values(now+1y, 12);") + tdSql.error("insert into tb0 values(now+1y, 12);") + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql_error insert into $tb values ('9999-12-31 213:59:59.999', + # 13) + tdLog.info("insert into tb0 values ('9999-12-31 213:59:59.999', 13)") + tdSql.error("insert into tb0 values ('9999-12-31 213:59:59.999', 13)") + # TSIM: sql select ts from $tb + tdLog.info('select ts from tb0') + tdSql.query('select ts from tb0') + # TSIM: print $rows + tdLog.info('$rows') + # TSIM: if $rows != 8 then + tdLog.info('tdSql.checkRow(8)') + tdSql.checkRows(8) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql_error insert into $tb values ('9999-12-99 23:59:59.999', + # 13) + tdLog.info("insert into tb0 values ('9999-12-99 23:59:59.999', 13)") + tdSql.error("insert into tb0 values ('9999-12-99 23:59:59.999', 13)") + # TSIM: + # TSIM: sql select ts from $tb + tdLog.info('select ts from tb0') + tdSql.query('select ts from tb0') + # TSIM: if $rows != 8 then + tdLog.info('tdSql.checkRow(8)') + tdSql.checkRows(8) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: $i = 1 + # TSIM: $tb = $tbPrefix . $i + # TSIM: sql create table $tb (ts timestamp, ts2 timestamp) + tdLog.info("create table tb1 (ts timestamp, ts2 timestamp)") + tdSql.execute('create table tb1 (ts timestamp, ts2 timestamp)') + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql insert into $tb values (now, now) + tdLog.info("insert into tb1 values (now, now)") + tdSql.execute("insert into tb1 values (now, now)") + # TSIM: sql select * from $tb + tdLog.info('select * from tb1') + tdSql.query('select * from tb1') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/double.py b/tests/pytest/insert/double.py new file mode 100644 index 0000000000000000000000000000000000000000..1b66ed1c44c7cec645be1f0f23866c7f06501ebc --- /dev/null +++ b/tests/pytest/insert/double.py @@ -0,0 +1,90 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdLog.info('=============== step1') + tdLog.info('create table tb (ts timestamp, speed double)') + tdSql.execute('create table tb (ts timestamp, speed double)') + tdLog.info('=============== step2') + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + tdLog.info('=============== step3') + tdLog.info("insert into tb values (now+2a, 2.85)") + tdSql.execute("insert into tb values (now+2a, 2.85)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + tdLog.info('tdSql.checkData(0, 1, 2.850000000)') + tdSql.checkData(0, 1, 2.850000000) + tdLog.info('=============== step4') + tdLog.info("insert into tb values (now+3a, 3.4)") + tdSql.execute("insert into tb values (now+3a, 3.4)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(2)') + tdSql.checkRows(2) + tdLog.info('tdSql.checkData(0, 1, 3.400000000)') + tdSql.checkData(0, 1, 3.400000000) + tdLog.info('=============== step5') + tdLog.info("insert into tb values (now+4a, a2) -x step51") + tdSql.error("insert into tb values (now+4a, a2)1") + tdLog.info("insert into tb values (now+4a, 0)") + tdSql.execute("insert into tb values (now+4a, 0)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(3)') + tdSql.checkRows(3) + tdLog.info('tdSql.checkData(0, 1, 0.000000000)') + tdSql.checkData(0, 1, 0.000000000) + tdLog.info('=============== step6') + tdLog.info("insert into tb values (now+5a, 2a) -x step6") + tdSql.error("insert into tb values (now+5a, 2a)") + tdLog.info("insert into tb values(now+5a, 2)") + tdSql.execute("insert into tb values(now+5a, 2)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(4)') + tdSql.checkRows(4) + tdLog.info('tdSql.checkData(0, 1, 2.000000000)') + tdSql.checkData(0, 1, 2.000000000) + tdLog.info('=============== step7') + tdLog.info("insert into tb values (now+6a, 2a'1) -x step7") + tdSql.error("insert into tb values (now+6a, 2a'1)") + tdLog.info("insert into tb values(now+6a, 2)") + tdSql.execute("insert into tb values(now+6a, 2)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + tdLog.info('tdSql.checkData(0, 1, 2.000000000)') + tdSql.checkData(0, 1, 2.000000000) + tdLog.info('drop database db') + tdSql.execute('drop database db') + tdLog.info('show databases') + tdSql.query('show databases') + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/float.py b/tests/pytest/insert/float.py new file mode 100644 index 0000000000000000000000000000000000000000..8b6277d43657c1da3fa5e65ddbaa073fd7a7189e --- /dev/null +++ b/tests/pytest/insert/float.py @@ -0,0 +1,144 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import datetime +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdLog.info("=============== step1") + cmd = 'create table tb (ts timestamp, speed float)' + tdLog.info(cmd) + tdSql.execute(cmd) + cmd = 'insert into tb values (now, -3.40E+38)' + tdLog.info(cmd) + tdSql.execute(cmd) + + tdLog.info("=============== step2") + cmd = 'insert into tb values (now+1a, 3.40E+308)' + tdLog.info(cmd) + try: + tdSql.execute(cmd) + tdLog.exit( + "This test failed: insert wrong data error _not_ catched") + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("insert wrong data error catched") + + cmd = 'select * from tb order by ts desc' + tdLog.info(cmd) + tdSql.query(cmd) + tdSql.checkRows(1) + + tdLog.info("=============== step3") + cmd = "insert into tb values (now+2a, 2.85)" + tdLog.info(cmd) + tdSql.execute(cmd) + cmd = "select * from tb order by ts desc" + tdLog.info(cmd) + ret = tdSql.query(cmd) + tdSql.checkRows(2) + + if ((abs(tdSql.getData(0, 1) - 2.850000)) > 1.0e-7): + tdLog.exit("data is not 2.850000") + + tdLog.info("=============== step4") + cmd = "insert into tb values (now+3a, 3.4)" + tdLog.info(cmd) + tdSql.execute(cmd) + cmd = "select * from tb order by ts desc" + tdLog.info(cmd) + tdSql.query(cmd) + tdSql.checkRows(3) + if (abs(tdSql.getData(0, 1) - 3.400000) > 1.0e-7): + tdLog.exit("data is not 3.400000") + + tdLog.info("=============== step5") + cmd = "insert into tb values (now+4a, a2)" + tdLog.info(cmd) + try: + tdSql.execute(cmd) + tdLog.exit("This test failed: \ + insert wrong data error _not_ catched") + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("insert wrong data error catched") + + cmd = "insert into tb values (now+4a, 0)" + tdLog.info(cmd) + tdSql.execute(cmd) + cmd = "select * from tb order by ts desc" + tdLog.info(cmd) + tdSql.query(cmd) + tdSql.checkRows(4) + if (abs(tdSql.getData(0, 1) - 0.000000) != 0): + tdLog.exit("data is not 0.000000") + + tdLog.info("=============== step6") + cmd = "insert into tb values (now+5a, 2a)" + tdLog.info(cmd) + try: + tdSql.execute(cmd) + tdLog.exit( + "This test failed: insert wrong data error _not_ catched") + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("insert wrong data error catched") + + cmd = "insert into tb values (now+5a, 2)" + tdLog.info(cmd) + tdSql.execute(cmd) + cmd = "select * from tb order by ts desc" + tdLog.info(cmd) + ret = tdSql.query(cmd) + tdSql.checkRows(5) + if (abs(tdSql.getData(0, 1) - 2.000000) > 1.0e-7): + tdLog.info("data is not 2.000000") + + tdLog.info("=============== step7") + cmd = "insert into tb values (now+6a, 2a'1)" + tdLog.info(cmd) + try: + tdSql.execute(cmd) + tdLog.exit( + "This test failed: insert wrong data error _not_ catched") + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("insert wrong data error catched") + + cmd = "insert into tb values (now+6a, 2)" + tdLog.info(cmd) + tdSql.execute(cmd) + cmd = "select * from tb order by ts desc" + tdLog.info(cmd) + tdSql.query(cmd) + if (abs(tdSql.getData(0, 1) - 2.000000) > 1.0e-7): + tdLog.exit("data is not 2.000000") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/flushwhiledrop.py b/tests/pytest/insert/flushwhiledrop.py new file mode 100644 index 0000000000000000000000000000000000000000..3784657117ad9e5a24851a2e6ac11e11594f0c72 --- /dev/null +++ b/tests/pytest/insert/flushwhiledrop.py @@ -0,0 +1,67 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import threading +from util.log import * +from util.cases import * +from util.sql import * +from time import sleep + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self.numberOfRecords = 15000 + self.ts = 1601481600000 + + def run(self): + tdSql.execute('create database test cache 1 blocks 3') + tdSql.execute('use test') + tdSql.execute('create table tb(ts timestamp, c1 timestamp, c2 int, c3 bigint, c4 float, c5 double, c6 binary(8), c7 smallint, c8 tinyint, c9 bool, c10 nchar(8))') + threads = [] + t1 = threading.Thread(target=self.insertAndFlush, args=()) + threads.append(t1) + t2 = threading.Thread(target=self.drop, args=()) + threads.append(t2) + for t in threads: + t.setDaemon(True) + t.start() + for t in threads: + t.join() + + def insertAndFlush(self): + finish = 0 + currts = self.ts + + while(finish < self.numberOfRecords): + sql = "insert into tb values" + for i in range(finish, self.numberOfRecords): + sql += "(%d, 1019774612, 29931, 1442173978, 165092.468750, 1128.643179, 'MOCq1pTu', 18405, 82, 0, 'g0A6S0Fu')" % (currts + i) + finish = i + 1 + if (1048576 - len(sql)) < 16384: + break + tdSql.execute(sql) + + def drop(self): + sleep(30) + tdSql.execute('drop database test') + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/insert/in_function.py b/tests/pytest/insert/in_function.py new file mode 100644 index 0000000000000000000000000000000000000000..3f2e1a03cad0a74c665341ac04250ec8a239ad6f --- /dev/null +++ b/tests/pytest/insert/in_function.py @@ -0,0 +1,1114 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import datetime + +from util.log import * +from util.cases import * +from util.sql import * + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + # test case for https://jira.taosdata.com:18080/browse/TD-4568 + # test case for https://jira.taosdata.com:18080/browse/TD-4824 + + tdLog.info("=============== step1,check bool and tinyint data type") + + tdLog.info("=============== step1.1,drop table && create table") + cmd1 = 'drop table if exists in_bool_tinyint_1 ;' + cmd2 = 'drop table if exists in_bool_tinyint_2 ;' + cmd3 = 'drop table if exists in_bool_tinyint_3 ;' + cmd10 = 'drop table if exists in_stable_1 ;' + cmd11 = 'create stable in_stable_1(ts timestamp,in_bool bool,in_tinyint tinyint) tags (tin_bool bool,tin_tinyint tinyint) ;' + cmd12 = 'create table in_bool_tinyint_1 using in_stable_1 tags(\'true\',\'127\') ; ' + cmd13 = 'create table in_bool_tinyint_2 using in_stable_1 tags(\'false\',\'-127\') ; ' + cmd14 = 'create table in_bool_tinyint_3 using in_stable_1 tags(\'false\',\'0\') ; ' + tdLog.info(cmd1) + tdSql.execute(cmd1) + tdLog.info(cmd2) + tdSql.execute(cmd2) + tdLog.info(cmd3) + tdSql.execute(cmd3) + tdLog.info(cmd10) + tdSql.execute(cmd10) + tdLog.info(cmd11) + tdSql.execute(cmd11) + tdLog.info(cmd12) + tdSql.execute(cmd12) + tdLog.info(cmd13) + tdSql.execute(cmd13) + tdLog.info(cmd14) + tdSql.execute(cmd14) + + tdLog.info("=============== step1.2,insert stable right data and check in function") + cmd1 = 'insert into in_bool_tinyint_1 values(now,\'true\',\'-127\') ;' + tdLog.info(cmd1) + tdSql.execute(cmd1) + tdSql.query('select * from in_stable_1 where in_bool in (true) order by ts desc') + tdSql.checkData(0,1,'True') + tdSql.checkData(0,2,'-127') + tdSql.checkData(0,3,'True') + tdSql.checkData(0,4,'127') + tdSql.query('select * from in_stable_1 where in_tinyint in (-127) order by ts desc') + tdSql.checkData(0,1,'True') + tdSql.checkData(0,2,'-127') + tdSql.checkData(0,3,'True') + tdSql.checkData(0,4,'127') + tdSql.query('select * from in_stable_1 where tin_bool in (true) order by ts desc') + tdSql.checkData(0,1,'True') + tdSql.checkData(0,2,'-127') + tdSql.checkData(0,3,'True') + tdSql.checkData(0,4,'127') + tdSql.query('select * from in_stable_1 where tin_tinyint in (127) order by ts desc') + tdSql.checkData(0,1,'True') + tdSql.checkData(0,2,'-127') + tdSql.checkData(0,3,'True') + tdSql.checkData(0,4,'127') + tdSql.query('select * from in_bool_tinyint_1 where in_bool in (true) order by ts desc') + tdSql.checkData(0,1,'True') + tdSql.checkData(0,2,'-127') + tdSql.query('select * from in_bool_tinyint_1 where in_tinyint in (-127) order by ts desc') + tdSql.checkData(0,1,'True') + tdSql.checkData(0,2,'-127') + + cmd2 = 'insert into in_bool_tinyint_2 values(now,\'false\',\'127\') ;' + tdLog.info(cmd2) + tdSql.execute(cmd2) + tdSql.query('select * from in_stable_1 where in_bool in (false) order by ts desc') + tdSql.checkData(0,1,'False') + tdSql.checkData(0,2,'127') + tdSql.checkData(0,3,'False') + tdSql.checkData(0,4,'-127') + tdSql.query('select * from in_stable_1 where in_tinyint in (127) order by ts desc') + tdSql.checkData(0,1,'False') + tdSql.checkData(0,2,'127') + tdSql.checkData(0,3,'False') + tdSql.checkData(0,4,'-127') + tdSql.query('select * from in_stable_1 where tin_bool in (false) order by ts desc') + tdSql.checkData(0,1,'False') + tdSql.checkData(0,2,'127') + tdSql.checkData(0,3,'False') + tdSql.checkData(0,4,'-127') + tdSql.query('select * from in_stable_1 where tin_tinyint in (-127) order by ts desc') + tdSql.checkData(0,1,'False') + tdSql.checkData(0,2,'127') + tdSql.checkData(0,3,'False') + tdSql.checkData(0,4,'-127') + tdSql.query('select * from in_bool_tinyint_2 where in_bool in (false) order by ts desc') + tdSql.checkData(0,1,'False') + tdSql.checkData(0,2,'127') + tdSql.query('select * from in_bool_tinyint_2 where in_tinyint in (127) order by ts desc') + tdSql.checkData(0,1,'False') + tdSql.checkData(0,2,'127') + + cmd3 = 'insert into in_bool_tinyint_3 values(now,\'true\',\'0\') ;' + tdLog.info(cmd3) + tdSql.execute(cmd3) + tdSql.query('select * from in_stable_1 where in_tinyint in (0) order by ts desc') + tdSql.checkData(0,1,'True') + tdSql.checkData(0,2,'0') + tdSql.checkData(0,3,'False') + tdSql.checkData(0,4,'0') + tdSql.query('select * from in_stable_1 where tin_tinyint in (0) order by ts desc') + tdSql.checkData(0,1,'True') + tdSql.checkData(0,2,'0') + tdSql.checkData(0,3,'False') + tdSql.checkData(0,4,'0') + tdSql.query('select * from in_bool_tinyint_3 where in_bool in (true) order by ts desc') + tdSql.checkData(0,1,'True') + tdSql.checkData(0,2,'0') + tdSql.query('select * from in_bool_tinyint_3 where in_tinyint in (0) order by ts desc') + tdSql.checkData(0,1,'True') + tdSql.checkData(0,2,'0') + + tdLog.info("=============== step1.3,multiple column and multiple tag check in function") + cmd1 = '''select * from in_stable_1 + where in_bool in (true,false) and in_tinyint in (0,127,-127) + and tin_bool in (true,false) and tin_tinyint in (0,127,-127) + order by ts desc ;''' + tdLog.info(cmd1) + tdSql.query(cmd1) + tdSql.checkData(0,1,'True') + tdSql.checkData(0,2,'0') + tdSql.checkData(0,3,'False') + tdSql.checkData(0,4,'0') + tdSql.checkData(1,1,'False') + tdSql.checkData(1,2,'127') + tdSql.checkData(1,3,'False') + tdSql.checkData(1,4,'-127') + tdSql.checkData(2,1,'True') + tdSql.checkData(2,2,'-127') + tdSql.checkData(2,3,'True') + tdSql.checkData(2,4,'127') + + + tdLog.info("=============== step1.4,drop normal table && create table") + cmd1 = 'drop table if exists normal_in_bool_tinyint_1 ;' + cmd2 = 'create table normal_in_bool_tinyint_1 (ts timestamp,in_bool bool,in_tinyint tinyint) ; ' + tdLog.info(cmd1) + tdSql.execute(cmd1) + tdLog.info(cmd2) + tdSql.execute(cmd2) + + + tdLog.info("=============== step1.5,insert normal table right data and check in function") + cmd1 = 'insert into normal_in_bool_tinyint_1 values(now,\'true\',\'-127\') ;' + tdLog.info(cmd1) + tdSql.execute(cmd1) + tdSql.query('select * from normal_in_bool_tinyint_1 where in_bool in (true) order by ts desc') + tdSql.checkData(0,1,'True') + tdSql.checkData(0,2,'-127') + tdSql.query('select * from normal_in_bool_tinyint_1 where in_tinyint in (-127) order by ts desc') + tdSql.checkData(0,1,'True') + tdSql.checkData(0,2,'-127') + + cmd2 = 'insert into normal_in_bool_tinyint_1 values(now,\'false\',\'127\') ;' + tdLog.info(cmd2) + tdSql.execute(cmd2) + tdSql.query('select * from normal_in_bool_tinyint_1 where in_bool in (false) order by ts desc') + tdSql.checkData(0,1,'False') + tdSql.checkData(0,2,'127') + tdSql.query('select * from normal_in_bool_tinyint_1 where in_tinyint in (127) order by ts desc') + tdSql.checkData(0,1,'False') + tdSql.checkData(0,2,'127') + + cmd3 = 'insert into normal_in_bool_tinyint_1 values(now,\'true\',\'0\') ;' + tdLog.info(cmd3) + tdSql.execute(cmd3) + tdSql.query('select * from normal_in_bool_tinyint_1 where in_tinyint in (0) order by ts desc') + tdSql.checkData(0,1,'True') + tdSql.checkData(0,2,'0') + + cmd4 = '''select * from normal_in_bool_tinyint_1 + where in_bool in (true,false) and in_tinyint in (0,127,-127) + order by ts desc ;''' + tdLog.info(cmd4) + tdSql.query(cmd4) + tdSql.checkData(0,1,'True') + tdSql.checkData(0,2,'0') + tdSql.checkData(1,1,'False') + tdSql.checkData(1,2,'127') + tdSql.checkData(2,1,'True') + tdSql.checkData(2,2,'-127') + + + tdLog.info("=============== step2,check int、smallint and bigint data type") + + tdLog.info("=============== step2.1,drop table && create table") + cmd1 = 'drop table if exists in_int_smallint_bigint_1 ;' + cmd2 = 'drop table if exists in_int_smallint_bigint_2 ;' + cmd3 = 'drop table if exists in_int_smallint_bigint_3 ;' + cmd10 = 'drop table if exists in_stable_2 ;' + cmd11 = 'create stable in_stable_2(ts timestamp,in_int int,in_small smallint , in_big bigint) tags (tin_int int,tin_small smallint , tin_big bigint) ;' + cmd12 = 'create table in_int_smallint_bigint_1 using in_stable_2 tags(\'2147483647\',\'-32767\',\'0\') ; ' + cmd13 = 'create table in_int_smallint_bigint_2 using in_stable_2 tags(\'-2147483647\',\'0\',\'9223372036854775807\') ; ' + cmd14 = 'create table in_int_smallint_bigint_3 using in_stable_2 tags(\'0\',\'32767\',\'-9223372036854775807\') ; ' + tdLog.info(cmd1) + tdSql.execute(cmd1) + tdLog.info(cmd2) + tdSql.execute(cmd2) + tdLog.info(cmd3) + tdSql.execute(cmd3) + tdLog.info(cmd10) + tdSql.execute(cmd10) + tdLog.info(cmd11) + tdSql.execute(cmd11) + tdLog.info(cmd12) + tdSql.execute(cmd12) + tdLog.info(cmd13) + tdSql.execute(cmd13) + tdLog.info(cmd14) + tdSql.execute(cmd14) + + tdLog.info("=============== step2.2,insert stable right data and check in function") + cmd1 = 'insert into in_int_smallint_bigint_1 values(now,\'2147483647\',\'-32767\',\'0\') ;' + tdLog.info(cmd1) + tdSql.execute(cmd1) + tdSql.query('select * from in_stable_2 where in_int in (2147483647) order by ts desc') + tdSql.checkData(0,1,'2147483647') + tdSql.checkData(0,2,'-32767') + tdSql.checkData(0,3,'0') + tdSql.checkData(0,4,'2147483647') + tdSql.checkData(0,5,'-32767') + tdSql.checkData(0,6,'0') + tdSql.query('select * from in_stable_2 where in_small in (-32767) order by ts desc') + tdSql.checkData(0,1,'2147483647') + tdSql.checkData(0,2,'-32767') + tdSql.checkData(0,3,'0') + tdSql.checkData(0,4,'2147483647') + tdSql.checkData(0,5,'-32767') + tdSql.checkData(0,6,'0') + tdSql.query('select * from in_stable_2 where in_big in (0) order by ts desc') + tdSql.checkData(0,1,'2147483647') + tdSql.checkData(0,2,'-32767') + tdSql.checkData(0,3,'0') + tdSql.checkData(0,4,'2147483647') + tdSql.checkData(0,5,'-32767') + tdSql.checkData(0,6,'0') + tdSql.query('select * from in_stable_2 where tin_int in (2147483647) order by ts desc') + tdSql.checkData(0,1,'2147483647') + tdSql.checkData(0,2,'-32767') + tdSql.checkData(0,3,'0') + tdSql.checkData(0,4,'2147483647') + tdSql.checkData(0,5,'-32767') + tdSql.checkData(0,6,'0') + tdSql.query('select * from in_stable_2 where tin_small in (-32767) order by ts desc') + tdSql.checkData(0,1,'2147483647') + tdSql.checkData(0,2,'-32767') + tdSql.checkData(0,3,'0') + tdSql.checkData(0,4,'2147483647') + tdSql.checkData(0,5,'-32767') + tdSql.checkData(0,6,'0') + tdSql.query('select * from in_stable_2 where tin_big in (0) order by ts desc') + tdSql.checkData(0,1,'2147483647') + tdSql.checkData(0,2,'-32767') + tdSql.checkData(0,3,'0') + tdSql.checkData(0,4,'2147483647') + tdSql.checkData(0,5,'-32767') + tdSql.checkData(0,6,'0') + tdSql.query('select * from in_int_smallint_bigint_1 where in_int in (2147483647) order by ts desc') + tdSql.checkData(0,1,'2147483647') + tdSql.checkData(0,2,'-32767') + tdSql.checkData(0,3,'0') + tdSql.query('select * from in_int_smallint_bigint_1 where in_small in (-32767) order by ts desc') + tdSql.checkData(0,1,'2147483647') + tdSql.checkData(0,2,'-32767') + tdSql.checkData(0,3,'0') + tdSql.query('select * from in_int_smallint_bigint_1 where in_big in (0) order by ts desc') + tdSql.checkData(0,1,'2147483647') + tdSql.checkData(0,2,'-32767') + tdSql.checkData(0,3,'0') + + cmd2 = 'insert into in_int_smallint_bigint_2 values(now,\'-2147483647\',\'0\',\'9223372036854775807\') ;' + tdLog.info(cmd2) + tdSql.execute(cmd2) + tdSql.query('select * from in_stable_2 where in_int in (-2147483647) order by ts desc') + tdSql.checkData(0,1,'-2147483647') + tdSql.checkData(0,2,'0') + tdSql.checkData(0,3,'9223372036854775807') + tdSql.checkData(0,4,'-2147483647') + tdSql.checkData(0,5,'0') + tdSql.checkData(0,6,'9223372036854775807') + tdSql.query('select * from in_stable_2 where in_small in (0) order by ts desc') + tdSql.checkData(0,1,'-2147483647') + tdSql.checkData(0,2,'0') + tdSql.checkData(0,3,'9223372036854775807') + tdSql.checkData(0,4,'-2147483647') + tdSql.checkData(0,5,'0') + tdSql.checkData(0,6,'9223372036854775807') + tdSql.query('select * from in_stable_2 where in_big in (9223372036854775807) order by ts desc') + tdSql.checkData(0,1,'-2147483647') + tdSql.checkData(0,2,'0') + tdSql.checkData(0,3,'9223372036854775807') + tdSql.checkData(0,4,'-2147483647') + tdSql.checkData(0,5,'0') + tdSql.checkData(0,6,'9223372036854775807') + tdSql.query('select * from in_stable_2 where tin_int in (-2147483647) order by ts desc') + tdSql.checkData(0,1,'-2147483647') + tdSql.checkData(0,2,'0') + tdSql.checkData(0,3,'9223372036854775807') + tdSql.checkData(0,4,'-2147483647') + tdSql.checkData(0,5,'0') + tdSql.checkData(0,6,'9223372036854775807') + tdSql.query('select * from in_stable_2 where tin_small in (0) order by ts desc') + tdSql.checkData(0,1,'-2147483647') + tdSql.checkData(0,2,'0') + tdSql.checkData(0,3,'9223372036854775807') + tdSql.checkData(0,4,'-2147483647') + tdSql.checkData(0,5,'0') + tdSql.checkData(0,6,'9223372036854775807') + tdSql.query('select * from in_stable_2 where tin_big in (9223372036854775807) order by ts desc') + tdSql.checkData(0,1,'-2147483647') + tdSql.checkData(0,2,'0') + tdSql.checkData(0,3,'9223372036854775807') + tdSql.checkData(0,4,'-2147483647') + tdSql.checkData(0,5,'0') + tdSql.checkData(0,6,'9223372036854775807') + tdSql.query('select * from in_int_smallint_bigint_2 where in_int in (-2147483647) order by ts desc') + tdSql.checkData(0,1,'-2147483647') + tdSql.checkData(0,2,'0') + tdSql.checkData(0,3,'9223372036854775807') + tdSql.query('select * from in_int_smallint_bigint_2 where in_small in (0) order by ts desc') + tdSql.checkData(0,1,'-2147483647') + tdSql.checkData(0,2,'0') + tdSql.checkData(0,3,'9223372036854775807') + tdSql.query('select * from in_int_smallint_bigint_2 where in_big in (9223372036854775807) order by ts desc') + tdSql.checkData(0,1,'-2147483647') + tdSql.checkData(0,2,'0') + tdSql.checkData(0,3,'9223372036854775807') + + cmd3 = 'insert into in_int_smallint_bigint_3 values(now,\'0\',\'32767\',\'-9223372036854775807\') ;' + tdLog.info(cmd3) + tdSql.execute(cmd3) + tdSql.query('select * from in_stable_2 where in_int in (0) order by ts desc') + tdSql.checkData(0,1,'0') + tdSql.checkData(0,2,'32767') + tdSql.checkData(0,3,'-9223372036854775807') + tdSql.checkData(0,4,'0') + tdSql.checkData(0,5,'32767') + tdSql.checkData(0,6,'-9223372036854775807') + tdSql.query('select * from in_stable_2 where in_small in (32767) order by ts desc') + tdSql.checkData(0,1,'0') + tdSql.checkData(0,2,'32767') + tdSql.checkData(0,3,'-9223372036854775807') + tdSql.checkData(0,4,'0') + tdSql.checkData(0,5,'32767') + tdSql.checkData(0,6,'-9223372036854775807') + tdSql.query('select * from in_stable_2 where in_big in (-9223372036854775807) order by ts desc') + tdSql.checkData(0,1,'0') + tdSql.checkData(0,2,'32767') + tdSql.checkData(0,3,'-9223372036854775807') + tdSql.checkData(0,4,'0') + tdSql.checkData(0,5,'32767') + tdSql.checkData(0,6,'-9223372036854775807') + tdSql.query('select * from in_stable_2 where tin_int in (0) order by ts desc') + tdSql.checkData(0,1,'0') + tdSql.checkData(0,2,'32767') + tdSql.checkData(0,3,'-9223372036854775807') + tdSql.checkData(0,4,'0') + tdSql.checkData(0,5,'32767') + tdSql.checkData(0,6,'-9223372036854775807') + tdSql.query('select * from in_stable_2 where tin_small in (32767) order by ts desc') + tdSql.checkData(0,1,'0') + tdSql.checkData(0,2,'32767') + tdSql.checkData(0,3,'-9223372036854775807') + tdSql.checkData(0,4,'0') + tdSql.checkData(0,5,'32767') + tdSql.checkData(0,6,'-9223372036854775807') + tdSql.query('select * from in_stable_2 where tin_big in (-9223372036854775807) order by ts desc') + tdSql.checkData(0,1,'0') + tdSql.checkData(0,2,'32767') + tdSql.checkData(0,3,'-9223372036854775807') + tdSql.checkData(0,4,'0') + tdSql.checkData(0,5,'32767') + tdSql.checkData(0,6,'-9223372036854775807') + tdSql.query('select * from in_int_smallint_bigint_3 where in_int in (0) order by ts desc') + tdSql.checkData(0,1,'0') + tdSql.checkData(0,2,'32767') + tdSql.checkData(0,3,'-9223372036854775807') + tdSql.query('select * from in_int_smallint_bigint_3 where in_small in (32767) order by ts desc') + tdSql.checkData(0,1,'0') + tdSql.checkData(0,2,'32767') + tdSql.checkData(0,3,'-9223372036854775807') + tdSql.query('select * from in_int_smallint_bigint_3 where in_big in (-9223372036854775807) order by ts desc') + tdSql.checkData(0,1,'0') + tdSql.checkData(0,2,'32767') + tdSql.checkData(0,3,'-9223372036854775807') + + + tdLog.info("=============== step2.3,multiple column and multiple tag check in function") + cmd1 = '''select * from in_stable_2 + where in_int in (0,2147483647,-2147483647) and in_small in (0,32767,-32767) + and in_big in (0,9223372036854775807,-9223372036854775807) + and tin_int in (0,2147483647,-2147483647) and tin_small in (0,32767,-32767) + and tin_big in (0,9223372036854775807,-9223372036854775807) + order by ts desc ;''' + tdLog.info(cmd1) + tdSql.query(cmd1) + tdSql.checkData(0,1,'0') + tdSql.checkData(0,2,'32767') + tdSql.checkData(0,3,'-9223372036854775807') + tdSql.checkData(0,4,'0') + tdSql.checkData(0,5,'32767') + tdSql.checkData(0,6,'-9223372036854775807') + tdSql.checkData(1,1,'-2147483647') + tdSql.checkData(1,2,'0') + tdSql.checkData(1,3,'9223372036854775807') + tdSql.checkData(1,4,'-2147483647') + tdSql.checkData(1,5,'0') + tdSql.checkData(1,6,'9223372036854775807') + tdSql.checkData(2,1,'2147483647') + tdSql.checkData(2,2,'-32767') + tdSql.checkData(2,3,'0') + tdSql.checkData(2,4,'2147483647') + tdSql.checkData(2,5,'-32767') + tdSql.checkData(2,6,'0') + + + tdLog.info("=============== step2.4,drop normal table && create table") + cmd1 = 'drop table if exists normal_int_smallint_bigint_1 ;' + cmd2 = 'create table normal_int_smallint_bigint_1 (ts timestamp,in_int int,in_small smallint , in_big bigint) ; ' + tdLog.info(cmd1) + tdSql.execute(cmd1) + tdLog.info(cmd2) + tdSql.execute(cmd2) + + + tdLog.info("=============== step2.5,insert normal table right data and check in function") + cmd1 = 'insert into normal_int_smallint_bigint_1 values(now,\'2147483647\',\'-32767\',\'0\') ;' + tdLog.info(cmd1) + tdSql.execute(cmd1) + tdSql.query('select * from normal_int_smallint_bigint_1 where in_int in (2147483647) order by ts desc') + tdSql.checkData(0,1,'2147483647') + tdSql.checkData(0,2,'-32767') + tdSql.checkData(0,3,'0') + tdSql.query('select * from normal_int_smallint_bigint_1 where in_small in (-32767) order by ts desc') + tdSql.checkData(0,1,'2147483647') + tdSql.checkData(0,2,'-32767') + tdSql.checkData(0,3,'0') + tdSql.query('select * from normal_int_smallint_bigint_1 where in_big in (0) order by ts desc') + tdSql.checkData(0,1,'2147483647') + tdSql.checkData(0,2,'-32767') + tdSql.checkData(0,3,'0') + + cmd2 = 'insert into normal_int_smallint_bigint_1 values(now,\'-2147483647\',\'0\',\'9223372036854775807\') ;' + tdLog.info(cmd2) + tdSql.execute(cmd2) + tdSql.query('select * from normal_int_smallint_bigint_1 where in_int in (-2147483647) order by ts desc') + tdSql.checkData(0,1,'-2147483647') + tdSql.checkData(0,2,'0') + tdSql.checkData(0,3,'9223372036854775807') + tdSql.query('select * from normal_int_smallint_bigint_1 where in_small in (0) order by ts desc') + tdSql.checkData(0,1,'-2147483647') + tdSql.checkData(0,2,'0') + tdSql.checkData(0,3,'9223372036854775807') + tdSql.query('select * from normal_int_smallint_bigint_1 where in_big in (9223372036854775807) order by ts desc') + tdSql.checkData(0,1,'-2147483647') + tdSql.checkData(0,2,'0') + tdSql.checkData(0,3,'9223372036854775807') + + cmd3 = 'insert into normal_int_smallint_bigint_1 values(now,\'0\',\'32767\',\'-9223372036854775807\') ;' + tdLog.info(cmd3) + tdSql.execute(cmd3) + tdSql.query('select * from normal_int_smallint_bigint_1 where in_int in (0) order by ts desc') + tdSql.checkData(0,1,'0') + tdSql.checkData(0,2,'32767') + tdSql.checkData(0,3,'-9223372036854775807') + tdSql.query('select * from normal_int_smallint_bigint_1 where in_small in (32767) order by ts desc') + tdSql.checkData(0,1,'0') + tdSql.checkData(0,2,'32767') + tdSql.checkData(0,3,'-9223372036854775807') + tdSql.query('select * from normal_int_smallint_bigint_1 where in_big in (-9223372036854775807) order by ts desc') + tdSql.checkData(0,1,'0') + tdSql.checkData(0,2,'32767') + tdSql.checkData(0,3,'-9223372036854775807') + + cmd4 = '''select * from normal_int_smallint_bigint_1 + where in_int in (0,2147483647,-2147483647) and in_small in (0,32767,-32767) + and in_big in (0,9223372036854775807,-9223372036854775807) + order by ts desc ;''' + tdLog.info(cmd4) + tdSql.query(cmd4) + tdSql.checkData(0,1,'0') + tdSql.checkData(0,2,'32767') + tdSql.checkData(0,3,'-9223372036854775807') + tdSql.checkData(1,1,'-2147483647') + tdSql.checkData(1,2,'0') + tdSql.checkData(1,3,'9223372036854775807') + tdSql.checkData(2,1,'2147483647') + tdSql.checkData(2,2,'-32767') + tdSql.checkData(2,3,'0') + + + tdLog.info("=============== step3,check binary and nchar data type") + + tdLog.info("=============== step3.1,drop table && create table") + cmd1 = 'drop table if exists in_binary_nchar_1 ;' + cmd2 = 'drop table if exists in_binary_nchar_2 ;' + cmd3 = 'drop table if exists in_binary_nchar_3 ;' + cmd10 = 'drop table if exists in_stable_3 ;' + cmd11 = 'create stable in_stable_3(ts timestamp,in_binary binary(8),in_nchar nchar(12)) tags (tin_binary binary(16),tin_nchar nchar(20)) ;' + cmd12 = 'create table in_binary_nchar_1 using in_stable_3 tags(\'0\',\'0\') ; ' + cmd13 = 'create table in_binary_nchar_2 using in_stable_3 tags(\'TDengine\',\'北京涛思数据科技有限公司\') ; ' + cmd14 = 'create table in_binary_nchar_3 using in_stable_3 tags(\'taosdataTDengine\',\'北京涛思数据科技有限公司TDengine\') ; ' + tdLog.info(cmd1) + tdSql.execute(cmd1) + tdLog.info(cmd2) + tdSql.execute(cmd2) + tdLog.info(cmd3) + tdSql.execute(cmd3) + tdLog.info(cmd10) + tdSql.execute(cmd10) + tdLog.info(cmd11) + tdSql.execute(cmd11) + tdLog.info(cmd12) + tdSql.execute(cmd12) + tdLog.info(cmd13) + tdSql.execute(cmd13) + tdLog.info(cmd14) + tdSql.execute(cmd14) + + tdLog.info("=============== step3.2,insert stable right data and check in function") + cmd1 = 'insert into in_binary_nchar_1 values(now,\'0\',\'0\') ;' + tdLog.info(cmd1) + tdSql.execute(cmd1) + tdSql.query('select * from in_stable_3 where in_binary in (\'0\') order by ts desc') + tdSql.checkData(0,1,'0') + tdSql.checkData(0,2,'0') + tdSql.checkData(0,3,'0') + tdSql.checkData(0,4,'0') + tdSql.query('select * from in_stable_3 where in_nchar in (\'0\') order by ts desc') + tdSql.checkData(0,1,'0') + tdSql.checkData(0,2,'0') + tdSql.checkData(0,3,'0') + tdSql.checkData(0,4,'0') + tdSql.query('select * from in_stable_3 where tin_binary in (\'0\') order by ts desc') + tdSql.checkData(0,1,'0') + tdSql.checkData(0,2,'0') + tdSql.checkData(0,3,'0') + tdSql.checkData(0,4,'0') + tdSql.query('select * from in_stable_3 where tin_nchar in (\'0\') order by ts desc') + tdSql.checkData(0,1,'0') + tdSql.checkData(0,2,'0') + tdSql.checkData(0,3,'0') + tdSql.checkData(0,4,'0') + tdSql.query('select * from in_binary_nchar_1 where in_binary in (\'0\') order by ts desc') + tdSql.checkData(0,1,'0') + tdSql.checkData(0,2,'0') + tdSql.query('select * from in_binary_nchar_1 where in_nchar in (\'0\') order by ts desc') + tdSql.checkData(0,1,'0') + tdSql.checkData(0,2,'0') + + cmd2 = 'insert into in_binary_nchar_2 values(now,\'TAOS\',\'涛思数据TAOSdata\') ;' + tdLog.info(cmd2) + tdSql.execute(cmd2) + tdSql.query('select * from in_stable_3 where in_binary in (\'TAOS\') order by ts desc') + tdSql.checkData(0,1,'TAOS') + tdSql.checkData(0,2,'涛思数据TAOSdata') + tdSql.checkData(0,3,'TDengine') + tdSql.checkData(0,4,'北京涛思数据科技有限公司') + tdSql.query('select * from in_stable_3 where in_nchar in (\'涛思数据TAOSdata\') order by ts desc') + tdSql.checkData(0,1,'TAOS') + tdSql.checkData(0,2,'涛思数据TAOSdata') + tdSql.checkData(0,3,'TDengine') + tdSql.checkData(0,4,'北京涛思数据科技有限公司') + tdSql.query('select * from in_stable_3 where tin_binary in (\'TDengine\') order by ts desc') + tdSql.checkData(0,1,'TAOS') + tdSql.checkData(0,2,'涛思数据TAOSdata') + tdSql.checkData(0,3,'TDengine') + tdSql.checkData(0,4,'北京涛思数据科技有限公司') + tdSql.query('select * from in_stable_3 where tin_nchar in (\'北京涛思数据科技有限公司\') order by ts desc') + tdSql.checkData(0,1,'TAOS') + tdSql.checkData(0,2,'涛思数据TAOSdata') + tdSql.checkData(0,3,'TDengine') + tdSql.checkData(0,4,'北京涛思数据科技有限公司') + tdSql.query('select * from in_binary_nchar_2 where in_binary in (\'TAOS\') order by ts desc') + tdSql.checkData(0,1,'TAOS') + tdSql.checkData(0,2,'涛思数据TAOSdata') + tdSql.query('select * from in_binary_nchar_2 where in_nchar in (\'涛思数据TAOSdata\') order by ts desc') + tdSql.checkData(0,1,'TAOS') + tdSql.checkData(0,2,'涛思数据TAOSdata') + + cmd3 = 'insert into in_binary_nchar_3 values(now,\'TDengine\',\'北京涛思数据科技有限公司\') ;' + tdLog.info(cmd3) + tdSql.execute(cmd3) + tdSql.query('select * from in_stable_3 where in_binary in (\'TDengine\') order by ts desc') + tdSql.checkData(0,1,'TDengine') + tdSql.checkData(0,2,'北京涛思数据科技有限公司') + tdSql.checkData(0,3,'taosdataTDengine') + tdSql.checkData(0,4,'北京涛思数据科技有限公司TDengine') + tdSql.query('select * from in_stable_3 where in_nchar in (\'北京涛思数据科技有限公司\') order by ts desc') + tdSql.checkData(0,1,'TDengine') + tdSql.checkData(0,2,'北京涛思数据科技有限公司') + tdSql.checkData(0,3,'taosdataTDengine') + tdSql.checkData(0,4,'北京涛思数据科技有限公司TDengine') + tdSql.query('select * from in_stable_3 where tin_binary in (\'taosdataTDengine\') order by ts desc') + tdSql.checkData(0,1,'TDengine') + tdSql.checkData(0,2,'北京涛思数据科技有限公司') + tdSql.checkData(0,3,'taosdataTDengine') + tdSql.checkData(0,4,'北京涛思数据科技有限公司TDengine') + tdSql.query('select * from in_stable_3 where tin_nchar in (\'北京涛思数据科技有限公司TDengine\') order by ts desc') + tdSql.checkData(0,1,'TDengine') + tdSql.checkData(0,2,'北京涛思数据科技有限公司') + tdSql.checkData(0,3,'taosdataTDengine') + tdSql.checkData(0,4,'北京涛思数据科技有限公司TDengine') + tdSql.query('select * from in_binary_nchar_3 where in_binary in (\'TDengine\') order by ts desc') + tdSql.checkData(0,1,'TDengine') + tdSql.checkData(0,2,'北京涛思数据科技有限公司') + tdSql.query('select * from in_binary_nchar_3 where in_nchar in (\'北京涛思数据科技有限公司\') order by ts desc') + tdSql.checkData(0,1,'TDengine') + tdSql.checkData(0,2,'北京涛思数据科技有限公司') + + + tdLog.info("=============== step3.3,multiple column and multiple tag check in function") + cmd1 = '''select * from in_stable_3 + where in_binary in (\'0\',\'TDengine\',\'TAOS\') + and in_nchar in (\'0\',\'北京涛思数据科技有限公司\',\'涛思数据TAOSdata\') + and tin_binary in (\'0\',\'TDengine\',\'taosdataTDengine\') + and tin_nchar in (\'0\',\'北京涛思数据科技有限公司\',\'北京涛思数据科技有限公司TDengine\') + order by ts desc ;''' + tdLog.info(cmd1) + tdSql.query(cmd1) + tdSql.checkData(0,1,'TDengine') + tdSql.checkData(0,2,'北京涛思数据科技有限公司') + tdSql.checkData(0,3,'taosdataTDengine') + tdSql.checkData(0,4,'北京涛思数据科技有限公司TDengine') + tdSql.checkData(1,1,'TAOS') + tdSql.checkData(1,2,'涛思数据TAOSdata') + tdSql.checkData(1,3,'TDengine') + tdSql.checkData(1,4,'北京涛思数据科技有限公司') + tdSql.checkData(2,1,'0') + tdSql.checkData(2,2,'0') + tdSql.checkData(2,3,'0') + tdSql.checkData(2,4,'0') + + + tdLog.info("=============== step3.4,drop normal table && create table") + cmd1 = 'drop table if exists normal_in_binary_nchar_1 ;' + cmd2 = 'create table normal_in_binary_nchar_1 (ts timestamp,in_binary binary(8),in_nchar nchar(12)) ; ' + tdLog.info(cmd1) + tdSql.execute(cmd1) + tdLog.info(cmd2) + tdSql.execute(cmd2) + + + tdLog.info("=============== step3.5,insert normal table right data and check in function") + cmd1 = 'insert into normal_in_binary_nchar_1 values(now,\'0\',\'0\') ;' + tdLog.info(cmd1) + tdSql.execute(cmd1) + tdSql.query('select * from normal_in_binary_nchar_1 where in_binary in (\'0\') order by ts desc') + tdSql.checkData(0,1,'0') + tdSql.checkData(0,2,'0') + tdSql.query('select * from normal_in_binary_nchar_1 where in_nchar in (\'0\') order by ts desc') + tdSql.checkData(0,1,'0') + tdSql.checkData(0,2,'0') + + cmd2 = 'insert into normal_in_binary_nchar_1 values(now,\'TAOS\',\'涛思数据TAOSdata\') ;' + tdLog.info(cmd2) + tdSql.execute(cmd2) + tdSql.query('select * from normal_in_binary_nchar_1 where in_binary in (\'TAOS\') order by ts desc') + tdSql.checkData(0,1,'TAOS') + tdSql.checkData(0,2,'涛思数据TAOSdata') + tdSql.query('select * from normal_in_binary_nchar_1 where in_nchar in (\'涛思数据TAOSdata\') order by ts desc') + tdSql.checkData(0,1,'TAOS') + tdSql.checkData(0,2,'涛思数据TAOSdata') + + cmd3 = 'insert into normal_in_binary_nchar_1 values(now,\'TDengine\',\'北京涛思数据科技有限公司\') ;' + tdLog.info(cmd3) + tdSql.execute(cmd3) + tdSql.query('select * from normal_in_binary_nchar_1 where in_binary in (\'TDengine\') order by ts desc') + tdSql.checkData(0,1,'TDengine') + tdSql.checkData(0,2,'北京涛思数据科技有限公司') + tdSql.query('select * from normal_in_binary_nchar_1 where in_nchar in (\'北京涛思数据科技有限公司\') order by ts desc') + tdSql.checkData(0,1,'TDengine') + tdSql.checkData(0,2,'北京涛思数据科技有限公司') + + cmd4 = '''select * from normal_in_binary_nchar_1 + where in_binary in (\'0\',\'TDengine\',\'TAOS\') + and in_nchar in (\'0\',\'北京涛思数据科技有限公司\',\'涛思数据TAOSdata\') + order by ts desc ;''' + tdLog.info(cmd4) + tdSql.query(cmd4) + tdSql.checkData(0,1,'TDengine') + tdSql.checkData(0,2,'北京涛思数据科技有限公司') + tdSql.checkData(1,1,'TAOS') + tdSql.checkData(1,2,'涛思数据TAOSdata') + tdSql.checkData(2,1,'0') + tdSql.checkData(2,2,'0') + + + tdLog.info("=============== step4,check float and double data type") + + tdLog.info("=============== step4.1,drop table && create table") + cmd1 = 'drop table if exists in_ts_float_double_1 ;' + cmd2 = 'drop table if exists in_ts_float_double_2 ;' + cmd3 = 'drop table if exists in_ts_float_double_3 ;' + cmd10 = 'drop table if exists in_stable_4 ;' + cmd11 = 'create stable in_stable_4(ts timestamp,in_ts timestamp,in_float float,in_double double) tags (tin_ts timestamp,tin_float float,tin_double double) ;' + cmd12 = 'create table in_ts_float_double_1 using in_stable_4 tags(\'0\',\'0\',\'0\') ; ' + cmd13 = 'create table in_ts_float_double_2 using in_stable_4 tags(\'2020-01-01 08:00:00.001\',\'666\',\'-88888\') ; ' + cmd14 = 'create table in_ts_float_double_3 using in_stable_4 tags(\'2021-01-01 08:00:00.001\',\'-888.00000\',\'66666.000000000\') ; ' + tdLog.info(cmd1) + tdSql.execute(cmd1) + tdLog.info(cmd2) + tdSql.execute(cmd2) + tdLog.info(cmd3) + tdSql.execute(cmd3) + tdLog.info(cmd10) + tdSql.execute(cmd10) + tdLog.info(cmd11) + tdSql.execute(cmd11) + tdLog.info(cmd12) + tdSql.execute(cmd12) + tdLog.info(cmd13) + tdSql.execute(cmd13) + tdLog.info(cmd14) + tdSql.execute(cmd14) + + tdLog.info("=============== step4.2,insert stable right data and check in function") + cmd1 = 'insert into in_ts_float_double_1 values(now,\'0\',\'0\',\'0\') ;' + tdLog.info(cmd1) + tdSql.execute(cmd1) + + tdSql.query('select * from in_stable_4 where in_ts in (\'0\') order by ts desc') + tdSql.checkData(0,1,'1970-01-01 08:00:00.000') + tdSql.checkData(0,2,0.00000) + tdSql.checkData(0,3,0.000000000) + tdSql.checkData(0,4,'1970-01-01 08:00:00.000') + tdSql.checkData(0,5,0.00000) + tdSql.checkData(0,6,0.000000000) + tdSql.query('select * from in_stable_4 where in_ts in (\'1970-01-01 08:00:00.000\') order by ts desc') + tdSql.checkData(0,1,'1970-01-01 08:00:00.000') + tdSql.checkData(0,2,0.00000) + tdSql.checkData(0,3,0.000000000) + tdSql.checkData(0,4,'1970-01-01 08:00:00.000') + tdSql.checkData(0,5,0.00000) + tdSql.checkData(0,6,0.000000000) + tdSql.query('select * from in_stable_4 where in_float in (0.00000) order by ts desc') + tdSql.checkData(0,1,'1970-01-01 08:00:00.000') + tdSql.checkData(0,2,0.00000) + tdSql.checkData(0,3,0.000000000) + tdSql.checkData(0,4,'1970-01-01 08:00:00.000') + tdSql.checkData(0,5,0.00000) + tdSql.checkData(0,6,0.000000000) + tdSql.query('select * from in_stable_4 where in_double in (0.000000000) order by ts desc') + tdSql.checkData(0,1,'1970-01-01 08:00:00.000') + tdSql.checkData(0,2,0.00000) + tdSql.checkData(0,3,0.000000000) + tdSql.checkData(0,4,'1970-01-01 08:00:00.000') + tdSql.checkData(0,5,0.00000) + tdSql.checkData(0,6,0.000000000) + + tdSql.query('select * from in_stable_4 where tin_ts in (\'0\') order by ts desc') + tdSql.checkData(0,1,'1970-01-01 08:00:00.000') + tdSql.checkData(0,2,0.00000) + tdSql.checkData(0,3,0.000000000) + tdSql.checkData(0,4,'1970-01-01 08:00:00.000') + tdSql.checkData(0,5,0.00000) + tdSql.checkData(0,6,0.000000000) + tdSql.query('select * from in_stable_4 where tin_ts in (\'1970-01-01 08:00:00.000\') order by ts desc') + tdSql.checkData(0,1,'1970-01-01 08:00:00.000') + tdSql.checkData(0,2,0.00000) + tdSql.checkData(0,3,0.000000000) + tdSql.checkData(0,4,'1970-01-01 08:00:00.000') + tdSql.checkData(0,5,0.00000) + tdSql.checkData(0,6,0.000000000) + tdSql.query('select * from in_stable_4 where tin_float in (0.00000) order by ts desc') + tdSql.checkData(0,1,'1970-01-01 08:00:00.000') + tdSql.checkData(0,2,0.00000) + tdSql.checkData(0,3,0.000000000) + tdSql.checkData(0,4,'1970-01-01 08:00:00.000') + tdSql.checkData(0,5,0.00000) + tdSql.checkData(0,6,0.000000000) + tdSql.query('select * from in_stable_4 where tin_double in (0.000000000) order by ts desc') + tdSql.checkData(0,1,'1970-01-01 08:00:00.000') + tdSql.checkData(0,2,0.00000) + tdSql.checkData(0,3,0.000000000) + tdSql.checkData(0,4,'1970-01-01 08:00:00.000') + tdSql.checkData(0,5,0.00000) + tdSql.checkData(0,6,0.000000000) + + tdSql.query('select * from in_ts_float_double_1 where in_ts in (\'0\') order by ts desc') + tdSql.checkData(0,1,'1970-01-01 08:00:00.000') + tdSql.checkData(0,2,0.00000) + tdSql.checkData(0,3,0.000000000) + tdSql.query('select * from in_ts_float_double_1 where in_ts in (\'1970-01-01 08:00:00.000\') order by ts desc') + tdSql.checkData(0,1,'1970-01-01 08:00:00.000') + tdSql.checkData(0,2,0.00000) + tdSql.checkData(0,3,0.000000000) + tdSql.query('select * from in_ts_float_double_1 where in_float in (0.00000) order by ts desc') + tdSql.checkData(0,1,'1970-01-01 08:00:00.000') + tdSql.checkData(0,2,0.00000) + tdSql.checkData(0,3,0.000000000) + tdSql.query('select * from in_ts_float_double_1 where in_double in (0.000000000) order by ts desc') + tdSql.checkData(0,1,'1970-01-01 08:00:00.000') + tdSql.checkData(0,2,0.00000) + tdSql.checkData(0,3,0.000000000) + + cmd2 = 'insert into in_ts_float_double_2 values(now,\'2020-01-01 08:00:00.001\',\'666\',\'-88888\') ;' + tdLog.info(cmd2) + tdSql.execute(cmd2) + + tdSql.query('select * from in_stable_4 where in_ts in (\'2020-01-01 08:00:00.001\') order by ts desc') + tdSql.checkData(0,1,'2020-01-01 08:00:00.001000') + tdSql.checkData(0,2,666.00000) + tdSql.checkData(0,3,-88888.000000000) + tdSql.checkData(0,4,'2020-01-01 08:00:00.001') + tdSql.checkData(0,5,666.00000) + tdSql.checkData(0,6,-88888.000000000) + tdSql.query('select * from in_stable_4 where in_ts in (\'1577836800001\') order by ts desc') + tdSql.checkData(0,1,'2020-01-01 08:00:00.001000') + tdSql.checkData(0,2,666.00000) + tdSql.checkData(0,3,-88888.000000000) + tdSql.checkData(0,4,'2020-01-01 08:00:00.001') + tdSql.checkData(0,5,666.00000) + tdSql.checkData(0,6,-88888.000000000) + tdSql.query('select * from in_stable_4 where in_float in (666.00000) order by ts desc') + tdSql.checkData(0,1,'2020-01-01 08:00:00.001000') + tdSql.checkData(0,2,666.00000) + tdSql.checkData(0,3,-88888.000000000) + tdSql.checkData(0,4,'2020-01-01 08:00:00.001') + tdSql.checkData(0,5,666.00000) + tdSql.checkData(0,6,-88888.000000000) + tdSql.query('select * from in_stable_4 where in_double in (-88888.000000000) order by ts desc') + tdSql.checkData(0,1,'2020-01-01 08:00:00.001000') + tdSql.checkData(0,2,666.00000) + tdSql.checkData(0,3,-88888.000000000) + tdSql.checkData(0,4,'2020-01-01 08:00:00.001') + tdSql.checkData(0,5,666.00000) + tdSql.checkData(0,6,-88888.000000000) + + tdSql.query('select * from in_stable_4 where tin_ts in (\'2020-01-01 08:00:00.001000\') order by ts desc') + tdSql.checkData(0,1,'2020-01-01 08:00:00.001000') + tdSql.checkData(0,2,666.00000) + tdSql.checkData(0,3,-88888.000000000) + tdSql.checkData(0,4,'2020-01-01 08:00:00.001') + tdSql.checkData(0,5,666.00000) + tdSql.checkData(0,6,-88888.000000000) + tdSql.query('select * from in_stable_4 where tin_ts in (\'1577836800001\') order by ts desc') + tdSql.checkData(0,1,'2020-01-01 08:00:00.001000') + tdSql.checkData(0,2,666.00000) + tdSql.checkData(0,3,-88888.000000000) + tdSql.checkData(0,4,'2020-01-01 08:00:00.001') + tdSql.checkData(0,5,666.00000) + tdSql.checkData(0,6,-88888.000000000) + tdSql.query('select * from in_stable_4 where tin_float in (666.00000) order by ts desc') + tdSql.checkData(0,1,'2020-01-01 08:00:00.001000') + tdSql.checkData(0,2,666.00000) + tdSql.checkData(0,3,-88888.000000000) + tdSql.checkData(0,4,'2020-01-01 08:00:00.001') + tdSql.checkData(0,5,666.00000) + tdSql.checkData(0,6,-88888.000000000) + tdSql.query('select * from in_stable_4 where tin_double in (-88888.000000000) order by ts desc') + tdSql.checkData(0,1,'2020-01-01 08:00:00.001000') + tdSql.checkData(0,2,666.00000) + tdSql.checkData(0,3,-88888.000000000) + tdSql.checkData(0,4,'2020-01-01 08:00:00.001') + tdSql.checkData(0,5,666.00000) + tdSql.checkData(0,6,-88888.000000000) + + tdSql.query('select * from in_ts_float_double_2 where in_ts in (\'1577836800001\') order by ts desc') + tdSql.checkData(0,1,'2020-01-01 08:00:00.001') + tdSql.checkData(0,2,666.00000) + tdSql.checkData(0,3,-88888.000000000) + tdSql.query('select * from in_ts_float_double_2 where in_ts in (\'2020-01-01 08:00:00.001\') order by ts desc') + tdSql.checkData(0,1,'2020-01-01 08:00:00.001') + tdSql.checkData(0,2,666.00000) + tdSql.checkData(0,3,-88888.000000000) + tdSql.query('select * from in_ts_float_double_2 where in_float in (666.00000) order by ts desc') + tdSql.checkData(0,1,'2020-01-01 08:00:00.001') + tdSql.checkData(0,2,666.00000) + tdSql.checkData(0,3,-88888.000000000) + tdSql.query('select * from in_ts_float_double_2 where in_double in (-88888.000000000) order by ts desc') + tdSql.checkData(0,1,'2020-01-01 08:00:00.001') + tdSql.checkData(0,2,666.00000) + tdSql.checkData(0,3,-88888.000000000) + + cmd3 = 'insert into in_ts_float_double_3 values(now,\'2021-01-01 08:00:00.001\',\'-888.00000\',\'66666.000000000\') ;' + tdLog.info(cmd3) + tdSql.execute(cmd3) + + tdSql.query('select * from in_stable_4 where in_ts in (\'2021-01-01 08:00:00.001\') order by ts desc') + tdSql.checkData(0,1,'2021-01-01 08:00:00.001000') + tdSql.checkData(0,2,-888.00000) + tdSql.checkData(0,3,66666.000000000) + tdSql.checkData(0,4,'2021-01-01 08:00:00.001') + tdSql.checkData(0,5,-888.00000) + tdSql.checkData(0,6,66666.000000000) + tdSql.query('select * from in_stable_4 where in_ts in (\'1609459200001\') order by ts desc') + tdSql.checkData(0,1,'2021-01-01 08:00:00.001000') + tdSql.checkData(0,2,-888.00000) + tdSql.checkData(0,3,66666.000000000) + tdSql.checkData(0,4,'2021-01-01 08:00:00.001') + tdSql.checkData(0,5,-888.00000) + tdSql.checkData(0,6,66666.000000000) + tdSql.query('select * from in_stable_4 where in_float in (-888.00000) order by ts desc') + tdSql.checkData(0,1,'2021-01-01 08:00:00.001000') + tdSql.checkData(0,2,-888.00000) + tdSql.checkData(0,3,66666.000000000) + tdSql.checkData(0,4,'2021-01-01 08:00:00.001') + tdSql.checkData(0,5,-888.00000) + tdSql.checkData(0,6,66666.000000000) + tdSql.query('select * from in_stable_4 where in_double in (66666.000000000) order by ts desc') + tdSql.checkData(0,1,'2021-01-01 08:00:00.001000') + tdSql.checkData(0,2,-888.00000) + tdSql.checkData(0,3,66666.000000000) + tdSql.checkData(0,4,'2021-01-01 08:00:00.001') + tdSql.checkData(0,5,-888.00000) + tdSql.checkData(0,6,66666.000000000) + + tdSql.query('select * from in_stable_4 where tin_ts in (\'2021-01-01 08:00:00.001000\') order by ts desc') + tdSql.checkData(0,1,'2021-01-01 08:00:00.001000') + tdSql.checkData(0,2,-888.00000) + tdSql.checkData(0,3,66666.000000000) + tdSql.checkData(0,4,'2021-01-01 08:00:00.001') + tdSql.checkData(0,5,-888.00000) + tdSql.checkData(0,6,66666.000000000) + tdSql.query('select * from in_stable_4 where tin_ts in (\'1609459200001\') order by ts desc') + tdSql.checkData(0,1,'2021-01-01 08:00:00.001000') + tdSql.checkData(0,2,-888.00000) + tdSql.checkData(0,3,66666.000000000) + tdSql.checkData(0,4,'2021-01-01 08:00:00.001') + tdSql.checkData(0,5,-888.00000) + tdSql.checkData(0,6,66666.000000000) + tdSql.query('select * from in_stable_4 where tin_float in (-888.00000) order by ts desc') + tdSql.checkData(0,1,'2021-01-01 08:00:00.001000') + tdSql.checkData(0,2,-888.00000) + tdSql.checkData(0,3,66666.000000000) + tdSql.checkData(0,4,'2021-01-01 08:00:00.001') + tdSql.checkData(0,5,-888.00000) + tdSql.checkData(0,6,66666.000000000) + tdSql.query('select * from in_stable_4 where tin_double in (66666.000000000) order by ts desc') + tdSql.checkData(0,1,'2021-01-01 08:00:00.001000') + tdSql.checkData(0,2,-888.00000) + tdSql.checkData(0,3,66666.000000000) + tdSql.checkData(0,4,'2021-01-01 08:00:00.001') + tdSql.checkData(0,5,-888.00000) + tdSql.checkData(0,6,66666.000000000) + + tdSql.query('select * from in_ts_float_double_3 where in_ts in (\'1609459200001\') order by ts desc') + tdSql.checkData(0,1,'2021-01-01 08:00:00.001') + tdSql.checkData(0,2,-888.00000) + tdSql.checkData(0,3,66666.000000000) + tdSql.query('select * from in_ts_float_double_3 where in_ts in (\'2021-01-01 08:00:00.001\') order by ts desc') + tdSql.checkData(0,1,'2021-01-01 08:00:00.001') + tdSql.checkData(0,2,-888.00000) + tdSql.checkData(0,3,66666.000000000) + tdSql.query('select * from in_ts_float_double_3 where in_float in (-888.00000) order by ts desc') + tdSql.checkData(0,1,'2021-01-01 08:00:00.001') + tdSql.checkData(0,2,-888.00000) + tdSql.checkData(0,3,66666.000000000) + tdSql.query('select * from in_ts_float_double_3 where in_double in (66666.000000000) order by ts desc') + tdSql.checkData(0,1,'2021-01-01 08:00:00.001') + tdSql.checkData(0,2,-888.00000) + tdSql.checkData(0,3,66666.000000000) + + + tdLog.info("=============== step4.3,multiple column and multiple tag check in function") + cmd1 = '''select * from in_stable_4 + where in_ts in (\'1609459200001\',\'2021-01-01 08:00:00.001\',\'1577836800001\',\'2020-01-01 08:00:00.001000\',\'0\',\'1970-01-01 08:00:00.000\') + and in_float in (0.00000,666.00000,-888.00000) + and in_double in (0.000000000,66666.000000000,-88888.000000000) + and tin_ts in (\'1609459200001\',\'2021-01-01 08:00:00.001\',\'1577836800001\',\'2020-01-01 08:00:00.001000\',\'0\',\'1970-01-01 08:00:00.000\') + and tin_float in (0.00000,666.00000,-888.00000) + and tin_double in (0.000000000,66666.000000000,-88888.000000000) + order by ts desc ;''' + tdLog.info(cmd1) + tdSql.query(cmd1) + tdSql.checkData(0,1,'2021-01-01 08:00:00.001000') + tdSql.checkData(0,2,-888.00000) + tdSql.checkData(0,3,66666.000000000) + tdSql.checkData(0,4,'2021-01-01 08:00:00.001') + tdSql.checkData(0,5,-888.00000) + tdSql.checkData(0,6,66666.000000000) + tdSql.checkData(1,1,'2020-01-01 08:00:00.001000') + tdSql.checkData(1,2,666.00000) + tdSql.checkData(1,3,-88888.000000000) + tdSql.checkData(1,4,'2020-01-01 08:00:00.001') + tdSql.checkData(1,5,666.00000) + tdSql.checkData(1,6,-88888.000000000) + tdSql.checkData(2,1,'1970-01-01 08:00:00.000') + tdSql.checkData(2,2,0.00000) + tdSql.checkData(2,3,0.000000000) + tdSql.checkData(2,4,'1970-01-01 08:00:00.000') + tdSql.checkData(2,5,0.00000) + tdSql.checkData(2,6,0.000000000) + + + + + tdLog.info("=============== step4.4,drop normal table && create table") + cmd1 = 'drop table if exists normal_in_ts_float_double_1 ;' + cmd2 = 'create table normal_in_ts_float_double_1 (ts timestamp,in_ts timestamp,in_float float,in_double double) ; ' + tdLog.info(cmd1) + tdSql.execute(cmd1) + tdLog.info(cmd2) + tdSql.execute(cmd2) + + + tdLog.info("=============== step4.5,insert normal table right data and check in function") + cmd1 = 'insert into normal_in_ts_float_double_1 values(now,\'0\',\'0\',\'0\') ;' + tdLog.info(cmd1) + tdSql.execute(cmd1) + + tdSql.query('select * from normal_in_ts_float_double_1 where in_ts in (\'0\') order by ts desc') + tdSql.checkData(0,1,'1970-01-01 08:00:00.000') + tdSql.checkData(0,2,0.00000) + tdSql.checkData(0,3,0.000000000) + tdSql.query('select * from normal_in_ts_float_double_1 where in_ts in (\'1970-01-01 08:00:00.000\') order by ts desc') + tdSql.checkData(0,1,'1970-01-01 08:00:00.000') + tdSql.checkData(0,2,0.00000) + tdSql.checkData(0,3,0.000000000) + tdSql.query('select * from normal_in_ts_float_double_1 where in_float in (0.00000) order by ts desc') + tdSql.checkData(0,1,'1970-01-01 08:00:00.000') + tdSql.checkData(0,2,0.00000) + tdSql.checkData(0,3,0.000000000) + tdSql.query('select * from normal_in_ts_float_double_1 where in_double in (0.000000000) order by ts desc') + tdSql.checkData(0,1,'1970-01-01 08:00:00.000') + tdSql.checkData(0,2,0.00000) + tdSql.checkData(0,3,0.000000000) + + cmd2 = 'insert into normal_in_ts_float_double_1 values(now,\'2020-01-01 08:00:00.001\',\'666\',\'-88888\') ;' + tdLog.info(cmd2) + tdSql.execute(cmd2) + + tdSql.query('select * from normal_in_ts_float_double_1 where in_ts in (\'1577836800001\') order by ts desc') + tdSql.checkData(0,1,'2020-01-01 08:00:00.001') + tdSql.checkData(0,2,666.00000) + tdSql.checkData(0,3,-88888.000000000) + tdSql.query('select * from normal_in_ts_float_double_1 where in_ts in (\'2020-01-01 08:00:00.001\') order by ts desc') + tdSql.checkData(0,1,'2020-01-01 08:00:00.001') + tdSql.checkData(0,2,666.00000) + tdSql.checkData(0,3,-88888.000000000) + tdSql.query('select * from normal_in_ts_float_double_1 where in_float in (666.00000) order by ts desc') + tdSql.checkData(0,1,'2020-01-01 08:00:00.001') + tdSql.checkData(0,2,666.00000) + tdSql.checkData(0,3,-88888.000000000) + tdSql.query('select * from normal_in_ts_float_double_1 where in_double in (-88888.000000000) order by ts desc') + tdSql.checkData(0,1,'2020-01-01 08:00:00.001') + tdSql.checkData(0,2,666.00000) + tdSql.checkData(0,3,-88888.000000000) + + cmd3 = 'insert into normal_in_ts_float_double_1 values(now,\'2021-01-01 08:00:00.001\',\'-888.00000\',\'66666.000000000\') ;' + tdLog.info(cmd3) + tdSql.execute(cmd3) + + tdSql.query('select * from normal_in_ts_float_double_1 where in_ts in (\'1609459200001\') order by ts desc') + tdSql.checkData(0,1,'2021-01-01 08:00:00.001') + tdSql.checkData(0,2,-888.00000) + tdSql.checkData(0,3,66666.000000000) + tdSql.query('select * from normal_in_ts_float_double_1 where in_ts in (\'2021-01-01 08:00:00.001\') order by ts desc') + tdSql.checkData(0,1,'2021-01-01 08:00:00.001') + tdSql.checkData(0,2,-888.00000) + tdSql.checkData(0,3,66666.000000000) + tdSql.query('select * from normal_in_ts_float_double_1 where in_float in (-888.00000) order by ts desc') + tdSql.checkData(0,1,'2021-01-01 08:00:00.001') + tdSql.checkData(0,2,-888.00000) + tdSql.checkData(0,3,66666.000000000) + tdSql.query('select * from normal_in_ts_float_double_1 where in_double in (66666.000000000) order by ts desc') + tdSql.checkData(0,1,'2021-01-01 08:00:00.001') + tdSql.checkData(0,2,-888.00000) + tdSql.checkData(0,3,66666.000000000) + + cmd4 = '''select * from normal_in_ts_float_double_1 + where in_ts in (\'1609459200001\',\'2021-01-01 08:00:00.001\',\'1577836800001\',\'2020-01-01 08:00:00.001000\',\'0\',\'1970-01-01 08:00:00.000\') + and in_double in (0.000000000,66666.000000000,-88888.000000000) + and in_float in (0.00000,666.00000,-888.00000) + order by ts desc ;''' + tdLog.info(cmd4) + tdSql.query(cmd4) + tdSql.checkData(0,1,'2021-01-01 08:00:00.001') + tdSql.checkData(0,2,-888.00000) + tdSql.checkData(0,3,66666.000000000) + tdSql.checkData(1,1,'2020-01-01 08:00:00.001') + tdSql.checkData(1,2,666.00000) + tdSql.checkData(1,3,-88888.000000000) + tdSql.checkData(2,1,'1970-01-01 08:00:00.000') + tdSql.checkData(2,2,0.00000) + tdSql.checkData(2,3,0.000000000) + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/insertDemo.py b/tests/pytest/insert/insertDemo.py new file mode 100644 index 0000000000000000000000000000000000000000..d18206e7a46b960499263b2960a7e3a42ff806ca --- /dev/null +++ b/tests/pytest/insert/insertDemo.py @@ -0,0 +1,47 @@ +import taos +import datetime +import random +import multiprocessing + +def taos_excute(table, connect_host): + conn = taos.connect(host=connect_host, user="root", password="taosdata", config="/etc/taos", database='test') + cursor = conn.cursor() + for i in range(1000000): + pk = random.randint(100001, 300000) + time_now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")[:-3] + col1 = random.randint(1, 10000) + col2 = random.randint(1, 10000) + col3 = random.randint(1, 10000) + col4 = random.randint(1, 10000) + col5 = random.randint(1, 10000) + col6 = random.randint(1, 10000) + sql = f"INSERT INTO {table}_{pk} USING {table} TAGS ({pk}) VALUES ('{time_now}', {col1}, {col2}, {col3}, {col4}, {col5}, {col6})" + cursor.execute(sql) + cursor.close() + conn.close() + +def taos_init(table, connect_host, pk): + conn = taos.connect(host=connect_host, user="root", password="taosdata", config="/etc/taos", database='test') + cursor = conn.cursor() + sql = f"CREATE TABLE {table}_{pk} USING {table} TAGS ({pk})" + cursor.execute(sql) + cursor.close() + conn.close() + +print("init time:", datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")) + +connect_list = ["node1", "node2", "node3", "node4", "node5"] +pool = multiprocessing.Pool(processes=108) + +for pk in range(100001, 300000): + pool.apply_async(func=taos_init, args=("test", connect_list[pk % 5], pk, )) + +print("start time:", datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")) + +for i in range(10000): + pool.apply_async(func=taos_excute, args=("test", connect_list[i % 5],)) + +pool.close() +pool.join() + +print("end time:", datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")) \ No newline at end of file diff --git a/tests/pytest/insert/insertDynamicColBeforeVal.py b/tests/pytest/insert/insertDynamicColBeforeVal.py new file mode 100644 index 0000000000000000000000000000000000000000..4b596049d16a194b37b2e48e9c7dc521a20b3282 --- /dev/null +++ b/tests/pytest/insert/insertDynamicColBeforeVal.py @@ -0,0 +1,136 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + tdSql.execute("drop database if exists db") + tdSql.execute("create database if not exists db keep 3650") + tdSql.execute("use db") + + tdLog.printNoPrefix("==========step1:create table") + tdSql.execute( + "create table stb1 (ts timestamp, c11 int, c12 float ) TAGS(t11 int, t12 int )" + ) + + tdLog.printNoPrefix("==========step2:insert data with new syntax") + tdSql.execute( + "insert into t1 using stb1(t11, t12) tags(11, 12) (ts, c11, c12) values (now, 10, 20)" + ) + + # case for tag-value + tdSql.execute( + "insert into t2 using stb1(t11) tags(21) (ts, c11, c12) values (now-1m, 11, 21)" + ) + tdSql.execute( + "insert into t3 using stb1 tags(31, 32) (ts, c11, c12) values (now-2m, 12, 22)" + ) + tdSql.error( + "insert into t4 using stb1(t11, t12) (ts, c11, c12) values (now-3m, 13, 23)" + ) + tdSql.error( + "insert into t5 using stb1(t11, t12) tags() (ts, c11, c12) values (now-4m, 14, 24)" + ) + tdSql.error( + "insert into t6 using stb1(t11, t12) tags(41) (ts, c11, c12) values (now-5m, 15, 25)" + ) + tdSql.error( + "insert into t7 using stb1(t12) tags(51, 52) (ts, c11, c12) values (now-6m, 16, 26)" + ) + tdSql.execute( + "insert into t8 using stb1(t11, t12) tags('61', 62) (ts, c11, c12) values (now-7m, 17, 27)" + ) + + + # case for col-value + tdSql.execute( + "insert into t9 using stb1(t11, t12) tags(71, 72) values (now-8m, 18, 28)" + ) + tdSql.error( + "insert into t10 using stb1(t11, t12) tags(81, 82) (ts, c11, c12) values ()" + ) + tdSql.error( + "insert into t11 using stb1(t11, t12) tags(91, 92) (ts, c11, c12) " + ) + tdSql.error( + "insert into t12 using stb1(t11, t12) tags(101, 102) values (now-9m, 19)" + ) + tdSql.error( + "insert into t13 using stb1(t11, t12) tags(111, 112) (ts, c11) values (now-10m, 110, 210)" + ) + tdSql.error( + "insert into t14 using stb1(t11, t12) tags(121, 122) (ts, c11, c12) values (now-11m, 111)" + ) + tdSql.execute( + "insert into t15 using stb1(t11, t12) tags(131, 132) (ts, c11, c12) values (now-12m, NULL , 212)" + ) + tdSql.execute( + "insert into t16 using stb1(t11, t12) tags(141, 142) (ts, c11, c12) values (now-13m, 'NULL', 213)" + ) + tdSql.error( + "insert into t17 using stb1(t11, t12) tags(151, 152) (ts, c11, c12) values (now-14m, Nan, 214)" + ) + tdSql.error( + "insert into t18 using stb1(t11, t12) tags(161, 162) (ts, c11, c12) values (now-15m, 'NaN', 215)" + ) + tdSql.execute( + "insert into t19 using stb1(t11, t12) tags(171, 172) (ts, c11) values (now-16m, 216)" + ) + tdSql.error( + "insert into t20 using stb1(t11, t12) tags(181, 182) (c11, c12) values (117, 217)" + ) + + # multi-col_value + tdSql.execute( + "insert into t21 using stb1(t11, t12) tags(191, 192) (ts, c11, c12) values (now-17m, 118, 218)(now-18m, 119, 219)" + ) + tdSql.execute( + "insert into t22 using stb1(t11, t12) tags(201, 202) values (now-19m, 120, 220)(now-19m, 121, 221)" + ) + tdSql.error( + "insert into t23 using stb1(t11, t12) tags(211, 212) values (now-20m, 122, 222) (ts, c11, c12) values (now-21m, 123, 223)" + ) + tdSql.error( + "insert into t24 using stb1(t11, t12) tags(221, 222) (ts, c11, c12) values (now-22m, 124, 224) (ts, c11, c12) values (now-23m, 125, 225)" + ) + tdSql.execute( + "insert into t25 (ts, c11, c12) using stb1(t11, t12) tags(231, 232) values (now-24m, 126, 226)(now-25m, 127, 227)" + ) + tdSql.error( + "insert into t26 (ts, c11, c12) values (now-24m, 128, 228)(now-25m, 129, 229) using stb1(t11, t12) tags(241, 242) " + ) + tdSql.error( + "insert into t27 (ts, c11, c12) values (now-24m, 130, 230) using stb1(t11, t12) tags(251, 252) " + ) + + tdSql.query("show tables") + tdSql.checkRows(21) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/insert/insertFromCSV.py b/tests/pytest/insert/insertFromCSV.py new file mode 100644 index 0000000000000000000000000000000000000000..c5d36485699dd2b798b353b614008be7234edfd4 --- /dev/null +++ b/tests/pytest/insert/insertFromCSV.py @@ -0,0 +1,72 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +import time +import datetime +import csv +import random +import pandas as pd + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.ts = 1500074556514 + self.csvfile = "/tmp/csvfile.csv" + self.rows = 100000 + + def writeCSV(self): + with open(self.csvfile, 'w', encoding='utf-8', newline='') as csvFile: + writer = csv.writer(csvFile, dialect='excel') + for i in range(self.rows): + writer.writerow([self.ts + i, random.randint(1, 100), random.uniform(1, 100), random.randint(1, 100), random.randint(1, 100)]) + + def removCSVHeader(self): + data = pd.read_csv("ordered.csv") + data = data.drop([0]) + data.to_csv("ordered.csv", header = False, index = False) + + def run(self): + self.writeCSV() + + tdSql.prepare() + tdSql.execute("create table t1(ts timestamp, c1 int, c2 float, c3 int, c4 int)") + startTime = time.time() + tdSql.execute("insert into t1 file '%s'" % self.csvfile) + duration = time.time() - startTime + print("Insert time: %d" % duration) + tdSql.query("select * from t1") + tdSql.checkRows(self.rows) + + tdSql.execute("create table stb(ts timestamp, c1 int, c2 float, c3 int, c4 int) tags(t1 int, t2 binary(20))") + tdSql.execute("insert into t2 using stb(t1) tags(1) file '%s'" % self.csvfile) + tdSql.query("select * from stb") + tdSql.checkRows(self.rows) + + tdSql.execute("insert into t3 using stb tags(1, 'test') file '%s'" % self.csvfile) + tdSql.query("select * from stb") + tdSql.checkRows(self.rows * 2) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/insert/insertFromCSVPerformance.py b/tests/pytest/insert/insertFromCSVPerformance.py new file mode 100644 index 0000000000000000000000000000000000000000..487497631a368778c857ce71234a4574837390c1 --- /dev/null +++ b/tests/pytest/insert/insertFromCSVPerformance.py @@ -0,0 +1,149 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +import time +import datetime +import csv +import random +import pandas as pd +import argparse +import os.path + +class insertFromCSVPerformace: + def __init__(self, commitID, dbName, tbName, branchName, buildType): + self.commitID = commitID + self.dbName = dbName + self.tbName = tbName + self.branchName = branchName + self.type = buildType + self.ts = 1500000000000 + self.host = "127.0.0.1" + self.user = "root" + self.password = "taosdata" + self.config = "/etc/perf" + self.conn = taos.connect( + self.host, + self.user, + self.password, + self.config) + self.host2 = "192.168.1.179" + self.conn2 = taos.connect( + host = self.host2, + user = self.user, + password = self.password, + config = self.config) + + def writeCSV(self): + tsset = set() + rows = 0 + with open('test4.csv','w', encoding='utf-8', newline='') as csvFile: + writer = csv.writer(csvFile, dialect='excel') + while True: + newTimestamp = self.ts + random.randint(1, 10) * 10000000000 + random.randint(1, 10) * 1000000000 + random.randint(1, 10) * 100000000 + random.randint(1, 10) * 10000000 + random.randint(1, 10) * 1000000 + random.randint(1, 10) * 100000 + random.randint(1, 10) * 10000 + random.randint(1, 10) * 1000 + random.randint(1, 10) * 100 + random.randint(1, 10) * 10 + random.randint(1, 10) + if newTimestamp not in tsset: + tsset.add(newTimestamp) + d = datetime.datetime.fromtimestamp(newTimestamp / 1000) + dt = str(d.strftime("%Y-%m-%d %H:%M:%S.%f")) + writer.writerow(["'%s'" % dt, random.randint(1, 100), random.uniform(1, 100), random.randint(1, 100), random.randint(1, 100)]) + rows += 1 + if rows == 2000000: + break + + def removCSVHeader(self): + data = pd.read_csv("ordered.csv") + data = data.drop([0]) + data.to_csv("ordered.csv", header = False, index = False) + + def run(self): + cursor = self.conn.cursor() + cursor.execute("create database if not exists %s" % self.dbName) + cursor.execute("use %s" % self.dbName) + print("==================== CSV insert performance ====================") + + totalTime = 0 + for i in range(10): + cursor.execute("drop table if exists t1") + cursor.execute("create table if not exists t1(ts timestamp, c1 int, c2 float, c3 int, c4 int)") + startTime = time.time() + cursor.execute("insert into t1 file 'outoforder.csv'") + totalTime += time.time() - startTime + time.sleep(1) + + out_of_order_time = (float) (totalTime / 10) + print("Out of Order - Insert time: %f" % out_of_order_time) + + totalTime = 0 + for i in range(10): + cursor.execute("drop table if exists t2") + cursor.execute("create table if not exists t2(ts timestamp, c1 int, c2 float, c3 int, c4 int)") + startTime = time.time() + cursor.execute("insert into t2 file 'ordered.csv'") + totalTime += time.time() - startTime + time.sleep(1) + + in_order_time = (float) (totalTime / 10) + print("In order - Insert time: %f" % in_order_time) + cursor.close() + + + cursor2 = self.conn2.cursor() + cursor2.execute("create database if not exists %s" % self.dbName) + cursor2.execute("use %s" % self.dbName) + cursor2.execute("create table if not exists %s(ts timestamp, in_order_time float, out_of_order_time float, commit_id binary(50), branch binary(50), type binary(20))" % self.tbName) + cursor2.execute("insert into %s values(now, %f, %f, '%s', '%s', '%s')" % (self.tbName, in_order_time, out_of_order_time, self.commitID, self.branchName, self.type)) + + cursor2.close() + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + parser.add_argument( + '-c', + '--commit-id', + action='store', + default='null', + type=str, + help='git commit id (default: null)') + parser.add_argument( + '-d', + '--database-name', + action='store', + default='perf', + type=str, + help='Database name to be created (default: perf)') + parser.add_argument( + '-t', + '--table-name', + action='store', + default='csv_insert', + type=str, + help='Database name to be created (default: csv_insert)') + parser.add_argument( + '-b', + '--branch-name', + action='store', + default='develop', + type=str, + help='branch name (default: develop)') + parser.add_argument( + '-T', + '--build-type', + action='store', + default='glibc', + type=str, + help='build type (default: glibc)') + + args = parser.parse_args() + perftest = insertFromCSVPerformace(args.commit_id, args.database_name, args.table_name, args.branch_name, args.build_type) + perftest.run() \ No newline at end of file diff --git a/tests/pytest/insert/insertIntoTwoTables.py b/tests/pytest/insert/insertIntoTwoTables.py new file mode 100644 index 0000000000000000000000000000000000000000..8b4f423c3dae38a0d8218f7b113f2784259300b4 --- /dev/null +++ b/tests/pytest/insert/insertIntoTwoTables.py @@ -0,0 +1,53 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + ### test case for TD-1758 ### + print("==============step1") + tdSql.execute( + "create table t0(ts timestamp, c int)") + tdSql.execute( + 'create table t1(ts timestamp, c binary(1))') + tdSql.execute( + "insert into t0 values(now,1) t1 values(now,'0')(now+1a,'1')(now+2a,'2')(now+3a,'3')(now+4a,'4')") + + print("==============step2") + + tdSql.query("select * from t0") + tdSql.checkRows(1) + tdSql.checkData(0, 1, 1) + + tdSql.query("select * from t1") + tdSql.checkRows(5) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/insert_before_use_db.py b/tests/pytest/insert/insert_before_use_db.py new file mode 100644 index 0000000000000000000000000000000000000000..8cc02b3d4bde3fc6465c6011ade24fd8d15818be --- /dev/null +++ b/tests/pytest/insert/insert_before_use_db.py @@ -0,0 +1,39 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.error('insert into tb values (now + 10m, 10)') + tdSql.prepare() + tdSql.error('insert into tb values (now + 10m, 10)') + tdSql.execute('drop database db') + tdSql.error('insert into tb values (now + 10m, 10)') + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/insert_locking.py b/tests/pytest/insert/insert_locking.py new file mode 100644 index 0000000000000000000000000000000000000000..0d780a7132fbc83b99e4f5b54fe17101ff4f35f9 --- /dev/null +++ b/tests/pytest/insert/insert_locking.py @@ -0,0 +1,178 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +import random + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + + + def run(self): + tdSql.prepare() + # test case for https://jira.taosdata.com:18080/browse/TD-5021 + + tdLog.info("\n\n----------step1 : drop db and create db----------\n") + tdSql.execute('''drop database if exists db ;''') + tdSql.execute('''create database db ;''') + sql = '''show databases;''' + tdSql.query(sql) + tdSql.checkRows(1) + + tdLog.info("\n\n----------step2 : create stable----------\n") + tdSql.execute('''create stable + db.stable_1 (ts timestamp, payload binary(256)) + tags(t1 binary(16),t2 int);''') + sql = '''show db.stables;''' + tdSql.query(sql) + tdSql.checkRows(1) + + tdLog.info("\n\n----------step3 : create table and insert----------\n") + sql = '''insert into db.table1 using db.stable_1 (t1 , t2) tags ("table_1" , 111) ( values (now, ;''' + tdLog.info(sql) + tdSql.error(sql) + try: + tdSql.execute(sql) + tdLog.exit(" unexpected token") + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("DB error: syntax error near ', ;' (unexpected token)") + + sql = '''insert into db.table1(ts , payload) using db.stable_1 (t1 , t2) tags ("table_1" , 111) ( values (now, ;''' + tdLog.info(sql) + tdSql.error(sql) + try: + tdSql.execute(sql) + tdLog.exit(" bind columns again") + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("DB error: syntax error near ', ;' (bind columns again)") + + sql = '''insert into db.table1 using db.stable_1 (t1 , t2) tags ("table_1",111) (ts , payload) ( values (now, ;''' + tdLog.info(sql) + tdSql.error(sql) + try: + tdSql.execute(sql) + tdLog.exit(" keyword VALUES or FILE required ") + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("DB error: invalid SQL: (keyword VALUES or FILE required)") + + tdSql.execute('''insert into db.table1 using db.stable_1 (t1 , t2) + tags ("table_1" , 111) values ( now , 1) ''') + sql = '''select * from db.stable_1;''' + tdSql.query(sql) + tdSql.checkRows(1) + tdSql.checkData(0,1,1) + tdSql.checkData(0,2,'table_1') + + tdLog.info("\n\n----------step4 : create table and insert again----------\n") + sql = '''insert into db.table2 using db.stable_1 (t1) tags ("table_2") ( values (now, ;''' + tdLog.info(sql) + tdSql.error(sql) + try: + tdSql.execute(sql) + tdLog.exit(" unexpected token") + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("DB error: syntax error near ', ;' (unexpected token)") + + tdSql.execute('''insert into db.table2 using db.stable_1 (t1) + tags ("table_2") values ( now , 2) ''') + sql = '''select * from db.stable_1;''' + tdSql.query(sql) + tdSql.checkRows(2) + tdSql.checkData(1,1,2) + tdSql.checkData(1,2,'table_2') + + tdLog.info("\n\n----------step5 : create table and insert without db----------\n") + tdSql.execute('''use db''') + sql = '''insert into table3 using stable_1 (t1) tags ("table_3") ( values (now, ;''' + tdLog.info(sql) + tdSql.error(sql) + try: + tdSql.execute(sql) + tdLog.exit(" unexpected token") + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("DB error: syntax error near ', ;' (unexpected token)") + + tdSql.execute('''insert into table3 using stable_1 (t1 , t2) + tags ("table_3" , 333) values ( now , 3) ''') + sql = '''select * from stable_1;''' + tdSql.query(sql) + tdSql.checkRows(3) + tdSql.checkData(2,1,3) + tdSql.checkData(2,2,'table_3') + + tdLog.info("\n\n----------step6 : create tables in one sql ----------\n") + sql = '''insert into table4 using stable_1 (t1) tags ("table_4") values (now, 4) + table5 using stable_1 (t1) tags ("table_5") ( values (now, ;''' + tdLog.info(sql) + tdSql.error(sql) + try: + tdSql.execute(sql) + tdLog.exit(" unexpected token") + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("DB error: syntax error near ', ;' (unexpected token)") + + tdSql.execute('''insert into table4 using stable_1 (t1) tags ("table_4") values (now, 4) + table5 using stable_1 (t1) tags ("table_5") values (now, 5) ''') + sql = '''select * from stable_1;''' + tdSql.query(sql) + tdSql.checkRows(5) + tdSql.checkData(3,1,4) + tdSql.checkData(3,2,'table_4') + tdSql.checkData(4,1,5) + tdSql.checkData(4,2,'table_5') + + + sql = '''insert into table6 using stable_1 (t1) tags ("table_6") ( values (now, + table7 using stable_1 (t1) tags ("table_7") values (now, 7);''' + tdLog.info(sql) + tdSql.error(sql) + try: + tdSql.execute(sql) + tdLog.exit(" invalid SQL") + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("invalid SQL") + + tdSql.execute('''insert into table6 using stable_1 (t1 , t2) tags ("table_6" , 666) values (now, 6) + table7 using stable_1 (t1) tags ("table_7") values (now, 7) ''') + sql = '''select * from stable_1;''' + tdSql.query(sql) + tdSql.checkRows(7) + tdSql.checkData(5,1,6) + tdSql.checkData(5,2,'table_6') + tdSql.checkData(6,1,7) + tdSql.checkData(6,2,'table_7') + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/insert/int.py b/tests/pytest/insert/int.py new file mode 100644 index 0000000000000000000000000000000000000000..4a94a331d63eaf04fd7d8ec37f4814b385017d22 --- /dev/null +++ b/tests/pytest/insert/int.py @@ -0,0 +1,183 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import datetime + +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdLog.info("=============== step1") + tdSql.execute('create table tb (ts timestamp, speed int)') + + cmd = 'insert into tb values (now, NULL)' + tdLog.info(cmd) + tdSql.execute(cmd) + tdSql.query('select * from tb order by ts desc') + tdSql.checkRows(1) + if(tdSql.getData(0, 1) is not None): + tdLog.exit("data is not NULL") + + tdLog.info("=============== step2") + cmd = 'insert into tb values (now+1m, -2147483648)' + tdLog.info(cmd) + try: + tdSql.execute(cmd) + tdLog.exit( + "This test failed: INT data overflow error _not_ catched") + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("INT data overflow error catched") + + cmd = 'insert into tb values (now+1m, NULL)' + tdLog.info(cmd) + tdSql.execute(cmd) + tdSql.query('select * from tb order by ts desc') + tdSql.checkRows(2) + + if(tdSql.getData(0, 1) is not None): + tdLog.exit("data is not NULL") + + tdLog.info("=============== step3") + cmd = 'insert into tb values (now+2m, 2147483647)' + tdLog.info(cmd) + tdSql.execute(cmd) + tdSql.query('select * from tb order by ts desc') + tdSql.checkRows(3) + if(tdSql.getData(0, 1) != 2147483647): + tdLog.exit("data is not 2147483647") + + tdLog.info("=============== step4") + cmd = 'insert into tb values (now+3m, 2147483648)' + tdLog.info(cmd) + try: + tdSql.execute(cmd) + tdLog.exit( + "This test failed: INT data overflow error _not_ catched") + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("INT data overflow error catched") + + cmd = 'insert into tb values (now+3m, NULL)' + tdLog.info(cmd) + tdSql.execute(cmd) + tdSql.query('select * from tb order by ts desc') + tdSql.checkRows(4) + + if(tdSql.getData(0, 1) is not None): + tdLog.exit("data is not NULL") + + tdLog.info("=============== step5") + cmd = 'insert into tb values (now+4m, a2)' + tdLog.info(cmd) + try: + tdSql.execute(cmd) + tdLog.exit( + "This test failed: insert wrong data error _not_ catched") + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("insert wrong data error catched") + + cmd = 'insert into tb values (now+4m, 0)' + tdLog.info(cmd) + tdSql.execute(cmd) + tdSql.query('select * from tb order by ts desc') + tdSql.checkRows(5) + + if(tdSql.getData(0, 1) != 0): + tdLog.exit("data is not 0") + + tdLog.info("=============== step6") + cmd = 'insert into tb values (now+5m, 2a)' + tdLog.info(cmd) + try: + tdSql.execute(cmd) + tdLog.exit( + "This test failed: insert wrong data error _not_ catched") + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("insert wrong data error catched") + + cmd = 'insert into tb values (now+5m, 2)' + tdLog.info(cmd) + tdSql.execute(cmd) + tdSql.query('select * from tb order by ts desc') + tdSql.checkRows(6) + if (tdSql.getData(0, 1) != 2): + tdLog.exit("data is not 2") + + tdLog.info("=============== step7") + cmd = "insert into tb values (now+6m, 2a'1)" + tdLog.info(cmd) + try: + tdSql.execute(cmd) + tdLog.exit( + "This test failed: insert wrong data error _not_ catched") + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("insert wrong data error catched") + + cmd = 'insert into tb values (now+6m, 2)' + tdLog.info(cmd) + tdSql.execute(cmd) + tdSql.query('select * from tb order by ts desc') + tdSql.checkRows(7) + if (tdSql.getData(0, 1) != 2): + tdLog.exit("data is not 2") + + tdLog.info("=============== step8") + cmd = 'insert into tb values (now+8m, "null")' + tdLog.info(cmd) + tdSql.execute(cmd) + tdSql.query('select * from tb order by ts desc') + tdSql.checkRows(8) + + if (tdSql.getData(0, 1) is not None): + tdLog.exit("data is not null") + + tdLog.info("=============== step9") + cmd = "insert into tb values (now+9m, 'null')" + tdLog.info(cmd) + tdSql.execute(cmd) + tdSql.query('select * from tb order by ts desc') + tdSql.checkRows(9) + if (tdSql.getData(0, 1) is not None): + tdLog.exit("data is not null") + + tdLog.info("=============== step10") + cmd = 'insert into tb values (now+10m, -123)' + tdLog.info(cmd) + tdSql.execute(cmd) + tdSql.query('select * from tb order by ts desc') + tdSql.checkRows(10) + + if (tdSql.getData(0, 1) != -123): + tdLog.exit("data is not -123") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/line_insert.py b/tests/pytest/insert/line_insert.py new file mode 100644 index 0000000000000000000000000000000000000000..92fdd0f28e612994df414ea1b560152a3f2001a8 --- /dev/null +++ b/tests/pytest/insert/line_insert.py @@ -0,0 +1,93 @@ +################################################################### +# Copyright (c) 2021 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self._conn = conn + + def run(self): + print("running {}".format(__file__)) + tdSql.execute("drop database if exists test") + tdSql.execute("create database if not exists test precision 'us'") + tdSql.execute('use test') + + tdSql.execute('create stable ste(ts timestamp, f int) tags(t1 bigint)') + + lines = [ "st,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000ns", + "st,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640000000ns", + "ste,t2=5f64,t3=L\"ste\" c1=true,c2=4i64,c3=\"iam\" 1626056811823316532ns", + "stf,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000ns", + "st,t1=4i64,t2=5f64,t3=\"t4\" c1=3i64,c3=L\"passitagain\",c2=true,c4=5f64 1626006833642000000ns", + "ste,t2=5f64,t3=L\"ste2\" c3=\"iamszhou\",c4=false 1626056811843316532ns", + "ste,t2=5f64,t3=L\"ste2\" c3=\"iamszhou\",c4=false,c5=32i8,c6=64i16,c7=32i32,c8=88.88f32 1626056812843316532ns", + "st,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000ns", + "stf,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641000000ns" + ] + + code = self._conn.insert_lines(lines) + print("insert_lines result {}".format(code)) + + lines2 = [ "stg,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000ns", + "stg,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640000000ns" + ] + + code = self._conn.insert_lines([ lines2[0] ]) + print("insert_lines result {}".format(code)) + + self._conn.insert_lines([ lines2[1] ]) + print("insert_lines result {}".format(code)) + + tdSql.query("select * from st") + tdSql.checkRows(4) + + tdSql.query("select * from ste") + tdSql.checkRows(3) + + tdSql.query("select * from stf") + tdSql.checkRows(2) + + tdSql.query("select * from stg") + tdSql.checkRows(2) + + tdSql.query("show tables") + tdSql.checkRows(8) + + tdSql.query("describe stf") + tdSql.checkData(2, 2, 14) + + self._conn.insert_lines([ + "sth,t1=4i64,t2=5f64,t4=5f64,ID=\"childtable\" c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641ms", + "sth,t1=4i64,t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933654ms" + ]) + tdSql.execute('reset query cache') + + tdSql.query('select tbname, * from sth') + tdSql.checkRows(2) + + tdSql.query('select tbname, * from childtable') + tdSql.checkRows(1) + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/metadataUpdate.py b/tests/pytest/insert/metadataUpdate.py new file mode 100644 index 0000000000000000000000000000000000000000..f996a707ffc8a98a49f4dc607cb19316d3f1085a --- /dev/null +++ b/tests/pytest/insert/metadataUpdate.py @@ -0,0 +1,108 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +from util.dnodes import tdDnodes +import subprocess + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.ts = 1538548685000 + self.tables = 10 + self.rows = 1000 + + + def deleteTableAndRecreate(self): + self.config = tdDnodes.getSimCfgPath() + + sqlCmds = "use test; drop table stb;" + sqlCmds += "create table if not exists stb (ts timestamp, col1 int) tags(areaid int, city nchar(20));" + for i in range(self.tables): + city = "beijing" if i % 2 == 0 else "shanghai" + sqlCmds += "create table tb%d using stb tags(%d, '%s');" % (i, i, city) + for j in range(5): + sqlCmds += "insert into tb%d values(%d, %d);" % (i, self.ts + j, j * 100000) + command = ["taos", "-c", self.config, "-s", sqlCmds] + print("drop stb, recreate stb and insert data ") + result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf-8") + if result.returncode == 0: + print("success:", result) + else: + print("error:", result) + + def run(self): + tdSql.prepare() + + print("==============step1") + tdSql.execute("create table if not exists tb (ts timestamp, col1 int)") + tdSql.execute("insert into tb values(%d, 1)" % self.ts) + + print("==============step2") + tdSql.query("select * from tb") + tdSql.checkRows(1) + + self.config = tdDnodes.getSimCfgPath() + command = ["taos", "-c", self.config, "-s", "alter table db.tb add column col2 int;"] + print("alter table db.tb add column col2 int;") + result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf-8") + if result.returncode == 0: + print("success:", result) + else: + print("error:", result) + + tdSql.execute("insert into tb(ts, col1, col2) values(%d, 1, 2)" % (self.ts + 2)) + + print("==============step2") + tdSql.query("select * from tb") + tdSql.checkRows(2) + + # Add test case: https://jira.taosdata.com:18080/browse/TD-3474 + + print("==============step1") + tdSql.execute("create database test") + tdSql.execute("use test") + tdSql.execute("create table if not exists stb (ts timestamp, col1 int) tags(areaid int, city nchar(20))") + + for i in range(self.tables): + city = "beijing" if i % 2 == 0 else "shanghai" + tdSql.execute("create table tb%d using stb tags(%d, '%s')" % (i, i, city)) + for j in range(self.rows): + tdSql.execute("insert into tb%d values(%d, %d)" % (i, self.ts + j, j * 100000)) + + tdSql.query("select count(*) from stb") + tdSql.checkData(0, 0, 10000) + + tdSql.query("select count(*) from tb0") + tdSql.checkData(0, 0, 1000) + + # drop stable in subprocess + self.deleteTableAndRecreate() + + tdSql.query("select count(*) from stb") + tdSql.checkData(0, 0, 5 * self.tables) + + tdSql.query("select count(*) from tb0") + tdSql.checkData(0, 0, 5) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/modify_column.py b/tests/pytest/insert/modify_column.py new file mode 100644 index 0000000000000000000000000000000000000000..3632eb817a269dbf8ae03954ccabf1c5df40266d --- /dev/null +++ b/tests/pytest/insert/modify_column.py @@ -0,0 +1,382 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import datetime + +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + # test case for https://jira.taosdata.com:18080/browse/TD-4541 + + tdLog.info("=============== step1,check normal table") + + tdLog.info("=============== step1.1,drop table && create table") + cmd1 = 'drop table if exists length11 ;' + cmd2 = 'create table length11 (ts timestamp,lengthbia binary(10),lengthnchar nchar(20));' + tdLog.info(cmd1) + tdSql.execute(cmd1) + tdLog.info(cmd2) + tdSql.execute(cmd2) + + tdLog.info("=============== step1.2,insert table right data") + cmd1 = 'insert into length11 values(now,\'aaaaaaaaaa\',\'bbbbbbbbbbbbbbbbbbbb\') ;' + tdLog.info(cmd1) + tdSql.execute(cmd1) + tdSql.query('select * from length11 order by ts desc') + tdSql.checkData(0,1,'aaaaaaaaaa') + tdSql.checkData(0,2,'bbbbbbbbbbbbbbbbbbbb') + + tdLog.info("=============== step1.3,insert table wrong data") + cmd1 = 'insert into length11 values(now,\'aaaaaaaaaa1\',\'bbbbbbbbbbbbbbbbbbbb1\') ;' + tdLog.info(cmd1) + tdSql.error(cmd1) + try: + tdSql.execute(cmd1) + tdLog.exit("string data overflow") + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("insert wrong data error catched") + tdSql.query('select * from length11 order by ts desc') + tdSql.checkData(0,1,'aaaaaaaaaa') + tdSql.checkData(0,2,'bbbbbbbbbbbbbbbbbbbb') + + tdLog.info("=============== step1.4,modify columu length ") + cmd1 = 'alter table length11 modify column lengthbia binary(10) ;' + tdLog.info(cmd1) + tdSql.error(cmd1) + try: + tdSql.execute(cmd1) + tdLog.exit("new column length should be bigger than old one") + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("new column length should be bigger than old one") + + cmd2 = 'alter table length11 modify column lengthnchar nchar(20);' + tdLog.info(cmd2) + tdSql.error(cmd2) + try: + tdSql.execute(cmd2) + tdLog.exit("new column length should be bigger than old one") + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("new column length should be bigger than old one") + + cmd3 = 'alter table length11 modify column lengthbia binary(11) ;' + cmd4 = 'describe length11 ;' + tdLog.info(cmd3) + tdSql.execute(cmd3) + tdLog.info(cmd4) + tdSql.execute(cmd4) + tdSql.query('describe length11 ;') + tdSql.checkData(1,2,11) + + cmd5 = 'alter table length11 modify column lengthnchar nchar(21);' + cmd6 = 'describe length11 ;' + tdLog.info(cmd5) + tdSql.execute(cmd5) + tdLog.info(cmd6) + tdSql.execute(cmd6) + tdSql.query('describe length11 ;') + tdSql.checkData(2,2,21) + + tdSql.query('select * from length11 order by ts desc') + tdSql.checkData(0,1,'aaaaaaaaaa') + tdSql.checkData(0,2,'bbbbbbbbbbbbbbbbbbbb') + + + tdLog.info("=============== step1.5,insert table right data") + cmd1 = 'insert into length11 values(now,\'aaaaaaaaaa1\',\'bbbbbbbbbbbbbbbbbbbb1\') ;' + tdLog.info(cmd1) + tdSql.execute(cmd1) + tdSql.query('select * from length11 order by ts desc') + tdSql.checkData(0,1,'aaaaaaaaaa1') + tdSql.checkData(0,2,'bbbbbbbbbbbbbbbbbbbb1') + + + + + tdLog.info("=============== step2,check stable table and tag") + + tdLog.info("=============== step2.1,drop table && create table") + cmd1 = 'drop table if exists length1 ;' + cmd2 = 'drop table if exists length2 ;' + cmd3 = 'drop table if exists length2 ;' + cmd4 = 'drop table if exists lengthsta1 ;' + cmd5 = 'create stable lengthsta1(ts timestamp,lengthbia binary(10),lengthnchar nchar(20)) tags (tlengthbia binary(15),tlengthnchar nchar(25)) ;' + cmd6 = 'create table length1 using lengthsta1 tags(\'aaaaabbbbbaaaaa\',\'bbbbbaaaaabbbbbaaaaabbbbb\') ; ' + tdLog.info(cmd1) + tdSql.execute(cmd1) + tdLog.info(cmd2) + tdSql.execute(cmd2) + tdLog.info(cmd3) + tdSql.execute(cmd3) + tdLog.info(cmd4) + tdSql.execute(cmd4) + tdLog.info(cmd5) + tdSql.execute(cmd5) + tdLog.info(cmd6) + tdSql.execute(cmd6) + + tdLog.info("=============== step2.2,insert table right data") + cmd1 = 'insert into length1 values(now,\'aaaaaaaaaa\',\'bbbbbbbbbbbbbbbbbbbb\') ;' + tdLog.info(cmd1) + tdSql.execute(cmd1) + tdSql.query('select * from length1 order by ts desc') + tdSql.checkData(0,1,'aaaaaaaaaa') + tdSql.checkData(0,2,'bbbbbbbbbbbbbbbbbbbb') + + tdLog.info("=============== step2.3,insert table wrong data") + cmd1 = 'insert into length1 values(now,\'aaaaaaaaaa1\',\'bbbbbbbbbbbbbbbbbbbb1\') ;' + tdLog.info(cmd1) + tdSql.error(cmd1) + try: + tdSql.execute(cmd1) + tdLog.exit("string data overflow") + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("insert wrong data error catched") + tdSql.query('select * from length1 order by ts desc') + tdSql.checkData(0,1,'aaaaaaaaaa') + tdSql.checkData(0,2,'bbbbbbbbbbbbbbbbbbbb') + + tdLog.info("=============== step2.4,modify columu length ") + cmd0 = 'alter table length1 modify column lengthbia binary(10) ;' + tdLog.info(cmd0) + tdSql.error(cmd0) + try: + tdSql.execute(cmd1) + tdLog.exit("invalid operation: column can only be modified by super table") + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("invalid operation: column can only be modified by super table") + + cmd1 = 'alter table lengthsta1 modify column lengthbia binary(10) ;' + tdLog.info(cmd1) + tdSql.error(cmd1) + try: + tdSql.execute(cmd1) + tdLog.exit("new column length should be bigger than old one") + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("new column length should be bigger than old one") + + cmd2 = 'alter table lengthsta1 modify column lengthnchar nchar(20);' + tdLog.info(cmd2) + tdSql.error(cmd2) + try: + tdSql.execute(cmd2) + tdLog.exit("new column length should be bigger than old one") + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("new column length should be bigger than old one") + + cmd3 = 'alter table lengthsta1 modify column lengthbia binary(11) ;' + cmd4 = 'describe lengthsta1 ;' + tdLog.info(cmd3) + tdSql.execute(cmd3) + tdLog.info(cmd4) + tdSql.execute(cmd4) + tdSql.query('describe length1 ;') + tdSql.checkData(1,2,11) + + cmd5 = 'alter table lengthsta1 modify column lengthnchar nchar(21);' + cmd6 = 'describe lengthsta1 ;' + tdLog.info(cmd5) + tdSql.execute(cmd5) + tdLog.info(cmd6) + tdSql.execute(cmd6) + tdSql.query('describe lengthsta1 ;') + tdSql.checkData(2,2,21) + + tdSql.query('select * from lengthsta1 order by ts desc') + tdSql.checkData(0,1,'aaaaaaaaaa') + tdSql.checkData(0,2,'bbbbbbbbbbbbbbbbbbbb') + + + tdLog.info("=============== step2.5,insert table right data") + cmd1 = 'insert into length1 values(now,\'aaaaaaaaaa1\',\'bbbbbbbbbbbbbbbbbbbb1\') ;' + tdLog.info(cmd1) + tdSql.execute(cmd1) + tdSql.query('select * from length1 order by ts desc') + tdSql.checkData(0,1,'aaaaaaaaaa1') + tdSql.checkData(0,2,'bbbbbbbbbbbbbbbbbbbb1') + + + + tdLog.info("=============== step2.6,create table wrong tag") + cmd1 = 'create table length2 using lengthsta1 tags(\'aaaaabbbbbaaaaa1\',\'bbbbbaaaaabbbbbaaaaabbbbb1\') ;' + tdLog.info(cmd1) + tdSql.error(cmd1) + try: + tdSql.execute(cmd1) + tdLog.exit("invalid operation: tag value too long") + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("invalid operation: tag value too long") + tdSql.query('select * from lengthsta1 order by ts desc') + tdSql.checkData(0,1,'aaaaaaaaaa1') + tdSql.checkData(0,2,'bbbbbbbbbbbbbbbbbbbb1') + + tdLog.info("=============== step2.7,modify tag columu length ") + cmd1 = 'alter table lengthsta1 modify tag tlengthbia binary(15) ;' + tdLog.info(cmd1) + tdSql.error(cmd1) + try: + tdSql.execute(cmd1) + tdLog.exit("new column length should be bigger than old one") + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("new column length should be bigger than old one") + + cmd2 = 'alter table lengthsta1 modify tag tlengthnchar nchar(25);' + tdLog.info(cmd2) + tdSql.error(cmd2) + try: + tdSql.execute(cmd2) + tdLog.exit("new column length should be bigger than old one") + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("new column length should be bigger than old one") + + cmd3 = 'alter table lengthsta1 modify tag tlengthbia binary(16) ;' + cmd4 = 'describe lengthsta1 ;' + tdLog.info(cmd3) + tdSql.execute(cmd3) + tdLog.info(cmd4) + tdSql.execute(cmd4) + tdSql.query('describe lengthsta1 ;') + tdSql.checkData(3,2,16) + + cmd5 = 'alter table lengthsta1 modify tag tlengthnchar nchar(26);' + cmd6 = 'describe lengthsta1 ;' + tdLog.info(cmd5) + tdSql.execute(cmd5) + tdLog.info(cmd6) + tdSql.execute(cmd6) + tdSql.query('describe lengthsta1 ;') + tdSql.checkData(4,2,26) + + tdSql.query('select * from lengthsta1 order by ts desc') + tdSql.checkData(0,1,'aaaaaaaaaa1') + tdSql.checkData(0,2,'bbbbbbbbbbbbbbbbbbbb1') + tdSql.checkData(0,3,'aaaaabbbbbaaaaa') + tdSql.checkData(0,4,'bbbbbaaaaabbbbbaaaaabbbbb') + + + tdLog.info("=============== step2.8,creat tag right data and insert data") + cmd1 = 'create table length2 using lengthsta1 tags(\'aaaaabbbbbaaaaa1\',\'bbbbbaaaaabbbbbaaaaabbbbb1\') ;' + tdLog.info(cmd1) + tdSql.execute(cmd1) + tdSql.query('describe length2 ;') + tdSql.checkData(3,2,16) + tdSql.checkData(4,2,26) + + cmd2 = 'insert into length2 values(now,\'aaaaaaaaaa1\',\'bbbbbbbbbbbbbbbbbbbb1\') ;' + tdLog.info(cmd2) + tdSql.execute(cmd2) + tdSql.query('select * from length2 order by ts desc') + tdSql.checkData(0,1,'aaaaaaaaaa1') + tdSql.checkData(0,2,'bbbbbbbbbbbbbbbbbbbb1') + tdSql.query('select * from lengthsta1 order by ts desc') + tdSql.checkData(0,1,'aaaaaaaaaa1') + tdSql.checkData(0,2,'bbbbbbbbbbbbbbbbbbbb1') + tdSql.checkData(0,3,'aaaaabbbbbaaaaa1') + tdSql.checkData(0,4,'bbbbbaaaaabbbbbaaaaabbbbb1') + + + tdLog.info("=============== step2.9,modify tag columu length again ") + cmd1 = 'alter table lengthsta1 modify tag tlengthbia binary(16) ;' + tdLog.info(cmd1) + tdSql.error(cmd1) + try: + tdSql.execute(cmd1) + tdLog.exit("new column length should be bigger than old one") + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("new column length should be bigger than old one") + + cmd2 = 'alter table lengthsta1 modify tag tlengthnchar nchar(26);' + tdLog.info(cmd2) + tdSql.error(cmd2) + try: + tdSql.execute(cmd2) + tdLog.exit("new column length should be bigger than old one") + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("new column length should be bigger than old one") + + cmd3 = 'alter table lengthsta1 modify tag tlengthbia binary(20) ;' + cmd4 = 'describe lengthsta1 ;' + tdLog.info(cmd3) + tdSql.execute(cmd3) + tdLog.info(cmd4) + tdSql.execute(cmd4) + tdSql.query('describe lengthsta1 ;') + tdSql.checkData(3,2,20) + + cmd5 = 'alter table lengthsta1 modify tag tlengthnchar nchar(30);' + cmd6 = 'describe lengthsta1 ;' + tdLog.info(cmd5) + tdSql.execute(cmd5) + tdLog.info(cmd6) + tdSql.execute(cmd6) + tdSql.query('describe lengthsta1 ;') + tdSql.checkData(4,2,30) + + tdSql.query('select * from lengthsta1 order by ts desc') + tdSql.checkData(0,1,'aaaaaaaaaa1') + tdSql.checkData(0,2,'bbbbbbbbbbbbbbbbbbbb1') + tdSql.checkData(0,3,'aaaaabbbbbaaaaa1') + tdSql.checkData(0,4,'bbbbbaaaaabbbbbaaaaabbbbb1') + + + tdLog.info("=============== step2.10,creat tag right data and insert data again") + cmd1 = 'create table length3 using lengthsta1 tags(\'aaaaabbbbbaaaaabbbbb\',\'bbbbbaaaaabbbbbaaaaabbbbbaaaaa\') ;' + tdLog.info(cmd1) + tdSql.execute(cmd1) + tdSql.query('describe length3 ;') + tdSql.checkData(3,2,20) + tdSql.checkData(4,2,30) + + cmd2 = 'insert into length3 values(now,\'aaaaaaaaaa1\',\'bbbbbbbbbbbbbbbbbbbb1\') ;' + tdLog.info(cmd2) + tdSql.execute(cmd2) + tdSql.query('select * from length3 order by ts desc') + tdSql.checkData(0,1,'aaaaaaaaaa1') + tdSql.checkData(0,2,'bbbbbbbbbbbbbbbbbbbb1') + tdSql.query('select * from lengthsta1 order by ts desc') + tdSql.checkData(0,1,'aaaaaaaaaa1') + tdSql.checkData(0,2,'bbbbbbbbbbbbbbbbbbbb1') + tdSql.checkData(0,3,'aaaaabbbbbaaaaabbbbb') + tdSql.checkData(0,4,'bbbbbaaaaabbbbbaaaaabbbbbaaaaa') + + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/multi.py b/tests/pytest/insert/multi.py new file mode 100644 index 0000000000000000000000000000000000000000..42d699ea713006886ba14e1ceda15756d5715e51 --- /dev/null +++ b/tests/pytest/insert/multi.py @@ -0,0 +1,69 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + print("==============step1") + + tdLog.info("create table") + + tdSql.execute( + "create table if not exists st(ts timestamp, tagtype int) tags(dev nchar(50))") + tdSql.execute( + "CREATE TABLE if not exists dev_001 using st tags('dev_01')") + + print("==============step2") + tdLog.info("multiple inserts by insert") + tdSql.execute( + "insert INTO dev_001 VALUES ('2020-05-13 10:00:00.000', 1),('2020-05-13 10:00:00.001', 1)") + tdSql.checkAffectedRows(2) + + print("==============step3") + tdLog.info("multiple inserts by import") + tdSql.execute( + "import INTO dev_001 VALUES ('2020-05-13 10:00:00.000', 1),('2020-05-13 10:00:00.001', 1)") + tdSql.checkAffectedRows(2) + + + tdSql.execute( + "CREATE TABLE if not exists dev_002 using st tags('dev_01')") + tdSql.execute( + "CREATE TABLE if not exists dev_003 using st tags('dev_01')") + print("==============step4") + tdLog.info("multiple tables inserts by insert") + tdSql.execute( + '''insert INTO dev_002 VALUES ('2020-05-13 10:00:00.000', 1),('2020-05-13 10:00:00.001', 1) + dev_003 VALUES ('2020-05-13 10:00:00.000', 2),('2020-05-13 10:00:00.001', 3)''') + tdSql.checkAffectedRows(4) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/nchar-boundary.py b/tests/pytest/insert/nchar-boundary.py new file mode 100644 index 0000000000000000000000000000000000000000..05a66f60661c18de5a4fbf55f9850932d3d36e7a --- /dev/null +++ b/tests/pytest/insert/nchar-boundary.py @@ -0,0 +1,65 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdSql.error('create table tb (ts timestamp, col nchar(1022))') + tdSql.execute('create table tb (ts timestamp, col nchar(1021))') + tdSql.execute("insert into tb values (now, 'taosdata')") + tdSql.query("select * from tb") + tdSql.checkRows(1) + tdSql.checkData(0, 1, 'taosdata') + + with open("../../README.md", "r") as inputFile: + data = inputFile.read(1021).replace( + "\n", + " ").replace( + "\\", + " ").replace( + "\'", + " ").replace( + "\"", + " ").replace( + "[", + " ").replace( + "]", + " ").replace( + "!", + " ") + + tdLog.info("insert %d length data: %s" % (len(data), data)) + + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(2) + tdSql.checkData(1, 1, data) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/nchar-unicode.py b/tests/pytest/insert/nchar-unicode.py new file mode 100644 index 0000000000000000000000000000000000000000..4afcf5b760baab67111beb83c42d6807a65bb830 --- /dev/null +++ b/tests/pytest/insert/nchar-unicode.py @@ -0,0 +1,662 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdSql.execute('create table tb (ts timestamp, col nchar(1021))') + tdSql.execute("insert into tb values (now, 'taosdata')") + tdSql.query("select * from tb") + tdSql.checkRows(1) + tdSql.checkData(0, 1, 'taosdata') + + with open("../../README.md", "r") as inputFile: + data = inputFile.read(1021).replace( + "\n", + " ").replace( + "\\", + " ").replace( + "\'", + " ").replace( + "\"", + " ").replace( + "[", + " ").replace( + "]", + " ").replace( + "!", + " ") + + tdLog.info("insert %d length data: %s" % (len(data), data)) + + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(2) + tdSql.checkData(1, 1, data) + + # https://www.ltg.ed.ac.uk/~richard/unicode-sample.html + # Basic Latin + data = r'! # $ % & ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \\ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~' + tdLog.info("insert Basic Latin %d length data: %s" % (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(3) + + data = data.replace('\\\\', '\\') + tdSql.checkData(2, 1, data) + # tdSql.execute("insert into tb values(now, 'abc')") + + # Latin-1 Supplement + data = ' ¡ ¢ £ ¤ ¥ ¦ § ¨ © ª « ¬ ­ ® ¯ ° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿ À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß à á â ã ä å æ ç è é ê ë ì í î ï ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý þ ÿ' + tdLog.info( + "insert Latin-1 Supplement %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(4) + tdSql.checkData(3, 1, data) + + # Latin Extended-A + data = 'Ā ā Ă ă Ą ą Ć ć Ĉ ĉ Ċ ċ Č č Ď ď Đ đ Ē ē Ĕ ĕ Ė ė Ę ę Ě ě Ĝ ĝ Ğ ğ Ġ ġ Ģ ģ Ĥ ĥ Ħ ħ Ĩ ĩ Ī ī Ĭ ĭ Į į İ ı IJ ij Ĵ ĵ Ķ ķ ĸ Ĺ ĺ Ļ ļ Ľ ľ Ŀ ŀ Ł ł Ń ń Ņ ņ Ň ň ʼn Ŋ ŋ Ō ō Ŏ ŏ Ő ő Œ œ Ŕ ŕ Ŗ ŗ Ř ř Ś ś Ŝ ŝ Ş ş Š š Ţ ţ Ť ť Ŧ ŧ Ũ ũ Ū ū Ŭ ŭ Ů ů Ű ű Ų ų Ŵ ŵ Ŷ ŷ Ÿ Ź ź Ż ż Ž ž ſ' + tdLog.info( + "insert Latin Extended-A %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(5) + tdSql.checkData(4, 1, data) + + # Latin Extended-B + data = 'ƀ Ɓ Ƃ ƃ Ƅ ƅ Ɔ Ƈ ƈ Ɖ Ɗ Ƌ ƌ ƍ Ǝ Ə Ɛ Ƒ ƒ Ɠ Ɣ ƕ Ɩ Ɨ Ƙ ƙ ƚ ƛ Ɯ Ɲ ƞ Ɵ Ơ ơ Ƣ ƣ Ƥ ƥ Ʀ Ƨ ƨ Ʃ ƪ ƫ Ƭ ƭ Ʈ Ư ư Ʊ Ʋ Ƴ ƴ Ƶ ƶ Ʒ Ƹ ƹ ƺ ƻ Ƽ ƽ ƾ ƿ ǀ ǁ ǂ ǃ DŽ Dž dž LJ Lj lj NJ Nj nj Ǎ ǎ Ǐ ǐ Ǒ ǒ Ǔ ǔ Ǖ ǖ Ǘ ǘ Ǚ ǚ Ǜ ǜ ǝ Ǟ ǟ Ǡ ǡ Ǣ ǣ Ǥ ǥ Ǧ ǧ Ǩ ǩ Ǫ ǫ Ǭ ǭ Ǯ ǯ ǰ DZ Dz dz Ǵ ǵ Ǻ ǻ Ǽ ǽ Ǿ ǿ Ȁ ȁ Ȃ ȃ ...' + tdLog.info( + "insert Latin Extended-B %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(6) + tdSql.checkData(5, 1, data) + + # IPA Extensions + data = 'ɐ ɑ ɒ ɓ ɔ ɕ ɖ ɗ ɘ ə ɚ ɛ ɜ ɝ ɞ ɟ ɠ ɡ ɢ ɣ ɤ ɥ ɦ ɧ ɨ ɩ ɪ ɫ ɬ ɭ ɮ ɯ ɰ ɱ ɲ ɳ ɴ ɵ ɶ ɷ ɸ ɹ ɺ ɻ ɼ ɽ ɾ ɿ ʀ ʁ ʂ ʃ ʄ ʅ ʆ ʇ ʈ ʉ ʊ ʋ ʌ ʍ ʎ ʏ ʐ ʑ ʒ ʓ ʔ ʕ ʖ ʗ ʘ ʙ ʚ ʛ ʜ ʝ ʞ ʟ ʠ ʡ ʢ ʣ ʤ ʥ ʦ ʧ ʨ' + tdLog.info( + "insert IPA Extensions %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(7) + tdSql.checkData(6, 1, data) + + # Spacing Modifier Letters + data = 'ʰ ʱ ʲ ʳ ʴ ʵ ʶ ʷ ʸ ʹ ʺ ʻ ʼ ʽ ʾ ʿ ˀ ˁ ˂ ˃ ˄ ˅ ˆ ˇ ˈ ˉ ˊ ˋ ˌ ˍ ˎ ˏ ː ˑ ˒ ˓ ˔ ˕ ˖ ˗ ˘ ˙ ˚ ˛ ˜ ˝ ˞ ˠ ˡ ˢ ˣ ˤ ˥ ˦ ˧ ˨ ˩' + tdLog.info( + "insert Spacing Modifier Letters %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(8) + tdSql.checkData(7, 1, data) + + # Combining Diacritical Marks + data = '̀ ́ ̂ ̃ ̄ ̅ ̆ ̇ ̈ ̉ ̊ ̋ ̌ ̍ ̎ ̏ ̐ ̑ ̒ ̓ ̔ ̕ ̖ ̗ ̘ ̙ ̚ ̛ ̜ ̝ ̞ ̟ ̠ ̡ ̢ ̣ ̤ ̥ ̦ ̧ ̨ ̩ ̪ ̫ ̬ ̭ ̮ ̯ ̰ ̱ ̲ ̳ ̴ ̵ ̶ ̷ ̸ ̹ ̺ ̻ ̼ ̽ ̾ ̿ ̀ ́ ͂ ̓ ̈́ ͅ ͠ ͡' + tdLog.info( + "insert Combining Diacritical Marks %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(9) + tdSql.checkData(8, 1, data) + + # Greek + data = 'ʹ ͵ ͺ ; ΄ ΅ Ά · Έ Ή Ί Ό Ύ Ώ ΐ Α Β Γ Δ Ε Ζ Η Θ Ι Κ Λ Μ Ν Ξ Ο Π Ρ Σ Τ Υ Φ Χ Ψ Ω Ϊ Ϋ ά έ ή ί ΰ α β γ δ ε ζ η θ ι κ λ μ ν ξ ο π ρ ς σ τ υ φ χ ψ ω ϊ ϋ ό ύ ώ ϐ ϑ ϒ ϓ ϔ ϕ ϖ Ϛ Ϝ Ϟ Ϡ Ϣ ϣ Ϥ ϥ Ϧ ϧ Ϩ ϩ Ϫ ϫ Ϭ ϭ Ϯ ϯ ϰ ϱ ϲ ϳ' + tdLog.info("insert Greek %d length data: %s" % (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(10) + tdSql.checkData(9, 1, data) + + # Cyrillic + data = 'Ё Ђ Ѓ Є Ѕ І Ї Ј Љ Њ Ћ Ќ Ў Џ А Б В Г Д Е Ж З И Й К Л М Н О П Р С Т У Ф Х Ц Ч Ш Щ Ъ Ы Ь Э Ю Я а б в г д е ж з и й к л м н о п р с т у ф х ц ч ш щ ъ ы ь э ю я ё ђ ѓ є ѕ і ї ј љ њ ћ ќ ў џ Ѡ ѡ Ѣ ѣ Ѥ ѥ Ѧ ѧ Ѩ ѩ Ѫ ѫ Ѭ ѭ Ѯ ѯ Ѱ ѱ Ѳ ѳ Ѵ ѵ Ѷ ѷ Ѹ ѹ Ѻ ѻ Ѽ ѽ Ѿ ѿ Ҁ ҁ ҂ ҃ ...' + tdLog.info("insert Cyrillic %d length data: %s" % (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(11) + tdSql.checkData(10, 1, data) + + # Armenian + data = 'Ա Բ Գ Դ Ե Զ Է Ը Թ Ժ Ի Լ Խ Ծ Կ Հ Ձ Ղ Ճ Մ Յ Ն Շ Ո Չ Պ Ջ Ռ Ս Վ Տ Ր Ց Ւ Փ Ք Օ Ֆ ՙ ՚ ՛ ՜ ՝ ՞ ՟ ա բ գ դ ե զ է ը թ ժ ի լ խ ծ կ հ ձ ղ ճ մ յ ն շ ո չ պ ջ ռ ս վ տ ր ց ւ փ ք օ ֆ և ։' + tdLog.info("insert Armenian %d length data: %s" % (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(12) + tdSql.checkData(11, 1, data) + + # Hebrew + data = ' ֒ ֓ ֔ ֕ ֖ ֗ ֘ ֙ ֚ ֛ ֜ ֝ ֞ ֟ ֠ ֡ ֣ ֤ ֥ ֦ ֧ ֨ ֩ ֪ ֫ ֬ ֭ ֮ ֯ ְ ֱ ֲ ֳ ִ ֵ ֶ ַ ָ ֹ ֻ ּ ֽ ־ ֿ ׀ ׁ ׂ ׃ ׄ א ב ג ד ה ו ז ח ט י ך כ ל ם מ ן נ ס ע ף פ ץ צ ק ר ש ת װ ױ ײ ׳ ״' + tdLog.info("insert Hebrew %d length data: %s" % (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(13) + tdSql.checkData(12, 1, data) + + # Arabic + data = '، ؛ ؟ ء آ أ ؤ إ ئ ا ب ة ت ث ج ح خ د ذ ر ز س ش ص ض ط ظ ع غ ـ ف ق ك ل م ن ه و ى ي ً ٌ ٍ َ ُ ِ ّ ْ ٠ ١ ٢ ٣ ٤ ٥ ٦ ٧ ٨ ٩ ٪ ٫ ٬ ٭ ٰ ٱ ٲ ٳ ٴ ٵ ٶ ٷ ٸ ٹ ٺ ٻ ټ ٽ پ ٿ ڀ ځ ڂ ڃ ڄ څ چ ڇ ڈ ډ ڊ ڋ ڌ ڍ ڎ ڏ ڐ ڑ ڒ ړ ڔ ڕ ږ ڗ ژ ڙ ښ ڛ ڜ ڝ ڞ ڟ ڠ ڡ ڢ ڣ ڤ ڥ ڦ ڧ ڨ ک ڪ ګ ڬ ڭ ڮ گ ڰ ڱ ...' + tdLog.info( + "FAILED: insert Arabic %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(14) + tdSql.checkData(13, 1, data) + + # Devanagari + data = 'ँ ं ः अ आ इ ई उ ऊ ऋ ऌ ऍ ऎ ए ऐ ऑ ऒ ओ औ क ख ग घ ङ च छ ज झ ञ ट ठ ड ढ ण त थ द ध न ऩ प फ ब भ म य र ऱ ल ळ ऴ व श ष स ह ़ ऽ ा ि ी ु ू ृ ॄ ॅ ॆ े ै ॉ ॊ ो ौ ् ॐ ॑ ॒ ॓ ॔ क़ ख़ ग़ ज़ ड़ ढ़ फ़ य़ ॠ ॡ ॢ ॣ । ॥ ० १ २ ३ ४ ५ ६ ७ ८ ९ ॰' + tdLog.info("insert Devanagari %d length data: %s" % (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(15) + tdSql.checkData(14, 1, data) + + # Bengali + data = 'ঁ ং ঃ অ আ ই ঈ উ ঊ ঋ ঌ এ ঐ ও ঔ ক খ গ ঘ ঙ চ ছ জ ঝ ঞ ট ঠ ড ঢ ণ ত থ দ ধ ন প ফ ব ভ ম য র ল শ ষ স হ ় া ি ী ু ূ ৃ ৄ ে ৈ ো ৌ ্ ৗ ড় ঢ় য় ৠ ৡ ৢ ৣ ০ ১ ২ ৩ ৪ ৫ ৬ ৭ ৮ ৯ ৰ ৱ ৲ ৳ ৴ ৵ ৶ ৷ ৸ ৹ ৺' + tdLog.info("insert Bengali %d length data: %s" % (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(16) + tdSql.checkData(15, 1, data) + + # Gurmukhi + data = 'ਂ ਅ ਆ ਇ ਈ ਉ ਊ ਏ ਐ ਓ ਔ ਕ ਖ ਗ ਘ ਙ ਚ ਛ ਜ ਝ ਞ ਟ ਠ ਡ ਢ ਣ ਤ ਥ ਦ ਧ ਨ ਪ ਫ ਬ ਭ ਮ ਯ ਰ ਲ ਲ਼ ਵ ਸ਼ ਸ ਹ ਼ ਾ ਿ ੀ ੁ ੂ ੇ ੈ ੋ ੌ ੍ ਖ਼ ਗ਼ ਜ਼ ੜ ਫ਼ ੦ ੧ ੨ ੩ ੪ ੫ ੬ ੭ ੮ ੯ ੰ ੱ ੲ ੳ ੴ' + tdLog.info("insert Gurmukhi %d length data: %s" % (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(17) + tdSql.checkData(16, 1, data) + + # Gujarati + data = 'ઁ ં ઃ અ આ ઇ ઈ ઉ ઊ ઋ ઍ એ ઐ ઑ ઓ ઔ ક ખ ગ ઘ ઙ ચ છ જ ઝ ઞ ટ ઠ ડ ઢ ણ ત થ દ ધ ન પ ફ બ ભ મ ય ર લ ળ વ શ ષ સ હ ઼ ઽ ા િ ી ુ ૂ ૃ ૄ ૅ ે ૈ ૉ ો ૌ ્ ૐ ૠ ૦ ૧ ૨ ૩ ૪ ૫ ૬ ૭ ૮ ૯' + tdLog.info("insert Gujarati %d length data: %s" % (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(18) + tdSql.checkData(17, 1, data) + + # Oriya + data = 'ଁ ଂ ଃ ଅ ଆ ଇ ଈ ଉ ଊ ଋ ଌ ଏ ଐ ଓ ଔ କ ଖ ଗ ଘ ଙ ଚ ଛ ଜ ଝ ଞ ଟ ଠ ଡ ଢ ଣ ତ ଥ ଦ ଧ ନ ପ ଫ ବ ଭ ମ ଯ ର ଲ ଳ ଶ ଷ ସ ହ ଼ ଽ ା ି ୀ ୁ ୂ ୃ େ ୈ ୋ ୌ ୍ ୖ ୗ ଡ଼ ଢ଼ ୟ ୠ ୡ ୦ ୧ ୨ ୩ ୪ ୫ ୬ ୭ ୮ ୯ ୰' + tdLog.info("insert Oriya %d length data: %s" % (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(19) + tdSql.checkData(18, 1, data) + + # Tamil + data = 'ஂ ஃ அ ஆ இ ஈ உ ஊ எ ஏ ஐ ஒ ஓ ஔ க ங ச ஜ ஞ ட ண த ந ன ப ம ய ர ற ல ள ழ வ ஷ ஸ ஹ ா ி ீ ு ூ ெ ே ை ொ ோ ௌ ் ௗ ௧ ௨ ௩ ௪ ௫ ௬ ௭ ௮ ௯ ௰ ௱ ௲' + tdLog.info("insert Tamil %d length data: %s" % (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(20) + tdSql.checkData(19, 1, data) + + # Telugu + data = 'ఁ ం ః అ ఆ ఇ ఈ ఉ ఊ ఋ ఌ ఎ ఏ ఐ ఒ ఓ ఔ క ఖ గ ఘ ఙ చ ఛ జ ఝ ఞ ట ఠ డ ఢ ణ త థ ద ధ న ప ఫ బ భ మ య ర ఱ ల ళ వ శ ష స హ ా ి ీ ు ూ ృ ౄ ె ే ై ొ ో ౌ ్ ౕ ౖ ౠ ౡ ౦ ౧ ౨ ౩ ౪ ౫ ౬ ౭ ౮ ౯' + tdLog.info("insert Telugu %d length data: %s" % (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(21) + tdSql.checkData(20, 1, data) + + # Kannada + data = 'ಂ ಃ ಅ ಆ ಇ ಈ ಉ ಊ ಋ ಌ ಎ ಏ ಐ ಒ ಓ ಔ ಕ ಖ ಗ ಘ ಙ ಚ ಛ ಜ ಝ ಞ ಟ ಠ ಡ ಢ ಣ ತ ಥ ದ ಧ ನ ಪ ಫ ಬ ಭ ಮ ಯ ರ ಱ ಲ ಳ ವ ಶ ಷ ಸ ಹ ಾ ಿ ೀ ು ೂ ೃ ೄ ೆ ೇ ೈ ೊ ೋ ೌ ್ ೕ ೖ ೞ ೠ ೡ ೦ ೧ ೨ ೩ ೪ ೫ ೬ ೭ ೮ ೯' + tdLog.info("insert Kannada %d length data: %s" % (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(22) + tdSql.checkData(21, 1, data) + + # Malayalam + data = 'ം ഃ അ ആ ഇ ഈ ഉ ഊ ഋ ഌ എ ഏ ഐ ഒ ഓ ഔ ക ഖ ഗ ഘ ങ ച ഛ ജ ഝ ഞ ട ഠ ഡ ഢ ണ ത ഥ ദ ധ ന പ ഫ ബ ഭ മ യ ര റ ല ള ഴ വ ശ ഷ സ ഹ ാ ി ീ ു ൂ ൃ െ േ ൈ ൊ ോ ൌ ് ൗ ൠ ൡ ൦ ൧ ൨ ൩ ൪ ൫ ൬ ൭ ൮ ൯' + tdLog.info("insert Malayalam %d length data: %s" % (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(23) + tdSql.checkData(22, 1, data) + + # Thai + data = 'ก ข ฃ ค ฅ ฆ ง จ ฉ ช ซ ฌ ญ ฎ ฏ ฐ ฑ ฒ ณ ด ต ถ ท ธ น บ ป ผ ฝ พ ฟ ภ ม ย ร ฤ ล ฦ ว ศ ษ ส ห ฬ อ ฮ ฯ ะ ั า ำ ิ ี ึ ื ุ ู ฺ ฿ เ แ โ ใ ไ ๅ ๆ ็ ่ ้ ๊ ๋ ์ ํ ๎ ๏ ๐ ๑ ๒ ๓ ๔ ๕ ๖ ๗ ๘ ๙ ๚ ๛' + tdLog.info("insert Thai %d length data: %s" % (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(24) + tdSql.checkData(23, 1, data) + + # Thai + data = 'ก ข ฃ ค ฅ ฆ ง จ ฉ ช ซ ฌ ญ ฎ ฏ ฐ ฑ ฒ ณ ด ต ถ ท ธ น บ ป ผ ฝ พ ฟ ภ ม ย ร ฤ ล ฦ ว ศ ษ ส ห ฬ อ ฮ ฯ ะ ั า ำ ิ ี ึ ื ุ ู ฺ ฿ เ แ โ ใ ไ ๅ ๆ ็ ่ ้ ๊ ๋ ์ ํ ๎ ๏ ๐ ๑ ๒ ๓ ๔ ๕ ๖ ๗ ๘ ๙ ๚ ๛' + tdLog.info("insert Thai %d length data: %s" % (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(25) + tdSql.checkData(24, 1, data) + + # Lao + data = 'ກ ຂ ຄ ງ ຈ ຊ ຍ ດ ຕ ຖ ທ ນ ບ ປ ຜ ຝ ພ ຟ ມ ຢ ຣ ລ ວ ສ ຫ ອ ຮ ຯ ະ ັ າ ຳ ິ ີ ຶ ື ຸ ູ ົ ຼ ຽ ເ ແ ໂ ໃ ໄ ໆ ່ ້ ໊ ໋ ໌ ໍ ໐ ໑ ໒ ໓ ໔ ໕ ໖ ໗ ໘ ໙ ໜ ໝ' + tdLog.info("insert Lao %d length data: %s" % (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(26) + tdSql.checkData(25, 1, data) + + # Tibetan + data = 'ༀ ༁ ༂ ༃ ༄ ༅ ༆ ༇ ༈ ༉ ༊ ་ ༌ ། ༎ ༏ ༐ ༑ ༒ ༓ ༔ ༕ ༖ ༗ ༘ ༙ ༚ ༛ ༜ ༝ ༞ ༟ ༠ ༡ ༢ ༣ ༤ ༥ ༦ ༧ ༨ ༩ ༪ ༫ ༬ ༭ ༮ ༯ ༰ ༱ ༲ ༳ ༴ ༵ ༶ ༷ ༸ ༹ ༺ ༻ ༼ ༽ ༾ ༿ ཀ ཁ ག གྷ ང ཅ ཆ ཇ ཉ ཊ ཋ ཌ ཌྷ ཎ ཏ ཐ ད དྷ ན པ ཕ བ བྷ མ ཙ ཚ ཛ ཛྷ ཝ ཞ ཟ འ ཡ ར ལ ཤ ཥ ས ཧ ཨ ཀྵ ཱ ི ཱི ུ ཱུ ྲྀ ཷ ླྀ ཹ ེ ཻ ོ ཽ ཾ ཿ ྀ ཱྀ ྂ ྃ ྄ ྅ ྆ ྇ ...' + tdLog.info("insert Tibetan %d length data: %s" % (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(27) + tdSql.checkData(26, 1, data) + + # Georgian + data = 'Ⴀ Ⴁ Ⴂ Ⴃ Ⴄ Ⴅ Ⴆ Ⴇ Ⴈ Ⴉ Ⴊ Ⴋ Ⴌ Ⴍ Ⴎ Ⴏ Ⴐ Ⴑ Ⴒ Ⴓ Ⴔ Ⴕ Ⴖ Ⴗ Ⴘ Ⴙ Ⴚ Ⴛ Ⴜ Ⴝ Ⴞ Ⴟ Ⴠ Ⴡ Ⴢ Ⴣ Ⴤ Ⴥ ა ბ გ დ ე ვ ზ თ ი კ ლ მ ნ ო პ ჟ რ ს ტ უ ფ ქ ღ ყ შ ჩ ც ძ წ ჭ ხ ჯ ჰ ჱ ჲ ჳ ჴ ჵ ჶ ჻' + tdLog.info("insert Georgian %d length data: %s" % (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(28) + tdSql.checkData(27, 1, data) + + # Hangul Jamo + data = 'ᄀ ᄁ ᄂ ᄃ ᄄ ᄅ ᄆ ᄇ ᄈ ᄉ ᄊ ᄋ ᄌ ᄍ ᄎ ᄏ ᄐ ᄑ ᄒ ᄓ ᄔ ᄕ ᄖ ᄗ ᄘ ᄙ ᄚ ᄛ ᄜ ᄝ ᄞ ᄟ ᄠ ᄡ ᄢ ᄣ ᄤ ᄥ ᄦ ᄧ ᄨ ᄩ ᄪ ᄫ ᄬ ᄭ ᄮ ᄯ ᄰ ᄱ ᄲ ᄳ ᄴ ᄵ ᄶ ᄷ ᄸ ᄹ ᄺ ᄻ ᄼ ᄽ ᄾ ᄿ ᅀ ᅁ ᅂ ᅃ ᅄ ᅅ ᅆ ᅇ ᅈ ᅉ ᅊ ᅋ ᅌ ᅍ ᅎ ᅏ ᅐ ᅑ ᅒ ᅓ ᅔ ᅕ ᅖ ᅗ ᅘ ᅙ ᅟ ᅠ ᅡ ᅢ ᅣ ᅤ ᅥ ᅦ ᅧ ᅨ ᅩ ᅪ ᅫ ᅬ ᅭ ᅮ ᅯ ᅰ ᅱ ᅲ ᅳ ᅴ ᅵ ᅶ ᅷ ᅸ ᅹ ᅺ ᅻ ᅼ ᅽ ᅾ ᅿ ᆀ ᆁ ᆂ ᆃ ᆄ ...' + tdLog.info("insert Hangul Jamo %d length data: %s" % (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(29) + tdSql.checkData(28, 1, data) + + # Latin Extended Additional + data = 'Ḁ ḁ Ḃ ḃ Ḅ ḅ Ḇ ḇ Ḉ ḉ Ḋ ḋ Ḍ ḍ Ḏ ḏ Ḑ ḑ Ḓ ḓ Ḕ ḕ Ḗ ḗ Ḙ ḙ Ḛ ḛ Ḝ ḝ Ḟ ḟ Ḡ ḡ Ḣ ḣ Ḥ ḥ Ḧ ḧ Ḩ ḩ Ḫ ḫ Ḭ ḭ Ḯ ḯ Ḱ ḱ Ḳ ḳ Ḵ ḵ Ḷ ḷ Ḹ ḹ Ḻ ḻ Ḽ ḽ Ḿ ḿ Ṁ ṁ Ṃ ṃ Ṅ ṅ Ṇ ṇ Ṉ ṉ Ṋ ṋ Ṍ ṍ Ṏ ṏ Ṑ ṑ Ṓ ṓ Ṕ ṕ Ṗ ṗ Ṙ ṙ Ṛ ṛ Ṝ ṝ Ṟ ṟ Ṡ ṡ Ṣ ṣ Ṥ ṥ Ṧ ṧ Ṩ ṩ Ṫ ṫ Ṭ ṭ Ṯ ṯ Ṱ ṱ Ṳ ṳ Ṵ ṵ Ṷ ṷ Ṹ ṹ Ṻ ṻ Ṽ ṽ Ṿ ṿ ...' + tdLog.info( + "insert Latin Extended Additional %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(30) + tdSql.checkData(29, 1, data) + + # Geek Extended + data = 'ἀ ἁ ἂ ἃ ἄ ἅ ἆ ἇ Ἀ Ἁ Ἂ Ἃ Ἄ Ἅ Ἆ Ἇ ἐ ἑ ἒ ἓ ἔ ἕ Ἐ Ἑ Ἒ Ἓ Ἔ Ἕ ἠ ἡ ἢ ἣ ἤ ἥ ἦ ἧ Ἠ Ἡ Ἢ Ἣ Ἤ Ἥ Ἦ Ἧ ἰ ἱ ἲ ἳ ἴ ἵ ἶ ἷ Ἰ Ἱ Ἲ Ἳ Ἴ Ἵ Ἶ Ἷ ὀ ὁ ὂ ὃ ὄ ὅ Ὀ Ὁ Ὂ Ὃ Ὄ Ὅ ὐ ὑ ὒ ὓ ὔ ὕ ὖ ὗ Ὑ Ὓ Ὕ Ὗ ὠ ὡ ὢ ὣ ὤ ὥ ὦ ὧ Ὠ Ὡ Ὢ Ὣ Ὤ Ὥ Ὦ Ὧ ὰ ά ὲ έ ὴ ή ὶ ί ὸ ό ὺ ύ ὼ ώ ᾀ ᾁ ᾂ ᾃ ᾄ ᾅ ᾆ ᾇ ᾈ ᾉ ᾊ ᾋ ᾌ ᾍ ...' + tdLog.info( + "insert Geek Extended %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(31) + tdSql.checkData(30, 1, data) + + # General Punctuation + data = '                      ‐ ‑ ‒ – — ― ‖ ‗ ‘ ’ ‚ ‛ “ ” „ ‟ † ‡ • ‣ ․ ‥ … ‧ 
 
 ' + tdLog.info( + "insert General Punctuation %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(32) + tdSql.checkData(31, 1, data) + + # Superscripts and Subscripts + data = '⁰ ⁴ ⁵ ⁶ ⁷ ⁸ ⁹ ⁺ ⁻ ⁼ ⁽ ⁾ ⁿ ₀ ₁ ₂ ₃ ₄ ₅ ₆ ₇ ₈ ₉ ₊ ₋ ₌ ₍ ₎' + tdLog.info( + "insert Superscripts and Subscripts %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(33) + tdSql.checkData(32, 1, data) + + # Currency Symbols + data = '₠ ₡ ₢ ₣ ₤ ₥ ₦ ₧ ₨ ₩ ₪ ₫' + tdLog.info( + "insert Currency Symbols %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(34) + tdSql.checkData(33, 1, data) + + # Combining Marks for Symbols + data = '⃐ ⃑ ⃒ ⃓ ⃔ ⃕ ⃖ ⃗ ⃘ ⃙ ⃚ ⃛ ⃜ ⃝ ⃞ ⃟ ⃠ ⃡' + tdLog.info( + "insert Combining Marks for Symbols %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(35) + tdSql.checkData(34, 1, data) + + # Letterlike Symbols + data = '℀ ℁ ℂ ℃ ℄ ℅ ℆ ℇ ℈ ℉ ℊ ℋ ℌ ℍ ℎ ℏ ℐ ℑ ℒ ℓ ℔ ℕ № ℗ ℘ ℙ ℚ ℛ ℜ ℝ ℞ ℟ ℠ ℡ ™ ℣ ℤ ℥ Ω ℧ ℨ ℩ K Å ℬ ℭ ℮ ℯ ℰ ℱ Ⅎ ℳ ℴ ℵ ℶ ℷ ℸ' + tdLog.info( + "insert Letterlike Symbols %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(36) + tdSql.checkData(35, 1, data) + + # Number Forms + data = '⅓ ⅔ ⅕ ⅖ ⅗ ⅘ ⅙ ⅚ ⅛ ⅜ ⅝ ⅞ ⅟ Ⅰ Ⅱ Ⅲ Ⅳ Ⅴ Ⅵ Ⅶ Ⅷ Ⅸ Ⅹ Ⅺ Ⅻ Ⅼ Ⅽ Ⅾ Ⅿ ⅰ ⅱ ⅲ ⅳ ⅴ ⅵ ⅶ ⅷ ⅸ ⅹ ⅺ ⅻ ⅼ ⅽ ⅾ ⅿ ↀ ↁ ↂ' + tdLog.info( + "insert Number Forms %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(37) + tdSql.checkData(36, 1, data) + + # Arrows + data = '← ↑ → ↓ ↔ ↕ ↖ ↗ ↘ ↙ ↚ ↛ ↜ ↝ ↞ ↟ ↠ ↡ ↢ ↣ ↤ ↥ ↦ ↧ ↨ ↩ ↪ ↫ ↬ ↭ ↮ ↯ ↰ ↱ ↲ ↳ ↴ ↵ ↶ ↷ ↸ ↹ ↺ ↻ ↼ ↽ ↾ ↿ ⇀ ⇁ ⇂ ⇃ ⇄ ⇅ ⇆ ⇇ ⇈ ⇉ ⇊ ⇋ ⇌ ⇍ ⇎ ⇏ ⇐ ⇑ ⇒ ⇓ ⇔ ⇕ ⇖ ⇗ ⇘ ⇙ ⇚ ⇛ ⇜ ⇝ ⇞ ⇟ ⇠ ⇡ ⇢ ⇣ ⇤ ⇥ ⇦ ⇧ ⇨ ⇩ ⇪' + tdLog.info("insert Arrows %d length data: %s" % (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(38) + tdSql.checkData(37, 1, data) + + # Mathematical Operators + data = '∀ ∁ ∂ ∃ ∄ ∅ ∆ ∇ ∈ ∉ ∊ ∋ ∌ ∍ ∎ ∏ ∐ ∑ − ∓ ∔ ∕ ∖ ∗ ∘ ∙ √ ∛ ∜ ∝ ∞ ∟ ∠ ∡ ∢ ∣ ∤ ∥ ∦ ∧ ∨ ∩ ∪ ∫ ∬ ∭ ∮ ∯ ∰ ∱ ∲ ∳ ∴ ∵ ∶ ∷ ∸ ∹ ∺ ∻ ∼ ∽ ∾ ∿ ≀ ≁ ≂ ≃ ≄ ≅ ≆ ≇ ≈ ≉ ≊ ≋ ≌ ≍ ≎ ≏ ≐ ≑ ≒ ≓ ≔ ≕ ≖ ≗ ≘ ≙ ≚ ≛ ≜ ≝ ≞ ≟ ≠ ≡ ≢ ≣ ≤ ≥ ≦ ≧ ≨ ≩ ≪ ≫ ≬ ≭ ≮ ≯ ≰ ≱ ≲ ≳ ≴ ≵ ≶ ≷ ≸ ≹ ≺ ≻ ≼ ≽ ≾ ≿ ...' + tdLog.info( + "insert Mathematical Operators %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(39) + tdSql.checkData(38, 1, data) + + # Miscellaneous Technical + data = '⌀ ⌂ ⌃ ⌄ ⌅ ⌆ ⌇ ⌈ ⌉ ⌊ ⌋ ⌌ ⌍ ⌎ ⌏ ⌐ ⌑ ⌒ ⌓ ⌔ ⌕ ⌖ ⌗ ⌘ ⌙ ⌚ ⌛ ⌜ ⌝ ⌞ ⌟ ⌠ ⌡ ⌢ ⌣ ⌤ ⌥ ⌦ ⌧ ⌨ 〈 〉 ⌫ ⌬ ⌭ ⌮ ⌯ ⌰ ⌱ ⌲ ⌳ ⌴ ⌵ ⌶ ⌷ ⌸ ⌹ ⌺ ⌻ ⌼ ⌽ ⌾ ⌿ ⍀ ⍁ ⍂ ⍃ ⍄ ⍅ ⍆ ⍇ ⍈ ⍉ ⍊ ⍋ ⍌ ⍍ ⍎ ⍏ ⍐ ⍑ ⍒ ⍓ ⍔ ⍕ ⍖ ⍗ ⍘ ⍙ ⍚ ⍛ ⍜ ⍝ ⍞ ⍟ ⍠ ⍡ ⍢ ⍣ ⍤ ⍥ ⍦ ⍧ ⍨ ⍩ ⍪ ⍫ ⍬ ⍭ ⍮ ⍯ ⍰ ⍱ ⍲ ⍳ ⍴ ⍵ ⍶ ⍷ ⍸ ⍹ ⍺' + tdLog.info( + "insert Miscellaneous Technical %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(40) + tdSql.checkData(39, 1, data) + + # Control Pictures + data = '␀ ␁ ␂ ␃ ␄ ␅ ␆ ␇ ␈ ␉ ␊ ␋ ␌ ␍ ␎ ␏ ␐ ␑ ␒ ␓ ␔ ␕ ␖ ␗ ␘ ␙ ␚ ␛ ␜ ␝ ␞ ␟ ␠ ␡ ␢ ␣ ␤' + tdLog.info( + "insert Control Pictures %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(41) + tdSql.checkData(40, 1, data) + + # Optical Character Recognition + data = '⑀ ⑁ ⑂ ⑃ ⑄ ⑅ ⑆ ⑇ ⑈ ⑉ ⑊' + tdLog.info( + "insert Optical Character Recognition %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(42) + tdSql.checkData(41, 1, data) + + # Enclosed Alphanumerics + data = '① ② ③ ④ ⑤ ⑥ ⑦ ⑧ ⑨ ⑩ ⑪ ⑫ ⑬ ⑭ ⑮ ⑯ ⑰ ⑱ ⑲ ⑳ ⑴ ⑵ ⑶ ⑷ ⑸ ⑹ ⑺ ⑻ ⑼ ⑽ ⑾ ⑿ ⒀ ⒁ ⒂ ⒃ ⒄ ⒅ ⒆ ⒇ ⒈ ⒉ ⒊ ⒋ ⒌ ⒍ ⒎ ⒏ ⒐ ⒑ ⒒ ⒓ ⒔ ⒕ ⒖ ⒗ ⒘ ⒙ ⒚ ⒛ ⒜ ⒝ ⒞ ⒟ ⒠ ⒡ ⒢ ⒣ ⒤ ⒥ ⒦ ⒧ ⒨ ⒩ ⒪ ⒫ ⒬ ⒭ ⒮ ⒯ ⒰ ⒱ ⒲ ⒳ ⒴ ⒵ Ⓐ Ⓑ Ⓒ Ⓓ Ⓔ Ⓕ Ⓖ Ⓗ Ⓘ Ⓙ Ⓚ Ⓛ Ⓜ Ⓝ Ⓞ Ⓟ Ⓠ Ⓡ Ⓢ Ⓣ Ⓤ Ⓥ Ⓦ Ⓧ Ⓨ Ⓩ ⓐ ⓑ ⓒ ⓓ ⓔ ⓕ ⓖ ⓗ ⓘ ⓙ ⓚ ⓛ ⓜ ⓝ ⓞ ⓟ ...' + tdLog.info( + "insert Enclosed Alphanumerics %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(43) + tdSql.checkData(42, 1, data) + + # Box Drawing + data = '─ ━ │ ┃ ┄ ┅ ┆ ┇ ┈ ┉ ┊ ┋ ┌ ┍ ┎ ┏ ┐ ┑ ┒ ┓ └ ┕ ┖ ┗ ┘ ┙ ┚ ┛ ├ ┝ ┞ ┟ ┠ ┡ ┢ ┣ ┤ ┥ ┦ ┧ ┨ ┩ ┪ ┫ ┬ ┭ ┮ ┯ ┰ ┱ ┲ ┳ ┴ ┵ ┶ ┷ ┸ ┹ ┺ ┻ ┼ ┽ ┾ ┿ ╀ ╁ ╂ ╃ ╄ ╅ ╆ ╇ ╈ ╉ ╊ ╋ ╌ ╍ ╎ ╏ ═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟ ╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬ ╭ ╮ ╯ ╰ ╱ ╲ ╳ ╴ ╵ ╶ ╷ ╸ ╹ ╺ ╻ ╼ ╽ ╾ ╿' + tdLog.info("insert Box Drawing %d length data: %s" % (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(44) + tdSql.checkData(43, 1, data) + + # Block Elements + data = '▀ ▁ ▂ ▃ ▄ ▅ ▆ ▇ █ ▉ ▊ ▋ ▌ ▍ ▎ ▏ ▐ ░ ▒ ▓ ▔ ▕' + tdLog.info( + "insert Block Elements %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(45) + tdSql.checkData(44, 1, data) + + # Geometric Shapes + data = '■ □ ▢ ▣ ▤ ▥ ▦ ▧ ▨ ▩ ▪ ▫ ▬ ▭ ▮ ▯ ▰ ▱ ▲ △ ▴ ▵ ▶ ▷ ▸ ▹ ► ▻ ▼ ▽ ▾ ▿ ◀ ◁ ◂ ◃ ◄ ◅ ◆ ◇ ◈ ◉ ◊ ○ ◌ ◍ ◎ ● ◐ ◑ ◒ ◓ ◔ ◕ ◖ ◗ ◘ ◙ ◚ ◛ ◜ ◝ ◞ ◟ ◠ ◡ ◢ ◣ ◤ ◥ ◦ ◧ ◨ ◩ ◪ ◫ ◬ ◭ ◮ ◯' + tdLog.info( + "insert Geometric Shapes %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(46) + tdSql.checkData(45, 1, data) + + # Miscellaneous Symbols + data = '☀ ☁ ☂ ☃ ☄ ★ ☆ ☇ ☈ ☉ ☊ ☋ ☌ ☍ ☎ ☏ ☐ ☑ ☒ ☓ ☚ ☛ ☜ ☝ ☞ ☟ ☠ ☡ ☢ ☣ ☤ ☥ ☦ ☧ ☨ ☩ ☪ ☫ ☬ ☭ ☮ ☯ ☰ ☱ ☲ ☳ ☴ ☵ ☶ ☷ ☸ ☹ ☺ ☻ ☼ ☽ ☾ ☿ ♀ ♁ ♂ ♃ ♄ ♅ ♆ ♇ ♈ ♉ ♊ ♋ ♌ ♍ ♎ ♏ ♐ ♑ ♒ ♓ ♔ ♕ ♖ ♗ ♘ ♙ ♚ ♛ ♜ ♝ ♞ ♟ ♠ ♡ ♢ ♣ ♤ ♥ ♦ ♧ ♨ ♩ ♪ ♫ ♬ ♭ ♮ ♯' + tdLog.info( + "insert Miscellaneous Symbols %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(47) + tdSql.checkData(46, 1, data) + + # Dingbats + data = '✁ ✂ ✃ ✄ ✆ ✇ ✈ ✉ ✌ ✍ ✎ ✏ ✐ ✑ ✒ ✓ ✔ ✕ ✖ ✗ ✘ ✙ ✚ ✛ ✜ ✝ ✞ ✟ ✠ ✡ ✢ ✣ ✤ ✥ ✦ ✧ ✩ ✪ ✫ ✬ ✭ ✮ ✯ ✰ ✱ ✲ ✳ ✴ ✵ ✶ ✷ ✸ ✹ ✺ ✻ ✼ ✽ ✾ ✿ ❀ ❁ ❂ ❃ ❄ ❅ ❆ ❇ ❈ ❉ ❊ ❋ ❍ ❏ ❐ ❑ ❒ ❖ ❘ ❙ ❚ ❛ ❜ ❝ ❞ ❡ ❢ ❣ ❤ ❥ ❦ ❧ ❶ ❷ ❸ ❹ ❺ ❻ ❼ ❽ ❾ ❿ ➀ ➁ ➂ ➃ ➄ ➅ ➆ ➇ ➈ ➉ ➊ ➋ ➌ ➍ ➎ ➏ ➐ ➑ ➒ ➓ ➔ ➘ ➙ ➚ ➛ ➜ ➝ ...' + tdLog.info("insert Dingbats %d length data: %s" % (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(48) + tdSql.checkData(47, 1, data) + + # CJK Symbols and Punctuation + data = '、 。 〃 〄 々 〆 〇 〈 〉 《 》 「 」 『 』 【 】 〒 〓 〔 〕 〖 〗 〘 〙 〚 〛 〜 〝 〞 〟 〠 〡 〢 〣 〤 〥 〦 〧 〨 〩 〪 〫 〬 〭 〮 〯 〰 〱 〲 〳 〴 〵 〶 〷 〿' + tdLog.info( + "insert CJK Symbols and Punctuation %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(49) + tdSql.checkData(48, 1, data) + + # Hiragana + data = 'ぁ あ ぃ い ぅ う ぇ え ぉ お か が き ぎ く ぐ け げ こ ご さ ざ し じ す ず せ ぜ そ ぞ た だ ち ぢ っ つ づ て で と ど な に ぬ ね の は ば ぱ ひ び ぴ ふ ぶ ぷ へ べ ぺ ほ ぼ ぽ ま み む め も ゃ や ゅ ゆ ょ よ ら り る れ ろ ゎ わ ゐ ゑ を ん ゔ ゙ ゚ ゛ ゜ ゝ ゞ' + tdLog.info("insert Hiragana %d length data: %s" % (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(50) + tdSql.checkData(49, 1, data) + + # Katakana + data = 'ァ ア ィ イ ゥ ウ ェ エ ォ オ カ ガ キ ギ ク グ ケ ゲ コ ゴ サ ザ シ ジ ス ズ セ ゼ ソ ゾ タ ダ チ ヂ ッ ツ ヅ テ デ ト ド ナ ニ ヌ ネ ノ ハ バ パ ヒ ビ ピ フ ブ プ ヘ ベ ペ ホ ボ ポ マ ミ ム メ モ ャ ヤ ュ ユ ョ ヨ ラ リ ル レ ロ ヮ ワ ヰ ヱ ヲ ン ヴ ヵ ヶ ヷ ヸ ヹ ヺ ・ ー ヽ ヾ' + tdLog.info("insert Katakana %d length data: %s" % (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(51) + tdSql.checkData(50, 1, data) + + # Bopomofo + data = 'ㄅ ㄆ ㄇ ㄈ ㄉ ㄊ ㄋ ㄌ ㄍ ㄎ ㄏ ㄐ ㄑ ㄒ ㄓ ㄔ ㄕ ㄖ ㄗ ㄘ ㄙ ㄚ ㄛ ㄜ ㄝ ㄞ ㄟ ㄠ ㄡ ㄢ ㄣ ㄤ ㄥ ㄦ ㄧ ㄨ ㄩ ㄪ ㄫ ㄬ' + tdLog.info("insert Bopomofo %d length data: %s" % (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(52) + tdSql.checkData(51, 1, data) + + # Hangul Compatibility Jamo + data = 'ㄱ ㄲ ㄳ ㄴ ㄵ ㄶ ㄷ ㄸ ㄹ ㄺ ㄻ ㄼ ㄽ ㄾ ㄿ ㅀ ㅁ ㅂ ㅃ ㅄ ㅅ ㅆ ㅇ ㅈ ㅉ ㅊ ㅋ ㅌ ㅍ ㅎ ㅏ ㅐ ㅑ ㅒ ㅓ ㅔ ㅕ ㅖ ㅗ ㅘ ㅙ ㅚ ㅛ ㅜ ㅝ ㅞ ㅟ ㅠ ㅡ ㅢ ㅣ ㅤ ㅥ ㅦ ㅧ ㅨ ㅩ ㅪ ㅫ ㅬ ㅭ ㅮ ㅯ ㅰ ㅱ ㅲ ㅳ ㅴ ㅵ ㅶ ㅷ ㅸ ㅹ ㅺ ㅻ ㅼ ㅽ ㅾ ㅿ ㆀ ㆁ ㆂ ㆃ ㆄ ㆅ ㆆ ㆇ ㆈ ㆉ ㆊ ㆋ ㆌ ㆍ ㆎ' + tdLog.info( + "insert Hangul Compatibility Jamo %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(53) + tdSql.checkData(52, 1, data) + + # Kanbun + data = '㆐ ㆑ ㆒ ㆓ ㆔ ㆕ ㆖ ㆗ ㆘ ㆙ ㆚ ㆛ ㆜ ㆝ ㆞ ㆟' + tdLog.info("insert Kanbun %d length data: %s" % (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(54) + tdSql.checkData(53, 1, data) + + # Enclosed CJK Letters and Months + data = '㈀ ㈁ ㈂ ㈃ ㈄ ㈅ ㈆ ㈇ ㈈ ㈉ ㈊ ㈋ ㈌ ㈍ ㈎ ㈏ ㈐ ㈑ ㈒ ㈓ ㈔ ㈕ ㈖ ㈗ ㈘ ㈙ ㈚ ㈛ ㈜ ㈠ ㈡ ㈢ ㈣ ㈤ ㈥ ㈦ ㈧ ㈨ ㈩ ㈪ ㈫ ㈬ ㈭ ㈮ ㈯ ㈰ ㈱ ㈲ ㈳ ㈴ ㈵ ㈶ ㈷ ㈸ ㈹ ㈺ ㈻ ㈼ ㈽ ㈾ ㈿ ㉀ ㉁ ㉂ ㉃ ㉠ ㉡ ㉢ ㉣ ㉤ ㉥ ㉦ ㉧ ㉨ ㉩ ㉪ ㉫ ㉬ ㉭ ㉮ ㉯ ㉰ ㉱ ㉲ ㉳ ㉴ ㉵ ㉶ ㉷ ㉸ ㉹ ㉺ ㉻ ㉿ ㊀ ㊁ ㊂ ㊃ ㊄ ㊅ ㊆ ㊇ ㊈ ㊉ ㊊ ㊋ ㊌ ㊍ ㊎ ㊏ ㊐ ㊑ ㊒ ㊓ ㊔ ㊕ ㊖ ㊗ ㊘ ㊙ ㊚ ㊛ ㊜ ㊝ ㊞ ㊟ ㊠ ㊡ ...' + tdLog.info( + "insert Enclosed CJK Letters and Months %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(55) + tdSql.checkData(54, 1, data) + + # CJK Compatibility + data = '㌀ ㌁ ㌂ ㌃ ㌄ ㌅ ㌆ ㌇ ㌈ ㌉ ㌊ ㌋ ㌌ ㌍ ㌎ ㌏ ㌐ ㌑ ㌒ ㌓ ㌔ ㌕ ㌖ ㌗ ㌘ ㌙ ㌚ ㌛ ㌜ ㌝ ㌞ ㌟ ㌠ ㌡ ㌢ ㌣ ㌤ ㌥ ㌦ ㌧ ㌨ ㌩ ㌪ ㌫ ㌬ ㌭ ㌮ ㌯ ㌰ ㌱ ㌲ ㌳ ㌴ ㌵ ㌶ ㌷ ㌸ ㌹ ㌺ ㌻ ㌼ ㌽ ㌾ ㌿ ㍀ ㍁ ㍂ ㍃ ㍄ ㍅ ㍆ ㍇ ㍈ ㍉ ㍊ ㍋ ㍌ ㍍ ㍎ ㍏ ㍐ ㍑ ㍒ ㍓ ㍔ ㍕ ㍖ ㍗ ㍘ ㍙ ㍚ ㍛ ㍜ ㍝ ㍞ ㍟ ㍠ ㍡ ㍢ ㍣ ㍤ ㍥ ㍦ ㍧ ㍨ ㍩ ㍪ ㍫ ㍬ ㍭ ㍮ ㍯ ㍰ ㍱ ㍲ ㍳ ㍴ ㍵ ㍶ ㍻ ㍼ ㍽ ㍾ ㍿ ㎀ ㎁ ㎂ ㎃ ...' + tdLog.info( + "insert CJK Compatibility %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(56) + tdSql.checkData(55, 1, data) + + # CJK Unified Ideographs + data = '一 丁 丂 七 丄 丅 丆 万 丈 三 上 下 丌 不 与 丏 丐 丑 丒 专 且 丕 世 丗 丘 丙 业 丛 东 丝 丞 丟 丠 両 丢 丣 两 严 並 丧 丨 丩 个 丫 丬 中 丮 丯 丰 丱 串 丳 临 丵 丶 丷 丸 丹 为 主 丼 丽 举 丿 乀 乁 乂 乃 乄 久 乆 乇 么 义 乊 之 乌 乍 乎 乏 乐 乑 乒 乓 乔 乕 乖 乗 乘 乙 乚 乛 乜 九 乞 也 习 乡 乢 乣 乤 乥 书 乧 乨 乩 乪 乫 乬 乭 乮 乯 买 乱 乲 乳 乴 乵 乶 乷 乸 乹 乺 乻 乼 乽 乾 乿 ...' + tdLog.info( + "insert CJK Unified Ideographs %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(57) + tdSql.checkData(56, 1, data) + + # Hangul Syllables + data = '一 丁 丂 七 丄 丅 丆 万 丈 三 上 下 丌 不 与 丏 丐 丑 丒 专 且 丕 世 丗 丘 丙 业 丛 东 丝 丞 丟 丠 両 丢 丣 两 严 並 丧 丨 丩 个 丫 丬 中 丮 丯 丰 丱 串 丳 临 丵 丶 丷 丸 丹 为 主 丼 丽 举 丿 乀 乁 乂 乃 乄 久 乆 乇 么 义 乊 之 乌 乍 乎 乏 乐 乑 乒 乓 乔 乕 乖 乗 乘 乙 乚 乛 乜 九 乞 也 习 乡 乢 乣 乤 乥 书 乧 乨 乩 乪 乫 乬 乭 乮 乯 买 乱 乲 乳 乴 乵 乶 乷 乸 乹 乺 乻 乼 乽 乾 乿 ...' + tdLog.info( + "insert Hangul Syllables %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(58) + tdSql.checkData(57, 1, data) + + # Private Use + data = '                                                                                                                                ...' + tdLog.info("insert Private Use %d length data: %s" % (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(59) + tdSql.checkData(58, 1, data) + + # CJK Compatibility Ideographs + data = '豈 更 車 賈 滑 串 句 龜 龜 契 金 喇 奈 懶 癩 羅 蘿 螺 裸 邏 樂 洛 烙 珞 落 酪 駱 亂 卵 欄 爛 蘭 鸞 嵐 濫 藍 襤 拉 臘 蠟 廊 朗 浪 狼 郎 來 冷 勞 擄 櫓 爐 盧 老 蘆 虜 路 露 魯 鷺 碌 祿 綠 菉 錄 鹿 論 壟 弄 籠 聾 牢 磊 賂 雷 壘 屢 樓 淚 漏 累 縷 陋 勒 肋 凜 凌 稜 綾 菱 陵 讀 拏 樂 諾 丹 寧 怒 率 異 北 磻 便 復 不 泌 數 索 參 塞 省 葉 說 殺 辰 沈 拾 若 掠 略 亮 兩 凉 梁 糧 良 諒 量 勵 ...' + tdLog.info( + "insert CJK Compatibility Ideographs %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(60) + tdSql.checkData(59, 1, data) + + # Alphabetic Presentation Forms + data = 'ff fi fl ffi ffl ſt st ﬓ ﬔ ﬕ ﬖ ﬗ ﬞ ײַ ﬠ ﬡ ﬢ ﬣ ﬤ ﬥ ﬦ ﬧ ﬨ ﬩ שׁ שׂ שּׁ שּׂ אַ אָ אּ בּ גּ דּ הּ וּ זּ טּ יּ ךּ כּ לּ מּ נּ סּ ףּ פּ צּ קּ רּ שּ תּ וֹ בֿ כֿ פֿ ﭏ' + tdLog.info( + "insert Alphabetic Presentation Forms %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(61) + tdSql.checkData(60, 1, data) + + # Arabic Presentation Forms-A + data = 'ﭐ ﭑ ﭒ ﭓ ﭔ ﭕ ﭖ ﭗ ﭘ ﭙ ﭚ ﭛ ﭜ ﭝ ﭞ ﭟ ﭠ ﭡ ﭢ ﭣ ﭤ ﭥ ﭦ ﭧ ﭨ ﭩ ﭪ ﭫ ﭬ ﭭ ﭮ ﭯ ﭰ ﭱ ﭲ ﭳ ﭴ ﭵ ﭶ ﭷ ﭸ ﭹ ﭺ ﭻ ﭼ ﭽ ﭾ ﭿ ﮀ ﮁ ﮂ ﮃ ﮄ ﮅ ﮆ ﮇ ﮈ ﮉ ﮊ ﮋ ﮌ ﮍ ﮎ ﮏ ﮐ ﮑ ﮒ ﮓ ﮔ ﮕ ﮖ ﮗ ﮘ ﮙ ﮚ ﮛ ﮜ ﮝ ﮞ ﮟ ﮠ ﮡ ﮢ ﮣ ﮤ ﮥ ﮦ ﮧ ﮨ ﮩ ﮪ ﮫ ﮬ ﮭ ﮮ ﮯ ﮰ ﮱ ﯓ ﯔ ﯕ ﯖ ﯗ ﯘ ﯙ ﯚ ﯛ ﯜ ﯝ ﯞ ﯟ ﯠ ﯡ ﯢ ﯣ ﯤ ﯥ ﯦ ﯧ ﯨ ﯩ ﯪ ﯫ ﯬ ﯭ ﯮ ﯯ ﯰ ...' + tdLog.info( + "insert Arabic Presentation Forms-A %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(62) + tdSql.checkData(61, 1, data) + + # Combining Half Marks + data = '︠ ︡ ︢ ︣' + tdLog.info( + "insert Combining Half Marks %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(63) + tdSql.checkData(62, 1, data) + + # CJK Compatibility Forms + data = '︰ ︱ ︲ ︳ ︴ ︵ ︶ ︷ ︸ ︹ ︺ ︻ ︼ ︽ ︾ ︿ ﹀ ﹁ ﹂ ﹃ ﹄ ﹉ ﹊ ﹋ ﹌ ﹍ ﹎ ﹏' + tdLog.info( + "insert CJK Compatibility Forms %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(64) + tdSql.checkData(63, 1, data) + + # Small Form Variants + data = '﹐ ﹑ ﹒ ﹔ ﹕ ﹖ ﹗ ﹘ ﹙ ﹚ ﹛ ﹜ ﹝ ﹞ ﹟ ﹠ ﹡ ﹢ ﹣ ﹤ ﹥ ﹦ ﹨ ﹩ ﹪ ﹫' + tdLog.info( + "insert Small Form Variants %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(65) + tdSql.checkData(64, 1, data) + + # Arabic Presentation Forms-B + data = 'ﹰ ﹱ ﹲ ﹴ ﹶ ﹷ ﹸ ﹹ ﹺ ﹻ ﹼ ﹽ ﹾ ﹿ ﺀ ﺁ ﺂ ﺃ ﺄ ﺅ ﺆ ﺇ ﺈ ﺉ ﺊ ﺋ ﺌ ﺍ ﺎ ﺏ ﺐ ﺑ ﺒ ﺓ ﺔ ﺕ ﺖ ﺗ ﺘ ﺙ ﺚ ﺛ ﺜ ﺝ ﺞ ﺟ ﺠ ﺡ ﺢ ﺣ ﺤ ﺥ ﺦ ﺧ ﺨ ﺩ ﺪ ﺫ ﺬ ﺭ ﺮ ﺯ ﺰ ﺱ ﺲ ﺳ ﺴ ﺵ ﺶ ﺷ ﺸ ﺹ ﺺ ﺻ ﺼ ﺽ ﺾ ﺿ ﻀ ﻁ ﻂ ﻃ ﻄ ﻅ ﻆ ﻇ ﻈ ﻉ ﻊ ﻋ ﻌ ﻍ ﻎ ﻏ ﻐ ﻑ ﻒ ﻓ ﻔ ﻕ ﻖ ﻗ ﻘ ﻙ ﻚ ﻛ ﻜ ﻝ ﻞ ﻟ ﻠ ﻡ ﻢ ﻣ ﻤ ﻥ ﻦ ﻧ ﻨ ﻩ ﻪ ﻫ ﻬ ﻭ ﻮ ﻯ ﻰ ﻱ ...' + tdLog.info( + "insert Arabic Presentation Forms-B %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(66) + tdSql.checkData(65, 1, data) + + # Halfwidth and Fullwidth Forms + data = '! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~ 。 「 」 、 ・ ヲ ァ ィ ゥ ェ ォ ャ ュ ョ ッ ー ア イ ウ エ オ カ キ ク ケ コ サ シ ス セ ソ タ チ ツ ...' + tdLog.info( + "insert Halfwidth and Fullwidth Forms %d length data: %s" % + (len(data), data)) + tdSql.execute("insert into tb values (now, '%s')" % data) + tdSql.query("select * from tb") + tdSql.checkRows(67) + tdSql.checkData(66, 1, data) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/nchar.py b/tests/pytest/insert/nchar.py new file mode 100644 index 0000000000000000000000000000000000000000..023da5b014864a2d010e6ec6acc16a33ccb20424 --- /dev/null +++ b/tests/pytest/insert/nchar.py @@ -0,0 +1,51 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +import platform + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdSql.execute('create table tb (ts timestamp, col nchar(10))') + tdSql.execute("insert into tb values (now, 'taosdata')") + tdSql.query("select * from tb") + tdSql.checkRows(1) + tdSql.checkData(0, 1, 'taosdata') + tdSql.execute("insert into tb values (now, '涛思数据')") + tdSql.query("select * from tb") + tdSql.checkRows(2) + tdSql.checkData(1, 1, '涛思数据') + + tdSql.error("insert into tb values (now, 'taosdata001')") + + if platform.system() == "Linux" : tdSql.error("insert into tb(now, 😀)") + tdSql.query("select * from tb") + tdSql.checkRows(2) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/ningsiInsert.py b/tests/pytest/insert/ningsiInsert.py new file mode 100644 index 0000000000000000000000000000000000000000..bcad2b03ed52bc01cae8b8b800edcd7c213ca375 --- /dev/null +++ b/tests/pytest/insert/ningsiInsert.py @@ -0,0 +1,88 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import requests, json +import threading +import string +import random +import time + +class RestfulInsert: + def init(self): + self.header = {'Authorization': 'Basic cm9vdDp0YW9zZGF0YQ=='} + self.url = "http://ningsi60:6041/rest/sql" + self.ts = 1104508800000 + self.numOfThreads = 10 + self.numOfTables = 3000 + self.dbName = 'netmonitortaos' + self.stbName = 'devinfomt' + self.prefix = 'dev' + + def get_random_string(self, length): + letters = string.ascii_lowercase + result_str = ''.join(random.choice(letters) for i in range(length)) + return result_str + + def createTables(self, threadID): + print("create table: thread %d started" % threadID) + tablesPerThread = int (self.numOfTables / self.numOfThreads) + for i in range(tablesPerThread): + data = "create table '%s'.dev_%d using '%s'.'%s' tags('%s', '%s')" % (self.dbName, i + threadID * tablesPerThread, self.dbName, self.stbName, self.get_random_string(25), self.get_random_string(25)) + response = requests.post(self.url, data, headers = self.header) + if response.status_code != 200: + print(response.content) + + def insertData(self, threadID): + print("insert data: thread %d started" % threadID) + tablesPerThread = int (self.numOfTables / self.numOfThreads) + base_ts = self.ts + while True: + i = 0 + for i in range(tablesPerThread): + data = "insert into %s.dev_%d values(%d, '%s', '%s', %d, %d, %d)" % (self.dbName, i + threadID * tablesPerThread, base_ts, self.get_random_string(25), self.get_random_string(30), random.randint(1, 10000), random.randint(1, 10000), random.randint(1, 10000)) + response = requests.post(self.url, data, headers = self.header) + if response.status_code != 200: + print(response.content) + + time.sleep(30) + base_ts = base_ts + 1 + + def run(self): + data = "create database if not exists %s keep 7300" % self.dbName + requests.post(self.url, data, headers = self.header) + + data = "create table '%s'.'%s' (timeid timestamp, devdesc binary(50), devname binary(50), cpu bigint, temp bigint, ram bigint) tags(devid binary(50), modelid binary(50))" % (self.dbName, self.stbName) + requests.post(self.url, data, headers = self.header) + + threads = [] + for i in range(self.numOfThreads): + thread = threading.Thread(target=self.createTables, args=(i,)) + thread.start() + threads.append(thread) + + for i in range(self.numOfThreads): + threads[i].join() + + threads = [] + for i in range(self.numOfThreads): + thread = threading.Thread(target=self.insertData, args=(i,)) + thread.start() + threads.append(thread) + + for i in range(self.numOfThreads): + threads[i].join() + +ri = RestfulInsert() +ri.init() +ri.run() diff --git a/tests/pytest/insert/randomNullCommit.py b/tests/pytest/insert/randomNullCommit.py new file mode 100644 index 0000000000000000000000000000000000000000..ecacd20daf522a7a57ef53c78af477d118d90ede --- /dev/null +++ b/tests/pytest/insert/randomNullCommit.py @@ -0,0 +1,66 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import random + +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdLog.info("=============== step1") + tdSql.execute( + 'create table tb (ts timestamp, speed int, temp float, note binary(5), flag bool)') + + numOfRecords = 0 + randomList = [10, 50, 100, 500, 1000, 5000] + for i in range(0, 10): + num = random.choice(randomList) + tdLog.info("will insert %d records" % num) + for x in range(0, num): + tdLog.info( + 'insert into tb values (now + %da, NULL, NULL, NULL, TRUE)' % + x) + tdSql.execute( + 'insert into tb values (now + %da, NULL, NULL, NULL, TRUE)' % + x) + + numOfRecords = numOfRecords + num + + tdSql.query("select * from tb") + tdSql.checkRows(numOfRecords) + tdSql.checkData(numOfRecords - num, 1, None) + tdSql.checkData(numOfRecords - 1, 2, None) + + tdLog.info("stop dnode to commit data to disk") + tdDnodes.stop(1) + tdDnodes.start(1) + tdLog.sleep(5) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/restful.py b/tests/pytest/insert/restful.py new file mode 100644 index 0000000000000000000000000000000000000000..bf9bde99f0f97276e9a00aaa3290258274da988b --- /dev/null +++ b/tests/pytest/insert/restful.py @@ -0,0 +1,60 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import requests, json +import threading +import string +import random + +class RestfulInsert: + def init(self): + self.header = {'Authorization': 'Basic cm9vdDp0YW9zZGF0YQ=='} + self.url = "http://127.0.0.1:6041/rest/sql" + self.ts = 1104508800000 + self.numOfThreads = 50 + + def get_random_string(self, length): + letters = string.ascii_lowercase + result_str = ''.join(random.choice(letters) for i in range(length)) + return result_str + + def insertData(self, threadID): + print("thread %d started" % threadID) + data = "create table test.tb%d(ts timestamp, name nchar(20))" % threadID + requests.post(self.url, data, headers = self.header) + name = self.get_random_string(10) + start = self.ts + while True: + start += 1 + data = "insert into test.tb%d values(%d, '%s')" % (threadID, start, name) + requests.post(self.url, data, headers = self.header) + + def run(self): + data = "drop database if exists test" + requests.post(self.url, data, headers = self.header) + data = "create database test keep 7300" + requests.post(self.url, data, headers = self.header) + + threads = [] + for i in range(self.numOfThreads): + thread = threading.Thread(target=self.insertData, args=(i,)) + thread.start() + threads.append(thread) + + for i in range(self.numOfThreads): + threads[i].join() + +ri = RestfulInsert() +ri.init() +ri.run() \ No newline at end of file diff --git a/tests/pytest/insert/restfulInsert.py b/tests/pytest/insert/restfulInsert.py new file mode 100644 index 0000000000000000000000000000000000000000..43dc4bd4037e0186628f044db4ea1ec5e033ea38 --- /dev/null +++ b/tests/pytest/insert/restfulInsert.py @@ -0,0 +1,248 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import requests +import threading +import random +import time +import argparse + +class RestfulInsert: + def __init__(self, host, startTimestamp, dbname, threads, tables, records, batchSize, tbNamePerfix, outOfOrder,tablePerbatch): + self.header = {'Authorization': 'Basic cm9vdDp0YW9zZGF0YQ=='} + self.url = "http://%s:6041/rest/sql" % host + self.ts = startTimestamp + self.dbname = dbname + self.numOfThreads = threads + self.numOfTables = tables + self.recordsPerTable = records + self.batchSize = batchSize + self.tableNamePerfix = tbNamePerfix + self.outOfOrder = outOfOrder + self.tablePerbatch = tablePerbatch + + def createTable(self, threadID): + tablesPerThread = int (self.numOfTables / self.numOfThreads) + loop = tablesPerThread if threadID != self.numOfThreads - 1 else self.numOfTables - tablesPerThread * threadID + print("create table %d to %d" % (tablesPerThread * threadID, tablesPerThread * threadID + loop - 1)) + for i in range(loop): + tableID = threadID * tablesPerThread + if tableID + i >= self.numOfTables : break + name = 'beijing' if (tableID + i) % 2 == 0 else 'shanghai' + data = "create table if not exists %s.%s%d using %s.meters tags(%d, '%s')" % (self.dbname, self.tableNamePerfix, tableID + i, self.dbname, tableID + i, name) + try: + response = requests.post(self.url, data, headers = self.header) + if response.status_code != 200: + print(response.content) + except Exception as e: + print(e) + + def insertData(self, threadID): + print("thread %d started" % threadID) + tablesPerThread = int (self.numOfTables / self.numOfThreads) + loop = int(self.recordsPerTable / self.batchSize) + if self.tablePerbatch == 1 : + for i in range(tablesPerThread+1): + tableID = i + threadID * tablesPerThread + if tableID >= self.numOfTables: return + start = self.ts + start1=time.time() + for k in range(loop): + data = "insert into %s.%s%d values" % (self.dbname, self.tableNamePerfix, tableID) + values = [] + bloop = self.batchSize if k != loop - 1 else self.recordsPerTable - self.batchSize * k + for l in range(bloop): + values.append("(%d, %d, %d, %d)" % (start + k * self.batchSize + l, random.randint(1, 100), random.randint(1, 100), random.randint(1, 100))) + if len(data) > 1048576 : + print ('batch size is larger than 1M') + exit(-1) + if self.outOfOrder : + random.shuffle(values) + data+=''.join(values) + response = requests.post(self.url, data, headers = self.header) + if response.status_code != 200: + print(response.content) + else: + for i in range(0,tablesPerThread+self.tablePerbatch,self.tablePerbatch): + for k in range(loop): + data = "insert into " + for j in range(self.tablePerbatch): + tableID = i + threadID * tablesPerThread+j + if tableID >= self.numOfTables: return + start = self.ts + data += "%s.%s%d values" % (self.dbname, self.tableNamePerfix, tableID) + values = [] + bloop = self.batchSize if k != loop - 1 else self.recordsPerTable - self.batchSize * k + for l in range(bloop): + values.append("(%d, %d, %d, %d)" % (start + k * self.batchSize + l, random.randint(1, 100), random.randint(1, 100), random.randint(1, 100))) + if self.outOfOrder : + random.shuffle(values) + data+=''.join(values) + if len(data) > 1024*1024 : + print ('batch size is larger than 1M') + exit(-1) + try: + startTime = time.time() + response = requests.post(self.url, data, headers = self.header) + endTime = time.time() + if response.status_code != 200: + print(response.content) + else: + print("inserted %d records, %d seconds" % (bloop, endTime - startTime)) + except Exception as e: + print(e) + + def insertUnlimitedData(self, threadID): + print("thread %d started" % threadID) + tablesPerThread = int (self.numOfTables / self.numOfThreads) + + count = 0 + while True: + i = 0 + start = self.ts + count * self.batchSize + count = count + 1 + + for i in range(tablesPerThread): + tableID = i + threadID * tablesPerThread + + data = "insert into %s.%s%d values" % (self.dbname, self.tableNamePerfix, tableID) + values = [] + for k in range(self.batchSize): + values.append("(%d, %d, %d, %d)" % (start + k, random.randint(1, 100), random.randint(1, 100), random.randint(1, 100))) + + if(self.outOfOrder == False): + for k in range(len(values)): + data += values[k] + else: + random.shuffle(values) + for k in range(len(values)): + data += values[k] + try: + startTime = time.time() + response = requests.post(self.url, data, headers = self.header) + endTime = time.time() + if response.status_code != 200: + print(response.content) + else: + print("inserted %d records, %d seconds" % (self.batchSize, endTime - startTime)) + except Exception as e: + print(e) + + def run(self): + data = "create database if not exists %s" % self.dbname + requests.post(self.url, data, headers = self.header) + data = "create table if not exists %s.meters(ts timestamp, f1 int, f2 int, f3 int) tags(id int, loc nchar(20))" % self.dbname + requests.post(self.url, data, headers = self.header) + + threads = [] + startTime = time.time() + for i in range(self.numOfThreads): + thread = threading.Thread(target=self.createTable, args=(i,)) + thread.start() + threads.append(thread) + for i in range(self.numOfThreads): + threads[i].join() + print("createing %d tables takes %d seconds" % (self.numOfTables, (time.time() - startTime))) + + print("inserting data =======") + threads = [] + startTime = time.time() + for i in range(self.numOfThreads): + if(self.recordsPerTable != -1): + thread = threading.Thread(target=self.insertData, args=(i,)) + else: + thread = threading.Thread(target=self.insertUnlimitedData, args=(i,)) + thread.start() + threads.append(thread) + + for i in range(self.numOfThreads): + threads[i].join() + print("inserting %s records takes %d seconds" % (self.numOfTables * self.recordsPerTable, (time.time() - startTime))) + +parser = argparse.ArgumentParser() +parser.add_argument( + '-H', + '--host-name', + action='store', + default='127.0.0.1', + type=str, + help='host name to be connected (default: 127.0.0.1)') +parser.add_argument( + '-S', + '--start-timestamp', + action='store', + default=1500000000000, + type=int, + help='insert data from timestamp (default: 1500000000000)') +parser.add_argument( + '-d', + '--db-name', + action='store', + default='test', + type=str, + help='Database name to be created (default: test)') +parser.add_argument( + '-t', + '--number-of-threads', + action='store', + default=10, + type=int, + help='Number of threads to create tables and insert datas (default: 10)') +parser.add_argument( + '-T', + '--number-of-tables', + action='store', + default=10000, + type=int, + help='Number of tables to be created (default: 1000)') +parser.add_argument( + '-r', + '--number-of-records', + action='store', + default=10000, + type=int, + help='Number of record to be created for each table (default: 1000, -1 for unlimited records)') +parser.add_argument( + '-s', + '--batch-size', + action='store', + default='1000', + type=int, + help='Number of tables to be created (default: 1000)') +parser.add_argument( + '-p', + '--table-name-prefix', + action='store', + default='t', + type=str, + help='Number of tables to be created (default: 1000)') +parser.add_argument( + '-o', + '--out-of-order', + action='store_true', + help='The order of test data (default: False)') +parser.add_argument( + '-b', + '--table-per-batch', + action='store', + default=1, + type=int, + help='the table per batch (default: 1)') + + + +args = parser.parse_args() +ri = RestfulInsert( + args.host_name, args.start_timestamp, args.db_name, args.number_of_threads, args.number_of_tables, + args.number_of_records, args.batch_size, args.table_name_prefix, args.out_of_order, args.table_per_batch) +ri.run() \ No newline at end of file diff --git a/tests/pytest/insert/retentionpolicy.py b/tests/pytest/insert/retentionpolicy.py new file mode 100644 index 0000000000000000000000000000000000000000..607ee26a59969f1ecafd4160e4f9db58e3af568a --- /dev/null +++ b/tests/pytest/insert/retentionpolicy.py @@ -0,0 +1,138 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +import datetime +sys.path.insert(0, os.getcwd()) +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestRetetion: + def init(self): + self.queryRows=0 + tdLog.debug("start to execute %s" % __file__) + tdLog.info("prepare cluster") + tdDnodes.init("") + tdDnodes.setTestCluster(False) + tdDnodes.setValgrind(False) + tdDnodes.stopAll() + tdDnodes.deploy(1) + tdDnodes.start(1) + print(tdDnodes.getDnodesRootDir()) + self.conn = taos.connect(config=tdDnodes.getSimCfgPath()) + tdSql.init(self.conn.cursor()) + tdSql.execute('reset query cache') + def checkRows(self, expectRows,sql): + if self.queryRows == expectRows: + tdLog.info("sql:%s, queryRows:%d == expect:%d" % (sql, self.queryRows, expectRows)) + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, sql, self.queryRows, expectRows) + os.system("sudo timedatectl set-ntp true") + os.system("date -s '%s'"%(datetime.datetime.now()+datetime.timedelta(hours=1))) + time.sleep(5) + tdLog.exit("%s(%d) failed: sql:%s, queryRows:%d != expect:%d" % args) + + def run(self): + + tdLog.info("=============== step1") + tdSql.execute('create database test keep 3 days 1;') + tdSql.execute('use test;') + tdSql.execute('create table test(ts timestamp,i int);') + + cmd = 'insert into test values(now-2d,1)(now-1d,2)(now,3)(now+1d,4);' + tdLog.info(cmd) + tdSql.execute(cmd) + tdSql.query('select * from test') + tdSql.checkRows(4) + + tdLog.info("=============== step2") + tdDnodes.stop(1) + os.system("sudo timedatectl set-ntp false") + os.system("date -s '%s'"%(datetime.datetime.now()+datetime.timedelta(hours=48))) + tdDnodes.start(1) + cmd = 'insert into test values(now,5);' + tdDnodes.stop(1) + tdDnodes.start(1) + + tdLog.info(cmd) + ttime = datetime.datetime.now() + tdSql.execute(cmd) + self.queryRows=tdSql.query('select * from test') + self.checkRows(3,cmd) + tdLog.info("=============== step3") + tdDnodes.stop(1) + os.system("date -s '%s'"%(datetime.datetime.now()+datetime.timedelta(hours=48))) + tdDnodes.start(1) + tdLog.info(cmd) + tdSql.execute(cmd) + self.queryRows=tdSql.query('select * from test') + if self.queryRows==4: + self.checkRows(4,cmd) + return 0 + cmd = 'insert into test values(now-1d,6);' + tdLog.info(cmd) + tdSql.execute(cmd) + self.queryRows=tdSql.query('select * from test') + self.checkRows(3,cmd) + tdLog.info("=============== step4") + tdDnodes.stop(1) + tdDnodes.start(1) + cmd = 'insert into test values(now,7);' + tdLog.info(cmd) + tdSql.execute(cmd) + self.queryRows=tdSql.query('select * from test') + self.checkRows(4,cmd) + + tdLog.info("=============== step5") + tdDnodes.stop(1) + tdDnodes.start(1) + cmd='select * from test where ts > now-1d' + self.queryRows=tdSql.query('select * from test where ts > now-1d') + self.checkRows(2,cmd) + + tdLog.info("=============== step6") + tdDnodes.stop(1) + os.system("date -s '%s'"%(ttime + datetime.timedelta(seconds=(72*60*60-7)))) + tdDnodes.start(1) + while datetime.datetime.now() < (ttime + datetime.timedelta(seconds=(72*60*60-1))): + time.sleep(0.001) + cmd = 'select * from test' + self.queryRows=tdSql.query(cmd) + self.checkRows(4,cmd) + while datetime.datetime.now() <= (ttime + datetime.timedelta(hours=72)): + time.sleep(0.001) + time.sleep(0.01) + cmd = 'select * from test' + self.queryRows=tdSql.query(cmd) + print(tdSql.queryResult) + self.checkRows(3,cmd) + + def stop(self): + os.system("sudo timedatectl set-ntp true") + os.system("date -s '%s'"%(datetime.datetime.now()+datetime.timedelta(hours=1))) + time.sleep(5) + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +clients = TDTestRetetion() +clients.init() +clients.run() +clients.stop() + diff --git a/tests/pytest/insert/schemalessInsert.py b/tests/pytest/insert/schemalessInsert.py new file mode 100644 index 0000000000000000000000000000000000000000..403a30d0c40373d80badb8fee4dfa2887bbe1488 --- /dev/null +++ b/tests/pytest/insert/schemalessInsert.py @@ -0,0 +1,1344 @@ +################################################################### +# Copyright (c) 2021 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import traceback +import random +import string +from taos.error import LinesError +import time +from copy import deepcopy +import numpy as np +from util.log import * +from util.cases import * +from util.sql import * +import threading + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self._conn = conn + + def createDb(self, name="test", db_update_tag=0): + if db_update_tag == 0: + tdSql.execute(f"drop database if exists {name}") + tdSql.execute(f"create database if not exists {name} precision 'us'") + else: + tdSql.execute(f"drop database if exists {name}") + tdSql.execute(f"create database if not exists {name} precision 'us' update 1") + tdSql.execute(f'use {name}') + + def getLongName(self, len, mode = "mixed"): + """ + generate long name + mode could be numbers/letters/mixed + """ + if mode is "numbers": + chars = ''.join(random.choice(string.digits) for i in range(len)) + elif mode is "letters": + chars = ''.join(random.choice(string.ascii_letters.lower()) for i in range(len)) + else: + chars = ''.join(random.choice(string.ascii_letters.lower() + string.digits) for i in range(len)) + return chars + + def timeTrans(self, time_value): + if time_value.endswith("ns"): + ts = int(''.join(list(filter(str.isdigit, time_value))))/1000000000 + elif time_value.endswith("us") or time_value.isdigit() and int(time_value) != 0: + ts = int(''.join(list(filter(str.isdigit, time_value))))/1000000 + elif time_value.endswith("ms"): + ts = int(''.join(list(filter(str.isdigit, time_value))))/1000 + elif time_value.endswith("s") and list(time_value)[-1] not in "num": + ts = int(''.join(list(filter(str.isdigit, time_value))))/1 + elif int(time_value) == 0: + ts = time.time() + else: + print("input ts maybe not right format") + ulsec = repr(ts).split('.')[1][:6] + if len(ulsec) < 6 and int(ulsec) != 0: + ulsec = int(ulsec) * (10 ** (6 - len(ulsec))) + elif int(ulsec) == 0: + ulsec *= 6 + # * follow two rows added for tsCheckCase + td_ts = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(ts)) + return td_ts + #td_ts = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(ts)) + td_ts = time.strftime("%Y-%m-%d %H:%M:%S.{}".format(ulsec), time.localtime(ts)) + return td_ts + #return repr(datetime.datetime.strptime(td_ts, "%Y-%m-%d %H:%M:%S.%f")) + + def dateToTs(self, datetime_input): + return int(time.mktime(time.strptime(datetime_input, "%Y-%m-%d %H:%M:%S.%f"))) + + def getTdTypeValue(self, value): + if value.endswith("i8"): + td_type = "TINYINT" + td_tag_value = ''.join(list(value)[:-2]) + elif value.endswith("i16"): + td_type = "SMALLINT" + td_tag_value = ''.join(list(value)[:-3]) + elif value.endswith("i32"): + td_type = "INT" + td_tag_value = ''.join(list(value)[:-3]) + elif value.endswith("i64"): + td_type = "BIGINT" + td_tag_value = ''.join(list(value)[:-3]) + elif value.endswith("u64"): + td_type = "BIGINT UNSIGNED" + td_tag_value = ''.join(list(value)[:-3]) + elif value.endswith("f32"): + td_type = "FLOAT" + td_tag_value = ''.join(list(value)[:-3]) + td_tag_value = '{}'.format(np.float32(td_tag_value)) + elif value.endswith("f64"): + td_type = "DOUBLE" + td_tag_value = ''.join(list(value)[:-3]) + elif value.startswith('L"'): + td_type = "NCHAR" + td_tag_value = ''.join(list(value)[2:-1]) + elif value.startswith('"') and value.endswith('"'): + td_type = "BINARY" + td_tag_value = ''.join(list(value)[1:-1]) + elif value.lower() == "t" or value == "true" or value == "True": + td_type = "BOOL" + td_tag_value = "True" + elif value.lower() == "f" or value == "false" or value == "False": + td_type = "BOOL" + td_tag_value = "False" + else: + td_type = "FLOAT" + td_tag_value = value + return td_type, td_tag_value + + def typeTrans(self, type_list): + type_num_list = [] + for tp in type_list: + if tp.upper() == "TIMESTAMP": + type_num_list.append(9) + elif tp.upper() == "BOOL": + type_num_list.append(1) + elif tp.upper() == "TINYINT": + type_num_list.append(2) + elif tp.upper() == "SMALLINT": + type_num_list.append(3) + elif tp.upper() == "INT": + type_num_list.append(4) + elif tp.upper() == "BIGINT": + type_num_list.append(5) + elif tp.upper() == "FLOAT": + type_num_list.append(6) + elif tp.upper() == "DOUBLE": + type_num_list.append(7) + elif tp.upper() == "BINARY": + type_num_list.append(8) + elif tp.upper() == "NCHAR": + type_num_list.append(10) + elif tp.upper() == "BIGINT UNSIGNED": + type_num_list.append(14) + return type_num_list + + def inputHandle(self, input_sql): + input_sql_split_list = input_sql.split(" ") + + stb_tag_list = input_sql_split_list[0].split(',') + stb_col_list = input_sql_split_list[1].split(',') + ts_value = self.timeTrans(input_sql_split_list[2]) + + stb_name = stb_tag_list[0] + stb_tag_list.pop(0) + + tag_name_list = [] + tag_value_list = [] + td_tag_value_list = [] + td_tag_type_list = [] + + col_name_list = [] + col_value_list = [] + td_col_value_list = [] + td_col_type_list = [] + + for elm in stb_tag_list: + if "id=" in elm.lower(): + tb_name = elm.split('=')[1] + else: + tag_name_list.append(elm.split("=")[0]) + tag_value_list.append(elm.split("=")[1]) + tb_name = "" + td_tag_value_list.append(self.getTdTypeValue(elm.split("=")[1])[1]) + td_tag_type_list.append(self.getTdTypeValue(elm.split("=")[1])[0]) + + for elm in stb_col_list: + col_name_list.append(elm.split("=")[0]) + col_value_list.append(elm.split("=")[1]) + td_col_value_list.append(self.getTdTypeValue(elm.split("=")[1])[1]) + td_col_type_list.append(self.getTdTypeValue(elm.split("=")[1])[0]) + + final_field_list = [] + final_field_list.extend(col_name_list) + final_field_list.extend(tag_name_list) + + final_type_list = [] + final_type_list.append("TIMESTAMP") + final_type_list.extend(td_col_type_list) + final_type_list.extend(td_tag_type_list) + final_type_list = self.typeTrans(final_type_list) + + final_value_list = [] + final_value_list.append(ts_value) + final_value_list.extend(td_col_value_list) + final_value_list.extend(td_tag_value_list) + return final_value_list, final_field_list, final_type_list, stb_name, tb_name + + def genFullTypeSql(self, stb_name="", tb_name="", t0="", t1="127i8", t2="32767i16", t3="2147483647i32", + t4="9223372036854775807i64", t5="11.12345f32", t6="22.123456789f64", t7="\"binaryTagValue\"", + t8="L\"ncharTagValue\"", c0="", c1="127i8", c2="32767i16", c3="2147483647i32", + c4="9223372036854775807i64", c5="11.12345f32", c6="22.123456789f64", c7="\"binaryColValue\"", + c8="L\"ncharColValue\"", c9="7u64", ts="1626006833639000000ns", + id_noexist_tag=None, id_change_tag=None, id_upper_tag=None, id_double_tag=None, + ct_add_tag=None, ct_am_tag=None, ct_ma_tag=None, ct_min_tag=None): + if stb_name == "": + stb_name = self.getLongName(len=6, mode="letters") + if tb_name == "": + tb_name = f'{stb_name}_{random.randint(0, 65535)}_{random.randint(0, 65535)}' + if t0 == "": + t0 = random.choice(["f", "F", "false", "False", "t", "T", "true", "True"]) + if c0 == "": + c0 = random.choice(["f", "F", "false", "False", "t", "T", "true", "True"]) + #sql_seq = f'{stb_name},id=\"{tb_name}\",t0={t0},t1=127i8,t2=32767i16,t3=125.22f64,t4=11.321f32,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0={bool_value},c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"binaryValue\",c8=L\"ncharValue\" 1626006833639000000ns' + if id_upper_tag is not None: + id = "ID" + else: + id = "id" + sql_seq = f'{stb_name},{id}=\"{tb_name}\",t0={t0},t1={t1},t2={t2},t3={t3},t4={t4},t5={t5},t6={t6},t7={t7},t8={t8} c0={c0},c1={c1},c2={c2},c3={c3},c4={c4},c5={c5},c6={c6},c7={c7},c8={c8},c9={c9} {ts}' + if id_noexist_tag is not None: + sql_seq = f'{stb_name},t0={t0},t1={t1},t2={t2},t3={t3},t4={t4},t5={t5},t6={t6},t7={t7},t8={t8} c0={c0},c1={c1},c2={c2},c3={c3},c4={c4},c5={c5},c6={c6},c7={c7},c8={c8},c9={c9} {ts}' + if ct_add_tag is not None: + sql_seq = f'{stb_name},t0={t0},t1={t1},t2={t2},t3={t3},t4={t4},t5={t5},t6={t6},t7={t7},t8={t8},t9={t8} c0={c0},c1={c1},c2={c2},c3={c3},c4={c4},c5={c5},c6={c6},c7={c7},c8={c8},c9={c9} {ts}' + if id_change_tag is not None: + sql_seq = f'{stb_name},t0={t0},t1={t1},{id}=\"{tb_name}\",t2={t2},t3={t3},t4={t4},t5={t5},t6={t6},t7={t7},t8={t8} c0={c0},c1={c1},c2={c2},c3={c3},c4={c4},c5={c5},c6={c6},c7={c7},c8={c8},c9={c9} {ts}' + if id_double_tag is not None: + sql_seq = f'{stb_name},{id}=\"{tb_name}_1\",t0={t0},t1={t1},{id}=\"{tb_name}_2\",t2={t2},t3={t3},t4={t4},t5={t5},t6={t6},t7={t7},t8={t8} c0={c0},c1={c1},c2={c2},c3={c3},c4={c4},c5={c5},c6={c6},c7={c7},c8={c8},c9={c9} {ts}' + if ct_add_tag is not None: + sql_seq = f'{stb_name},{id}=\"{tb_name}\",t0={t0},t1={t1},t2={t2},t3={t3},t4={t4},t5={t5},t6={t6},t7={t7},t8={t8},t11={t1},t10={t8} c0={c0},c1={c1},c2={c2},c3={c3},c4={c4},c5={c5},c6={c6},c7={c7},c8={c8},c9={c9},c11={c8},c10={t0} {ts}' + if ct_am_tag is not None: + sql_seq = f'{stb_name},{id}=\"{tb_name}\",t0={t0},t1={t1},t2={t2},t3={t3},t4={t4},t5={t5},t6={t6} c0={c0},c1={c1},c2={c2},c3={c3},c4={c4},c5={c5},c6={c6},c7={c7},c8={c8},c9={c9},c11={c8},c10={t0} {ts}' + if id_noexist_tag is not None: + sql_seq = f'{stb_name},t0={t0},t1={t1},t2={t2},t3={t3},t4={t4},t5={t5},t6={t6} c0={c0},c1={c1},c2={c2},c3={c3},c4={c4},c5={c5},c6={c6},c7={c7},c8={c8},c9={c9},c11={c8},c10={t0} {ts}' + if ct_ma_tag is not None: + sql_seq = f'{stb_name},{id}=\"{tb_name}\",t0={t0},t1={t1},t2={t2},t3={t3},t4={t4},t5={t5},t6={t6},t7={t7},t8={t8},t11={t1},t10={t8} c0={c0},c1={c1},c2={c2},c3={c3},c4={c4},c5={c5},c6={c6} {ts}' + if id_noexist_tag is not None: + sql_seq = f'{stb_name},t0={t0},t1={t1},t2={t2},t3={t3},t4={t4},t5={t5},t6={t6},t7={t7},t8={t8},t11={t1},t10={t8} c0={c0},c1={c1},c2={c2},c3={c3},c4={c4},c5={c5},c6={c6} {ts}' + if ct_min_tag is not None: + sql_seq = f'{stb_name},{id}=\"{tb_name}\",t0={t0},t1={t1},t2={t2},t3={t3},t4={t4},t5={t5},t6={t6} c0={c0},c1={c1},c2={c2},c3={c3},c4={c4},c5={c5},c6={c6} {ts}' + return sql_seq, stb_name + + def genMulTagColStr(self, genType, count): + """ + genType must be tag/col + """ + tag_str = "" + col_str = "" + if genType == "tag": + for i in range(0, count): + if i < (count-1): + tag_str += f't{i}=f,' + else: + tag_str += f't{i}=f ' + return tag_str + if genType == "col": + for i in range(0, count): + if i < (count-1): + col_str += f'c{i}=t,' + else: + col_str += f'c{i}=t ' + return col_str + + def genLongSql(self, tag_count, col_count): + stb_name = self.getLongName(7, mode="letters") + tb_name = f'{stb_name}_1' + tag_str = self.genMulTagColStr("tag", tag_count) + col_str = self.genMulTagColStr("col", col_count) + ts = "1626006833640000000ns" + long_sql = stb_name + ',' + f'id=\"{tb_name}\"' + ',' + tag_str + col_str + ts + return long_sql, stb_name + + def getNoIdTbName(self, stb_name): + query_sql = f"select tbname from {stb_name}" + tb_name = self.resHandle(query_sql, True)[0][0] + return tb_name + + def resHandle(self, query_sql, query_tag): + tdSql.execute('reset query cache') + row_info = tdSql.query(query_sql, query_tag) + col_info = tdSql.getColNameList(query_sql, query_tag) + res_row_list = [] + sub_list = [] + for row_mem in row_info: + for i in row_mem: + sub_list.append(str(i)) + res_row_list.append(sub_list) + res_field_list_without_ts = col_info[0][1:] + res_type_list = col_info[1] + return res_row_list, res_field_list_without_ts, res_type_list + + def resCmp(self, input_sql, stb_name, query_sql="select * from", condition="", ts=None, id=True, none_check_tag=None): + expect_list = self.inputHandle(input_sql) + self._conn.insert_lines([input_sql]) + query_sql = f"{query_sql} {stb_name} {condition}" + res_row_list, res_field_list_without_ts, res_type_list = self.resHandle(query_sql, True) + if ts == 0: + res_ts = self.dateToTs(res_row_list[0][0]) + current_time = time.time() + if current_time - res_ts < 60: + tdSql.checkEqual(res_row_list[0][1:], expect_list[0][1:]) + else: + print("timeout") + tdSql.checkEqual(res_row_list[0], expect_list[0]) + else: + if none_check_tag is not None: + none_index_list = [i for i,x in enumerate(res_row_list[0]) if x=="None"] + none_index_list.reverse() + for j in none_index_list: + res_row_list[0].pop(j) + expect_list[0].pop(j) + tdSql.checkEqual(res_row_list[0], expect_list[0]) + tdSql.checkEqual(res_field_list_without_ts, expect_list[1]) + for i in range(len(res_type_list)): + tdSql.checkEqual(res_type_list[i], expect_list[2][i]) + # tdSql.checkEqual(res_type_list, expect_list[2]) + + def cleanStb(self): + query_sql = "show stables" + res_row_list = tdSql.query(query_sql, True) + stb_list = map(lambda x: x[0], res_row_list) + for stb in stb_list: + tdSql.execute(f'drop table if exists {stb}') + + def initCheckCase(self): + """ + normal tags and cols, one for every elm + """ + self.cleanStb() + input_sql, stb_name = self.genFullTypeSql() + self.resCmp(input_sql, stb_name) + + def boolTypeCheckCase(self): + """ + check all normal type + """ + self.cleanStb() + full_type_list = ["f", "F", "false", "False", "t", "T", "true", "True"] + for t_type in full_type_list: + input_sql, stb_name = self.genFullTypeSql(c0=t_type, t0=t_type) + self.resCmp(input_sql, stb_name) + + def symbolsCheckCase(self): + """ + check symbols = `~!@#$%^&*()_-+={[}]\|:;'\",<.>/? + """ + ''' + please test : + binary_symbols = '\"abcd`~!@#$%^&*()_-{[}]|:;<.>?lfjal"\'\'"\"' + ''' + self.cleanStb() + binary_symbols = '\"abcd`~!@#$%^&*()_-{[}]|:;<.>?lfjal"\"' + nchar_symbols = f'L{binary_symbols}' + input_sql, stb_name = self.genFullTypeSql(c7=binary_symbols, c8=nchar_symbols, t7=binary_symbols, t8=nchar_symbols) + self.resCmp(input_sql, stb_name) + + def tsCheckCase(self): + """ + test ts list --> ["1626006833639000000ns", "1626006833639019us", "1626006833640ms", "1626006834s", "1626006822639022"] + # ! us级时间戳都为0时,数据库中查询显示,但python接口拿到的结果不显示 .000000的情况请确认,目前修改时间处理代码可以通过 + """ + self.cleanStb() + ts_list = ["1626006833639000000ns", "1626006833639019us", "1626006833640ms", "1626006834s", "1626006822639022", 0] + for ts in ts_list: + input_sql, stb_name = self.genFullTypeSql(ts=ts) + self.resCmp(input_sql, stb_name, ts=ts) + + def idSeqCheckCase(self): + """ + check id.index in tags + eg: t0=**,id=**,t1=** + """ + self.cleanStb() + input_sql, stb_name = self.genFullTypeSql(id_change_tag=True) + self.resCmp(input_sql, stb_name) + + def idUpperCheckCase(self): + """ + check id param + eg: id and ID + """ + self.cleanStb() + input_sql, stb_name = self.genFullTypeSql(id_upper_tag=True) + self.resCmp(input_sql, stb_name) + input_sql, stb_name = self.genFullTypeSql(id_change_tag=True, id_upper_tag=True) + self.resCmp(input_sql, stb_name) + + def noIdCheckCase(self): + """ + id not exist + """ + self.cleanStb() + input_sql, stb_name = self.genFullTypeSql(id_noexist_tag=True) + self.resCmp(input_sql, stb_name) + query_sql = f"select tbname from {stb_name}" + res_row_list = self.resHandle(query_sql, True)[0] + if len(res_row_list[0][0]) > 0: + tdSql.checkColNameList(res_row_list, res_row_list) + else: + tdSql.checkColNameList(res_row_list, "please check noIdCheckCase") + + def maxColTagCheckCase(self): + """ + max tag count is 128 + max col count is ?? + """ + for input_sql in [self.genLongSql(128, 1)[0], self.genLongSql(1, 4094)[0]]: + self.cleanStb() + self._conn.insert_lines([input_sql]) + for input_sql in [self.genLongSql(129, 1)[0], self.genLongSql(1, 4095)[0]]: + self.cleanStb() + try: + self._conn.insert_lines([input_sql]) + except LinesError: + pass + + def idIllegalNameCheckCase(self): + """ + test illegal id name + mix "`~!@#$¥%^&*()-+={}|[]、「」【】\:;《》<>?" + """ + self.cleanStb() + rstr = list("`~!@#$¥%^&*()-+={}|[]、「」【】\:;《》<>?") + for i in rstr: + input_sql = self.genFullTypeSql(tb_name=f"\"aaa{i}bbb\"")[0] + try: + self._conn.insert_lines([input_sql]) + except LinesError: + pass + + def idStartWithNumCheckCase(self): + """ + id is start with num + """ + self.cleanStb() + input_sql = self.genFullTypeSql(tb_name=f"\"1aaabbb\"")[0] + try: + self._conn.insert_lines([input_sql]) + except LinesError: + pass + + def nowTsCheckCase(self): + """ + check now unsupported + """ + self.cleanStb() + input_sql = self.genFullTypeSql(ts="now")[0] + try: + self._conn.insert_lines([input_sql]) + except LinesError: + pass + + def dateFormatTsCheckCase(self): + """ + check date format ts unsupported + """ + self.cleanStb() + input_sql = self.genFullTypeSql(ts="2021-07-21\ 19:01:46.920")[0] + try: + self._conn.insert_lines([input_sql]) + except LinesError: + pass + + def illegalTsCheckCase(self): + """ + check ts format like 16260068336390us19 + """ + self.cleanStb() + input_sql = self.genFullTypeSql(ts="16260068336390us19")[0] + try: + self._conn.insert_lines([input_sql]) + except LinesError: + pass + + def tagValueLengthCheckCase(self): + """ + check full type tag value limit + """ + self.cleanStb() + # i8 + for t1 in ["-127i8", "127i8"]: + input_sql, stb_name = self.genFullTypeSql(t1=t1) + self.resCmp(input_sql, stb_name) + for t1 in ["-128i8", "128i8"]: + input_sql = self.genFullTypeSql(t1=t1)[0] + try: + self._conn.insert_lines([input_sql]) + except LinesError: + pass + + #i16 + for t2 in ["-32767i16", "32767i16"]: + input_sql, stb_name = self.genFullTypeSql(t2=t2) + self.resCmp(input_sql, stb_name) + for t2 in ["-32768i16", "32768i16"]: + input_sql = self.genFullTypeSql(t2=t2)[0] + try: + self._conn.insert_lines([input_sql]) + except LinesError: + pass + + #i32 + for t3 in ["-2147483647i32", "2147483647i32"]: + input_sql, stb_name = self.genFullTypeSql(t3=t3) + self.resCmp(input_sql, stb_name) + for t3 in ["-2147483648i32", "2147483648i32"]: + input_sql = self.genFullTypeSql(t3=t3)[0] + try: + self._conn.insert_lines([input_sql]) + except LinesError: + pass + + #i64 + for t4 in ["-9223372036854775807i64", "9223372036854775807i64"]: + input_sql, stb_name = self.genFullTypeSql(t4=t4) + self.resCmp(input_sql, stb_name) + for t4 in ["-9223372036854775808i64", "9223372036854775808i64"]: + input_sql = self.genFullTypeSql(t4=t4)[0] + try: + self._conn.insert_lines([input_sql]) + except LinesError: + pass + + # f32 + for t5 in [f"{-3.4028234663852885981170418348451692544*(10**38)}f32", f"{3.4028234663852885981170418348451692544*(10**38)}f32"]: + input_sql, stb_name = self.genFullTypeSql(t5=t5) + self.resCmp(input_sql, stb_name) + # * limit set to 4028234664*(10**38) + for t5 in [f"{-3.4028234664*(10**38)}f32", f"{3.4028234664*(10**38)}f32"]: + input_sql = self.genFullTypeSql(t5=t5)[0] + try: + self._conn.insert_lines([input_sql]) + raise Exception("should not reach here") + except LinesError as err: + tdSql.checkNotEqual(err.errno, 0) + + + # f64 + for t6 in [f'{-1.79769*(10**308)}f64', f'{-1.79769*(10**308)}f64']: + input_sql, stb_name = self.genFullTypeSql(t6=t6) + self.resCmp(input_sql, stb_name) + # * limit set to 1.797693134862316*(10**308) + for c6 in [f'{-1.797693134862316*(10**308)}f64', f'{-1.797693134862316*(10**308)}f64']: + input_sql = self.genFullTypeSql(c6=c6)[0] + try: + self._conn.insert_lines([input_sql]) + raise Exception("should not reach here") + except LinesError as err: + tdSql.checkNotEqual(err.errno, 0) + + # binary + stb_name = self.getLongName(7, "letters") + input_sql = f'{stb_name},t0=t,t1="{self.getLongName(16374, "letters")}" c0=f 1626006833639000000ns' + self._conn.insert_lines([input_sql]) + + input_sql = f'{stb_name},t0=t,t1="{self.getLongName(16375, "letters")}" c0=f 1626006833639000000ns' + try: + self._conn.insert_lines([input_sql]) + raise Exception("should not reach here") + except LinesError as err: + pass + + # nchar + # * legal nchar could not be larger than 16374/4 + stb_name = self.getLongName(7, "letters") + input_sql = f'{stb_name},t0=t,t1=L"{self.getLongName(4093, "letters")}" c0=f 1626006833639000000ns' + self._conn.insert_lines([input_sql]) + + input_sql = f'{stb_name},t0=t,t1=L"{self.getLongName(4094, "letters")}" c0=f 1626006833639000000ns' + try: + self._conn.insert_lines([input_sql]) + raise Exception("should not reach here") + except LinesError as err: + tdSql.checkNotEqual(err.errno, 0) + + def colValueLengthCheckCase(self): + """ + check full type col value limit + """ + self.cleanStb() + # i8 + for c1 in ["-127i8", "127i8"]: + input_sql, stb_name = self.genFullTypeSql(c1=c1) + self.resCmp(input_sql, stb_name) + + for c1 in ["-128i8", "128i8"]: + input_sql = self.genFullTypeSql(c1=c1)[0] + try: + self._conn.insert_lines([input_sql]) + raise Exception("should not reach here") + except LinesError as err: + tdSql.checkNotEqual(err.errno, 0) + # i16 + for c2 in ["-32767i16"]: + input_sql, stb_name = self.genFullTypeSql(c2=c2) + self.resCmp(input_sql, stb_name) + for c2 in ["-32768i16", "32768i16"]: + input_sql = self.genFullTypeSql(c2=c2)[0] + try: + self._conn.insert_lines([input_sql]) + raise Exception("should not reach here") + except LinesError as err: + tdSql.checkNotEqual(err.errno, 0) + + # i32 + for c3 in ["-2147483647i32"]: + input_sql, stb_name = self.genFullTypeSql(c3=c3) + self.resCmp(input_sql, stb_name) + for c3 in ["-2147483648i32", "2147483648i32"]: + input_sql = self.genFullTypeSql(c3=c3)[0] + try: + self._conn.insert_lines([input_sql]) + raise Exception("should not reach here") + except LinesError as err: + tdSql.checkNotEqual(err.errno, 0) + + # i64 + for c4 in ["-9223372036854775807i64"]: + input_sql, stb_name = self.genFullTypeSql(c4=c4) + self.resCmp(input_sql, stb_name) + for c4 in ["-9223372036854775808i64", "9223372036854775808i64"]: + input_sql = self.genFullTypeSql(c4=c4)[0] + try: + self._conn.insert_lines([input_sql]) + raise Exception("should not reach here") + except LinesError as err: + tdSql.checkNotEqual(err.errno, 0) + + # f32 + for c5 in [f"{-3.4028234663852885981170418348451692544*(10**38)}f32", f"{3.4028234663852885981170418348451692544*(10**38)}f32"]: + input_sql, stb_name = self.genFullTypeSql(c5=c5) + self.resCmp(input_sql, stb_name) + # * limit set to 4028234664*(10**38) + for c5 in [f"{-3.4028234664*(10**38)}f32", f"{3.4028234664*(10**38)}f32"]: + input_sql = self.genFullTypeSql(c5=c5)[0] + try: + self._conn.insert_lines([input_sql]) + raise Exception("should not reach here") + except LinesError as err: + tdSql.checkNotEqual(err.errno, 0) + + # f64 + for c6 in [f'{-1.79769313486231570814527423731704356798070567525844996598917476803157260780*(10**308)}f64', f'{-1.79769313486231570814527423731704356798070567525844996598917476803157260780*(10**308)}f64']: + input_sql, stb_name = self.genFullTypeSql(c6=c6) + self.resCmp(input_sql, stb_name) + # * limit set to 1.797693134862316*(10**308) + for c6 in [f'{-1.797693134862316*(10**308)}f64', f'{-1.797693134862316*(10**308)}f64']: + input_sql = self.genFullTypeSql(c6=c6)[0] + try: + self._conn.insert_lines([input_sql]) + raise Exception("should not reach here") + except LinesError as err: + tdSql.checkNotEqual(err.errno, 0) + + # # binary + stb_name = self.getLongName(7, "letters") + input_sql = f'{stb_name},t0=t c0=f,c1="{self.getLongName(16374, "letters")}" 1626006833639000000ns' + self._conn.insert_lines([input_sql]) + + input_sql = f'{stb_name},t0=t c0=f,c1="{self.getLongName(16375, "letters")}" 1626006833639000000ns' + try: + self._conn.insert_lines([input_sql]) + raise Exception("should not reach here") + except LinesError as err: + tdSql.checkNotEqual(err.errno, 0) + + # nchar + # * legal nchar could not be larger than 16374/4 + stb_name = self.getLongName(7, "letters") + input_sql = f'{stb_name},t0=t c0=f,c1=L"{self.getLongName(4093, "letters")}" 1626006833639000000ns' + self._conn.insert_lines([input_sql]) + + input_sql = f'{stb_name},t0=t c0=f,c1=L"{self.getLongName(4094, "letters")}" 1626006833639000000ns' + try: + self._conn.insert_lines([input_sql]) + raise Exception("should not reach here") + except LinesError as err: + tdSql.checkNotEqual(err.errno, 0) + + def tagColIllegalValueCheckCase(self): + + """ + test illegal tag col value + """ + self.cleanStb() + # bool + for i in ["TrUe", "tRue", "trUe", "truE", "FalsE", "fAlse", "faLse", "falSe", "falsE"]: + input_sql1 = self.genFullTypeSql(t0=i)[0] + try: + self._conn.insert_lines([input_sql1]) + raise Exception("should not reach here") + except LinesError as err: + tdSql.checkNotEqual(err.errno, 0) + input_sql2 = self.genFullTypeSql(c0=i)[0] + try: + self._conn.insert_lines([input_sql2]) + raise Exception("should not reach here") + except LinesError as err: + tdSql.checkNotEqual(err.errno, 0) + + # i8 i16 i32 i64 f32 f64 + for input_sql in [ + self.genFullTypeSql(t1="1s2i8")[0], + self.genFullTypeSql(t2="1s2i16")[0], + self.genFullTypeSql(t3="1s2i32")[0], + self.genFullTypeSql(t4="1s2i64")[0], + self.genFullTypeSql(t5="11.1s45f32")[0], + self.genFullTypeSql(t6="11.1s45f64")[0], + self.genFullTypeSql(c1="1s2i8")[0], + self.genFullTypeSql(c2="1s2i16")[0], + self.genFullTypeSql(c3="1s2i32")[0], + self.genFullTypeSql(c4="1s2i64")[0], + self.genFullTypeSql(c5="11.1s45f32")[0], + self.genFullTypeSql(c6="11.1s45f64")[0], + self.genFullTypeSql(c9="1s1u64")[0] + ]: + try: + self._conn.insert_lines([input_sql]) + raise Exception("should not reach here") + except LinesError as err: + tdSql.checkNotEqual(err.errno, 0) + + # check binary and nchar blank + stb_name = self.getLongName(7, "letters") + input_sql1 = f'{stb_name},t0=t c0=f,c1="abc aaa" 1626006833639000000ns' + input_sql2 = f'{stb_name},t0=t c0=f,c1=L"abc aaa" 1626006833639000000ns' + input_sql3 = f'{stb_name},t0=t,t1="abc aaa" c0=f 1626006833639000000ns' + input_sql4 = f'{stb_name},t0=t,t1=L"abc aaa" c0=f 1626006833639000000ns' + for input_sql in [input_sql1, input_sql2, input_sql3, input_sql4]: + try: + self._conn.insert_lines([input_sql]) + raise Exception("should not reach here") + except LinesError as err: + tdSql.checkNotEqual(err.errno, 0) + + # check accepted binary and nchar symbols + # # * ~!@#$¥%^&*()-+={}|[]、「」:; + for symbol in list('~!@#$¥%^&*()-+={}|[]、「」:;'): + input_sql1 = f'{stb_name},t0=t c0=f,c1="abc{symbol}aaa" 1626006833639000000ns' + input_sql2 = f'{stb_name},t0=t,t1="abc{symbol}aaa" c0=f 1626006833639000000ns' + self._conn.insert_lines([input_sql1]) + self._conn.insert_lines([input_sql2]) + + + def duplicateIdTagColInsertCheckCase(self): + """ + check duplicate Id Tag Col + """ + self.cleanStb() + input_sql_id = self.genFullTypeSql(id_double_tag=True)[0] + try: + self._conn.insert_lines([input_sql_id]) + raise Exception("should not reach here") + except LinesError as err: + tdSql.checkNotEqual(err.errno, 0) + + input_sql = self.genFullTypeSql()[0] + input_sql_tag = input_sql.replace("t5", "t6") + try: + self._conn.insert_lines([input_sql_tag]) + raise Exception("should not reach here") + except LinesError as err: + tdSql.checkNotEqual(err.errno, 0) + + input_sql = self.genFullTypeSql()[0] + input_sql_col = input_sql.replace("c5", "c6") + try: + self._conn.insert_lines([input_sql_col]) + raise Exception("should not reach here") + except LinesError as err: + tdSql.checkNotEqual(err.errno, 0) + + input_sql = self.genFullTypeSql()[0] + input_sql_col = input_sql.replace("c5", "C6") + try: + self._conn.insert_lines([input_sql_col]) + raise Exception("should not reach here") + except LinesError as err: + tdSql.checkNotEqual(err.errno, 0) + + ##### stb exist ##### + def noIdStbExistCheckCase(self): + """ + case no id when stb exist + """ + self.cleanStb() + input_sql, stb_name = self.genFullTypeSql(tb_name="sub_table_0123456", t0="f", c0="f") + self.resCmp(input_sql, stb_name) + input_sql, stb_name = self.genFullTypeSql(stb_name=stb_name, id_noexist_tag=True, t0="f", c0="f") + self.resCmp(input_sql, stb_name, condition='where tbname like "t_%"') + tdSql.query(f"select * from {stb_name}") + tdSql.checkRows(2) + # TODO cover other case + + def duplicateInsertExistCheckCase(self): + """ + check duplicate insert when stb exist + """ + self.cleanStb() + input_sql, stb_name = self.genFullTypeSql() + self.resCmp(input_sql, stb_name) + self._conn.insert_lines([input_sql]) + self.resCmp(input_sql, stb_name) + + def tagColBinaryNcharLengthCheckCase(self): + """ + check length increase + """ + self.cleanStb() + input_sql, stb_name = self.genFullTypeSql() + self.resCmp(input_sql, stb_name) + tb_name = self.getLongName(5, "letters") + input_sql, stb_name = self.genFullTypeSql(stb_name=stb_name, tb_name=tb_name,t7="\"binaryTagValuebinaryTagValue\"", t8="L\"ncharTagValuencharTagValue\"", c7="\"binaryTagValuebinaryTagValue\"", c8="L\"ncharTagValuencharTagValue\"") + self.resCmp(input_sql, stb_name, condition=f'where tbname like "{tb_name}"') + + def tagColAddDupIDCheckCase(self): + """ + check column and tag count add, stb and tb duplicate + * tag: alter table ... + * col: when update==0 and ts is same, unchange + * so this case tag&&value will be added, + * col is added without value when update==0 + * col is added with value when update==1 + """ + self.cleanStb() + tb_name = self.getLongName(7, "letters") + for db_update_tag in [0, 1]: + if db_update_tag == 1 : + self.createDb("test_update", db_update_tag=db_update_tag) + input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name, t0="f", c0="f") + self.resCmp(input_sql, stb_name) + self.genFullTypeSql(stb_name=stb_name, tb_name=tb_name, t0="f", c0="f", ct_add_tag=True) + if db_update_tag == 1 : + self.resCmp(input_sql, stb_name, condition=f'where tbname like "{tb_name}"') + else: + self.resCmp(input_sql, stb_name, condition=f'where tbname like "{tb_name}"', none_check_tag=True) + + def tagColAddCheckCase(self): + """ + check column and tag count add + """ + self.cleanStb() + tb_name = self.getLongName(7, "letters") + input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name, t0="f", c0="f") + self.resCmp(input_sql, stb_name) + tb_name_1 = self.getLongName(7, "letters") + input_sql, stb_name = self.genFullTypeSql(stb_name=stb_name, tb_name=tb_name_1, t0="f", c0="f", ct_add_tag=True) + self.resCmp(input_sql, stb_name, condition=f'where tbname like "{tb_name_1}"') + res_row_list = self.resHandle(f"select c10,c11,t10,t11 from {tb_name}", True)[0] + tdSql.checkEqual(res_row_list[0], ['None', 'None', 'None', 'None']) + self.resCmp(input_sql, stb_name, condition=f'where tbname like "{tb_name}"', none_check_tag=True) + + def tagMd5Check(self): + """ + condition: stb not change + insert two table, keep tag unchange, change col + """ + self.cleanStb() + input_sql, stb_name = self.genFullTypeSql(t0="f", c0="f", id_noexist_tag=True) + self.resCmp(input_sql, stb_name) + tb_name1 = self.getNoIdTbName(stb_name) + input_sql, stb_name = self.genFullTypeSql(stb_name=stb_name, t0="f", c0="f", id_noexist_tag=True) + self.resCmp(input_sql, stb_name) + tb_name2 = self.getNoIdTbName(stb_name) + tdSql.query(f"select * from {stb_name}") + tdSql.checkRows(1) + tdSql.checkEqual(tb_name1, tb_name2) + input_sql, stb_name = self.genFullTypeSql(stb_name=stb_name, t0="f", c0="f", id_noexist_tag=True, ct_add_tag=True) + self._conn.insert_lines([input_sql]) + tb_name3 = self.getNoIdTbName(stb_name) + tdSql.query(f"select * from {stb_name}") + tdSql.checkRows(2) + tdSql.checkNotEqual(tb_name1, tb_name3) + + # * tag binary max is 16384, col+ts binary max 49151 + def tagColBinaryMaxLengthCheckCase(self): + """ + every binary and nchar must be length+2 + """ + self.cleanStb() + stb_name = self.getLongName(7, "letters") + tb_name = f'{stb_name}_1' + input_sql = f'{stb_name},id="{tb_name}",t0=t c0=f 1626006833639000000ns' + self._conn.insert_lines([input_sql]) + + # * every binary and nchar must be length+2, so here is two tag, max length could not larger than 16384-2*2 + input_sql = f'{stb_name},t0=t,t1="{self.getLongName(16374, "letters")}",t2="{self.getLongName(5, "letters")}" c0=f 1626006833639000000ns' + self._conn.insert_lines([input_sql]) + + tdSql.query(f"select * from {stb_name}") + tdSql.checkRows(2) + input_sql = f'{stb_name},t0=t,t1="{self.getLongName(16374, "letters")}",t2="{self.getLongName(6, "letters")}" c0=f 1626006833639000000ns' + try: + self._conn.insert_lines([input_sql]) + raise Exception("should not reach here") + except LinesError: + pass + tdSql.query(f"select * from {stb_name}") + tdSql.checkRows(2) + + # # * check col,col+ts max in describe ---> 16143 + input_sql = f'{stb_name},t0=t c0=f,c1="{self.getLongName(16374, "letters")}",c2="{self.getLongName(16374, "letters")}",c3="{self.getLongName(16374, "letters")}",c4="{self.getLongName(12, "letters")}" 1626006833639000000ns' + self._conn.insert_lines([input_sql]) + + tdSql.query(f"select * from {stb_name}") + tdSql.checkRows(3) + input_sql = f'{stb_name},t0=t c0=f,c1="{self.getLongName(16374, "letters")}",c2="{self.getLongName(16374, "letters")}",c3="{self.getLongName(16374, "letters")}",c4="{self.getLongName(13, "letters")}" 1626006833639000000ns' + try: + self._conn.insert_lines([input_sql]) + raise Exception("should not reach here") + except LinesError as err: + tdSql.checkNotEqual(err.errno, 0) + tdSql.query(f"select * from {stb_name}") + tdSql.checkRows(3) + + # * tag nchar max is 16374/4, col+ts nchar max 49151 + def tagColNcharMaxLengthCheckCase(self): + """ + check nchar length limit + """ + self.cleanStb() + stb_name = self.getLongName(7, "letters") + tb_name = f'{stb_name}_1' + input_sql = f'{stb_name},id="{tb_name}",t0=t c0=f 1626006833639000000ns' + code = self._conn.insert_lines([input_sql]) + + # * legal nchar could not be larger than 16374/4 + input_sql = f'{stb_name},t0=t,t1=L"{self.getLongName(4093, "letters")}",t2=L"{self.getLongName(1, "letters")}" c0=f 1626006833639000000ns' + self._conn.insert_lines([input_sql]) + tdSql.query(f"select * from {stb_name}") + tdSql.checkRows(2) + input_sql = f'{stb_name},t0=t,t1=L"{self.getLongName(4093, "letters")}",t2=L"{self.getLongName(2, "letters")}" c0=f 1626006833639000000ns' + try: + self._conn.insert_lines([input_sql]) + raise Exception("should not reach here") + except LinesError as err: + tdSql.checkNotEqual(err.errno, 0) + tdSql.query(f"select * from {stb_name}") + tdSql.checkRows(2) + + input_sql = f'{stb_name},t0=t c0=f,c1=L"{self.getLongName(4093, "letters")}",c2=L"{self.getLongName(4093, "letters")}",c3=L"{self.getLongName(4093, "letters")}",c4=L"{self.getLongName(4, "letters")}" 1626006833639000000ns' + self._conn.insert_lines([input_sql]) + tdSql.query(f"select * from {stb_name}") + tdSql.checkRows(3) + input_sql = f'{stb_name},t0=t c0=f,c1=L"{self.getLongName(4093, "letters")}",c2=L"{self.getLongName(4093, "letters")}",c3=L"{self.getLongName(4093, "letters")}",c4=L"{self.getLongName(5, "letters")}" 1626006833639000000ns' + try: + self._conn.insert_lines([input_sql]) + raise Exception("should not reach here") + except LinesError as err: + tdSql.checkNotEqual(err.errno, 0) + tdSql.query(f"select * from {stb_name}") + tdSql.checkRows(3) + + def batchInsertCheckCase(self): + """ + test batch insert + """ + self.cleanStb() + stb_name = self.getLongName(8, "letters") + tdSql.execute(f'create stable {stb_name}(ts timestamp, f int) tags(t1 bigint)') + lines = ["st123456,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000ns", + "st123456,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640000000ns", + f"{stb_name},t2=5f64,t3=L\"ste\" c1=true,c2=4i64,c3=\"iam\" 1626056811823316532ns", + "stf567890,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000ns", + "st123456,t1=4i64,t2=5f64,t3=\"t4\" c1=3i64,c3=L\"passitagain\",c2=true,c4=5f64 1626006833642000000ns", + f"{stb_name},t2=5f64,t3=L\"ste2\" c3=\"iamszhou\",c4=false 1626056811843316532ns", + f"{stb_name},t2=5f64,t3=L\"ste2\" c3=\"iamszhou\",c4=false,c5=32i8,c6=64i16,c7=32i32,c8=88.88f32 1626056812843316532ns", + "st123456,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000ns", + "st123456,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641000000ns" + ] + self._conn.insert_lines(lines) + + def multiInsertCheckCase(self, count): + """ + test multi insert + """ + self.cleanStb() + sql_list = [] + stb_name = self.getLongName(8, "letters") + tdSql.execute(f'create stable {stb_name}(ts timestamp, f int) tags(t1 bigint)') + for i in range(count): + input_sql = self.genFullTypeSql(stb_name=stb_name, t7=f'"{self.getLongName(8, "letters")}"', c7=f'"{self.getLongName(8, "letters")}"', id_noexist_tag=True)[0] + sql_list.append(input_sql) + self._conn.insert_lines(sql_list) + + def batchErrorInsertCheckCase(self): + """ + test batch error insert + """ + self.cleanStb() + stb_name = self.getLongName(8, "letters") + lines = ["st123456,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000ns", + f"{stb_name},t2=5f64,t3=L\"ste\" c1=tRue,c2=4i64,c3=\"iam\" 1626056811823316532ns"] + try: + self._conn.insert_lines(lines) + raise Exception("should not reach here") + except LinesError as err: + tdSql.checkNotEqual(err.errno, 0) + + def genSqlList(self, count=5, stb_name="", tb_name=""): + """ + stb --> supertable + tb --> table + ts --> timestamp, same default + col --> column, same default + tag --> tag, same default + d --> different + s --> same + a --> add + m --> minus + """ + d_stb_d_tb_list = list() + s_stb_s_tb_list = list() + s_stb_s_tb_a_col_a_tag_list = list() + s_stb_s_tb_m_col_m_tag_list = list() + s_stb_d_tb_list = list() + s_stb_d_tb_a_col_m_tag_list = list() + s_stb_d_tb_a_tag_m_col_list = list() + s_stb_s_tb_d_ts_list = list() + s_stb_s_tb_d_ts_a_col_m_tag_list = list() + s_stb_s_tb_d_ts_a_tag_m_col_list = list() + s_stb_d_tb_d_ts_list = list() + s_stb_d_tb_d_ts_a_col_m_tag_list = list() + s_stb_d_tb_d_ts_a_tag_m_col_list = list() + for i in range(count): + d_stb_d_tb_list.append(self.genFullTypeSql(t0="f", c0="f")) + s_stb_s_tb_list.append(self.genFullTypeSql(stb_name=stb_name, tb_name=tb_name, t7=f'"{self.getLongName(8, "letters")}"', c7=f'"{self.getLongName(8, "letters")}"')) + s_stb_s_tb_a_col_a_tag_list.append(self.genFullTypeSql(stb_name=stb_name, tb_name=tb_name, t7=f'"{self.getLongName(8, "letters")}"', c7=f'"{self.getLongName(8, "letters")}"', ct_add_tag=True)) + s_stb_s_tb_m_col_m_tag_list.append(self.genFullTypeSql(stb_name=stb_name, tb_name=tb_name, t7=f'"{self.getLongName(8, "letters")}"', c7=f'"{self.getLongName(8, "letters")}"', ct_min_tag=True)) + s_stb_d_tb_list.append(self.genFullTypeSql(stb_name=stb_name, t7=f'"{self.getLongName(8, "letters")}"', c7=f'"{self.getLongName(8, "letters")}"', id_noexist_tag=True)) + s_stb_d_tb_a_col_m_tag_list.append(self.genFullTypeSql(stb_name=stb_name, t7=f'"{self.getLongName(8, "letters")}"', c7=f'"{self.getLongName(8, "letters")}"', id_noexist_tag=True, ct_am_tag=True)) + s_stb_d_tb_a_tag_m_col_list.append(self.genFullTypeSql(stb_name=stb_name, t7=f'"{self.getLongName(8, "letters")}"', c7=f'"{self.getLongName(8, "letters")}"', id_noexist_tag=True, ct_ma_tag=True)) + s_stb_s_tb_d_ts_list.append(self.genFullTypeSql(stb_name=stb_name, tb_name=tb_name, t7=f'"{self.getLongName(8, "letters")}"', c7=f'"{self.getLongName(8, "letters")}"', ts=0)) + s_stb_s_tb_d_ts_a_col_m_tag_list.append(self.genFullTypeSql(stb_name=stb_name, tb_name=tb_name, t7=f'"{self.getLongName(8, "letters")}"', c7=f'"{self.getLongName(8, "letters")}"', ts=0, ct_am_tag=True)) + s_stb_s_tb_d_ts_a_tag_m_col_list.append(self.genFullTypeSql(stb_name=stb_name, tb_name=tb_name, t7=f'"{self.getLongName(8, "letters")}"', c7=f'"{self.getLongName(8, "letters")}"', ts=0, ct_ma_tag=True)) + s_stb_d_tb_d_ts_list.append(self.genFullTypeSql(stb_name=stb_name, t7=f'"{self.getLongName(8, "letters")}"', c7=f'"{self.getLongName(8, "letters")}"', id_noexist_tag=True, ts=0)) + s_stb_d_tb_d_ts_a_col_m_tag_list.append(self.genFullTypeSql(stb_name=stb_name, t7=f'"{self.getLongName(8, "letters")}"', c7=f'"{self.getLongName(8, "letters")}"', id_noexist_tag=True, ts=0, ct_am_tag=True)) + s_stb_d_tb_d_ts_a_tag_m_col_list.append(self.genFullTypeSql(stb_name=stb_name, t7=f'"{self.getLongName(8, "letters")}"', c7=f'"{self.getLongName(8, "letters")}"', id_noexist_tag=True, ts=0, ct_ma_tag=True)) + + return d_stb_d_tb_list, s_stb_s_tb_list, s_stb_s_tb_a_col_a_tag_list, s_stb_s_tb_m_col_m_tag_list, \ + s_stb_d_tb_list, s_stb_d_tb_a_col_m_tag_list, s_stb_d_tb_a_tag_m_col_list, s_stb_s_tb_d_ts_list, \ + s_stb_s_tb_d_ts_a_col_m_tag_list, s_stb_s_tb_d_ts_a_tag_m_col_list, s_stb_d_tb_d_ts_list, \ + s_stb_d_tb_d_ts_a_col_m_tag_list, s_stb_d_tb_d_ts_a_tag_m_col_list + + + def genMultiThreadSeq(self, sql_list): + tlist = list() + for insert_sql in sql_list: + t = threading.Thread(target=self._conn.insert_lines,args=([insert_sql[0]],)) + tlist.append(t) + return tlist + + def multiThreadRun(self, tlist): + for t in tlist: + t.start() + for t in tlist: + t.join() + + def stbInsertMultiThreadCheckCase(self): + """ + thread input different stb + """ + self.cleanStb() + input_sql = self.genSqlList()[0] + self.multiThreadRun(self.genMultiThreadSeq(input_sql)) + tdSql.query(f"show tables;") + tdSql.checkRows(5) + + def sStbStbDdataInsertMultiThreadCheckCase(self): + """ + thread input same stb tb, different data, result keep first data + """ + self.cleanStb() + tb_name = self.getLongName(7, "letters") + input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name) + self.resCmp(input_sql, stb_name) + s_stb_s_tb_list = self.genSqlList(stb_name=stb_name, tb_name=tb_name)[1] + self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_list)) + tdSql.query(f"show tables;") + tdSql.checkRows(1) + expected_tb_name = self.getNoIdTbName(stb_name)[0] + tdSql.checkEqual(tb_name, expected_tb_name) + tdSql.query(f"select * from {stb_name};") + tdSql.checkRows(1) + + def sStbStbDdataAtcInsertMultiThreadCheckCase(self): + """ + thread input same stb tb, different data, add columes and tags, result keep first data + """ + self.cleanStb() + tb_name = self.getLongName(7, "letters") + input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name) + self.resCmp(input_sql, stb_name) + s_stb_s_tb_a_col_a_tag_list = self.genSqlList(stb_name=stb_name, tb_name=tb_name)[2] + self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_a_col_a_tag_list)) + tdSql.query(f"show tables;") + tdSql.checkRows(1) + expected_tb_name = self.getNoIdTbName(stb_name)[0] + tdSql.checkEqual(tb_name, expected_tb_name) + tdSql.query(f"select * from {stb_name};") + tdSql.checkRows(1) + + def sStbStbDdataMtcInsertMultiThreadCheckCase(self): + """ + thread input same stb tb, different data, minus columes and tags, result keep first data + """ + self.cleanStb() + tb_name = self.getLongName(7, "letters") + input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name) + self.resCmp(input_sql, stb_name) + s_stb_s_tb_m_col_m_tag_list = self.genSqlList(stb_name=stb_name, tb_name=tb_name)[3] + self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_m_col_m_tag_list)) + tdSql.query(f"show tables;") + tdSql.checkRows(1) + expected_tb_name = self.getNoIdTbName(stb_name)[0] + tdSql.checkEqual(tb_name, expected_tb_name) + tdSql.query(f"select * from {stb_name};") + tdSql.checkRows(1) + + def sStbDtbDdataInsertMultiThreadCheckCase(self): + """ + thread input same stb, different tb, different data + """ + self.cleanStb() + input_sql, stb_name = self.genFullTypeSql() + self.resCmp(input_sql, stb_name) + s_stb_d_tb_list = self.genSqlList(stb_name=stb_name)[4] + self.multiThreadRun(self.genMultiThreadSeq(s_stb_d_tb_list)) + tdSql.query(f"show tables;") + tdSql.checkRows(6) + + def sStbDtbDdataAcMtInsertMultiThreadCheckCase(self): + """ + thread input same stb, different tb, different data, add col, mul tag + """ + self.cleanStb() + input_sql, stb_name = self.genFullTypeSql() + self.resCmp(input_sql, stb_name) + # s_stb_d_tb_a_col_m_tag_list = self.genSqlList(stb_name=stb_name)[5] + s_stb_d_tb_a_col_m_tag_list = [(f'{stb_name},t0=F,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64 c0=t,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7="ngxgzdzs",c8=L"ncharColValue",c9=7u64,c11=L"ncharColValue",c10=F 1626006833639000000ns', 'hpxbys'), \ + (f'{stb_name},t0=True,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64 c0=T,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7="vvfrdtty",c8=L"ncharColValue",c9=7u64,c11=L"ncharColValue",c10=True 1626006833639000000ns', 'hpxbys'), \ + (f'{stb_name},t0=f,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64 c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7="kzscucnt",c8=L"ncharColValue",c9=7u64,c11=L"ncharColValue",c10=f 1626006833639000000ns', 'hpxbys'), \ + (f'{stb_name},t0=false,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64 c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7="asegdbqk",c8=L"ncharColValue",c9=7u64,c11=L"ncharColValue",c10=false 1626006833639000000ns', 'hpxbys'), \ + (f'{stb_name},t0=T,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64 c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7="yvqnhgmn",c8=L"ncharColValue",c9=7u64,c11=L"ncharColValue",c10=T 1626006833639000000ns', 'hpxbys')] + self.multiThreadRun(self.genMultiThreadSeq(s_stb_d_tb_a_col_m_tag_list)) + tdSql.query(f"show tables;") + tdSql.checkRows(3) + + def sStbDtbDdataAtMcInsertMultiThreadCheckCase(self): + """ + thread input same stb, different tb, different data, add tag, mul col + """ + self.cleanStb() + input_sql, stb_name = self.genFullTypeSql() + self.resCmp(input_sql, stb_name) + s_stb_d_tb_a_tag_m_col_list = self.genSqlList(stb_name=stb_name)[6] + self.multiThreadRun(self.genMultiThreadSeq(s_stb_d_tb_a_tag_m_col_list)) + tdSql.query(f"show tables;") + tdSql.checkRows(6) + + def sStbStbDdataDtsInsertMultiThreadCheckCase(self): + """ + thread input same stb tb, different ts + """ + self.cleanStb() + tb_name = self.getLongName(7, "letters") + input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name) + self.resCmp(input_sql, stb_name) + # s_stb_s_tb_d_ts_list = self.genSqlList(stb_name=stb_name, tb_name=tb_name)[7] + s_stb_s_tb_d_ts_list =[(f'{stb_name},id="{tb_name}",t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="tgqkvsws",t8=L"ncharTagValue" c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7="htvnnldm",c8=L"ncharColValue",c9=7u64 0', 'sfzqdz'), \ + (f'{stb_name},id="{tb_name}",t0=f,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="fvrhhqiy",t8=L"ncharTagValue" c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7="gybqvhos",c8=L"ncharColValue",c9=7u64 0', 'sfzqdz'), \ + (f'{stb_name},id="{tb_name}",t0=f,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="vifkabhu",t8=L"ncharTagValue" c0=t,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7="zlvxgquy",c8=L"ncharColValue",c9=7u64 0', 'sfzqdz'), \ + (f'{stb_name},id="{tb_name}",t0=True,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="lsyotcrn",t8=L"ncharTagValue" c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7="oaupfgtz",c8=L"ncharColValue",c9=7u64 0', 'sfzqdz'), \ + (f'{stb_name},id="{tb_name}",t0=T,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="jrwamcgy",t8=L"ncharTagValue" c0=F,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7="vgzadjsh",c8=L"ncharColValue",c9=7u64 0', 'sfzqdz')] + self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_d_ts_list)) + tdSql.query(f"show tables;") + tdSql.checkRows(1) + # ! Small probability bug ---> temporarily delete it + # tdSql.query(f"select * from {stb_name}") + # tdSql.checkRows(6) + + def sStbStbDdataDtsAcMtInsertMultiThreadCheckCase(self): + """ + thread input same stb tb, different ts, add col, mul tag + """ + self.cleanStb() + tb_name = self.getLongName(7, "letters") + input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name) + self.resCmp(input_sql, stb_name) + s_stb_s_tb_d_ts_a_col_m_tag_list = self.genSqlList(stb_name=stb_name, tb_name=tb_name)[8] + self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_d_ts_a_col_m_tag_list)) + tdSql.query(f"show tables;") + tdSql.checkRows(1) + tdSql.query(f"select * from {stb_name}") + tdSql.checkRows(6) + tdSql.query(f"select * from {stb_name} where t8 is not NULL") + tdSql.checkRows(6) + tdSql.query(f"select * from {tb_name} where c11 is not NULL;") + tdSql.checkRows(5) + + def sStbStbDdataDtsAtMcInsertMultiThreadCheckCase(self): + """ + thread input same stb tb, different ts, add tag, mul col + """ + self.cleanStb() + tb_name = self.getLongName(7, "letters") + input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name) + self.resCmp(input_sql, stb_name) + # s_stb_s_tb_d_ts_a_tag_m_col_list = self.genSqlList(stb_name=stb_name, tb_name=tb_name)[9] + s_stb_s_tb_d_ts_a_tag_m_col_list = [(f'{stb_name},id="{tb_name}",t0=T,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="xsajdfjc",t8=L"ncharTagValue",t11=127i8,t10=L"ncharTagValue" c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64 0', 'rgqcfb'), \ + (f'{stb_name},id="{tb_name}",t0=true,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="qzeyolgt",t8=L"ncharTagValue",t11=127i8,t10=L"ncharTagValue" c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64 0', 'rgqcfb'), \ + (f'{stb_name},id="{tb_name}",t0=False,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="suxqziwh",t8=L"ncharTagValue",t11=127i8,t10=L"ncharTagValue" c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64 0', 'rgqcfb'), \ + (f'{stb_name},id="{tb_name}",t0=false,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="vapolpgr",t8=L"ncharTagValue",t11=127i8,t10=L"ncharTagValue" c0=t,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64 0', 'rgqcfb'), \ + (f'{stb_name},id="{tb_name}",t0=F,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="eustwpfl",t8=L"ncharTagValue",t11=127i8,t10=L"ncharTagValue" c0=t,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64 0', 'rgqcfb')] + self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_d_ts_a_tag_m_col_list)) + tdSql.query(f"show tables;") + tdSql.checkRows(1) + tdSql.query(f"select * from {stb_name}") + tdSql.checkRows(6) + for c in ["c7", "c8", "c9"]: + tdSql.query(f"select * from {stb_name} where {c} is NULL") + tdSql.checkRows(5) + for t in ["t10", "t11"]: + tdSql.query(f"select * from {stb_name} where {t} is not NULL;") + tdSql.checkRows(0) + + def sStbDtbDdataDtsInsertMultiThreadCheckCase(self): + """ + thread input same stb, different tb, data, ts + """ + self.cleanStb() + input_sql, stb_name = self.genFullTypeSql() + self.resCmp(input_sql, stb_name) + s_stb_d_tb_d_ts_list = self.genSqlList(stb_name=stb_name)[10] + self.multiThreadRun(self.genMultiThreadSeq(s_stb_d_tb_d_ts_list)) + tdSql.query(f"show tables;") + tdSql.checkRows(6) + + def sStbDtbDdataDtsAcMtInsertMultiThreadCheckCase(self): + """ + thread input same stb, different tb, data, ts, add col, mul tag + """ + self.cleanStb() + input_sql, stb_name = self.genFullTypeSql() + self.resCmp(input_sql, stb_name) + # s_stb_d_tb_d_ts_a_col_m_tag_list = self.genSqlList(stb_name=stb_name)[11] + s_stb_d_tb_d_ts_a_col_m_tag_list = [(f'{stb_name},t0=True,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64 c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7="eltflgpz",c8=L"ncharColValue",c9=7u64,c11=L"ncharColValue",c10=True 0', 'ynnlov'), \ + (f'{stb_name},t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64 c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7="ysznggwl",c8=L"ncharColValue",c9=7u64,c11=L"ncharColValue",c10=t 0', 'ynnlov'), \ + (f'{stb_name},t0=f,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64 c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7="nxwjucch",c8=L"ncharColValue",c9=7u64,c11=L"ncharColValue",c10=f 0', 'ynnlov'), \ + (f'{stb_name},t0=F,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64 c0=T,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7="fzseicnt",c8=L"ncharColValue",c9=7u64,c11=L"ncharColValue",c10=F 0', 'ynnlov'), \ + (f'{stb_name},t0=False,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64 c0=F,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7="zwgurhdp",c8=L"ncharColValue",c9=7u64,c11=L"ncharColValue",c10=False 0', 'ynnlov')] + self.multiThreadRun(self.genMultiThreadSeq(s_stb_d_tb_d_ts_a_col_m_tag_list)) + tdSql.query(f"show tables;") + tdSql.checkRows(3) + + def test(self): + input_sql1 = "rfasta,id=\"rfasta_1\",t0=true,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"ddzhiksj\",t8=L\"ncharTagValue\" c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"bnhwlgvj\",c8=L\"ncharTagValue\",c9=7u64 1626006933640000000ns" + input_sql2 = "rfasta,id=\"rfasta_1\",t0=true,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64 c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64 1626006933640000000ns" + try: + self._conn.insert_lines([input_sql1]) + self._conn.insert_lines([input_sql2]) + except LinesError as err: + print(err.errno) + # self._conn.insert_lines([input_sql2]) + # input_sql3 = f'abcd,id="cc¥Ec",t0=True,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="ndsfdrum",t8=L"ncharTagValue" c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7="igwoehkm",c8=L"ncharColValue",c9=7u64 0' + # print(input_sql3) + # input_sql4 = 'hmemeb,id="kilrcrldgf",t0=F,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="fysodjql",t8=L"ncharTagValue" c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7="waszbfvc",c8=L"ncharColValue",c9=7u64 0' + # code = self._conn.insert_lines([input_sql3]) + # print(code) + # self._conn.insert_lines([input_sql4]) + + def runAll(self): + self.initCheckCase() + self.boolTypeCheckCase() + self.symbolsCheckCase() + self.tsCheckCase() + self.idSeqCheckCase() + self.idUpperCheckCase() + self.noIdCheckCase() + self.maxColTagCheckCase() + self.idIllegalNameCheckCase() + self.idStartWithNumCheckCase() + self.nowTsCheckCase() + self.dateFormatTsCheckCase() + self.illegalTsCheckCase() + self.tagValueLengthCheckCase() + self.colValueLengthCheckCase() + self.tagColIllegalValueCheckCase() + self.duplicateIdTagColInsertCheckCase() + self.noIdStbExistCheckCase() + self.duplicateInsertExistCheckCase() + self.tagColBinaryNcharLengthCheckCase() + self.tagColAddDupIDCheckCase() + self.tagColAddCheckCase() + self.tagMd5Check() + self.tagColBinaryMaxLengthCheckCase() + self.tagColNcharMaxLengthCheckCase() + self.batchInsertCheckCase() + self.multiInsertCheckCase(1000) + self.batchErrorInsertCheckCase() + # MultiThreads + self.stbInsertMultiThreadCheckCase() + self.sStbStbDdataInsertMultiThreadCheckCase() + self.sStbStbDdataAtcInsertMultiThreadCheckCase() + self.sStbStbDdataMtcInsertMultiThreadCheckCase() + self.sStbDtbDdataInsertMultiThreadCheckCase() + + # # ! concurrency conflict + self.sStbDtbDdataAcMtInsertMultiThreadCheckCase() + self.sStbDtbDdataAtMcInsertMultiThreadCheckCase() + + self.sStbStbDdataDtsInsertMultiThreadCheckCase() + + # # ! concurrency conflict + self.sStbStbDdataDtsAcMtInsertMultiThreadCheckCase() + self.sStbStbDdataDtsAtMcInsertMultiThreadCheckCase() + + self.sStbDtbDdataDtsInsertMultiThreadCheckCase() + + # ! concurrency conflict + self.sStbDtbDdataDtsAcMtInsertMultiThreadCheckCase() + + + + def run(self): + print("running {}".format(__file__)) + self.createDb() + try: + self.runAll() + except Exception as err: + print(''.join(traceback.format_exception(None, err, err.__traceback__))) + raise err + # self.tagColIllegalValueCheckCase() + # self.test() + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/smallint.py b/tests/pytest/insert/smallint.py new file mode 100644 index 0000000000000000000000000000000000000000..16322e9aeb801ae92b75b920922991206a4b2e35 --- /dev/null +++ b/tests/pytest/insert/smallint.py @@ -0,0 +1,106 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdLog.info('=============== step1') + tdLog.info('create table tb (ts timestamp, speed smallint)') + tdSql.execute('create table tb (ts timestamp, speed smallint)') + tdLog.info("insert into tb values (now, NULL)") + tdSql.execute("insert into tb values (now, NULL)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + tdLog.info('tdSql.checkData(0, 1, null)') + tdSql.checkData(0, 1, None) + tdLog.info('=============== step2') + tdLog.info("insert into tb values (now+1m, -32768) -x step2") + tdSql.error("insert into tb values (now+1m, -32768)") + tdLog.info("insert into tb values (now+1m, NULL)") + tdSql.execute("insert into tb values (now+1m, NULL)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(2)') + tdSql.checkRows(2) + tdLog.info('tdSql.checkData(0, 1, null)') + tdSql.checkData(0, 1, None) + tdLog.info('=============== step3') + tdLog.info("insert into tb values (now+2m, 32767)") + tdSql.execute("insert into tb values (now+2m, 32767)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(3)') + tdSql.checkRows(3) + tdLog.info('tdSql.checkData(0, 1, 32767)') + tdSql.checkData(0, 1, 32767) + tdLog.info('=============== step4') + tdLog.info("insert into tb values (now+3m, 32768) -x step4") + tdSql.error("insert into tb values (now+3m, 32768)") + tdLog.info("insert into tb values (now+3m, NULL)") + tdSql.execute("insert into tb values (now+3m, NULL)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(4)') + tdSql.checkRows(4) + tdLog.info('tdSql.checkData(0, 1, null)') + tdSql.checkData(0, 1, None) + tdLog.info('=============== step5') + tdLog.info("insert into tb values (now+4m, a2)") + tdSql.error("insert into tb values (now+4m, a2)") + tdLog.info("insert into tb values (now+4m, 0)") + tdSql.execute("insert into tb values (now+4m, 0)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + tdLog.info('tdSql.checkData(0, 1, 0)') + tdSql.checkData(0, 1, 0) + tdLog.info('=============== step6') + tdLog.info("insert into tb values (now+5m, 2a)") + tdSql.error("insert into tb values (now+5m, 2a)") + tdLog.info("insert into tb values (now+5m, 2)") + tdSql.execute("insert into tb values (now+5m, 2)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(6)') + tdSql.checkRows(6) + tdLog.info('tdSql.checkData(0, 1, 2)') + tdSql.checkData(0, 1, 2) + tdLog.info('=============== step7') + tdLog.info("insert into tb values (now+6m, 2a'1)") + tdSql.error("insert into tb values (now+6m, 2a'1)") + tdLog.info("insert into tb values (now+6m, 2)") + tdSql.execute("insert into tb values (now+6m, 2)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(7)') + tdSql.checkRows(7) + tdLog.info('tdSql.checkData(0, 1, 2)') + tdSql.checkData(0, 1, 2) + tdLog.info('drop database db') + tdSql.execute('drop database db') + tdLog.info('show databases') + tdSql.query('show databases') + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/sparseData.py b/tests/pytest/insert/sparseData.py new file mode 100644 index 0000000000000000000000000000000000000000..38b04b339efd2b3b465f0ff80812c627dd3826d8 --- /dev/null +++ b/tests/pytest/insert/sparseData.py @@ -0,0 +1,67 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys + +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdLog.info("=============== step1") + tdSql.execute( + 'create table tb (ts timestamp, speed int, temp float, note binary(4000), flag bool)') + + numOfRecords = 1000000 + dividend = 1000 + tdLog.info("will insert %d records" % numOfRecords) + + ts = 1500000000000 + for i in range(0, numOfRecords): + + if (i % dividend): + print(".", end="") + tdSql.execute( + 'insert into tb values (%d + %da, NULL, NULL, NULL, TRUE)' % + (ts, i)) + else: + print("a", end="") + tdSql.execute( + 'insert into tb values (%d + %da, NULL, NULL, "a", FALSE)' % + (ts, i)) + + tdSql.query("select * from tb") + tdSql.checkRows(numOfRecords) + tdSql.checkData(numOfRecords - dividend, 3, 'a') + tdSql.checkData(numOfRecords - dividend - 1, 3, None) + + tdLog.info("stop dnode to commit data to disk") + tdDnodes.stop(1) + tdLog.info("dnodes:%d size is %d" % (1, tdDnodes.getDataSize(1))) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/specialSql.py b/tests/pytest/insert/specialSql.py new file mode 100644 index 0000000000000000000000000000000000000000..908c14ead9d9d600221ecb662d226495e370e582 --- /dev/null +++ b/tests/pytest/insert/specialSql.py @@ -0,0 +1,48 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys + +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdLog.info("=============== step1") + tdSql.execute( + 'create stable properties_asch5snuykd (ts timestamp, create_time timestamp, number_value double, value int) tags (device_id nchar(8), property nchar(8))' + ) + tdSql.execute( + "insert into\n\t\t \n\t\t\tdb.properties_b86ca7d11556e0fdd43fd12ac08651f9 using db.properties_asch5snuykd\n\t\t\t(\n\t\t\t \n\t\t\t\tdevice_id\n\t\t\t , \n\t\t\t\tproperty\n\t\t\t \n\t\t\t)\n\t\t\ttags\n\t\t\t(\n\t\t\t \n\t\t\t\t'dev1'\n\t\t\t , \n\t\t\t\t'pres'\n\t\t\t \n\t\t\t)\n\t\t\t(\n\t\t\t \n\t\t\t\tts\n\t\t\t , \n\t\t\t\tcreate_time\n\t\t\t , \n\t\t\t\tnumber_value\n\t\t\t , \n\t\t\t\tvalue\n\t\t\t \n\t\t\t)\n\t\t\tvalues\n\t\t\t \n\t\t\t\t(\n\t\t\t\t \n\t\t\t\t\t1629443494659\n\t\t\t\t , \n\t\t\t\t\t1629443494660\n\t\t\t\t , \n\t\t\t\t\t-1000.0\n\t\t\t\t , \n\t\t\t\t\t'-1000'\n\t\t\t\t \n\t\t\t\t)\n;" + ) + + tdSql.query( + "select * from db.properties_b86ca7d11556e0fdd43fd12ac08651f9") + tdSql.checkRows(1) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/special_character_show.py b/tests/pytest/insert/special_character_show.py new file mode 100644 index 0000000000000000000000000000000000000000..3b2df5c87380c22fb18cbee06c866249b4365a70 --- /dev/null +++ b/tests/pytest/insert/special_character_show.py @@ -0,0 +1,59 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + # test case for https://jira.taosdata.com:18080/browse/TD-4584 + + #1 + tdLog.info('=============== step1,create stable') + tdLog.info('create table stb1 (ts timestamp, value double) tags (bin binary(128))') + tdSql.execute('create table stb1 (ts timestamp, value double) tags (bin binary(128))') + + tdLog.info('=============== step2,create table增加了转义字符') + tdLog.info('create table tb1 using stb1 tags("abc\\"def")') + #增加了转义字符\ + tdSql.execute('create table tb1 using stb1 tags("abc\\"def")') + + tdLog.info('=============== step3,insert data') + tdLog.info('insert into tb1 values(now,1.0)') + tdSql.execute('insert into tb1 values(now,1.0)') + + tdLog.info('=============== step4,select table') + tdLog.info('select * from stb1 ') + tdSql.query('select * from stb1 ') + + tdLog.info('=============== step5,check data') + tdSql.checkData(0,2,'abc"def') + + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/tagSepcified.py b/tests/pytest/insert/tagSepcified.py new file mode 100644 index 0000000000000000000000000000000000000000..213cf119a0d4f13756c7931aeb79b241250dbf06 --- /dev/null +++ b/tests/pytest/insert/tagSepcified.py @@ -0,0 +1,49 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdSql.execute('create table xcxlog (ts timestamp, user_id int, path BINARY(40),scene int) tags(appid bigint, adzone_id int,ip bigint,session_id bigint)') + tdSql.error("insert into d1000004(user_id,path,scene,ts) using xcxlog tags(1000004,145,97160) values (97160,'pagex/goods/taoke',1086,now)") + tdSql.execute("insert into d1000004_145(user_id,path,scene,ts) using xcxlog(appid,adzone_id,session_id,ip) tags(1000004,145,97160,1717171445) values (97160,'pagex/goods/taoke',1086,now)") + + tdSql.query("show tables") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 'd1000004_145') + + tdSql.query("select * from xcxlog") + tdSql.checkRows(1) + tdSql.checkData(0, 4, 1000004) + tdSql.checkData(0, 5, 145) + tdSql.checkData(0, 6, 1717171445) + tdSql.checkData(0, 7, 97160) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/timestamp.py b/tests/pytest/insert/timestamp.py new file mode 100644 index 0000000000000000000000000000000000000000..4c9cf36f40e31a792b550a557937d25d968f4fe2 --- /dev/null +++ b/tests/pytest/insert/timestamp.py @@ -0,0 +1,81 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys + +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self.ts = 1607281690000 + + def run(self): + tdSql.prepare() + + # TS-806 + tdLog.info("test case for TS-806") + + # Case 1 + tdSql.execute("create table t1(ts timestamp, c1 int)") + tdSql.execute("insert into t1(c1, ts) values(1, %d)" % self.ts) + tdSql.query("select * from t1") + tdSql.checkRows(1) + + # Case 2 + tdSql.execute("insert into t1(c1, ts) values(2, %d)(3, %d)" % (self.ts + 1000, self.ts + 2000)) + tdSql.query("select * from t1") + tdSql.checkRows(3) + + # Case 3 + tdSql.execute("create table t2(ts timestamp, c1 timestamp)") + tdSql.execute(" insert into t2(c1, ts) values(%d, %d)" % (self.ts, self.ts + 5000)) + tdSql.query("select * from t2") + tdSql.checkRows(1) + + tdSql.execute(" insert into t2(c1, ts) values(%d, %d)(%d, %d)" % (self.ts, self.ts + 6000, self.ts + 3000, self.ts + 8000)) + tdSql.query("select * from t2") + tdSql.checkRows(3) + + # Case 4 + tdSql.execute("create table stb(ts timestamp, c1 int, c2 binary(20)) tags(tstag timestamp, t1 int)") + tdSql.execute("insert into tb1(c2, ts, c1) using stb(t1, tstag) tags(1, now) values('test', %d, 1)" % self.ts) + tdSql.query("select * from stb") + tdSql.checkRows(1) + + # Case 5 + tdSql.execute("insert into tb1(c2, ts, c1) using stb(t1, tstag) tags(1, now) values('test', now, 1) tb2(c1, ts) using stb tags(now + 2m, 1000) values(1, now - 1h)") + tdSql.query("select * from stb") + tdSql.checkRows(3) + + tdSql.execute(" insert into tb1(c2, ts, c1) using stb(t1, tstag) tags(1, now) values('test', now + 10s, 1) tb2(c1, ts) using stb(tstag) tags(now + 2m) values(1, now - 3h)(2, now - 2h)") + tdSql.query("select * from stb") + tdSql.checkRows(6) + + # Case 6 + tdSql.execute("create table stb2 (ts timestamp, c1 timestamp, c2 timestamp) tags(t1 timestamp, t2 timestamp)") + tdSql.execute(" insert into tb4(c1, c2, ts) using stb2(t2, t1) tags(now, now + 1h) values(now + 1s, now + 2s, now + 3s)(now -1s, now - 2s, now - 3s) tb5(c2, ts, c1) using stb2(t2) tags(now + 1h) values(now, now, now)") + tdSql.query("select * from stb2") + tdSql.checkRows(3) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/tinyint.py b/tests/pytest/insert/tinyint.py new file mode 100644 index 0000000000000000000000000000000000000000..a10c999e8c2f0fe070347651f9246e3734104eca --- /dev/null +++ b/tests/pytest/insert/tinyint.py @@ -0,0 +1,106 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdLog.info('=============== step1') + tdLog.info('create table tb (ts timestamp, speed tinyint)') + tdSql.execute('create table tb (ts timestamp, speed tinyint)') + tdLog.info("insert into tb values (now, NULL)") + tdSql.execute("insert into tb values (now, NULL)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + tdLog.info('tdSql.checkData(0, 1, null)') + tdSql.checkData(0, 1, None) + tdLog.info('=============== step2') + tdLog.info("insert into tb values (now+1m, -128) -x step2") + tdSql.error("insert into tb values (now+1m, -128) ") + tdLog.info("insert into tb values (now+1m, NULL)") + tdSql.execute("insert into tb values (now+1m, NULL)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(2)') + tdSql.checkRows(2) + tdLog.info('tdSql.checkData(0, 1, null)') + tdSql.checkData(0, 1, None) + tdLog.info('=============== step3') + tdLog.info("insert into tb values (now+2m, 127)") + tdSql.execute("insert into tb values (now+2m, 127)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(3)') + tdSql.checkRows(3) + tdLog.info('tdSql.checkData(0, 1, 127)') + tdSql.checkData(0, 1, 127) + tdLog.info('=============== step4') + tdLog.info("insert into tb values (now+3m, 128) -x step4") + tdSql.error("insert into tb values (now+3m, 128)") + tdLog.info("insert into tb values (now+3m, NULL)") + tdSql.execute("insert into tb values (now+3m, NULL)") + tdLog.info('select * from tb') + tdSql.query('select * from tb') + tdLog.info('tdSql.checkRow(4)') + tdSql.checkRows(4) + tdLog.info('tdSql.checkData(0, 1, null)') + tdSql.checkData(0, 1, None) + tdLog.info('=============== step5') + tdLog.info("insert into tb values (now+4m, a2)") + tdSql.error("insert into tb values (now+4m, a2)") + tdLog.info("insert into tb values (now+4m, 0)") + tdSql.execute("insert into tb values (now+4m, 0)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + tdLog.info('tdSql.checkData(0, 1, 0)') + tdSql.checkData(0, 1, 0) + tdLog.info('=============== step6') + tdLog.info("insert into tb values (now+5m, 2a)") + tdSql.error("insert into tb values (now+5m, 2a)") + tdLog.info("insert into tb values (now+5m, 2)") + tdSql.execute("insert into tb values (now+5m, 2)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(6)') + tdSql.checkRows(6) + tdLog.info('tdSql.checkData(0, 1, 2)') + tdSql.checkData(0, 1, 2) + tdLog.info('=============== step7') + tdLog.info("insert into tb values (now+6m, 2a'1)") + tdSql.error("insert into tb values (now+6m, 2a'1)") + tdLog.info("insert into tb values (now+6m, 2)") + tdSql.execute("insert into tb values (now+6m, 2)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(7)') + tdSql.checkRows(7) + tdLog.info('tdSql.checkData(0, 1, 2)') + tdSql.checkData(0, 1, 2) + tdLog.info('drop database db') + tdSql.execute('drop database db') + tdLog.info('show databases') + tdSql.query('show databases') + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/unsignedBigint.py b/tests/pytest/insert/unsignedBigint.py new file mode 100644 index 0000000000000000000000000000000000000000..b222f2cd0195e14fddf1f10662447cef97f0e841 --- /dev/null +++ b/tests/pytest/insert/unsignedBigint.py @@ -0,0 +1,108 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdLog.info('=============== step1') + tdLog.info('create table tb (ts timestamp, speed bigint unsigned)') + tdSql.execute('create table tb (ts timestamp, speed bigint unsigned)') + tdLog.info("insert into tb values (now, NULL)") + tdSql.execute("insert into tb values (now, NULL)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + tdLog.info('tdSql.checkData(0, 1, null)') + tdSql.checkData(0, 1, None) + tdLog.info('=============== step2') + tdLog.info("insert into tb values (now+1m, -1) -x step2") + tdSql.error("insert into tb values (now+1m, -1) ") + tdLog.info("insert into tb values (now+1m, NULL)") + tdSql.execute("insert into tb values (now+1m, NULL)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(2)') + tdSql.checkRows(2) + tdLog.info('tdSql.checkData(0, 1, null)') + tdSql.checkData(0, 1, None) + tdLog.info('=============== step3') + tdLog.info("insert into tb values (now+2m, 18446744073709551614)") + tdSql.execute("insert into tb values (now+2m, 18446744073709551614)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(3)') + tdSql.checkRows(3) + tdLog.info('tdSql.checkData(0, 1, 18446744073709551614)') + tdSql.checkData(0, 1, 18446744073709551614) + tdLog.info('=============== step4') + tdLog.info("insert into tb values (now+3m, 18446744073709551615) -x step4") + tdSql.error("insert into tb values (now+3m, 18446744073709551615)") + tdLog.info("insert into tb values (now+3m, NULL)") + tdSql.execute("insert into tb values (now+3m, NULL)") + tdLog.info('select * from tb') + tdSql.query('select * from tb') + tdLog.info('tdSql.checkRow(4)') + tdSql.checkRows(4) + tdLog.info('tdSql.checkData(0, 1, null)') + tdSql.checkData(0, 1, None) + tdLog.info('=============== step5') + tdLog.info("insert into tb values (now+4m, a2)") + tdSql.error("insert into tb values (now+4m, a2)") + tdLog.info("insert into tb values (now-4m, -1)") + tdSql.error("insert into tb values (now-4m, -1)") + tdLog.info("insert into tb values (now+4m, 0)") + tdSql.execute("insert into tb values (now+4m, 0)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + tdLog.info('tdSql.checkData(0, 1, 0)') + tdSql.checkData(0, 1, 0) + tdLog.info('=============== step6') + tdLog.info("insert into tb values (now+5m, 2a)") + tdSql.error("insert into tb values (now+5m, 2a)") + tdLog.info("insert into tb values (now+5m, 2)") + tdSql.execute("insert into tb values (now+5m, 2)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(6)') + tdSql.checkRows(6) + tdLog.info('tdSql.checkData(0, 1, 2)') + tdSql.checkData(0, 1, 2) + tdLog.info('=============== step7') + tdLog.info("insert into tb values (now+6m, 2a'1)") + tdSql.error("insert into tb values (now+6m, 2a'1)") + tdLog.info("insert into tb values (now+6m, 2)") + tdSql.execute("insert into tb values (now+6m, 2)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(7)') + tdSql.checkRows(7) + tdLog.info('tdSql.checkData(0, 1, 2)') + tdSql.checkData(0, 1, 2) + tdLog.info('drop database db') + tdSql.execute('drop database db') + tdLog.info('show databases') + tdSql.query('show databases') + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/unsignedInt.py b/tests/pytest/insert/unsignedInt.py new file mode 100644 index 0000000000000000000000000000000000000000..ed18999bc415022da34788a79e9045a5f67cf8ee --- /dev/null +++ b/tests/pytest/insert/unsignedInt.py @@ -0,0 +1,108 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdLog.info('=============== step1') + tdLog.info('create table tb (ts timestamp, speed int unsigned)') + tdSql.execute('create table tb (ts timestamp, speed int unsigned)') + tdLog.info("insert into tb values (now, NULL)") + tdSql.execute("insert into tb values (now, NULL)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + tdLog.info('tdSql.checkData(0, 1, null)') + tdSql.checkData(0, 1, None) + tdLog.info('=============== step2') + tdLog.info("insert into tb values (now+1m, -1) -x step2") + tdSql.error("insert into tb values (now+1m, -1) ") + tdLog.info("insert into tb values (now+1m, NULL)") + tdSql.execute("insert into tb values (now+1m, NULL)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(2)') + tdSql.checkRows(2) + tdLog.info('tdSql.checkData(0, 1, null)') + tdSql.checkData(0, 1, None) + tdLog.info('=============== step3') + tdLog.info("insert into tb values (now+2m, 4294967294)") + tdSql.execute("insert into tb values (now+2m, 4294967294)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(3)') + tdSql.checkRows(3) + tdLog.info('tdSql.checkData(0, 1, 4294967294)') + tdSql.checkData(0, 1, 4294967294) + tdLog.info('=============== step4') + tdLog.info("insert into tb values (now+3m, 4294967295) -x step4") + tdSql.error("insert into tb values (now+3m, 4294967295)") + tdLog.info("insert into tb values (now+3m, NULL)") + tdSql.execute("insert into tb values (now+3m, NULL)") + tdLog.info('select * from tb') + tdSql.query('select * from tb') + tdLog.info('tdSql.checkRow(4)') + tdSql.checkRows(4) + tdLog.info('tdSql.checkData(0, 1, null)') + tdSql.checkData(0, 1, None) + tdLog.info('=============== step5') + tdLog.info("insert into tb values (now+4m, a2)") + tdSql.error("insert into tb values (now+4m, a2)") + tdLog.info("insert into tb values (now-4m, -1)") + tdSql.error("insert into tb values (now-4m, -1)") + tdLog.info("insert into tb values (now+4m, 0)") + tdSql.execute("insert into tb values (now+4m, 0)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + tdLog.info('tdSql.checkData(0, 1, 0)') + tdSql.checkData(0, 1, 0) + tdLog.info('=============== step6') + tdLog.info("insert into tb values (now+5m, 2a)") + tdSql.error("insert into tb values (now+5m, 2a)") + tdLog.info("insert into tb values (now+5m, 2)") + tdSql.execute("insert into tb values (now+5m, 2)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(6)') + tdSql.checkRows(6) + tdLog.info('tdSql.checkData(0, 1, 2)') + tdSql.checkData(0, 1, 2) + tdLog.info('=============== step7') + tdLog.info("insert into tb values (now+6m, 2a'1)") + tdSql.error("insert into tb values (now+6m, 2a'1)") + tdLog.info("insert into tb values (now+6m, 2)") + tdSql.execute("insert into tb values (now+6m, 2)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(7)') + tdSql.checkRows(7) + tdLog.info('tdSql.checkData(0, 1, 2)') + tdSql.checkData(0, 1, 2) + tdLog.info('drop database db') + tdSql.execute('drop database db') + tdLog.info('show databases') + tdSql.query('show databases') + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/unsignedSmallint.py b/tests/pytest/insert/unsignedSmallint.py new file mode 100644 index 0000000000000000000000000000000000000000..9893c470ce1a53a05138dd9d5c18e2b0a9f21374 --- /dev/null +++ b/tests/pytest/insert/unsignedSmallint.py @@ -0,0 +1,108 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdLog.info('=============== step1') + tdLog.info('create table tb (ts timestamp, speed smallint unsigned)') + tdSql.execute('create table tb (ts timestamp, speed smallint unsigned)') + tdLog.info("insert into tb values (now, NULL)") + tdSql.execute("insert into tb values (now, NULL)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + tdLog.info('tdSql.checkData(0, 1, null)') + tdSql.checkData(0, 1, None) + tdLog.info('=============== step2') + tdLog.info("insert into tb values (now+1m, -1) -x step2") + tdSql.error("insert into tb values (now+1m, -1) ") + tdLog.info("insert into tb values (now+1m, NULL)") + tdSql.execute("insert into tb values (now+1m, NULL)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(2)') + tdSql.checkRows(2) + tdLog.info('tdSql.checkData(0, 1, null)') + tdSql.checkData(0, 1, None) + tdLog.info('=============== step3') + tdLog.info("insert into tb values (now+2m, 65534)") + tdSql.execute("insert into tb values (now+2m, 65534)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(3)') + tdSql.checkRows(3) + tdLog.info('tdSql.checkData(0, 1, 65534)') + tdSql.checkData(0, 1, 65534) + tdLog.info('=============== step4') + tdLog.info("insert into tb values (now+3m, 65535) -x step4") + tdSql.error("insert into tb values (now+3m, 65535)") + tdLog.info("insert into tb values (now+3m, NULL)") + tdSql.execute("insert into tb values (now+3m, NULL)") + tdLog.info('select * from tb') + tdSql.query('select * from tb') + tdLog.info('tdSql.checkRow(4)') + tdSql.checkRows(4) + tdLog.info('tdSql.checkData(0, 1, null)') + tdSql.checkData(0, 1, None) + tdLog.info('=============== step5') + tdLog.info("insert into tb values (now+4m, a2)") + tdSql.error("insert into tb values (now+4m, a2)") + tdLog.info("insert into tb values (now-4m, -1)") + tdSql.error("insert into tb values (now-4m, -1)") + tdLog.info("insert into tb values (now+4m, 0)") + tdSql.execute("insert into tb values (now+4m, 0)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + tdLog.info('tdSql.checkData(0, 1, 0)') + tdSql.checkData(0, 1, 0) + tdLog.info('=============== step6') + tdLog.info("insert into tb values (now+5m, 2a)") + tdSql.error("insert into tb values (now+5m, 2a)") + tdLog.info("insert into tb values (now+5m, 2)") + tdSql.execute("insert into tb values (now+5m, 2)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(6)') + tdSql.checkRows(6) + tdLog.info('tdSql.checkData(0, 1, 2)') + tdSql.checkData(0, 1, 2) + tdLog.info('=============== step7') + tdLog.info("insert into tb values (now+6m, 2a'1)") + tdSql.error("insert into tb values (now+6m, 2a'1)") + tdLog.info("insert into tb values (now+6m, 2)") + tdSql.execute("insert into tb values (now+6m, 2)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(7)') + tdSql.checkRows(7) + tdLog.info('tdSql.checkData(0, 1, 2)') + tdSql.checkData(0, 1, 2) + tdLog.info('drop database db') + tdSql.execute('drop database db') + tdLog.info('show databases') + tdSql.query('show databases') + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/unsignedTinyint.py b/tests/pytest/insert/unsignedTinyint.py new file mode 100644 index 0000000000000000000000000000000000000000..5bdfe7580b198ccaffcab7005e88aa72e1c437af --- /dev/null +++ b/tests/pytest/insert/unsignedTinyint.py @@ -0,0 +1,106 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdLog.info('=============== step1') + tdLog.info('create table tb (ts timestamp, speed tinyint unsigned)') + tdSql.execute('create table tb (ts timestamp, speed tinyint unsigned)') + tdLog.info("insert into tb values (now, NULL)") + tdSql.execute("insert into tb values (now, NULL)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + tdLog.info('tdSql.checkData(0, 1, null)') + tdSql.checkData(0, 1, None) + tdLog.info('=============== step2') + tdLog.info("insert into tb values (now+1m, -1) -x step2") + tdSql.error("insert into tb values (now+1m, -1) ") + tdLog.info("insert into tb values (now+1m, NULL)") + tdSql.execute("insert into tb values (now+1m, NULL)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(2)') + tdSql.checkRows(2) + tdLog.info('tdSql.checkData(0, 1, null)') + tdSql.checkData(0, 1, None) + tdLog.info('=============== step3') + tdLog.info("insert into tb values (now+2m, 254)") + tdSql.execute("insert into tb values (now+2m, 254)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(3)') + tdSql.checkRows(3) + tdLog.info('tdSql.checkData(0, 1, 254)') + tdSql.checkData(0, 1, 254) + tdLog.info('=============== step4') + tdLog.info("insert into tb values (now+3m, 255) -x step4") + tdSql.error("insert into tb values (now+3m, 255)") + tdLog.info("insert into tb values (now+3m, NULL)") + tdSql.execute("insert into tb values (now+3m, NULL)") + tdLog.info('select * from tb') + tdSql.query('select * from tb') + tdLog.info('tdSql.checkRow(4)') + tdSql.checkRows(4) + tdLog.info('tdSql.checkData(0, 1, null)') + tdSql.checkData(0, 1, None) + tdLog.info('=============== step5') + tdLog.info("insert into tb values (now+4m, a2)") + tdSql.error("insert into tb values (now+4m, a2)") + tdLog.info("insert into tb values (now+4m, 0)") + tdSql.execute("insert into tb values (now+4m, 0)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + tdLog.info('tdSql.checkData(0, 1, 0)') + tdSql.checkData(0, 1, 0) + tdLog.info('=============== step6') + tdLog.info("insert into tb values (now+5m, 2a)") + tdSql.error("insert into tb values (now+5m, 2a)") + tdLog.info("insert into tb values (now+5m, 2)") + tdSql.execute("insert into tb values (now+5m, 2)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(6)') + tdSql.checkRows(6) + tdLog.info('tdSql.checkData(0, 1, 2)') + tdSql.checkData(0, 1, 2) + tdLog.info('=============== step7') + tdLog.info("insert into tb values (now+6m, 2a'1)") + tdSql.error("insert into tb values (now+6m, 2a'1)") + tdLog.info("insert into tb values (now+6m, 2)") + tdSql.execute("insert into tb values (now+6m, 2)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(7)') + tdSql.checkRows(7) + tdLog.info('tdSql.checkData(0, 1, 2)') + tdSql.checkData(0, 1, 2) + tdLog.info('drop database db') + tdSql.execute('drop database db') + tdLog.info('show databases') + tdSql.query('show databases') + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/verifyMemToDiskCrash.py b/tests/pytest/insert/verifyMemToDiskCrash.py new file mode 100644 index 0000000000000000000000000000000000000000..de8fa26fe29da9c96a3f47fa6c63bab14e294432 --- /dev/null +++ b/tests/pytest/insert/verifyMemToDiskCrash.py @@ -0,0 +1,133 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +from util.common import tdCom + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def checkTbMemDiskMerge(self): + tb_name = tdCom.getLongName(8, "letters") + tdSql.execute( + f'CREATE TABLE {tb_name} (ts timestamp, c1 int, c2 int)') + tdSql.execute( + f'insert into {tb_name} values ("2021-01-01 12:00:00.000", 1, 1)') + tdSql.execute( + f'insert into {tb_name} values ("2021-01-03 12:00:00.000", 3, 3)') + tdCom.restartTaosd() + tdSql.execute( + f'insert into {tb_name} values ("2021-01-02 12:00:00.000", Null, 2)') + tdSql.execute( + f'insert into {tb_name} values ("2021-01-04 12:00:00.000", Null, 4)') + query_sql = f'select * from {tb_name}' + res1 = tdSql.query(query_sql, True) + tdCom.restartTaosd() + res2 = tdSql.query(query_sql, True) + for i in range(4): + tdSql.checkEqual(res1[i], res2[i]) + + def checkStbMemDiskMerge(self): + stb_name = tdCom.getLongName(7, "letters") + tb_name = f'{stb_name}_sub' + tdSql.execute( + f'CREATE TABLE {stb_name} (ts timestamp, c1 int, c2 int) tags (t1 int)') + tdSql.execute( + f'CREATE TABLE {tb_name} using {stb_name} tags (1)') + tdSql.execute( + f'insert into {tb_name} values ("2021-01-01 12:00:00.000", 1, 1)') + tdSql.execute( + f'insert into {tb_name} values ("2021-01-03 12:00:00.000", 3, 3)') + tdCom.restartTaosd() + tdSql.execute( + f'insert into {tb_name} values ("2021-01-02 12:00:00.000", Null, 2)') + tdSql.execute( + f'insert into {tb_name} values ("2021-01-04 12:00:00.000", Null, 4)') + query_sql = f'select * from {stb_name}' + res1 = tdSql.query(query_sql, True) + tdCom.restartTaosd() + res2 = tdSql.query(query_sql, True) + for i in range(4): + tdSql.checkEqual(res1[i], res2[i]) + + def checkTbSuperSubBlockMerge(self): + tb_name = tdCom.getLongName(6, "letters") + tdSql.execute( + f'CREATE TABLE {tb_name} (ts timestamp, c1 int)') + + start_ts = 1577808001000 + for i in range(10): + tdSql.execute( + f'insert into {tb_name} values ({start_ts}, {i})') + start_ts += 1 + tdCom.restartTaosd() + + for i in range(10): + tdSql.execute( + f'insert into {tb_name} values ({start_ts}, Null)') + start_ts += 1 + tdCom.restartTaosd() + + for i in range(10): + new_ts = i + 10 + 10 + tdSql.execute( + f'insert into {tb_name} values ({start_ts}, {new_ts})') + start_ts += 1 + tdCom.restartTaosd() + tdSql.query(f'select * from {tb_name}') + + def checkStbSuperSubBlockMerge(self): + stb_name = tdCom.getLongName(5, "letters") + tb_name = f'{stb_name}_sub' + tdSql.execute( + f'CREATE TABLE {stb_name} (ts timestamp, c1 int) tags (t1 int)') + tdSql.execute( + f'CREATE TABLE {tb_name} using {stb_name} tags (1)') + + start_ts = 1577808001000 + for i in range(10): + tdSql.execute( + f'insert into {tb_name} values ({start_ts}, {i})') + start_ts += 1 + tdCom.restartTaosd() + + for i in range(10): + tdSql.execute( + f'insert into {tb_name} values ({start_ts}, Null)') + start_ts += 1 + tdCom.restartTaosd() + + for i in range(10): + new_ts = i + 10 + 10 + tdSql.execute( + f'insert into {tb_name} values ({start_ts}, {new_ts})') + start_ts += 1 + tdCom.restartTaosd() + tdSql.query(f'select * from {stb_name}') + + def run(self): + tdSql.prepare() + self.checkTbMemDiskMerge() + self.checkStbMemDiskMerge() + self.checkTbSuperSubBlockMerge() + self.checkStbSuperSubBlockMerge() + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/writeDBNonStop.py b/tests/pytest/insert/writeDBNonStop.py new file mode 100644 index 0000000000000000000000000000000000000000..bdc93f0469d8a774a3f8a8675eb65728ccb8aa8d --- /dev/null +++ b/tests/pytest/insert/writeDBNonStop.py @@ -0,0 +1,83 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +import time +from datetime import datetime +import csv + + +class DBWriteNonStop: + def __init__(self): + self.host = "127.0.0.1" + self.user = "root" + self.password = "taosdata" + self.config = "/etc/taos" + + def connectDB(self): + self.conn = taos.connect( + self.host, + self.user, + self.password, + self.config) + self.cursor = self.conn.cursor() + + def createTable(self): + self.cursor.execute("drop database if exists dbwrite") + self.cursor.execute("create database dbwrite") + self.cursor.execute("use dbwrite") + self.cursor.execute( + "create table if not exists st (ts timestamp, value nchar(50), speed int) tags(dev nchar(50))") + + def writeDataToCSVFile(self, data, duration): + csvFile = open('/root/csvFile.csv', 'a', newline='') + writer = csv.writer(csvFile) + writer.writerow([data[0][0], data[0][1], data[0][2], + data[0][3], data[0][4], data[0][5], duration]) + csvFile.close() + + def insertData(self): + print("===============inserting data===============") + i = 1 + startTime = datetime.now() + while True: + self.cursor.execute( + "insert into st1 using st tags('dev_001') values(now, 'taosdata%d', %d)" % + (i % + 10000, + i % + 100000)) + i += 1 + i = i % 32000000 + endTime = datetime.now() + if (endTime - startTime).seconds >= 3600 * 1: + startTime = endTime + start = datetime.now() + self.cursor.execute( + "select first(ts), last(ts), min(speed), max(speed), avg(speed), count(*) from st") + data = self.cursor.fetchall() + end = datetime.now() + self.writeDataToCSVFile(data, (end - start).seconds) + time.sleep(.001) + + def closeConn(self): + self.cursor.close() + self.conn.close() + + +test = DBWriteNonStop() +test.connectDB() +test.createTable() +test.insertData() +test.closeConn() diff --git a/tests/pytest/manualTest/manual_alter_block.py b/tests/pytest/manualTest/manual_alter_block.py new file mode 100644 index 0000000000000000000000000000000000000000..ccd98b1421400a765d85a35cf3a0b13b15f35f8e --- /dev/null +++ b/tests/pytest/manualTest/manual_alter_block.py @@ -0,0 +1,82 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import tdDnodes + +##TODO: auto test version is currently unsupported, need to come up with +# an auto test version in the future +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def run(self): + tdSql.prepare() + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + + #alter cache block to 3, then check alter + tdSql.execute('alter database db blocks 3') + tdSql.query('show databases') + tdSql.checkData(0,9,3) + + #run taosdemo to occupy all cache, need to manually check memory consumption + os.system("%staosdemo -f tools/taosdemoAllTest/manual_block1_comp.json" % binPath) + input("please check memory usage for taosd. After checking, press enter") + + #alter cache block to 8, then check alter + tdSql.execute('alter database db blocks 8') + tdSql.query('show databases') + tdSql.checkData(0,9,8) + + #run taosdemo to occupy all cache, need to manually check memory consumption + os.system("%staosdemo -f tools/taosdemoAllTest/manual_block2.json" % binPath) + input("please check memory usage for taosd. After checking, press enter") + + ##expected result the peak memory consumption should increase by around 80MB = 5 blocks of cache + + ##test results + #2021/06/02 before:2621700K after: 2703640K memory usage increased by 80MB = 5 block + # confirm with the change in block. Baosheng Chang + + def stop(self): + tdSql.close() + tdLog.debug("%s alter block manual check finish" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/manualTest/manual_alter_comp.py b/tests/pytest/manualTest/manual_alter_comp.py new file mode 100644 index 0000000000000000000000000000000000000000..6c3e0fc29606caae32b981c662daaacbd31b15be --- /dev/null +++ b/tests/pytest/manualTest/manual_alter_comp.py @@ -0,0 +1,126 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import tdDnodes + +##TODO: auto test version is currently unsupported, need to come up with +# an auto test version in the future +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getRootPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + print(selfPath) + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + print(projPath) + else: + projPath = selfPath[:selfPath.find("tests")] + print("test" + projPath) + + for root, dirs, files in os.walk(projPath): + if ('data' in dirs and 'sim' in root): + rootPath = root + + return rootPath + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + + + def run(self): + dnodePath = self.getRootPath() + os.system(f'rm -rf {dnodePath}/data/* {dnodePath}/log/*') + tdSql.prepare() + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + + #comp is at 14 + #check disk usage when comp=2 + tdSql.query('show databases') + tdSql.execute('alter database db blocks 3') # minimize the data in cache + tdSql.checkData(0,14,2) + os.system("%staosdemo -f tools/taosdemoAllTest/manual_block1_comp.json" % binPath) + print("default location is at /home/bryan/Documents/Github/TDengine/sim/dnode1/data/vnode") + print('comp = 2') + input("please check disk usage for taosd. After checking, press enter") + + #removing all data file + os.system(f'sudo rm -rf {dnodePath}/data/* {dnodePath}/log/*') + #print(f'rm -rf {dnodePath}/data/* {dnodePath}/log/*') #for showing the command ran + input("please check if the pervious data is being deleted. Then, press enter") + + #check disk usage when comp=0 + tdSql.prepare() + tdSql.query('show databases') + tdSql.checkData(0,14,2) + tdSql.execute('alter database db comp 0') + tdSql.query('show databases') + tdSql.checkData(0,14,0) + os.system("%staosdemo -f tools/taosdemoAllTest/manual_block1_comp.json" % binPath) + print("default location is at /home/bryan/Documents/Github/TDengine/sim/dnode1/data") + print('comp = 0') + input("please check disk usage for taosd. After checking, press enter") + + #removing all data file + os.system(f'sudo rm -rf {dnodePath}/data/* {dnodePath}/log/*') + #print(f'rm -rf {dnodePath}/data/* {dnodePath}/log/*') #for showing the command ran + input("please check if the pervious data is being deleted. Then, press enter") + + #check disk usage when comp=1 + tdSql.prepare() + tdSql.query('show databases') + tdSql.checkData(0,14,2) + tdSql.execute('alter database db comp 1') + tdSql.query('show databases') + tdSql.checkData(0,14,1) + os.system("%staosdemo -f tools/taosdemoAllTest/manual_block1_comp.json" % binPath) + print("default location is at /home/bryan/Documents/Github/TDengine/sim/dnode1/data") + print('comp = 1') + input("please check disk usage for taosd. After checking, press enter") + + ##test result + # 2021/06/02 comp=2:13M comp=1:57M comp=0:399M. Test past + # each row entered is identical Tester - Baosheng Chang + + def stop(self): + tdSql.close() + tdLog.debug("%s alter block manual check finish" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/manualTest/manual_change_time_2.py b/tests/pytest/manualTest/manual_change_time_2.py new file mode 100644 index 0000000000000000000000000000000000000000..4aeacb9f630a7e36ceb6e34a8a6c40f2d77dd1ca --- /dev/null +++ b/tests/pytest/manualTest/manual_change_time_2.py @@ -0,0 +1,97 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- +from fabric import Connection +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import tdDnodes +from datetime import datetime +import subprocess +import time +import taos +##TODO: this is now automatic, but not sure if this will run through jenkins + +#the initial time used for this test is 2020/10/20 + +#setting local machine's time for later connecting to the server +os.system('sudo timedatectl set-ntp off') +os.system('sudo timedatectl set-time 2020-10-25') + +#connect to VM lyq-1, and initalize the environment at lyq-1 +conn1 = Connection("{}@{}".format('ubuntu', "192.168.1.125"), connect_kwargs={"password": "{}".format('tbase125!')}) +conn1.run("sudo systemctl stop taosd") +conn1.run('ls -l') +conn1.run('sudo timedatectl set-ntp off') +conn1.run('sudo timedatectl set-time 2020-10-20') + +with conn1.cd('/data/taos/log'): + conn1.run('sudo rm -rf *') + +with conn1.cd('/data/taos/data'): + conn1.run('sudo rm -rf *') + +#lanuch taosd and start taosdemo +conn1.run("sudo systemctl start taosd") +time.sleep(5) +with conn1.cd('~/bschang_test'): + conn1.run('taosdemo -f manual_change_time_1_1_A.json') + +#force everything onto disk +conn1.run("sudo systemctl restart taosd") +time.sleep(10) + +#change lyq-1 to 2020/10/25 for testing if the server +#will send data that is out of time range +conn1.run('sudo timedatectl set-time 2020-10-25') + +#connect to VM lyq-2, initalize the environment at lyq-2, and run taosd +#on that +conn2 = Connection("{}@{}".format('ubuntu', "192.168.1.126"), connect_kwargs={"password": "{}".format('tbase125!')}) +conn2.run('sudo timedatectl set-ntp off') +conn2.run('sudo timedatectl set-time 2020-10-20') +conn2.run("sudo systemctl stop taosd") +with conn2.cd('/data/taos/log'): + conn2.run('sudo rm -rf *') +with conn2.cd('/data/taos/data'): + conn2.run('sudo rm -rf *') +conn2.run("sudo systemctl start taosd") + +#set replica to 2 +connTaos = taos.connect(host = '192.168.1.125', user = 'root', password = 'taosdata', cnfig = '/etc/taos') +c1 = connTaos.cursor() +c1.execute('create dnode \'lyq-2:6030\'') +c1.execute('alter database db replica 2') +c1.close() +connTaos.close() +time.sleep(5) + +#force everything onto the disk for lyq-2 +#stopping taosd on lyq-1 for future testing +conn2.run("sudo systemctl stop taosd") +conn1.run("sudo systemctl stop taosd") + +#reset the time +conn1.run('sudo timedatectl set-ntp on') +conn2.run('sudo timedatectl set-ntp on') +os.system('sudo timedatectl set-ntp on') + +#check if the number of file received is 7 +#the 4 oldest data files should be dropped +#4 files because of moving 5 days ahead +with conn2.cd('/data/taos/data/vnode/vnode3/tsdb/data'): + result = conn2.run('ls -l |grep \'data\' |wc -l') + if result.stdout.strip() != '7': + tdLog.exit('the file number is wrong') + else: + tdLog.success('the file number is the same. test pass') diff --git a/tests/pytest/manualTest/manual_change_time_3.py b/tests/pytest/manualTest/manual_change_time_3.py new file mode 100644 index 0000000000000000000000000000000000000000..a288147b56dd9bd1c98b354e347cfd7ac05fce38 --- /dev/null +++ b/tests/pytest/manualTest/manual_change_time_3.py @@ -0,0 +1,97 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- +from fabric import Connection +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import tdDnodes +from datetime import datetime +import subprocess +import time +import taos + +##TODO: this is now automatic, but not sure if this will run through jenkins + +#the initial time used for this test is 2020/10/20 + +#setting local machine's time for later connecting to the server +os.system('sudo timedatectl set-ntp off') +os.system('sudo timedatectl set-time 2020-10-20') + +#connect to VM lyq-1, and initalize the environment at lyq-1 +conn1 = Connection("{}@{}".format('ubuntu', "192.168.1.125"), connect_kwargs={"password": "{}".format('tbase125!')}) +conn1.run("sudo systemctl stop taosd") +conn1.run('sudo timedatectl set-ntp off') +conn1.run('sudo timedatectl set-time 2020-10-20') +with conn1.cd('/data/taos/log'): + conn1.run('sudo rm -rf *') + +with conn1.cd('/data/taos/data'): + conn1.run('sudo rm -rf *') + +#lanuch taosd and start taosdemo +conn1.run("sudo systemctl start taosd") +time.sleep(5) +with conn1.cd('~/bschang_test'): + conn1.run('taosdemo -f manual_change_time_1_1_A.json') #the json file is placed in lyq-1 already + +#force everything onto disk +conn1.run("sudo systemctl restart taosd") +time.sleep(10) + +#connect to VM lyq-2, and initalize the environment at lyq-2 +conn2 = Connection("{}@{}".format('ubuntu', "192.168.1.126"), connect_kwargs={"password": "{}".format('tbase125!')}) +conn2.run('sudo timedatectl set-ntp off') +conn2.run('sudo timedatectl set-time 2020-10-20') +conn2.run("sudo systemctl stop taosd") +with conn2.cd('/data/taos/log'): + conn2.run('sudo rm -rf *') +with conn2.cd('/data/taos/data'): + conn2.run('sudo rm -rf *') + +#the date of lyq-2 is going to be set to 2020/10/25 +#for testing if other pnode will accpet file out of local time range +conn2.run("sudo systemctl start taosd") +conn2.run('sudo timedatectl set-time 2020-10-25') + +#set the replica to 2 +connTaos = taos.connect(host = '192.168.1.125', user = 'root', password = 'taosdata', cnfig = '/etc/taos') +c1 = connTaos.cursor() +c1.execute('create dnode \'lyq-2:6030\'') +c1.execute('alter database db replica 2') +time.sleep(5) + +#force everything onto the disk for lyq-2 +#stopping taosd on lyq-1 for future testing +conn2.run("sudo systemctl stop taosd") +conn1.run("sudo systemctl stop taosd") + +#reset the time +conn1.run('sudo timedatectl set-ntp on') +conn2.run('sudo timedatectl set-ntp on') +os.system('sudo timedatectl set-ntp on') + +#check if the number of file received is 7 +#the 4 oldest data files should be dropped +#4 files because of moving 5 days ahead +with conn2.cd('/data/taos/data/vnode/vnode3/tsdb/data'): + result = conn2.run('ls -l |grep \'data\' |wc -l') + if result.stdout.strip() != '7': + tdLog.exit('the file number is wrong') + else: + tdLog.success('the file number is the same. test pass') + +c1.close() +connTaos.close() + diff --git a/tests/pytest/multilevel/basic.py b/tests/pytest/multilevel/basic.py new file mode 100644 index 0000000000000000000000000000000000000000..95549409c9f1a1b287fc872260d33f956ccf3510 --- /dev/null +++ b/tests/pytest/multilevel/basic.py @@ -0,0 +1,51 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + cfg={ + '/mnt/data1' : 'dataDir', + '/mnt/data2 0 0' : 'dataDir' + } + tdSql.createDir('/mnt/data1') + tdSql.createDir('/mnt/data2') + + tdLog.info("================= step1") + tdDnodes.stop(1) + tdDnodes.deploy(1,cfg) + tdDnodes.startWithoutSleep(1) + + tdLog.info("================= step2") + tdSql.haveFile('/mnt/data1',1) + tdSql.haveFile('/mnt/data2',1) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/multilevel/dirNotExist.py b/tests/pytest/multilevel/dirNotExist.py new file mode 100644 index 0000000000000000000000000000000000000000..e895ac31ad1d6361cddfe867e39cea370412cb58 --- /dev/null +++ b/tests/pytest/multilevel/dirNotExist.py @@ -0,0 +1,50 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + cfg={ + '/mnt/data1 0 0' : 'dataDir', + '/mnt/data2 0 0' : 'dataDir' + } + tdSql.createDir('/mnt/data1') + os.system('rm -rf /mnt/data2') + + + tdLog.info("================= step1") + tdDnodes.stop(1) + tdDnodes.deploy(1,cfg) + tdDnodes.startWithoutSleep(1) + + tdLog.info("================= step2") + tdSql.taosdStatus(0) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/multilevel/dirPermissionDenied.py b/tests/pytest/multilevel/dirPermissionDenied.py new file mode 100644 index 0000000000000000000000000000000000000000..db2cdcf757121c501e33f605aceebdf875d5f944 --- /dev/null +++ b/tests/pytest/multilevel/dirPermissionDenied.py @@ -0,0 +1,51 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + cfg={ + '/mnt/data1 0 0' : 'dataDir', + '/mnt/data2 0 0' : 'dataDir' + } + tdSql.createDir('/mnt/data1') + tdSql.createDir('/mnt/data2') + os.system('chmod 111 /mnt/data2') + + tdLog.info("================= step1") + tdDnodes.stop(1) + tdDnodes.deploy(1,cfg) + tdDnodes.startWithoutSleep(1) + + tdLog.info("================= step2") + tdSql.taosdStatus(0) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/multilevel/fileDistributionSameLevel.py b/tests/pytest/multilevel/fileDistributionSameLevel.py new file mode 100644 index 0000000000000000000000000000000000000000..83ce85671771c4d2627541e80262ef8c764e45c3 --- /dev/null +++ b/tests/pytest/multilevel/fileDistributionSameLevel.py @@ -0,0 +1,108 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + +dataDir = ['data00','data01','data02','data03','data04'] +dataDict = {'data00':0,'data01':0,'data02':0,'data03':0,'data04':0} +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getfiles(self,ospath): + try: + files = os.listdir(ospath) + for f in files: + path = os.path.join(ospath, f) + if os.path.isfile(path): + if path.endswith('.data'): + for i in dataDir: + if i in path: + dataDict[i] = dataDict[i] + 1 + print(path) + if os.path.isdir(path): + self.getfiles(path) + except Exception as e : + print(str(e)) + + def run(self): + self.ntables = 1000 + self.ts = 1520000010000 + + tdDnodes.stop(1) + # Test1 1 dataDir + tdLog.info("================= step1") + cfg={ + '10' : 'maxVgroupsPerDb', + '100' : 'maxTablesPerVnode', + '/mnt/data00 0 1' : 'dataDir', + '/mnt/data01 0 0' : 'dataDir', + '/mnt/data02 0 0' : 'dataDir', + '/mnt/data03 0 0' : 'dataDir', + '/mnt/data04 0 0' : 'dataDir' + } + tdSql.createDir('/mnt/data00') + tdSql.createDir('/mnt/data01') + tdSql.createDir('/mnt/data02') + tdSql.createDir('/mnt/data03') + tdSql.createDir('/mnt/data04') + + tdDnodes.deploy(1,cfg) + tdDnodes.startWithoutSleep(1) + + tdSql.execute("create database test days 1") + tdSql.execute("use test") + + tdSql.execute("create table stb(ts timestamp, c int) tags(t int)") + + for i in range(self.ntables): + tdSql.execute("create table tb%d using stb tags(%d)" %(i, i)) + tdSql.execute("insert into tb%d values(%d, 1)" % (i,self.ts + int (i / 100) * 86400000)) + + tdLog.info("================= step2") + tdDnodes.stop(1) + tdDnodes.start(1) + + tdSql.query("select * from test.stb") + tdSql.checkRows(1000) + + tdLog.info("================= step3") + tdSql.execute('drop database test') + for i in range(50): + tdSql.execute("create database test%d days 1" %(i)) + tdSql.execute("use test%d" %(i)) + tdSql.execute("create table tb (ts timestamp,i int)") + for j in range(10): + tdSql.execute("insert into tb values(%d, 1)" % (self.ts + int (i / 100) * 86400000)) + tdDnodes.stop(1) + tdDnodes.start(1) + flag = True + for i in range(4): + if dataDict[dataDir[i]] == dataDict[dataDir[i+1]]: + flag = flag & True + else: + flag = flag & False + break + if not flag : tdLog.exit("%s failed, expect not occured" % (sys.argv[0])) + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/multilevel/illegelLevelMountPoint.py b/tests/pytest/multilevel/illegelLevelMountPoint.py new file mode 100644 index 0000000000000000000000000000000000000000..cbf7fc1fe908fa528713576921555380d4a68ed8 --- /dev/null +++ b/tests/pytest/multilevel/illegelLevelMountPoint.py @@ -0,0 +1,59 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 10 + self.rowsPerTable = 10 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + # Test1 1 dataDir + cfg={ + '/mnt/data1 3 0' : 'dataDir' + } + tdSql.createDir('/mnt/data1') + + tdDnodes.deploy(1,cfg) + tdDnodes.startWithoutSleep(1) + + tdDnodes.stop(1) + # Test1 1 dataDir + cfg={ + '/mnt/data1 -1 0' : 'dataDir' + } + tdSql.createDir('/mnt/data1') + + tdDnodes.deploy(1,cfg) + tdDnodes.startWithoutSleep(1) + + tdSql.taosdStatus(0) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/multilevel/middleLevelMissing.py b/tests/pytest/multilevel/middleLevelMissing.py new file mode 100644 index 0000000000000000000000000000000000000000..727c2380ae0f3a148a475ae8ebdd01e8ff1f543f --- /dev/null +++ b/tests/pytest/multilevel/middleLevelMissing.py @@ -0,0 +1,64 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 10 + self.rowsPerTable = 10 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + # Test1 1 dataDir + cfg={ + '/mnt/data1 1 0' : 'dataDir' + } + tdSql.createDir('/mnt/data1') + + tdDnodes.deploy(1,cfg) + tdDnodes.startWithoutSleep(1) + + tdSql.taosdStatus(0) + + + tdDnodes.stop(1) + # Test2 2 dataDir + cfg={ + '/mnt/data1 0 1' : 'dataDir', + '/mnt/data1 2 0' : 'dataDir' + } + tdSql.createDir('/mnt/data1') + + tdDnodes.deploy(1,cfg) + tdDnodes.startWithoutSleep(1) + + tdSql.taosdStatus(0) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/multilevel/moreThan16disks.py b/tests/pytest/multilevel/moreThan16disks.py new file mode 100644 index 0000000000000000000000000000000000000000..407e5aa6970781ce5b511faa1f4f74e7a18e75a8 --- /dev/null +++ b/tests/pytest/multilevel/moreThan16disks.py @@ -0,0 +1,53 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + cfg={} + for i in range(17): + if i == 0 : + datadir = '/mnt/data%d 0 1' % (i+1) + else: + datadir = '/mnt/data%d 0 0' % (i+1) + cfg.update({ datadir : 'dataDir' }) + tdSql.createDir('/mnt/data%d' % (i+1)) + + + tdLog.info("================= step1") + tdDnodes.stop(1) + tdDnodes.deploy(1,cfg) + tdDnodes.startWithoutSleep(1) + + tdLog.info("================= step2") + + tdSql.taosdStatus(0) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/multilevel/multiMainMountPoint.py b/tests/pytest/multilevel/multiMainMountPoint.py new file mode 100644 index 0000000000000000000000000000000000000000..c5af816205cdbd325c11d600c560104ca1801b93 --- /dev/null +++ b/tests/pytest/multilevel/multiMainMountPoint.py @@ -0,0 +1,49 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + cfg={ + '/mnt/data1' : 'dataDir', + '/mnt/data2' : 'dataDir' + } + tdSql.createDir('/mnt/data1') + tdSql.createDir('/mnt/data2') + + tdLog.info("================= step1") + tdDnodes.stop(1) + tdDnodes.deploy(1,cfg) + tdDnodes.startWithoutSleep(1) + + tdLog.info("================= step2") + tdSql.taosdStatus(0) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/multilevel/noneMainMountPoint.py b/tests/pytest/multilevel/noneMainMountPoint.py new file mode 100644 index 0000000000000000000000000000000000000000..67fab7c7a24510244a663dbc20f2c212012f712d --- /dev/null +++ b/tests/pytest/multilevel/noneMainMountPoint.py @@ -0,0 +1,49 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + cfg={ + '/mnt/data1 0 0' : 'dataDir', + '/mnt/data2 0 0' : 'dataDir' + } + tdSql.createDir('/mnt/data1') + tdSql.createDir('/mnt/data2') + + tdLog.info("================= step1") + tdDnodes.stop(1) + tdDnodes.deploy(1,cfg) + tdDnodes.startWithoutSleep(1) + + tdLog.info("================= step2") + tdSql.taosdStatus(0) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/multilevel/retentionTest.py b/tests/pytest/multilevel/retentionTest.py new file mode 100644 index 0000000000000000000000000000000000000000..9ea59d9d5918d851f69acc69704926d97f3f5375 --- /dev/null +++ b/tests/pytest/multilevel/retentionTest.py @@ -0,0 +1,82 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 10 + self.rowsPerTable = 10 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + # Test1 1 dataDir + cfg={ + '/mnt/data00 0 1' : 'dataDir', + '/mnt/data01 0 0' : 'dataDir', + '/mnt/data02 0 0' : 'dataDir', + '/mnt/data10 1 0' : 'dataDir', + '/mnt/data11 1 0' : 'dataDir', + '/mnt/data12 1 0' : 'dataDir', + '/mnt/data20 2 0' : 'dataDir', + '/mnt/data21 2 0' : 'dataDir', + '/mnt/data22 2 0' : 'dataDir' + } + tdSql.createDir('/mnt/data00') + tdSql.createDir('/mnt/data01') + tdSql.createDir('/mnt/data02') + tdSql.createDir('/mnt/data10') + tdSql.createDir('/mnt/data11') + tdSql.createDir('/mnt/data12') + tdSql.createDir('/mnt/data20') + tdSql.createDir('/mnt/data21') + tdSql.createDir('/mnt/data22') + + tdDnodes.deploy(1,cfg) + tdDnodes.startWithoutSleep(1) + + tdSql.execute("create database test days 1 keep 15,5,10") + tdSql.execute("use test") + + tdSql.execute("create table tb(ts timestamp, c int)") + + count = 0 + os.system("sudo timedatectl set-ntp false") + + for i in range(self.rowsPerTable): + tdSql.execute("insert into tb values(now, 1)") + count += 1 + tdSql.query("select * from tb") + tdSql.checkRows(count) + tdDnodes.stop(1) + os.system("sudo date -s $(date -d \"${DATE} 1 day\" \"+%Y%m%d\")") + tdDnodes.start(1) + + def stop(self): + os.system("sudo timedatectl set-ntp true") + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/multilevel/threeLevelMountPoint.py b/tests/pytest/multilevel/threeLevelMountPoint.py new file mode 100644 index 0000000000000000000000000000000000000000..d97602eb76889ab265f6bc673f5c7558be5d7fe3 --- /dev/null +++ b/tests/pytest/multilevel/threeLevelMountPoint.py @@ -0,0 +1,74 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 10 + self.rowsPerTable = 10 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + # Test1 1 dataDir + cfg={ + '/mnt/data00 0 1' : 'dataDir', + '/mnt/data01 0 0' : 'dataDir', + '/mnt/data02 0 0' : 'dataDir', + '/mnt/data10 1 0' : 'dataDir', + '/mnt/data11 1 0' : 'dataDir', + '/mnt/data12 1 0' : 'dataDir', + '/mnt/data20 2 0' : 'dataDir', + '/mnt/data21 2 0' : 'dataDir', + '/mnt/data22 2 0' : 'dataDir' + } + tdSql.createDir('/mnt/data00') + tdSql.createDir('/mnt/data01') + tdSql.createDir('/mnt/data02') + tdSql.createDir('/mnt/data10') + tdSql.createDir('/mnt/data11') + tdSql.createDir('/mnt/data12') + tdSql.createDir('/mnt/data20') + tdSql.createDir('/mnt/data21') + tdSql.createDir('/mnt/data22') + + tdDnodes.deploy(1,cfg) + tdDnodes.startWithoutSleep(1) + + tdSql.taosdStatus(1) + tdSql.haveFile('/mnt/data00',1) + tdSql.haveFile('/mnt/data01',1) + tdSql.haveFile('/mnt/data02',1) + tdSql.haveFile('/mnt/data10',1) + tdSql.haveFile('/mnt/data11',1) + tdSql.haveFile('/mnt/data12',1) + tdSql.haveFile('/mnt/data20',1) + tdSql.haveFile('/mnt/data21',1) + tdSql.haveFile('/mnt/data22',1) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/multilevel/wrongLevelMountPoint.py b/tests/pytest/multilevel/wrongLevelMountPoint.py new file mode 100644 index 0000000000000000000000000000000000000000..00b9eb89c69a21a9d02f4927d508b8275e07a7f7 --- /dev/null +++ b/tests/pytest/multilevel/wrongLevelMountPoint.py @@ -0,0 +1,49 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 10 + self.rowsPerTable = 10 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + # Test1 1 dataDir + cfg={ + '/mnt/data1 1 1' : 'dataDir' + } + tdSql.createDir('/mnt/data1') + + tdDnodes.deploy(1,cfg) + tdDnodes.startWithoutSleep(1) + + tdSql.taosdStatus(0) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/perf_gen.py b/tests/pytest/perf_gen.py new file mode 100755 index 0000000000000000000000000000000000000000..f0402fbb6b86c3335f5b2a739bd7545886c8f0d1 --- /dev/null +++ b/tests/pytest/perf_gen.py @@ -0,0 +1,485 @@ +#!/usr/bin/python3.8 + +from abc import abstractmethod + +import time +from datetime import datetime + +from influxdb_client import InfluxDBClient, Point, WritePrecision, BucketsApi +from influxdb_client.client.write_api import SYNCHRONOUS + +import argparse +import textwrap +import subprocess +import sys + +import taos + +from crash_gen.crash_gen_main import Database, TdSuperTable +from crash_gen.service_manager import TdeInstance + +from crash_gen.shared.config import Config +from crash_gen.shared.db import DbConn +from crash_gen.shared.misc import Dice, Logging, Helper +from crash_gen.shared.types import TdDataType + + +# NUM_PROCESSES = 10 +# NUM_REPS = 1000 + +tick = int(time.time() - 5000000.0) # for now we will create max 5M record +value = 101 + +DB_NAME = 'mydb' +TIME_SERIES_NAME = 'widget' + +MAX_SHELF = 500 # shelf number runs up to this, non-inclusive +ITEMS_PER_SHELF = 5 +BATCH_SIZE = 2000 # Number of data points per request + +# None_RW: +# INFLUX_TOKEN='RRzVQZs8ERCpV9cS2RXqgtM_Y6FEZuJ7Tuk0aHtZItFTfcM9ajixtGDhW8HzqNIBmG3hmztw-P4sHOstfJvjFA==' +# DevOrg_RW: +# INFLUX_TOKEN='o1P8sEhBmXKhxBmNuiCyOUKv8d7qm5wUjMff9AbskBu2LcmNPQzU77NrAn5hDil8hZ0-y1AGWpzpL-4wqjFdkA==' +# DevOrg_All_Access +INFLUX_TOKEN='T2QTr4sloJhINH_oSrwSS-WIIZYjDfD123NK4ou3b7ajRs0c0IphCh3bNc0OsDZQRW1HyCby7opdEndVYFGTWQ==' +INFLUX_ORG="DevOrg" +INFLUX_BUCKET="Bucket01" + +def writeTaosBatch(dbc, tblName): + # Database.setupLastTick() + global value, tick + + data = [] + for i in range(0, 100): + data.append("('{}', {})".format(Database.getNextTick(), value) ) + value += 1 + + sql = "INSERT INTO {} VALUES {}".format(tblName, ''.join(data)) + dbc.execute(sql) + +class PerfGenError(taos.error.ProgrammingError): + pass + +class Benchmark(): + + # @classmethod + # def create(cls, dbType): + # if dbType == 'taos': + # return TaosBenchmark() + # elif dbType == 'influx': + # return InfluxBenchmark() + # else: + # raise RuntimeError("Unknown DB type: {}".format(dbType)) + + def __init__(self, dbType, loopCount = 0): + self._dbType = dbType + self._setLoopCount(loopCount) + + def _setLoopCount(self, loopCount): + cfgLoopCount = Config.getConfig().loop_count + if loopCount == 0: # use config + self._loopCount = cfgLoopCount + else: + if cfgLoopCount : + Logging.warning("Ignoring loop count for fixed-loop-count benchmarks: {}".format(cfgLoopCount)) + self._loopCount = loopCount + + @abstractmethod + def doIterate(self): + ''' + Execute the benchmark directly, without invoking sub processes, + effectively using one execution thread. + ''' + pass + + @abstractmethod + def prepare(self): + ''' + Preparation needed to run a certain benchmark + ''' + pass + + @abstractmethod + def execute(self): + ''' + Actually execute the benchmark + ''' + Logging.warning("Unexpected execution") + + @property + def name(self): + return self.__class__.__name__ + + def run(self): + print("Running benchmark: {}, class={} ...".format(self.name, self.__class__)) + startTime = time.time() + + # Prepare to execute the benchmark + self.prepare() + + # Actually execute the benchmark + self.execute() + + # if Config.getConfig().iterate_directly: # execute directly + # Logging.debug("Iterating...") + # self.doIterate() + # else: + # Logging.debug("Executing via sub process...") + # startTime = time.time() + # self.prepare() + # self.spawnProcesses() + # self.waitForProcecess() + # duration = time.time() - startTime + # Logging.info("Benchmark execution completed in {:.3f} seconds".format(duration)) + Logging.info("Benchmark {} finished in {:.3f} seconds".format( + self.name, time.time()-startTime)) + + def spawnProcesses(self): + self._subProcs = [] + for j in range(0, Config.getConfig().subprocess_count): + ON_POSIX = 'posix' in sys.builtin_module_names + tblName = 'cars_reg_{}'.format(j) + cmdLineStr = './perf_gen.sh -t {} -i -n {} -l {}'.format( + self._dbType, + tblName, + Config.getConfig().loop_count + ) + if Config.getConfig().debug: + cmdLineStr += ' -d' + subProc = subprocess.Popen(cmdLineStr, + shell = True, + close_fds = ON_POSIX) + self._subProcs.append(subProc) + + def waitForProcecess(self): + for sp in self._subProcs: + sp.wait(300) + + +class TaosBenchmark(Benchmark): + + def __init__(self, loopCount): + super().__init__('taos', loopCount) + # self._dbType = 'taos' + tInst = TdeInstance() + self._dbc = DbConn.createNative(tInst.getDbTarget()) + self._dbc.open() + self._sTable = TdSuperTable(TIME_SERIES_NAME + '_s', DB_NAME) + + def doIterate(self): + tblName = Config.getConfig().target_table_name + print("Benchmarking TAOS database (1 pass) for: {}".format(tblName)) + self._dbc.execute("USE {}".format(DB_NAME)) + + self._sTable.ensureRegTable(None, self._dbc, tblName) + try: + lCount = Config.getConfig().loop_count + print("({})".format(lCount)) + for i in range(0, lCount): + writeTaosBatch(self._dbc, tblName) + except taos.error.ProgrammingError as err: + Logging.error("Failed to write batch") + + def prepare(self): + self._dbc.execute("CREATE DATABASE IF NOT EXISTS {}".format(DB_NAME)) + self._dbc.execute("USE {}".format(DB_NAME)) + # Create the super table + self._sTable.drop(self._dbc, True) + self._sTable.create(self._dbc, + {'ts': TdDataType.TIMESTAMP, + 'temperature': TdDataType.INT, + 'pressure': TdDataType.INT, + 'notes': TdDataType.BINARY200 + }, + {'rack': TdDataType.INT, + 'shelf': TdDataType.INT, + 'barcode': TdDataType.BINARY16 + }) + + def execSql(self, sql): + try: + self._dbc.execute(sql) + except taos.error.ProgrammingError as err: + Logging.warning("SQL Error: 0x{:X}, {}, SQL: {}".format( + Helper.convertErrno(err.errno), err.msg, sql)) + raise + + def executeWrite(self): + # Sample: INSERT INTO t1 USING st TAGS(1) VALUES(now, 1) t2 USING st TAGS(2) VALUES(now, 2) + sqlPrefix = "INSERT INTO " + dataTemplate = "{} USING {} TAGS({},{},'barcode_{}') VALUES('{}',{},{},'{}') " + + stName = self._sTable.getName() + BATCH_SIZE = 2000 # number of items per request batch + ITEMS_PER_SHELF = 5 + + # rackSize = 10 # shelves per rack + # shelfSize = 100 # items per shelf + batchCount = self._loopCount // BATCH_SIZE + lastRack = 0 + for i in range(batchCount): + sql = sqlPrefix + for j in range(BATCH_SIZE): + n = i*BATCH_SIZE + j # serial number + # values first + # rtName = 'rt_' + str(n) # table name contains serial number, has info + temperature = 20 + (n % 10) + pressure = 70 + (n % 10) + # tags + shelf = (n // ITEMS_PER_SHELF) % MAX_SHELF # shelf number + rack = n // (ITEMS_PER_SHELF * MAX_SHELF) # rack number + barcode = rack + shelf + # table name + tableName = "reg_" + str(rack) + '_' + str(shelf) + # now the SQL + sql += dataTemplate.format(tableName, stName,# table name + rack, shelf, barcode, # tags + Database.getNextTick(), temperature, pressure, 'xxx') # values + lastRack = rack + self.execSql(sql) + Logging.info("Last Rack: {}".format(lastRack)) + +class TaosWriteBenchmark(TaosBenchmark): + def execute(self): + self.executeWrite() + +class Taos100kWriteBenchmark(TaosWriteBenchmark): + def __init__(self): + super().__init__(100*1000) + +class Taos10kWriteBenchmark(TaosWriteBenchmark): + def __init__(self): + super().__init__(10*1000) + +class Taos1mWriteBenchmark(TaosWriteBenchmark): + def __init__(self): + super().__init__(1000*1000) + +class Taos5mWriteBenchmark(TaosWriteBenchmark): + def __init__(self): + super().__init__(5*1000*1000) + +class Taos1kQueryBenchmark(TaosBenchmark): + def __init__(self): + super().__init__(1000) + +class Taos1MCreationBenchmark(TaosBenchmark): + def __init__(self): + super().__init__(1000000) + + +class InfluxBenchmark(Benchmark): + def __init__(self, loopCount): + super().__init__('influx', loopCount) + # self._dbType = 'influx' + + + # self._client = InfluxDBClient(host='localhost', port=8086) + + # def _writeBatch(self, tblName): + # global value, tick + # data = [] + # for i in range(0, 100): + # line = "{},device={} value={} {}".format( + # TIME_SERIES_NAME, + # tblName, + # value, + # tick*1000000000) + # # print(line) + # data.append(line) + # value += 1 + # tick +=1 + + # self._client.write(data, {'db':DB_NAME}, protocol='line') + + def executeWrite(self): + global tick # influx tick #TODO refactor + + lineTemplate = TIME_SERIES_NAME + ",rack={},shelf={},barcode='barcode_{}' temperature={},pressure={} {}" + + batchCount = self._loopCount // BATCH_SIZE + for i in range(batchCount): + lineBatch = [] + for j in range(BATCH_SIZE): + n = i*BATCH_SIZE + j # serial number + # values first + # rtName = 'rt_' + str(n) # table name contains serial number, has info + temperature = 20 + (n % 10) + pressure = 70 + (n % 10) + # tags + shelf = (n // ITEMS_PER_SHELF) % MAX_SHELF # shelf number + rack = n // (ITEMS_PER_SHELF * MAX_SHELF) # rack number + barcode = rack + shelf + # now the SQL + line = lineTemplate.format( + rack, shelf, barcode, # tags + temperature, pressure, # values + tick * 1000000000 ) + tick += 1 + lineBatch.append(line) + write_api = self._client.write_api(write_options=SYNCHRONOUS) + write_api.write(INFLUX_BUCKET, INFLUX_ORG, lineBatch) + # self._client.write(lineBatch, {'db':DB_NAME}, protocol='line') + + # def doIterate(self): + # tblName = Config.getConfig().target_table_name + # print("Benchmarking INFLUX database (1 pass) for: {}".format(tblName)) + + # for i in range(0, Config.getConfig().loop_count): + # self._writeBatch(tblName) + + def _getOrgIdByName(self, orgName): + """Find org by name. + + """ + orgApi = self._client.organizations_api() + orgs = orgApi.find_organizations() + for org in orgs: + if org.name == orgName: + return org.id + raise PerfGenError("Org not found with name: {}".format(orgName)) + + def _fetchAuth(self): + authApi = self._client.authorizations_api() + auths = authApi.find_authorizations() + for auth in auths: + if auth.token == INFLUX_TOKEN : + return auth + raise PerfGenError("No proper auth found") + + def _verifyPermissions(self, perms: list): + if list: + return #OK + raise PerfGenError("No permission found") + + def prepare(self): + self._client = InfluxDBClient( + url="http://127.0.0.1:8086", + token=INFLUX_TOKEN, + org=INFLUX_ORG) + + auth = self._fetchAuth() + + self._verifyPermissions(auth.permissions) + + bktApi = self._client.buckets_api() + # Delete + bkt = bktApi.find_bucket_by_name(INFLUX_BUCKET) + if bkt: + bktApi.delete_bucket(bkt) + # Recreate + + orgId = self._getOrgIdByName(INFLUX_ORG) + bktApi.create_bucket(bucket=None, bucket_name=INFLUX_BUCKET, org_id=orgId) + + # self._client.drop_database(DB_NAME) + # self._client.create_database(DB_NAME) + # self._client.switch_database(DB_NAME) + +class InfluxWriteBenchmark(InfluxBenchmark): + def execute(self): + return self.executeWrite() + +class Influx10kWriteBenchmark(InfluxWriteBenchmark): + def __init__(self): + super().__init__(10*1000) + +class Influx100kWriteBenchmark(InfluxWriteBenchmark): + def __init__(self): + super().__init__(100*1000) + +class Influx1mWriteBenchmark(InfluxWriteBenchmark): + def __init__(self): + super().__init__(1000*1000) + +class Influx5mWriteBenchmark(InfluxWriteBenchmark): + def __init__(self): + super().__init__(5*1000*1000) + +def _buildCmdLineParser(): + parser = argparse.ArgumentParser( + formatter_class=argparse.RawDescriptionHelpFormatter, + description=textwrap.dedent('''\ + TDengine Performance Benchmarking Tool + --------------------------------------------------------------------- + + ''')) + + parser.add_argument( + '-b', + '--benchmark-name', + action='store', + default='Taos1kQuery', + type=str, + help='Benchmark to use (default: Taos1kQuery)') + + parser.add_argument( + '-d', + '--debug', + action='store_true', + help='Turn on DEBUG mode for more logging (default: false)') + + parser.add_argument( + '-i', + '--iterate-directly', + action='store_true', + help='Execution operations directly without sub-process (default: false)') + + parser.add_argument( + '-l', + '--loop-count', + action='store', + default=1000, + type=int, + help='Number of loops to perform, 100 operations per loop. (default: 1000)') + + parser.add_argument( + '-n', + '--target-table-name', + action='store', + default=None, + type=str, + help='Regular table name in target DB (default: None)') + + parser.add_argument( + '-s', + '--subprocess-count', + action='store', + default=4, + type=int, + help='Number of sub processes to spawn. (default: 10)') + + parser.add_argument( + '-t', + '--target-database', + action='store', + default='taos', + type=str, + help='Benchmark target: taos, influx (default: taos)') + + return parser + +def main(): + parser = _buildCmdLineParser() + Config.init(parser) + Logging.clsInit(Config.getConfig().debug) + Dice.seed(0) # initial seeding of dice + + bName = Config.getConfig().benchmark_name + bClassName = bName + 'Benchmark' + x = globals() + if bClassName in globals(): + bClass = globals()[bClassName] + bm = bClass() # Benchmark object + bm.run() + else: + raise PerfGenError("No such benchmark: {}".format(bName)) + + # bm = Benchmark.create(Config.getConfig().target_database) + # bm.run() + +if __name__ == "__main__": + main() + + diff --git a/tests/pytest/perf_gen.sh b/tests/pytest/perf_gen.sh new file mode 100755 index 0000000000000000000000000000000000000000..d28b5422f8ba4d4683c78020e45d2085385c4b4f --- /dev/null +++ b/tests/pytest/perf_gen.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +# This is the script for us to try to cause the TDengine server or client to crash +# +# PREPARATION +# +# 1. Build an compile the TDengine source code that comes with this script, in the same directory tree +# 2. Please follow the direction in our README.md, and build TDengine in the build/ directory +# 3. Adjust the configuration file if needed under build/test/cfg/taos.cfg +# 4. Run the TDengine server instance: cd build; ./build/bin/taosd -c test/cfg +# 5. Make sure you have a working Python3 environment: run /usr/bin/python3 --version, and you should get 3.6 or above +# 6. Make sure you have the proper Python packages: # sudo apt install python3-setuptools python3-pip python3-distutils +# +# RUNNING THIS SCRIPT +# +# This script assumes the source code directory is intact, and that the binaries has been built in the +# build/ directory, as such, will will load the Python libraries in the directory tree, and also load +# the TDengine client shared library (so) file, in the build/directory, as evidenced in the env +# variables below. +# +# Running the script is simple, no parameter is needed (for now, but will change in the future). +# +# Happy Crashing... + + +# Due to the heavy path name assumptions/usage, let us require that the user be in the current directory +EXEC_DIR=`dirname "$0"` +if [[ $EXEC_DIR != "." ]] +then + echo "ERROR: Please execute `basename "$0"` in its own directory (for now anyway, pardon the dust)" + exit -1 +fi + +CURR_DIR=`pwd` +IN_TDINTERNAL="community" +if [[ "$CURR_DIR" == *"$IN_TDINTERNAL"* ]]; then + TAOS_DIR=$CURR_DIR/../../.. + TAOSD_DIR=`find $TAOS_DIR -name "taosd"|grep bin|head -n1` + LIB_DIR=`echo $TAOSD_DIR|rev|cut -d '/' -f 3,4,5,6,7|rev`/lib +else + TAOS_DIR=$CURR_DIR/../.. + TAOSD_DIR=`find $TAOS_DIR -name "taosd"|grep bin|head -n1` + LIB_DIR=`echo $TAOSD_DIR|rev|cut -d '/' -f 3,4,5,6|rev`/lib +fi + +# Now getting ready to execute Python +# The following is the default of our standard dev env (Ubuntu 20.04), modify/adjust at your own risk +PYTHON_EXEC=python3.8 + +# First we need to set up a path for Python to find our own TAOS modules, so that "import" can work. +export PYTHONPATH=$(pwd)/../../src/connector/python:$(pwd) + +# Then let us set up the library path so that our compiled SO file can be loaded by Python +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LIB_DIR + +# Now we are all let, and let's see if we can find a crash. Note we pass all params +PERF_GEN_EXEC=perf_gen.py +$PYTHON_EXEC $PERF_GEN_EXEC $@ + + diff --git a/tests/pytest/perfbenchmark/bug3433.py b/tests/pytest/perfbenchmark/bug3433.py new file mode 100644 index 0000000000000000000000000000000000000000..e4480df6b6753df88e3526930ac4bee087264d35 --- /dev/null +++ b/tests/pytest/perfbenchmark/bug3433.py @@ -0,0 +1,241 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import json + +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def __init__(self): + self.path = "" + + def init(self, conn, logSql): + tdLog.debug(f"start to execute {__file__}") + tdSql.init(conn.cursor(), logSql) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def getcfgPath(self, path): + binPath = os.path.dirname(os.path.realpath(__file__)) + binPath = binPath + "/../../../debug/" + tdLog.debug(f"binPath {binPath}") + binPath = os.path.realpath(binPath) + tdLog.debug(f"binPath real path {binPath}") + if path == "": + self.path = os.path.abspath(binPath + "../../") + else: + self.path = os.path.realpath(path) + return self.path + + def getCfgDir(self): + self.getcfgPath(self.path) + self.cfgDir = f"{self.path}/sim/psim/cfg" + return self.cfgDir + + def creatcfg(self): + dbinfo = { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 3650, + "minRows": 100, + "maxRows": 4096, + "comp": 2, + "walLevel": 1, + "cachelast": 0, + "quorum": 1, + "fsync": 3000, + "update": 0 + } + + # set stable schema + stable1 = { + "name": "stb1", + "child_table_exists": "no", + "childtable_count": 1000, + "childtable_prefix": "t1", + "auto_create_table": "no", + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 1, + "rows_per_tbl": 1, + "max_sql_len": 65480, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 20000, + "start_timestamp": "2020-12-31 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [ + {"type": "INT", "count": 2}, + {"type": "DOUBLE", "count": 2}, + {"type": "BIGINT", "count": 2}, + {"type": "FLOAT", "count": 2}, + {"type": "SMALLINT", "count": 2}, + {"type": "TINYINT", "count": 2}, + {"type": "BOOL", "count": 2}, + {"type": "NCHAR", "len": 3, "count": 1}, + {"type": "BINARY", "len": 8, "count": 1} + + ], + "tags": [ + {"type": "INT", "count": 2}, + {"type": "DOUBLE", "count": 2}, + {"type": "BIGINT", "count": 2}, + {"type": "FLOAT", "count": 2}, + {"type": "SMALLINT", "count": 2}, + {"type": "TINYINT", "count": 2}, + {"type": "BOOL", "count": 2}, + {"type": "NCHAR", "len": 3, "count": 1}, + {"type": "BINARY", "len": 8, "count": 1} + ] + } + stable2 = { + "name": "stb2", + "child_table_exists": "no", + "childtable_count": 1000, + "childtable_prefix": "t2", + "auto_create_table": "no", + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 1, + "rows_per_tbl": 1, + "max_sql_len": 65480, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 20000, + "start_timestamp": "2020-12-31 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [ + {"type": "INT", "count": 2}, + {"type": "DOUBLE", "count": 2}, + {"type": "BIGINT", "count": 2}, + {"type": "FLOAT", "count": 2}, + {"type": "SMALLINT", "count": 2}, + {"type": "TINYINT", "count": 2}, + {"type": "BOOL", "count": 2}, + {"type": "NCHAR", "len": 3, "count": 1}, + {"type": "BINARY", "len": 8, "count": 1} + + ], + "tags": [ + {"type": "INT", "count": 2}, + {"type": "DOUBLE", "count": 2}, + {"type": "BIGINT", "count": 2}, + {"type": "FLOAT", "count": 2}, + {"type": "SMALLINT", "count": 2}, + {"type": "TINYINT", "count": 2}, + {"type": "BOOL", "count": 2}, + {"type": "NCHAR", "len": 3, "count": 1}, + {"type": "BINARY", "len": 8, "count": 1} + ] + } + + # create different stables like stable1 and add to list super_tables + super_tables = [] + super_tables.append(stable1) + super_tables.append(stable2) + database = { + "dbinfo": dbinfo, + "super_tables": super_tables + } + + cfgdir = self.getCfgDir() + create_table = { + "filetype": "insert", + "cfgdir": cfgdir, + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "/tmp/insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "num_of_records_per_req": 100, + "databases": [database] + } + return create_table + + def createinsertfile(self): + create_table = self.creatcfg() + date = datetime.datetime.now().strftime("%Y%m%d%H%M") + file_create_table = f"/tmp/insert_{date}.json" + + with open(file_create_table, 'w') as f: + json.dump(create_table, f) + return file_create_table + + def inserttable(self, filepath): + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info(f"taosd found in {buildPath}") + binPath = buildPath + "/build/bin/" + + create_table_cmd = f"{binPath}taosdemo -f {filepath} > /dev/null 2>&1" + _ = subprocess.check_output(create_table_cmd, shell=True).decode("utf-8") + + def droptmpfile(self): + drop_file_cmd = "rm -f /tmp/insert_* " + _ = subprocess.check_output(drop_file_cmd, shell=True).decode("utf-8") + + def run(self): + tdLog.printNoPrefix("==========step1:create database and insert records") + file_create_table = self.createinsertfile() + self.inserttable(file_create_table) + + tdLog.printNoPrefix("==========step2:check database and stable records") + tdSql.query("show databases") + tdSql.checkData(0, 2, 2000) + tdSql.execute("use db") + tdSql.query("show stables") + tdSql.checkData(0, 4, 1000) + tdSql.checkData(1, 4, 1000) + + self.droptmpfile() + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/pytest/perfbenchmark/bug3589.py b/tests/pytest/perfbenchmark/bug3589.py new file mode 100644 index 0000000000000000000000000000000000000000..c54ef8595d0bea1c4984b3f90e282f09659576c3 --- /dev/null +++ b/tests/pytest/perfbenchmark/bug3589.py @@ -0,0 +1,156 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import json + +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def __init__(self): + self.path = "" + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/debug/build/bin")] + break + return buildPath + + def getCfgDir(self): + return self.getBuildPath() + "/sim/psim/cfg" + + def querycfg(self): + cfgdir = self.getCfgDir() + querycfg={ + "filetype": "query", + "cfgdir": cfgdir, + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "confirm_parameter_prompt": "yes", + "databases": "db", + "specified_table_query": { + "query_interval": 0, + "concurrent": 1, + "sqls": [ + { + "sql": "select * from t10, t11 where t10.ts=t11.ts" + } + ] + } + } + + return querycfg + + def querycfgfile(self): + querycfg = self.querycfg() + date = datetime.datetime.now().strftime("%Y%m%d%H%M") + querycfg.get("specified_table_query").get("sqls")[0]["result"] = f"/tmp/query_{date}.log" + file_query_table = f"/tmp/query_{date}.json" + with open(file_query_table, "w") as f: + json.dump(querycfg, f) + + return [file_query_table, querycfg] + + def querytable(self, filepath): + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info(f"taosd found in {buildPath}") + binPath = buildPath + "/debug/build/bin/" + + query_table_cmd = f"yes | {binPath}taosdemo -f {filepath}" + _ = subprocess.check_output(query_table_cmd, shell=True).decode("utf-8") + + def checkqueryresult(self, expectrows): + querycfg = self.querycfgfile()[1] + result_file = querycfg.get("specified_table_query").get("sqls")[0].get("result") + "-0" + if result_file: + check_cmd = f"wc -l {result_file}" + check_data_init = subprocess.check_output(check_cmd, shell=True).decode("utf-8") + check_data = int(check_data_init[0]) + if check_data == expectrows: + tdLog.info(f"queryResultRows:{check_data} == expect:{expectrows}") + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, check_data, expectrows) + tdLog.exit(f"{args[0]}({args[1]}) failed: result:{args[2]} != expect:{args[3]}") + + def droptmpfile(self): + drop_file_cmd = "rm -f /tmp/query_* " + _ = subprocess.check_output(drop_file_cmd, shell=True).decode("utf-8") + drop_file_cmd = "rm -f querySystemInfo-*" + _ = subprocess.check_output(drop_file_cmd, shell=True).decode("utf-8") + + def run(self): + tdSql.prepare() + + tdLog.printNoPrefix("==========step1:create table && insert data") + tdSql.execute("alter database db keep 36500") + tdSql.execute( + "create table stb1 (ts timestamp, c1 int) TAGS(t1 int)" + ) + tdSql.execute("create table t10 using stb1 tags(1)") + tdSql.execute("create table t11 using stb1 tags(2)") + + tdSql.execute("insert into t10 values (-865000000, 1)") + tdSql.execute("insert into t11 values (-865000000, 2)") + tdSql.execute("insert into t10 values ('1969-12-31 23:59:59.000', 2)") + tdSql.execute("insert into t11 values ('1969-12-31 23:59:59.000', 3)") + tdSql.execute("insert into t10 values ('1970-01-01 00:00:00.000', 3)") + tdSql.execute("insert into t11 values ('1970-01-01 00:00:00.000', 4)") + tdSql.execute("insert into t10 values (-15230000, 4)") + tdSql.execute("insert into t11 values (-15230000, 5)") + tdSql.execute("insert into t10 values (-15220000, 5)") + tdSql.execute("insert into t11 values (-15220000, 6)") + tdSql.execute("insert into t10 values (-15210000, 6)") + tdSql.execute("insert into t11 values (-15210000, 7)") + tdSql.execute("insert into t10 values (0, 7)") + tdSql.execute("insert into t11 values (0, 8)") + tdSql.execute("insert into t10 values ('2020-10-01 00:00:00.000', 8)") + tdSql.execute("insert into t11 values ('2020-10-01 00:00:00.000', 9)") + + tdLog.printNoPrefix("==========step2:query") + query_file = self.querycfgfile()[0] + self.querytable(query_file) + self.checkqueryresult(8) + + self.droptmpfile() + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/perfbenchmark/joinPerformance.py b/tests/pytest/perfbenchmark/joinPerformance.py new file mode 100644 index 0000000000000000000000000000000000000000..acd4f88c9b1a2df91f7e129ac87d57c9b04c7106 --- /dev/null +++ b/tests/pytest/perfbenchmark/joinPerformance.py @@ -0,0 +1,355 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import taos +import os +import json +import argparse +import subprocess +import datetime +import re + +from multiprocessing import cpu_count +# from util.log import * +# from util.sql import * +# from util.cases import * +# from util.dnodes import * + +class JoinPerf: + + def __init__(self, clearCache, dbName, keep): + self.clearCache = clearCache + self.dbname = dbName + self.drop = "yes" + self.keep = keep + self.host = "127.0.0.1" + self.user = "root" + self.password = "taosdata" + self.config = "/etc/taosperf" + self.conn = taos.connect( + self.host, + self.user, + self.password, + self.config) + + # def init(self, conn, logSql): + # tdLog.debug(f"start to excute {__file__}") + # tdSql.init(conn.cursor()) + + def getBuildPath(self) -> str: + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/debug/build/bin")] + break + return buildPath + + def getCfgDir(self) -> str: + return self.getBuildPath() + "/sim/dnode1/cfg" + + # def initConnection(self): + # return self.getCfgDir() + + # def connectDB(self): + # self.conn = taos.connect( + # self.host, + # self.user, + # self.password, + # self.getCfgDir()) + # return self.conn.cursor() + + def dbinfocfg(self) -> dict: + return { + "name": self.dbname, + "drop": self.drop, + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": self.keep, + "minRows": 100, + "maxRows": 4096, + "comp": 2, + "walLevel": 1, + "cachelast": 0, + "quorum": 1, + "fsync": 3000, + "update": 0 + } + + # def column_tag_count(self, **column_tag) -> list : + # return [{"type": type, "count": count} for type, count in column_tag.items()] + + def type_check(func): + def wrapper(self, **kwargs): + num_types = ["int", "float", "bigint", "tinyint", "smallint", "double"] + str_types = ["binary", "nchar"] + for k ,v in kwargs.items(): + if k.lower() not in num_types and k.lower() not in str_types: + return f"args {k} type error, not allowed" + elif not isinstance(v, (int, list, tuple)): + return f"value {v} type error, not allowed" + elif k.lower() in num_types and not isinstance(v, int): + return f"arg {v} takes 1 positional argument must be type int " + elif isinstance(v, (list,tuple)) and len(v) > 2: + return f"arg {v} takes from 1 to 2 positional arguments but more than 2 were given " + elif isinstance(v,(list,tuple)) and [ False for _ in v if not isinstance(_, int) ]: + return f"arg {v} takes from 1 to 2 positional arguments must be type int " + else: + pass + return func(self, **kwargs) + return wrapper + + @type_check + def column_tag_count(self, **column_tag) -> list : + init_column_tag = [] + for k, v in column_tag.items(): + if re.search(k, "int, float, bigint, tinyint, smallint, double", re.IGNORECASE): + init_column_tag.append({"type": k, "count": v}) + elif re.search(k, "binary, nchar", re.IGNORECASE): + if isinstance(v, int): + init_column_tag.append({"type": k, "count": v, "len":8}) + elif len(v) == 1: + init_column_tag.append({"type": k, "count": v[0], "len": 8}) + else: + init_column_tag.append({"type": k, "count": v[0], "len": v[1]}) + return init_column_tag + + def stbcfg(self, stb: str, child_tab_count: int, prechildtab: str, columns: dict, tags: dict) -> dict: + return { + "name": stb, + "child_table_exists": "no", + "childtable_count": child_tab_count, + "childtable_prefix": prechildtab, + "auto_create_table": "no", + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 50, + "multi_thread_write_one_tbl": "no", + "number_of_tbl_in_one_sql": 0, + "rows_per_tbl": 1, + "max_sql_len": 65480, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 20000, + "start_timestamp": "1969-12-31 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": self.column_tag_count(**columns), + "tags": self.column_tag_count(**tags) + } + + def createcfg(self,db: dict, stbs: list) -> dict: + return { + "filetype": "insert", + "cfgdir": self.config, + "host": self.host, + "port": 6030, + "user": self.user, + "password": self.password, + "thread_count": cpu_count(), + "thread_count_create_tbl": cpu_count(), + "result_file": "/tmp/insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "num_of_records_per_req": 100, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": db, + "super_tables": stbs + }] + } + + def createinsertfile(self,db: dict, stbs: list) -> str: + date = datetime.datetime.now().strftime("%Y%m%d%H%M") + file_create_table = f"/tmp/insert_{date}.json" + + with open(file_create_table, 'w') as f: + json.dump(self.createcfg(db, stbs), f) + + return file_create_table + + def querysqls(self, sql: str) -> list: + return [{"sql":sql,"result":""}] + + def querycfg(self, sql: str) -> dict: + return { + "filetype": "query", + "cfgdir": self.config, + "host": self.host, + "port": 6030, + "user": self.user, + "password": self.password, + "confirm_parameter_prompt": "yes", + "databases": "db", + "specified_table_query": { + "query_interval": 0, + "concurrent": cpu_count(), + "sqls": self.querysqls(sql) + } + } + + def createqueryfile(self, sql: str): + date = datetime.datetime.now().strftime("%Y%m%d%H%M") + file_query_table = f"/tmp/query_{date}.json" + + with open(file_query_table,"w") as f: + json.dump(self.querycfg(sql), f) + + return file_query_table + + def taosdemotable(self, filepath, resultfile="/dev/null"): + taosdemopath = self.getBuildPath() + "/debug/build/bin" + with open(filepath,"r") as f: + filetype = json.load(f)["filetype"] + if filetype == "insert": + taosdemo_table_cmd = f"{taosdemopath}/taosdemo -f {filepath} > {resultfile} 2>&1" + else: + taosdemo_table_cmd = f"yes | {taosdemopath}/taosdemo -f {filepath} > {resultfile} 2>&1" + _ = subprocess.check_output(taosdemo_table_cmd, shell=True).decode("utf-8") + + def droptmpfile(self): + drop_file_cmd = "rm -f /tmp/query_* " + _ = subprocess.check_output(drop_file_cmd, shell=True).decode("utf-8") + drop_file_cmd = "rm -f querySystemInfo-*" + _ = subprocess.check_output(drop_file_cmd, shell=True).decode("utf-8") + drop_file_cmd = "rm -f /tmp/insert_* " + _ = subprocess.check_output(drop_file_cmd, shell=True).decode("utf-8") + + def run(self): + print("========== join on table schema performance ==========") + if self.clearCache == True: + # must be root permission + subprocess.check_output("echo 3 > /proc/sys/vm/drop_caches") + + # cfg = { + # 'enableRecordSql': '1' + # } + # tdDnodes.deploy(1, cfg) + + # tdLog.printNoPrefix("==========step1: create 1024 columns on different data type==========") + # db = self.dbinfocfg() + # stblist = [] + # # the supertable config for each type in column_tag_types + # column_tag_types = ["INT","FLOAT","BIGINT","TINYINT","SMALLINT","DOUBLE","BINARY","NCHAR"] + # for i in range(len(column_tag_types)): + # tagtype = { + # "INT": 0, + # "FLOAT": 0, + # "BIGINT": 0, + # "TINYINT": 0, + # "SMALLINT": 0, + # "DOUBLE": 0, + # "BINARY": 0, + # "NCHAR": 0 + # } + # columntype = tagtype.copy() + # tagtype["INT"] = 2 + # if column_tag_types[i] == "BINARY": + # columntype[column_tag_types[i]] = [509, 10] + # elif column_tag_types[i] == "NCHAR": + # columntype[column_tag_types[i]] = [350, 10] + # else: + # columntype[column_tag_types[i]] = 1021 + # supertable = self.stbcfg( + # stb=f"stb{i}", + # child_tab_count=2, + # prechildtab=f"t{i}", + # columns=columntype, + # tags=tagtype + # ) + # stblist.append(supertable) + # self.taosdemotable(self.createinsertfile(db=db, stbs=stblist)) + + # tdLog.printNoPrefix("==========step2: execute query operation==========") + # tdLog.printNoPrefix("==========execute query operation==========") + sqls = { + "nchar":"select * from t00,t01 where t00.ts=t01.ts" + } + for type, sql in sqls.items(): + result_file = f"/tmp/queryResult_{type}.log" + self.taosdemotable(self.createqueryfile(sql), resultfile=result_file) + if result_file: + # tdLog.printNoPrefix(f"execute type {type} sql, the sql is: {sql}") + print(f"execute type {type} sql, the sql is: {sql}") + max_sql_time_cmd = f''' + grep Spent {result_file} | awk 'NR==1{{max=$7;next}}{{max=max>$7?max:$7}}END{{print "Max=",max,"s"}}' + ''' + max_sql_time = subprocess.check_output(max_sql_time_cmd, shell=True).decode("UTF-8") + # tdLog.printNoPrefix(f"type: {type} sql time : {max_sql_time}") + print(f"type: {type} sql time : {max_sql_time}") + + min_sql_time_cmd = f''' + grep Spent {result_file} | awk 'NR==1{{min=$7;next}}{{min=min<$7?min:$7}}END{{print "Min=",min,"s"}}' + ''' + min_sql_time = subprocess.check_output(min_sql_time_cmd, shell=True).decode("UTF-8") + # tdLog.printNoPrefix(f"type: {type} sql time : {min_sql_time}") + print(f"type: {type} sql time : {min_sql_time}") + + avg_sql_time_cmd = f''' + grep Spent {result_file} |awk '{{sum+=$7}}END{{print "Average=",sum/NR,"s"}}' + ''' + avg_sql_time = subprocess.check_output(avg_sql_time_cmd, shell=True).decode("UTF-8") + # tdLog.printNoPrefix(f"type: {type} sql time : {avg_sql_time}") + print(f"type: {type} sql time : {avg_sql_time}") + + # tdLog.printNoPrefix(f"==========type {type} sql is over==========") + + # tdLog.printNoPrefix("==========query operation is over==========") + + self.droptmpfile() + # tdLog.printNoPrefix("==========tmp file has been deleted==========") + + # def stop(self): + # tdSql.close() + # tdLog.success(f"{__file__} successfully executed") + +# tdCases.addLinux(__file__, TDTestCase()) +# tdCases.addWindows(__file__, TDTestCase()) + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + parser.add_argument( + '-r', + '--remove-cache', + action='store_true', + default=False, + help='clear cache before query (default: False)') + parser.add_argument( + '-d', + '--database-name', + action='store', + default='db', + type=str, + help='Database name to be created (default: db)') + parser.add_argument( + '-k', + '--keep-time', + action='store', + default=36500, + type=int, + help='Database keep parameters (default: 36500)') + + args = parser.parse_args() + jointest = JoinPerf(args.remove_cache, args.database_name, args.keep_time) + jointest.run() \ No newline at end of file diff --git a/tests/pytest/perfbenchmark/taosdemoInsert.py b/tests/pytest/perfbenchmark/taosdemoInsert.py new file mode 100644 index 0000000000000000000000000000000000000000..59a8143d5a34014ecbdfe57c6ecc073c0eaeb39c --- /dev/null +++ b/tests/pytest/perfbenchmark/taosdemoInsert.py @@ -0,0 +1,387 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import taos +import sys +import os +import json +import argparse +import subprocess +import datetime +import re + + +from multiprocessing import cpu_count +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * +from util.dnodes import TDDnode + +class Taosdemo: + def __init__(self, clearCache, dbName, keep): + self.clearCache = clearCache + self.dbname = dbName + self.drop = "yes" + self.keep = keep + self.host = "127.0.0.1" + self.user = "root" + self.password = "taosdata" + # self.config = "/etc/taosperf" + # self.conn = taos.connect( + # self.host, + # self.user, + # self.password, + # self.config) + + # env config + def getBuildPath(self) -> str: + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/debug/build/bin")] + break + return buildPath + + def getExeToolsDir(self) -> str: + self.debugdir = self.getBuildPath() + "/debug/build/bin" + return self.debugdir + + def getCfgDir(self) -> str: + self.config = self.getBuildPath() + "/sim/dnode1/cfg" + return self.config + + # taodemo insert file config + def dbinfocfg(self) -> dict: + return { + "name": self.dbname, + "drop": self.drop, + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": self.keep, + "minRows": 100, + "maxRows": 4096, + "comp": 2, + "walLevel": 1, + "cachelast": 0, + "quorum": 1, + "fsync": 3000, + "update": 0 + } + + def type_check(func): + def wrapper(self, **kwargs): + num_types = ["int", "float", "bigint", "tinyint", "smallint", "double"] + str_types = ["binary", "nchar"] + for k ,v in kwargs.items(): + if k.lower() not in num_types and k.lower() not in str_types: + return f"args {k} type error, not allowed" + elif not isinstance(v, (int, list, tuple)): + return f"value {v} type error, not allowed" + elif k.lower() in num_types and not isinstance(v, int): + return f"arg {v} takes 1 positional argument must be type int " + elif isinstance(v, (list,tuple)) and len(v) > 2: + return f"arg {v} takes from 1 to 2 positional arguments but more than 2 were given " + elif isinstance(v,(list,tuple)) and [ False for _ in v if not isinstance(_, int) ]: + return f"arg {v} takes from 1 to 2 positional arguments must be type int " + else: + pass + return func(self, **kwargs) + return wrapper + + @type_check + def column_tag_count(self, **column_tag) -> list : + init_column_tag = [] + for k, v in column_tag.items(): + if re.search(k, "int, float, bigint, tinyint, smallint, double", re.IGNORECASE): + init_column_tag.append({"type": k, "count": v}) + elif re.search(k, "binary, nchar", re.IGNORECASE): + if isinstance(v, int): + init_column_tag.append({"type": k, "count": v, "len":8}) + elif len(v) == 1: + init_column_tag.append({"type": k, "count": v[0], "len": 8}) + else: + init_column_tag.append({"type": k, "count": v[0], "len": v[1]}) + return init_column_tag + + def stbcfg(self, stb: str, child_tab_count: int, rows: int, prechildtab: str, columns: dict, tags: dict) -> dict: + return { + "name": stb, + "child_table_exists": "no", + "childtable_count": child_tab_count, + "childtable_prefix": prechildtab, + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": rows, + "childtable_limit": 0, + "childtable_offset": 0, + "rows_per_tbl": 1, + "max_sql_len": 65480, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": f"{datetime.datetime.now():%F %X}", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": self.column_tag_count(**columns), + "tags": self.column_tag_count(**tags) + } + + def schemecfg(self,intcount=1,floatcount=0,bcount=0,tcount=0,scount=0,doublecount=0,binarycount=0,ncharcount=0): + return { + "INT": intcount, + "FLOAT": floatcount, + "BIGINT": bcount, + "TINYINT": tcount, + "SMALLINT": scount, + "DOUBLE": doublecount, + "BINARY": binarycount, + "NCHAR": ncharcount + } + + def insertcfg(self,db: dict, stbs: list) -> dict: + return { + "filetype": "insert", + "cfgdir": self.config, + "host": self.host, + "port": 6030, + "user": self.user, + "password": self.password, + "thread_count": cpu_count(), + "thread_count_create_tbl": cpu_count(), + "result_file": "/tmp/insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "num_of_records_per_req": 100, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": db, + "super_tables": stbs + }] + } + + def createinsertfile(self,db: dict, stbs: list) -> str: + date = datetime.datetime.now() + file_create_table = f"/tmp/insert_{date:%F-%H%M}.json" + + with open(file_create_table, 'w') as f: + json.dump(self.insertcfg(db, stbs), f) + + return file_create_table + + # taosdemo query file config + def querysqls(self, sql: str) -> list: + return [{"sql":sql,"result":""}] + + def querycfg(self, sql: str) -> dict: + return { + "filetype": "query", + "cfgdir": self.config, + "host": self.host, + "port": 6030, + "user": self.user, + "password": self.password, + "confirm_parameter_prompt": "yes", + "query_times": 10, + "query_mode": "taosc", + "databases": self.dbname, + "specified_table_query": { + "query_interval": 0, + "concurrent": cpu_count(), + "sqls": self.querysqls(sql) + } + } + + def createqueryfile(self, sql: str): + date = datetime.datetime.now() + file_query_table = f"/tmp/query_{date:%F-%H%M}.json" + + with open(file_query_table,"w") as f: + json.dump(self.querycfg(sql), f) + + return file_query_table + + # Execute taosdemo, and delete temporary files when finished + def taosdemotable(self, filepath: str, resultfile="/dev/null"): + taosdemopath = self.getBuildPath() + "/debug/build/bin" + with open(filepath,"r") as f: + filetype = json.load(f)["filetype"] + if filetype == "insert": + taosdemo_table_cmd = f"{taosdemopath}/taosdemo -f {filepath} > {resultfile} 2>&1" + else: + taosdemo_table_cmd = f"yes | {taosdemopath}/taosdemo -f {filepath} > {resultfile} 2>&1" + try: + _ = subprocess.check_output(taosdemo_table_cmd, shell=True).decode("utf-8") + except subprocess.CalledProcessError as e: + _ = e.output + + def droptmpfile(self, filepath: str): + drop_file_cmd = f"[ -f {filepath} ] && rm -f {filepath}" + try: + _ = subprocess.check_output(drop_file_cmd, shell=True).decode("utf-8") + except subprocess.CalledProcessError as e: + _ = e.output + + # TODO:需要完成TD-4153的数据插入和客户端请求的性能查询。 + def td4153insert(self): + + tdLog.printNoPrefix("========== start to create table and insert data ==========") + self.dbname = "td4153" + db = self.dbinfocfg() + stblist = [] + + columntype = self.schemecfg(intcount=1, ncharcount=100) + tagtype = self.schemecfg(intcount=1) + stbname = "stb1" + prechild = "t1" + stable = self.stbcfg( + stb=stbname, + prechildtab=prechild, + child_tab_count=2, + rows=10000, + columns=columntype, + tags=tagtype + ) + stblist.append(stable) + insertfile = self.createinsertfile(db=db, stbs=stblist) + + nmon_file = f"/tmp/insert_{datetime.datetime.now():%F-%H%M}.nmon" + cmd = f"nmon -s5 -F {nmon_file} -m /tmp/" + try: + _ = subprocess.check_output(cmd, shell=True).decode("utf-8") + except subprocess.CalledProcessError as e: + _ = e.output + + self.taosdemotable(insertfile) + self.droptmpfile(insertfile) + self.droptmpfile("/tmp/insert_res.txt") + + # In order to prevent too many performance files from being generated, the nmon file is deleted. + # and the delete statement can be cancelled during the actual test. + self.droptmpfile(nmon_file) + + cmd = f"ps -ef|grep -w nmon| grep -v grep | awk '{{print $2}}'" + try: + time.sleep(10) + _ = subprocess.check_output(cmd,shell=True).decode("utf-8") + except BaseException as e: + raise e + + def td4153query(self): + tdLog.printNoPrefix("========== start to query operation ==========") + + sqls = { + "select_all": "select * from stb1", + "select_join": "select * from t10, t11 where t10.ts=t11.ts" + } + for type, sql in sqls.items(): + result_file = f"/tmp/queryResult_{type}.log" + query_file = self.createqueryfile(sql) + try: + self.taosdemotable(query_file, resultfile=result_file) + except subprocess.CalledProcessError as e: + out_put = e.output + if result_file: + print(f"execute rows {type.split('_')[1]} sql, the sql is: {sql}") + max_sql_time_cmd = f''' + grep -o Spent.*s {result_file} |awk 'NR==1{{max=$2;next}}{{max=max>$2?max:$2}}END{{print "Max=",max,"s"}}' + ''' + max_sql_time = subprocess.check_output(max_sql_time_cmd, shell=True).decode("UTF-8") + print(f"{type.split('_')[1]} rows sql time : {max_sql_time}") + + min_sql_time_cmd = f''' + grep -o Spent.*s {result_file} |awk 'NR==1{{min=$2;next}}{{min=min<$2?min:$2}}END{{print "Min=",min,"s"}}' + ''' + min_sql_time = subprocess.check_output(min_sql_time_cmd, shell=True).decode("UTF-8") + print(f"{type.split('_')[1]} rows sql time : {min_sql_time}") + + avg_sql_time_cmd = f''' + grep -o Spent.*s {result_file} |awk '{{sum+=$2}}END{{print "Average=",sum/NR,"s"}}' + ''' + avg_sql_time = subprocess.check_output(avg_sql_time_cmd, shell=True).decode("UTF-8") + print(f"{type.split('_')[1]} rows sql time : {avg_sql_time}") + + self.droptmpfile(query_file) + self.droptmpfile(result_file) + + drop_query_tmt_file_cmd = " find ./ -name 'querySystemInfo-*' -type f -exec rm {} \; " + try: + _ = subprocess.check_output(drop_query_tmt_file_cmd, shell=True).decode("utf-8") + except subprocess.CalledProcessError as e: + _ = e.output + pass + + def td4153(self): + self.td4153insert() + self.td4153query() + + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + parser.add_argument( + '-r', + '--remove-cache', + action='store_true', + default=False, + help='clear cache before query (default: False)') + parser.add_argument( + '-d', + '--database-name', + action='store', + default='db', + type=str, + help='Database name to be created (default: db)') + parser.add_argument( + '-k', + '--keep-time', + action='store', + default=3650, + type=int, + help='Database keep parameters (default: 3650)') + + args = parser.parse_args() + taosdemo = Taosdemo(args.remove_cache, args.database_name, args.keep_time) + # taosdemo.conn = taos.connect( + # taosdemo.host, + # taosdemo.user, + # taosdemo.password, + # taosdemo.config + # ) + + debugdir = taosdemo.getExeToolsDir() + cfgdir = taosdemo.getCfgDir() + cmd = f"{debugdir}/taosd -c {cfgdir} >/dev/null 2>&1 &" + try: + _ = subprocess.check_output(cmd, shell=True).decode("utf-8") + except subprocess.CalledProcessError as e: + _ = e.output + + if taosdemo.clearCache: + # must be root permission + subprocess.check_output("echo 3 > /proc/sys/vm/drop_caches", shell=True).decode("utf-8") + + taosdemo.td4153() diff --git a/tests/pytest/query/__init__.py b/tests/pytest/query/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/pytest/query/bug1471.py b/tests/pytest/query/bug1471.py new file mode 100644 index 0000000000000000000000000000000000000000..f1cb0bdcdfbb085410d0001606208e11373687a1 --- /dev/null +++ b/tests/pytest/query/bug1471.py @@ -0,0 +1,73 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import time +import threading + + +class myThread(threading.Thread): + def __init__(self, conn): + threading.Thread.__init__(self) + self.event = threading.Event() + self.conn = taos.connect(conn._host, port=conn._port, config=conn._config) + + def run(self): + cur = self.conn.cursor() + self.event.wait() + cur.execute("drop database db") + cur.close() + self.conn.close() + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + def run(self): + for i in range(50): + print("round", i) + thread = myThread(tdSql.cursor._connection) + thread.start() + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists db') + tdSql.execute('create database db') + tdSql.execute('use db') + tdSql.execute("create table car (ts timestamp, s int)") + tdSql.execute("insert into car values('2020-10-19 17:00:00', 123)") + + thread.event.set() + try: + tdSql.query("select s from car where ts = '2020-10-19 17:00:00'") + except Exception as e: + pass + else: + tdSql.checkData(0, 0, 123) + + thread.join() + time.sleep(0.2) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/bug1874.py b/tests/pytest/query/bug1874.py new file mode 100644 index 0000000000000000000000000000000000000000..717748487089f229cc578882b91000a7d488fcda --- /dev/null +++ b/tests/pytest/query/bug1874.py @@ -0,0 +1,59 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + print("==========step1") + print("create table && insert data") + + tdSql.execute("create table join_mt0 (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12))") + tdSql.execute("create table join_mt1 (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12))") + stable=0 + insertRows = 1000 + tbnum = 3 + t0 = 1604298064000 + tdLog.info("insert %d rows" % (insertRows)) + for i in range(tbnum): + tdSql.execute("create table join_tb%d using join_mt%d tags(%d,'abc')" %(i,stable,i)) + for j in range(insertRows): + ret = tdSql.execute( + "insert into join_tb%d values (%d , %d,%d,%d,%d,%d,%d,%d, '%s','%s')" % + (i,t0+i,i%100,i%100,i%100,i%100,i%100,i%100,i%100,'binary'+str(i%100),'nchar'+str(i%100))) + stable=stable+1 + for i in range(tbnum): + tdSql.execute("create table join_1_tb%d using join_mt%d tags(%d,'abc')" %(i,stable,i)) + for j in range(insertRows): + ret = tdSql.execute( + "insert into join_tb%d values (%d , %d,%d,%d,%d,%d,%d,%d, '%s','%s')" % + (i,t0+i,i%100,i%100,i%100,i%100,i%100,i%100,i%100,'binary'+str(i%100),'nchar'+str(i%100))) + print("==========step2") + print("join query ") + tdLog.info("select count(join_mt0.c1), first(join_mt0.c1) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts interval(10a) group by join_mt0.t1, join_mt0.t2, join_mt1.t1 order by join_mt0.ts desc, join_mt1.ts asc limit 10;") + tdSql.error("select count(join_mt0.c1), first(join_mt0.c1) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts interval(10a) group by join_mt0.t1, join_mt0.t2, join_mt1.t1 order by join_mt0.ts desc, join_mt1.ts asc limit 10;") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/query/bug1875.py b/tests/pytest/query/bug1875.py new file mode 100644 index 0000000000000000000000000000000000000000..12e22a7a259e1612d8da4f11647a0adcde5dae02 --- /dev/null +++ b/tests/pytest/query/bug1875.py @@ -0,0 +1,60 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + print("==========step1") + print("create table && insert data") + + tdSql.execute("create table join_mt0 (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12))") + tdSql.execute("create table join_mt1 (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12))") + stable=0 + insertRows = 1000 + tbnum = 3 + t0 = 1604298064000 + tdLog.info("insert %d rows" % (insertRows)) + for i in range(tbnum): + tdSql.execute("create table join_tb%d using join_mt%d tags(%d,'abc')" %(i,stable,i)) + for j in range(insertRows): + ret = tdSql.execute( + "insert into join_tb%d values (%d , %d,%d,%d,%d,%d,%d,%d, '%s','%s')" % + (i,t0+i,i%100,i%100,i%100,i%100,i%100,i%100,i%100,'binary'+str(i%100),'nchar'+str(i%100))) + stable=stable+1 + for i in range(tbnum): + tdSql.execute("create table join_1_tb%d using join_mt%d tags(%d,'abc')" %(i,stable,i)) + for j in range(insertRows): + ret = tdSql.execute( + "insert into join_tb%d values (%d , %d,%d,%d,%d,%d,%d,%d, '%s','%s')" % + (i,t0+i,i%100,i%100,i%100,i%100,i%100,i%100,i%100,'binary'+str(i%100),'nchar'+str(i%100))) + print("==========step2") + print("join query ") + tdLog.info("select count(join_mt0.c1), first(join_mt0.c1) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts interval(10a) group by join_mt0.t1, join_mt0.t2, join_mt1.t1 order by join_mt0.ts desc, join_mt1.ts asc limit 10;") + tdSql.error("select count(join_mt0.c1), first(join_mt0.c1), first(join_mt1.c9) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts interval(10a) group by join_mt0.t1, join_mt0.t2 order by join_mt0.t1 desc") + tdSql.error("select count(join_mt0.c1), first(join_mt0.c1), first(join_mt1.c9) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts interval(10a) group by join_mt0.t1, join_mt0.t2 order by join_mt0.t1 desc limit 3;") + tdSql.error("select count(join_mt0.c1), first(join_mt0.c1), first(join_mt1.c9) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts interval(10a) group by join_mt0.t1, join_mt0.t2 order by join_mt0.t1 desc slimit 3;") + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/query/bug1876.py b/tests/pytest/query/bug1876.py new file mode 100644 index 0000000000000000000000000000000000000000..a1cc4b6eb2dc3368fdb21989d3b8df27f74cc8f9 --- /dev/null +++ b/tests/pytest/query/bug1876.py @@ -0,0 +1,58 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + print("==========step1") + print("create table && insert data") + + tdSql.execute("create table join_mt0 (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12))") + tdSql.execute("create table join_mt1 (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12))") + stable=0 + insertRows = 1000 + tbnum = 3 + t0 = 1604298064000 + tdLog.info("insert %d rows" % (insertRows)) + for i in range(tbnum): + tdSql.execute("create table join_tb%d using join_mt%d tags(%d,'abc')" %(i,stable,i)) + for j in range(insertRows): + ret = tdSql.execute( + "insert into join_tb%d values (%d , %d,%d,%d,%d,%d,%d,%d, '%s','%s')" % + (i,t0+i,i%100,i%100,i%100,i%100,i%100,i%100,i%100,'binary'+str(i%100),'nchar'+str(i%100))) + stable=stable+1 + for i in range(tbnum): + tdSql.execute("create table join_1_tb%d using join_mt%d tags(%d,'abc')" %(i,stable,i)) + for j in range(insertRows): + ret = tdSql.execute( + "insert into join_tb%d values (%d , %d,%d,%d,%d,%d,%d,%d, '%s','%s')" % + (i,t0+i,i%100,i%100,i%100,i%100,i%100,i%100,i%100,'binary'+str(i%100),'nchar'+str(i%100))) + print("==========step2") + print("join query ") + tdLog.info("select count(join_mt0.c1), first(join_mt0.c1) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts interval(10a) group by join_mt0.t1, join_mt0.t2, join_mt1.t1 order by join_mt0.ts desc, join_mt1.ts asc limit 10;") + tdSql.error("select count(join_mt0.c1), first(join_mt0.c1)-first(join_mt1.c1), first(join_mt1.c9) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts;") + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/query/bug2117.py b/tests/pytest/query/bug2117.py new file mode 100644 index 0000000000000000000000000000000000000000..f637558d79fd49d49380c273ee649865d9d3ec4a --- /dev/null +++ b/tests/pytest/query/bug2117.py @@ -0,0 +1,65 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + print("==========step1") + print("create table && insert data") + + tdSql.execute("create table mt0 (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool,c8 binary(20),c9 nchar(20))") + insertRows = 1000 + t0 = 1604298064000 + tdLog.info("insert %d rows" % (insertRows)) + for i in range(insertRows): + ret = tdSql.execute( + "insert into mt0 values (%d , %d,%d,%d,%d,%d,%d,%d,'%s','%s')" % + (t0+i,i%100,i/2.0,i%41,i%51,i%53,i*1.0,i%2,'taos'+str(i%43),'涛思'+str(i%41))) + print("==========step2") + print("test last with group by normal_col ") + tdSql.query('select last(*) from mt0 group by c3') + tdSql.checkData(0,1,84) + tdSql.checkData(0,9,'涛思0') + tdSql.checkData(1,1,85) + tdSql.checkData(1,9,'涛思1') + tdSql.query('select last(*) from mt0 group by c7') + tdSql.checkData(0,1,98) + tdSql.checkData(0,9,'涛思14') + tdSql.checkData(1,1,99) + tdSql.checkData(1,9,'涛思15') + tdSql.query('select last(*) from mt0 group by c8') + tdSql.checkData(0,3,5) + tdSql.checkData(0,4,20) + tdSql.checkData(3,1,92) + tdSql.checkData(3,9,'涛思8') + tdSql.query('select last(*) from mt0 group by c9') + tdSql.checkData(0,3,0) + tdSql.checkData(0,8,'taos38') + tdSql.checkData(40,1,83) + tdSql.checkData(40,3,40) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/query/bug2118.py b/tests/pytest/query/bug2118.py new file mode 100644 index 0000000000000000000000000000000000000000..803f442a1b201b8fcd508e39f5f02b0ab95812aa --- /dev/null +++ b/tests/pytest/query/bug2118.py @@ -0,0 +1,52 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + tdLog.info("==========step1") + tdLog.info("create table && insert data") + + tdSql.execute("create table mt0 (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool,c8 binary(20),c9 nchar(20))") + insertRows = 1000 + t0 = 1604298064000 + tdLog.info("insert %d rows" % (insertRows)) + for i in range(insertRows): + ret = tdSql.execute( + "insert into mt0 values (%d , %d,%d,%d,%d,%d,%d,%d,'%s','%s')" % + (t0+i,i%100,i/2.0,i%41,i%51,i%53,i*1.0,i%2,'taos'+str(i%43),'涛思'+str(i%41))) + tdLog.info("==========step2") + tdLog.info("test percentile with group by normal_col ") + tdSql.query('select percentile(c1,1),percentile(c2,1),percentile(c6,1) from mt0 group by c3 limit 3 offset 2') + + tdSql.checkData(0,0,2.48) + tdSql.checkData(0,0,2.48) + tdSql.checkData(0,2,11.84) + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/query/bug2119.py b/tests/pytest/query/bug2119.py new file mode 100644 index 0000000000000000000000000000000000000000..4224e55596c201f27fbdacd582a90ef5bfd45b85 --- /dev/null +++ b/tests/pytest/query/bug2119.py @@ -0,0 +1,41 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + print("==========step1") + print("create table && insert data") + + tdSql.execute("create table t1 (ts timestamp, c1 int, c2 float)") + + + print("==========step2") + print("query percentile from blank table") + tdSql.query('select percentile(c1,1) from t1') + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/query/bug2143.py b/tests/pytest/query/bug2143.py new file mode 100644 index 0000000000000000000000000000000000000000..c28abba53503cbd8c35531c44ca2bd698b2c2d03 --- /dev/null +++ b/tests/pytest/query/bug2143.py @@ -0,0 +1,73 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + print("==========step1") + print("create table && insert data") + + tdSql.execute("create table mt0 (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool,c8 binary(20),c9 nchar(20))") + insertRows = 1000 + t0 = 1604298064000 + tdLog.info("insert %d rows" % (insertRows)) + for i in range(insertRows): + ret = tdSql.execute( + "insert into mt0 values (%d , %d,%d,%d,%d,%d,%d,%d,'%s','%s')" % + (t0+i,i%100,i/2.0,i%41,i%51,i%53,i*1.0,i%2,'taos'+str(i%43),'涛思'+str(i%41))) + print("==========step2") + print("test group by normal_col with limit offset") + tdSql.query('select max(c1),min(c1),first(c1),last(c1) from mt0 group by c3 limit 3 offset 2') + tdSql.checkData(0,0,99) + tdSql.checkData(0,1,2) + tdSql.checkData(0,2,2) + tdSql.checkData(0,3,86) + tdSql.checkData(1,0,95) + tdSql.checkData(2,1,1) + tdSql.query('select max(c1),min(c1),first(c1),last(c1) from mt0 group by c3 limit 3 offset 40') + tdSql.checkRows(1) + tdSql.query('select max(c1),min(c1),first(c1),last(c1) from mt0 group by c3 limit 3 offset 41') + tdSql.checkRows(0) + tdSql.query('select max(c1),min(c1),first(c1),last(c1) from mt0 group by c3 limit 3 offset 99') + tdSql.checkRows(0) + tdSql.query('select max(c1),min(c1),first(c1),last(c1) from mt0 group by c3 limit 70 offset 3') + tdSql.checkRows(38) + tdSql.query('select max(c1),min(c1),first(c1),last(c1) from mt0 group by c8 limit 3 offset 2') + tdSql.checkData(0,0,91) + tdSql.checkData(0,1,2) + tdSql.checkData(0,2,2) + tdSql.checkData(0,3,91) + tdSql.checkData(1,0,92) + tdSql.checkData(2,1,4) + tdSql.query('select max(c1),min(c1),first(c1),last(c1) from mt0 group by c9 limit 2 offset 9') + tdSql.checkData(0,0,96) + tdSql.checkData(0,1,1) + tdSql.checkData(0,2,9) + tdSql.checkData(0,3,93) + tdSql.checkData(1,0,97) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/query/bug2218.py b/tests/pytest/query/bug2218.py new file mode 100644 index 0000000000000000000000000000000000000000..080472383de905c74ca7680d2d7dddd7310daff5 --- /dev/null +++ b/tests/pytest/query/bug2218.py @@ -0,0 +1,54 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + print("==========step1") + print("create table && insert data") + + tdSql.execute("create table mt0 (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool)") + insertRows = 1000 + t0 = 1604298064000 + tdLog.info("insert %d rows" % (insertRows)) + for i in range(insertRows): + ret = tdSql.execute( + "insert into mt0 values (%d , %d,%d,%d,%d,%d,%d,%d)" % + (t0+i,i%100,i/2,i%100,i%100,i%100,i*1.0,i%2)) + print("==========step2") + print("test col*1*1 desc ") + tdSql.query('select c1,c1*1*1,c2*1*1,c3*1*1,c4*1*1,c5*1*1,c6*1*1 from mt0 order by ts desc limit 2') + tdSql.checkData(0,0,99) + tdSql.checkData(0,1,99.0) + tdSql.checkData(0,2,499.0) + tdSql.checkData(0,3,99.0) + tdSql.checkData(0,4,99.0) + tdSql.checkData(0,5,99.0) + tdSql.checkData(0,6,999.0) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/query/bug2281.py b/tests/pytest/query/bug2281.py new file mode 100644 index 0000000000000000000000000000000000000000..b8eb17f5cd8594389f0a218a95a7024e18735231 --- /dev/null +++ b/tests/pytest/query/bug2281.py @@ -0,0 +1,47 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + print("==========step1") + print("create table && insert data") + + tdSql.execute("create table t1 (ts timestamp, c1 int, c2 float)") + insertRows = 10 + t0 = 1604298064000 + tdLog.info("insert %d rows" % (insertRows)) + for i in range(insertRows): + ret = tdSql.execute( + "insert into t1 values (%d , %d,%d)" % + (t0+i,i%100,i/2.0)) + + print("==========step2") + print("query diff && top") + tdSql.error('select diff(c1),top(c2) from t1') + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/query/bug3351.py b/tests/pytest/query/bug3351.py new file mode 100644 index 0000000000000000000000000000000000000000..288d071a69cac30e9e5666b4d39a8de5c29f91d9 --- /dev/null +++ b/tests/pytest/query/bug3351.py @@ -0,0 +1,74 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + tdSql.execute("drop database if exists db") + tdSql.execute("create database if not exists db keep 36500") + tdSql.execute("use db") + tdLog.printNoPrefix("==========step1:create table && insert data") + + tdSql.execute( + "create table stb1 (ts timestamp, c1 int) TAGS(t1 int)" + ) + tdSql.execute("create table t0 using stb1 tags(1)") + tdSql.execute("insert into t0 values (-865000000, 1)") + tdSql.execute("insert into t0 values (-864000000, 2)") + tdSql.execute("insert into t0 values (-863000000, 3)") + tdSql.execute("insert into t0 values (-15230000, 4)") + tdSql.execute("insert into t0 values (-15220000, 5)") + tdSql.execute("insert into t0 values (-15210000, 6)") + + tdLog.printNoPrefix("==========step2:query") + # bug1:when ts > -864000000, return 0 rows; + # bug2:when ts = -15220000, return 0 rows. + tdSql.query('select * from t0 where ts < -864000000') + tdSql.checkRows(1) + tdSql.query('select * from t0 where ts <= -864000000') + tdSql.checkRows(2) + tdSql.query('select * from t0 where ts = -864000000') + tdSql.checkRows(1) + tdSql.query('select * from t0 where ts > -864000000') + tdSql.checkRows(4) + tdSql.query('select * from t0 where ts >= -864000000') + tdSql.checkRows(5) + tdSql.query('select * from t0 where ts < -15220000') + tdSql.checkRows(4) + tdSql.query('select * from t0 where ts <= -15220000') + tdSql.checkRows(5) + tdSql.query('select * from t0 where ts = -15220000') + tdSql.checkRows(1) + tdSql.query('select * from t0 where ts > -15220000') + tdSql.checkRows(1) + tdSql.query('select * from t0 where ts >= -15220000') + tdSql.checkRows(2) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/query/bug3375.py b/tests/pytest/query/bug3375.py new file mode 100644 index 0000000000000000000000000000000000000000..25c3467c0508073545c630c2a0fe9d5cc31f5dbe --- /dev/null +++ b/tests/pytest/query/bug3375.py @@ -0,0 +1,61 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + tdSql.execute("drop database if exists db") + tdSql.execute("create database if not exists db keep 36500") + tdSql.execute("use db") + + tdLog.printNoPrefix("==========step1:create table && insert data") + tdSql.execute( + "create table stb1 (ts timestamp, c11 int) TAGS(t11 int, t12 int )" + ) + tdSql.execute( + "create table stb2 (ts timestamp, c21 int) TAGS(t21 int, t22 int )" + ) + tdSql.execute("create table t10 using stb1 tags(1, 10)") + tdSql.execute("create table t20 using stb2 tags(1, 12)") + tdSql.execute("insert into t10 values (1600000000000, 1)") + tdSql.execute("insert into t10 values (1610000000000, 2)") + tdSql.execute("insert into t20 values (1600000000000, 3)") + tdSql.execute("insert into t20 values (1610000000000, 4)") + + tdLog.printNoPrefix("==========step2:query crash test") + tdSql.query("select stb1.c11, stb1.t11, stb1.t12 from stb2,stb1 where stb2.t21 = stb1.t11 and stb1.ts = stb2.ts") + tdSql.checkRows(2) + tdSql.query("select stb2.c21, stb2.t21, stb2.t21 from stb1, stb2 where stb2.t21 = stb1.t11 and stb1.ts = stb2.ts") + tdSql.checkRows(2) + tdSql.query("select top(stb2.c21,2) from stb1, stb2 where stb2.t21 = stb1.t11 and stb1.ts = stb2.ts") + tdSql.checkRows(2) + tdSql.query("select last(stb2.c21) from stb1, stb2 where stb2.t21 = stb1.t11 and stb1.ts = stb2.ts") + tdSql.checkRows(1) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/query/bug5903.py b/tests/pytest/query/bug5903.py new file mode 100644 index 0000000000000000000000000000000000000000..a973efbbdf7a0868a4db7910bf57bd5eef8dae06 --- /dev/null +++ b/tests/pytest/query/bug5903.py @@ -0,0 +1,36 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +from util.log import * +from util.cases import * +from util.sql import * + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + # TD-5903 show db.vgroups xxx. xxx is invalid content, but still returns results. + + tdSql.execute("create database if not exists test_5903") + tdSql.execute("show test_5903.vgroups") + tdSql.error("show test_5903.vgroups xxx") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/bug6586.py b/tests/pytest/query/bug6586.py new file mode 100644 index 0000000000000000000000000000000000000000..87d7199dd06a42eed1345311bdfb833ba4cfe93a --- /dev/null +++ b/tests/pytest/query/bug6586.py @@ -0,0 +1,42 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +from util.log import * +from util.cases import * +from util.sql import * + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + # TD-6586 Binary type value return None with python connector + # PR: https://github.com/taosdata/TDengine/pull/7913/files + + tdSql.execute("create database if not exists binary_convertion") + tdSql.execute("use binary_convertion") + tdSql.execute("create stable stb (ts timestamp,value binary(3)) tags (t0 bool,t1 tinyint,t2 smallint,t3 int,t4 bigint,t5 float,t6 double,t7 binary(3),t8 nchar(3))") + tdSql.execute("create table if not exists tb1 using stb(t0,t1,t2,t3,t4,t5,t6,t7,t8) tags (1,127,32767,2147483647,9223372036854775807,11.123450279,22.123456789,'aaa','aaa')") + tdSql.execute("insert into tb1 (ts,value) values (1600000000000, \"aaa\")") + res = tdSql.query('select * from stb', True) + expected_res = [(datetime.datetime(2020, 9, 13, 20, 26, 40), 'aaa', True, 127, 32767, 2147483647, 9223372036854775807, 11.12345027923584, 22.123456789, 'aaa', 'aaa')] + tdSql.checkEqual(res, expected_res) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/computeErrorinWhere.py b/tests/pytest/query/computeErrorinWhere.py new file mode 100644 index 0000000000000000000000000000000000000000..4ceb1ab89f852743de98af65f73f502ab817005d --- /dev/null +++ b/tests/pytest/query/computeErrorinWhere.py @@ -0,0 +1,136 @@ +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug(f"start to execute {__file__}") + tdSql.init(conn.cursor(), logSql) + + def insertnow(self): + tdSql.execute("drop database if exists dbcom") + tdSql.execute("create database if not exists dbcom keep 36500") + tdSql.execute("use dbcom") + + tdSql.execute( + "create table stbcom (ts timestamp, c1 int, c2 tinyint, c3 smallint, c4 bigint, c5 float, c6 double) TAGS(t1 int)" + ) + tdSql.execute("create table tcom1 using stbcom tags(1)") + + # timestamp list: + # 0 -> "1970-01-01 08:00:00" | -28800000 -> "1970-01-01 00:00:00" | -946800000000 -> "1940-01-01 00:00:00" + # -631180800000 -> "1950-01-01 00:00:00" + + tdSql.execute("insert into tcom1 values (now-1d, 1, 11, 21, 31, 41.0, 51.1)") + tdSql.execute("insert into tcom1 values (now-2d, 2, 12, 22, 32, 42.0, 52.1)") + tdSql.execute("insert into tcom1 values (now-3d, 3, 13, 23, 33, 43.0, 53.1)") + tdSql.execute("insert into tcom1 values (now-4d, 4, 14, 24, 34, 44.0, 54.1)") + + def querycom(self): + tdSql.query("select * from tcom1 where c1=2-1") + tdSql.checkRows(1) + tdSql.query("select * from tcom1 where c1=-1+2") + tdSql.checkRows(1) + tdSql.query("select * from tcom1 where c1=1.0*1.0") + tdSql.checkRows(1) + tdSql.query("select * from tcom1 where c1=1.0/1.0") + tdSql.checkRows(1) + tdSql.query("select * from tcom1 where c1>1.0/1.0") + tdSql.checkRows(3) + tdSql.query("select * from tcom1 where c1<1.0/1.0") + tdSql.checkRows(0) + + tdSql.query("select * from tcom1 where c2=12-1") + tdSql.checkRows(1) + tdSql.query("select * from tcom1 where c2=-1+12") + tdSql.checkRows(1) + tdSql.query("select * from tcom1 where c2=11.0*1.0") + tdSql.checkRows(1) + tdSql.query("select * from tcom1 where c2=11.0/1.0") + tdSql.checkRows(1) + tdSql.query("select * from tcom1 where c2>11.0/1.0") + tdSql.checkRows(3) + tdSql.query("select * from tcom1 where c2<11.0/1.0") + tdSql.checkRows(0) + + tdSql.query("select * from tcom1 where c3=22-1") + tdSql.checkRows(1) + tdSql.query("select * from tcom1 where c3=-1+22") + tdSql.checkRows(1) + tdSql.query("select * from tcom1 where c3=21.0*1.0") + tdSql.checkRows(1) + tdSql.query("select * from tcom1 where c3=21.0/1.0") + tdSql.checkRows(1) + tdSql.query("select * from tcom1 where c3>21.0/1.0") + tdSql.checkRows(3) + tdSql.query("select * from tcom1 where c3<21.0/1.0") + tdSql.checkRows(0) + + tdSql.query("select * from tcom1 where c4=32-1") + tdSql.checkRows(1) + tdSql.query("select * from tcom1 where c4=-1+32") + tdSql.checkRows(1) + tdSql.query("select * from tcom1 where c4=31.0*1.0") + tdSql.checkRows(1) + tdSql.query("select * from tcom1 where c4=31.0/1.0") + tdSql.checkRows(1) + tdSql.query("select * from tcom1 where c4>31.0/1.0") + tdSql.checkRows(3) + tdSql.query("select * from tcom1 where c4<31.0/1.0") + tdSql.checkRows(0) + + tdSql.query("select * from tcom1 where c5=42-1") + tdSql.checkRows(1) + tdSql.query("select * from tcom1 where c5=-1+42") + tdSql.checkRows(1) + tdSql.query("select * from tcom1 where c5=41*1") + tdSql.checkRows(1) + tdSql.query("select * from tcom1 where c5=41/1") + tdSql.checkRows(1) + tdSql.query("select * from tcom1 where c5>41/1") + tdSql.checkRows(3) + tdSql.query("select * from tcom1 where c5<41/1") + tdSql.checkRows(0) + tdSql.query("select * from tcom1 where c5=42.000000008-1.0000000099999999999999") + tdSql.checkRows(1) + tdSql.query("select * from tcom1 where c5=42.0008-1.0000099999999999999") + tdSql.checkRows(0) + + tdSql.query("select * from tcom1 where c6=52-0.9") + tdSql.checkRows(1) + tdSql.query("select * from tcom1 where c6=-0.9+52") + tdSql.checkRows(1) + tdSql.query("select * from tcom1 where c6=51.1*1") + tdSql.checkRows(1) + tdSql.query("select * from tcom1 where c6=51.1/1") + tdSql.checkRows(1) + tdSql.query("select * from tcom1 where c6>51.1/1") + tdSql.checkRows(3) + tdSql.query("select * from tcom1 where c6<51.1/1") + tdSql.checkRows(0) + tdSql.query("select * from tcom1 where c6=52.100000000000008-1.000000000000009") + tdSql.checkRows(1) + + + def run(self): + self.insertnow() + self.querycom() + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/query/dataLossTest.py b/tests/pytest/query/dataLossTest.py new file mode 100644 index 0000000000000000000000000000000000000000..b29dc1fa9f977b1f3f68b3e8f7781c6ac5a1e646 --- /dev/null +++ b/tests/pytest/query/dataLossTest.py @@ -0,0 +1,76 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import inspect + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.numberOfTables = 240 + self.numberOfRecords = 10000 + + def run(self): + tdSql.prepare() + + os.system("yes | taosdemo -t %d -n %d" % (self.numberOfTables, self.numberOfRecords)) + print("==============step1") + + tdSql.execute("use test") + sql = "select count(*) from meters" + tdSql.query(sql) + rows = tdSql.getData(0, 0) + print ("number of records: %d" % rows) + + newRows = rows + for i in range(10000): + print("kill taosd") + time.sleep(10) + os.system("sudo kill -9 $(pgrep taosd)") + tdDnodes.startWithoutSleep(1) + while True: + try: + tdSql.query(sql) + newRows = tdSql.getData(0, 0) + print("numer of records after kill taosd %d" % newRows) + time.sleep(10) + break + except Exception as e: + pass + continue + + if newRows < rows: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, sql, newRows, rows) + tdLog.exit("%s(%d) failed: sql:%s, queryRows:%d != expect:%d" % args) + break + + tdSql.query(sql) + tdSql.checkData(0, 0, rows) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/filter.py b/tests/pytest/query/filter.py new file mode 100644 index 0000000000000000000000000000000000000000..2d60fdcd7fc85ad57ba1ec5f7df8603ab76967c8 --- /dev/null +++ b/tests/pytest/query/filter.py @@ -0,0 +1,127 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + def run(self): + tdSql.prepare() + + print("==============step1") + tdSql.execute( + "create table if not exists st (ts timestamp, tagtype int, name nchar(16), col4 binary(16)) tags(dev nchar(50), tag2 binary(16))") + tdSql.execute( + 'CREATE TABLE if not exists dev_001 using st tags("dev_01", "tag_01")') + tdSql.execute( + 'CREATE TABLE if not exists dev_002 using st tags("dev_02", "tag_02")') + + print("==============step2") + + tdSql.execute( + """INSERT INTO dev_001 VALUES('2020-05-13 10:00:00.000', 1, 'first', 'binary1'),('2020-05-13 10:00:00.001', 2, 'second', 'binary2'), + ('2020-05-13 10:00:00.002', 3, 'third' , 'binary3') dev_002 VALUES('2020-05-13 10:00:00.003', 1, 'first', 'binary4'), ('2020-05-13 10:00:00.004', 2, 'second', 'binary5'), + ('2020-05-13 10:00:00.005', 3, 'third', 'binary6')""") + + # > for timestamp type + tdSql.query("select * from db.st where ts > '2020-05-13 10:00:00.002'") + tdSql.checkRows(3) + + # > for numeric type + tdSql.query("select * from db.st where tagtype > 2") + tdSql.checkRows(2) + + # < for timestamp type + tdSql.query("select * from db.st where ts < '2020-05-13 10:00:00.002'") + tdSql.checkRows(2) + + # < for numeric type + tdSql.query("select * from db.st where tagtype < 2") + tdSql.checkRows(2) + + # >= for timestamp type + tdSql.query("select * from db.st where ts >= '2020-05-13 10:00:00.002'") + tdSql.checkRows(4) + + # >= for numeric type + tdSql.query("select * from db.st where tagtype >= 2") + tdSql.checkRows(4) + + # <= for timestamp type + tdSql.query("select * from db.st where ts <= '2020-05-13 10:00:00.002'") + tdSql.checkRows(3) + + # <= for numeric type + tdSql.query("select * from db.st where tagtype <= 2") + tdSql.checkRows(4) + + # = for timestamp type + tdSql.query("select * from db.st where ts = '2020-05-13 10:00:00.002'") + tdSql.checkRows(1) + + # = for numeric type + tdSql.query("select * from db.st where tagtype = 2") + tdSql.checkRows(2) + + # = for nchar type + tdSql.query("select * from db.st where name = 'first'") + tdSql.checkRows(2) + + tdSql.query("select * from db.st where col4 = 1231231") + tdSql.checkRows(0) + + tdSql.query("select * from db.st where name = 1231231") + tdSql.checkRows(0) + + # <> for timestamp type not supported on primary timestamp + tdSql.error("select * from db.st where ts <> '2020-05-13 10:00:00.002'") + # tdSql.checkRows(4) + + # <> for numeric type + tdSql.query("select * from db.st where tagtype <> 2") + tdSql.checkRows(4) + + # <> for nchar type + tdSql.query("select * from db.st where name <> 'first'") + tdSql.checkRows(4) + + # % for nchar type + tdSql.query("select * from db.st where name like 'fi%'") + tdSql.checkRows(2) + + # - for nchar type + tdSql.query("select * from db.st where name like '_econd'") + tdSql.checkRows(2) + + # for tag + tdSql.query("select * from db.st where dev=1") + tdSql.checkRows(0) + + tdSql.query("select * from db.st where tag2=1") + tdSql.checkRows(0) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/filterAllIntTypes.py b/tests/pytest/query/filterAllIntTypes.py new file mode 100644 index 0000000000000000000000000000000000000000..4d91168dae3440443be6daa96747386a687a0f58 --- /dev/null +++ b/tests/pytest/query/filterAllIntTypes.py @@ -0,0 +1,173 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.powers = [7, 15, 31, 63] + self.types = ["tinyint", "smallint", "int", "bigint"] + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.prepare() + + for i in range(len(self.powers)): + curType = self.types[i] + print("======= Verify filter for %s type =========" % (curType)) + tdLog.debug( + "create table st%s(ts timestamp, num %s) tags(id %s)" % + (curType, curType, curType)) + tdSql.execute( + "create table st%s(ts timestamp, num %s) tags(id %s)" % + (curType, curType, curType)) + + # create 10 tables, insert 10 rows for each table + for j in range(self.rowNum): + tdSql.execute( + "create table st%s%d using st%s tags(%d)" % + (curType, j + 1, curType, j + 1)) + for k in range(self.rowNum): + tdSql.execute( + "insert into st%s%d values(%d, %d)" % + (curType, j + 1, self.ts + k + 1, j * 10 + k + 1)) + + tdSql.error("insert into st%s10 values(%d, %d)" % + (curType, self.ts + 11, pow(2, self.powers[i]))) + tdSql.execute("insert into st%s10 values(%d, %d)" % + (curType, self.ts + 12, pow(2, self.powers[i]) - 1)) + tdSql.error("insert into st%s10 values(%d, %d)" % + (curType, self.ts + 13, pow(-2, self.powers[i]))) + tdSql.execute("insert into st%s10 values(%d, %d)" % + (curType, self.ts + 14, pow(-2, self.powers[i]) + 1)) + + # > for int type on column + tdSql.query("select * from st%s where num > 50" % curType) + tdSql.checkRows(51) + + # >= for int type on column + tdSql.query("select * from st%s where num >= 50" % curType) + tdSql.checkRows(52) + + # = for int type on column + tdSql.query("select * from st%s where num = 50" % curType) + tdSql.checkRows(1) + + # < for int type on column + tdSql.query("select * from st%s where num < 50" % curType) + tdSql.checkRows(50) + + # <= for int type on column + tdSql.query("select * from st%s where num <= 50" % curType) + tdSql.checkRows(51) + + # <> for int type on column + tdSql.query("select * from st%s where num <> 50" % curType) + tdSql.checkRows(101) + + # != for int type on column + tdSql.query("select * from st%s where num != 50" % curType) + tdSql.checkRows(101) + + # range for int type on column + tdSql.query( + "select * from st%s where num > 50 and num < 100" % + curType) + tdSql.checkRows(49) + + tdSql.query( + "select * from st%s where num >= 50 and num < 100" % + curType) + tdSql.checkRows(50) + + tdSql.query( + "select * from st%s where num > 50 and num <= 100" % + curType) + tdSql.checkRows(50) + + tdSql.query( + "select * from st%s where num >= 50 and num <= 100" % + curType) + tdSql.checkRows(51) + + # > for int type on tag + tdSql.query("select * from st%s where id > 5" % curType) + tdSql.checkRows(52) + + # >= for int type on tag + tdSql.query("select * from st%s where id >= 5" % curType) + tdSql.checkRows(62) + + # = for int type on tag + tdSql.query("select * from st%s where id = 5" % curType) + tdSql.checkRows(10) + + # < for int type on tag + tdSql.query("select * from st%s where id < 5" % curType) + tdSql.checkRows(40) + + # <= for int type on tag + tdSql.query("select * from st%s where id <= 5" % curType) + tdSql.checkRows(50) + + # <> for int type on tag + tdSql.query("select * from st%s where id <> 5" % curType) + tdSql.checkRows(92) + + # != for int type on tag + tdSql.query("select * from st%s where id != 5" % curType) + tdSql.checkRows(92) + + # != for int type on tag + tdSql.query("select * from st%s where id != 5" % curType) + tdSql.checkRows(92) + + # range for int type on tag + tdSql.query("select * from st%s where id > 5 and id < 7" % curType) + tdSql.checkRows(10) + + tdSql.query( + "select * from st%s where id >= 5 and id < 7" % + curType) + tdSql.checkRows(20) + + tdSql.query( + "select * from st%s where id > 5 and id <= 7" % + curType) + tdSql.checkRows(20) + + tdSql.query( + "select * from st%s where id >= 5 and id <= 7" % + curType) + tdSql.checkRows(30) + + print( + "======= Verify filter for %s type finished =========" % + curType) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/filterAllUnsignedIntTypes.py b/tests/pytest/query/filterAllUnsignedIntTypes.py new file mode 100644 index 0000000000000000000000000000000000000000..0ff2f2b6eeb1424b0bcfd9a9e54537e8f216f9c6 --- /dev/null +++ b/tests/pytest/query/filterAllUnsignedIntTypes.py @@ -0,0 +1,176 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.powers = [8, 16, 32, 64] + self.types = ["tinyint", "smallint", "int", "bigint"] + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.prepare() + + for i in range(len(self.powers)): + curType = self.types[i] + print("======= Verify filter for %s type =========" % (curType)) + tdLog.debug( + "create table st%s(ts timestamp, num %s unsigned) tags(id %s unsigned)" % + (curType, curType, curType)) + tdSql.execute( + "create table st%s(ts timestamp, num %s unsigned) tags(id %s unsigned)" % + (curType, curType, curType)) + + # create 10 tables, insert 10 rows for each table + for j in range(self.rowNum): + tdSql.execute( + "create table st%s%d using st%s tags(%d)" % + (curType, j + 1, curType, j + 1)) + for k in range(self.rowNum): + tdSql.execute( + "insert into st%s%d values(%d, %d)" % + (curType, j + 1, self.ts + k + 1, j * 10 + k + 1)) + + tdSql.error("insert into st%s10 values(%d, %d)" % + (curType, self.ts + 11, pow(2, self.powers[i]) - 1 )) + tdSql.execute("insert into st%s10 values(%d, %d)" % + (curType, self.ts + 12, pow(2, self.powers[i]) - 2 )) + tdSql.error("insert into st%s10 values(%d, %d)" % + (curType, self.ts + 13, -1 )) + tdSql.execute("insert into st%s10 values(%d, %d)" % + (curType, self.ts + 14, 0 )) + # select all data + # tdSql.query("select * from st%s " % curType) + # tdSql.checkRows(102) + + # > for int type on column + tdSql.query("select * from st%s where num > 50" % curType) + tdSql.checkRows(51) + + # >= for int type on column + tdSql.query("select * from st%s where num >= 50" % curType) + tdSql.checkRows(52) + + # = for int type on column + tdSql.query("select * from st%s where num = 50" % curType) + tdSql.checkRows(1) + + # < for int type on column + tdSql.query("select * from st%s where num < 50" % curType) + tdSql.checkRows(50) + + # <= for int type on column + tdSql.query("select * from st%s where num <= 50" % curType) + tdSql.checkRows(51) + + # <> for int type on column + tdSql.query("select * from st%s where num <> 50" % curType) + tdSql.checkRows(101) + + # != for int type on column + tdSql.query("select * from st%s where num != 50" % curType) + tdSql.checkRows(101) + + # range for int type on column + tdSql.query( + "select * from st%s where num > 50 and num < 100" % + curType) + tdSql.checkRows(49) + + tdSql.query( + "select * from st%s where num >= 50 and num < 100" % + curType) + tdSql.checkRows(50) + + tdSql.query( + "select * from st%s where num > 50 and num <= 100" % + curType) + tdSql.checkRows(50) + + tdSql.query( + "select * from st%s where num >= 50 and num <= 100" % + curType) + tdSql.checkRows(51) + + # > for int type on tag + tdSql.query("select * from st%s where id > 5" % curType) + tdSql.checkRows(52) + + # >= for int type on tag + tdSql.query("select * from st%s where id >= 5" % curType) + tdSql.checkRows(62) + + # = for int type on tag + tdSql.query("select * from st%s where id = 5" % curType) + tdSql.checkRows(10) + + # < for int type on tag + tdSql.query("select * from st%s where id < 5" % curType) + tdSql.checkRows(40) + + # <= for int type on tag + tdSql.query("select * from st%s where id <= 5" % curType) + tdSql.checkRows(50) + + # <> for int type on tag + tdSql.query("select * from st%s where id <> 5" % curType) + tdSql.checkRows(92) + + # != for int type on tag + tdSql.query("select * from st%s where id != 5" % curType) + tdSql.checkRows(92) + + # != for int type on tag + tdSql.query("select * from st%s where id != 5" % curType) + tdSql.checkRows(92) + + # range for int type on tag + tdSql.query("select * from st%s where id > 5 and id < 7" % curType) + tdSql.checkRows(10) + + tdSql.query( + "select * from st%s where id >= 5 and id < 7" % + curType) + tdSql.checkRows(20) + + tdSql.query( + "select * from st%s where id > 5 and id <= 7" % + curType) + tdSql.checkRows(20) + + tdSql.query( + "select * from st%s where id >= 5 and id <= 7" % + curType) + tdSql.checkRows(30) + + print( + "======= Verify filter for %s type finished =========" % + curType) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/filterCombo.py b/tests/pytest/query/filterCombo.py new file mode 100644 index 0000000000000000000000000000000000000000..e769addb525433bb05c7a287590c07f88ce86714 --- /dev/null +++ b/tests/pytest/query/filterCombo.py @@ -0,0 +1,63 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + print("==============step1") + tdSql.execute( + "create table if not exists st (ts timestamp, tagtype int, name nchar(16)) tags(dev nchar(50))") + tdSql.execute( + 'CREATE TABLE if not exists dev_001 using st tags("dev_01")') + tdSql.execute( + 'CREATE TABLE if not exists dev_002 using st tags("dev_02")') + + print("==============step2") + + tdSql.execute( + """INSERT INTO dev_001(ts, tagtype, name) VALUES('2020-05-13 10:00:00.000', 1, 'first'),('2020-05-13 10:00:00.001', 2, 'second'), + ('2020-05-13 10:00:00.002', 3, 'third') dev_002 VALUES('2020-05-13 10:00:00.003', 1, 'first'), ('2020-05-13 10:00:00.004', 2, 'second'), + ('2020-05-13 10:00:00.005', 3, 'third')""") + + # query with filter condition A OR condition B + tdSql.query( + "select * from db.st where ts > '2020-05-13 10:00:00.002' AND tagtype < 2") + tdSql.checkRows(1) + + # query with filter condition A OR condition B, error expected + tdSql.error( + "select * from db.st where ts > '2020-05-13 10:00:00.002' OR tagtype < 2") + + # illegal condition + tdSql.error( + "select * from db.st where ts != '2020-05-13 10:00:00.002' OR tagtype < 2") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/filterFloatAndDouble.py b/tests/pytest/query/filterFloatAndDouble.py new file mode 100644 index 0000000000000000000000000000000000000000..8d0e5baeca6775b129c5fc2438bb1a6bc8957b87 --- /dev/null +++ b/tests/pytest/query/filterFloatAndDouble.py @@ -0,0 +1,186 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + tdSql.prepare() + + print("======= Verify filter for float and double type =========") + tdLog.debug( + "create table st(ts timestamp, num float, speed double) tags(tagcol1 float, tagcol2 double)") + tdSql.execute( + "create table st(ts timestamp, num float, speed double) tags(tagcol1 float, tagcol2 double)") + + for j in range(self.rowNum): + tdSql.execute("insert into st1 using st tags(1.1, 2.3) values(%d, %f, %f)" % ( + self.ts + j + 1, 1.1 * (j + 1), 2.3 * (j + 1))) + + # > for float type on column + tdSql.query("select * from st where num > 5.5") + tdSql.checkRows(5) + + # >= for float type on column + tdSql.query("select * from st where num >= 5.5") + tdSql.checkRows(6) + + # = for float type on column + tdSql.query("select * from st where num = 5.5") + tdSql.checkRows(1) + + # <> for float type on column + tdSql.query("select * from st where num <> 5.5") + tdSql.checkRows(9) + + # != for float type on column + tdSql.query("select * from st where num != 5.5") + tdSql.checkRows(9) + + # <= for float type on column + tdSql.query("select * from st where num <= 5.5") + tdSql.checkRows(5) + + # < for float type on column + tdSql.query("select * from st where num < 5.5") + tdSql.checkRows(4) + + # range for float type on column + tdSql.query("select * from st where num > 5.5 and num < 11.0") + tdSql.checkRows(4) + + tdSql.query("select * from st where num >= 5.5 and num < 11.0") + tdSql.checkRows(5) + + tdSql.query("select * from st where num > 5.5 and num <= 11.0") + tdSql.checkRows(5) + + tdSql.query("select * from st where num >= 5.5 and num <= 11.0") + tdSql.checkRows(6) + + # > for float type on tag + tdSql.query("select * from st where tagcol1 > 1.1") + tdSql.checkRows(0) + + # >= for float type on tag + tdSql.query("select * from st where tagcol1 >= 1.1") + tdSql.checkRows(10) + + # = for float type on tag + tdSql.query("select * from st where tagcol1 = 1.1") + tdSql.checkRows(10) + + # <> for float type on tag + tdSql.query("select * from st where tagcol1 <> 1.1") + tdSql.checkRows(0) + + # != for float type on tag + tdSql.query("select * from st where tagcol1 != 1.1") + tdSql.checkRows(0) + + # <= for float type on tag + tdSql.query("select * from st where tagcol1 <= 1.1") + tdSql.checkRows(10) + + # < for float type on tag + tdSql.query("select * from st where tagcol1 < 1.1") + tdSql.checkRows(0) + + # > for double type on column + tdSql.query("select * from st where speed > 11.5") + tdSql.checkRows(5) + + # >= for double type on column + tdSql.query("select * from st where speed >= 11.5") + tdSql.checkRows(6) + + # = for double type on column + tdSql.query("select * from st where speed = 11.5") + tdSql.checkRows(1) + + # <> for double type on column + tdSql.query("select * from st where speed <> 11.5") + tdSql.checkRows(9) + + # != for double type on column + tdSql.query("select * from st where speed != 11.5") + tdSql.checkRows(9) + + # <= for double type on column + tdSql.query("select * from st where speed <= 11.5") + tdSql.checkRows(5) + + # < for double type on column + tdSql.query("select * from st where speed < 11.5") + tdSql.checkRows(4) + + # range for double type on column + tdSql.query("select * from st where speed > 11.5 and speed < 20.7") + tdSql.checkRows(3) + + tdSql.query("select * from st where speed >= 11.5 and speed < 20.7") + tdSql.checkRows(4) + + tdSql.query("select * from st where speed > 11.5 and speed <= 20.7") + tdSql.checkRows(4) + + tdSql.query("select * from st where speed >= 11.5 and speed <= 20.7") + tdSql.checkRows(5) + + # > for double type on tag + tdSql.query("select * from st where tagcol2 > 2.3") + tdSql.checkRows(0) + + # >= for double type on tag + tdSql.query("select * from st where tagcol2 >= 2.3") + tdSql.checkRows(10) + + # = for double type on tag + tdSql.query("select * from st where tagcol2 = 2.3") + tdSql.checkRows(10) + + # <> for double type on tag + tdSql.query("select * from st where tagcol2 <> 2.3") + tdSql.checkRows(0) + + # != for double type on tag + tdSql.query("select * from st where tagcol2 != 2.3") + tdSql.checkRows(0) + + # <= for double type on tag + tdSql.query("select * from st where tagcol2 <= 2.3") + tdSql.checkRows(10) + + # < for double type on tag + tdSql.query("select * from st where tagcol2 < 2.3") + tdSql.checkRows(0) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/filterNoKeyword.py b/tests/pytest/query/filterNoKeyword.py new file mode 100644 index 0000000000000000000000000000000000000000..34d74efd8200dbfae13ec24c9cd8b6792b009a6b --- /dev/null +++ b/tests/pytest/query/filterNoKeyword.py @@ -0,0 +1,83 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.ts = 1537146000000 + + def run(self): + tdSql.prepare() + + print("======= Verify filter for bool, nchar and binary type =========") + tdLog.debug( + "create table st(ts timestamp, tbcol1 bool, tbcol2 binary(10), tbcol3 nchar(20), tbcol4 tinyint, tbcol5 smallint, tbcol6 int, tbcol7 bigint, tbcol8 float, tbcol9 double) tags(tagcol1 bool, tagcol2 binary(10), tagcol3 nchar(10))") + tdSql.execute( + "create table st(ts timestamp, tbcol1 bool, tbcol2 binary(10), tbcol3 nchar(20), tbcol4 tinyint, tbcol5 smallint, tbcol6 int, tbcol7 bigint, tbcol8 float, tbcol9 double) tags(tagcol1 bool, tagcol2 binary(10), tagcol3 nchar(10))") + + tdSql.execute("create table st1 using st tags(true, 'table1', '水表')") + for i in range(1, 6): + tdSql.execute( + "insert into st1 values(%d, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d, %f, %f)" % + (self.ts + i, i % + 2, i, i, + i, i, i, i, 1.0, 1.0)) + + # =============Data type keywords cannot be used in filter==================== + # timestamp + tdSql.error("select * from st where timestamp = 1629417600") + + # bool + tdSql.error("select * from st where bool = false") + + #binary + tdSql.error("select * from st where binary = 'taosdata'") + + # nchar + tdSql.error("select * from st where nchar = '涛思数据'") + + # tinyint + tdSql.error("select * from st where tinyint = 127") + + # smallint + tdSql.error("select * from st where smallint = 32767") + + # int + tdSql.error("select * from st where INTEGER = 2147483647") + tdSql.error("select * from st where int = 2147483647") + + # bigint + tdSql.error("select * from st where bigint = 2147483647") + + # float + tdSql.error("select * from st where float = 3.4E38") + + # double + tdSql.error("select * from st where double = 1.7E308") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/filterOtherTypes.py b/tests/pytest/query/filterOtherTypes.py new file mode 100644 index 0000000000000000000000000000000000000000..f80552138deb6850a87c63bed0c3f543036e7c17 --- /dev/null +++ b/tests/pytest/query/filterOtherTypes.py @@ -0,0 +1,417 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.ts = 1537146000000 + + def run(self): + tdSql.prepare() + + print("======= Verify filter for bool, nchar and binary type =========") + tdLog.debug( + "create table st(ts timestamp, tbcol1 bool, tbcol2 binary(10), tbcol3 nchar(20)) tags(tagcol1 bool, tagcol2 binary(10), tagcol3 nchar(10))") + tdSql.execute( + "create table st(ts timestamp, tbcol1 bool, tbcol2 binary(10), tbcol3 nchar(20)) tags(tagcol1 bool, tagcol2 binary(10), tagcol3 nchar(10))") + + tdSql.execute("create table st1 using st tags(true, 'table1', '水表')") + for i in range(1, 6): + tdSql.execute( + "insert into st1 values(%d, %d, 'taosdata%d', '涛思数据%d')" % + (self.ts + i, i % + 2, i, i)) + + tdSql.execute("create table st2 using st tags(false, 'table2', '电表')") + for i in range(6, 11): + tdSql.execute( + "insert into st2 values(%d, %d, 'taosdata%d', '涛思数据%d')" % + (self.ts + i, i % + 2, i, i)) + + # =============Verify stable columns==================== + # > for bool type on column + tdSql.error("select * from st where tbcol1 > false") + + # >= for bool type on column + tdSql.error("select * from st where tbcol1 >= false") + + # = for bool type on column + tdSql.query("select * from st where tbcol1 = false") + tdSql.checkRows(5) + + # <> for bool type on column + tdSql.query("select * from st where tbcol1 <> true") + tdSql.checkRows(5) + + # != for bool type on column + tdSql.query("select * from st where tbcol1 != true") + tdSql.checkRows(5) + + # > for bool type on column + tdSql.error("select * from st where tbcol1 < true") + + # >= for bool type on column + tdSql.error("select * from st where tbcol1 <= true") + + # % for bool type on column + tdSql.error("select * from st where tbcol1 like '%'") + + # _ for bool type on column + tdSql.error("select * from st where tbcol1 like '____'") + + # > for nchar type on column + tdSql.error("select * from st where tbcol2 > 'taosdata'") + + # >= for nchar type on column + tdSql.error("select * from st where tbcol2 >= 'taosdata'") + + # = for nchar type on column + tdSql.query("select * from st where tbcol2 = 'taosdata1'") + tdSql.checkRows(1) + + # <> for nchar type on column + tdSql.query("select * from st where tbcol2 <> 'taosdata1'") + tdSql.checkRows(9) + + # != for nchar type on column + tdSql.query("select * from st where tbcol2 != 'taosdata1'") + tdSql.checkRows(9) + + # > for nchar type on column + tdSql.error("select * from st where tbcol2 < 'taodata'") + + # >= for nchar type on column + tdSql.error("select * from st where tbcol2 <= 'taodata'") + + # % for nchar type on column case 1 + tdSql.query("select * from st where tbcol2 like '%'") + tdSql.checkRows(10) + + # % for nchar type on column case 2 + tdSql.query("select * from st where tbcol2 like 'a%'") + tdSql.checkRows(0) + + # % for nchar type on column case 3 + tdSql.query("select * from st where tbcol2 like 't%_'") + tdSql.checkRows(10) + + # % for nchar type on column case 4 + tdSql.query("select * from st where tbcol2 like '%1'") + # tdSql.checkRows(2) + + # _ for nchar type on column case 1 + tdSql.query("select * from st where tbcol2 like '____________'") + tdSql.checkRows(0) + + # _ for nchar type on column case 2 + tdSql.query("select * from st where tbcol2 like '__________'") + tdSql.checkRows(1) + + # _ for nchar type on column case 3 + tdSql.query("select * from st where tbcol2 like '_________'") + tdSql.checkRows(9) + + # _ for nchar type on column case 4 + tdSql.query("select * from st where tbcol2 like 't________'") + tdSql.checkRows(9) + + # _ for nchar type on column case 5 + tdSql.query("select * from st where tbcol2 like '%________'") + tdSql.checkRows(10) + + # > for binary type on column + tdSql.error("select * from st where tbcol3 > '涛思数据'") + + # >= for binary type on column + tdSql.error("select * from st where tbcol3 >= '涛思数据'") + + # = for binary type on column + tdSql.query("select * from st where tbcol3 = '涛思数据1'") + tdSql.checkRows(1) + + # <> for binary type on column + tdSql.query("select * from st where tbcol3 <> '涛思数据1'") + tdSql.checkRows(9) + + # != for binary type on column + tdSql.query("select * from st where tbcol3 != '涛思数据1'") + tdSql.checkRows(9) + + # > for binary type on column + tdSql.error("select * from st where tbcol3 < '涛思数据'") + + # >= for binary type on column + tdSql.error("select * from st where tbcol3 <= '涛思数据'") + + # % for binary type on column case 1 + tdSql.query("select * from st where tbcol3 like '%'") + tdSql.checkRows(10) + + # % for binary type on column case 2 + tdSql.query("select * from st where tbcol3 like '陶%'") + tdSql.checkRows(0) + + # % for binary type on column case 3 + tdSql.query("select * from st where tbcol3 like '涛%_'") + tdSql.checkRows(10) + + # % for binary type on column case 4 + tdSql.query("select * from st where tbcol3 like '%1'") + tdSql.checkRows(1) + + # _ for binary type on column case 1 + tdSql.query("select * from st where tbcol3 like '_______'") + tdSql.checkRows(0) + + # _ for binary type on column case 2 + tdSql.query("select * from st where tbcol3 like '______'") + tdSql.checkRows(1) + + # _ for binary type on column case 2 + tdSql.query("select * from st where tbcol3 like '_____'") + tdSql.checkRows(9) + + # _ for binary type on column case 3 + tdSql.query("select * from st where tbcol3 like '____'") + tdSql.checkRows(0) + + # _ for binary type on column case 4 + tdSql.query("select * from st where tbcol3 like 't____'") + tdSql.checkRows(0) + + # =============Verify stable tags==================== + # > for bool type on tag + tdSql.error("select * from st where tagcol1 > false") + + # >= for bool type on tag + tdSql.error("select * from st where tagcol1 >= false") + + # = for bool type on tag + tdSql.query("select * from st where tagcol1 = false") + tdSql.checkRows(5) + + # <> for bool type on tag + tdSql.query("select * from st where tagcol1 <> true") + tdSql.checkRows(5) + + # != for bool type on tag + tdSql.query("select * from st where tagcol1 != true") + tdSql.checkRows(5) + + # > for bool type on tag + tdSql.error("select * from st where tagcol1 < true") + + # >= for bool type on tag + tdSql.error("select * from st where tagcol1 <= true") + + # % for bool type on tag + tdSql.error("select * from st where tagcol1 like '%'") + + # _ for bool type on tag + tdSql.error("select * from st where tagcol1 like '____'") + + # > for nchar type on tag + tdSql.query("select * from st where tagcol2 > 'table1'") + tdSql.checkRows(5) + + # >= for nchar type on tag + tdSql.query("select * from st where tagcol2 >= 'table1'") + tdSql.checkRows(10) + + # = for nchar type on tag + tdSql.query("select * from st where tagcol2 = 'table1'") + tdSql.checkRows(5) + + # <> for nchar type on tag + tdSql.query("select * from st where tagcol2 <> 'table1'") + tdSql.checkRows(5) + + # != for nchar type on tag + tdSql.query("select * from st where tagcol2 != 'table'") + tdSql.checkRows(10) + + # > for nchar type on tag + tdSql.query("select * from st where tagcol2 < 'table'") + tdSql.checkRows(0) + + # >= for nchar type on tag + tdSql.query("select * from st where tagcol2 <= 'table'") + tdSql.checkRows(0) + + # % for nchar type on tag case 1 + tdSql.query("select * from st where tagcol2 like '%'") + tdSql.checkRows(10) + + # % for nchar type on tag case 2 + tdSql.query("select * from st where tagcol2 like 'a%'") + tdSql.checkRows(0) + + # % for nchar type on tag case 3 + tdSql.query("select * from st where tagcol2 like 't%_'") + tdSql.checkRows(10) + + # % for nchar type on tag case 4 + tdSql.query("select * from st where tagcol2 like '%1'") + tdSql.checkRows(5) + + # _ for nchar type on tag case 1 + tdSql.query("select * from st where tagcol2 like '_______'") + tdSql.checkRows(0) + + # _ for nchar type on tag case 2 + tdSql.query("select * from st where tagcol2 like '______'") + tdSql.checkRows(10) + + # _ for nchar type on tag case 3 + tdSql.query("select * from st where tagcol2 like 't_____'") + tdSql.checkRows(10) + + # _ for nchar type on tag case 4 + tdSql.query("select * from st where tagcol2 like 's________'") + tdSql.checkRows(0) + + # _ for nchar type on tag case 5 + tdSql.query("select * from st where tagcol2 like '%__'") + tdSql.checkRows(10) + + # > for binary type on tag + tdSql.query("select * from st where tagcol3 > '表'") + tdSql.checkRows(10) + + # >= for binary type on tag + tdSql.query("select * from st where tagcol3 >= '表'") + tdSql.checkRows(10) + + # = for binary type on tag + tdSql.query("select * from st where tagcol3 = '水表'") + tdSql.checkRows(5) + + # <> for binary type on tag + tdSql.query("select * from st where tagcol3 <> '水表'") + tdSql.checkRows(5) + + # != for binary type on tag + tdSql.query("select * from st where tagcol3 != '水表'") + tdSql.checkRows(5) + + # > for binary type on tag + tdSql.query("select * from st where tagcol3 < '水表'") + tdSql.checkRows(0) + + # >= for binary type on tag + tdSql.query("select * from st where tagcol3 <= '水表'") + tdSql.checkRows(5) + + # % for binary type on tag case 1 + tdSql.query("select * from st where tagcol3 like '%'") + tdSql.checkRows(10) + + # % for binary type on tag case 2 + tdSql.query("select * from st where tagcol3 like '水%'") + tdSql.checkRows(5) + + # % for binary type on tag case 3 + tdSql.query("select * from st where tagcol3 like '数%_'") + tdSql.checkRows(0) + + # % for binary type on tag case 4 + tdSql.query("select * from st where tagcol3 like '%表'") + tdSql.checkRows(10) + + # % for binary type on tag case 5 + tdSql.query("select * from st where tagcol3 like '%据'") + tdSql.checkRows(0) + + # _ for binary type on tag case 1 + tdSql.query("select * from st where tagcol3 like '__'") + tdSql.checkRows(10) + + # _ for binary type on tag case 2 + tdSql.query("select * from st where tagcol3 like '水_'") + tdSql.checkRows(5) + + # _ for binary type on tag case 2 + tdSql.query("select * from st where tagcol3 like '_表'") + tdSql.checkRows(10) + + # _ for binary type on tag case 3 + tdSql.query("select * from st where tagcol3 like '___'") + tdSql.checkRows(0) + + # _ for binary type on tag case 4 + tdSql.query("select * from st where tagcol3 like '数_'") + tdSql.checkRows(0) + + # _ for binary type on tag case 5 + tdSql.query("select * from st where tagcol3 like '_据'") + tdSql.checkRows(0) + + # test case for https://jira.taosdata.com:18080/browse/TD-857 + tdSql.execute("create database test") + tdSql.execute("use test") + tdSql.execute("create table meters(ts timestamp, voltage int) tags(tag1 binary(20))") + tdSql.execute("create table t1 using meters tags('beijing')") + tdSql.execute("create table t2 using meters tags('nanjing')") + + tdSql.execute("insert into t1 values(1538548685000, 1) (1538548685001, 2) (1538548685002, 3)") + tdSql.execute("insert into t2 values(1538548685000, 4) (1538548685001, 5) (1538548685002, 6)") + + tdSql.error("select * from t1 where tag1 like '%g'") + + tdSql.error("select * from t2 where tag1 like '%g'") + + tdSql.query("select * from meters where tag1 like '%g'") + tdSql.checkRows(6) + + tdSql.execute("create table meters1(ts timestamp, voltage int) tags(tag1 nchar(20))") + tdSql.execute("create table t3 using meters1 tags('北京')") + tdSql.execute("create table t4 using meters1 tags('南京')") + tdSql.execute("create table t5 using meters1 tags('beijing')") + tdSql.execute("create table t6 using meters1 tags('nanjing')") + + tdSql.execute("insert into t3 values(1538548685000, 1) (1538548685001, 2) (1538548685002, 3)") + tdSql.execute("insert into t4 values(1538548685000, 4) (1538548685001, 5) (1538548685002, 6)") + tdSql.execute("insert into t5 values(1538548685000, 1) (1538548685001, 2) (1538548685002, 3)") + tdSql.execute("insert into t6 values(1538548685000, 1) (1538548685001, 2) (1538548685002, 3)") + + tdSql.error("select * from t3 where tag1 like '%京'") + + tdSql.error("select * from t4 where tag1 like '%京'") + + tdSql.query("select * from meters1 where tag1 like '%京'") + tdSql.checkRows(6) + + tdSql.error("select * from t5 where tag1 like '%g'") + + tdSql.error("select * from t6 where tag1 like '%g'") + + tdSql.query("select * from meters1 where tag1 like '%g'") + tdSql.checkRows(6) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/filterWithinMultiNchar.py b/tests/pytest/query/filterWithinMultiNchar.py new file mode 100644 index 0000000000000000000000000000000000000000..15fcf4e24ba8c1d84bd1e11ef2aa43febf71ac79 --- /dev/null +++ b/tests/pytest/query/filterWithinMultiNchar.py @@ -0,0 +1,51 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + print("==============step1") + tdSql.execute( + "create stable t6 (ts timestamp,val int,flow nchar(36)) tags(dev nchar(36),dev1 nchar(36),dev2 nchar(36))") + tdSql.execute("insert into t6004 using t6 (dev,dev1,dev2) tags ('b50c79bc-b102-48e6-bda1-4212263e46d0','b50c79bc-b102-48e6-bda1-4212263e46d0', 'b50c79bc-b102-48e6-bda1-4212263e46d0') values(now,1,'b50c79bc-b102-48e6-bda1-4212263e46d0')") + + + print("==============step2") + tdSql.query("select * from t6 where dev='b50c79bc-b102-48e6-bda1-4212263e46d0'") + tdSql.checkRows(1) + + tdSql.query("select * from t6 where dev1='b50c79bc-b102-48e6-bda1-4212263e46d0'") + tdSql.checkRows(1) + + tdSql.query("select * from t6 where dev2='b50c79bc-b102-48e6-bda1-4212263e46d0'") + tdSql.checkRows(1) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/floatCompare.py b/tests/pytest/query/floatCompare.py new file mode 100644 index 0000000000000000000000000000000000000000..cdbddb893e8c0af19fc4aee1596172ade759583f --- /dev/null +++ b/tests/pytest/query/floatCompare.py @@ -0,0 +1,172 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.ts = 1537146000000 + + def run(self): + tdSql.prepare() + + print("==============step1") + tdSql.execute("create table st(ts timestamp, c1 float, c2 double) tags(t1 float, t2 double)") + tdSql.execute( + 'CREATE TABLE if not exists t1 using st tags(1.023, 3.00412)') + tdSql.execute( + 'CREATE TABLE if not exists t2 using st tags(2.005, 10.129001)') + + print("==============step2") + for i in range(10): + tdSql.execute("insert into t1 values(%d, %s, %s) t2 values(%d, %s, %s)" % + (self.ts + i, 1.0001 + i, 2.0001301 + i, self.ts + i, 1.0001 * i, 2.0001301 * i)) + + tdSql.query("select count(*) from st") + tdSql.checkData(0, 0, 20) + + tdSql.query("select count(*) from st where t1 > 1.023") + tdSql.checkData(0, 0, 10) + + tdSql.query("select count(*) from st where t1 < 1.023") + tdSql.checkRows(0) + + tdSql.query("select count(*) from st where t1 >= 1.023") + tdSql.checkData(0, 0, 20) + + tdSql.query("select count(*) from st where t1 <= 1.023") + tdSql.checkData(0, 0, 10) + + tdSql.query("select count(*) from st where t1 = 1.023") + tdSql.checkData(0, 0, 10) + + tdSql.query("select count(*) from st where t1 <> 1.023") + tdSql.checkData(0, 0, 10) + + tdSql.query("select count(*) from st where t1 != 1.023") + tdSql.checkData(0, 0, 10) + + tdSql.query("select count(*) from st where t1 >= 1.023 and t1 <= 1.023") + tdSql.checkData(0, 0, 10) + + tdSql.query("select count(*) from st where t1 > 1.023 and t1 <= 1.023") + tdSql.checkRows(0) + + tdSql.query("select count(*) from st where t1 >= 1.023 and t1 < 1.023") + tdSql.checkRows(0) + + tdSql.query("select count(*) from st where t2 > 3.00412") + tdSql.checkData(0, 0, 10) + + tdSql.query("select count(*) from st where t2 < 3.00412") + tdSql.checkRows(0) + + tdSql.query("select count(*) from st where t2 >= 3.00412") + tdSql.checkData(0, 0, 20) + + tdSql.query("select count(*) from st where t2 <= 3.00412") + tdSql.checkData(0, 0, 10) + + tdSql.query("select count(*) from st where t2 = 3.00412") + tdSql.checkData(0, 0, 10) + + tdSql.query("select count(*) from st where t2 <> 3.00412") + tdSql.checkData(0, 0, 10) + + tdSql.query("select count(*) from st where t2 != 3.00412") + tdSql.checkData(0, 0, 10) + + tdSql.query("select count(*) from st where t2 >= 3.00412 and t2 <= 3.00412") + tdSql.checkData(0, 0, 10) + + tdSql.query("select count(*) from st where t2 > 3.00412 and t2 <= 3.00412") + tdSql.checkRows(0) + + tdSql.query("select count(*) from st where t2 >= 3.00412 and t2 < 3.00412") + tdSql.checkRows(0) + + tdSql.query("select count(*) from t1 where c1 < 2.0001") + tdSql.checkData(0, 0, 1) + + tdSql.query("select count(*) from t1 where c1 <= 2.0001") + tdSql.checkData(0, 0, 2) + + tdSql.query("select count(*) from t1 where c1 = 2.0001") + tdSql.checkData(0, 0, 1) + + tdSql.query("select count(*) from t1 where c1 > 2.0001") + tdSql.checkData(0, 0, 8) + + tdSql.query("select count(*) from t1 where c1 >= 2.0001") + tdSql.checkData(0, 0, 9) + + tdSql.query("select count(*) from t1 where c1 <> 2.0001") + tdSql.checkData(0, 0, 9) + + tdSql.query("select count(*) from t1 where c1 != 2.0001") + tdSql.checkData(0, 0, 9) + + tdSql.query("select count(*) from t1 where c1 >= 2.0001 and c1 <= 2.0001") + tdSql.checkData(0, 0, 1) + + tdSql.query("select count(*) from t1 where c1 > 2.0001 and c1 <= 2.0001") + tdSql.checkRows(0) + + tdSql.query("select count(*) from t1 where c1 >= 2.0001 and c1 < 2.0001") + tdSql.checkRows(0) + + tdSql.query("select count(*) from t2 where c2 < 2.0001301") + tdSql.checkData(0, 0, 1) + + tdSql.query("select count(*) from t2 where c2 <= 2.0001301") + tdSql.checkData(0, 0, 2) + + tdSql.query("select count(*) from t2 where c2 = 2.0001301") + tdSql.checkData(0, 0, 1) + + tdSql.query("select count(*) from t2 where c2 > 2.0001301") + tdSql.checkData(0, 0, 8) + + tdSql.query("select count(*) from t2 where c2 >= 2.0001301") + tdSql.checkData(0, 0, 9) + + tdSql.query("select count(*) from t2 where c2 <> 2.0001301") + tdSql.checkData(0, 0, 9) + + tdSql.query("select count(*) from t2 where c2 != 2.0001301") + tdSql.checkData(0, 0, 9) + + tdSql.query("select count(*) from t2 where c2 >= 2.0001301 and c2 <= 2.0001301") + tdSql.checkData(0, 0, 1) + + tdSql.query("select count(*) from t2 where c2 > 2.0001301 and c2 <= 2.0001301") + tdSql.checkRows(0) + + tdSql.query("select count(*) from t2 where c2 >= 2.0001301 and c2 < 2.0001301") + tdSql.checkRows(0) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/in.py b/tests/pytest/query/in.py new file mode 100644 index 0000000000000000000000000000000000000000..8644b74a45099fcaa7c7608d8d33140b0a30f82f --- /dev/null +++ b/tests/pytest/query/in.py @@ -0,0 +1,163 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +from util.dnodes import tdDnodes + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.ts = 1538548685000 + + def run(self): + tdSql.prepare() + + print("==============step1") + tdSql.execute( + "create table if not exists st (ts timestamp, tagtype int) tags(dev nchar(50))") + tdSql.execute( + 'CREATE TABLE if not exists dev_001 using st tags("dev_01")') + tdSql.execute( + 'CREATE TABLE if not exists dev_002 using st tags("dev_02")') + + print("==============step2") + tdSql.error("select * from db.st where ts in ('2020-05-13 10:00:00.000')") + + tdSql.execute( + """INSERT INTO dev_001(ts, tagtype) VALUES('2020-05-13 10:00:00.000', 1), + ('2020-05-13 10:00:00.001', 1) + dev_002 VALUES('2020-05-13 10:00:00.001', 1)""") + + # TAG nchar + tdSql.query('select count(ts) from db.st where dev in ("dev_01")') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 2) + + tdSql.query('select count(ts) from db.st where dev in ("dev_01", "dev_01")') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 2) + + tdSql.query('select count(ts) from db.st where dev in ("dev_01", "dev_01", "dev_02")') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 3) + + + # colume int + tdSql.query("select count(ts) from db.st where tagtype in (1)") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 3) + + tdSql.query("select count(ts) from db.st where tagtype in (1, 2)") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 3) + tdSql.execute( + """INSERT INTO dev_001(ts, tagtype) VALUES('2020-05-13 10:00:01.000', 2), + ('2020-05-13 10:00:02.001', 2) + dev_002 VALUES('2020-05-13 10:00:03.001', 2)""") + + tdSql.query("select count(ts) from db.st where tagtype in (1, 2)") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 6) + + tdSql.execute("create table tb(ts timestamp, c1 int, c2 binary(10), c3 nchar(10), c4 float, c5 bool)") + for i in range(10): + tdSql.execute("insert into tb values(%d, %d, 'binary%d', 'nchar%d', %f, %d)" % (self.ts + i, i, i, i, i + 0.1, i % 2)) + + #binary + tdSql.query('select count(ts) from db.tb where c2 in ("binary1")') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select count(ts) from db.tb where c2 in ("binary1", "binary2", "binary1")') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 2) + + #bool + #tdSql.query('select count(ts) from db.tb where c5 in (true)') + #tdSql.checkRows(1) + #tdSql.checkData(0, 0, 5) + + #float + #tdSql.query('select count(ts) from db.tb where c4 in (0.1)') + #tdSql.checkRows(1) + #tdSql.checkData(0, 0, 1) + + #nchar + tdSql.query('select count(ts) from db.tb where c3 in ("nchar0")') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + + #tdSql.query("select tbname, dev from dev_001") + #tdSql.checkRows(1) + #tdSql.checkData(0, 0, 'dev_001') + #tdSql.checkData(0, 1, 'dev_01') + + #tdSql.query("select tbname, dev, tagtype from dev_001") + #tdSql.checkRows(2) + + ### test case for https://jira.taosdata.com:18080/browse/TD-1930 + #tdSql.execute("create table tb(ts timestamp, c1 int, c2 binary(10), c3 nchar(10), c4 float, c5 bool)") + #for i in range(10): + # tdSql.execute("insert into tb values(%d, %d, 'binary%d', 'nchar%d', %f, %d)" % (self.ts + i, i, i, i, i + 0.1, i % 2)) + # + #tdSql.error("select * from tb where c2 = binary2") + #tdSql.error("select * from tb where c3 = nchar2") + + #tdSql.query("select * from tb where c2 = 'binary2' ") + #tdSql.checkRows(1) + + #tdSql.query("select * from tb where c3 = 'nchar2' ") + #tdSql.checkRows(1) + + #tdSql.query("select * from tb where c1 = '2' ") + #tdSql.checkRows(1) + + #tdSql.query("select * from tb where c1 = 2 ") + #tdSql.checkRows(1) + + #tdSql.query("select * from tb where c4 = '0.1' ") + #tdSql.checkRows(1) + + #tdSql.query("select * from tb where c4 = 0.1 ") + #tdSql.checkRows(1) + + #tdSql.query("select * from tb where c5 = true ") + #tdSql.checkRows(5) + + #tdSql.query("select * from tb where c5 = 'true' ") + #tdSql.checkRows(5) + + ## For jira: https://jira.taosdata.com:18080/browse/TD-2850 + #tdSql.execute("create database 'Test' ") + #tdSql.execute("use 'Test' ") + #tdSql.execute("create table 'TB'(ts timestamp, 'Col1' int) tags('Tag1' int)") + #tdSql.execute("insert into 'Tb0' using tb tags(1) values(now, 1)") + #tdSql.query("select * from tb") + #tdSql.checkRows(1) + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/intervalOffset.py b/tests/pytest/query/intervalOffset.py new file mode 100644 index 0000000000000000000000000000000000000000..6d4dd720ee599274ea62c9a84c1381ea724f3759 --- /dev/null +++ b/tests/pytest/query/intervalOffset.py @@ -0,0 +1,225 @@ +################################################################### +# Copyright (c) 2020 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + def general(self): + tdSql.execute("create table meters(ts timestamp, s int) tags(id int)") + tdSql.execute("create table t0 using meters tags(0)") + tdSql.execute("create table t1 using meters tags(1)") + tdSql.execute("create table t2 using meters tags(2)") + tdSql.execute("create table t3 using meters tags(3)") + tdSql.execute("create table t4 using meters tags(4)") + + tdSql.execute("insert into t0 values('2019-01-01 00:00:00', 1)") + tdSql.execute("insert into t1 values('2019-01-01 00:00:01', 1)") + tdSql.execute("insert into t2 values('2019-01-01 00:01:00', 1)") + tdSql.execute("insert into t1 values('2019-01-01 00:01:01', 1)") + tdSql.execute("insert into t1 values('2019-01-01 00:01:02', 1)") + tdSql.execute("insert into t1 values('2019-01-01 00:01:03', 1)") + tdSql.execute("insert into t1 values('2019-01-01 00:01:30', 1)") + tdSql.execute("insert into t1 values('2019-01-01 00:01:50', 1)") + tdSql.execute("insert into t2 values('2019-01-01 00:02:00', 1)") + tdSql.execute("insert into t3 values('2019-01-01 00:02:02', 1)") + tdSql.execute("insert into t3 values('2019-01-01 00:02:59', 1)") + tdSql.execute("insert into t4 values('2019-01-01 00:02:59', 1)") + tdSql.execute("insert into t1 values('2019-01-01 00:03:10', 1)") + tdSql.execute("insert into t2 values('2019-01-01 00:08:00', 1)") + tdSql.execute("insert into t1 values('2019-01-01 00:08:00', 1)") + + tdSql.query("select count(*) from meters interval(1m, 1s)") + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 2) + tdSql.checkData(2, 1, 6) + tdSql.checkData(3, 1, 3) + tdSql.checkData(4, 1, 1) + tdSql.checkData(5, 1, 2) + + tdSql.query("select count(*) from meters interval(1m, 2s)") + tdSql.checkData(0, 1, 2) + tdSql.checkData(1, 1, 2) + tdSql.checkData(2, 1, 5) + tdSql.checkData(3, 1, 3) + tdSql.checkData(4, 1, 1) + tdSql.checkData(5, 1, 2) + + tdSql.query("select count(*) from meters interval(90s, 1500a)") + tdSql.checkData(0, 1, 2) + tdSql.checkData(1, 1, 5) + tdSql.checkData(2, 1, 5) + tdSql.checkData(3, 1, 1) + tdSql.checkData(4, 1, 2) + + def singleTable(self): + tdSql.execute("create table car(ts timestamp, s int)") + tdSql.execute("insert into car values('2019-01-01 00:00:00', 1)") + tdSql.execute("insert into car values('2019-05-13 12:00:00', 1)") + tdSql.execute("insert into car values('2019-12-31 23:59:59', 1)") + tdSql.execute("insert into car values('2020-01-01 12:00:00', 1)") + tdSql.execute("insert into car values('2020-01-02 12:00:00', 1)") + tdSql.execute("insert into car values('2020-01-03 12:00:00', 1)") + tdSql.execute("insert into car values('2020-01-04 12:00:00', 1)") + tdSql.execute("insert into car values('2020-01-05 12:00:00', 1)") + tdSql.execute("insert into car values('2020-01-31 12:00:00', 1)") + tdSql.execute("insert into car values('2020-02-01 12:00:00', 1)") + tdSql.execute("insert into car values('2020-02-02 12:00:00', 1)") + tdSql.execute("insert into car values('2020-02-29 12:00:00', 1)") + tdSql.execute("insert into car values('2020-03-01 12:00:00', 1)") + tdSql.execute("insert into car values('2020-03-02 12:00:00', 1)") + tdSql.execute("insert into car values('2020-03-15 12:00:00', 1)") + tdSql.execute("insert into car values('2020-03-31 12:00:00', 1)") + tdSql.execute("insert into car values('2020-05-01 12:00:00', 1)") + + tdSql.query("select count(*) from car interval(1n, 10d)") + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 1) + tdSql.checkData(2, 1, 6) + tdSql.checkData(3, 1, 3) + tdSql.checkData(4, 1, 3) + tdSql.checkData(5, 1, 2) + tdSql.checkData(6, 1, 1) + + tdSql.query("select count(*) from car interval(1n, 10d) order by ts desc") + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 2) + tdSql.checkData(2, 1, 3) + tdSql.checkData(3, 1, 3) + tdSql.checkData(4, 1, 6) + tdSql.checkData(5, 1, 1) + tdSql.checkData(6, 1, 1) + + tdSql.query("select count(*) from car interval(2n, 5d)") + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 1) + tdSql.checkData(2, 1, 6) + tdSql.checkData(3, 1, 6) + tdSql.checkData(4, 1, 3) + + tdSql.query("select count(*) from car interval(2n) order by ts desc") + tdSql.checkData(0, 1, 3) + tdSql.checkData(1, 1, 6) + tdSql.checkData(2, 1, 6) + tdSql.checkData(3, 1, 1) + tdSql.checkData(4, 1, 1) + + tdSql.query("select count(*) from car interval(1y, 1n)") + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 8) + tdSql.checkData(2, 1, 8) + + tdSql.query("select count(*) from car interval(1y, 2n)") + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 11) + tdSql.checkData(2, 1, 5) + + tdSql.query("select count(*) from car where ts > '2019-05-14 00:00:00' interval(1y, 5d)") + tdSql.checkData(0, 1, 6) + tdSql.checkData(1, 1, 9) + + def superTable(self): + tdSql.execute("create table cars(ts timestamp, s int) tags(id int)") + tdSql.execute("create table car0 using cars tags(0)") + tdSql.execute("create table car1 using cars tags(1)") + tdSql.execute("create table car2 using cars tags(2)") + tdSql.execute("create table car3 using cars tags(3)") + tdSql.execute("create table car4 using cars tags(4)") + + tdSql.execute("insert into car0 values('2019-01-01 00:00:00', 1)") + tdSql.execute("insert into car1 values('2019-05-13 12:00:00', 1)") + tdSql.execute("insert into car2 values('2019-12-31 23:59:59', 1)") + tdSql.execute("insert into car1 values('2020-01-01 12:00:00', 1)") + tdSql.execute("insert into car1 values('2020-01-02 12:00:00', 1)") + tdSql.execute("insert into car1 values('2020-01-03 12:00:00', 1)") + tdSql.execute("insert into car1 values('2020-01-04 12:00:00', 1)") + tdSql.execute("insert into car1 values('2020-01-05 12:00:00', 1)") + tdSql.execute("insert into car1 values('2020-01-31 12:00:00', 1)") + tdSql.execute("insert into car1 values('2020-02-01 12:00:00', 1)") + tdSql.execute("insert into car2 values('2020-02-02 12:00:00', 1)") + tdSql.execute("insert into car2 values('2020-02-29 12:00:00', 1)") + tdSql.execute("insert into car3 values('2020-03-01 12:00:00', 1)") + tdSql.execute("insert into car3 values('2020-03-02 12:00:00', 1)") + tdSql.execute("insert into car3 values('2020-03-15 12:00:00', 1)") + tdSql.execute("insert into car4 values('2020-03-31 12:00:00', 1)") + tdSql.execute("insert into car3 values('2020-05-01 12:00:00', 1)") + + tdSql.query("select count(*) from cars interval(1n, 10d)") + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 1) + tdSql.checkData(2, 1, 6) + tdSql.checkData(3, 1, 3) + tdSql.checkData(4, 1, 3) + tdSql.checkData(5, 1, 2) + tdSql.checkData(6, 1, 1) + + tdSql.query("select count(*) from cars interval(1n, 10d) order by ts desc") + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 2) + tdSql.checkData(2, 1, 3) + tdSql.checkData(3, 1, 3) + tdSql.checkData(4, 1, 6) + tdSql.checkData(5, 1, 1) + tdSql.checkData(6, 1, 1) + + tdSql.query("select count(*) from cars interval(2n, 5d)") + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 1) + tdSql.checkData(2, 1, 6) + tdSql.checkData(3, 1, 6) + tdSql.checkData(4, 1, 3) + + tdSql.query("select count(*) from cars interval(2n) order by ts desc") + tdSql.checkData(0, 1, 3) + tdSql.checkData(1, 1, 6) + tdSql.checkData(2, 1, 6) + tdSql.checkData(3, 1, 1) + tdSql.checkData(4, 1, 1) + + tdSql.query("select count(*) from cars interval(1y, 1n)") + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 8) + tdSql.checkData(2, 1, 8) + + tdSql.query("select count(*) from cars interval(1y, 2n)") + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 11) + tdSql.checkData(2, 1, 5) + + tdSql.query("select count(*) from cars where ts > '2019-05-14 00:00:00' interval(1y, 5d)") + tdSql.checkData(0, 1, 6) + tdSql.checkData(1, 1, 9) + + def run(self): + tdSql.prepare() + self.general() + self.singleTable() + self.superTable() + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) + diff --git a/tests/pytest/query/isNullTest.py b/tests/pytest/query/isNullTest.py new file mode 100644 index 0000000000000000000000000000000000000000..7b79679c7d9d9ac4629a69b32acb1a11b61a83c1 --- /dev/null +++ b/tests/pytest/query/isNullTest.py @@ -0,0 +1,128 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.ts = 1537146000000 + + def run(self): + tdSql.prepare() + + print("==============step1") + tdSql.execute("create table st(ts timestamp, c1 int, c2 binary(20), c3 nchar(20)) tags(t1 int, t2 binary(20), t3 nchar(20))") + tdSql.execute("create table t1 using st tags(1, 'binary1', 'nchar1')") + tdSql.execute("insert into t2(ts, c2) using st(t2) tags('') values(%d, '')" % (self.ts + 10)) + tdSql.execute("insert into t3(ts, c2) using st(t3) tags('') values(%d, '')" % (self.ts + 10)) + + for i in range(10): + tdSql.execute("insert into t1 values(%d, %d, 'binary%d', 'nchar%d')" % (self.ts + i, i, i, i)) + tdSql.execute("insert into t2 values(%d, %d, 'binary%d', 'nchar%d')" % (self.ts + i, i, i, i)) + tdSql.execute("insert into t3 values(%d, %d, 'binary%d', 'nchar%d')" % (self.ts + i, i, i, i)) + + tdSql.execute("insert into t1(ts, c2) values(%d, '')" % (self.ts + 10)) + tdSql.execute("insert into t1(ts, c3) values(%d, '')" % (self.ts + 11)) + tdSql.execute("insert into t2(ts, c3) values(%d, '')" % (self.ts + 11)) + tdSql.execute("insert into t3(ts, c3) values(%d, '')" % (self.ts + 11)) + + tdSql.query("select count(*) from st") + tdSql.checkData(0, 0, 36) + + tdSql.query("select count(*) from st where t1 is null") + tdSql.checkData(0, 0, 24) + + tdSql.query("select count(*) from st where t1 is not null") + tdSql.checkData(0, 0, 12) + + tdSql.query("select count(*) from st where t2 is null") + tdSql.checkData(0, 0, 12) + + tdSql.query("select count(*) from st where t2 is not null") + tdSql.checkData(0, 0, 24) + + tdSql.error("select count(*) from st where t2 <> null") + tdSql.error("select count(*) from st where t2 = null") + + tdSql.query("select count(*) from st where t2 = '' ") + tdSql.checkData(0, 0, 12) + + tdSql.query("select count(*) from st where t2 <> '' ") + tdSql.checkData(0, 0, 24) + + tdSql.query("select count(*) from st where t3 is null") + tdSql.checkData(0, 0, 12) + + tdSql.query("select count(*) from st where t3 is not null") + tdSql.checkData(0, 0, 24) + + tdSql.error("select count(*) from st where t3 <> null") + tdSql.error("select count(*) from st where t3 = null") + + tdSql.query("select count(*) from st where t3 = '' ") + tdSql.checkData(0, 0, 12) + + tdSql.query("select count(*) from st where t3 <> '' ") + tdSql.checkData(0, 0, 24) + + tdSql.query("select count(*) from st where c1 is not null") + tdSql.checkData(0, 0, 30) + + tdSql.query("select count(*) from st where c1 is null") + tdSql.checkData(0, 0, 6) + + tdSql.query("select count(*) from st where c2 is not null") + tdSql.checkData(0, 0, 33) + + tdSql.query("select count(*) from st where c2 is null") + tdSql.checkData(0, 0, 3) + + tdSql.error("select count(*) from st where c2 <> null") + tdSql.error("select count(*) from st where c2 = null") + + tdSql.query("select count(*) from st where c2 = '' ") + tdSql.checkData(0, 0, 3) + + tdSql.query("select count(*) from st where c2 <> '' ") + tdSql.checkData(0, 0, 30) + + tdSql.query("select count(*) from st where c3 is not null") + tdSql.checkData(0, 0, 33) + + tdSql.query("select count(*) from st where c3 is null") + tdSql.checkData(0, 0, 3) + + tdSql.error("select count(*) from st where c3 <> null") + tdSql.error("select count(*) from st where c3 = null") + + tdSql.query("select count(*) from st where c3 = '' ") + tdSql.checkData(0, 0, 3) + + tdSql.query("select count(*) from st where c3 <> '' ") + tdSql.checkData(0, 0, 30) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/kill_query.py b/tests/pytest/query/kill_query.py new file mode 100644 index 0000000000000000000000000000000000000000..8975eea2685b93e551e0008fbf5013d5e16e934f --- /dev/null +++ b/tests/pytest/query/kill_query.py @@ -0,0 +1,82 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +from util.dnodes import tdDnodes +import os +import threading +import time + + +class TDTestCase: + """ + kill query + """ + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + + def query(self): + conn = taos.connect(host='127.0.0.1', user='root', password='taosdata', config='/etc/config') + cursor = conn.cursor() + while True: + cursor.execute('show queries;') + print('show queries!') + temp = cursor.fetchall() + if temp: + print(temp[0][0]) + cursor.execute('kill query %s ;' % temp[0][0]) + print('kill query success') + break + time.sleep(0.5) + cursor.close() + conn.close() + + def run(self): + tdSql.prepare() + + print("==============step1") + os.system('yes | sudo taosdemo -n 100') + print('insert into test.meters 10000000 rows') + + + t1 = threading.Thread(target=self.query) + t1.setDaemon(True) + t1.start() + + print("==============step2") + tdSql.execute('use test;') + try: + print('============begin select * from 10000000 rows') + tdSql.query('select * from test.meters;') + # print(tdSql.queryResult) + except Exception as e: + if not "ProgrammingError('Query terminated'" in str(e): + raise Exception('fail') + + print('success') + print('kill query success') + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) + diff --git a/tests/pytest/query/last_cache.py b/tests/pytest/query/last_cache.py new file mode 100644 index 0000000000000000000000000000000000000000..c31d9821e2695dd7883674519325c24f0e473bf2 --- /dev/null +++ b/tests/pytest/query/last_cache.py @@ -0,0 +1,133 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +from util.dnodes import tdDnodes + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.tables = 10 + self.rows = 20 + self.perfix = 't' + self.ts = 1601481600000 + + def insertData(self): + print("==============step1") + tdSql.execute("create table st (ts timestamp, c1 int) tags(t1 int)") + + for i in range(self.tables): + tdSql.execute("create table %s%d using st tags(%d)" % (self.perfix, i, i)) + for j in range(self.rows): + tc = self.ts + j * 60000 + tdSql.execute("insert into %s%d values(%d, %d)" %(self.perfix, i, tc, j)) + + def executeQueries(self): + print("==============step2") + tdSql.query("select last(c1) from %s%d" % (self.perfix, 1)) + tdSql.checkData(0, 0, 19) + + tdSql.query("select last(c1) from %s%d where ts <= %d" % (self.perfix, 1, self.ts + 4 * 60000)) + tdSql.checkData(0, 0, 4) + + tdSql.query("select last(c1) as b from %s%d" % (self.perfix, 1)) + tdSql.checkData(0, 0, 19) + + tdSql.query("select last(c1) from %s%d interval(1m)" % (self.perfix, 1)) + tdSql.checkData(1, 1, 1) + + tdSql.query("select last(c1) from %s%d interval(1d)" % (self.perfix, 1)) + tdSql.checkData(0, 1, 19) + + tdSql.query("select last(c1) from %s%d where ts <= %d interval(1m)" % (self.perfix, 1, self.ts + 4 * 60000)) + tdSql.checkRows(5) + tdSql.checkData(1, 1, 1) + + tdSql.query("select last(c1) from st") + tdSql.checkData(0, 0, 19) + + tdSql.query("select last(c1) as c from st where ts <= %d" % (self.ts + 4 * 60000)) + tdSql.checkData(0, 0, 4) + + tdSql.query("select last(c1) as c from st where t1 <= 5") + tdSql.checkData(0, 0, 19) + + tdSql.query("select last(c1) as c from st where t1 <= 5 and ts <= %d" % (self.ts + 4 * 60000)) + tdSql.checkData(0, 0, 4) + + tdSql.query("select last(c1) from st interval(1m)") + tdSql.checkData(1, 1, 1) + + tdSql.query("select last(c1) from st interval(1d)") + tdSql.checkData(0, 1, 19) + + tdSql.query("select last(c1) from st group by t1") + tdSql.checkRows(10) + tdSql.checkData(0, 0, 19) + + tdSql.query("select last(c1) as c from st where ts <= %d interval(1m) group by t1" % (self.ts + 4 * 60000)) + tdSql.checkData(1, 1, 1) + tdSql.checkRows(50) + + def run(self): + tdSql.prepare() + + # last_cache_0.sim + tdSql.execute("create database test1 cachelast 0") + tdSql.execute("use test1") + self.insertData() + self.executeQueries() + + tdSql.execute("alter database test1 cachelast 1") + self.executeQueries() + tdDnodes.stop(1) + tdDnodes.start(1) + self.executeQueries() + + tdSql.execute("alter database test1 cachelast 0") + self.executeQueries() + tdDnodes.stop(1) + tdDnodes.start(1) + self.executeQueries() + + # last_cache_1.sim + tdSql.execute("create database test2 cachelast 1") + tdSql.execute("use test2") + self.insertData() + self.executeQueries() + + tdSql.execute("alter database test2 cachelast 0") + self.executeQueries() + tdDnodes.stop(1) + tdDnodes.start(1) + self.executeQueries() + + tdSql.execute("alter database test2 cachelast 1") + self.executeQueries() + tdDnodes.stop(1) + tdDnodes.start(1) + self.executeQueries() + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/last_row_cache.py b/tests/pytest/query/last_row_cache.py new file mode 100644 index 0000000000000000000000000000000000000000..0e11e3d60c08362c0114166dcf071990893689f8 --- /dev/null +++ b/tests/pytest/query/last_row_cache.py @@ -0,0 +1,258 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +from util.dnodes import tdDnodes + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.tables = 10 + self.rows = 20 + self.columns = 100 + self.perfix = 't' + self.ts = 1601481600000 + + def insertData(self): + print("==============step1") + sql = "create table st(ts timestamp, " + for i in range(self.columns - 1): + sql += "c%d bigint, " % (i + 1) + sql += "c100 bigint) tags(t1 int)" + tdSql.execute(sql) + + for i in range(self.tables): + tdSql.execute("create table %s%d using st tags(%d)" % (self.perfix, i, i)) + for j in range(self.rows): + tc = self.ts + j * 60000 + tdSql.execute("insert into %s%d(ts, c1) values(%d, %d)" %(self.perfix, i, tc, j)) + + def executeQueries(self): + print("==============step2") + tdSql.query("select last_row(c1) from %s%d" % (self.perfix, 1)) + tdSql.checkData(0, 0, 19) + + tdSql.query("select last_row(c1) from %s%d where ts <= %d" % (self.perfix, 1, self.ts + 4 * 60000)) + tdSql.checkData(0, 0, 4) + + tdSql.query("select last_row(c1) as b from %s%d" % (self.perfix, 1)) + tdSql.checkData(0, 0, 19) + + tdSql.query("select last_row(c1) from st") + tdSql.checkData(0, 0, 19) + + tdSql.query("select last_row(c1) as c from st where ts <= %d" % (self.ts + 4 * 60000)) + tdSql.checkData(0, 0, 4) + + tdSql.query("select last_row(c1) as c from st where t1 < 5") + tdSql.checkData(0, 0, 19) + + tdSql.query("select last_row(c1) as c from st where t1 <= 5 and ts <= %d" % (self.ts + 4 * 60000)) + tdSql.checkData(0, 0, 4) + + tdSql.query("select last_row(c1) as c from st group by t1") + tdSql.checkRows(10) + tdSql.checkData(0, 0, 19) + + tc = self.ts + 1 * 3600000 + tdSql.execute("insert into %s%d(ts, c1) values(%d, %d)" %(self.perfix, 1, tc, 10)) + + tc = self.ts + 3 * 3600000 + tdSql.execute("insert into %s%d(ts, c1) values(%d, null)" %(self.perfix, 1, tc)) + + tc = self.ts + 5 * 3600000 + tdSql.execute("insert into %s%d(ts, c1) values(%d, %d)" %(self.perfix, 1, tc, -1)) + + tc = self.ts + 7 * 3600000 + tdSql.execute("insert into %s%d(ts, c1) values(%d, null)" %(self.perfix, 1, tc)) + + def insertData2(self): + tc = self.ts + 1 * 3600000 + tdSql.execute("insert into %s%d(ts, c1) values(%d, %d)" %(self.perfix, 1, tc, 10)) + + tc = self.ts + 3 * 3600000 + tdSql.execute("insert into %s%d(ts, c1) values(%d, null)" %(self.perfix, 1, tc)) + + tc = self.ts + 5 * 3600000 + tdSql.execute("insert into %s%d(ts, c1) values(%d, %d)" %(self.perfix, 1, tc, -1)) + + tc = self.ts + 7 * 3600000 + tdSql.execute("insert into %s%d(ts, c1) values(%d, null)" %(self.perfix, 1, tc)) + + def executeQueries2(self): + # For stable + tc = self.ts + 6 * 3600000 + tdSql.query("select last_row(c1) from st where ts < %d " % tc) + tdSql.checkData(0, 0, -1) + + tc = self.ts + 8 * 3600000 + tdSql.query("select last_row(*) from st where ts < %d " % tc) + tdSql.checkData(0, 1, None) + + tdSql.query("select last_row(*) from st") + tdSql.checkData(0, 1, None) + + tc = self.ts + 4 * 3600000 + tdSql.query("select last_row(*) from st where ts < %d " % tc) + tdSql.checkData(0, 1, None) + + tc1 = self.ts + 1 * 3600000 + tc2 = self.ts + 4 * 3600000 + tdSql.query("select last_row(*) from st where ts > %d and ts <= %d" % (tc1, tc2)) + tdSql.checkData(0, 1, None) + + # For table + tc = self.ts + 6 * 3600000 + tdSql.query("select last_row(*) from %s%d where ts <= %d" % (self.perfix, 1, tc)) + tdSql.checkData(0, 1, -1) + + tc = self.ts + 8 * 3600000 + tdSql.query("select last_row(*) from %s%d where ts <= %d" % (self.perfix, 1, tc)) + tdSql.checkData(0, 1, None) + + tdSql.query("select last_row(*) from %s%d" % (self.perfix, 1)) + tdSql.checkData(0, 1, None) + + tc = self.ts + 4 * 3600000 + tdSql.query("select last_row(*) from %s%d where ts <= %d" % (self.perfix, 1, tc)) + tdSql.checkData(0, 1, None) + + tc1 = self.ts + 1 * 3600000 + tc2 = self.ts + 4 * 3600000 + tdSql.query("select last_row(*) from st where ts > %d and ts <= %d" % (tc1, tc2)) + tdSql.checkData(0, 1, None) + + def run(self): + tdSql.prepare() + + print("============== Step1: last_row_cache_0.sim") + tdSql.execute("create database test1 cachelast 0") + tdSql.execute("use test1") + self.insertData() + self.executeQueries() + self.insertData2() + self.executeQueries2() + + print("============== Step2: alter database test1 cachelast 1") + tdSql.execute("alter database test1 cachelast 1") + self.executeQueries2() + + print("============== Step3: alter database test1 cachelast 2") + tdSql.execute("alter database test1 cachelast 2") + self.executeQueries2() + + print("============== Step4: alter database test1 cachelast 3") + tdSql.execute("alter database test1 cachelast 3") + self.executeQueries2() + + + print("============== Step5: alter database test1 cachelast 0 and restart taosd") + tdSql.execute("alter database test1 cachelast 0") + self.executeQueries2() + tdDnodes.stop(1) + tdDnodes.start(1) + self.executeQueries2() + + print("============== Step6: alter database test1 cachelast 1 and restart taosd") + tdSql.execute("alter database test1 cachelast 1") + self.executeQueries2() + tdDnodes.stop(1) + tdDnodes.start(1) + self.executeQueries2() + + print("============== Step7: alter database test1 cachelast 2 and restart taosd") + tdSql.execute("alter database test1 cachelast 2") + self.executeQueries2() + tdDnodes.stop(1) + tdDnodes.start(1) + self.executeQueries2() + + print("============== Step8: alter database test1 cachelast 3 and restart taosd") + tdSql.execute("alter database test1 cachelast 3") + self.executeQueries2() + tdDnodes.stop(1) + tdDnodes.start(1) + self.executeQueries2() + + print("============== Step9: create database test2 cachelast 1") + tdSql.execute("create database test2 cachelast 1") + tdSql.execute("use test2") + self.insertData() + self.executeQueries() + self.insertData2() + self.executeQueries2() + tdDnodes.stop(1) + tdDnodes.start(1) + self.executeQueries2() + + print("============== Step8: alter database test2 cachelast 0") + tdSql.execute("alter database test2 cachelast 0") + self.executeQueries2() + + print("============== Step9: alter database test2 cachelast 1") + tdSql.execute("alter database test2 cachelast 1") + self.executeQueries2() + + print("============== Step10: alter database test2 cachelast 2") + tdSql.execute("alter database test2 cachelast 2") + self.executeQueries2() + + print("============== Step11: alter database test2 cachelast 3") + tdSql.execute("alter database test2 cachelast 3") + self.executeQueries2() + + print("============== Step12: alter database test2 cachelast 0 and restart taosd") + tdSql.execute("alter database test2 cachelast 0") + self.executeQueries2() + tdDnodes.stop(1) + tdDnodes.start(1) + self.executeQueries2() + + print("============== Step13: alter database test2 cachelast 1 and restart taosd") + tdSql.execute("alter database test2 cachelast 1") + self.executeQueries2() + tdDnodes.stop(1) + tdDnodes.start(1) + self.executeQueries2() + + print("============== Step14: alter database test2 cachelast 2 and restart taosd") + tdSql.execute("alter database test2 cachelast 2") + self.executeQueries2() + tdDnodes.stop(1) + tdDnodes.start(1) + self.executeQueries2() + + print("============== Step15: alter database test2 cachelast 3 and restart taosd") + tdSql.execute("alter database test2 cachelast 3") + self.executeQueries2() + tdDnodes.stop(1) + tdDnodes.start(1) + self.executeQueries2() + + print("============== Step16: select last_row(*) from st group by tbname") + tdSql.query("select last_row(*) from st group by tbname") + tdSql.checkRows(10) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/natualInterval.py b/tests/pytest/query/natualInterval.py new file mode 100644 index 0000000000000000000000000000000000000000..434cd392bb5d6cf94ad8f762aca2921d77436637 --- /dev/null +++ b/tests/pytest/query/natualInterval.py @@ -0,0 +1,170 @@ +################################################################### +# Copyright (c) 2020 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + def singleTable(self): + tdSql.execute("create table car(ts timestamp, s int)") + tdSql.execute("insert into car values('2019-01-01 00:00:00', 1)") + tdSql.execute("insert into car values('2019-05-13 12:00:00', 1)") + tdSql.execute("insert into car values('2019-12-31 23:59:59', 1)") + tdSql.execute("insert into car values('2020-01-01 12:00:00', 1)") + tdSql.execute("insert into car values('2020-01-02 12:00:00', 1)") + tdSql.execute("insert into car values('2020-01-03 12:00:00', 1)") + tdSql.execute("insert into car values('2020-01-04 12:00:00', 1)") + tdSql.execute("insert into car values('2020-01-05 12:00:00', 1)") + tdSql.execute("insert into car values('2020-01-31 12:00:00', 1)") + tdSql.execute("insert into car values('2020-02-01 12:00:00', 1)") + tdSql.execute("insert into car values('2020-02-02 12:00:00', 1)") + tdSql.execute("insert into car values('2020-02-29 12:00:00', 1)") + tdSql.execute("insert into car values('2020-03-01 12:00:00', 1)") + tdSql.execute("insert into car values('2020-03-02 12:00:00', 1)") + tdSql.execute("insert into car values('2020-03-15 12:00:00', 1)") + tdSql.execute("insert into car values('2020-03-31 12:00:00', 1)") + tdSql.execute("insert into car values('2020-05-01 12:00:00', 1)") + + tdSql.query("select count(*) from car interval(1n)") + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 1) + tdSql.checkData(2, 1, 1) + tdSql.checkData(3, 1, 6) + tdSql.checkData(4, 1, 3) + tdSql.checkData(5, 1, 4) + tdSql.checkData(6, 1, 1) + + tdSql.query("select count(*) from car interval(1n) order by ts desc") + tdSql.checkData(6, 1, 1) + tdSql.checkData(5, 1, 1) + tdSql.checkData(4, 1, 1) + tdSql.checkData(3, 1, 6) + tdSql.checkData(2, 1, 3) + tdSql.checkData(1, 1, 4) + tdSql.checkData(0, 1, 1) + + tdSql.query("select count(*) from car interval(2n)") + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 1) + tdSql.checkData(2, 1, 1) + tdSql.checkData(3, 1, 9) + tdSql.checkData(4, 1, 4) + tdSql.checkData(5, 1, 1) + + tdSql.query("select count(*) from car interval(2n) order by ts desc") + tdSql.checkData(5, 1, 1) + tdSql.checkData(4, 1, 1) + tdSql.checkData(3, 1, 1) + tdSql.checkData(2, 1, 9) + tdSql.checkData(1, 1, 4) + tdSql.checkData(0, 1, 1) + + tdSql.query("select count(*) from car interval(1y)") + tdSql.checkData(0, 1, 3) + tdSql.checkData(1, 1, 14) + + tdSql.query("select count(*) from car interval(2y)") + tdSql.checkData(0, 1, 3) + tdSql.checkData(1, 1, 14) + + + def superTable(self): + tdSql.execute("create table cars(ts timestamp, s int) tags(id int)") + tdSql.execute("create table car0 using cars tags(0)") + tdSql.execute("create table car1 using cars tags(1)") + tdSql.execute("create table car2 using cars tags(2)") + tdSql.execute("create table car3 using cars tags(3)") + tdSql.execute("create table car4 using cars tags(4)") + + tdSql.execute("insert into car0 values('2019-01-01 00:00:00', 1)") + tdSql.execute("insert into car1 values('2019-05-13 12:00:00', 1)") + tdSql.execute("insert into car2 values('2019-12-31 23:59:59', 1)") + tdSql.execute("insert into car1 values('2020-01-01 12:00:00', 1)") + tdSql.execute("insert into car1 values('2020-01-02 12:00:00', 1)") + tdSql.execute("insert into car1 values('2020-01-03 12:00:00', 1)") + tdSql.execute("insert into car1 values('2020-01-04 12:00:00', 1)") + tdSql.execute("insert into car1 values('2020-01-05 12:00:00', 1)") + tdSql.execute("insert into car1 values('2020-01-31 12:00:00', 1)") + tdSql.execute("insert into car1 values('2020-02-01 12:00:00', 1)") + tdSql.execute("insert into car2 values('2020-02-02 12:00:00', 1)") + tdSql.execute("insert into car2 values('2020-02-29 12:00:00', 1)") + tdSql.execute("insert into car3 values('2020-03-01 12:00:00', 1)") + tdSql.execute("insert into car3 values('2020-03-02 12:00:00', 1)") + tdSql.execute("insert into car3 values('2020-03-15 12:00:00', 1)") + tdSql.execute("insert into car4 values('2020-03-31 12:00:00', 1)") + tdSql.execute("insert into car3 values('2020-05-01 12:00:00', 1)") + + tdSql.query("select count(*) from cars interval(1n)") + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 1) + tdSql.checkData(2, 1, 1) + tdSql.checkData(3, 1, 6) + tdSql.checkData(4, 1, 3) + tdSql.checkData(5, 1, 4) + tdSql.checkData(6, 1, 1) + + tdSql.query("select count(*) from cars interval(1n) order by ts desc") + tdSql.checkData(6, 1, 1) + tdSql.checkData(5, 1, 1) + tdSql.checkData(4, 1, 1) + tdSql.checkData(3, 1, 6) + tdSql.checkData(2, 1, 3) + tdSql.checkData(1, 1, 4) + tdSql.checkData(0, 1, 1) + + tdSql.query("select count(*) from cars interval(2n)") + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 1) + tdSql.checkData(2, 1, 1) + tdSql.checkData(3, 1, 9) + tdSql.checkData(4, 1, 4) + tdSql.checkData(5, 1, 1) + + tdSql.query("select count(*) from cars interval(2n) order by ts desc") + tdSql.checkData(5, 1, 1) + tdSql.checkData(4, 1, 1) + tdSql.checkData(3, 1, 1) + tdSql.checkData(2, 1, 9) + tdSql.checkData(1, 1, 4) + tdSql.checkData(0, 1, 1) + + tdSql.query("select count(*) from cars interval(1y)") + tdSql.checkData(0, 1, 3) + tdSql.checkData(1, 1, 14) + + tdSql.query("select count(*) from cars interval(2y)") + tdSql.checkData(0, 1, 3) + tdSql.checkData(1, 1, 14) + + + def run(self): + tdSql.prepare() + self.singleTable() + self.superTable() + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/nestedQuery/insertData.json b/tests/pytest/query/nestedQuery/insertData.json new file mode 100644 index 0000000000000000000000000000000000000000..149a4b56acb69ec9a35b1c05a54d6d08803f8080 --- /dev/null +++ b/tests/pytest/query/nestedQuery/insertData.json @@ -0,0 +1,62 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file":"./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 1, + "childtable_prefix": "stb0_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 100000, + "childtable_limit": -1, + "childtable_offset": 0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1, + "timestamp_step": 1000, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./tools/taosdemoAllTest/sample.csv", + "tags_file": "", + "columns": [{"type": "INT", "count":1}, {"type": "BINARY", "len": 16, "count":1}, {"type": "BOOL"}], + "tags": [{"type": "TINYINT", "count":1}, {"type": "BINARY", "len": 16, "count":1}] + }] + }] +} diff --git a/tests/pytest/query/nestedQuery/nestedQuery.py b/tests/pytest/query/nestedQuery/nestedQuery.py new file mode 100755 index 0000000000000000000000000000000000000000..2b6f8a63550ecb35907dca71cf94437cc2364605 --- /dev/null +++ b/tests/pytest/query/nestedQuery/nestedQuery.py @@ -0,0 +1,2506 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import random +import string +import os +import sys +import time +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +from util.dnodes import tdDnodes +from util.dnodes import * + +class TDTestCase: + updatecfgDict={'maxSQLLength':1048576} + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + os.system("rm -rf query/nestedQuery/nestedQuery.py.sql") + now = time.time() + self.ts = int(round(now * 1000)) + self.num = 10 + self.fornum = 20 + + def get_random_string(self, length): + letters = string.ascii_lowercase + result_str = ''.join(random.choice(letters) for i in range(length)) + return result_str + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def restartDnodes(self): + tdDnodes.stop(1) + tdDnodes.start(1) + + def dropandcreateDB(self,n): + for i in range(n): + tdSql.execute('''drop database if exists db ;''') + tdSql.execute('''create database db;''') + tdSql.execute('''use db;''') + + tdSql.execute('''create stable stable_1 + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint, + q_bool bool , q_binary binary(20) , q_nchar nchar(20) ,q_float float , q_double double , q_ts timestamp) + tags(loc nchar(20) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, + t_bool bool , t_binary binary(20) , t_nchar nchar(20) ,t_float float , t_double double , t_ts timestamp);''') + tdSql.execute('''create stable stable_2 + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint, + q_bool bool , q_binary binary(20) , q_nchar nchar(20) ,q_float float , q_double double , q_ts timestamp) + tags(loc nchar(20) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, + t_bool bool , t_binary binary(20) , t_nchar nchar(20) ,t_float float , t_double double , t_ts timestamp);''') + tdSql.execute('''create stable stable_3 + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint, + q_bool bool , q_binary binary(20) , q_nchar nchar(20) ,q_float float , q_double double , q_ts timestamp) + tags(loc nchar(20) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, + t_bool bool , t_binary binary(20) , t_nchar nchar(20) ,t_float float , t_double double , t_ts timestamp);''') + + tdSql.execute('''create table table_0 using stable_1 + tags('table_0' , '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0')''') + tdSql.execute('''create table table_1 using stable_1 + tags('table_1' , '2147483647' , '9223372036854775807' , '32767' , '127' , 1 , + 'binary1' , 'nchar1' , '1' , '11' , \'1999-09-09 09:09:09.090\')''') + tdSql.execute('''create table table_2 using stable_1 + tags('table_2' , '-2147483647' , '-9223372036854775807' , '-32767' , '-127' , false , + 'binary2' , 'nchar2nchar2' , '-2.2' , '-22.22' , \'2099-09-09 09:09:09.090\')''') + tdSql.execute('''create table table_3 using stable_1 + tags('table_3' , '3' , '3' , '3' , '3' , true , 'binary3' , 'nchar3' , '33.33' , '3333.3333' , '0')''') + tdSql.execute('''create table table_4 using stable_1 + tags('table_4' , '4' , '4' , '4' , '4' , false , 'binary4' , 'nchar4' , '-444.444' , '-444444.444444' , '0')''') + tdSql.execute('''create table table_5 using stable_1 + tags('table_5' , '5' , '5' , '5' , '5' , true , 'binary5' , 'nchar5' , '5555.5555' , '55555555.55555555' , '0')''') + tdSql.execute('''create table table_21 using stable_2 + tags('table_5' , '5' , '5' , '5' , '5' , true , 'binary5' , 'nchar5' , '5555.5555' , '55555555.55555555' , '0')''') + tdSql.execute('''create table table_31 using stable_3 + tags('table_5' , '5' , '5' , '5' , '5' , true , 'binary5' , 'nchar5' , '5555.5555' , '55555555.55555555' , '0')''') + + #regular table + tdSql.execute('''create table regular_table_1 + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint, + q_bool bool , q_binary binary(20) , q_nchar nchar(20) ,q_float float , q_double double , q_ts timestamp) ;''') + tdSql.execute('''create table regular_table_2 + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint, + q_bool bool , q_binary binary(20) , q_nchar nchar(20) ,q_float float , q_double double , q_ts timestamp) ;''') + tdSql.execute('''create table regular_table_3 + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint, + q_bool bool , q_binary binary(20) , q_nchar nchar(20) ,q_float float , q_double double , q_ts timestamp) ;''') + + for i in range(self.num): + tdSql.execute('''insert into table_0 values(%d, %d, %d, %d, %d, 0, 'binary.%s', 'nchar.%s', %f, %f, %d)''' + % (self.ts + i, i, i, i, i, i, i, i, i, self.ts + i)) + tdSql.execute('''insert into table_1 values(%d, %d, %d, %d, %d, 1, 'binary1.%s', 'nchar1.%s', %f, %f, %d)''' + % (self.ts + i, 2147483647-i, 9223372036854775807-i, 32767-i, 127-i, + i, i, random.random(), random.random(), 1262304000001 + i)) + tdSql.execute('''insert into table_2 values(%d, %d, %d, %d, %d, true, 'binary2.%s', 'nchar2nchar2.%s', %f, %f, %d)''' + % (self.ts + i, -2147483647+i, -9223372036854775807+i, -32767+i, -127+i, + i, i, random.uniform(-1,0), random.uniform(-1,0), 1577836800001 + i)) + tdSql.execute('''insert into table_3 values(%d, %d, %d, %d, %d, false, 'binary3.%s', 'nchar3.%s', %f, %f, %d)''' + % (self.ts + i, random.randint(-2147483647, 2147483647), + random.randint(-9223372036854775807, 9223372036854775807), random.randint(-32767, 32767), + random.randint(-127, 127), random.randint(-100, 100), random.randint(-10000, 10000), + random.uniform(-100000,100000), random.uniform(-1000000000,1000000000), self.ts + i)) + tdSql.execute('''insert into table_4 values(%d, %d, %d, %d, %d, true, 'binary4.%s', 'nchar4.%s', %f, %f, %d)''' + % (self.ts + i, i, i, i, i, i, i, i, i, self.ts + i)) + tdSql.execute('''insert into table_5 values(%d, %d, %d, %d, %d, false, 'binary5.%s', 'nchar5.%s', %f, %f, %d)''' + % (self.ts + i, i, i, i, i, i, i, i, i, self.ts + i)) + tdSql.execute('''insert into table_21 values(%d, %d, %d, %d, %d, false, 'binary5.%s', 'nchar5.%s', %f, %f, %d)''' + % (self.ts + i, i, i, i, i, i, i, i, i, self.ts + i)) + + tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, 0, 'binary.%s', 'nchar.%s', %f, %f, %d)''' + % (self.ts + i, i, i, i, i, i, i, i, i, self.ts + i)) + tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, 1, 'binary1.%s', 'nchar1.%s', %f, %f, %d)''' + % (self.ts + 100 + i, 2147483647-i, 9223372036854775807-i, 32767-i, 127-i, + i, i, random.random(), random.random(), 1262304000001 + i)) + tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, true, 'binary2.%s', 'nchar2nchar2.%s', %f, %f, %d)''' + % (self.ts + 200 + i, -2147483647+i, -9223372036854775807+i, -32767+i, -127+i, + i, i, random.uniform(-1,0), random.uniform(-1,0), 1577836800001 + i)) + tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, false, 'binary3.%s', 'nchar3.%s', %f, %f, %d)''' + % (self.ts + 300 + i, random.randint(-2147483647, 2147483647), + random.randint(-9223372036854775807, 9223372036854775807), random.randint(-32767, 32767), + random.randint(-127, 127), random.randint(-100, 100), random.randint(-10000, 10000), + random.uniform(-100000,100000), random.uniform(-1000000000,1000000000), self.ts + i)) + tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, true, 'binary4.%s', 'nchar4.%s', %f, %f, %d)''' + % (self.ts + 400 + i, i, i, i, i, i, i, i, i, self.ts + i)) + tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, false, 'binary5.%s', 'nchar5.%s', %f, %f, %d)''' + % (self.ts + 500 + i, i, i, i, i, i, i, i, i, self.ts + i)) + + tdSql.execute('''insert into regular_table_2 values(%d, %d, %d, %d, %d, 0, 'binary.%s', 'nchar.%s', %f, %f, %d)''' + % (self.ts + i, i, i, i, i, i, i, i, i, self.ts + i)) + tdSql.execute('''insert into regular_table_2 values(%d, %d, %d, %d, %d, 1, 'binary1.%s', 'nchar1.%s', %f, %f, %d)''' + % (self.ts + 100 + i, 2147483647-i, 9223372036854775807-i, 32767-i, 127-i, + i, i, random.random(), random.random(), 1262304000001 + i)) + tdSql.execute('''insert into regular_table_2 values(%d, %d, %d, %d, %d, true, 'binary2.%s', 'nchar2nchar2.%s', %f, %f, %d)''' + % (self.ts + 200 + i, -2147483647+i, -9223372036854775807+i, -32767+i, -127+i, + i, i, random.uniform(-1,0), random.uniform(-1,0), 1577836800001 + i)) + tdSql.execute('''insert into regular_table_2 values(%d, %d, %d, %d, %d, false, 'binary3.%s', 'nchar3.%s', %f, %f, %d)''' + % (self.ts + 300 + i, random.randint(-2147483647, 2147483647), + random.randint(-9223372036854775807, 9223372036854775807), random.randint(-32767, 32767), + random.randint(-127, 127), random.randint(-100, 100), random.randint(-10000, 10000), + random.uniform(-100000,100000), random.uniform(-1000000000,1000000000), self.ts + i)) + tdSql.execute('''insert into regular_table_2 values(%d, %d, %d, %d, %d, true, 'binary4.%s', 'nchar4.%s', %f, %f, %d)''' + % (self.ts + 400 + i, i, i, i, i, i, i, i, i, self.ts + i)) + tdSql.execute('''insert into regular_table_2 values(%d, %d, %d, %d, %d, false, 'binary5.%s', 'nchar5.%s', %f, %f, %d)''' + % (self.ts + 500 + i, i, i, i, i, i, i, i, i, self.ts + i)) + + def run(self): + tdSql.prepare() + # test case for https://jira.taosdata.com:18080/browse/TD-5665 + os.system("rm -rf nestedQuery.py.sql") + startTime = time.time() + + dcDB = self.dropandcreateDB(1) + + # regular column select + q_select= ['ts' , '*' , 'q_int', 'q_bigint' , 'q_bigint' , 'q_smallint' , 'q_tinyint' , 'q_bool' , 'q_binary' , 'q_nchar' ,'q_float' , 'q_double' ,'q_ts '] + + # tag column select + t_select= ['*' , 'loc' ,'t_int', 't_bigint' , 't_bigint' , 't_smallint' , 't_tinyint' , 't_bool' , 't_binary' , 't_nchar' ,'t_float' , 't_double' ,'t_ts '] + + # regular and tag column select + qt_select= q_select + t_select + + # distinct regular column select + dq_select= ['distinct q_int', 'distinct q_bigint' , 'distinct q_smallint' , 'distinct q_tinyint' , + 'distinct q_bool' , 'distinct q_binary' , 'distinct q_nchar' ,'distinct q_float' , 'distinct q_double' ,'distinct q_ts '] + + # distinct tag column select + dt_select= ['distinct loc', 'distinct t_int', 'distinct t_bigint' , 'distinct t_smallint' , 'distinct t_tinyint' , + 'distinct t_bool' , 'distinct t_binary' , 'distinct t_nchar' ,'distinct t_float' , 'distinct t_double' ,'distinct t_ts '] + + # distinct regular and tag column select + dqt_select= dq_select + dt_select + + # special column select + s_r_select= ['_c0', '_C0' ] + s_s_select= ['tbname' , '_c0', '_C0' ] + + # regular column where + q_where = ['ts < now +1s','q_bigint >= -9223372036854775807 and q_bigint <= 9223372036854775807', 'q_int <= 2147483647 and q_int >= -2147483647', + 'q_smallint >= -32767 and q_smallint <= 32767','q_tinyint >= -127 and q_tinyint <= 127','q_float >= -100000 and q_float <= 100000', + 'q_double >= -1000000000 and q_double <= 1000000000', 'q_binary like \'binary%\' or q_binary = \'0\' ' , 'q_nchar like \'nchar%\' or q_nchar = \'0\' ' , + 'q_bool = true or q_bool = false' , 'q_bool in (0 , 1)' , 'q_bool in ( true , false)' , 'q_bool = 0 or q_bool = 1', + 'q_bigint between -9223372036854775807 and 9223372036854775807',' q_int between -2147483647 and 2147483647','q_smallint between -32767 and 32767', + 'q_tinyint between -127 and 127 ','q_float between -100000 and 100000','q_double between -1000000000 and 1000000000'] + #TD-6201 ,'q_bool between 0 and 1' + + # regular column where for test union,join + q_u_where = ['t1.ts < now +1s' , 't2.ts < now +1s','t1.q_bigint >= -9223372036854775807 and t1.q_bigint <= 9223372036854775807 and t2.q_bigint >= -9223372036854775807 and t2.q_bigint <= 9223372036854775807', + 't1.q_int <= 2147483647 and t1.q_int >= -2147483647 and t2.q_int <= 2147483647 and t2.q_int >= -2147483647', + 't1.q_smallint >= -32767 and t1.q_smallint <= 32767 and t2.q_smallint >= -32767 and t2.q_smallint <= 32767', + 't1.q_tinyint >= -127 and t1.q_tinyint <= 127 and t2.q_tinyint >= -127 and t2.q_tinyint <= 127', + 't1.q_float >= -100000 and t1.q_float <= 100000 and t2.q_float >= -100000 and t2.q_float <= 100000', + 't1.q_double >= -1000000000 and t1.q_double <= 1000000000 and t2.q_double >= -1000000000 and t2.q_double <= 1000000000', + 't1.q_binary like \'binary%\' and t2.q_binary like \'binary%\' ' , + 't1.q_nchar like \'nchar%\' and t2.q_nchar like \'nchar%\' ' , + 't1.q_bool in (0 , 1) and t2.q_bool in (0 , 1)' , 't1.q_bool in ( true , false) and t2.q_bool in ( true , false)' , + 't1.q_bigint between -9223372036854775807 and 9223372036854775807 and t2.q_bigint between -9223372036854775807 and 9223372036854775807', + 't1.q_int between -2147483647 and 2147483647 and t2.q_int between -2147483647 and 2147483647', + 't1.q_smallint between -32767 and 32767 and t2.q_smallint between -32767 and 32767', + 't1.q_tinyint between -127 and 127 and t2.q_tinyint between -127 and 127 ','t1.q_float between -100000 and 100000 and t2.q_float between -100000 and 100000', + 't1.q_double between -1000000000 and 1000000000 and t2.q_double between -1000000000 and 1000000000'] + #TD-6201 ,'t1.q_bool between 0 and 1 or t2.q_bool between 0 and 1'] + #'t1.q_bool = true and t1.q_bool = false and t2.q_bool = true and t2.q_bool = false' , 't1.q_bool = 0 and t1.q_bool = 1 and t2.q_bool = 0 and t2.q_bool = 1' , + + q_u_or_where = ['t1.q_binary like \'binary%\' or t1.q_binary = \'0\' or t2.q_binary like \'binary%\' or t2.q_binary = \'0\' ' , + 't1.q_nchar like \'nchar%\' or t1.q_nchar = \'0\' or t2.q_nchar like \'nchar%\' or t2.q_nchar = \'0\' ' , 't1.q_bool = true or t1.q_bool = false or t2.q_bool = true or t2.q_bool = false' , + 't1.q_bool in (0 , 1) or t2.q_bool in (0 , 1)' , 't1.q_bool in ( true , false) or t2.q_bool in ( true , false)' , 't1.q_bool = 0 or t1.q_bool = 1 or t2.q_bool = 0 or t2.q_bool = 1' , + 't1.q_bigint between -9223372036854775807 and 9223372036854775807 or t2.q_bigint between -9223372036854775807 and 9223372036854775807', + 't1.q_int between -2147483647 and 2147483647 or t2.q_int between -2147483647 and 2147483647', + 't1.q_smallint between -32767 and 32767 or t2.q_smallint between -32767 and 32767', + 't1.q_tinyint between -127 and 127 or t2.q_tinyint between -127 and 127 ','t1.q_float between -100000 and 100000 or t2.q_float between -100000 and 100000', + 't1.q_double between -1000000000 and 1000000000 or t2.q_double between -1000000000 and 1000000000'] + + # tag column where + t_where = ['ts < now +1s','t_bigint >= -9223372036854775807 and t_bigint <= 9223372036854775807','t_int <= 2147483647 and t_int >= -2147483647', + 't_smallint >= -32767 and t_smallint <= 32767','q_tinyint >= -127 and t_tinyint <= 127','t_float >= -100000 and t_float <= 100000', + 't_double >= -1000000000 and t_double <= 1000000000', 't_binary like \'binary%\' or t_binary = \'0\' ' , 't_nchar like \'nchar%\' or t_nchar = \'0\'' , + 't_bool = true or t_bool = false' , 't_bool in (0 , 1)' , 't_bool in ( true , false)' , 't_bool = 0 or t_bool = 1', + 't_bigint between -9223372036854775807 and 9223372036854775807',' t_int between -2147483647 and 2147483647','t_smallint between -32767 and 32767', + 't_tinyint between -127 and 127 ','t_float between -100000 and 100000','t_double between -1000000000 and 1000000000'] + #TD-6201,'t_bool between 0 and 1' + + # tag column where for test union,join | this is not support + t_u_where = ['t1.ts < now +1s' , 't2.ts < now +1s','t1.t_bigint >= -9223372036854775807 and t1.t_bigint <= 9223372036854775807 and t2.t_bigint >= -9223372036854775807 and t2.t_bigint <= 9223372036854775807', + 't1.t_int <= 2147483647 and t1.t_int >= -2147483647 and t2.t_int <= 2147483647 and t2.t_int >= -2147483647', + 't1.t_smallint >= -32767 and t1.t_smallint <= 32767 and t2.t_smallint >= -32767 and t2.t_smallint <= 32767', + 't1.t_tinyint >= -127 and t1.t_tinyint <= 127 and t2.t_tinyint >= -127 and t2.t_tinyint <= 127', + 't1.t_float >= -100000 and t1.t_float <= 100000 and t2.t_float >= -100000 and t2.t_float <= 100000', + 't1.t_double >= -1000000000 and t1.t_double <= 1000000000 and t2.t_double >= -1000000000 and t2.t_double <= 1000000000', + 't1.t_binary like \'binary%\' or t1.t_binary = \'0\' or t2.t_binary like \'binary%\' or t2.t_binary = \'0\' ' , + 't1.t_nchar like \'nchar%\' or t1.t_nchar = \'0\' or t2.t_nchar like \'nchar%\' or t2.t_nchar = \'0\' ' , 't1.t_bool = true or t1.t_bool = false or t2.t_bool = true or t2.t_bool = false' , + 't1.t_bool in (0 , 1) and t2.t_bool in (0 , 1)' , 't1.t_bool in ( true , false) and t2.t_bool in ( true , false)' , 't1.t_bool = 0 or t1.t_bool = 1 or t2.t_bool = 0 or t2.t_bool = 1', + 't1.t_bigint between -9223372036854775807 and 9223372036854775807 and t2.t_bigint between -9223372036854775807 and 9223372036854775807', + 't1.t_int between -2147483647 and 2147483647 and t2.t_int between -2147483647 and 2147483647', + 't1.t_smallint between -32767 and 32767 and t2.t_smallint between -32767 and 32767', + 't1.t_tinyint between -127 and 127 and t2.t_tinyint between -127 and 127 ','t1.t_float between -100000 and 100000 and t2.t_float between -100000 and 100000', + 't1.t_double between -1000000000 and 1000000000 and t2.t_double between -1000000000 and 1000000000'] + #TD-6201,'t1.t_bool between 0 and 1 or t2.q_bool between 0 and 1'] + + t_u_or_where = ['t1.t_binary like \'binary%\' or t1.t_binary = \'0\' or t2.t_binary like \'binary%\' or t2.t_binary = \'0\' ' , + 't1.t_nchar like \'nchar%\' or t1.t_nchar = \'0\' or t2.t_nchar like \'nchar%\' or t2.t_nchar = \'0\' ' , 't1.t_bool = true or t1.t_bool = false or t2.t_bool = true or t2.t_bool = false' , + 't1.t_bool in (0 , 1) or t2.t_bool in (0 , 1)' , 't1.t_bool in ( true , false) or t2.t_bool in ( true , false)' , 't1.t_bool = 0 or t1.t_bool = 1 or t2.t_bool = 0 or t2.t_bool = 1', + 't1.t_bigint between -9223372036854775807 and 9223372036854775807 or t2.t_bigint between -9223372036854775807 and 9223372036854775807', + 't1.t_int between -2147483647 and 2147483647 or t2.t_int between -2147483647 and 2147483647', + 't1.t_smallint between -32767 and 32767 or t2.t_smallint between -32767 and 32767', + 't1.t_tinyint between -127 and 127 or t2.t_tinyint between -127 and 127 ','t1.t_float between -100000 and 100000 or t2.t_float between -100000 and 100000', + 't1.t_double between -1000000000 and 1000000000 or t2.t_double between -1000000000 and 1000000000'] + + # regular and tag column where + qt_where = q_where + t_where + qt_u_where = q_u_where + t_u_where + # now,qt_u_or_where is not support + qt_u_or_where = q_u_or_where + t_u_or_where + + # tag column where for test super join | this is support , 't1.t_bool = t2.t_bool ' ??? + t_join_where = ['t1.t_bigint = t2.t_bigint ', 't1.t_int = t2.t_int ', 't1.t_smallint = t2.t_smallint ', 't1.t_tinyint = t2.t_tinyint ', + 't1.t_float = t2.t_float ', 't1.t_double = t2.t_double ', 't1.t_binary = t2.t_binary ' , 't1.t_nchar = t2.t_nchar ' ] + + # session && fill + session_where = ['session(ts,10a)' , 'session(ts,10s)', 'session(ts,10m)' , 'session(ts,10h)','session(ts,10d)' , 'session(ts,10w)'] + session_u_where = ['session(t1.ts,10a)' , 'session(t1.ts,10s)', 'session(t1.ts,10m)' , 'session(t1.ts,10h)','session(t1.ts,10d)' , 'session(t1.ts,10w)', + 'session(t2.ts,10a)' , 'session(t2.ts,10s)', 'session(t2.ts,10m)' , 'session(t2.ts,10h)','session(t2.ts,10d)' , 'session(t2.ts,10w)'] + + fill_where = ['FILL(NONE)','FILL(PREV)','FILL(NULL)','FILL(LINEAR)','FILL(NEXT)','FILL(VALUE, 1.23)'] + + state_window = ['STATE_WINDOW(q_tinyint)','STATE_WINDOW(q_bigint)','STATE_WINDOW(q_int)','STATE_WINDOW(q_bool)','STATE_WINDOW(q_smallint)'] + state_u_window = ['STATE_WINDOW(t1.q_tinyint)','STATE_WINDOW(t1.q_bigint)','STATE_WINDOW(t1.q_int)','STATE_WINDOW(t1.q_bool)','STATE_WINDOW(t1.q_smallint)', + 'STATE_WINDOW(t2.q_tinyint)','STATE_WINDOW(t2.q_bigint)','STATE_WINDOW(t2.q_int)','STATE_WINDOW(t2.q_bool)','STATE_WINDOW(t2.q_smallint)'] + + # order by where + order_where = ['order by ts' , 'order by ts asc'] + order_u_where = ['order by t1.ts' , 'order by t1.ts asc' , 'order by t2.ts' , 'order by t2.ts asc'] + order_desc_where = ['order by ts' , 'order by ts asc' , 'order by ts desc' ] + orders_desc_where = ['order by ts' , 'order by ts asc' , 'order by ts desc' , 'order by loc' , 'order by loc asc' , 'order by loc desc'] + + # group by where,not include null-tag + group_where = ['group by tbname , loc' , 'group by tbname', 'group by tbname, t_bigint', 'group by tbname,t_int', 'group by tbname, t_smallint', 'group by tbname,t_tinyint', + 'group by tbname,t_float', 'group by tbname,t_double' , 'group by tbname,t_binary', 'group by tbname,t_nchar', 'group by tbname,t_bool' ,'group by tbname ,loc ,t_bigint', + 'group by tbname,t_binary ,t_nchar ,t_bool' , 'group by tbname,t_int ,t_smallint ,t_tinyint' , 'group by tbname,t_float ,t_double ' ] + having_support = ['having count(q_int) > 0','having count(q_bigint) > 0','having count(q_smallint) > 0','having count(q_tinyint) > 0','having count(q_float) > 0','having count(q_double) > 0','having count(q_bool) > 0', + 'having avg(q_int) > 0','having avg(q_bigint) > 0','having avg(q_smallint) > 0','having avg(q_tinyint) > 0','having avg(q_float) > 0','having avg(q_double) > 0', + 'having sum(q_int) > 0','having sum(q_bigint) > 0','having sum(q_smallint) > 0','having sum(q_tinyint) > 0','having sum(q_float) > 0','having sum(q_double) > 0', + 'having STDDEV(q_int) > 0','having STDDEV(q_bigint) > 0','having STDDEV(q_smallint) > 0','having STDDEV(q_tinyint) > 0','having STDDEV(q_float) > 0','having STDDEV(q_double) > 0', + 'having TWA(q_int) > 0','having TWA(q_bigint) > 0','having TWA(q_smallint) > 0','having TWA(q_tinyint) > 0','having TWA(q_float) > 0','having TWA(q_double) > 0', + 'having IRATE(q_int) > 0','having IRATE(q_bigint) > 0','having IRATE(q_smallint) > 0','having IRATE(q_tinyint) > 0','having IRATE(q_float) > 0','having IRATE(q_double) > 0', + 'having MIN(q_int) > 0','having MIN(q_bigint) > 0','having MIN(q_smallint) > 0','having MIN(q_tinyint) > 0','having MIN(q_float) > 0','having MIN(q_double) > 0', + 'having MAX(q_int) > 0','having MAX(q_bigint) > 0','having MAX(q_smallint) > 0','having MAX(q_tinyint) > 0','having MAX(q_float) > 0','having MAX(q_double) > 0', + 'having FIRST(q_int) > 0','having FIRST(q_bigint) > 0','having FIRST(q_smallint) > 0','having FIRST(q_tinyint) > 0','having FIRST(q_float) > 0','having FIRST(q_double) > 0', + 'having LAST(q_int) > 0','having LAST(q_bigint) > 0','having LAST(q_smallint) > 0','having LAST(q_tinyint) > 0','having LAST(q_float) > 0','having LAST(q_double) > 0', + 'having APERCENTILE(q_int,10) > 0','having APERCENTILE(q_bigint,10) > 0','having APERCENTILE(q_smallint,10) > 0','having APERCENTILE(q_tinyint,10) > 0','having APERCENTILE(q_float,10) > 0','having APERCENTILE(q_double,10) > 0'] + having_not_support = ['having TOP(q_int,10) > 0','having TOP(q_bigint,10) > 0','having TOP(q_smallint,10) > 0','having TOP(q_tinyint,10) > 0','having TOP(q_float,10) > 0','having TOP(q_double,10) > 0','having TOP(q_bool,10) > 0', + 'having BOTTOM(q_int,10) > 0','having BOTTOM(q_bigint,10) > 0','having BOTTOM(q_smallint,10) > 0','having BOTTOM(q_tinyint,10) > 0','having BOTTOM(q_float,10) > 0','having BOTTOM(q_double,10) > 0','having BOTTOM(q_bool,10) > 0', + 'having LEASTSQUARES(q_int) > 0','having LEASTSQUARES(q_bigint) > 0','having LEASTSQUARES(q_smallint) > 0','having LEASTSQUARES(q_tinyint) > 0','having LEASTSQUARES(q_float) > 0','having LEASTSQUARES(q_double) > 0','having LEASTSQUARES(q_bool) > 0', + 'having FIRST(q_bool) > 0','having IRATE(q_bool) > 0','having PERCENTILE(q_bool,10) > 0','having avg(q_bool) > 0','having LAST_ROW(q_bool) > 0','having sum(q_bool) > 0','having STDDEV(q_bool) > 0','having APERCENTILE(q_bool,10) > 0','having TWA(q_bool) > 0','having LAST(q_bool) > 0', + 'having PERCENTILE(q_int,10) > 0','having PERCENTILE(q_bigint,10) > 0','having PERCENTILE(q_smallint,10) > 0','having PERCENTILE(q_tinyint,10) > 0','having PERCENTILE(q_float,10) > 0','having PERCENTILE(q_double,10) > 0'] + having_tagnot_support = ['having LAST_ROW(q_int) > 0','having LAST_ROW(q_bigint) > 0','having LAST_ROW(q_smallint) > 0','having LAST_ROW(q_tinyint) > 0','having LAST_ROW(q_float) > 0','having LAST_ROW(q_double) > 0'] + + # limit offset where + limit_where = ['limit 1 offset 1' , 'limit 1' , 'limit 2 offset 1' , 'limit 2', 'limit 12 offset 1' , 'limit 20', 'limit 20 offset 10' , 'limit 200'] + limit1_where = ['limit 1 offset 1' , 'limit 1' ] + limit_u_where = ['limit 100 offset 10' , 'limit 50' , 'limit 100' , 'limit 10' ] + + # slimit soffset where + slimit_where = ['slimit 1 soffset 1' , 'slimit 1' , 'slimit 2 soffset 1' , 'slimit 2'] + slimit1_where = ['slimit 2 soffset 1' , 'slimit 1' ] + + # aggregate function include [all:count(*)\avg\sum\stddev ||regualr:twa\irate\leastsquares ||group by tbname:twa\irate\] + # select function include [all: min\max\first(*)\last(*)\top\bottom\apercentile\last_row(*)(not with interval)\interp(*)(FILL) ||regualr: percentile] + # calculation function include [all:spread\+-*/ ||regualr:diff\derivative ||group by tbname:diff\derivative\] + # **_ns_** express is not support stable, therefore, separated from regular tables + # calc_select_all calc_select_regular calc_select_in_ts calc_select_fill calc_select_not_interval + # calc_aggregate_all calc_aggregate_regular calc_aggregate_groupbytbname + # calc_calculate_all calc_calculate_regular calc_calculate_groupbytbname + + # calc_select_all calc_select_regular calc_select_in_ts calc_select_fill calc_select_not_interval + # select function include [all: min\max\first(*)\last(*)\top\bottom\apercentile\last_row(*)(not with interval)\interp(*)(FILL) ||regualr: percentile] + + calc_select_all = ['bottom(q_int,20)' , 'bottom(q_bigint,20)' , 'bottom(q_smallint,20)' , 'bottom(q_tinyint,20)' ,'bottom(q_float,20)' , 'bottom(q_double,20)' , + 'top(q_int,20)' , 'top(q_bigint,20)' , 'top(q_smallint,20)' ,'top(q_tinyint,20)' ,'top(q_float,20)' ,'top(q_double,20)' , + 'first(q_int)' , 'first(q_bigint)' , 'first(q_smallint)' , 'first(q_tinyint)' , 'first(q_float)' ,'first(q_double)' ,'first(q_binary)' ,'first(q_nchar)' ,'first(q_bool)' ,'first(q_ts)' , + 'last(q_int)' , 'last(q_bigint)' , 'last(q_smallint)' , 'last(q_tinyint)' , 'last(q_float)' ,'last(q_double)' , 'last(q_binary)' ,'last(q_nchar)' ,'last(q_bool)' ,'last(q_ts)' , + 'min(q_int)' , 'min(q_bigint)' , 'min(q_smallint)' , 'min(q_tinyint)' , 'min(q_float)' ,'min(q_double)' , + 'max(q_int)' , 'max(q_bigint)' , 'max(q_smallint)' , 'max(q_tinyint)' ,'max(q_float)' ,'max(q_double)' , + 'apercentile(q_int,20)' , 'apercentile(q_bigint,20)' ,'apercentile(q_smallint,20)' ,'apercentile(q_tinyint,20)' ,'apercentile(q_float,20)' ,'apercentile(q_double,20)' , + 'last_row(q_int)' , 'last_row(q_bigint)' , 'last_row(q_smallint)' , 'last_row(q_tinyint)' , 'last_row(q_float)' , + 'last_row(q_double)' , 'last_row(q_bool)' ,'last_row(q_binary)' ,'last_row(q_nchar)' ,'last_row(q_ts)'] + + calc_select_in_ts = ['bottom(q_int,20)' , 'bottom(q_bigint,20)' , 'bottom(q_smallint,20)' , 'bottom(q_tinyint,20)' ,'bottom(q_float,20)' , 'bottom(q_double,20)' , + 'top(q_int,20)' , 'top(q_bigint,20)' , 'top(q_smallint,20)' ,'top(q_tinyint,20)' ,'top(q_float,20)' ,'top(q_double,20)' , + 'first(q_int)' , 'first(q_bigint)' , 'first(q_smallint)' , 'first(q_tinyint)' , 'first(q_float)' ,'first(q_double)' ,'first(q_binary)' ,'first(q_nchar)' ,'first(q_bool)' ,'first(q_ts)' , + 'last(q_int)' , 'last(q_bigint)' , 'last(q_smallint)' , 'last(q_tinyint)' , 'last(q_float)' ,'last(q_double)' , 'last(q_binary)' ,'last(q_nchar)' ,'last(q_bool)' ,'last(q_ts)' ] + + calc_select_in = ['min(q_int)' , 'min(q_bigint)' , 'min(q_smallint)' , 'min(q_tinyint)' , 'min(q_float)' ,'min(q_double)' , + 'max(q_int)' , 'max(q_bigint)' , 'max(q_smallint)' , 'max(q_tinyint)' ,'max(q_float)' ,'max(q_double)' , + 'apercentile(q_int,20)' , 'apercentile(q_bigint,20)' ,'apercentile(q_smallint,20)' ,'apercentile(q_tinyint,20)' ,'apercentile(q_float,20)' ,'apercentile(q_double,20)' , + 'last_row(q_int)' , 'last_row(q_bigint)' , 'last_row(q_smallint)' , 'last_row(q_tinyint)' , 'last_row(q_float)' , + 'last_row(q_double)' , 'last_row(q_bool)' ,'last_row(q_binary)' ,'last_row(q_nchar)' ,'last_row(q_ts)'] + + + calc_select_regular = [ 'PERCENTILE(q_int,10)' ,'PERCENTILE(q_bigint,20)' , 'PERCENTILE(q_smallint,30)' ,'PERCENTILE(q_tinyint,40)' ,'PERCENTILE(q_float,50)' ,'PERCENTILE(q_double,60)'] + + + calc_select_fill = ['INTERP(q_bool)' ,'INTERP(q_binary)' ,'INTERP(q_nchar)' ,'INTERP(q_ts)', 'INTERP(q_int)' ,'INTERP(*)' ,'INTERP(q_bigint)' ,'INTERP(q_smallint)' ,'INTERP(q_tinyint)', 'INTERP(q_float)' ,'INTERP(q_double)'] + interp_where = ['ts = now' , 'ts = \'2020-09-13 20:26:40.000\'' , 'ts = \'2020-09-13 20:26:40.009\'' ,'tbname in (\'table_1\') and ts = now' ,'tbname in (\'table_0\' ,\'table_1\',\'table_2\',\'table_3\',\'table_4\',\'table_5\') and ts = \'2020-09-13 20:26:40.000\'','tbname like \'table%\' and ts = \'2020-09-13 20:26:40.002\''] + + #two table join + calc_select_in_ts_j = ['bottom(t1.q_int,20)' , 'bottom(t1.q_bigint,20)' , 'bottom(t1.q_smallint,20)' , 'bottom(t1.q_tinyint,20)' ,'bottom(t1.q_float,20)' , 'bottom(t1.q_double,20)' , + 'top(t1.q_int,20)' , 'top(t1.q_bigint,20)' , 'top(t1.q_smallint,20)' ,'top(t1.q_tinyint,20)' ,'top(t1.q_float,20)' ,'top(t1.q_double,20)' , + 'first(t1.q_int)' , 'first(t1.q_bigint)' , 'first(t1.q_smallint)' , 'first(t1.q_tinyint)' , 'first(t1.q_float)' ,'first(t1.q_double)' ,'first(t1.q_binary)' ,'first(t1.q_nchar)' ,'first(t1.q_bool)' ,'first(t1.q_ts)' , + 'last(t1.q_int)' , 'last(t1.q_bigint)' , 'last(t1.q_smallint)' , 'last(t1.q_tinyint)' , 'last(t1.q_float)' ,'last(t1.q_double)' , 'last(t1.q_binary)' ,'last(t1.q_nchar)' ,'last(t1.q_bool)' ,'last(t1.q_ts)' , + 'bottom(t2.q_int,20)' , 'bottom(t2.q_bigint,20)' , 'bottom(t2.q_smallint,20)' , 'bottom(t2.q_tinyint,20)' ,'bottom(t2.q_float,20)' , 'bottom(t2.q_double,20)' , + 'top(t2.q_int,20)' , 'top(t2.q_bigint,20)' , 'top(t2.q_smallint,20)' ,'top(t2.q_tinyint,20)' ,'top(t2.q_float,20)' ,'top(t2.q_double,20)' , + 'first(t2.q_int)' , 'first(t2.q_bigint)' , 'first(t2.q_smallint)' , 'first(t2.q_tinyint)' , 'first(t2.q_float)' ,'first(t2.q_double)' ,'first(t2.q_binary)' ,'first(t2.q_nchar)' ,'first(t2.q_bool)' ,'first(t2.q_ts)' , + 'last(t2.q_int)' , 'last(t2.q_bigint)' , 'last(t2.q_smallint)' , 'last(t2.q_tinyint)' , 'last(t2.q_float)' ,'last(t2.q_double)' , 'last(t2.q_binary)' ,'last(t2.q_nchar)' ,'last(t2.q_bool)' ,'last(t2.q_ts)'] + + calc_select_in_j = ['min(t1.q_int)' , 'min(t1.q_bigint)' , 'min(t1.q_smallint)' , 'min(t1.q_tinyint)' , 'min(t1.q_float)' ,'min(t1.q_double)' , + 'max(t1.q_int)' , 'max(t1.q_bigint)' , 'max(t1.q_smallint)' , 'max(t1.q_tinyint)' ,'max(t1.q_float)' ,'max(t1.q_double)' , + 'apercentile(t1.q_int,20)' , 'apercentile(t1.q_bigint,20)' ,'apercentile(t1.q_smallint,20)' ,'apercentile(t1.q_tinyint,20)' ,'apercentile(t1.q_float,20)' ,'apercentile(t1.q_double,20)' , + 'last_row(t1.q_int)' , 'last_row(t1.q_bigint)' , 'last_row(t1.q_smallint)' , 'last_row(t1.q_tinyint)' , 'last_row(t1.q_float)' , + 'last_row(t1.q_double)' , 'last_row(t1.q_bool)' ,'last_row(t1.q_binary)' ,'last_row(t1.q_nchar)' ,'last_row(t1.q_ts)' , + 'min(t2.q_int)' , 'min(t2.q_bigint)' , 'min(t2.q_smallint)' , 'min(t2.q_tinyint)' , 'min(t2.q_float)' ,'min(t2.q_double)' , + 'max(t2.q_int)' , 'max(t2.q_bigint)' , 'max(t2.q_smallint)' , 'max(t2.q_tinyint)' ,'max(t2.q_float)' ,'max(t2.q_double)' , + 'apercentile(t2.q_int,20)' , 'apercentile(t2.q_bigint,20)' ,'apercentile(t2.q_smallint,20)' ,'apercentile(t2.q_tinyint,20)' ,'apercentile(t2.q_float,20)' ,'apercentile(t2.q_double,20)' , + 'last_row(t2.q_int)' , 'last_row(t2.q_bigint)' , 'last_row(t2.q_smallint)' , 'last_row(t2.q_tinyint)' , 'last_row(t2.q_float)' , + 'last_row(t2.q_double)' , 'last_row(t2.q_bool)' ,'last_row(t2.q_binary)' ,'last_row(t2.q_nchar)' ,'last_row(t2.q_ts)'] + + calc_select_all_j = calc_select_in_ts_j + calc_select_in_j + + calc_select_regular_j = [ 'PERCENTILE(t1.q_int,10)' ,'PERCENTILE(t1.q_bigint,20)' , 'PERCENTILE(t1.q_smallint,30)' ,'PERCENTILE(t1.q_tinyint,40)' ,'PERCENTILE(t1.q_float,50)' ,'PERCENTILE(t1.q_double,60)' , + 'PERCENTILE(t2.q_int,10)' ,'PERCENTILE(t2.q_bigint,20)' , 'PERCENTILE(t2.q_smallint,30)' ,'PERCENTILE(t2.q_tinyint,40)' ,'PERCENTILE(t2.q_float,50)' ,'PERCENTILE(t2.q_double,60)'] + + + calc_select_fill_j = ['INTERP(t1.q_bool)' ,'INTERP(t1.q_binary)' ,'INTERP(t1.q_nchar)' ,'INTERP(t1.q_ts)', 'INTERP(t1.q_int)' ,'INTERP(t1.*)' ,'INTERP(t1.q_bigint)' ,'INTERP(t1.q_smallint)' ,'INTERP(t1.q_tinyint)', 'INTERP(t1.q_float)' ,'INTERP(t1.q_double)' , + 'INTERP(t2.q_bool)' ,'INTERP(t2.q_binary)' ,'INTERP(t2.q_nchar)' ,'INTERP(t2.q_ts)', 'INTERP(t2.q_int)' ,'INTERP(t2.*)' ,'INTERP(t2.q_bigint)' ,'INTERP(t2.q_smallint)' ,'INTERP(t2.q_tinyint)', 'INTERP(t2.q_float)' ,'INTERP(t2.q_double)'] + interp_where_j = ['t1.ts = now' , 't1.ts = \'2020-09-13 20:26:40.000\'' , 't1.ts = \'2020-09-13 20:26:40.009\'' ,'t2.ts = now' , 't2.ts = \'2020-09-13 20:26:40.000\'' , 't2.ts = \'2020-09-13 20:26:40.009\'' , + 't1.tbname in (\'table_1\') and t1.ts = now' ,'t1.tbname in (\'table_0\' ,\'table_1\',\'table_2\',\'table_3\',\'table_4\',\'table_5\') and t1.ts = \'2020-09-13 20:26:40.000\'','t1.tbname like \'table%\' and t1.ts = \'2020-09-13 20:26:40.002\'', + 't2.tbname in (\'table_1\') and t2.ts = now' ,'t2.tbname in (\'table_0\' ,\'table_1\',\'table_2\',\'table_3\',\'table_4\',\'table_5\') and t2.ts = \'2020-09-13 20:26:40.000\'','t2.tbname like \'table%\' and t2.ts = \'2020-09-13 20:26:40.002\''] + + # calc_aggregate_all calc_aggregate_regular calc_aggregate_groupbytbname APERCENTILE\PERCENTILE + # aggregate function include [all:count(*)\avg\sum\stddev ||regualr:twa\irate\leastsquares ||group by tbname:twa\irate\] + calc_aggregate_all = ['count(*)' , 'count(q_int)' ,'count(q_bigint)' , 'count(q_smallint)' ,'count(q_tinyint)' ,'count(q_float)' , + 'count(q_double)' ,'count(q_binary)' ,'count(q_nchar)' ,'count(q_bool)' ,'count(q_ts)' , + 'avg(q_int)' ,'avg(q_bigint)' , 'avg(q_smallint)' ,'avg(q_tinyint)' ,'avg(q_float)' ,'avg(q_double)' , + 'sum(q_int)' ,'sum(q_bigint)' , 'sum(q_smallint)' ,'sum(q_tinyint)' ,'sum(q_float)' ,'sum(q_double)' , + 'STDDEV(q_int)' ,'STDDEV(q_bigint)' , 'STDDEV(q_smallint)' ,'STDDEV(q_tinyint)' ,'STDDEV(q_float)' ,'STDDEV(q_double)', + 'APERCENTILE(q_int,10)' ,'APERCENTILE(q_bigint,20)' , 'APERCENTILE(q_smallint,30)' ,'APERCENTILE(q_tinyint,40)' ,'APERCENTILE(q_float,50)' ,'APERCENTILE(q_double,60)'] + + calc_aggregate_regular = ['twa(q_int)' ,'twa(q_bigint)' , 'twa(q_smallint)' ,'twa(q_tinyint)' ,'twa (q_float)' ,'twa(q_double)' , + 'IRATE(q_int)' ,'IRATE(q_bigint)' , 'IRATE(q_smallint)' ,'IRATE(q_tinyint)' ,'IRATE (q_float)' ,'IRATE(q_double)' , + 'LEASTSQUARES(q_int,15,3)' , 'LEASTSQUARES(q_bigint,10,1)' , 'LEASTSQUARES(q_smallint,20,3)' ,'LEASTSQUARES(q_tinyint,10,4)' ,'LEASTSQUARES(q_float,6,4)' ,'LEASTSQUARES(q_double,3,1)' , + 'PERCENTILE(q_int,10)' ,'PERCENTILE(q_bigint,20)' , 'PERCENTILE(q_smallint,30)' ,'PERCENTILE(q_tinyint,40)' ,'PERCENTILE(q_float,50)' ,'PERCENTILE(q_double,60)'] + + calc_aggregate_groupbytbname = ['twa(q_int)' ,'twa(q_bigint)' , 'twa(q_smallint)' ,'twa(q_tinyint)' ,'twa (q_float)' ,'twa(q_double)' , + 'IRATE(q_int)' ,'IRATE(q_bigint)' , 'IRATE(q_smallint)' ,'IRATE(q_tinyint)' ,'IRATE (q_float)' ,'IRATE(q_double)' ] + + #two table join + calc_aggregate_all_j = ['count(t1.*)' , 'count(t1.q_int)' ,'count(t1.q_bigint)' , 'count(t1.q_smallint)' ,'count(t1.q_tinyint)' ,'count(t1.q_float)' , + 'count(t1.q_double)' ,'count(t1.q_binary)' ,'count(t1.q_nchar)' ,'count(t1.q_bool)' ,'count(t1.q_ts)' , + 'avg(t1.q_int)' ,'avg(t1.q_bigint)' , 'avg(t1.q_smallint)' ,'avg(t1.q_tinyint)' ,'avg(t1.q_float)' ,'avg(t1.q_double)' , + 'sum(t1.q_int)' ,'sum(t1.q_bigint)' , 'sum(t1.q_smallint)' ,'sum(t1.q_tinyint)' ,'sum(t1.q_float)' ,'sum(t1.q_double)' , + 'STDDEV(t1.q_int)' ,'STDDEV(t1.q_bigint)' , 'STDDEV(t1.q_smallint)' ,'STDDEV(t1.q_tinyint)' ,'STDDEV(t1.q_float)' ,'STDDEV(t1.q_double)', + 'APERCENTILE(t1.q_int,10)' ,'APERCENTILE(t1.q_bigint,20)' , 'APERCENTILE(t1.q_smallint,30)' ,'APERCENTILE(t1.q_tinyint,40)' ,'APERCENTILE(t1.q_float,50)' ,'APERCENTILE(t1.q_double,60)' , + 'count(t2.*)' , 'count(t2.q_int)' ,'count(t2.q_bigint)' , 'count(t2.q_smallint)' ,'count(t2.q_tinyint)' ,'count(t2.q_float)' , + 'count(t2.q_double)' ,'count(t2.q_binary)' ,'count(t2.q_nchar)' ,'count(t2.q_bool)' ,'count(t2.q_ts)' , + 'avg(t2.q_int)' ,'avg(t2.q_bigint)' , 'avg(t2.q_smallint)' ,'avg(t2.q_tinyint)' ,'avg(t2.q_float)' ,'avg(t2.q_double)' , + 'sum(t2.q_int)' ,'sum(t2.q_bigint)' , 'sum(t2.q_smallint)' ,'sum(t2.q_tinyint)' ,'sum(t2.q_float)' ,'sum(t2.q_double)' , + 'STDDEV(t2.q_int)' ,'STDDEV(t2.q_bigint)' , 'STDDEV(t2.q_smallint)' ,'STDDEV(t2.q_tinyint)' ,'STDDEV(t2.q_float)' ,'STDDEV(t2.q_double)', + 'APERCENTILE(t2.q_int,10)' ,'APERCENTILE(t2.q_bigint,20)' , 'APERCENTILE(t2.q_smallint,30)' ,'APERCENTILE(t2.q_tinyint,40)' ,'APERCENTILE(t2.q_float,50)' ,'APERCENTILE(t2.q_double,60)'] + + calc_aggregate_regular_j = ['twa(t1.q_int)' ,'twa(t1.q_bigint)' , 'twa(t1.q_smallint)' ,'twa(t1.q_tinyint)' ,'twa (t1.q_float)' ,'twa(t1.q_double)' , + 'IRATE(t1.q_int)' ,'IRATE(t1.q_bigint)' , 'IRATE(t1.q_smallint)' ,'IRATE(t1.q_tinyint)' ,'IRATE (t1.q_float)' ,'IRATE(t1.q_double)' , + 'LEASTSQUARES(t1.q_int,15,3)' , 'LEASTSQUARES(t1.q_bigint,10,1)' , 'LEASTSQUARES(t1.q_smallint,20,3)' ,'LEASTSQUARES(t1.q_tinyint,10,4)' ,'LEASTSQUARES(t1.q_float,6,4)' ,'LEASTSQUARES(t1.q_double,3,1)' , + 'PERCENTILE(t1.q_int,10)' ,'PERCENTILE(t1.q_bigint,20)' , 'PERCENTILE(t1.q_smallint,30)' ,'PERCENTILE(t1.q_tinyint,40)' ,'PERCENTILE(t1.q_float,50)' ,'PERCENTILE(t1.q_double,60)' , + 'twa(t2.q_int)' ,'twa(t2.q_bigint)' , 'twa(t2.q_smallint)' ,'twa(t2.q_tinyint)' ,'twa (t2.q_float)' ,'twa(t2.q_double)' , + 'IRATE(t2.q_int)' ,'IRATE(t2.q_bigint)' , 'IRATE(t2.q_smallint)' ,'IRATE(t2.q_tinyint)' ,'IRATE (t2.q_float)' ,'IRATE(t2.q_double)', + 'LEASTSQUARES(t2.q_int,15,3)' , 'LEASTSQUARES(t2.q_bigint,10,1)' , 'LEASTSQUARES(t2.q_smallint,20,3)' ,'LEASTSQUARES(t2.q_tinyint,10,4)' ,'LEASTSQUARES(t2.q_float,6,4)' ,'LEASTSQUARES(t2.q_double,3,1)' , + 'PERCENTILE(t2.q_int,10)' ,'PERCENTILE(t2.q_bigint,20)' , 'PERCENTILE(t2.q_smallint,30)' ,'PERCENTILE(t2.q_tinyint,40)' ,'PERCENTILE(t2.q_float,50)' ,'PERCENTILE(t2.q_double,60)'] + + calc_aggregate_groupbytbname_j = ['twa(t1.q_int)' ,'twa(t1.q_bigint)' , 'twa(t1.q_smallint)' ,'twa(t1.q_tinyint)' ,'twa (t1.q_float)' ,'twa(t1.q_double)' , + 'IRATE(t1.q_int)' ,'IRATE(t1.q_bigint)' , 'IRATE(t1.q_smallint)' ,'IRATE(t1.q_tinyint)' ,'IRATE (t1.q_float)' ,'IRATE(t1.q_double)' , + 'twa(t2.q_int)' ,'twa(t2.q_bigint)' , 'twa(t2.q_smallint)' ,'twa(t2.q_tinyint)' ,'twa (t2.q_float)' ,'twa(t2.q_double)' , + 'IRATE(t2.q_int)' ,'IRATE(t2.q_bigint)' , 'IRATE(t2.q_smallint)' ,'IRATE(t2.q_tinyint)' ,'IRATE (t2.q_float)' ,'IRATE(t2.q_double)' ] + + # calc_calculate_all calc_calculate_regular calc_calculate_groupbytbname + # calculation function include [all:spread\+-*/ ||regualr:diff\derivative ||group by tbname:diff\derivative\] + calc_calculate_all = ['SPREAD(ts)' , 'SPREAD(q_ts)' , 'SPREAD(q_int)' ,'SPREAD(q_bigint)' , 'SPREAD(q_smallint)' ,'SPREAD(q_tinyint)' ,'SPREAD(q_float)' ,'SPREAD(q_double)' , + '(SPREAD(q_int) + SPREAD(q_bigint))' , '(SPREAD(q_smallint) - SPREAD(q_float))', '(SPREAD(q_double) * SPREAD(q_tinyint))' , '(SPREAD(q_double) / SPREAD(q_float))'] + calc_calculate_regular = ['DIFF(q_int)' ,'DIFF(q_bigint)' , 'DIFF(q_smallint)' ,'DIFF(q_tinyint)' ,'DIFF(q_float)' ,'DIFF(q_double)' , + 'DERIVATIVE(q_int,15s,0)' , 'DERIVATIVE(q_bigint,10s,1)' , 'DERIVATIVE(q_smallint,20s,0)' ,'DERIVATIVE(q_tinyint,10s,1)' ,'DERIVATIVE(q_float,6s,0)' ,'DERIVATIVE(q_double,3s,1)' ] + calc_calculate_groupbytbname = calc_calculate_regular + + #two table join + calc_calculate_all_j = ['SPREAD(t1.ts)' , 'SPREAD(t1.q_ts)' , 'SPREAD(t1.q_int)' ,'SPREAD(t1.q_bigint)' , 'SPREAD(t1.q_smallint)' ,'SPREAD(t1.q_tinyint)' ,'SPREAD(t1.q_float)' ,'SPREAD(t1.q_double)' , + 'SPREAD(t2.ts)' , 'SPREAD(t2.q_ts)' , 'SPREAD(t2.q_int)' ,'SPREAD(t2.q_bigint)' , 'SPREAD(t2.q_smallint)' ,'SPREAD(t2.q_tinyint)' ,'SPREAD(t2.q_float)' ,'SPREAD(t2.q_double)' , + '(SPREAD(t1.q_int) + SPREAD(t1.q_bigint))' , '(SPREAD(t1.q_tinyint) - SPREAD(t1.q_float))', '(SPREAD(t1.q_double) * SPREAD(t1.q_tinyint))' , '(SPREAD(t1.q_double) / SPREAD(t1.q_tinyint))', + '(SPREAD(t2.q_int) + SPREAD(t2.q_bigint))' , '(SPREAD(t2.q_smallint) - SPREAD(t2.q_float))', '(SPREAD(t2.q_double) * SPREAD(t2.q_tinyint))' , '(SPREAD(t2.q_double) / SPREAD(t2.q_tinyint))', + '(SPREAD(t1.q_int) + SPREAD(t1.q_smallint))' , '(SPREAD(t2.q_smallint) - SPREAD(t2.q_float))', '(SPREAD(t1.q_double) * SPREAD(t1.q_tinyint))' , '(SPREAD(t1.q_double) / SPREAD(t1.q_float))'] + calc_calculate_regular_j = ['DIFF(t1.q_int)' ,'DIFF(t1.q_bigint)' , 'DIFF(t1.q_smallint)' ,'DIFF(t1.q_tinyint)' ,'DIFF(t1.q_float)' ,'DIFF(t1.q_double)' , + 'DERIVATIVE(t1.q_int,15s,0)' , 'DERIVATIVE(t1.q_bigint,10s,1)' , 'DERIVATIVE(t1.q_smallint,20s,0)' ,'DERIVATIVE(t1.q_tinyint,10s,1)' ,'DERIVATIVE(t1.q_float,6s,0)' ,'DERIVATIVE(t1.q_double,3s,1)' , + 'DIFF(t2.q_int)' ,'DIFF(t2.q_bigint)' , 'DIFF(t2.q_smallint)' ,'DIFF(t2.q_tinyint)' ,'DIFF(t2.q_float)' ,'DIFF(t2.q_double)' , + 'DERIVATIVE(t2.q_int,15s,0)' , 'DERIVATIVE(t2.q_bigint,10s,1)' , 'DERIVATIVE(t2.q_smallint,20s,0)' ,'DERIVATIVE(t2.q_tinyint,10s,1)' ,'DERIVATIVE(t2.q_float,6s,0)' ,'DERIVATIVE(t2.q_double,3s,1)' ] + calc_calculate_groupbytbname_j = calc_calculate_regular_j + + + #inter && calc_aggregate_all\calc_aggregate_regular\calc_select_all + interval_sliding = ['interval(4w) sliding(1w) ','interval(1w) sliding(1d) ','interval(1d) sliding(1h) ' , + 'interval(1h) sliding(1m) ','interval(1m) sliding(1s) ','interval(1s) sliding(100a) ', + 'interval(1y) ','interval(1n) ','interval(1w) ','interval(1d) ','interval(1h) ','interval(1m) ','interval(1s) ' ,'interval(100a)', + 'interval(1y,1n) ','interval(1n,1w) ','interval(1w,1d) ','interval(1d,1h) ','interval(1h,1m) ','interval(1m,1s) ','interval(1s,100a) ' ,'interval(100a,30a)'] + + #1 select * from (select column form regular_table where <\>\in\and\or order by) + tdSql.query("select 1-1 from table_0;") + for i in range(self.fornum): + sql = "select ts , * from ( select " + sql += "%s, " % random.choice(s_s_select) + sql += "%s, " % random.choice(q_select) + sql += "ts from regular_table_1 where " + sql += "%s " % random.choice(q_where) + sql += "%s " % random.choice(order_where) + sql += ");" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + #tdSql.checkData(0,0,'2020-09-13 20:26:40.000') + tdSql.checkRows(6*self.num) + + #1 outer union not support + #dcDB = self.dropandcreateDB(random.randint(1,3)) + tdSql.query("select 1-2 from table_0;") + for i in range(self.fornum): + sql = "select ts , * from ( select " + sql += "%s, " % random.choice(s_r_select) + sql += "%s, " % random.choice(q_select) + #sql += "%s, " % q_select[len(q_select) -i-1] + sql += "ts from regular_table_1 where " + sql += "%s " % random.choice(q_where) + sql += "%s " % random.choice(order_where) + sql += ")" + sql += " union all " + sql += "select ts , * from ( select " + sql += "%s, " % random.choice(s_r_select) + sql += "%s, " % random.choice(q_select) + #sql += "%s, " % q_select[len(q_select) -i-1] + sql += "ts from regular_table_1 where " + sql += "%s " % random.choice(q_where) + sql += "%s " % random.choice(order_where) + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + #1 inter union not support + tdSql.query("select 1-3 from table_0;") + for i in range(self.fornum): + sql = "select ts , * from ( select " + sql += "%s, " % random.choice(s_r_select) + sql += "%s, " % random.choice(q_select) + #sql += "%s, " % q_select[len(q_select) -i-1] + sql += "ts from regular_table_1 where " + sql += "%s " % random.choice(q_where) + sql += "%s " % random.choice(order_where) + sql += " union all " + sql += " select " + sql += "%s, " % random.choice(s_r_select) + sql += "%s, " % random.choice(q_select) + #sql += "%s, " % q_select[len(q_select) -i-1] + sql += "ts from regular_table_2 where " + sql += "%s " % random.choice(q_where) + sql += "%s " % random.choice(order_where) + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + #join:TD-6020\TD-6149 select * from (select column form regular_table1,regular_table2 where t1.ts=t2.ts and <\>\in\and\or order by) + dcDB = self.dropandcreateDB(random.randint(1,3)) + tdSql.query("select 1-4 from table_0;") + for i in range(self.fornum): + sql = "select ts , * from ( select t1.ts ," + sql += "t1.%s, " % random.choice(s_s_select) + sql += "t1.%s, " % random.choice(q_select) + sql += "t2.%s, " % random.choice(s_s_select) + sql += "t2.%s, " % random.choice(q_select) + sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(q_u_where) + sql += "%s " % random.choice(order_u_where) + sql += ");" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + #tdSql.checkData(0,0,'2020-09-13 20:26:40.000') + #tdSql.checkRows(6*self.num) + + tdSql.query("select 1-5 from table_0;") + for i in range(self.fornum): + sql = "select ts , * from ( select t1.ts ," + sql += "t1.%s, " % random.choice(s_s_select) + sql += "t1.%s, " % random.choice(q_select) + sql += "t2.%s, " % random.choice(s_s_select) + sql += "t2.%s, " % random.choice(q_select) + sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(q_u_or_where) + sql += "%s " % random.choice(order_u_where) + sql += ");" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + #2 select column from (select * form regular_table ) where <\>\in\and\or order by + dcDB = self.dropandcreateDB(random.randint(1,2)) + tdSql.query("select 2-1 from table_0;") + for i in range(self.fornum): + sql = "select ts ," + sql += "%s, " % random.choice(s_r_select) + sql += "%s " % random.choice(q_select) + sql += " from ( select * from regular_table_1 ) where " + sql += "%s " % random.choice(q_where) + sql += "%s " % random.choice(order_where) + sql += " ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + #tdSql.checkData(0,0,'2020-09-13 20:26:40.000') + tdSql.checkRows(6*self.num) + + #join: select column from (select column form regular_table1,regular_table2 )where t1.ts=t2.ts and <\>\in\and\or order by + #cross join not supported yet + tdSql.query("select 2-2 from table_0;") + for i in range(self.fornum): + sql = "select ts , * from ( select t1.ts ," + sql += "t1.%s, " % random.choice(s_s_select) + sql += "t1.%s, " % random.choice(q_select) + sql += "t2.%s, " % random.choice(s_s_select) + sql += "t2.%s, " % random.choice(q_select) + sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 ) where t1.ts = t2.ts and " + sql += "%s " % random.choice(q_u_where) + sql += "%s " % random.choice(order_u_where) + #sql += ");" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + #3 select * from (select column\tag form stable where <\>\in\and\or order by ) + dcDB = self.dropandcreateDB(random.randint(1,3)) + tdSql.query("select 3-1 from table_0;") + for i in range(self.fornum): + sql = "select ts , * , " + sql += "%s, " % random.choice(s_r_select) + sql += " * from ( select " + sql += "%s, " % random.choice(s_s_select) + sql += "%s, " % random.choice(q_select) + sql += "%s, " % random.choice(t_select) + sql += "ts from stable_1 where " + sql += "%s " % random.choice(qt_where) + sql += "%s " % random.choice(order_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + #tdSql.checkData(0,0,'2020-09-13 20:26:40.000') + tdSql.checkRows(6*self.num) + + # select ts,* from (select column\tag form stable1,stable2 where t1.ts = t2.ts and <\>\in\and\or order by ) + dcDB = self.dropandcreateDB(random.randint(1,3)) + tdSql.query("select 3-2 from table_0;") + for i in range(self.fornum): + sql = "select ts , * from ( select t1.ts , " + sql += "t1.%s, " % random.choice(s_s_select) + sql += "t1.%s, " % random.choice(q_select) + sql += "t2.%s, " % random.choice(s_s_select) + sql += "t2.%s, " % random.choice(q_select) + sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(t_join_where) + sql += "%s " % random.choice(order_u_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + #3 outer union not support + rsDn = self.restartDnodes() + tdSql.query("select 3-3 from table_0;") + for i in range(self.fornum): + sql = "select ts , * from ( select " + sql += "%s, " % random.choice(s_r_select) + sql += "%s, " % random.choice(q_select) + #sql += "%s, " % q_select[len(q_select) -i-1] + sql += "ts from stable_1 where " + sql += "%s " % random.choice(q_where) + sql += "%s " % random.choice(order_where) + sql += ")" + sql += " union all " + sql += "select ts , * from ( select " + sql += "%s, " % random.choice(s_r_select) + sql += "%s, " % random.choice(q_select) + #sql += "%s, " % q_select[len(q_select) -i-1] + sql += "ts from stable_2 where " + sql += "%s " % random.choice(q_where) + sql += "%s " % random.choice(order_where) + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + #3 inter union not support + tdSql.query("select 3-4 from table_0;") + for i in range(self.fornum): + sql = "select ts , * from ( select " + sql += "%s, " % random.choice(s_r_select) + sql += "%s, " % random.choice(q_select) + #sql += "%s, " % q_select[len(q_select) -i-1] + sql += "ts from stable_1 where " + sql += "%s " % random.choice(q_where) + sql += "%s " % random.choice(order_where) + sql += " union all " + sql += " select " + sql += "%s, " % random.choice(s_r_select) + sql += "%s, " % random.choice(q_select) + #sql += "%s, " % q_select[len(q_select) -i-1] + sql += "ts from stable_2 where " + sql += "%s " % random.choice(q_where) + sql += "%s " % random.choice(order_where) + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + #join:TD-6020\TD-6155 select * from (select column form stable1,stable2 where t1.ts=t2.ts and <\>\in\and\or order by) + tdSql.query("select 3-5 from table_0;") + for i in range(self.fornum): + sql = "select ts , * from ( select t1.ts ," + sql += "t1.%s, " % random.choice(s_s_select) + sql += "t1.%s, " % random.choice(q_select) + sql += "t2.%s, " % random.choice(s_s_select) + sql += "t2.%s, " % random.choice(q_select) + sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(t_u_where) + sql += "%s " % random.choice(order_u_where) + sql += ");" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + tdSql.query("select 3-6 from table_0;") + for i in range(self.fornum): + sql = "select ts , * from ( select t1.ts ," + sql += "t1.%s, " % random.choice(s_s_select) + sql += "t1.%s, " % random.choice(q_select) + sql += "t2.%s, " % random.choice(s_s_select) + sql += "t2.%s, " % random.choice(q_select) + sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(t_u_or_where) + sql += "%s " % random.choice(order_u_where) + sql += ");" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + #4 select column from (select * form stable where <\>\in\and\or order by ) + dcDB = self.dropandcreateDB(random.randint(1,2)) + tdSql.query("select 4-1 from table_0;") + for i in range(self.fornum): + sql = "select ts , " + sql += "%s, " % random.choice(s_r_select) + sql += "%s, " % random.choice(q_select) + sql += "%s " % random.choice(t_select) + sql += " from ( select * from stable_1 where " + sql += "%s " % random.choice(qt_where) + sql += "%s " % random.choice(order_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + #tdSql.checkData(0,0,'2020-09-13 20:26:40.000') + tdSql.checkRows(6*self.num) + + #5 select distinct column\tag from (select * form stable where <\>\in\and\or order by limit offset ) + tdSql.query("select 5-1 from table_0;") + for i in range(self.fornum): + sql = "select " + sql += "%s " % random.choice(dqt_select) + sql += " from ( select * from stable_1 where " + sql += "%s " % random.choice(qt_where) + sql += "%s " % random.choice(order_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + #5-1 select distinct column\tag from (select calc form stable where <\>\in\and\or order by limit offset ) + tdSql.query("select 5-2 from table_0;") + for i in range(self.fornum): + sql = "select distinct c5_1 " + sql += " from ( select " + sql += "%s " % random.choice(calc_select_in_ts) + sql += " as c5_1 from stable_1 where " + sql += "%s " % random.choice(qt_where) + sql += "%s " % random.choice(order_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + #6-error select * from (select distinct(tag) form stable where <\>\in\and\or order by limit ) + tdSql.query("select 6-1 from table_0;") + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s " % random.choice(dt_select) + sql += " from stable_1 where " + sql += "%s " % random.choice(qt_where) + sql += "%s " % random.choice(order_desc_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + #7-error select * from (select distinct(tag) form stable where <\>\in\and\or order by limit ) + tdSql.query("select 7-1 from table_0;") + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s " % random.choice(dq_select) + sql += " from stable_1 where " + sql += "%s " % random.choice(qt_where) + sql += "%s " % random.choice(order_desc_where) + sql += "%s " % random.choice([limit_where[0] , limit_where[1]] ) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + #calc_select,TWA/Diff/Derivative/Irate are not allowed to apply to super table directly + #8 select * from (select ts,calc form ragular_table where <\>\in\and\or order by ) + #TD-6185 + dcDB = self.dropandcreateDB(random.randint(1,3)) + tdSql.query("select 8-1 from table_0;") + for i in range(self.fornum): + sql = "select * from ( select ts ," + sql += "%s " % random.choice(calc_select_in_ts) + sql += "from regular_table_1 where " + sql += "%s " % random.choice(q_where) + sql += "%s " % random.choice(order_where) + sql += "%s " % random.choice(limit1_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + + dcDB = self.dropandcreateDB(random.randint(1,3)) + tdSql.query("select 8-2 from table_0;") + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s " % random.choice(calc_select_in_ts_j) + sql += "from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(q_u_where) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(limit1_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + tdSql.query("select 8-3 from table_0;") + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s " % random.choice(calc_select_in_ts_j) + sql += "from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(q_u_or_where) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(limit1_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + #9 select * from (select ts,calc form stable where <\>\in\and\or order by ) + # TD-5960\TD-6185 + dcDB = self.dropandcreateDB(random.randint(1,2)) + tdSql.query("select 9-1 from table_0;") + for i in range(self.fornum): + sql = "select * from ( select ts ," + sql += "%s " % random.choice(calc_select_in_ts) + sql += "from stable_1 where " + sql += "%s " % random.choice(qt_where) + sql += "%s " % random.choice(order_where) + sql += "%s " % random.choice(limit1_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + + dcDB = self.dropandcreateDB(random.randint(1,3)) + tdSql.query("select 9-2 from table_0;") + #TD-6426 + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s " % random.choice(calc_select_in_ts_j) + sql += "from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(t_join_where) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(limit1_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + tdSql.query("select 9-3 from table_0;") + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s " % random.choice(calc_select_in_ts_j) + sql += "from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(qt_u_or_where) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(limit1_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + #functions or others can not be mixed up ,calc out select not use with ts + + #10 select calc from (select * form regualr_table where <\>\in\and\or order by ) + dcDB = self.dropandcreateDB(random.randint(1,2)) + tdSql.query("select 10-1 from table_0;") + for i in range(self.fornum): + sql = "select " + sql += "%s " % random.choice(calc_select_in_ts) + sql += "as calc10_1 from ( select * from regular_table_1 where " + sql += "%s " % random.choice(q_where) + sql += "%s " % random.choice(order_desc_where) + sql += "%s " % random.choice(limit1_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(1) + + #10-1 select calc from (select * form regualr_table where <\>\in\and\or order by ) + rsDn = self.restartDnodes() + dcDB = self.dropandcreateDB(random.randint(1,3)) + rsDn = self.restartDnodes() + tdSql.query("select 10-2 from table_0;") + for i in range(self.fornum): + sql = "select " + sql += "%s " % random.choice(calc_select_all) + sql += "as calc10_1 from ( select * from regular_table_1 where " + sql += "%s " % random.choice(q_where) + sql += "%s " % random.choice(order_desc_where) + sql += "%s " % random.choice(limit1_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(1) + + #10-2 select calc from (select * form regualr_tables where <\>\in\and\or order by ) + dcDB = self.dropandcreateDB(random.randint(1,3)) + tdSql.query("select 10-3 from table_0;") + for i in range(self.fornum): + sql = "select " + sql += "%s as calc10_1 " % random.choice(calc_select_all) + sql += " from ( select * from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(q_u_where) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(limit_u_where) + sql += ") " + sql += "%s ;" % random.choice(limit_u_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + tdSql.query("select 10-4 from table_0;") + for i in range(self.fornum): + sql = "select " + sql += "%s as calc10_1 " % random.choice(calc_select_all) + sql += " from ( select * from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(q_u_or_where) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(limit_u_where) + sql += ") " + sql += "%s ;" % random.choice(limit_u_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + #11 select calc from (select * form stable where <\>\in\and\or order by limit ) + dcDB = self.dropandcreateDB(random.randint(1,2)) + tdSql.query("select 11-1 from table_0;") + for i in range(self.fornum): + sql = "select " + sql += "%s " % random.choice(calc_select_in_ts) + sql += "as calc11_1 from ( select * from stable_1 where " + sql += "%s " % random.choice(qt_where) + sql += "%s " % random.choice(order_desc_where) + sql += "%s " % random.choice(limit1_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(1) + + #11-1 select calc from (select * form stable where <\>\in\and\or order by limit ) + dcDB = self.dropandcreateDB(random.randint(1,3)) + tdSql.query("select 11-2 from table_0;") + for i in range(self.fornum): + sql = "select " + sql += "%s " % random.choice(calc_select_all) + sql += "as calc11_1 from ( select * from stable_1 where " + sql += "%s " % random.choice(qt_where) + sql += "%s " % random.choice(order_desc_where) + sql += "%s " % random.choice(limit1_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(1) + + #11-2 select calc from (select * form stables where <\>\in\and\or order by limit ) + tdSql.query("select 11-3 from table_0;") + for i in range(self.fornum): + sql = "select " + sql += "%s " % random.choice(calc_select_all) + sql += "as calc11_1 from ( select * from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(t_join_where) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(limit_u_where) + sql += ") " + sql += "%s ;" % random.choice(limit_u_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + tdSql.query("select 11-4 from table_0;") + for i in range(self.fornum): + sql = "select " + sql += "%s " % random.choice(calc_select_all) + sql += "as calc11_1 from ( select * from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(qt_u_or_where) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(limit_u_where) + sql += ") " + sql += "%s ;" % random.choice(limit_u_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + #12 select calc-diff from (select * form regualr_table where <\>\in\and\or order by limit ) + dcDB = self.dropandcreateDB(random.randint(1,3)) + tdSql.query("select 12-1 from table_0;") + for i in range(self.fornum): + sql = "select " + sql += "%s " % random.choice(calc_calculate_regular) + sql += " from ( select * from regular_table_1 where " + sql += "%s " % random.choice(q_where) + sql += "%s " % random.choice(order_desc_where) + sql += "%s " % random.choice([limit_where[2] , limit_where[3]] ) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(1) + + tdSql.query("select 12-2 from table_0;") + for i in range(self.fornum): + sql = "select " + sql += "%s " % random.choice(calc_calculate_regular) + sql += " from ( select * from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(q_u_where) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice([limit_where[2] , limit_where[3]] ) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + #tdSql.checkRows(1) + + tdSql.query("select 12-2.2 from table_0;") + for i in range(self.fornum): + sql = "select " + sql += "%s " % random.choice(calc_calculate_regular) + sql += " from ( select * from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(q_u_or_where) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice([limit_where[2] , limit_where[3]] ) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + #12-1 select calc-diff from (select * form stable where <\>\in\and\or order by limit ) + tdSql.query("select 12-3 from table_0;") + rsDn = self.restartDnodes() + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s " % random.choice(calc_calculate_regular) + sql += " from stable_1 where " + sql += "%s " % random.choice(q_where) + sql += "%s " % random.choice(group_where) + sql += ") " + sql += "%s " % random.choice(order_desc_where) + sql += "%s " % random.choice([limit_where[2] , limit_where[3]] ) + sql += " ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + tdSql.query("select 12-4 from table_0;") + #join query does not support group by + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s " % random.choice(calc_calculate_regular_j) + sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(t_join_where) + sql += "%s " % random.choice(group_where) + sql += ") " + sql += "%s " % random.choice(order_desc_where) + sql += "%s " % random.choice([limit_where[2] , limit_where[3]] ) + sql += " ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + tdSql.query("select 12-5 from table_0;") + #join query does not support group by + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s " % random.choice(calc_calculate_regular_j) + sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(qt_u_or_where) + sql += "%s " % random.choice(group_where) + sql += ") " + sql += "%s " % random.choice(order_desc_where) + sql += "%s " % random.choice([limit_where[2] , limit_where[3]] ) + sql += " ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + + #13 select calc-diff as diffns from (select * form stable where <\>\in\and\or order by limit ) + tdSql.query("select 13-1 from table_0;") + for i in range(self.fornum): + sql = "select " + sql += "%s " % random.choice(calc_calculate_regular) + sql += " as calc13_1 from ( select * from stable_1 where " + sql += "%s " % random.choice(qt_where) + sql += "%s " % random.choice(orders_desc_where) + sql += "%s " % random.choice([limit_where[2] , limit_where[3]] ) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + #14 select * from (select calc_aggregate_alls as agg from stable where <\>\in\and\or group by order by slimit soffset ) + # TD-5955 select * from ( select count (q_double) from stable_1 where t_bool = true or t_bool = false group by loc order by ts asc slimit 1 ) ; + dcDB = self.dropandcreateDB(random.randint(1,3)) + tdSql.query("select 14-1 from table_0;") + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s as calc14_1, " % random.choice(calc_aggregate_all) + sql += "%s as calc14_2, " % random.choice(calc_aggregate_all) + sql += "%s " % random.choice(calc_aggregate_all) + sql += " as calc14_3 from stable_1 where " + sql += "%s " % random.choice(qt_where) + sql += "%s " % random.choice(group_where) + sql += "%s " % random.choice(order_desc_where) + sql += "%s " % random.choice(slimit1_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + #tdSql.checkRows(1) + + # error group by in out query + tdSql.query("select 14-2 from table_0;") + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s as calc14_1, " % random.choice(calc_aggregate_all) + sql += "%s as calc14_2, " % random.choice(calc_aggregate_all) + sql += "%s " % random.choice(calc_aggregate_all) + sql += " as calc14_3 from stable_1 where " + sql += "%s " % random.choice(qt_where) + sql += "%s " % random.choice(group_where) + sql += "%s " % random.choice(having_support) + sql += "%s " % random.choice(orders_desc_where) + sql += "%s " % random.choice(slimit1_where) + sql += ") " + sql += "%s " % random.choice(group_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + #14-2 TD-6426 select * from (select calc_aggregate_all_js as agg from stables where <\>\in\and\or group by order by slimit soffset ) + tdSql.query("select 14-3 from table_0;") + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s as calc14_1, " % random.choice(calc_aggregate_all_j) + sql += "%s as calc14_2, " % random.choice(calc_aggregate_all_j) + sql += "%s " % random.choice(calc_aggregate_all_j) + sql += " as calc14_3 from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(t_join_where) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(slimit1_where) + sql += ") " + sql += "%s ;" % random.choice(limit_u_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + tdSql.query("select 14-4 from table_0;") + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s as calc14_1, " % random.choice(calc_aggregate_all_j) + sql += "%s as calc14_2, " % random.choice(calc_aggregate_all_j) + sql += "%s " % random.choice(calc_aggregate_all_j) + sql += " as calc14_3 from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(qt_u_or_where) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(slimit1_where) + sql += ") " + sql += "%s ;" % random.choice(limit_u_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + #15 TD-6320 select * from (select calc_aggregate_regulars as agg from regular_table where <\>\in\and\or order by slimit soffset ) + tdSql.query("select 15-1 from table_0;") + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s as calc15_1, " % random.choice(calc_aggregate_regular) + sql += "%s as calc15_2, " % random.choice(calc_aggregate_regular) + sql += "%s " % random.choice(calc_aggregate_regular) + sql += " as calc15_3 from regular_table_1 where " + sql += "%s " % random.choice(q_where) + sql += "%s " % random.choice(order_desc_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(1) + + dcDB = self.dropandcreateDB(random.randint(1,3)) + tdSql.query("select 15-2 from table_0;") + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s as calc15_1, " % random.choice(calc_aggregate_regular_j) + sql += "%s as calc15_2, " % random.choice(calc_aggregate_regular_j) + sql += "%s " % random.choice(calc_aggregate_regular_j) + sql += " as calc15_3 from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(q_u_where) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(limit_u_where) + sql += ") " + sql += "%s ;" % random.choice(limit_u_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + tdSql.query("select 15-2.2 from table_0;") + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s as calc15_1, " % random.choice(calc_aggregate_regular_j) + sql += "%s as calc15_2, " % random.choice(calc_aggregate_regular_j) + sql += "%s " % random.choice(calc_aggregate_regular_j) + sql += " as calc15_3 from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(q_u_or_where) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(limit_u_where) + sql += ") " + sql += "%s ;" % random.choice(limit_u_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + rsDn = self.restartDnodes() + tdSql.query("select 15-3 from table_0;") + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s as calc15_1, " % random.choice(calc_aggregate_groupbytbname) + sql += "%s as calc15_2, " % random.choice(calc_aggregate_groupbytbname) + sql += "%s " % random.choice(calc_aggregate_groupbytbname) + sql += " as calc15_3 from stable_1 where " + sql += "%s " % random.choice(q_where) + sql += "%s " % random.choice(group_where) + sql += "%s " % random.choice(having_support) + sql += "%s " % random.choice(order_desc_where) + sql += ") " + sql += "order by calc15_1 " + sql += "%s " % random.choice(limit_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + tdSql.query("select 15-4 from table_0;") + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s as calc15_1, " % random.choice(calc_aggregate_groupbytbname_j) + sql += "%s as calc15_2, " % random.choice(calc_aggregate_groupbytbname_j) + sql += "%s " % random.choice(calc_aggregate_groupbytbname_j) + sql += " as calc15_3 from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(t_join_where) + sql += "%s " % random.choice(group_where) + sql += "%s " % random.choice(having_support) + sql += "%s " % random.choice(orders_desc_where) + sql += ") " + sql += "order by calc15_1 " + sql += "%s " % random.choice(limit_u_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + tdSql.query("select 15-4.2 from table_0;") + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s as calc15_1, " % random.choice(calc_aggregate_groupbytbname_j) + sql += "%s as calc15_2, " % random.choice(calc_aggregate_groupbytbname_j) + sql += "%s " % random.choice(calc_aggregate_groupbytbname_j) + sql += " as calc15_3 from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(qt_u_or_where) + sql += "%s " % random.choice(group_where) + sql += "%s " % random.choice(having_support) + sql += "%s " % random.choice(orders_desc_where) + sql += ") " + sql += "order by calc15_1 " + sql += "%s " % random.choice(limit_u_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + tdSql.query("select 15-5 from table_0;") + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s as calc15_1, " % random.choice(calc_aggregate_groupbytbname) + sql += "%s as calc15_2, " % random.choice(calc_aggregate_groupbytbname) + sql += "%s " % random.choice(calc_aggregate_groupbytbname) + sql += " as calc15_3 from stable_1 where " + sql += "%s " % random.choice(q_where) + sql += "%s " % random.choice(orders_desc_where) + sql += ") " + sql += "order by calc15_1 " + sql += "%s " % random.choice(limit_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + #16 select * from (select calc_aggregate_regulars as agg from regular_table where <\>\in\and\or order by limit offset ) + dcDB = self.dropandcreateDB(random.randint(1,2)) + tdSql.query("select 16-1 from table_0;") + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s as calc16_0 , " % random.choice(calc_calculate_all) + sql += "%s as calc16_1 , " % random.choice(calc_aggregate_all) + sql += "%s as calc16_2 " % random.choice(calc_select_in) + sql += " from stable_1 where " + sql += "%s " % random.choice(q_where) + sql += "%s " % random.choice(group_where) + sql += "%s " % random.choice(having_support) + sql += ") " + sql += "order by calc16_0 " + sql += "%s " % random.choice(limit1_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(1) + + tdSql.query("select 16-2 from table_0;") + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s as calc16_0 " % random.choice(calc_calculate_all_j) + sql += ", %s as calc16_1 " % random.choice(calc_aggregate_all_j) + #sql += ", %s as calc16_2 " % random.choice(calc_select_in_j) + sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(t_join_where) + sql += ") " + sql += "order by calc16_0 " + sql += "%s " % random.choice(limit1_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + tdSql.query("select 16-2.2 from table_0;") + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s as calc16_0 " % random.choice(calc_calculate_all_j) + sql += ", %s as calc16_1 " % random.choice(calc_aggregate_all_j) + sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(qt_u_or_where) + sql += ") " + sql += "order by calc16_0 " + sql += "%s " % random.choice(limit1_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + dcDB = self.dropandcreateDB(random.randint(1,3)) + tdSql.query("select 16-3 from table_0;") + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s as calc16_1 " % random.choice(calc_calculate_regular) + sql += " from regular_table_1 where " + sql += "%s " % random.choice(q_where) + sql += "limit 2 ) " + sql += "%s " % random.choice(limit1_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(1) + + tdSql.query("select 16-4 from table_0;") + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s as calc16_1 " % random.choice(calc_calculate_regular_j) + sql += " from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(q_u_where) + sql += "limit 2 ) " + sql += "%s " % random.choice(limit1_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(1) + + tdSql.query("select 16-4.2 from table_0;") + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s as calc16_1 " % random.choice(calc_calculate_regular_j) + sql += " from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(q_u_or_where) + sql += "limit 2 ) " + sql += "%s " % random.choice(limit1_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + tdSql.query("select 16-5 from table_0;") + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s as calc16_1 , " % random.choice(calc_calculate_all) + sql += "%s as calc16_1 , " % random.choice(calc_calculate_regular) + sql += "%s as calc16_2 " % random.choice(calc_select_all) + sql += " from stable_1 where " + sql += "%s " % random.choice(q_where) + sql += "%s " % random.choice(group_where) + sql += "%s " % random.choice(having_support) + sql += ") " + sql += "order by calc16_1 " + sql += "%s " % random.choice(limit1_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + dcDB = self.dropandcreateDB(random.randint(1,3)) + tdSql.query("select 16-6 from table_0;") + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s as calc16_1 " % random.choice(calc_calculate_groupbytbname) + sql += " from stable_1 where " + sql += "%s " % random.choice(q_where) + sql += "%s " % random.choice(group_where) + sql += "limit 2 ) " + sql += "%s " % random.choice(limit1_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(1) + + tdSql.query("select 16-7 from table_0;") + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s as calc16_1 " % random.choice(calc_calculate_groupbytbname_j) + sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(t_join_where) + sql += "limit 2 ) " + sql += "%s " % random.choice(limit1_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + tdSql.query("select 16-8 from table_0;") + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s as calc16_1 " % random.choice(calc_calculate_groupbytbname_j) + sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(qt_u_or_where) + sql += "limit 2 ) " + sql += "%s " % random.choice(limit1_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + #17 select apercentile from (select calc_aggregate_alls form regualr_table or stable where <\>\in\and\or interval_sliding group by having order by limit offset )interval_sliding + # TD-6088 + dcDB = self.dropandcreateDB(random.randint(1,2)) + tdSql.query("select 17-1 from table_0;") + for i in range(self.fornum): + #this is having_support , but tag-select cannot mix with last_row,other select can + sql = "select apercentile(cal17_0, %d)/10 ,apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) + sql += "%s as cal17_0 , " % random.choice(calc_calculate_all) + sql += "%s as cal17_1 ," % random.choice(calc_aggregate_all) + sql += "%s as cal17_2 " % random.choice(calc_aggregate_all) + sql += " from stable_1 where " + sql += "%s " % random.choice(qt_where) + sql += "%s " % random.choice(interval_sliding) + sql += "%s " % random.choice(group_where) + sql += "%s " % random.choice(having_support) + sql += "%s " % random.choice(order_where) + sql += "%s " % random.choice(limit1_where) + sql += ") " + sql += "%s " % random.choice(interval_sliding) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + dcDB = self.dropandcreateDB(random.randint(1,3)) + tdSql.query("select 17-2 from table_0;") + for i in range(self.fornum): + #this is having_support , but tag-select cannot mix with last_row,other select can + sql = "select apercentile(cal17_0, %d)/10 ,apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) + sql += "%s as cal17_0 , " % random.choice(calc_calculate_all_j) + sql += "%s as cal17_1 ," % random.choice(calc_aggregate_all_j) + sql += "%s as cal17_2 " % random.choice(calc_aggregate_all_j) + sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(t_join_where) + sql += "%s " % random.choice(interval_sliding) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(limit_u_where) + sql += ") " + sql += "%s " % random.choice(interval_sliding) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + tdSql.query("select 17-2.2 from table_0;") + for i in range(self.fornum): + #this is having_support , but tag-select cannot mix with last_row,other select can + sql = "select apercentile(cal17_0, %d)/10 ,apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) + sql += "%s as cal17_0 , " % random.choice(calc_calculate_all_j) + sql += "%s as cal17_1 ," % random.choice(calc_aggregate_all_j) + sql += "%s as cal17_2 " % random.choice(calc_aggregate_all_j) + sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(qt_u_or_where) + sql += "%s " % random.choice(interval_sliding) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(limit_u_where) + sql += ") " + sql += "%s " % random.choice(interval_sliding) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + rsDn = self.restartDnodes() + tdSql.query("select 17-3 from table_0;") + for i in range(self.fornum): + #this is having_tagnot_support , because tag-select cannot mix with last_row... + sql = "select apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) + sql += "%s as cal17_1 ," % random.choice(calc_aggregate_all) + sql += "%s as cal17_2 " % random.choice(calc_aggregate_all) + sql += " from stable_1 where " + sql += "%s " % random.choice(q_where) + sql += "%s " % random.choice(interval_sliding) + sql += "%s " % random.choice(group_where) + sql += "%s " % random.choice(having_tagnot_support) + sql += "%s " % random.choice(order_where) + sql += "%s " % random.choice(limit1_where) + sql += ") " + sql += "%s " % random.choice(interval_sliding) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + tdSql.query("select 17-4 from table_0;") + for i in range(self.fornum): + #this is having_tagnot_support , because tag-select cannot mix with last_row... + sql = "select apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) + sql += "%s as cal17_1 ," % random.choice(calc_aggregate_all_j) + sql += "%s as cal17_2 " % random.choice(calc_aggregate_all_j) + sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(t_join_where) + sql += "%s " % random.choice(interval_sliding) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(limit_u_where) + sql += ") " + sql += "%s " % random.choice(interval_sliding) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + tdSql.query("select 17-4.2 from table_0;") + for i in range(self.fornum): + #this is having_tagnot_support , because tag-select cannot mix with last_row... + sql = "select apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) + sql += "%s as cal17_1 ," % random.choice(calc_aggregate_all_j) + sql += "%s as cal17_2 " % random.choice(calc_aggregate_all_j) + sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(qt_u_or_where) + sql += "%s " % random.choice(interval_sliding) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(limit_u_where) + sql += ") " + sql += "%s " % random.choice(interval_sliding) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + tdSql.query("select 17-5 from table_0;") + for i in range(self.fornum): + #having_not_support + sql = "select apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) + sql += "%s as cal17_1 ," % random.choice(calc_aggregate_all) + sql += "%s as cal17_2 " % random.choice(calc_aggregate_all) + sql += " from stable_1 where " + sql += "%s " % random.choice(qt_where) + sql += "%s " % random.choice(interval_sliding) + sql += "%s " % random.choice(group_where) + sql += "%s " % random.choice(having_not_support) + sql += "%s " % random.choice(order_where) + sql += "%s " % random.choice(limit1_where) + sql += ") " + sql += "%s " % random.choice(interval_sliding) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + dcDB = self.dropandcreateDB(random.randint(1,2)) + tdSql.query("select 17-6 from table_0;") + for i in range(self.fornum): + sql = "select apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) + sql += "%s as cal17_1 ," % random.choice(calc_aggregate_all) + sql += "%s as cal17_2 " % random.choice(calc_aggregate_all) + sql += " from table_1 where " + sql += "%s " % random.choice(q_where) + sql += "%s " % random.choice(interval_sliding) + sql += "%s " % random.choice(order_where) + sql += "%s " % random.choice(limit1_where) + sql += ") " + sql += "%s " % random.choice(interval_sliding) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + tdSql.query("select 17-7 from table_0;") + for i in range(self.fornum): + sql = "select apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) + sql += "%s as cal17_1 ," % random.choice(calc_aggregate_all_j) + sql += "%s as cal17_2 " % random.choice(calc_aggregate_all_j) + sql += " from table_1 t1, table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(q_u_where) + sql += "%s " % random.choice(interval_sliding) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(limit1_where) + sql += ") " + sql += "%s " % random.choice(interval_sliding) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + tdSql.query("select 17-7.2 from table_0;") + for i in range(self.fornum): + sql = "select apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) + sql += "%s as cal17_1 ," % random.choice(calc_aggregate_all_j) + sql += "%s as cal17_2 " % random.choice(calc_aggregate_all_j) + sql += " from table_1 t1, table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(q_u_or_where) + sql += "%s " % random.choice(interval_sliding) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(limit1_where) + sql += ") " + sql += "%s " % random.choice(interval_sliding) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + rsDn = self.restartDnodes() + tdSql.query("select 17-8 from table_0;") + for i in range(self.fornum): + sql = "select apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) + sql += "%s as cal17_1 ," % random.choice(calc_aggregate_all) + sql += "%s as cal17_2 " % random.choice(calc_aggregate_all) + sql += " from regular_table_1 where " + sql += "%s " % random.choice(q_where) + sql += "%s " % random.choice(interval_sliding) + sql += "%s " % random.choice(order_where) + sql += "%s " % random.choice(limit1_where) + sql += ") " + sql += "%s " % random.choice(interval_sliding) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + dcDB = self.dropandcreateDB(random.randint(1,2)) + tdSql.query("select 17-9 from table_0;") + for i in range(self.fornum): + sql = "select apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) + sql += "%s as cal17_1 ," % random.choice(calc_aggregate_all_j) + sql += "%s as cal17_2 " % random.choice(calc_aggregate_all_j) + sql += " from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(q_u_where) + sql += "%s " % random.choice(interval_sliding) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(limit_u_where) + sql += ") " + sql += "%s " % random.choice(interval_sliding) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + tdSql.query("select 17-10 from table_0;") + for i in range(self.fornum): + sql = "select apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) + sql += "%s as cal17_1 ," % random.choice(calc_aggregate_all_j) + sql += "%s as cal17_2 " % random.choice(calc_aggregate_all_j) + sql += " from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(q_u_or_where) + sql += "%s " % random.choice(interval_sliding) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(limit_u_where) + sql += ") " + sql += "%s " % random.choice(interval_sliding) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + #18 select apercentile from (select calc_aggregate_alls form regualr_table or stable where <\>\in\and\or session order by limit )interval_sliding + tdSql.query("select 18-1 from table_0;") + for i in range(self.fornum): + sql = "select apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) + sql += "%s as cal18_1 ," % random.choice(calc_aggregate_all) + sql += "%s as cal18_2 " % random.choice(calc_aggregate_all) + sql += " from regular_table_1 where " + sql += "%s " % random.choice(q_where) + sql += "%s " % random.choice(session_where) + sql += "%s " % random.choice(fill_where) + sql += "%s " % random.choice(order_where) + sql += "%s " % random.choice(limit1_where) + sql += ") " + sql += "%s " % random.choice(interval_sliding) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + tdSql.query("select 18-2 from table_0;") + dcDB = self.dropandcreateDB(random.randint(1,3)) + for i in range(self.fornum): + sql = "select apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) + sql += "%s as cal18_1 ," % random.choice(calc_aggregate_all_j) + sql += "%s as cal18_2 " % random.choice(calc_aggregate_all_j) + sql += " from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(q_u_where) + sql += "%s " % random.choice(session_u_where) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(limit_u_where) + sql += ") " + sql += "%s " % random.choice(interval_sliding) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + tdSql.query("select 18-2.2 from table_0;") + for i in range(self.fornum): + sql = "select apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) + sql += "%s as cal18_1 ," % random.choice(calc_aggregate_all_j) + sql += "%s as cal18_2 " % random.choice(calc_aggregate_all_j) + sql += " from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(q_u_or_where) + sql += "%s " % random.choice(session_u_where) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(limit_u_where) + sql += ") " + sql += "%s " % random.choice(interval_sliding) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + rsDn = self.restartDnodes() + tdSql.query("select 18-3 from table_0;") + for i in range(self.fornum): + sql = "select apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) + sql += "%s as cal18_1 ," % random.choice(calc_aggregate_all) + sql += "%s as cal18_2 " % random.choice(calc_aggregate_all) + sql += " from table_1 where " + sql += "%s " % random.choice(q_where) + sql += "%s " % random.choice(session_where) + sql += "%s " % random.choice(fill_where) + sql += "%s " % random.choice(order_where) + sql += "%s " % random.choice(limit1_where) + sql += ") " + sql += "%s " % random.choice(interval_sliding) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + tdSql.query("select 18-4 from table_0;") + dcDB = self.dropandcreateDB(random.randint(1,3)) + for i in range(self.fornum): + sql = "select apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) + sql += "%s as cal18_1 ," % random.choice(calc_aggregate_all_j) + sql += "%s as cal18_2 " % random.choice(calc_aggregate_all_j) + sql += " from table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(q_u_where) + sql += "%s " % random.choice(session_u_where) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(limit_u_where) + sql += ") " + sql += "%s " % random.choice(interval_sliding) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + tdSql.query("select 18-4.2 from table_0;") + for i in range(self.fornum): + sql = "select apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) + sql += "%s as cal18_1 ," % random.choice(calc_aggregate_all_j) + sql += "%s as cal18_2 " % random.choice(calc_aggregate_all_j) + sql += " from table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(q_u_or_where) + sql += "%s " % random.choice(session_u_where) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(limit_u_where) + sql += ") " + sql += "%s " % random.choice(interval_sliding) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + tdSql.query("select 18-5 from table_0;") + for i in range(self.fornum): + sql = "select apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) + sql += "%s as cal18_1 ," % random.choice(calc_aggregate_all) + sql += "%s as cal18_2 " % random.choice(calc_aggregate_all) + sql += " from stable_1 where " + sql += "%s " % random.choice(q_where) + sql += "%s " % random.choice(session_where) + sql += "%s " % random.choice(fill_where) + sql += "%s " % random.choice(order_where) + sql += "%s " % random.choice(limit1_where) + sql += ") " + sql += "%s " % random.choice(interval_sliding) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + tdSql.query("select 18-6 from table_0;") + for i in range(self.fornum): + sql = "select apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) + sql += "%s as cal18_1 ," % random.choice(calc_aggregate_all_j) + sql += "%s as cal18_2 " % random.choice(calc_aggregate_all_j) + sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(t_join_where) + sql += "%s " % random.choice(session_u_where) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(limit_u_where) + sql += ") " + sql += "%s " % random.choice(interval_sliding) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + tdSql.query("select 18-7 from table_0;") + for i in range(self.fornum): + sql = "select apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) + sql += "%s as cal18_1 ," % random.choice(calc_aggregate_all_j) + sql += "%s as cal18_2 " % random.choice(calc_aggregate_all_j) + sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(qt_u_or_where) + sql += "%s " % random.choice(session_u_where) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(limit_u_where) + sql += ") " + sql += "%s " % random.choice(interval_sliding) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + #19 select apercentile from (select calc_aggregate_alls form regualr_table or stable where <\>\in\and\or session order by limit )interval_sliding + dcDB = self.dropandcreateDB(random.randint(1,3)) + tdSql.query("select 19-1 from table_0;") + for i in range(self.fornum): + sql = "select apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) + sql += "%s as cal19_1 ," % random.choice(calc_aggregate_all) + sql += "%s as cal19_2 " % random.choice(calc_aggregate_all) + sql += " from regular_table_1 where " + sql += "%s " % random.choice(q_where) + sql += "%s " % random.choice(state_window) + sql += "%s " % random.choice(order_where) + sql += "%s " % random.choice(limit1_where) + sql += ") " + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + tdSql.query("select 19-2 from table_0;") + #TD-6435 state_window not support join + for i in range(self.fornum): + sql = "select apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) + sql += "%s as cal19_1 ," % random.choice(calc_aggregate_all_j) + sql += "%s as cal19_2 " % random.choice(calc_aggregate_all_j) + sql += " from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(q_u_where) + sql += "%s " % random.choice(state_u_window) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(limit_u_where) + sql += ") " + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + tdSql.query("select 19-2.2 from table_0;") + for i in range(self.fornum): + sql = "select apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) + sql += "%s as cal19_1 ," % random.choice(calc_aggregate_all_j) + sql += "%s as cal19_2 " % random.choice(calc_aggregate_all_j) + sql += " from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(q_u_or_where) + sql += "%s " % random.choice(state_u_window) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(limit_u_where) + sql += ") " + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + dcDB = self.dropandcreateDB(random.randint(1,2)) + tdSql.query("select 19-3 from table_0;") + for i in range(self.fornum): + sql = "select apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) + sql += "%s as cal19_1 ," % random.choice(calc_aggregate_all) + sql += "%s as cal19_2 " % random.choice(calc_aggregate_all) + sql += " from table_1 where " + sql += "%s " % random.choice(q_where) + sql += "%s " % random.choice(state_window) + sql += "%s " % random.choice(order_where) + sql += "%s " % random.choice(limit1_where) + sql += ") " + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + tdSql.query("select 19-4 from table_0;") + for i in range(self.fornum): + sql = "select apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) + sql += "%s as cal19_1 ," % random.choice(calc_aggregate_all_j) + sql += "%s as cal19_2 " % random.choice(calc_aggregate_all_j) + sql += " from table_1 t1, table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(q_u_where) + #sql += "%s " % random.choice(state_window) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(limit_u_where) + sql += ") " + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + tdSql.query("select 19-4.2 from table_0;") + for i in range(self.fornum): + sql = "select apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) + sql += "%s as cal19_1 ," % random.choice(calc_aggregate_all_j) + sql += "%s as cal19_2 " % random.choice(calc_aggregate_all_j) + sql += " from table_1 t1, table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(q_u_or_where) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(limit_u_where) + sql += ") " + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + tdSql.query("select 19-5 from table_0;") + for i in range(self.fornum): + sql = "select apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) + sql += "%s as cal19_1 ," % random.choice(calc_aggregate_all) + sql += "%s as cal19_2 " % random.choice(calc_aggregate_all) + sql += " from stable_1 where " + sql += "%s " % random.choice(q_where) + sql += "%s " % random.choice(state_window) + sql += "%s " % random.choice(order_where) + sql += "%s " % random.choice(limit1_where) + sql += ") " + sql += "%s " % random.choice(interval_sliding) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + dcDB = self.dropandcreateDB(random.randint(1,3)) + tdSql.query("select 19-6 from table_0;") + for i in range(self.fornum): + sql = "select apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) + sql += "%s as cal19_1 ," % random.choice(calc_aggregate_all_j) + sql += "%s as cal19_2 " % random.choice(calc_aggregate_all_j) + sql += " from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(q_u_where) + #sql += "%s " % random.choice(state_window) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(limit_u_where) + sql += ") " + sql += "%s " % random.choice(interval_sliding) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + tdSql.query("select 19-7 from table_0;") + for i in range(self.fornum): + sql = "select apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) + sql += "%s as cal19_1 ," % random.choice(calc_aggregate_all_j) + sql += "%s as cal19_2 " % random.choice(calc_aggregate_all_j) + sql += " from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(qt_u_or_where) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(limit_u_where) + sql += ") " + sql += "%s " % random.choice(interval_sliding) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + #20 select * from (select calc_select_fills form regualr_table or stable where <\>\in\and\or fill_where group by order by limit offset ) + dcDB = self.dropandcreateDB(random.randint(1,2)) + tdSql.query("select 20-1 from table_0;") + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s , " % random.choice(calc_select_fill) + sql += "%s ," % random.choice(calc_select_fill) + sql += "%s " % random.choice(calc_select_fill) + sql += " from stable_1 where " + sql += "%s " % random.choice(interp_where) + sql += "%s " % random.choice(fill_where) + sql += "%s " % random.choice(group_where) + sql += "%s " % random.choice(order_where) + sql += "%s " % random.choice(limit_where) + sql += ") " + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + rsDn = self.restartDnodes() + tdSql.query("select 20-2 from table_0;") + #TD-6438 + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s , " % random.choice(calc_select_fill_j) + sql += "%s ," % random.choice(calc_select_fill_j) + sql += "%s " % random.choice(calc_select_fill_j) + sql += " from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " + sql += "%s and " % random.choice(t_join_where) + sql += "%s " % random.choice(interp_where_j) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(limit_u_where) + sql += ") " + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + tdSql.query("select 20-2.2 from table_0;") + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s , " % random.choice(calc_select_fill_j) + sql += "%s ," % random.choice(calc_select_fill_j) + sql += "%s " % random.choice(calc_select_fill_j) + sql += " from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " + sql += "%s and " % random.choice(qt_u_or_where) + sql += "%s " % random.choice(interp_where_j) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(limit_u_where) + sql += ") " + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + tdSql.query("select 20-3 from table_0;") + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s , " % random.choice(calc_select_fill) + sql += "%s ," % random.choice(calc_select_fill) + sql += "%s " % random.choice(calc_select_fill) + sql += " from table_0 where " + sql += "%s " % interp_where[2] + sql += "%s " % random.choice(fill_where) + sql += "%s " % random.choice(order_where) + sql += "%s " % random.choice(limit_where) + sql += ") " + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + tdSql.query("select 20-4 from table_0;") + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s , " % random.choice(calc_select_fill_j) + sql += "%s ," % random.choice(calc_select_fill_j) + sql += "%s " % random.choice(calc_select_fill_j) + sql += " from table_0 t1, table_1 t2 where t1.ts = t2.ts and " + #sql += "%s and " % random.choice(t_join_where) + sql += "%s " % interp_where_j[random.randint(0,5)] + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(limit_u_where) + sql += ") " + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + tdSql.query("select 20-4.2 from table_0;") + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s , " % random.choice(calc_select_fill_j) + sql += "%s ," % random.choice(calc_select_fill_j) + sql += "%s " % random.choice(calc_select_fill_j) + sql += " from table_0 t1, table_1 t2 where t1.ts = t2.ts and " + sql += "%s and " % random.choice(qt_u_or_where) + sql += "%s " % interp_where_j[random.randint(0,5)] + sql += "%s " % random.choice(fill_where) + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(limit_u_where) + sql += ") " + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + dcDB = self.dropandcreateDB(random.randint(1,2)) + tdSql.query("select 20-5 from table_0;") + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s , " % random.choice(calc_select_fill) + sql += "%s ," % random.choice(calc_select_fill) + sql += "%s " % random.choice(calc_select_fill) + sql += " from regular_table_1 where " + sql += "%s " % interp_where[1] + sql += "%s " % random.choice(fill_where) + sql += "%s " % random.choice(order_where) + sql += "%s " % random.choice(limit_where) + sql += ") " + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + tdSql.query("select 20-6 from table_0;") + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s , " % random.choice(calc_select_fill_j) + sql += "%s ," % random.choice(calc_select_fill_j) + sql += "%s " % random.choice(calc_select_fill_j) + sql += " from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " + #sql += "%s " % random.choice(interp_where_j) + sql += "%s " % interp_where_j[random.randint(0,5)] + sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(limit_u_where) + sql += ") " + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + tdSql.query("select 21-1 from table_0;") + for i in range(self.fornum): + sql = "select avg(res1),min(res2),max(res3) from ( select " + sql += "%s res1, " % random.choice(calc_aggregate_all) + sql += "%s res2," % random.choice(calc_aggregate_all) + sql += "%s res3 " % random.choice(calc_aggregate_all) + sql += " from regular_table_1 t1 " + sql += " where %s " % random.choice(q_where) + sql += " %s ) " % random.choice(interval_sliding) + sql += " where ts >now-10h and ts < now+10h " + sql += "%s " % random.choice(interval_sliding) + sql += "%s " % random.choice(fill_where) + sql += "%s ;" % random.choice(limit_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + tdSql.query("select 21-2 from table_0;") + for i in range(self.fornum): + sql = "select avg(res1),min(res2),max(res3) from ( select " + sql += "%s res1, " % random.choice(calc_aggregate_all) + sql += "%s res2," % random.choice(calc_aggregate_all) + sql += "%s res3 " % random.choice(calc_aggregate_all) + sql += " from table_1 t1 " + sql += " where %s " % random.choice(q_where) + sql += " %s ) " % random.choice(interval_sliding) + sql += " where ts >now-10h and ts < now+10h " + sql += "%s " % random.choice(interval_sliding) + sql += "%s " % random.choice(fill_where) + sql += "%s ;" % random.choice([limit_where[2] , limit_where[3]] ) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + tdSql.query("select 21-3 from table_0;") + for i in range(self.fornum): + sql = "select avg(res1),min(res2),max(res3) from ( select " + sql += "%s res1, " % random.choice(calc_aggregate_all) + sql += "%s res2," % random.choice(calc_aggregate_all) + sql += "%s res3 " % random.choice(calc_aggregate_all) + sql += " from stable_1 t1 " + sql += " where %s " % random.choice(q_where) + sql += " %s ) " % random.choice(interval_sliding) + sql += " where ts >now-10h and ts < now+10h " + sql += "%s " % random.choice(interval_sliding) + sql += "%s " % random.choice(fill_where) + sql += "%s ;" % random.choice(limit_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + tdSql.query("select 21-4 from table_0;") + for i in range(self.fornum): + sql = "select avg(res1),min(res2),max(res3) from ( select " + sql += "%s res1, " % random.choice(calc_aggregate_all) + sql += "%s res2," % random.choice(calc_aggregate_all) + sql += "%s res3 " % random.choice(calc_aggregate_all) + sql += " from regular_table_1 t1 " + sql += " where %s " % random.choice(q_where) + sql += " %s ) " % random.choice(interval_sliding) + sql += "group by ts " + sql += "%s ;" % random.choice(limit_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + tdSql.query("select 21-5 from table_0;") + for i in range(self.fornum): + sql = "select avg(res1),min(res2),max(res3) from ( select " + sql += "%s res1, " % random.choice(calc_aggregate_all) + sql += "%s res2," % random.choice(calc_aggregate_all) + sql += "%s res3 " % random.choice(calc_aggregate_all) + sql += " from table_1 t1 " + sql += " where %s " % random.choice(q_where) + sql += " %s ) " % random.choice(interval_sliding) + sql += "group by ts " + sql += "%s ;" % random.choice([limit_where[2] , limit_where[3]] ) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + tdSql.query("select 21-6 from table_0;") + for i in range(self.fornum): + sql = "select avg(res1),min(res2),max(res3) from ( select " + sql += "%s res1, " % random.choice(calc_aggregate_all) + sql += "%s res2," % random.choice(calc_aggregate_all) + sql += "%s res3 " % random.choice(calc_aggregate_all) + sql += " from stable_1 t1 " + sql += " where %s " % random.choice(q_where) + sql += " %s ) " % random.choice(interval_sliding) + sql += "group by ts " + sql += "%s ;" % random.choice(limit_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + tdSql.query("select 21-7 from table_0;") + for i in range(self.fornum): + sql = "select avg(res1),min(res2),max(res3) from ( select " + sql += "%s res1, " % random.choice(calc_aggregate_all) + sql += "%s res2," % random.choice(calc_aggregate_all) + sql += "%s res3 " % random.choice(calc_aggregate_all) + sql += " from stable_1 t1 " + sql += " where %s " % random.choice(q_where) + sql += " %s " % random.choice(interval_sliding) + sql += " %s ) " % random.choice(group_where) + sql += "group by ts " + sql += "%s ;" % random.choice(limit_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + + # error + #1 select * from (select * from (select * form regular_table where <\>\in\and\or order by limit )) + tdSql.query("select 1-1 from table_1;") + for i in range(self.fornum): + sql = "select * , ts from ( select * from ( select " + sql += "%s, " % random.choice(s_r_select) + sql += "%s, " % random.choice(q_select) + sql += "ts from regular_table_1 where " + sql += "%s " % random.choice(q_where) + sql += ")) ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + #2 select * from (select * from (select * form stable where <\>\in\and\or order by limit )) + tdSql.query("select 2-1 from table_1;") + for i in range(self.fornum): + sql = "select * , ts from ( select * from ( select " + sql += "%s, " % random.choice(s_s_select) + sql += "%s, " % random.choice(qt_select) + sql += "ts from stable_1 where " + sql += "%s " % random.choice(q_where) + sql += ")) ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + #3 select ts ,calc from (select * form stable where <\>\in\and\or order by limit ) + dcDB = self.dropandcreateDB(random.randint(1,2)) + tdSql.query("select 3-1 from table_1;") + for i in range(self.fornum): + sql = "select ts , " + sql += "%s " % random.choice(calc_calculate_regular) + sql += " from ( select * from stable_1 where " + sql += "%s " % random.choice(qt_where) + sql += "%s " % random.choice(orders_desc_where) + sql += "%s " % random.choice(limit_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + # ts not in in select #TD-5955#TD-6192 + #4 select * from (select calc form stable where <\>\in\and\or order by limit ) + tdSql.query("select 4-1 from table_1;") + for i in range(self.fornum): + sql = "select * from ( select " + sql += "%s " % random.choice(calc_select_in_ts) + sql += "from stable_1 where " + sql += "%s " % random.choice(qt_where) + sql += "%s " % random.choice(order_desc_where) + sql += "%s " % random.choice(limit_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + + #5 select ts ,tbname from (select * form stable where <\>\in\and\or order by limit ) + tdSql.query("select 5-1 from table_1;") + for i in range(self.fornum): + sql = "select ts , tbname , " + sql += "%s ," % random.choice(calc_calculate_regular) + sql += "%s ," % random.choice(dqt_select) + sql += "%s " % random.choice(qt_select) + sql += " from ( select * from stable_1 where " + sql += "%s " % random.choice(qt_where) + sql += "%s " % random.choice(orders_desc_where) + sql += "%s " % random.choice(limit_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + + #special sql + tdSql.query("select 6-1 from table_1;") + for i in range(self.fornum): + sql = "select * from ( select _block_dist() from stable_1);" + tdSql.query(sql) + tdSql.checkRows(1) + sql = "select _block_dist() from (select * from stable_1);" + tdSql.error(sql) + sql = "select * from (select database());" + tdSql.error(sql) + sql = "select * from (select client_version());" + tdSql.error(sql) + sql = "select * from (select client_version() as version);" + tdSql.error(sql) + sql = "select * from (select server_version());" + tdSql.error(sql) + sql = "select * from (select server_version() as version);" + tdSql.error(sql) + sql = "select * from (select server_status());" + tdSql.error(sql) + sql = "select * from (select server_status() as status);" + tdSql.error(sql) + + #4096 + + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + + # regualr-table + os.system("%staosdemo -N -d regular -t 2 -n 1000 -l 4095 -y" % binPath) + tdSql.execute("use regular") + tdSql.query("select * from d0;") + tdSql.checkCols(4096) + tdSql.query("describe d0;") + tdSql.checkRows(4096) + tdSql.query("select * from (select * from d0);") + tdSql.checkCols(4096) + + # select * from (select 4096 columns form d0) + sql = "select * from ( select ts , " + for i in range(4094): + sql += "c%d , " % (i) + sql += "c4094 from d0 " + sql += " %s )" % random.choice(order_where) + sql += " %s ;" % random.choice(order_desc_where) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkCols(4096) + tdSql.checkRows(1000) + + # select 4096 columns from (select * form d0) + sql = "select ts, " + for i in range(4094): + sql += "c%d , " % (i) + sql += " c4094 from ( select * from d0 " + sql += " %s )" % random.choice(order_where) + sql += " %s ;" % random.choice(order_desc_where) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkCols(4096) + tdSql.checkRows(1000) + + # select 4096 columns from (select * form d0,d1 where d0.ts=d1.ts) + sql = "select ts, " + for i in range(4094): + sql += "c%d , " % (i) + sql += " c4094 from ( select t1.* from d0 t1,d1 t2 where t1.ts=t2.ts " + sql += " %s ) ;" % random.choice(order_u_where) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkCols(4096) + tdSql.checkRows(1000) + + # select 4096 columns from (select 4096 columns form d0) + rsDn = self.restartDnodes() + sql = "select ts, " + for i in range(4094): + sql += "c%d , " % (i) + sql += " c4094 from ( select ts , " + for i in range(4094): + sql += "c%d , " % (i) + sql += "c4094 from d0 " + sql += " %s )" % random.choice(order_where) + sql += " %s ;" % random.choice(order_desc_where) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkCols(4096) + tdSql.checkRows(1000) + + #stable + os.system("%staosdemo -d super -t 2 -n 1000 -l 4093 -y" % binPath) + tdSql.execute("use super") + tdSql.query("select * from meters;") + tdSql.checkCols(4096) + tdSql.query("select * from d0;") + tdSql.checkCols(4094) + tdSql.query("describe meters;") + tdSql.checkRows(4096) + tdSql.query("describe d0;") + tdSql.checkRows(4096) + tdSql.query("select * from (select * from d0);") + tdSql.checkCols(4094) + tdSql.query("select * from (select * from meters);") + tdSql.checkCols(4096) + + # select * from (select 4096 columns form d0) + sql = "select * from ( select ts , " + for i in range(4093): + sql += "c%d , " % (i) + sql += "t0 , t1 from d0 " + sql += " %s )" % random.choice(order_where) + sql += " %s ;" % random.choice(order_desc_where) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkCols(4096) + tdSql.checkRows(1000) + + sql = "select * from ( select ts , " + for i in range(4093): + sql += "c%d , " % (i) + sql += "t0 , t1 from meters " + sql += " %s )" % random.choice(order_where) + sql += " %s ;" % random.choice(order_desc_where) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkCols(4096) + tdSql.checkRows(2000) + + # select 4096 columns from (select * , t0, t1 form d0) + sql = "select ts, " + for i in range(4093): + sql += "c%d , " % (i) + sql += " t0 , t1 from ( select * , t0, t1 from d0 ); " + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkCols(4096) + tdSql.checkRows(1000) + + sql = "select ts, " + for i in range(4093): + sql += "c%d , " % (i) + sql += " t0 , t1 from ( select * from meters " + sql += " %s )" % random.choice(order_where) + sql += " %s ;" % random.choice(order_desc_where) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkCols(4096) + tdSql.checkRows(2000) + + # select 4096 columns from (select d0.*, d0.t0, d0.t1 form d0,d1 where d0.ts=d1.ts) + sql = "select ts, " + for i in range(4093): + sql += "c%d , " % (i) + sql += " t0 , t1 from ( select d1.* , d1.t0, d1.t1 from d0 , d1 where d0.ts = d1.ts ); " + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkCols(4096) + tdSql.checkRows(1000) + + # select 4096 columns from (select 4096 columns form d0) + rsDn = self.restartDnodes() + sql = "select ts, " + for i in range(4093): + sql += "c%d , " % (i) + sql += " t0 ,t1 from ( select ts , " + for i in range(4093): + sql += "c%d , " % (i) + sql += "t0 ,t1 from d0 );" + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkCols(4096) + tdSql.checkRows(1000) + sql = "select ts, " + for i in range(4093): + sql += "c%d , " % (i) + sql += " t0 ,t1 from ( select ts , " + for i in range(4093): + sql += "c%d , " % (i) + sql += "t0 ,t1 from meters " + sql += " %s )" % random.choice(order_where) + sql += " %s ;" % random.choice(order_desc_where) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkCols(4096) + tdSql.checkRows(2000) + + + + endTime = time.time() + print("total time %ds" % (endTime - startTime)) + + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/query/nestedQuery/nestedQueryJson.py b/tests/pytest/query/nestedQuery/nestedQueryJson.py new file mode 100644 index 0000000000000000000000000000000000000000..36a231a9165a15cb46cbc0c1d37152f90e54b03e --- /dev/null +++ b/tests/pytest/query/nestedQuery/nestedQueryJson.py @@ -0,0 +1,81 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def run(self): + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + + # insert: create one or mutiple tables per sql and insert multiple rows per sql + os.system("%staosdemo -f query/nestedQuery/insertData.json -y " % binPath) + tdSql.execute("use db") + tdSql.query("select count (tbname) from stb0") + tdSql.checkData(0, 0, 1000) + tdSql.query("select count (tbname) from stb1") + tdSql.checkData(0, 0, 1000) + tdSql.query("select count(*) from stb00_0") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 100000) + tdSql.query("select count(*) from stb01_1") + tdSql.checkData(0, 0, 200) + tdSql.query("select count(*) from stb1") + tdSql.checkData(0, 0, 200000) + + + + testcaseFilename = os.path.split(__file__)[-1] + os.system("rm -rf ./insert_res.txt") + os.system("rm -rf query/nestedQuery/%s.sql" % testcaseFilename ) + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/nestedQuery/nestedQuery_datacheck.py b/tests/pytest/query/nestedQuery/nestedQuery_datacheck.py new file mode 100755 index 0000000000000000000000000000000000000000..308bf4f9e69828bf80728e320247a03303c7121e --- /dev/null +++ b/tests/pytest/query/nestedQuery/nestedQuery_datacheck.py @@ -0,0 +1,637 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import random +import string +import os +import sys +import time +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +from util.dnodes import tdDnodes +from util.dnodes import * + +class TDTestCase: + updatecfgDict={'maxSQLLength':1048576} + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + os.system("rm -rf query/nestedQuery/nestedQuery_datacheck.py.sql") + now = time.time() + self.ts = 1630000000000 + self.num = 100 + self.fornum = 3 + + def get_random_string(self, length): + letters = string.ascii_lowercase + result_str = ''.join(random.choice(letters) for i in range(length)) + return result_str + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def restartDnodes(self): + tdDnodes.stop(1) + tdDnodes.start(1) + + def dropandcreateDB(self,n): + for i in range(n): + tdSql.execute('''drop database if exists db ;''') + tdSql.execute('''create database db keep 36500;''') + tdSql.execute('''use db;''') + + tdSql.execute('''create stable stable_1 + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint, + q_bool bool , q_binary binary(20) , q_nchar nchar(20) ,q_float float , q_double double , q_ts timestamp) + tags(loc nchar(20) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, + t_bool bool , t_binary binary(20) , t_nchar nchar(20) ,t_float float , t_double double , t_ts timestamp);''') + tdSql.execute('''create stable stable_2 + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint, + q_bool bool , q_binary binary(20) , q_nchar nchar(20) ,q_float float , q_double double , q_ts timestamp) + tags(loc nchar(20) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, + t_bool bool , t_binary binary(20) , t_nchar nchar(20) ,t_float float , t_double double , t_ts timestamp);''') + + + tdSql.execute('''create table table_0 using stable_1 + tags('table_0' , '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0')''') + tdSql.execute('''create table table_1 using stable_1 + tags('table_1' , '2147483647' , '9223372036854775807' , '32767' , '127' , 1 , + 'binary1' , 'nchar1' , '1' , '11' , \'1999-09-09 09:09:09.090\')''') + tdSql.execute('''create table table_2 using stable_1 + tags('table_2' , '-2147483647' , '-9223372036854775807' , '-32767' , '-127' , false , + 'binary2' , 'nchar2nchar2' , '-2.2' , '-22.22' , \'2099-09-09 09:09:09.090\')''') + tdSql.execute('''create table table_21 using stable_2 + tags('table_21' , '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0')''') + + #regular table + tdSql.execute('''create table regular_table_1 + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint, + q_bool bool , q_binary binary(20) , q_nchar nchar(20) ,q_float float , q_double double , q_ts timestamp) ;''') + tdSql.execute('''create table regular_table_2 + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint, + q_bool bool , q_binary binary(20) , q_nchar nchar(20) ,q_float float , q_double double , q_ts timestamp) ;''') + + + for i in range(self.num): + tdSql.execute('''insert into table_0 values(%d, %d, %d, %d, %d, 0, 'binary.%s', 'nchar.%s', %f, %f, %d)''' + % (self.ts + i*10000000, i, i, i, i, i, i, i, i, self.ts + i)) + tdSql.execute('''insert into table_1 values(%d, %d, %d, %d, %d, 1, 'binary1.%s', 'nchar1.%s', %f, %f, %d)''' + % (self.ts + i*10000000+1, 2147483647-i, 9223372036854775807-i, 32767-i, 127-i, + i, i, i, i, 1262304000001 + i)) + tdSql.execute('''insert into table_2 values(%d, %d, %d, %d, %d, true, 'binary2.%s', 'nchar2nchar2.%s', %f, %f, %d)''' + % (self.ts + i*10000000+2, -2147483647+i, -9223372036854775807+i, -32767+i, -127+i, + i, i, -i, -i, 1577836800001 + i)) + + tdSql.execute('''insert into table_21 values(%d, %d, %d, %d, %d, 0, 'binary.%s', 'nchar.%s', %f, %f, %d)''' + % (self.ts + i*10000000, i, i, i, i, i, i, i, i, self.ts + i)) + + tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, 0, 'binary.%s', 'nchar.%s', %f, %f, %d)''' + % (self.ts + i*10000000, i, i, i, i, i, i, i, i, self.ts + i)) + + tdSql.execute('''insert into regular_table_2 values(%d, %d, %d, %d, %d, 1, 'binary1.%s', 'nchar1.%s', %f, %f, %d)''' + % (self.ts + i*10000000 , 2147483647-i, 9223372036854775807-i, 32767-i, 127-i, + i, i, i, i, 1262304000001 + i)) + tdSql.execute('''insert into regular_table_2 values(%d, %d, %d, %d, %d, true, 'binary2.%s', 'nchar2nchar2.%s', %f, %f, %d)''' + % (self.ts + i*10000000 +2, -2147483647+i, -9223372036854775807+i, -32767+i, -127+i, + i, i, -i, -i, 1577836800001 + i)) + + def regular1_checkall_0(self,sql): + tdLog.info(sql) + tdSql.query(sql) + tdSql.checkData(0,0,'2021-08-27 01:46:40.000') + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + tdSql.checkData(0,4,0) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary.0') + tdSql.checkData(0,7,'nchar.0') + tdSql.checkData(0,8,0) + tdSql.checkData(0,9,0) + tdSql.checkData(0,10,'2021-08-27 01:46:40.000') + + def regular1_checkall_100(self,sql): + tdLog.info(sql) + tdSql.query(sql) + tdSql.checkData(99,0,'2021-09-07 12:46:40.000') + tdSql.checkData(99,1,99) + tdSql.checkData(99,2,99) + tdSql.checkData(99,3,99) + tdSql.checkData(99,4,99) + tdSql.checkData(99,5,'False') + tdSql.checkData(99,6,'binary.99') + tdSql.checkData(99,7,'nchar.99') + tdSql.checkData(99,8,99) + tdSql.checkData(99,9,99) + tdSql.checkData(99,10,'2021-08-27 01:46:40.099') + + def regular_join_checkall_0(self,sql): + self.regular1_checkall_0(sql) + tdSql.checkData(0,11,'2021-08-27 01:46:40.000') + tdSql.checkData(0,12,2147483647) + tdSql.checkData(0,13,9223372036854775807) + tdSql.checkData(0,14,32767) + tdSql.checkData(0,15,127) + tdSql.checkData(0,16,'True') + tdSql.checkData(0,17,'binary1.0') + tdSql.checkData(0,18,'nchar1.0') + tdSql.checkData(0,19,0) + tdSql.checkData(0,20,0) + tdSql.checkData(0,21,'2010-01-01 08:00:00.001') + + def regular_join_checkall_100(self,sql): + self.regular1_checkall_100(sql) + tdSql.checkData(99,11,'2021-09-07 12:46:40.000') + tdSql.checkData(99,12,2147483548) + tdSql.checkData(99,13,9223372036854775708) + tdSql.checkData(99,14,32668) + tdSql.checkData(99,15,28) + tdSql.checkData(99,16,'True') + tdSql.checkData(99,17,'binary1.99') + tdSql.checkData(99,18,'nchar1.99') + tdSql.checkData(99,19,99) + tdSql.checkData(99,20,99) + tdSql.checkData(99,21,'2010-01-01 08:00:00.100') + + def stable1_checkall_0(self,sql): + self.regular1_checkall_0(sql) + + def stable1_checkall_300(self,sql): + tdLog.info(sql) + tdSql.query(sql) + tdSql.checkData(299,0,'2021-09-07 12:46:40.002') + tdSql.checkData(299,1,-2147483548) + tdSql.checkData(299,2,-9223372036854775708) + tdSql.checkData(299,3,-32668) + tdSql.checkData(299,4,-28) + tdSql.checkData(299,5,'True') + tdSql.checkData(299,6,'binary2.99') + tdSql.checkData(299,7,'nchar2nchar2.99') + tdSql.checkData(299,8,-99) + tdSql.checkData(299,9,-99) + tdSql.checkData(299,10,'2010-01-01 08:00:00.100') + + def stable_join_checkall_0(self,sql): + self.regular1_checkall_0(sql) + tdSql.checkData(0,22,'2021-08-27 01:46:40.000') + tdSql.checkData(0,23,0) + tdSql.checkData(0,24,0) + tdSql.checkData(0,25,0) + tdSql.checkData(0,26,0) + tdSql.checkData(0,27,'False') + tdSql.checkData(0,28,'binary.0') + tdSql.checkData(0,29,'nchar.0') + tdSql.checkData(0,30,0) + tdSql.checkData(0,31,0) + tdSql.checkData(0,32,'2021-08-27 01:46:40.000') + + def stable_join_checkall_100(self,sql): + tdSql.checkData(99,0,'2021-09-07 12:46:40.000') + tdSql.checkData(99,1,99) + tdSql.checkData(99,2,99) + tdSql.checkData(99,3,99) + tdSql.checkData(99,4,99) + tdSql.checkData(99,5,'False') + tdSql.checkData(99,6,'binary.99') + tdSql.checkData(99,7,'nchar.99') + tdSql.checkData(99,8,99) + tdSql.checkData(99,9,99) + tdSql.checkData(99,10,'2021-08-27 01:46:40.099') + tdSql.checkData(99,22,'2021-09-07 12:46:40.000') + tdSql.checkData(99,23,99) + tdSql.checkData(99,24,99) + tdSql.checkData(99,25,99) + tdSql.checkData(99,26,99) + tdSql.checkData(99,27,'False') + tdSql.checkData(99,28,'binary.99') + tdSql.checkData(99,29,'nchar.99') + tdSql.checkData(99,30,99) + tdSql.checkData(99,31,99) + tdSql.checkData(99,32,'2021-08-27 01:46:40.099') + + + def run(self): + tdSql.prepare() + # test case for https://jira.taosdata.com:18080/browse/TD-5665 + os.system("rm -rf nestedQuery.py.sql") + startTime = time.time() + + dcDB = self.dropandcreateDB(1) + + # regular column select + q_select= ['ts' , '*' , 'q_int', 'q_bigint' , 'q_bigint' , 'q_smallint' , 'q_tinyint' , 'q_bool' , 'q_binary' , 'q_nchar' ,'q_float' , 'q_double' ,'q_ts '] + + # tag column select + t_select= ['*' , 'loc' ,'t_int', 't_bigint' , 't_bigint' , 't_smallint' , 't_tinyint' , 't_bool' , 't_binary' , 't_nchar' ,'t_float' , 't_double' ,'t_ts '] + + # regular and tag column select + qt_select= q_select + t_select + + # distinct regular column select + dq_select= ['distinct q_int', 'distinct q_bigint' , 'distinct q_smallint' , 'distinct q_tinyint' , + 'distinct q_bool' , 'distinct q_binary' , 'distinct q_nchar' ,'distinct q_float' , 'distinct q_double' ,'distinct q_ts '] + + # distinct tag column select + dt_select= ['distinct loc', 'distinct t_int', 'distinct t_bigint' , 'distinct t_smallint' , 'distinct t_tinyint' , + 'distinct t_bool' , 'distinct t_binary' , 'distinct t_nchar' ,'distinct t_float' , 'distinct t_double' ,'distinct t_ts '] + + # distinct regular and tag column select + dqt_select= dq_select + dt_select + + # special column select + s_r_select= ['_c0', '_C0' ] + s_s_select= ['tbname' , '_c0', '_C0' ] + + # regular column where + q_where = ['ts < now +1s','q_bigint >= -9223372036854775807 and q_bigint <= 9223372036854775807', 'q_int <= 2147483647 and q_int >= -2147483647', + 'q_smallint >= -32767 and q_smallint <= 32767','q_tinyint >= -127 and q_tinyint <= 127','q_float >= -100000 and q_float <= 100000', + 'q_double >= -1000000000 and q_double <= 1000000000', 'q_binary like \'binary%\' or q_binary = \'0\' ' , 'q_nchar like \'nchar%\' or q_nchar = \'0\' ' , + 'q_bool = true or q_bool = false' , 'q_bool in (0 , 1)' , 'q_bool in ( true , false)' , 'q_bool = 0 or q_bool = 1', + 'q_bigint between -9223372036854775807 and 9223372036854775807',' q_int between -2147483647 and 2147483647','q_smallint between -32767 and 32767', + 'q_tinyint between -127 and 127 ','q_float between -100000 and 100000','q_double between -1000000000 and 1000000000'] + #TD-6201 ,'q_bool between 0 and 1' + + # regular column where for test union,join + q_u_where = ['t1.ts < now +1s' , 't2.ts < now +1s','t1.q_bigint >= -9223372036854775807 and t1.q_bigint <= 9223372036854775807 and t2.q_bigint >= -9223372036854775807 and t2.q_bigint <= 9223372036854775807', + 't1.q_int <= 2147483647 and t1.q_int >= -2147483647 and t2.q_int <= 2147483647 and t2.q_int >= -2147483647', + 't1.q_smallint >= -32767 and t1.q_smallint <= 32767 and t2.q_smallint >= -32767 and t2.q_smallint <= 32767', + 't1.q_tinyint >= -127 and t1.q_tinyint <= 127 and t2.q_tinyint >= -127 and t2.q_tinyint <= 127', + 't1.q_float >= -100000 and t1.q_float <= 100000 and t2.q_float >= -100000 and t2.q_float <= 100000', + 't1.q_double >= -1000000000 and t1.q_double <= 1000000000 and t2.q_double >= -1000000000 and t2.q_double <= 1000000000', + 't1.q_binary like \'binary%\' and t2.q_binary like \'binary%\' ' , + 't1.q_nchar like \'nchar%\' and t2.q_nchar like \'nchar%\' ' , + 't1.q_bool in (0 , 1) and t2.q_bool in (0 , 1)' , 't1.q_bool in ( true , false) and t2.q_bool in ( true , false)' , + 't1.q_bigint between -9223372036854775807 and 9223372036854775807 and t2.q_bigint between -9223372036854775807 and 9223372036854775807', + 't1.q_int between -2147483647 and 2147483647 and t2.q_int between -2147483647 and 2147483647', + 't1.q_smallint between -32767 and 32767 and t2.q_smallint between -32767 and 32767', + 't1.q_tinyint between -127 and 127 and t2.q_tinyint between -127 and 127 ','t1.q_float between -100000 and 100000 and t2.q_float between -100000 and 100000', + 't1.q_double between -1000000000 and 1000000000 and t2.q_double between -1000000000 and 1000000000'] + #TD-6201 ,'t1.q_bool between 0 and 1 or t2.q_bool between 0 and 1'] + #'t1.q_bool = true and t1.q_bool = false and t2.q_bool = true and t2.q_bool = false' , 't1.q_bool = 0 and t1.q_bool = 1 and t2.q_bool = 0 and t2.q_bool = 1' , + + q_u_or_where = ['t1.q_binary like \'binary%\' or t1.q_binary = \'0\' or t2.q_binary like \'binary%\' or t2.q_binary = \'0\' ' , + 't1.q_nchar like \'nchar%\' or t1.q_nchar = \'0\' or t2.q_nchar like \'nchar%\' or t2.q_nchar = \'0\' ' , 't1.q_bool = true or t1.q_bool = false or t2.q_bool = true or t2.q_bool = false' , + 't1.q_bool in (0 , 1) or t2.q_bool in (0 , 1)' , 't1.q_bool in ( true , false) or t2.q_bool in ( true , false)' , 't1.q_bool = 0 or t1.q_bool = 1 or t2.q_bool = 0 or t2.q_bool = 1' , + 't1.q_bigint between -9223372036854775807 and 9223372036854775807 or t2.q_bigint between -9223372036854775807 and 9223372036854775807', + 't1.q_int between -2147483647 and 2147483647 or t2.q_int between -2147483647 and 2147483647', + 't1.q_smallint between -32767 and 32767 or t2.q_smallint between -32767 and 32767', + 't1.q_tinyint between -127 and 127 or t2.q_tinyint between -127 and 127 ','t1.q_float between -100000 and 100000 or t2.q_float between -100000 and 100000', + 't1.q_double between -1000000000 and 1000000000 or t2.q_double between -1000000000 and 1000000000'] + + # tag column where + t_where = ['ts < now +1s','t_bigint >= -9223372036854775807 and t_bigint <= 9223372036854775807','t_int <= 2147483647 and t_int >= -2147483647', + 't_smallint >= -32767 and t_smallint <= 32767','q_tinyint >= -127 and t_tinyint <= 127','t_float >= -100000 and t_float <= 100000', + 't_double >= -1000000000 and t_double <= 1000000000', 't_binary like \'binary%\' or t_binary = \'0\' ' , 't_nchar like \'nchar%\' or t_nchar = \'0\'' , + 't_bool = true or t_bool = false' , 't_bool in (0 , 1)' , 't_bool in ( true , false)' , 't_bool = 0 or t_bool = 1', + 't_bigint between -9223372036854775807 and 9223372036854775807',' t_int between -2147483647 and 2147483647','t_smallint between -32767 and 32767', + 't_tinyint between -127 and 127 ','t_float between -100000 and 100000','t_double between -1000000000 and 1000000000'] + #TD-6201,'t_bool between 0 and 1' + + # tag column where for test union,join | this is not support + t_u_where = ['t1.ts < now +1s' , 't2.ts < now +1s','t1.t_bigint >= -9223372036854775807 and t1.t_bigint <= 9223372036854775807 and t2.t_bigint >= -9223372036854775807 and t2.t_bigint <= 9223372036854775807', + 't1.t_int <= 2147483647 and t1.t_int >= -2147483647 and t2.t_int <= 2147483647 and t2.t_int >= -2147483647', + 't1.t_smallint >= -32767 and t1.t_smallint <= 32767 and t2.t_smallint >= -32767 and t2.t_smallint <= 32767', + 't1.t_tinyint >= -127 and t1.t_tinyint <= 127 and t2.t_tinyint >= -127 and t2.t_tinyint <= 127', + 't1.t_float >= -100000 and t1.t_float <= 100000 and t2.t_float >= -100000 and t2.t_float <= 100000', + 't1.t_double >= -1000000000 and t1.t_double <= 1000000000 and t2.t_double >= -1000000000 and t2.t_double <= 1000000000', + 't1.t_binary like \'binary%\' or t1.t_binary = \'0\' or t2.t_binary like \'binary%\' or t2.t_binary = \'0\' ' , + 't1.t_nchar like \'nchar%\' or t1.t_nchar = \'0\' or t2.t_nchar like \'nchar%\' or t2.t_nchar = \'0\' ' , 't1.t_bool = true or t1.t_bool = false or t2.t_bool = true or t2.t_bool = false' , + 't1.t_bool in (0 , 1) and t2.t_bool in (0 , 1)' , 't1.t_bool in ( true , false) and t2.t_bool in ( true , false)' , 't1.t_bool = 0 or t1.t_bool = 1 or t2.t_bool = 0 or t2.t_bool = 1', + 't1.t_bigint between -9223372036854775807 and 9223372036854775807 and t2.t_bigint between -9223372036854775807 and 9223372036854775807', + 't1.t_int between -2147483647 and 2147483647 and t2.t_int between -2147483647 and 2147483647', + 't1.t_smallint between -32767 and 32767 and t2.t_smallint between -32767 and 32767', + 't1.t_tinyint between -127 and 127 and t2.t_tinyint between -127 and 127 ','t1.t_float between -100000 and 100000 and t2.t_float between -100000 and 100000', + 't1.t_double between -1000000000 and 1000000000 and t2.t_double between -1000000000 and 1000000000'] + #TD-6201,'t1.t_bool between 0 and 1 or t2.q_bool between 0 and 1'] + + t_u_or_where = ['t1.t_binary like \'binary%\' or t1.t_binary = \'0\' or t2.t_binary like \'binary%\' or t2.t_binary = \'0\' ' , + 't1.t_nchar like \'nchar%\' or t1.t_nchar = \'0\' or t2.t_nchar like \'nchar%\' or t2.t_nchar = \'0\' ' , 't1.t_bool = true or t1.t_bool = false or t2.t_bool = true or t2.t_bool = false' , + 't1.t_bool in (0 , 1) or t2.t_bool in (0 , 1)' , 't1.t_bool in ( true , false) or t2.t_bool in ( true , false)' , 't1.t_bool = 0 or t1.t_bool = 1 or t2.t_bool = 0 or t2.t_bool = 1', + 't1.t_bigint between -9223372036854775807 and 9223372036854775807 or t2.t_bigint between -9223372036854775807 and 9223372036854775807', + 't1.t_int between -2147483647 and 2147483647 or t2.t_int between -2147483647 and 2147483647', + 't1.t_smallint between -32767 and 32767 or t2.t_smallint between -32767 and 32767', + 't1.t_tinyint between -127 and 127 or t2.t_tinyint between -127 and 127 ','t1.t_float between -100000 and 100000 or t2.t_float between -100000 and 100000', + 't1.t_double between -1000000000 and 1000000000 or t2.t_double between -1000000000 and 1000000000'] + + # regular and tag column where + qt_where = q_where + t_where + qt_u_where = q_u_where + t_u_where + # now,qt_u_or_where is not support + qt_u_or_where = q_u_or_where + t_u_or_where + + # tag column where for test super join | this is support , 't1.t_bool = t2.t_bool ' ??? + t_join_where = ['t1.t_bigint = t2.t_bigint ', 't1.t_int = t2.t_int ', 't1.t_smallint = t2.t_smallint ', 't1.t_tinyint = t2.t_tinyint ', + 't1.t_float = t2.t_float ', 't1.t_double = t2.t_double ', 't1.t_binary = t2.t_binary ' , 't1.t_nchar = t2.t_nchar ' ] + + # session && fill + session_where = ['session(ts,10a)' , 'session(ts,10s)', 'session(ts,10m)' , 'session(ts,10h)','session(ts,10d)' , 'session(ts,10w)'] + session_u_where = ['session(t1.ts,10a)' , 'session(t1.ts,10s)', 'session(t1.ts,10m)' , 'session(t1.ts,10h)','session(t1.ts,10d)' , 'session(t1.ts,10w)', + 'session(t2.ts,10a)' , 'session(t2.ts,10s)', 'session(t2.ts,10m)' , 'session(t2.ts,10h)','session(t2.ts,10d)' , 'session(t2.ts,10w)'] + + fill_where = ['FILL(NONE)','FILL(PREV)','FILL(NULL)','FILL(LINEAR)','FILL(NEXT)','FILL(VALUE, 1.23)'] + + state_window = ['STATE_WINDOW(q_tinyint)','STATE_WINDOW(q_bigint)','STATE_WINDOW(q_int)','STATE_WINDOW(q_bool)','STATE_WINDOW(q_smallint)'] + state_u_window = ['STATE_WINDOW(t1.q_tinyint)','STATE_WINDOW(t1.q_bigint)','STATE_WINDOW(t1.q_int)','STATE_WINDOW(t1.q_bool)','STATE_WINDOW(t1.q_smallint)', + 'STATE_WINDOW(t2.q_tinyint)','STATE_WINDOW(t2.q_bigint)','STATE_WINDOW(t2.q_int)','STATE_WINDOW(t2.q_bool)','STATE_WINDOW(t2.q_smallint)'] + + # order by where + order_where = ['order by ts' , 'order by ts asc'] + order_u_where = ['order by t1.ts' , 'order by t1.ts asc' , 'order by t2.ts' , 'order by t2.ts asc'] + order_desc_where = ['order by ts' , 'order by ts asc' , 'order by ts desc' ] + orders_desc_where = ['order by ts' , 'order by ts asc' , 'order by ts desc' , 'order by loc' , 'order by loc asc' , 'order by loc desc'] + + # group by where,not include null-tag + group_where = ['group by tbname , loc' , 'group by tbname', 'group by tbname, t_bigint', 'group by tbname,t_int', 'group by tbname, t_smallint', 'group by tbname,t_tinyint', + 'group by tbname,t_float', 'group by tbname,t_double' , 'group by tbname,t_binary', 'group by tbname,t_nchar', 'group by tbname,t_bool' ,'group by tbname ,loc ,t_bigint', + 'group by tbname,t_binary ,t_nchar ,t_bool' , 'group by tbname,t_int ,t_smallint ,t_tinyint' , 'group by tbname,t_float ,t_double ' ] + having_support = ['having count(q_int) > 0','having count(q_bigint) > 0','having count(q_smallint) > 0','having count(q_tinyint) > 0','having count(q_float) > 0','having count(q_double) > 0','having count(q_bool) > 0', + 'having avg(q_int) > 0','having avg(q_bigint) > 0','having avg(q_smallint) > 0','having avg(q_tinyint) > 0','having avg(q_float) > 0','having avg(q_double) > 0', + 'having sum(q_int) > 0','having sum(q_bigint) > 0','having sum(q_smallint) > 0','having sum(q_tinyint) > 0','having sum(q_float) > 0','having sum(q_double) > 0', + 'having STDDEV(q_int) > 0','having STDDEV(q_bigint) > 0','having STDDEV(q_smallint) > 0','having STDDEV(q_tinyint) > 0','having STDDEV(q_float) > 0','having STDDEV(q_double) > 0', + 'having TWA(q_int) > 0','having TWA(q_bigint) > 0','having TWA(q_smallint) > 0','having TWA(q_tinyint) > 0','having TWA(q_float) > 0','having TWA(q_double) > 0', + 'having IRATE(q_int) > 0','having IRATE(q_bigint) > 0','having IRATE(q_smallint) > 0','having IRATE(q_tinyint) > 0','having IRATE(q_float) > 0','having IRATE(q_double) > 0', + 'having MIN(q_int) > 0','having MIN(q_bigint) > 0','having MIN(q_smallint) > 0','having MIN(q_tinyint) > 0','having MIN(q_float) > 0','having MIN(q_double) > 0', + 'having MAX(q_int) > 0','having MAX(q_bigint) > 0','having MAX(q_smallint) > 0','having MAX(q_tinyint) > 0','having MAX(q_float) > 0','having MAX(q_double) > 0', + 'having FIRST(q_int) > 0','having FIRST(q_bigint) > 0','having FIRST(q_smallint) > 0','having FIRST(q_tinyint) > 0','having FIRST(q_float) > 0','having FIRST(q_double) > 0', + 'having LAST(q_int) > 0','having LAST(q_bigint) > 0','having LAST(q_smallint) > 0','having LAST(q_tinyint) > 0','having LAST(q_float) > 0','having LAST(q_double) > 0', + 'having APERCENTILE(q_int,10) > 0','having APERCENTILE(q_bigint,10) > 0','having APERCENTILE(q_smallint,10) > 0','having APERCENTILE(q_tinyint,10) > 0','having APERCENTILE(q_float,10) > 0','having APERCENTILE(q_double,10) > 0'] + having_not_support = ['having TOP(q_int,10) > 0','having TOP(q_bigint,10) > 0','having TOP(q_smallint,10) > 0','having TOP(q_tinyint,10) > 0','having TOP(q_float,10) > 0','having TOP(q_double,10) > 0','having TOP(q_bool,10) > 0', + 'having BOTTOM(q_int,10) > 0','having BOTTOM(q_bigint,10) > 0','having BOTTOM(q_smallint,10) > 0','having BOTTOM(q_tinyint,10) > 0','having BOTTOM(q_float,10) > 0','having BOTTOM(q_double,10) > 0','having BOTTOM(q_bool,10) > 0', + 'having LEASTSQUARES(q_int) > 0','having LEASTSQUARES(q_bigint) > 0','having LEASTSQUARES(q_smallint) > 0','having LEASTSQUARES(q_tinyint) > 0','having LEASTSQUARES(q_float) > 0','having LEASTSQUARES(q_double) > 0','having LEASTSQUARES(q_bool) > 0', + 'having FIRST(q_bool) > 0','having IRATE(q_bool) > 0','having PERCENTILE(q_bool,10) > 0','having avg(q_bool) > 0','having LAST_ROW(q_bool) > 0','having sum(q_bool) > 0','having STDDEV(q_bool) > 0','having APERCENTILE(q_bool,10) > 0','having TWA(q_bool) > 0','having LAST(q_bool) > 0', + 'having PERCENTILE(q_int,10) > 0','having PERCENTILE(q_bigint,10) > 0','having PERCENTILE(q_smallint,10) > 0','having PERCENTILE(q_tinyint,10) > 0','having PERCENTILE(q_float,10) > 0','having PERCENTILE(q_double,10) > 0'] + having_tagnot_support = ['having LAST_ROW(q_int) > 0','having LAST_ROW(q_bigint) > 0','having LAST_ROW(q_smallint) > 0','having LAST_ROW(q_tinyint) > 0','having LAST_ROW(q_float) > 0','having LAST_ROW(q_double) > 0'] + + # limit offset where + limit_where = ['limit 1 offset 1' , 'limit 1' , 'limit 2 offset 1' , 'limit 2', 'limit 12 offset 1' , 'limit 20', 'limit 20 offset 10' , 'limit 200'] + limit1_where = ['limit 1 offset 1' , 'limit 1' ] + limit_u_where = ['limit 100 offset 10' , 'limit 50' , 'limit 100' , 'limit 10' ] + + # slimit soffset where + slimit_where = ['slimit 1 soffset 1' , 'slimit 1' , 'slimit 2 soffset 1' , 'slimit 2'] + slimit1_where = ['slimit 2 soffset 1' , 'slimit 1' ] + + # aggregate function include [all:count(*)\avg\sum\stddev ||regualr:twa\irate\leastsquares ||group by tbname:twa\irate\] + # select function include [all: min\max\first(*)\last(*)\top\bottom\apercentile\last_row(*)(not with interval)\interp(*)(FILL) ||regualr: percentile] + # calculation function include [all:spread\+-*/ ||regualr:diff\derivative ||group by tbname:diff\derivative\] + # **_ns_** express is not support stable, therefore, separated from regular tables + # calc_select_all calc_select_regular calc_select_in_ts calc_select_fill calc_select_not_interval + # calc_aggregate_all calc_aggregate_regular calc_aggregate_groupbytbname + # calc_calculate_all calc_calculate_regular calc_calculate_groupbytbname + + # calc_select_all calc_select_regular calc_select_in_ts calc_select_fill calc_select_not_interval + # select function include [all: min\max\first(*)\last(*)\top\bottom\apercentile\last_row(*)(not with interval)\interp(*)(FILL) ||regualr: percentile] + + calc_select_all = ['bottom(q_int,20)' , 'bottom(q_bigint,20)' , 'bottom(q_smallint,20)' , 'bottom(q_tinyint,20)' ,'bottom(q_float,20)' , 'bottom(q_double,20)' , + 'top(q_int,20)' , 'top(q_bigint,20)' , 'top(q_smallint,20)' ,'top(q_tinyint,20)' ,'top(q_float,20)' ,'top(q_double,20)' , + 'first(q_int)' , 'first(q_bigint)' , 'first(q_smallint)' , 'first(q_tinyint)' , 'first(q_float)' ,'first(q_double)' ,'first(q_binary)' ,'first(q_nchar)' ,'first(q_bool)' ,'first(q_ts)' , + 'last(q_int)' , 'last(q_bigint)' , 'last(q_smallint)' , 'last(q_tinyint)' , 'last(q_float)' ,'last(q_double)' , 'last(q_binary)' ,'last(q_nchar)' ,'last(q_bool)' ,'last(q_ts)' , + 'min(q_int)' , 'min(q_bigint)' , 'min(q_smallint)' , 'min(q_tinyint)' , 'min(q_float)' ,'min(q_double)' , + 'max(q_int)' , 'max(q_bigint)' , 'max(q_smallint)' , 'max(q_tinyint)' ,'max(q_float)' ,'max(q_double)' , + 'apercentile(q_int,20)' , 'apercentile(q_bigint,20)' ,'apercentile(q_smallint,20)' ,'apercentile(q_tinyint,20)' ,'apercentile(q_float,20)' ,'apercentile(q_double,20)' , + 'last_row(q_int)' , 'last_row(q_bigint)' , 'last_row(q_smallint)' , 'last_row(q_tinyint)' , 'last_row(q_float)' , + 'last_row(q_double)' , 'last_row(q_bool)' ,'last_row(q_binary)' ,'last_row(q_nchar)' ,'last_row(q_ts)'] + + calc_select_in_ts = ['bottom(q_int,20)' , 'bottom(q_bigint,20)' , 'bottom(q_smallint,20)' , 'bottom(q_tinyint,20)' ,'bottom(q_float,20)' , 'bottom(q_double,20)' , + 'top(q_int,20)' , 'top(q_bigint,20)' , 'top(q_smallint,20)' ,'top(q_tinyint,20)' ,'top(q_float,20)' ,'top(q_double,20)' , + 'first(q_int)' , 'first(q_bigint)' , 'first(q_smallint)' , 'first(q_tinyint)' , 'first(q_float)' ,'first(q_double)' ,'first(q_binary)' ,'first(q_nchar)' ,'first(q_bool)' ,'first(q_ts)' , + 'last(q_int)' , 'last(q_bigint)' , 'last(q_smallint)' , 'last(q_tinyint)' , 'last(q_float)' ,'last(q_double)' , 'last(q_binary)' ,'last(q_nchar)' ,'last(q_bool)' ,'last(q_ts)' ] + + calc_select_in = ['min(q_int)' , 'min(q_bigint)' , 'min(q_smallint)' , 'min(q_tinyint)' , 'min(q_float)' ,'min(q_double)' , + 'max(q_int)' , 'max(q_bigint)' , 'max(q_smallint)' , 'max(q_tinyint)' ,'max(q_float)' ,'max(q_double)' , + 'apercentile(q_int,20)' , 'apercentile(q_bigint,20)' ,'apercentile(q_smallint,20)' ,'apercentile(q_tinyint,20)' ,'apercentile(q_float,20)' ,'apercentile(q_double,20)' , + 'last_row(q_int)' , 'last_row(q_bigint)' , 'last_row(q_smallint)' , 'last_row(q_tinyint)' , 'last_row(q_float)' , + 'last_row(q_double)' , 'last_row(q_bool)' ,'last_row(q_binary)' ,'last_row(q_nchar)' ,'last_row(q_ts)'] + + + calc_select_regular = [ 'PERCENTILE(q_int,10)' ,'PERCENTILE(q_bigint,20)' , 'PERCENTILE(q_smallint,30)' ,'PERCENTILE(q_tinyint,40)' ,'PERCENTILE(q_float,50)' ,'PERCENTILE(q_double,60)'] + + + calc_select_fill = ['INTERP(q_bool)' ,'INTERP(q_binary)' ,'INTERP(q_nchar)' ,'INTERP(q_ts)', 'INTERP(q_int)' ,'INTERP(*)' ,'INTERP(q_bigint)' ,'INTERP(q_smallint)' ,'INTERP(q_tinyint)', 'INTERP(q_float)' ,'INTERP(q_double)'] + interp_where = ['ts = now' , 'ts = \'2020-09-13 20:26:40.000\'' , 'ts = \'2020-09-13 20:26:40.009\'' ,'tbname in (\'table_1\') and ts = now' ,'tbname in (\'table_0\' ,\'table_1\',\'table_2\',\'table_3\',\'table_4\',\'table_5\') and ts = \'2020-09-13 20:26:40.000\'','tbname like \'table%\' and ts = \'2020-09-13 20:26:40.002\''] + + #two table join + calc_select_in_ts_j = ['bottom(t1.q_int,20)' , 'bottom(t1.q_bigint,20)' , 'bottom(t1.q_smallint,20)' , 'bottom(t1.q_tinyint,20)' ,'bottom(t1.q_float,20)' , 'bottom(t1.q_double,20)' , + 'top(t1.q_int,20)' , 'top(t1.q_bigint,20)' , 'top(t1.q_smallint,20)' ,'top(t1.q_tinyint,20)' ,'top(t1.q_float,20)' ,'top(t1.q_double,20)' , + 'first(t1.q_int)' , 'first(t1.q_bigint)' , 'first(t1.q_smallint)' , 'first(t1.q_tinyint)' , 'first(t1.q_float)' ,'first(t1.q_double)' ,'first(t1.q_binary)' ,'first(t1.q_nchar)' ,'first(t1.q_bool)' ,'first(t1.q_ts)' , + 'last(t1.q_int)' , 'last(t1.q_bigint)' , 'last(t1.q_smallint)' , 'last(t1.q_tinyint)' , 'last(t1.q_float)' ,'last(t1.q_double)' , 'last(t1.q_binary)' ,'last(t1.q_nchar)' ,'last(t1.q_bool)' ,'last(t1.q_ts)' , + 'bottom(t2.q_int,20)' , 'bottom(t2.q_bigint,20)' , 'bottom(t2.q_smallint,20)' , 'bottom(t2.q_tinyint,20)' ,'bottom(t2.q_float,20)' , 'bottom(t2.q_double,20)' , + 'top(t2.q_int,20)' , 'top(t2.q_bigint,20)' , 'top(t2.q_smallint,20)' ,'top(t2.q_tinyint,20)' ,'top(t2.q_float,20)' ,'top(t2.q_double,20)' , + 'first(t2.q_int)' , 'first(t2.q_bigint)' , 'first(t2.q_smallint)' , 'first(t2.q_tinyint)' , 'first(t2.q_float)' ,'first(t2.q_double)' ,'first(t2.q_binary)' ,'first(t2.q_nchar)' ,'first(t2.q_bool)' ,'first(t2.q_ts)' , + 'last(t2.q_int)' , 'last(t2.q_bigint)' , 'last(t2.q_smallint)' , 'last(t2.q_tinyint)' , 'last(t2.q_float)' ,'last(t2.q_double)' , 'last(t2.q_binary)' ,'last(t2.q_nchar)' ,'last(t2.q_bool)' ,'last(t2.q_ts)'] + + calc_select_in_j = ['min(t1.q_int)' , 'min(t1.q_bigint)' , 'min(t1.q_smallint)' , 'min(t1.q_tinyint)' , 'min(t1.q_float)' ,'min(t1.q_double)' , + 'max(t1.q_int)' , 'max(t1.q_bigint)' , 'max(t1.q_smallint)' , 'max(t1.q_tinyint)' ,'max(t1.q_float)' ,'max(t1.q_double)' , + 'apercentile(t1.q_int,20)' , 'apercentile(t1.q_bigint,20)' ,'apercentile(t1.q_smallint,20)' ,'apercentile(t1.q_tinyint,20)' ,'apercentile(t1.q_float,20)' ,'apercentile(t1.q_double,20)' , + 'last_row(t1.q_int)' , 'last_row(t1.q_bigint)' , 'last_row(t1.q_smallint)' , 'last_row(t1.q_tinyint)' , 'last_row(t1.q_float)' , + 'last_row(t1.q_double)' , 'last_row(t1.q_bool)' ,'last_row(t1.q_binary)' ,'last_row(t1.q_nchar)' ,'last_row(t1.q_ts)' , + 'min(t2.q_int)' , 'min(t2.q_bigint)' , 'min(t2.q_smallint)' , 'min(t2.q_tinyint)' , 'min(t2.q_float)' ,'min(t2.q_double)' , + 'max(t2.q_int)' , 'max(t2.q_bigint)' , 'max(t2.q_smallint)' , 'max(t2.q_tinyint)' ,'max(t2.q_float)' ,'max(t2.q_double)' , + 'apercentile(t2.q_int,20)' , 'apercentile(t2.q_bigint,20)' ,'apercentile(t2.q_smallint,20)' ,'apercentile(t2.q_tinyint,20)' ,'apercentile(t2.q_float,20)' ,'apercentile(t2.q_double,20)' , + 'last_row(t2.q_int)' , 'last_row(t2.q_bigint)' , 'last_row(t2.q_smallint)' , 'last_row(t2.q_tinyint)' , 'last_row(t2.q_float)' , + 'last_row(t2.q_double)' , 'last_row(t2.q_bool)' ,'last_row(t2.q_binary)' ,'last_row(t2.q_nchar)' ,'last_row(t2.q_ts)'] + + calc_select_all_j = calc_select_in_ts_j + calc_select_in_j + + calc_select_regular_j = [ 'PERCENTILE(t1.q_int,10)' ,'PERCENTILE(t1.q_bigint,20)' , 'PERCENTILE(t1.q_smallint,30)' ,'PERCENTILE(t1.q_tinyint,40)' ,'PERCENTILE(t1.q_float,50)' ,'PERCENTILE(t1.q_double,60)' , + 'PERCENTILE(t2.q_int,10)' ,'PERCENTILE(t2.q_bigint,20)' , 'PERCENTILE(t2.q_smallint,30)' ,'PERCENTILE(t2.q_tinyint,40)' ,'PERCENTILE(t2.q_float,50)' ,'PERCENTILE(t2.q_double,60)'] + + + calc_select_fill_j = ['INTERP(t1.q_bool)' ,'INTERP(t1.q_binary)' ,'INTERP(t1.q_nchar)' ,'INTERP(t1.q_ts)', 'INTERP(t1.q_int)' ,'INTERP(t1.*)' ,'INTERP(t1.q_bigint)' ,'INTERP(t1.q_smallint)' ,'INTERP(t1.q_tinyint)', 'INTERP(t1.q_float)' ,'INTERP(t1.q_double)' , + 'INTERP(t2.q_bool)' ,'INTERP(t2.q_binary)' ,'INTERP(t2.q_nchar)' ,'INTERP(t2.q_ts)', 'INTERP(t2.q_int)' ,'INTERP(t2.*)' ,'INTERP(t2.q_bigint)' ,'INTERP(t2.q_smallint)' ,'INTERP(t2.q_tinyint)', 'INTERP(t2.q_float)' ,'INTERP(t2.q_double)'] + interp_where_j = ['t1.ts = now' , 't1.ts = \'2020-09-13 20:26:40.000\'' , 't1.ts = \'2020-09-13 20:26:40.009\'' ,'t2.ts = now' , 't2.ts = \'2020-09-13 20:26:40.000\'' , 't2.ts = \'2020-09-13 20:26:40.009\'' , + 't1.tbname in (\'table_1\') and t1.ts = now' ,'t1.tbname in (\'table_0\' ,\'table_1\',\'table_2\',\'table_3\',\'table_4\',\'table_5\') and t1.ts = \'2020-09-13 20:26:40.000\'','t1.tbname like \'table%\' and t1.ts = \'2020-09-13 20:26:40.002\'', + 't2.tbname in (\'table_1\') and t2.ts = now' ,'t2.tbname in (\'table_0\' ,\'table_1\',\'table_2\',\'table_3\',\'table_4\',\'table_5\') and t2.ts = \'2020-09-13 20:26:40.000\'','t2.tbname like \'table%\' and t2.ts = \'2020-09-13 20:26:40.002\''] + + # calc_aggregate_all calc_aggregate_regular calc_aggregate_groupbytbname APERCENTILE\PERCENTILE + # aggregate function include [all:count(*)\avg\sum\stddev ||regualr:twa\irate\leastsquares ||group by tbname:twa\irate\] + calc_aggregate_all = ['count(*)' , 'count(q_int)' ,'count(q_bigint)' , 'count(q_smallint)' ,'count(q_tinyint)' ,'count(q_float)' , + 'count(q_double)' ,'count(q_binary)' ,'count(q_nchar)' ,'count(q_bool)' ,'count(q_ts)' , + 'avg(q_int)' ,'avg(q_bigint)' , 'avg(q_smallint)' ,'avg(q_tinyint)' ,'avg(q_float)' ,'avg(q_double)' , + 'sum(q_int)' ,'sum(q_bigint)' , 'sum(q_smallint)' ,'sum(q_tinyint)' ,'sum(q_float)' ,'sum(q_double)' , + 'STDDEV(q_int)' ,'STDDEV(q_bigint)' , 'STDDEV(q_smallint)' ,'STDDEV(q_tinyint)' ,'STDDEV(q_float)' ,'STDDEV(q_double)', + 'APERCENTILE(q_int,10)' ,'APERCENTILE(q_bigint,20)' , 'APERCENTILE(q_smallint,30)' ,'APERCENTILE(q_tinyint,40)' ,'APERCENTILE(q_float,50)' ,'APERCENTILE(q_double,60)'] + + calc_aggregate_regular = ['twa(q_int)' ,'twa(q_bigint)' , 'twa(q_smallint)' ,'twa(q_tinyint)' ,'twa (q_float)' ,'twa(q_double)' , + 'IRATE(q_int)' ,'IRATE(q_bigint)' , 'IRATE(q_smallint)' ,'IRATE(q_tinyint)' ,'IRATE (q_float)' ,'IRATE(q_double)' , + 'LEASTSQUARES(q_int,15,3)' , 'LEASTSQUARES(q_bigint,10,1)' , 'LEASTSQUARES(q_smallint,20,3)' ,'LEASTSQUARES(q_tinyint,10,4)' ,'LEASTSQUARES(q_float,6,4)' ,'LEASTSQUARES(q_double,3,1)' , + 'PERCENTILE(q_int,10)' ,'PERCENTILE(q_bigint,20)' , 'PERCENTILE(q_smallint,30)' ,'PERCENTILE(q_tinyint,40)' ,'PERCENTILE(q_float,50)' ,'PERCENTILE(q_double,60)'] + + calc_aggregate_groupbytbname = ['twa(q_int)' ,'twa(q_bigint)' , 'twa(q_smallint)' ,'twa(q_tinyint)' ,'twa (q_float)' ,'twa(q_double)' , + 'IRATE(q_int)' ,'IRATE(q_bigint)' , 'IRATE(q_smallint)' ,'IRATE(q_tinyint)' ,'IRATE (q_float)' ,'IRATE(q_double)' ] + + #two table join + calc_aggregate_all_j = ['count(t1.*)' , 'count(t1.q_int)' ,'count(t1.q_bigint)' , 'count(t1.q_smallint)' ,'count(t1.q_tinyint)' ,'count(t1.q_float)' , + 'count(t1.q_double)' ,'count(t1.q_binary)' ,'count(t1.q_nchar)' ,'count(t1.q_bool)' ,'count(t1.q_ts)' , + 'avg(t1.q_int)' ,'avg(t1.q_bigint)' , 'avg(t1.q_smallint)' ,'avg(t1.q_tinyint)' ,'avg(t1.q_float)' ,'avg(t1.q_double)' , + 'sum(t1.q_int)' ,'sum(t1.q_bigint)' , 'sum(t1.q_smallint)' ,'sum(t1.q_tinyint)' ,'sum(t1.q_float)' ,'sum(t1.q_double)' , + 'STDDEV(t1.q_int)' ,'STDDEV(t1.q_bigint)' , 'STDDEV(t1.q_smallint)' ,'STDDEV(t1.q_tinyint)' ,'STDDEV(t1.q_float)' ,'STDDEV(t1.q_double)', + 'APERCENTILE(t1.q_int,10)' ,'APERCENTILE(t1.q_bigint,20)' , 'APERCENTILE(t1.q_smallint,30)' ,'APERCENTILE(t1.q_tinyint,40)' ,'APERCENTILE(t1.q_float,50)' ,'APERCENTILE(t1.q_double,60)' , + 'count(t2.*)' , 'count(t2.q_int)' ,'count(t2.q_bigint)' , 'count(t2.q_smallint)' ,'count(t2.q_tinyint)' ,'count(t2.q_float)' , + 'count(t2.q_double)' ,'count(t2.q_binary)' ,'count(t2.q_nchar)' ,'count(t2.q_bool)' ,'count(t2.q_ts)' , + 'avg(t2.q_int)' ,'avg(t2.q_bigint)' , 'avg(t2.q_smallint)' ,'avg(t2.q_tinyint)' ,'avg(t2.q_float)' ,'avg(t2.q_double)' , + 'sum(t2.q_int)' ,'sum(t2.q_bigint)' , 'sum(t2.q_smallint)' ,'sum(t2.q_tinyint)' ,'sum(t2.q_float)' ,'sum(t2.q_double)' , + 'STDDEV(t2.q_int)' ,'STDDEV(t2.q_bigint)' , 'STDDEV(t2.q_smallint)' ,'STDDEV(t2.q_tinyint)' ,'STDDEV(t2.q_float)' ,'STDDEV(t2.q_double)', + 'APERCENTILE(t2.q_int,10)' ,'APERCENTILE(t2.q_bigint,20)' , 'APERCENTILE(t2.q_smallint,30)' ,'APERCENTILE(t2.q_tinyint,40)' ,'APERCENTILE(t2.q_float,50)' ,'APERCENTILE(t2.q_double,60)'] + + calc_aggregate_regular_j = ['twa(t1.q_int)' ,'twa(t1.q_bigint)' , 'twa(t1.q_smallint)' ,'twa(t1.q_tinyint)' ,'twa (t1.q_float)' ,'twa(t1.q_double)' , + 'IRATE(t1.q_int)' ,'IRATE(t1.q_bigint)' , 'IRATE(t1.q_smallint)' ,'IRATE(t1.q_tinyint)' ,'IRATE (t1.q_float)' ,'IRATE(t1.q_double)' , + 'LEASTSQUARES(t1.q_int,15,3)' , 'LEASTSQUARES(t1.q_bigint,10,1)' , 'LEASTSQUARES(t1.q_smallint,20,3)' ,'LEASTSQUARES(t1.q_tinyint,10,4)' ,'LEASTSQUARES(t1.q_float,6,4)' ,'LEASTSQUARES(t1.q_double,3,1)' , + 'PERCENTILE(t1.q_int,10)' ,'PERCENTILE(t1.q_bigint,20)' , 'PERCENTILE(t1.q_smallint,30)' ,'PERCENTILE(t1.q_tinyint,40)' ,'PERCENTILE(t1.q_float,50)' ,'PERCENTILE(t1.q_double,60)' , + 'twa(t2.q_int)' ,'twa(t2.q_bigint)' , 'twa(t2.q_smallint)' ,'twa(t2.q_tinyint)' ,'twa (t2.q_float)' ,'twa(t2.q_double)' , + 'IRATE(t2.q_int)' ,'IRATE(t2.q_bigint)' , 'IRATE(t2.q_smallint)' ,'IRATE(t2.q_tinyint)' ,'IRATE (t2.q_float)' ,'IRATE(t2.q_double)', + 'LEASTSQUARES(t2.q_int,15,3)' , 'LEASTSQUARES(t2.q_bigint,10,1)' , 'LEASTSQUARES(t2.q_smallint,20,3)' ,'LEASTSQUARES(t2.q_tinyint,10,4)' ,'LEASTSQUARES(t2.q_float,6,4)' ,'LEASTSQUARES(t2.q_double,3,1)' , + 'PERCENTILE(t2.q_int,10)' ,'PERCENTILE(t2.q_bigint,20)' , 'PERCENTILE(t2.q_smallint,30)' ,'PERCENTILE(t2.q_tinyint,40)' ,'PERCENTILE(t2.q_float,50)' ,'PERCENTILE(t2.q_double,60)'] + + calc_aggregate_groupbytbname_j = ['twa(t1.q_int)' ,'twa(t1.q_bigint)' , 'twa(t1.q_smallint)' ,'twa(t1.q_tinyint)' ,'twa (t1.q_float)' ,'twa(t1.q_double)' , + 'IRATE(t1.q_int)' ,'IRATE(t1.q_bigint)' , 'IRATE(t1.q_smallint)' ,'IRATE(t1.q_tinyint)' ,'IRATE (t1.q_float)' ,'IRATE(t1.q_double)' , + 'twa(t2.q_int)' ,'twa(t2.q_bigint)' , 'twa(t2.q_smallint)' ,'twa(t2.q_tinyint)' ,'twa (t2.q_float)' ,'twa(t2.q_double)' , + 'IRATE(t2.q_int)' ,'IRATE(t2.q_bigint)' , 'IRATE(t2.q_smallint)' ,'IRATE(t2.q_tinyint)' ,'IRATE (t2.q_float)' ,'IRATE(t2.q_double)' ] + + # calc_calculate_all calc_calculate_regular calc_calculate_groupbytbname + # calculation function include [all:spread\+-*/ ||regualr:diff\derivative ||group by tbname:diff\derivative\] + calc_calculate_all = ['SPREAD(ts)' , 'SPREAD(q_ts)' , 'SPREAD(q_int)' ,'SPREAD(q_bigint)' , 'SPREAD(q_smallint)' ,'SPREAD(q_tinyint)' ,'SPREAD(q_float)' ,'SPREAD(q_double)' , + '(SPREAD(q_int) + SPREAD(q_bigint))' , '(SPREAD(q_smallint) - SPREAD(q_float))', '(SPREAD(q_double) * SPREAD(q_tinyint))' , '(SPREAD(q_double) / SPREAD(q_float))'] + calc_calculate_regular = ['DIFF(q_int)' ,'DIFF(q_bigint)' , 'DIFF(q_smallint)' ,'DIFF(q_tinyint)' ,'DIFF(q_float)' ,'DIFF(q_double)' , + 'DERIVATIVE(q_int,15s,0)' , 'DERIVATIVE(q_bigint,10s,1)' , 'DERIVATIVE(q_smallint,20s,0)' ,'DERIVATIVE(q_tinyint,10s,1)' ,'DERIVATIVE(q_float,6s,0)' ,'DERIVATIVE(q_double,3s,1)' ] + calc_calculate_groupbytbname = calc_calculate_regular + + #two table join + calc_calculate_all_j = ['SPREAD(t1.ts)' , 'SPREAD(t1.q_ts)' , 'SPREAD(t1.q_int)' ,'SPREAD(t1.q_bigint)' , 'SPREAD(t1.q_smallint)' ,'SPREAD(t1.q_tinyint)' ,'SPREAD(t1.q_float)' ,'SPREAD(t1.q_double)' , + 'SPREAD(t2.ts)' , 'SPREAD(t2.q_ts)' , 'SPREAD(t2.q_int)' ,'SPREAD(t2.q_bigint)' , 'SPREAD(t2.q_smallint)' ,'SPREAD(t2.q_tinyint)' ,'SPREAD(t2.q_float)' ,'SPREAD(t2.q_double)' , + '(SPREAD(t1.q_int) + SPREAD(t1.q_bigint))' , '(SPREAD(t1.q_tinyint) - SPREAD(t1.q_float))', '(SPREAD(t1.q_double) * SPREAD(t1.q_tinyint))' , '(SPREAD(t1.q_double) / SPREAD(t1.q_tinyint))', + '(SPREAD(t2.q_int) + SPREAD(t2.q_bigint))' , '(SPREAD(t2.q_smallint) - SPREAD(t2.q_float))', '(SPREAD(t2.q_double) * SPREAD(t2.q_tinyint))' , '(SPREAD(t2.q_double) / SPREAD(t2.q_tinyint))', + '(SPREAD(t1.q_int) + SPREAD(t1.q_smallint))' , '(SPREAD(t2.q_smallint) - SPREAD(t2.q_float))', '(SPREAD(t1.q_double) * SPREAD(t1.q_tinyint))' , '(SPREAD(t1.q_double) / SPREAD(t1.q_float))'] + calc_calculate_regular_j = ['DIFF(t1.q_int)' ,'DIFF(t1.q_bigint)' , 'DIFF(t1.q_smallint)' ,'DIFF(t1.q_tinyint)' ,'DIFF(t1.q_float)' ,'DIFF(t1.q_double)' , + 'DERIVATIVE(t1.q_int,15s,0)' , 'DERIVATIVE(t1.q_bigint,10s,1)' , 'DERIVATIVE(t1.q_smallint,20s,0)' ,'DERIVATIVE(t1.q_tinyint,10s,1)' ,'DERIVATIVE(t1.q_float,6s,0)' ,'DERIVATIVE(t1.q_double,3s,1)' , + 'DIFF(t2.q_int)' ,'DIFF(t2.q_bigint)' , 'DIFF(t2.q_smallint)' ,'DIFF(t2.q_tinyint)' ,'DIFF(t2.q_float)' ,'DIFF(t2.q_double)' , + 'DERIVATIVE(t2.q_int,15s,0)' , 'DERIVATIVE(t2.q_bigint,10s,1)' , 'DERIVATIVE(t2.q_smallint,20s,0)' ,'DERIVATIVE(t2.q_tinyint,10s,1)' ,'DERIVATIVE(t2.q_float,6s,0)' ,'DERIVATIVE(t2.q_double,3s,1)' ] + calc_calculate_groupbytbname_j = calc_calculate_regular_j + + + #inter && calc_aggregate_all\calc_aggregate_regular\calc_select_all + interval_sliding = ['interval(4w) sliding(1w) ','interval(1w) sliding(1d) ','interval(1d) sliding(1h) ' , + 'interval(1h) sliding(1m) ','interval(1m) sliding(1s) ','interval(1s) sliding(10a) ', + 'interval(1y) ','interval(1n) ','interval(1w) ','interval(1d) ','interval(1h) ','interval(1m) ','interval(1s) ' ,'interval(10a)', + 'interval(1y,1n) ','interval(1n,1w) ','interval(1w,1d) ','interval(1d,1h) ','interval(1h,1m) ','interval(1m,1s) ','interval(1s,10a) ' ,'interval(100a,30a)'] + + + for i in range(self.fornum): + tdSql.query("select 1-1 from table_0;") + sql = "select count(*) from (select count(*) from stable_1 where ts>= 1620000000000 interval(1d) group by tbname) interval(1d);" + tdLog.info(sql) + tdSql.query(sql) + tdSql.checkData(0,0,'2021-08-27 00:00:00.000') + tdSql.checkData(0,1,3) + tdSql.checkData(1,0,'2021-08-28 00:00:00.000') + tdSql.checkData(1,1,3) + tdSql.checkData(2,0,'2021-08-29 00:00:00.000') + tdSql.checkRows(12) + + #sql = "select * from ( select * from regular_table_1 where q_tinyint >= -127 and q_tinyint <= 127 order by ts );" + tdSql.query("select 1-2 from table_0;") + sql = "select * from ( select * from regular_table_1 where " + sql += "%s );" % random.choice(q_where) + datacheck = self.regular1_checkall_0(sql) + tdSql.checkRows(100) + datacheck = self.regular1_checkall_100(sql) + + #sql = "select * from ( select * from regular_table_1 ) where q_binary like 'binary%' or q_binary = '0' order by ts asc ;" + tdSql.query("select 1-3 from table_0;") + sql = "select * from ( select * from regular_table_1 ) where " + sql += "%s ;" % random.choice(q_where) + datacheck = self.regular1_checkall_0(sql) + tdSql.checkRows(100) + datacheck = self.regular1_checkall_100(sql) + + #sql = select * from ( select * from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and t1.q_double >= -1000000000 and t1.q_double <= 1000000000 and t2.q_double >= -1000000000 and t2.q_double <= 1000000000 order by t2.ts asc );; + tdSql.query("select 1-4 from table_0;") + sql = "select * from ( select * from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s )" % random.choice(q_u_where) + datacheck = self.regular_join_checkall_0(sql) + tdSql.checkRows(100) + datacheck = self.regular_join_checkall_100(sql) + + + + + #sql = "select * from ( select * from stable_1 where q_tinyint >= -127 and q_tinyint <= 127 order by ts );" + tdSql.query("select 2-1 from stable_1;") + sql = "select * from ( select * from stable_1 where " + sql += "%s );" % random.choice(qt_where) + datacheck = self.stable1_checkall_0(sql) + tdSql.checkRows(300) + datacheck = self.stable1_checkall_300(sql) + + #sql = "select * from ( select * from stable_1 ) order by ts asc ;" + tdSql.query("select 2-2 from stable_1;") + sql = "select * from ( select * from stable_1 ) where " + sql += "%s ;" % random.choice(qt_where) + datacheck = self.stable1_checkall_0(sql) + tdSql.checkRows(300) + datacheck = self.stable1_checkall_300(sql) + + #sql = "select * from ( select * from table_0 ) where q_binary like 'binary%' or q_binary = '0' order by ts asc ;" + tdSql.query("select 2-3 from stable_1;") + sql = "select * from ( select * from table_0 ) where " + sql += "%s ;" % random.choice(q_where) + datacheck = self.regular1_checkall_0(sql) + tdSql.checkRows(100) + datacheck = self.regular1_checkall_100(sql) + + #sql = "select * from ( select * from table_0 where q_binary like 'binary%' or q_binary = '0' order by ts asc );" + tdSql.query("select 2-4 from stable_1;") + sql = "select * from ( select * from table_0 where " + sql += "%s );" % random.choice(q_where) + datacheck = self.regular1_checkall_0(sql) + tdSql.checkRows(100) + datacheck = self.regular1_checkall_100(sql) + + #sql = select * from ( select * from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and t1.t_int = t2.t_int ) ;; + tdSql.query("select 2-5 from stable_1;") + sql = "select * from ( select * from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " + sql += "%s )" % random.choice(t_join_where) + datacheck = self.stable_join_checkall_0(sql) + tdSql.checkRows(100) + datacheck = self.stable_join_checkall_100(sql) + + + endTime = time.time() + print("total time %ds" % (endTime - startTime)) + + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/query/nestedQuery/queryInterval.py b/tests/pytest/query/nestedQuery/queryInterval.py new file mode 100644 index 0000000000000000000000000000000000000000..f48e451069c0c2be31132f05246bfb457fd0d58d --- /dev/null +++ b/tests/pytest/query/nestedQuery/queryInterval.py @@ -0,0 +1,116 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +from util.dnodes import tdDnodes +import random + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.ts1 = 1593548685000 + self.ts2 = 1593548785000 + + + def run(self): + # tdSql.execute("drop database db ") + tdSql.prepare() + tdSql.execute("create table st (ts timestamp, num int, value int , t_instance int) tags (loc nchar(30))") + node = 5 + number = 10 + for n in range(node): + for m in range(number): + dt= m*300000+n*60000 # collecting'frequency is 10s + args1=(n,n,self.ts1+dt,n,100+2*m+2*n,10+m+n) + # args2=(n,self.ts2+dt,n,120+n,15+n) + tdSql.execute("insert into t%d using st tags('beijing%d') values(%d, %d, %d, %d)" % args1) + # tdSql.execute("insert into t1 using st tags('shanghai') values(%d, %d, %d, %d)" % args2) + + # interval function + tdSql.query("select avg(value) from st interval(10m)") + # print(tdSql.queryResult) + tdSql.checkRows(6) + tdSql.checkData(0, 0, "2020-07-01 04:20:00") + tdSql.checkData(1, 1, 107.4) + + # subquery with interval + tdSql.query("select avg(avg_val) from(select avg(value) as avg_val from st where loc='beijing0' interval(10m));") + tdSql.checkData(0, 0, 109.0) + + # subquery with interval and select two Column in parent query + tdSql.error("select ts,avg(avg_val) from(select avg(value) as avg_val from st where loc='beijing0' interval(10m));") + + # subquery with interval and sliding + tdSql.query("select avg(value) as avg_val from st where loc='beijing0' interval(8m) sliding(30s) limit 1;") + tdSql.checkData(0, 0, "2020-07-01 04:17:00") + tdSql.checkData(0, 1, 100) + tdSql.query("select avg(avg_val) from(select avg(value) as avg_val from st where loc='beijing1' interval(8m) sliding(30s));") + tdSql.checkData(0, 0, 111) + + # subquery with interval and offset + tdSql.query("select avg(value) as avg_val from st where loc='beijing0' interval(5m,1m);") + tdSql.checkData(0, 0, "2020-07-01 04:21:00") + tdSql.checkData(0, 1, 100) + tdSql.query("select avg(avg_val) from(select avg(value) as avg_val from st where loc='beijing0' interval(5m,1m) group by loc);") + tdSql.checkData(0, 0, 109) + + # subquery with interval,sliding and group by ; parent query with interval + tdSql.query("select avg(value) as avg_val from st where loc='beijing0' interval(8m) sliding(1m) group by loc limit 1 offset 52 ;") + tdSql.checkData(0, 0, "2020-07-01 05:09:00") + tdSql.checkData(0, 1, 118) + tdSql.query("select avg(avg_val) as ncst from(select avg(value) as avg_val from st where loc!='beijing0' interval(8m) sliding(1m) group by loc ) interval(5m);") + tdSql.checkData(1, 1, 105) + + # # subquery and parent query with interval and sliding + tdSql.query("select avg(avg_val) from(select avg(value) as avg_val from st where loc='beijing1' interval(8m) sliding(5m)) interval(10m) sliding(2m);") + tdSql.checkData(29, 0, "2020-07-01 05:10:00.000") + + # subquery and parent query with top and bottom + tdSql.query("select top(avg_val,2) from(select avg(value) as avg_val,num from st where loc!='beijing0' group by num) order by avg_val desc;") + tdSql.checkData(0, 1, 117) + tdSql.query("select bottom(avg_val,3) from(select avg(value) as avg_val,num from st where loc!='beijing0' group by num) order by avg_val asc;") + tdSql.checkData(0, 1, 111) + + # + tdSql.query("select top(avg_val,2) from(select avg(value) as avg_val from st where loc='beijing1' interval(8m) sliding(3m));") + tdSql.checkData(0, 1, 120) + + # TS-802 + tdSql.query("select first(*) from st interval(5m) limit 10") + tdSql.checkRows(10) + + tdSql.query("select * from (select first(*) from st interval(5m) limit 10) order by ts") + tdSql.checkRows(10) + + tdSql.query("select * from (select first(*) from st interval(5m) limit 10) order by ts desc") + tdSql.checkRows(10) + + # clear env + testcaseFilename = os.path.split(__file__)[-1] + os.system("rm -rf ./insert_res.txt") + os.system("rm -rf wal/%s.sql" % testcaseFilename ) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/nestedQuery/queryWithOrderLimit.py b/tests/pytest/query/nestedQuery/queryWithOrderLimit.py new file mode 100644 index 0000000000000000000000000000000000000000..692b5b7d364bee2164bda6707443b29c4cef4d14 --- /dev/null +++ b/tests/pytest/query/nestedQuery/queryWithOrderLimit.py @@ -0,0 +1,87 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +from util.dnodes import tdDnodes +import random + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.ts = 1593548685000 + self.tables = 10 + self.rowsPerTable = 100 + + + def run(self): + # tdSql.execute("drop database db ") + tdSql.prepare() + tdSql.execute("create table st (ts timestamp, num int, value int) tags (loc nchar(30))") + for i in range(self.tables): + for j in range(self.rowsPerTable): + args1=(i, i, self.ts + i * self.rowsPerTable + j * 10000, i, random.randint(1, 100)) + tdSql.execute("insert into t%d using st tags('beijing%d') values(%d, %d, %d)" % args1) + + tdSql.query("select * from (select * from st)") + tdSql.checkRows(self.tables * self.rowsPerTable) + + tdSql.query("select * from (select * from st limit 10)") + tdSql.checkRows(10) + + tdSql.query("select * from (select * from st order by ts desc limit 10)") + tdSql.checkRows(10) + + # bug: https://jira.taosdata.com:18080/browse/TD-5043 + tdSql.query("select * from (select * from st order by ts desc limit 10 offset 1000)") + tdSql.checkRows(0) + + tdSql.query("select avg(value), sum(value) from st group by tbname") + tdSql.checkRows(self.tables) + + tdSql.query("select * from (select avg(value), sum(value) from st group by tbname)") + tdSql.checkRows(self.tables) + + tdSql.query("select avg(value), sum(value) from st group by tbname slimit 5") + tdSql.checkRows(5) + + tdSql.query("select * from (select avg(value), sum(value) from st group by tbname slimit 5)") + tdSql.checkRows(5) + + tdSql.query("select avg(value), sum(value) from st group by tbname slimit 5 soffset 7") + tdSql.checkRows(3) + + tdSql.query("select * from (select avg(value), sum(value) from st group by tbname slimit 5 soffset 7)") + tdSql.checkRows(3) + + # https://jira.taosdata.com:18080/browse/TD-5497 + tdSql.execute("create table tt(ts timestamp ,i int)") + tdSql.execute("insert into tt values(now, 11)(now + 1s, -12)") + tdSql.query("select * from (select max(i),0-min(i) from tt)") + tdSql.checkRows(1); + tdSql.checkData(0, 0, 11); + tdSql.checkData(0, 1, 12.0); + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/nestedQuery/queryWithSpread.py b/tests/pytest/query/nestedQuery/queryWithSpread.py new file mode 100644 index 0000000000000000000000000000000000000000..4e09b1b826f66a06b7ff5789a692173e899e6aa3 --- /dev/null +++ b/tests/pytest/query/nestedQuery/queryWithSpread.py @@ -0,0 +1,46 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdSql.execute('create table stb (ts timestamp, speed int) tags(t1 int);') + + for i in range(10): + tdSql.execute(f'create table tb_{i} using stb tags({i});') + tdSql.execute(f'insert into tb_{i} values(now, 0)') + tdSql.execute(f'insert into tb_{i} values(now+10s, {i})') + + tdSql.query('select max(col3) from (select spread(speed) as col3 from stb group by tbname);') + tdSql.checkData(0,0,'9.0') + tdSql.error('select max(col3) from (select spread(col3) as col3 from stb group by tbname);') + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/nestquery_last_row.py b/tests/pytest/query/nestquery_last_row.py new file mode 100644 index 0000000000000000000000000000000000000000..36431b4e0bd20de4764235c9dc9cb7fae8897681 --- /dev/null +++ b/tests/pytest/query/nestquery_last_row.py @@ -0,0 +1,268 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +import random +import time +import os + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + os.system("rm -rf query/nestquery_last_row.py.sql") + now = time.time() + self.ts = int(round(now * 1000)) + self.num = 10 + + def run(self): + tdSql.prepare() + # test case for https://jira.taosdata.com:18080/browse/TD-4735 + + tdSql.execute('''create stable stable_1 + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint, + q_bool bool , q_binary binary(20) , q_nchar nchar(20) , + q_float float , q_double double , q_ts timestamp) + tags(loc nchar(20) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, + t_bool bool , t_binary binary(20) , t_nchar nchar(20) , + t_float float , t_double double , t_ts timestamp);''') + tdSql.execute('''create table table_0 using stable_1 + tags('table_0' , '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0')''') + tdSql.execute('''create table table_1 using stable_1 + tags('table_1' , '2147483647' , '9223372036854775807' , '32767' , '127' , 1 , + 'binary1' , 'nchar1' , '1' , '11' , \'1999-09-09 09:09:09.090\')''') + tdSql.execute('''create table table_2 using stable_1 + tags('table_2' , '-2147483647' , '-9223372036854775807' , '-32767' , '-127' , false , + 'binary2' , 'nchar2nchar2' , '-2.2' , '-22.22' , \'2099-09-09 09:09:09.090\')''') + tdSql.execute('''create table table_3 using stable_1 + tags('table_3' , '3' , '3' , '3' , '3' , true , 'binary3' , 'nchar3' , '33.33' , '3333.3333' , '0')''') + tdSql.execute('''create table table_4 using stable_1 + tags('table_4' , '4' , '4' , '4' , '4' , false , 'binary4' , 'nchar4' , '-444.444' , '-444444.444444' , '0')''') + tdSql.execute('''create table table_5 using stable_1 + tags('table_5' , '5' , '5' , '5' , '5' , true , 'binary5' , 'nchar5' , '5555.5555' , '55555555.55555555' , '0')''') + #regular table + tdSql.execute('''create table regular_table_1 + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint, + q_bool bool , q_binary binary(20) , q_nchar nchar(20) , + q_float float , q_double double , q_ts timestamp) ;''') + + for i in range(self.num): + tdSql.execute('''insert into table_0 values(%d, %d, %d, %d, %d, 0, 'binary.%s', 'nchar.%s', %f, %f, %d)''' + % (self.ts + i, i, i, i, i, i, i, i, i, self.ts + i)) + tdSql.execute('''insert into table_1 values(%d, %d, %d, %d, %d, 1, 'binary1.%s', 'nchar1.%s', %f, %f, %d)''' + % (self.ts + i, 2147483647-i, 9223372036854775807-i, 32767-i, 127-i, + i, i, random.random(), random.random(), 1262304000001 + i)) + tdSql.execute('''insert into table_2 values(%d, %d, %d, %d, %d, true, 'binary2.%s', 'nchar2nchar2.%s', %f, %f, %d)''' + % (self.ts + i, -2147483647+i, -9223372036854775807+i, -32767+i, -127+i, + i, i, random.uniform(-1,0), random.uniform(-1,0), 1577836800001 + i)) + tdSql.execute('''insert into table_3 values(%d, %d, %d, %d, %d, false, 'binary3.%s', 'nchar3.%s', %f, %f, %d)''' + % (self.ts + i, random.randint(-2147483647, 2147483647), + random.randint(-9223372036854775807, 9223372036854775807), random.randint(-32767, 32767), + random.randint(-127, 127), random.randint(-100, 100), random.randint(-10000, 10000), + random.uniform(-100000,100000), random.uniform(-1000000000,1000000000), self.ts + i)) + tdSql.execute('''insert into table_4 values(%d, %d, %d, %d, %d, true, 'binary4.%s', 'nchar4.%s', %f, %f, %d)''' + % (self.ts + i, i, i, i, i, i, i, i, i, self.ts + i)) + tdSql.execute('''insert into table_5 values(%d, %d, %d, %d, %d, false, 'binary5.%s', 'nchar5.%s', %f, %f, %d)''' + % (self.ts + i, i, i, i, i, i, i, i, i, self.ts + i)) + + tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, 0, 'binary.%s', 'nchar.%s', %f, %f, %d)''' + % (self.ts + i, i, i, i, i, i, i, i, i, self.ts + i)) + tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, 1, 'binary1.%s', 'nchar1.%s', %f, %f, %d)''' + % (self.ts + 100 + i, 2147483647-i, 9223372036854775807-i, 32767-i, 127-i, + i, i, random.random(), random.random(), 1262304000001 + i)) + tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, true, 'binary2.%s', 'nchar2nchar2.%s', %f, %f, %d)''' + % (self.ts + 200 + i, -2147483647+i, -9223372036854775807+i, -32767+i, -127+i, + i, i, random.uniform(-1,0), random.uniform(-1,0), 1577836800001 + i)) + tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, false, 'binary3.%s', 'nchar3.%s', %f, %f, %d)''' + % (self.ts + 300 + i, random.randint(-2147483647, 2147483647), + random.randint(-9223372036854775807, 9223372036854775807), random.randint(-32767, 32767), + random.randint(-127, 127), random.randint(-100, 100), random.randint(-10000, 10000), + random.uniform(-100000,100000), random.uniform(-1000000000,1000000000), self.ts + i)) + tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, true, 'binary4.%s', 'nchar4.%s', %f, %f, %d)''' + % (self.ts + 400 + i, i, i, i, i, i, i, i, i, self.ts + i)) + tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, false, 'binary5.%s', 'nchar5.%s', %f, %f, %d)''' + % (self.ts + 500 + i, i, i, i, i, i, i, i, i, self.ts + i)) + + sql = '''select * from stable_1''' + tdSql.query(sql) + tdSql.checkRows(6*self.num) + sql = '''select * from regular_table_1''' + tdSql.query(sql) + tdSql.checkRows(6*self.num) + + tdLog.info("=======last_row(*)========") + sql = '''select last_row(*) from stable_1;''' + tdSql.query(sql) + tdSql.checkData(0,1,self.num-1) + sql = '''select last_row(*) from regular_table_1;''' + tdSql.query(sql) + tdSql.checkData(0,1,self.num-1) + + sql = '''select * from stable_1 + where loc = 'table_0';''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select last_row(*) from + (select * from stable_1 + where loc = 'table_0');''' + tdSql.query(sql) + tdSql.checkRows(1) + sql = '''select last_row(*) from + (select * from stable_1);''' + tdSql.query(sql) + tdSql.checkData(0,1,self.num-1) + tdSql.checkData(0,2,self.num-1) + tdSql.checkData(0,3,self.num-1) + tdSql.checkData(0,4,self.num-1) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary5.9') + tdSql.checkData(0,7,'nchar5.9') + tdSql.checkData(0,8,9.00000) + tdSql.checkData(0,9,9.000000000) + tdSql.checkData(0,10,'2020-09-13 20:26:40.009') + tdSql.checkData(0,11,'table_5') + tdSql.checkData(0,12,5) + tdSql.checkData(0,13,5) + tdSql.checkData(0,14,5) + tdSql.checkData(0,15,5) + tdSql.checkData(0,16,'True') + tdSql.checkData(0,17,'binary5') + tdSql.checkData(0,18,'nchar5') + tdSql.checkData(0,21,'1970-01-01 08:00:00.000') + + sql = '''select * from regular_table_1 ;''' + tdSql.query(sql) + tdSql.checkRows(6*self.num) + sql = '''select last_row(*) from + (select * from regular_table_1);''' + tdSql.query(sql) + tdSql.checkRows(1) + tdSql.checkData(0,1,self.num-1) + tdSql.checkData(0,2,self.num-1) + tdSql.checkData(0,3,self.num-1) + tdSql.checkData(0,4,self.num-1) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary5.9') + tdSql.checkData(0,7,'nchar5.9') + tdSql.checkData(0,8,9.00000) + tdSql.checkData(0,9,9.000000000) + tdSql.checkData(0,10,'2020-09-13 20:26:40.009') + + # incorrect result, not support nest > 2 + sql = '''select last_row(*) from + ((select * from table_0) union all + (select * from table_1) union all + (select * from table_2));''' + tdSql.error(sql) + #tdSql.checkRows(1) + #tdSql.checkData(0,1,self.num-1) + #tdSql.checkData(0,2,self.num-1) + #tdSql.checkData(0,3,self.num-1) + #tdSql.checkData(0,4,self.num-1) + #tdSql.checkData(0,5,'False') + #tdSql.checkData(0,6,'binary.9') + #tdSql.checkData(0,7,'nchar.9') + #tdSql.checkData(0,8,9.00000) + #tdSql.checkData(0,9,9.000000000) + #tdSql.checkData(0,10,'2020-09-13 20:26:40.009') + + # bug 5055 + # sql = '''select last_row(*) from + # ((select * from stable_1) union all + # (select * from table_1) union all + # (select * from regular_table_1));''' + # tdSql.query(sql) + # tdSql.checkData(0,1,self.num-1) + + sql = '''select last_row(*) from + ((select last_row(*) from table_0) union all + (select last_row(*) from table_1) union all + (select last_row(*) from table_2));''' + tdSql.error(sql) + #tdSql.checkRows(1) + #tdSql.checkData(0,1,self.num-1) + #tdSql.checkData(0,2,self.num-1) + #tdSql.checkData(0,3,self.num-1) + #tdSql.checkData(0,4,self.num-1) + #tdSql.checkData(0,5,'False') + #tdSql.checkData(0,6,'binary.9') + #tdSql.checkData(0,7,'nchar.9') + #tdSql.checkData(0,8,9.00000) + #tdSql.checkData(0,9,9.000000000) + #tdSql.checkData(0,10,'2020-09-13 20:26:40.009') + + # bug 5055 + # sql = '''select last_row(*) from + # ((select last_row(*) from stable_1) union all + # (select last_row(*) from table_1) union all + # (select last_row(*) from regular_table_1));''' + # tdSql.query(sql) + # tdSql.checkData(0,1,self.num-1) + + sql = '''select last_row(*) from + ((select * from table_0 limit 5 offset 5) union all + (select * from table_1 limit 5 offset 5) union all + (select * from regular_table_1 limit 5 offset 5));''' + tdSql.error(sql) + #tdSql.checkRows(1) + #tdSql.checkData(0,1,self.num-1) + #tdSql.checkData(0,2,self.num-1) + #tdSql.checkData(0,3,self.num-1) + #tdSql.checkData(0,4,self.num-1) + #tdSql.checkData(0,5,'False') + #tdSql.checkData(0,6,'binary.9') + #tdSql.checkData(0,7,'nchar.9') + #tdSql.checkData(0,8,9.00000) + #tdSql.checkData(0,9,9.000000000) + #tdSql.checkData(0,10,'2020-09-13 20:26:40.009') + + + sql = '''select last_row(*) from + (select * from stable_1) + having q_int>5;''' + tdLog.info(sql) + tdSql.error(sql) + try: + tdSql.execute(sql) + tdLog.exit(" having only works with group by") + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("invalid operation: having only works with group by") + + #bug 5057 + # sql = '''select last_row(*) from + # (select * from (select * from stable_1))''' + # tdLog.info(sql) + # tdSql.error(sql) + # try: + # tdSql.execute(sql) + # tdLog.exit(" core dumped") + # except Exception as e: + # tdLog.info(repr(e)) + # tdLog.info("core dumped") + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/operator_cost.py b/tests/pytest/query/operator_cost.py new file mode 100644 index 0000000000000000000000000000000000000000..e7ec6d2b6de9404a2ae73492a2760f59e6155ab4 --- /dev/null +++ b/tests/pytest/query/operator_cost.py @@ -0,0 +1,537 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +import random +import time + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + now = time.time() + self.ts = int(round(now * 1000)) + self.num = 10 + + def run(self): + tdSql.prepare() + # test case for https://jira.taosdata.com:18080/browse/TD-5074 + + startTime = time.time() + + tdSql.execute('''create stable stable_1 + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint, + q_bool bool , q_binary binary(20) , q_nchar nchar(20) , + q_float float , q_double double , q_ts timestamp) + tags(loc nchar(20) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, + t_bool bool , t_binary binary(20) , t_nchar nchar(20) , + t_float float , t_double double , t_ts timestamp);''') + tdSql.execute('''create stable stable_2 + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint, + q_bool bool , q_binary binary(20) , q_nchar nchar(20) , + q_float float , q_double double , q_ts timestamp) + tags(loc nchar(20) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, + t_bool bool , t_binary binary(20) , t_nchar nchar(20) , + t_float float , t_double double , t_ts timestamp);''') + tdSql.execute('''create table table_0 using stable_1 + tags('table_0' , '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0')''') + tdSql.execute('''create table table_1 using stable_1 + tags('table_1' , '2147483647' , '9223372036854775807' , '32767' , '127' , 1 , + 'binary1' , 'nchar1' , '1' , '11' , \'1999-09-09 09:09:09.090\')''') + tdSql.execute('''create table table_2 using stable_1 + tags('table_2' , '-2147483647' , '-9223372036854775807' , '-32767' , '-127' , false , + 'binary2' , 'nchar2nchar2' , '-2.2' , '-22.22' , \'2099-09-09 09:09:09.090\')''') + tdSql.execute('''create table table_3 using stable_1 + tags('table_3' , '3' , '3' , '3' , '3' , true , 'binary3' , 'nchar3' , '33.33' , '3333.3333' , '0')''') + tdSql.execute('''create table table_4 using stable_1 + tags('table_4' , '4' , '4' , '4' , '4' , false , 'binary4' , 'nchar4' , '-444.444' , '-444444.444444' , '0')''') + tdSql.execute('''create table table_5 using stable_1 + tags('table_5' , '5' , '5' , '5' , '5' , true , 'binary5' , 'nchar5' , '5555.5555' , '55555555.55555555' , '0')''') + tdSql.execute('''create table table_21 using stable_2 + tags('table_5' , '5' , '5' , '5' , '5' , true , 'binary5' , 'nchar5' , '5555.5555' , '55555555.55555555' , '0')''') + #regular table + tdSql.execute('''create table regular_table_1 + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint, + q_bool bool , q_binary binary(20) , q_nchar nchar(20) , + q_float float , q_double double , q_ts timestamp) ;''') + + for i in range(self.num): + tdSql.execute('''insert into table_0 values(%d, %d, %d, %d, %d, 0, 'binary.%s', 'nchar.%s', %f, %f, %d)''' + % (self.ts + i, i, i, i, i, i, i, i, i, self.ts + i)) + tdSql.execute('''insert into table_1 values(%d, %d, %d, %d, %d, 1, 'binary1.%s', 'nchar1.%s', %f, %f, %d)''' + % (self.ts + i, 2147483647-i, 9223372036854775807-i, 32767-i, 127-i, + i, i, random.random(), random.random(), 1262304000001 + i)) + tdSql.execute('''insert into table_2 values(%d, %d, %d, %d, %d, true, 'binary2.%s', 'nchar2nchar2.%s', %f, %f, %d)''' + % (self.ts + i, -2147483647+i, -9223372036854775807+i, -32767+i, -127+i, + i, i, random.uniform(-1,0), random.uniform(-1,0), 1577836800001 + i)) + tdSql.execute('''insert into table_3 values(%d, %d, %d, %d, %d, false, 'binary3.%s', 'nchar3.%s', %f, %f, %d)''' + % (self.ts + i, random.randint(-2147483647, 2147483647), + random.randint(-9223372036854775807, 9223372036854775807), random.randint(-32767, 32767), + random.randint(-127, 127), random.randint(-100, 100), random.randint(-10000, 10000), + random.uniform(-100000,100000), random.uniform(-1000000000,1000000000), self.ts + i)) + tdSql.execute('''insert into table_4 values(%d, %d, %d, %d, %d, true, 'binary4.%s', 'nchar4.%s', %f, %f, %d)''' + % (self.ts + i, i, i, i, i, i, i, i, i, self.ts + i)) + tdSql.execute('''insert into table_5 values(%d, %d, %d, %d, %d, false, 'binary5.%s', 'nchar5.%s', %f, %f, %d)''' + % (self.ts + i, i, i, i, i, i, i, i, i, self.ts + i)) + tdSql.execute('''insert into table_21 values(%d, %d, %d, %d, %d, false, 'binary5.%s', 'nchar5.%s', %f, %f, %d)''' + % (self.ts + i, i, i, i, i, i, i, i, i, self.ts + i)) + + tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, 0, 'binary.%s', 'nchar.%s', %f, %f, %d)''' + % (self.ts + i, i, i, i, i, i, i, i, i, self.ts + i)) + tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, 1, 'binary1.%s', 'nchar1.%s', %f, %f, %d)''' + % (self.ts + 100 + i, 2147483647-i, 9223372036854775807-i, 32767-i, 127-i, + i, i, random.random(), random.random(), 1262304000001 + i)) + tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, true, 'binary2.%s', 'nchar2nchar2.%s', %f, %f, %d)''' + % (self.ts + 200 + i, -2147483647+i, -9223372036854775807+i, -32767+i, -127+i, + i, i, random.uniform(-1,0), random.uniform(-1,0), 1577836800001 + i)) + tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, false, 'binary3.%s', 'nchar3.%s', %f, %f, %d)''' + % (self.ts + 300 + i, random.randint(-2147483647, 2147483647), + random.randint(-9223372036854775807, 9223372036854775807), random.randint(-32767, 32767), + random.randint(-127, 127), random.randint(-100, 100), random.randint(-10000, 10000), + random.uniform(-100000,100000), random.uniform(-1000000000,1000000000), self.ts + i)) + tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, true, 'binary4.%s', 'nchar4.%s', %f, %f, %d)''' + % (self.ts + 400 + i, i, i, i, i, i, i, i, i, self.ts + i)) + tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, false, 'binary5.%s', 'nchar5.%s', %f, %f, %d)''' + % (self.ts + 500 + i, i, i, i, i, i, i, i, i, self.ts + i)) + + tdLog.info("========== operator=1(OP_TableScan) ==========") + tdLog.info("========== operator=7(OP_Project) ==========") + sql = '''select * from stable_1''' + tdSql.query(sql) + tdSql.checkRows(6*self.num) + sql = '''select * from regular_table_1''' + tdSql.query(sql) + tdSql.checkRows(6*self.num) + + tdLog.info("========== operator=14(OP_MultiTableAggregate ) ==========") + sql = '''select last_row(*) from stable_1;''' + tdSql.query(sql) + tdSql.checkData(0,1,self.num-1) + + tdLog.info("========== operator=6(OP_Aggregate) ==========") + sql = '''select last_row(*) from regular_table_1;''' + tdSql.query(sql) + tdSql.checkData(0,1,self.num-1) + + tdLog.info("========== operator=9(OP_Limit) ==========") + sql = '''select * from stable_1 where loc = 'table_0' limit 5;''' + tdSql.query(sql) + tdSql.checkRows(5) + sql = '''select last_row(*) from (select * from stable_1 where loc = 'table_0');''' + tdSql.query(sql) + tdSql.checkRows(1) + + sql = '''select * from regular_table_1 ;''' + tdSql.query(sql) + tdSql.checkRows(6*self.num) + sql = '''select last_row(*) from (select * from regular_table_1);''' + tdSql.query(sql) + tdSql.checkRows(1) + tdSql.checkData(0,1,self.num-1) + + + sql = '''select last_row(*) from + ((select * from table_0) union all + (select * from table_1) union all + (select * from table_2));''' + tdSql.error(sql) + + tdLog.info("========== operator=16(OP_DummyInput) ==========") + sql = '''select last_row(*) from + ((select last_row(*) from table_0) union all + (select last_row(*) from table_1) union all + (select last_row(*) from table_2));''' + tdSql.error(sql) + + sql = '''select last_row(*) from + ((select * from table_0 limit 5 offset 5) union all + (select * from table_1 limit 5 offset 5) union all + (select * from regular_table_1 limit 5 offset 5));''' + tdSql.error(sql) + + tdLog.info("========== operator=10(OP_SLimit) ==========") + sql = '''select count(*) from stable_1 group by loc slimit 3 soffset 2 ;''' + tdSql.query(sql) + tdSql.checkRows(3) + + sql = '''select last_row(*) from + ((select * from table_0) union all + (select * from table_1) union all + (select * from table_2));''' + tdSql.error(sql) + + tdLog.info("========== operator=20(OP_Distinct) ==========") + tdLog.info("========== operator=4(OP_TagScan) ==========") + sql = '''select distinct(t_bool) from stable_1;''' + tdSql.query(sql) + tdSql.checkRows(2) + sql = '''select distinct(loc) from stable_1;''' + tdSql.query(sql) + tdSql.checkRows(6) + sql = '''select distinct(t_int) from stable_1;''' + tdSql.query(sql) + tdSql.checkRows(6) + sql = '''select distinct(t_bigint) from stable_1;''' + tdSql.query(sql) + tdSql.checkRows(6) + sql = '''select distinct(t_smallint) from stable_1;''' + tdSql.query(sql) + tdSql.checkRows(6) + sql = '''select distinct(t_tinyint) from stable_1;''' + tdSql.query(sql) + tdSql.checkRows(6) + sql = '''select distinct(t_nchar) from stable_1;''' + tdSql.query(sql) + tdSql.checkRows(6) + sql = '''select distinct(t_float) from stable_1;''' + tdSql.query(sql) + tdSql.checkRows(6) + sql = '''select distinct(t_double) from stable_1;''' + tdSql.query(sql) + tdSql.checkRows(6) + sql = '''select distinct(t_ts) from stable_1;''' + tdSql.query(sql) + tdSql.checkRows(3) + # sql = '''select distinct(tbname) from stable_1;''' + # tdSql.query(sql) + # tdSql.checkRows(6) + + tdLog.info("========== operator=2(OP_DataBlocksOptScan) ==========") + sql = '''select last(q_int),first(q_int) from stable_1;''' + tdSql.query(sql) + tdSql.checkRows(1) + sql = '''select last(q_bigint),first(q_bigint) from stable_1;''' + tdSql.query(sql) + tdSql.checkRows(1) + sql = '''select last(q_smallint),first(q_smallint) from stable_1;''' + tdSql.query(sql) + tdSql.checkRows(1) + sql = '''select last(q_tinyint),first(q_tinyint) from stable_1;''' + tdSql.query(sql) + tdSql.checkRows(1) + sql = '''select last(q_bool),first(q_bool) from stable_1;''' + tdSql.query(sql) + tdSql.checkRows(1) + sql = '''select last(q_binary),first(q_binary) from stable_1;''' + tdSql.query(sql) + tdSql.checkRows(1) + sql = '''select last(q_nchar),first(q_nchar) from stable_1;''' + tdSql.query(sql) + tdSql.checkRows(1) + sql = '''select last(q_float),first(q_float) from stable_1;''' + tdSql.query(sql) + tdSql.checkRows(1) + sql = '''select last(q_double),first(q_double) from stable_1;''' + tdSql.query(sql) + tdSql.checkRows(1) + sql = '''select last(q_ts),first(q_ts) from stable_1;''' + tdSql.query(sql) + tdSql.checkRows(1) + sql = '''select last(q_int),last(q_bigint), last(q_smallint),last(q_tinyint),last(q_bool),last(q_binary),last(q_nchar), + last(q_float),last(q_double),last(q_ts),first(q_int),first(q_bigint),first(q_smallint),first(q_tinyint), + first(q_bool),first(q_binary),first(q_nchar),first(q_float),first(q_float),first(q_double),first(q_ts) from stable_1;''' + tdSql.query(sql) + tdSql.checkRows(1) + sql = '''select last(q_int),last(q_bigint), last(q_smallint),last(q_tinyint),last(q_bool),last(q_binary),last(q_nchar), + last(q_float),last(q_double),last(q_ts),first(q_int),first(q_bigint),first(q_smallint),first(q_tinyint),first(q_bool), + first(q_binary),first(q_nchar),first(q_float),first(q_float),first(q_double),first(q_ts) from regular_table_1;''' + tdSql.query(sql) + tdSql.checkRows(1) + + tdLog.info("========== operator=8(OP_Groupby) ==========") + sql = '''select stddev(q_int) from table_0 group by q_int;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select stddev(q_int),stddev(q_bigint),stddev(q_smallint),stddev(q_tinyint),stddev(q_float),stddev(q_double) from stable_1 group by q_int;''' + tdSql.query(sql) + sql = '''select stddev(q_int),stddev(q_bigint),stddev(q_smallint),stddev(q_tinyint),stddev(q_float),stddev(q_double) from table_1 group by q_bigint;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select stddev(q_int),stddev(q_bigint),stddev(q_smallint),stddev(q_tinyint),stddev(q_float),stddev(q_double) from regular_table_1 group by q_smallint;''' + tdSql.query(sql) + + tdLog.info("========== operator=11(OP_TimeWindow) ==========") + sql = '''select last(q_int) from table_0 interval(1m);''' + tdSql.query(sql) + tdSql.checkRows(1) + sql = '''select last(q_int),last(q_bigint), last(q_smallint),last(q_tinyint), + first(q_int),first(q_bigint),first(q_smallint),first(q_tinyint) from table_1 interval(1m);''' + tdSql.query(sql) + tdSql.checkRows(1) + sql = '''select last(q_int),last(q_bigint), last(q_smallint),last(q_tinyint), + first(q_int),first(q_bigint),first(q_smallint),first(q_tinyint) from stable_1 interval(1m);''' + tdSql.query(sql) + tdSql.checkRows(1) + sql = '''select last(q_int),last(q_bigint), last(q_smallint),last(q_tinyint), + first(q_int),first(q_bigint),first(q_smallint),first(q_tinyint) from regular_table_1 interval(1m);''' + tdSql.query(sql) + tdSql.checkRows(1) + + tdLog.info("========== operator=12(OP_SessionWindow) ==========") + sql = '''select count(*) from table_1 session(ts,1s);''' + tdSql.query(sql) + tdSql.checkRows(1) + sql = '''select count(*) from regular_table_1 session(ts,1s);''' + tdSql.query(sql) + tdSql.checkRows(1) + sql = '''select count(*),sum(q_int), avg(q_int), min(q_int), max(q_int), first(q_int), last(q_int), + sum(q_bigint), avg(q_bigint), min(q_bigint), max(q_bigint), first(q_bigint), last(q_bigint), + sum(q_smallint), avg(q_smallint), min(q_smallint), max(q_smallint), first(q_smallint), last(q_smallint), + sum(q_tinyint), avg(q_tinyint), min(q_tinyint), max(q_tinyint), first(q_tinyint), last(q_tinyint), + sum(q_float), avg(q_float), min(q_float), max(q_float), first(q_float), last(q_float), + sum(q_double), avg(q_double), min(q_double), max(q_double), first(q_double), last(q_double) + from table_1 session(ts,1s);''' + tdSql.query(sql) + tdSql.checkRows(1) + sql = '''select count(*),sum(q_int), avg(q_int), min(q_int), max(q_int), first(q_int), last(q_int), + sum(q_bigint), avg(q_bigint), min(q_bigint), max(q_bigint), first(q_bigint), last(q_bigint), + sum(q_smallint), avg(q_smallint), min(q_smallint), max(q_smallint), first(q_smallint), last(q_smallint), + sum(q_tinyint), avg(q_tinyint), min(q_tinyint), max(q_tinyint), first(q_tinyint), last(q_tinyint), + sum(q_float), avg(q_float), min(q_float), max(q_float), first(q_float), last(q_float), + sum(q_double), avg(q_double), min(q_double), max(q_double), first(q_double), last(q_double) + from regular_table_1 session(ts,1s);''' + tdSql.query(sql) + tdSql.checkRows(1) + + tdLog.info("========== operator=13(OP_Fill) ==========") + sql = '''select sum(q_int) from table_0 + where ts >='1970-10-01 00:00:00' and ts <=now interval(1n) fill(NULL);''' + tdSql.query(sql) + tdSql.checkData(0,1,'None') + sql = '''select sum(q_int), avg(q_int), min(q_int), max(q_int), first(q_int), last(q_int), + sum(q_bigint), avg(q_bigint), min(q_bigint), max(q_bigint), first(q_bigint), last(q_bigint), + sum(q_smallint), avg(q_smallint), min(q_smallint), max(q_smallint), first(q_smallint), last(q_smallint), + sum(q_tinyint), avg(q_tinyint), min(q_tinyint), max(q_tinyint), first(q_tinyint), last(q_tinyint), + sum(q_float), avg(q_float), min(q_float), max(q_float), first(q_float), last(q_float), + sum(q_double), avg(q_double), min(q_double), max(q_double), first(q_double), last(q_double) + from stable_1 where ts >='1970-10-01 00:00:00' and ts <=now interval(1n) fill(NULL);''' + tdSql.query(sql) + tdSql.checkData(0,1,'None') + sql = '''select sum(q_int), avg(q_int), min(q_int), max(q_int), first(q_int), last(q_int), + sum(q_bigint), avg(q_bigint), min(q_bigint), max(q_bigint), first(q_bigint), last(q_bigint), + sum(q_smallint), avg(q_smallint), min(q_smallint), max(q_smallint), first(q_smallint), last(q_smallint), + sum(q_tinyint), avg(q_tinyint), min(q_tinyint), max(q_tinyint), first(q_tinyint), last(q_tinyint), + sum(q_float), avg(q_float), min(q_float), max(q_float), first(q_float), last(q_float), + sum(q_double), avg(q_double), min(q_double), max(q_double), first(q_double), last(q_double) + from regular_table_1 where ts >='1970-10-01 00:00:00' and ts <=now interval(1n) fill(NULL);''' + tdSql.query(sql) + tdSql.checkData(0,1,'None') + sql = '''select sum(q_int), avg(q_int), min(q_int), max(q_int), first(q_int), last(q_int), + sum(q_bigint), avg(q_bigint), min(q_bigint), max(q_bigint), first(q_bigint), last(q_bigint), + sum(q_smallint), avg(q_smallint), min(q_smallint), max(q_smallint), first(q_smallint), last(q_smallint), + sum(q_tinyint), avg(q_tinyint), min(q_tinyint), max(q_tinyint), first(q_tinyint), last(q_tinyint), + sum(q_float), avg(q_float), min(q_float), max(q_float), first(q_float), last(q_float), + sum(q_double), avg(q_double), min(q_double), max(q_double), first(q_double), last(q_double) + from table_0 where ts >='1970-10-01 00:00:00' and ts <=now interval(1n) fill(NULL);''' + tdSql.query(sql) + tdSql.checkData(0,1,'None') + #TD-5190 + sql = '''select sum(q_tinyint),stddev(q_float) from stable_1 + where ts >='1970-10-01 00:00:00' and ts <=now interval(1n) fill(NULL);''' + tdSql.query(sql) + tdSql.checkData(0,1,'None') + + tdLog.info("========== operator=15(OP_MultiTableTimeInterval) ==========") + sql = '''select avg(q_int) from stable_1 where ts=0;''' + tdSql.query(sql) + tdSql.checkData(0,0,'table_0') + sql = '''select loc, sum(q_int), avg(q_int), min(q_int), max(q_int), first(q_int), last(q_int), + sum(q_bigint), avg(q_bigint), min(q_bigint), max(q_bigint), first(q_bigint), last(q_bigint), + sum(q_smallint), avg(q_smallint), min(q_smallint), max(q_smallint), first(q_smallint), last(q_smallint), + sum(q_tinyint), avg(q_tinyint), min(q_tinyint), max(q_tinyint), first(q_tinyint), last(q_tinyint), + sum(q_float), avg(q_float), min(q_float), max(q_float), first(q_float), last(q_float), + sum(q_double), avg(q_double), min(q_double), max(q_double), first(q_double), last(q_double) + from stable_1 group by loc having sum(q_int)>=0;''' + tdSql.query(sql) + tdSql.checkData(0,0,'table_0') + sql = '''select loc, sum(q_int), avg(q_int), min(q_int), max(q_int), first(q_int), last(q_int), + sum(q_bigint), avg(q_bigint), min(q_bigint), max(q_bigint), first(q_bigint), last(q_bigint), + sum(q_smallint), avg(q_smallint), min(q_smallint), max(q_smallint), first(q_smallint), last(q_smallint), + sum(q_tinyint), avg(q_tinyint), min(q_tinyint), max(q_tinyint), first(q_tinyint), last(q_tinyint), + sum(q_float), avg(q_float), min(q_float), max(q_float), first(q_float), last(q_float), + sum(q_double), avg(q_double), min(q_double), max(q_double), first(q_double), last(q_double) + from stable_1 group by loc having avg(q_int)>=0;''' + tdSql.query(sql) + tdSql.checkData(0,0,'table_0') + sql = '''select loc, sum(q_int), avg(q_int), min(q_int), max(q_int), first(q_int), last(q_int), + sum(q_bigint), avg(q_bigint), min(q_bigint), max(q_bigint), first(q_bigint), last(q_bigint), + sum(q_smallint), avg(q_smallint), min(q_smallint), max(q_smallint), first(q_smallint), last(q_smallint), + sum(q_tinyint), avg(q_tinyint), min(q_tinyint), max(q_tinyint), first(q_tinyint), last(q_tinyint), + sum(q_float), avg(q_float), min(q_float), max(q_float), first(q_float), last(q_float), + sum(q_double), avg(q_double), min(q_double), max(q_double), first(q_double), last(q_double) + from stable_1 group by loc having min(q_int)>=0;''' + tdSql.query(sql) + tdSql.checkData(0,0,'table_0') + sql = '''select loc, sum(q_int), avg(q_int), min(q_int), max(q_int), first(q_int), last(q_int), + sum(q_bigint), avg(q_bigint), min(q_bigint), max(q_bigint), first(q_bigint), last(q_bigint), + sum(q_smallint), avg(q_smallint), min(q_smallint), max(q_smallint), first(q_smallint), last(q_smallint), + sum(q_tinyint), avg(q_tinyint), min(q_tinyint), max(q_tinyint), first(q_tinyint), last(q_tinyint), + sum(q_float), avg(q_float), min(q_float), max(q_float), first(q_float), last(q_float), + sum(q_double), avg(q_double), min(q_double), max(q_double), first(q_double), last(q_double) + from stable_1 group by loc having max(q_int)>=0;''' + tdSql.query(sql) + tdSql.checkData(0,0,'table_0') + sql = '''select loc, sum(q_int), avg(q_int), min(q_int), max(q_int), first(q_int), last(q_int), + sum(q_bigint), avg(q_bigint), min(q_bigint), max(q_bigint), first(q_bigint), last(q_bigint), + sum(q_smallint), avg(q_smallint), min(q_smallint), max(q_smallint), first(q_smallint), last(q_smallint), + sum(q_tinyint), avg(q_tinyint), min(q_tinyint), max(q_tinyint), first(q_tinyint), last(q_tinyint), + sum(q_float), avg(q_float), min(q_float), max(q_float), first(q_float), last(q_float), + sum(q_double), avg(q_double), min(q_double), max(q_double), first(q_double), last(q_double) + from stable_1 group by loc having first(q_int)>=0;''' + tdSql.query(sql) + tdSql.checkData(0,0,'table_0') + sql = '''select loc, sum(q_int), avg(q_int), min(q_int), max(q_int), first(q_int), last(q_int), + sum(q_bigint), avg(q_bigint), min(q_bigint), max(q_bigint), first(q_bigint), last(q_bigint), + sum(q_smallint), avg(q_smallint), min(q_smallint), max(q_smallint), first(q_smallint), last(q_smallint), + sum(q_tinyint), avg(q_tinyint), min(q_tinyint), max(q_tinyint), first(q_tinyint), last(q_tinyint), + sum(q_float), avg(q_float), min(q_float), max(q_float), first(q_float), last(q_float), + sum(q_double), avg(q_double), min(q_double), max(q_double), first(q_double), last(q_double) + from stable_1 group by loc having last(q_int)>=0;''' + tdSql.query(sql) + tdSql.checkData(0,0,'table_0') + + tdLog.info("========== operator=21(OP_Join) ==========") + sql = '''select t1.q_int,t2.q_int from + (select ts,q_int from table_1) t1 , (select ts,q_int from table_2) t2 + where t2.ts = t1.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select t1.*,t2.* from + (select * from table_1) t1 , (select * from table_2) t2 + where t2.ts = t1.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select t1.*,t2.* from + (select * from regular_table_1) t1 , (select * from table_0) t2 + where t2.ts = t1.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select t1.*,t2.* from + (select * from stable_1) t1 , (select * from table_2) t2 + where t2.ts = t1.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select t1.*,t2.* from + (select * from regular_table_1) t1 , (select * from stable_1) t2 + where t2.ts = t1.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select t1.*,t2.*,t3.* from + (select * from regular_table_1) t1 , (select * from stable_1) t2, (select * from table_0) t3 + where t2.ts = t1.ts and t3.ts = t1.ts and t2.ts = t3.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + + tdLog.info("========== operator=22(OP_StateWindow) ==========") + sql = '''select avg(q_int),sum(q_smallint) from table_1 state_window(q_int);''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select sum(q_int), avg(q_int), min(q_int), max(q_int), first(q_int), last(q_int), + sum(q_bigint), avg(q_bigint), min(q_bigint), max(q_bigint), first(q_bigint), last(q_bigint), + sum(q_smallint), avg(q_smallint), min(q_smallint), max(q_smallint), first(q_smallint), last(q_smallint), + sum(q_tinyint), avg(q_tinyint), min(q_tinyint), max(q_tinyint), first(q_tinyint), last(q_tinyint), + sum(q_float), avg(q_float), min(q_float), max(q_float), first(q_float), last(q_float), + sum(q_double), avg(q_double), min(q_double), max(q_double), first(q_double), last(q_double) + from table_1 state_window(q_bigint);''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select sum(q_int), avg(q_int), min(q_int), max(q_int), first(q_int), last(q_int), + sum(q_bigint), avg(q_bigint), min(q_bigint), max(q_bigint), first(q_bigint), last(q_bigint), + sum(q_smallint), avg(q_smallint), min(q_smallint), max(q_smallint), first(q_smallint), last(q_smallint), + sum(q_tinyint), avg(q_tinyint), min(q_tinyint), max(q_tinyint), first(q_tinyint), last(q_tinyint), + sum(q_float), avg(q_float), min(q_float), max(q_float), first(q_float), last(q_float), + sum(q_double), avg(q_double), min(q_double), max(q_double), first(q_double), last(q_double) + from regular_table_1 state_window(q_smallint);''' + tdSql.query(sql) + tdSql.checkRows(6*self.num) + + endTime = time.time() + print("total time %ds" % (endTime - startTime)) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/query/query.py b/tests/pytest/query/query.py new file mode 100644 index 0000000000000000000000000000000000000000..81ee262ae8d6e3367d351ed98dcdbd083ec1f4fe --- /dev/null +++ b/tests/pytest/query/query.py @@ -0,0 +1,173 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.ts = 1538548685000 + + def bug_6387(self): + tdSql.execute("create database bug6387 ") + tdSql.execute("use bug6387 ") + tdSql.execute("create table test(ts timestamp, c1 int) tags(t1 int)") + for i in range(5000): + sql = "insert into t%d using test tags(1) values " % i + for j in range(21): + sql = sql + "(now+%ds,%d)" % (j ,j ) + tdSql.execute(sql) + tdSql.query("select count(*) from test interval(1s) group by tbname") + tdSql.checkData(0,1,1) + + def run(self): + tdSql.prepare() + + print("==============step1") + tdSql.execute( + "create table if not exists st (ts timestamp, tagtype int) tags(dev nchar(50))") + tdSql.execute( + 'CREATE TABLE if not exists dev_001 using st tags("dev_01")') + tdSql.execute( + 'CREATE TABLE if not exists dev_002 using st tags("dev_02")') + + print("==============step2") + + tdSql.execute( + """INSERT INTO dev_001(ts, tagtype) VALUES('2020-05-13 10:00:00.000', 1), + ('2020-05-13 10:00:00.001', 1) + dev_002 VALUES('2020-05-13 10:00:00.001', 1)""") + + tdSql.query("select * from db.st where ts='2020-05-13 10:00:00.000'") + tdSql.checkRows(1) + + tdSql.query("select tbname, dev from dev_001") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 'dev_001') + tdSql.checkData(0, 1, 'dev_01') + + tdSql.query("select tbname, dev, tagtype from dev_001") + tdSql.checkRows(2) + tdSql.checkData(0, 0, 'dev_001') + tdSql.checkData(0, 1, 'dev_01') + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 0, 'dev_001') + tdSql.checkData(1, 1, 'dev_01') + tdSql.checkData(1, 2, 1) + + ## test case for https://jira.taosdata.com:18080/browse/TD-2488 + tdSql.execute("create table m1(ts timestamp, k int) tags(a int)") + tdSql.execute("create table t1 using m1 tags(1)") + tdSql.execute("create table t2 using m1 tags(2)") + tdSql.execute("insert into t1 values('2020-1-1 1:1:1', 1)") + tdSql.execute("insert into t1 values('2020-1-1 1:10:1', 2)") + tdSql.execute("insert into t2 values('2020-1-1 1:5:1', 99)") + + tdSql.query("select count(*) from m1 where ts = '2020-1-1 1:5:1' ") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdDnodes.stop(1) + tdDnodes.start(1) + + tdSql.query("select count(*) from m1 where ts = '2020-1-1 1:5:1' ") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + ## test case for https://jira.taosdata.com:18080/browse/TD-1930 + tdSql.execute("create table tb(ts timestamp, c1 int, c2 binary(10), c3 nchar(10), c4 float, c5 bool)") + for i in range(10): + tdSql.execute( + "insert into tb values(%d, %d, 'binary%d', 'nchar%d', %f, %d)" % (self.ts + i, i, i, i, i + 0.1, i % 2)) + + tdSql.error("select * from tb where c2 = binary2") + tdSql.error("select * from tb where c3 = nchar2") + + tdSql.query("select * from tb where c2 = 'binary2' ") + tdSql.checkRows(1) + + tdSql.query("select * from tb where c3 = 'nchar2' ") + tdSql.checkRows(1) + + tdSql.query("select * from tb where c1 = '2' ") + tdSql.checkRows(1) + + tdSql.query("select * from tb where c1 = 2 ") + tdSql.checkRows(1) + + tdSql.query("select * from tb where c4 = '0.1' ") + tdSql.checkRows(1) + + tdSql.query("select * from tb where c4 = 0.1 ") + tdSql.checkRows(1) + + tdSql.query("select * from tb where c5 = true ") + tdSql.checkRows(5) + + tdSql.query("select * from tb where c5 = 'true' ") + tdSql.checkRows(5) + + # For jira: https://jira.taosdata.com:18080/browse/TD-2850 + tdSql.execute("create database 'Test' ") + tdSql.execute("use 'Test' ") + tdSql.execute("create table 'TB'(ts timestamp, 'Col1' int) tags('Tag1' int)") + tdSql.execute("insert into 'Tb0' using tb tags(1) values(now, 1)") + tdSql.query("select * from tb") + tdSql.checkRows(1) + tdSql.query("select * from tb0") + tdSql.checkRows(1) + + # For jira:https://jira.taosdata.com:18080/browse/TD-6314 + tdSql.execute("use db") + tdSql.execute("create stable stb_001(ts timestamp,v int) tags(c0 int)") + tdSql.execute("insert into stb1 using stb_001 tags(1) values(now,1)") + tdSql.query("select _block_dist() from stb_001") + tdSql.checkRows(1) + + + + #For jira: https://jira.taosdata.com:18080/browse/TD-6387 + tdLog.info("case for bug_6387") + self.bug_6387() + + #JIRA TS-583 + tdLog.info("case for JIRA TS-583") + tdSql.execute("create database test2") + tdSql.execute("use test2") + tdSql.execute("create table stb(ts timestamp, c1 int) tags(t1 binary(120))") + tdSql.execute("create table t0 using stb tags('abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz')") + + tdSql.query("show create table t0") + tdSql.checkRows(1) + + tdSql.execute("create table stb2(ts timestamp, c1 int) tags(t1 nchar(120))") + tdSql.execute("create table t1 using stb2 tags('abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz')") + + tdSql.query("show create table t1") + tdSql.checkRows(1) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/query1970YearsAf.py b/tests/pytest/query/query1970YearsAf.py new file mode 100644 index 0000000000000000000000000000000000000000..a365369b21fc7429216f5c1e8c624bf856a744c1 --- /dev/null +++ b/tests/pytest/query/query1970YearsAf.py @@ -0,0 +1,256 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import taos +import sys +import os +import json +import subprocess +import datetime + + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * +from util.dnodes import TDDnode + +class TDTestCase: + + def __init__(self): + self.path = "" + + def init(self, conn, logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + + def getcfgPath(self, path): + binPath = os.path.dirname(os.path.realpath(__file__)) + binPath = binPath + "/../../../debug/" + tdLog.debug(f"binPath {binPath}") + binPath = os.path.realpath(binPath) + tdLog.debug(f"binPath real path {binPath}") + + if path == "": + self.path = os.path.abspath(binPath + "../../") + else: + self.path = os.path.realpath(path) + return self.path + + def getCfgDir(self): + self.getcfgPath(self.path) + self.cfgDir = f"{self.path}/sim/psim/cfg" + return self.cfgDir + + def creatcfg(self): + dbinfo = { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp": 2, + "walLevel": 1, + "cachelast": 0, + "quorum": 1, + "fsync": 3000, + "update": 0 + } + + # set stable schema + stable1 = { + "name": "stb2", + "child_table_exists": "no", + "childtable_count": 10, + "childtable_prefix": "t", + "auto_create_table": "no", + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 5000, + "rows_per_tbl": 1, + "max_sql_len": 65480, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 20000, + "start_timestamp": "1969-12-31 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [ + {"type": "INT", "count": 2}, + {"type": "DOUBLE", "count": 2}, + {"type": "BIGINT", "count": 2}, + {"type": "FLOAT", "count": 2}, + {"type": "SMALLINT", "count": 2}, + {"type": "TINYINT", "count": 2}, + {"type": "BOOL", "count": 2}, + {"type": "NCHAR", "len": 3, "count": 1}, + {"type": "BINARY", "len": 8, "count": 1} + + ], + "tags": [ + {"type": "INT", "count": 2}, + {"type": "DOUBLE", "count": 2}, + {"type": "BIGINT", "count": 2}, + {"type": "FLOAT", "count": 2}, + {"type": "SMALLINT", "count": 2}, + {"type": "TINYINT", "count": 2}, + {"type": "BOOL", "count": 2}, + {"type": "NCHAR", "len": 3, "count": 1}, + {"type": "BINARY", "len": 8, "count": 1} + ] + } + + # create different stables like stable1 and add to list super_tables + super_tables = [] + super_tables.append(stable1) + database = { + "dbinfo": dbinfo, + "super_tables": super_tables + } + + cfgdir = self.getCfgDir() + create_table = { + "filetype": "insert", + "cfgdir": cfgdir, + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "/tmp/insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "num_of_records_per_req": 100, + "databases": [database] + } + return create_table + + def createinsertfile(self): + create_table = self.creatcfg() + date = datetime.datetime.now().strftime("%Y%m%d%H%M") + file_create_table = f"/tmp/insert_{date}.json" + + with open(file_create_table, 'w') as f: + json.dump(create_table, f) + return file_create_table + + def inserttable(self, filepath): + create_table_cmd = f"taosdemo -f {filepath} > /dev/null 2>&1" + _ = subprocess.check_output(create_table_cmd, shell=True).decode("utf-8") + + def sqlsquery(self): + # stable query + tdSql.query( + "select * from stb2 where stb2.ts < '1970-01-01 00:00:00.000' " + ) + tdSql.checkRows(43200) + + tdSql.query( + "select * from stb2 where stb2.ts >= '1970-01-01 00:00:00.000' " + ) + tdSql.checkRows(6800) + + tdSql.query( + "select * from stb2 where stb2.ts > '1969-12-31 23:00:00.000' and stb2.ts <'1970-01-01 01:00:00.000' " + ) + tdSql.checkRows(3590) + + # child-tables query + tdSql.query( + "select * from t0 where t0.ts < '1970-01-01 00:00:00.000' " + ) + tdSql.checkRows(4320) + + tdSql.query( + "select * from t1 where t1.ts >= '1970-01-01 00:00:00.000' " + ) + tdSql.checkRows(680) + + tdSql.query( + "select * from t9 where t9.ts > '1969-12-31 22:00:00.000' and t9.ts <'1970-01-01 02:00:00.000' " + ) + tdSql.checkRows(719) + + tdSql.query( + "select * from t0,t1 where t0.ts=t1.ts and t1.ts >= '1970-01-01 00:00:00.000' " + ) + tdSql.checkRows(680) + + tdSql.query( + "select diff(c1) from t0 where t0.ts >= '1970-01-01 00:00:00.000' " + ) + tdSql.checkRows(679) + + tdSql.query( + "select t0,c1 from stb2 where stb2.ts < '1970-01-01 00:00:00.000' order by ts" + ) + tdSql.checkRows(43200) + + # query with timestamp in 'where ...' + tdSql.query( + "select * from stb2 where stb2.ts > -28800000 " + ) + tdSql.checkRows(6790) + + tdSql.query( + "select * from stb2 where stb2.ts > -28800000 and stb2.ts < '1970-01-01 08:00:00.000' " + ) + tdSql.checkRows(6790) + + tdSql.query( + "select * from stb2 where stb2.ts < -28800000 and stb2.ts > '1969-12-31 22:00:00.000' " + ) + tdSql.checkRows(3590) + + def run(self): + s = 'reset query cache' + tdSql.execute(s) + s = 'create database if not exists db' + tdSql.execute(s) + s = 'use db' + tdSql.execute(s) + + tdLog.info("==========step1:create table stable and child table,then insert data automatically") + insertfile = self.createinsertfile() + self.inserttable(insertfile) + + tdLog.info("==========step2:query join") + self.sqlsquery() + + # after wal and sync, check again + tdSql.query("show dnodes") + index = tdSql.getData(0, 0) + tdDnodes.stop(index) + tdDnodes.start(index) + + tdLog.info("==========step3: query join again") + self.sqlsquery() + + # delete temporary file + rm_cmd = f"rm -f /tmp/insert* > /dev/null 2>&1" + _ = subprocess.check_output(rm_cmd, shell=True).decode("utf-8") + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/pytest/query/queryBase.py b/tests/pytest/query/queryBase.py new file mode 100644 index 0000000000000000000000000000000000000000..4544fab3adcb6e760dcbc05ab56cd22edd35b3e2 --- /dev/null +++ b/tests/pytest/query/queryBase.py @@ -0,0 +1,178 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- +# +# query base function test case +# + +import sys + +from numpy.lib.function_base import insert +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + +# constant define +WAITS = 5 # wait seconds + +class TDTestCase: + # + # --------------- main frame ------------------- + # + + def caseDescription(self): + ''' + Query moudle base api or keyword test case: + case1: api first() last() + case2: none + ''' + return + + # init + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + tdSql.prepare() + self.create_tables(); + self.ts = 1500000000000 + + + # run case + def run(self): + # insert data + self.insert_data("t1", self.ts, 1*10000, 30000, 0); + self.insert_data("t2", self.ts, 2*10000, 30000, 100000); + self.insert_data("t3", self.ts, 3*10000, 30000, 200000); + # test base case + self.case_first() + tdLog.debug(" QUERYBASE first() api ............ [OK]") + # test advance case + self.case_last() + tdLog.debug(" QUERYBASE last() api ............ [OK]") + + # stop + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + # + # --------------- case ------------------- + # + + # create table + def create_tables(self): + # super table + tdSql.execute("create table st(ts timestamp, i1 int) tags(area int)"); + # child table + tdSql.execute("create table t1 using st tags(1)"); + tdSql.execute("create table t2 using st tags(2)"); + tdSql.execute("create table t3 using st tags(3)"); + return + + # insert data1 + def insert_data(self, tbname, ts_start, count, batch_num, base): + pre_insert = "insert into %s values"%tbname + sql = pre_insert + tdLog.debug("doing insert table %s rows=%d ..."%(tbname, count)) + for i in range(count): + sql += " (%d,%d)"%(ts_start + i*1000, base + i) + if i >0 and i%batch_num == 0: + tdSql.execute(sql) + sql = pre_insert + # end sql + if sql != pre_insert: + tdSql.execute(sql) + + tdLog.debug("INSERT TABLE DATA ............ [OK]") + return + + # first case base + def case_first(self): + # + # last base function + # + + # base t1 table + sql = "select first(*) from t1 where ts>='2017-07-14 12:40:00' order by ts asc;" + tdSql.waitedQuery(sql, 1, WAITS) + tdSql.checkData(0, 1, 7200) + sql = "select first(*) from t1 where ts>='2017-07-14 12:40:00' order by ts desc;" # desc + tdSql.waitedQuery(sql, 1, WAITS) + tdSql.checkData(0, 1, 7200) + # super table st + sql = "select first(*) from st where ts>='2017-07-14 11:40:00' and ts<='2017-07-14 12:40:00' and tbname in('t1') order by ts;" + tdSql.waitedQuery(sql, 1, WAITS) + tdSql.checkData(0, 1, 3600) + sql = "select first(*) from st where ts>='2017-07-14 11:40:00' and ts<='2017-07-14 12:40:00' and tbname in('t1') order by ts desc;" # desc + tdSql.waitedQuery(sql, 1, WAITS) + tdSql.checkData(0, 1, 3600) + # sub query + sql = "select first(*) from ( select sum(i1) from st where ts>='2017-07-14 11:40:00' and ts<'2017-07-14 12:40:00' interval(10m) order by ts asc );" + tdSql.waitedQuery(sql, 1, WAITS) + tdSql.checkData(0, 1, 187019100) + sql = "select first(*) from ( select sum(i1) from st where ts>='2017-07-14 11:40:00' and ts<'2017-07-14 12:40:00' interval(10m) order by ts desc );" # desc + tdSql.waitedQuery(sql, 1, WAITS) + tdSql.checkData(0, 1, 187019100) + return + + # last case + def case_last(self): + # + # last base test + # + + # base t1 table + sql = "select last(*) from t1 where ts<='2017-07-14 12:40:00' order by ts asc;" + tdSql.waitedQuery(sql, 1, WAITS) + tdSql.checkData(0, 1, 7200) + sql = "select last(*) from t1 where ts<='2017-07-14 12:40:00' order by ts desc;" # desc + tdSql.waitedQuery(sql, 1, WAITS) + tdSql.checkData(0, 1, 7200) + # super table st + sql = "select last(*) from st where ts>='2017-07-14 11:40:00' and ts<='2017-07-14 12:40:00' and tbname in('t1') order by ts;" + tdSql.waitedQuery(sql, 1, WAITS) + tdSql.checkData(0, 1, 7200) + sql = "select last(*) from st where ts>='2017-07-14 11:40:00' and ts<='2017-07-14 12:40:00' and tbname in('t1') order by ts desc;" # desc + tdSql.waitedQuery(sql, 1, WAITS) + tdSql.checkData(0, 1, 7200) + + # sub query + sql = "select last(*) from ( select sum(i1) from st where ts>='2017-07-14 11:40:00' and ts<'2017-07-14 12:40:00' interval(10m) order by ts asc );" + tdSql.waitedQuery(sql, 1, WAITS) + tdSql.checkData(0, 1, 192419100) + sql = "select last(*) from ( select sum(i1) from st where ts>='2017-07-14 11:40:00' and ts<'2017-07-14 12:40:00' interval(10m) order by ts desc );" # desc + tdSql.waitedQuery(sql, 1, WAITS) + tdSql.checkData(0, 1, 192419100) + + # add parent query order by + # first + sql = "select first(*) from (select first(i1) from st interval(10m) order by ts asc) order by ts desc;" + tdSql.waitedQuery(sql, 1, WAITS) + tdSql.checkData(0, 1, 0) + sql = "select first(*) from (select first(i1) from st interval(10m) order by ts desc) order by ts asc;" + tdSql.waitedQuery(sql, 1, WAITS) + tdSql.checkData(0, 1, 0) + # last + sql = "select last(*) from (select first(i1) from st interval(10m) order by ts asc) order by ts desc;" + tdSql.waitedQuery(sql, 1, WAITS) + tdSql.checkData(0, 1, 229400) + sql = "select last(*) from (select first(i1) from st interval(10m) order by ts desc) order by ts asc;" + tdSql.waitedQuery(sql, 1, WAITS) + tdSql.checkData(0, 1, 229400) + +# +# add case with filename +# +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/query/queryBetweenAnd.py b/tests/pytest/query/queryBetweenAnd.py new file mode 100644 index 0000000000000000000000000000000000000000..cd4320f5235222049f3c1dfc6a7bb8a1ab901b61 --- /dev/null +++ b/tests/pytest/query/queryBetweenAnd.py @@ -0,0 +1,206 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import taos +import sys + +from util.log import * +from util.sql import * +from util.cases import * + + + +class TDTestCase: + + def init(self, conn, logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + + def run(self): + tdSql.prepare() + + tdLog.printNoPrefix("==========step1:create table") + tdSql.execute( + '''create table if not exists supt + (ts timestamp, c1 int, c2 float, c3 bigint, c4 double, c5 smallint, c6 tinyint) + tags(location binary(64), type int, isused bool , family nchar(64))''' + ) + tdSql.execute("create table t1 using supt tags('beijing', 1, 1, '自行车')") + tdSql.execute("create table t2 using supt tags('shanghai', 2, 0, '拖拉机')") + + tdLog.printNoPrefix("==========step2:insert data") + for i in range(10): + tdSql.execute( + f"insert into t1 values (now+{i}m, {32767+i}, {20.0+i/10}, {2**31+i}, {3.4*10**38+i/10}, {127+i}, {i})" + ) + tdSql.execute( + f"insert into t2 values (now-{i}m, {-32767-i}, {20.0-i/10}, {-i-2**31}, {-i/10-3.4*10**38}, {-127-i}, {-i})" + ) + tdSql.execute( + f"insert into t1 values (now+11m, {2**31-1}, {pow(10,37)*34}, {pow(2,63)-1}, {1.7*10**308}, 32767, 127)" + ) + tdSql.execute( + f"insert into t2 values (now-11m, {1-2**31}, {-3.4*10**38}, {1-2**63}, {-1.7*10**308}, -32767, -127)" + ) + tdSql.execute( + f"insert into t2 values (now-12m, null , {-3.4*10**38}, null , {-1.7*10**308}, null , null)" + ) + + tdLog.printNoPrefix("==========step3:query timestamp type") + + tdSql.query("select * from t1 where ts between now-1m and now+10m") + tdSql.checkRows(10) + tdSql.query("select * from t1 where ts between '2021-01-01 00:00:00.000' and '2121-01-01 00:00:00.000'") + tdSql.checkRows(11) + tdSql.query("select * from t1 where ts between '1969-01-01 00:00:00.000' and '1969-12-31 23:59:59.999'") + tdSql.checkRows(0) + tdSql.query("select * from t1 where ts between -2793600 and 31507199") + tdSql.checkRows(0) + tdSql.query("select * from t1 where ts between 1609430400000 and 4765104000000") + tdSql.checkRows(11) + + tdLog.printNoPrefix("==========step4:query int type") + + tdSql.query("select * from t1 where c1 between 32767 and 32776") + tdSql.checkRows(10) + tdSql.query("select * from t1 where c1 between 32766.9 and 32776.1") + tdSql.checkRows(10) + tdSql.query("select * from t1 where c1 between 32776 and 32767") + tdSql.checkRows(0) + tdSql.error("select * from t1 where c1 between 'a' and 'e'") + # tdSql.query("select * from t1 where c1 between 0x64 and 0x69") + # tdSql.checkRows(6) + tdSql.error("select * from t1 where c1 not between 100 and 106") + tdSql.query(f"select * from t1 where c1 between {2**31-2} and {2**31+1}") + tdSql.checkRows(1) + tdSql.error(f"select * from t2 where c1 between null and {1-2**31}") + # tdSql.checkRows(3) + tdSql.query(f"select * from t2 where c1 between {-2**31} and {1-2**31}") + tdSql.checkRows(1) + + tdLog.printNoPrefix("==========step5:query float type") + + tdSql.query("select * from t1 where c2 between 20.0 and 21.0") + tdSql.checkRows(10) + tdSql.query(f"select * from t1 where c2 between {-3.4*10**38-1} and {3.4*10**38+1}") + tdSql.checkRows(11) + tdSql.query("select * from t1 where c2 between 21.0 and 20.0") + tdSql.checkRows(0) + tdSql.error("select * from t1 where c2 between 'DC3' and 'SYN'") + tdSql.error("select * from t1 where c2 not between 0.1 and 0.2") + # tdSql.query(f"select * from t1 where c2 between {pow(10,38)*3.4} and {pow(10,38)*3.4+1}") + # tdSql.checkRows(1) + tdSql.query(f"select * from t2 where c2 between {-3.4*10**38-1} and {-3.4*10**38}") + tdSql.checkRows(0) + tdSql.error(f"select * from t2 where c2 between null and {-3.4*10**38}") + # tdSql.checkRows(3) + + tdLog.printNoPrefix("==========step6:query bigint type") + + tdSql.query(f"select * from t1 where c3 between {2**31} and {2**31+10}") + tdSql.checkRows(10) + tdSql.error(f"select * from t1 where c3 between {-2**63} and {2**63}") + # tdSql.checkRows(11) + tdSql.query(f"select * from t1 where c3 between {2**31+10} and {2**31}") + tdSql.checkRows(0) + tdSql.error("select * from t1 where c3 between 'a' and 'z'") + tdSql.error("select * from t1 where c3 not between 1 and 2") + tdSql.query(f"select * from t1 where c3 between {2**63-2} and {2**63-1}") + tdSql.checkRows(1) + tdSql.error(f"select * from t2 where c3 between {-2**63} and {1-2**63}") + # tdSql.checkRows(3) + tdSql.error(f"select * from t2 where c3 between null and {1-2**63}") + # tdSql.checkRows(2) + + tdLog.printNoPrefix("==========step7:query double type") + + tdSql.query(f"select * from t1 where c4 between {3.4*10**38} and {3.4*10**38+10}") + tdSql.checkRows(10) + tdSql.query(f"select * from t1 where c4 between {1.7*10**308+1} and {1.7*10**308+2}") + # 因为精度原因,在超出bigint边界后,数值不能进行准确的判断 + # tdSql.checkRows(0) + tdSql.query(f"select * from t1 where c4 between {3.4*10**38+10} and {3.4*10**38}") + # tdSql.checkRows(0) + tdSql.error("select * from t1 where c4 between 'a' and 'z'") + tdSql.error("select * from t1 where c4 not between 1 and 2") + tdSql.query(f"select * from t1 where c4 between {1.7*10**308} and {1.7*10**308+1}") + tdSql.checkRows(1) + tdSql.query(f"select * from t2 where c4 between {-1.7*10**308-1} and {-1.7*10**308}") + # tdSql.checkRows(3) + tdSql.error(f"select * from t2 where c4 between null and {-1.7*10**308}") + # tdSql.checkRows(3) + + tdLog.printNoPrefix("==========step8:query smallint type") + + tdSql.query("select * from t1 where c5 between 127 and 136") + tdSql.checkRows(10) + tdSql.query("select * from t1 where c5 between 126.9 and 135.9") + tdSql.checkRows(9) + tdSql.query("select * from t1 where c5 between 136 and 127") + tdSql.checkRows(0) + tdSql.error("select * from t1 where c5 between '~' and 'ˆ'") + tdSql.error("select * from t1 where c5 not between 1 and 2") + tdSql.query("select * from t1 where c5 between 32767 and 32768") + tdSql.checkRows(1) + tdSql.query("select * from t2 where c5 between -32768 and -32767") + tdSql.checkRows(1) + tdSql.error("select * from t2 where c5 between null and -32767") + # tdSql.checkRows(1) + + tdLog.printNoPrefix("==========step9:query tinyint type") + + tdSql.query("select * from t1 where c6 between 0 and 9") + tdSql.checkRows(10) + tdSql.query("select * from t1 where c6 between -1.1 and 8.9") + tdSql.checkRows(9) + tdSql.query("select * from t1 where c6 between 9 and 0") + tdSql.checkRows(0) + tdSql.error("select * from t1 where c6 between 'NUL' and 'HT'") + tdSql.error("select * from t1 where c6 not between 1 and 2") + tdSql.query("select * from t1 where c6 between 127 and 128") + tdSql.checkRows(1) + tdSql.query("select * from t2 where c6 between -128 and -127") + tdSql.checkRows(1) + tdSql.error("select * from t2 where c6 between null and -127") + # tdSql.checkRows(3) + + tdLog.printNoPrefix("==========step10:invalid query type") + + tdSql.query("select * from supt where location between 'beijing' and 'shanghai'") + tdSql.checkRows(23) + # 非0值均解析为1,因此"between 负值 and o"解析为"between 1 and 0" + tdSql.query("select * from supt where isused between 0 and 1") + tdSql.checkRows(23) + tdSql.query("select * from supt where isused between -1 and 0") + tdSql.checkRows(0) + tdSql.error("select * from supt where isused between false and true") + tdSql.query("select * from supt where family between '拖拉机' and '自行车'") + tdSql.checkRows(23) + + tdLog.printNoPrefix("==========step11:query HEX/OCT/BIN type") + + tdSql.error("select * from t1 where c6 between 0x7f and 0x80") # check filter HEX + tdSql.error("select * from t1 where c6 between 0b1 and 0b11111") # check filter BIN + tdSql.error("select * from t1 where c6 between 0b1 and 0x80") + tdSql.error("select * from t1 where c6=0b1") + tdSql.error("select * from t1 where c6=0x1") + # 八进制数据会按照十进制数据进行判定 + tdSql.query("select * from t1 where c6 between 01 and 0200") # check filter OCT + tdSql.checkRows(10) + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/query/queryCnameDisplay.py b/tests/pytest/query/queryCnameDisplay.py new file mode 100644 index 0000000000000000000000000000000000000000..186b3bfe1d1d06c4210c950fff097cb37a73d5df --- /dev/null +++ b/tests/pytest/query/queryCnameDisplay.py @@ -0,0 +1,111 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- +import string +import random +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getLongName(self, len, mode = "mixed"): + """ + generate long str + """ + chars = ''.join(random.choice(string.ascii_letters.lower()) for i in range(len)) + return chars + + def checkRegularTableCname(self): + """ + check regular table cname + """ + # len(colName) <=64, generate cname list and make first param = 63 and second param = 65 + cname_list = [] + for i in range(10): + cname_list.append(self.getLongName(64)) + cname_list[0] = self.getLongName(63) + cname_list[1] = self.getLongName(65) + # create table and insert data + tdSql.execute("CREATE TABLE regular_table_cname_check (ts timestamp, pi1 int, pi2 bigint, pf1 float, pf2 double, ps1 binary(10), pi3 smallint, pi4 tinyint, pb1 bool, ps2 nchar(20))") + tdSql.execute('insert into regular_table_cname_check values (now, 1, 2, 1.1, 2.2, "a", 1, 1, true, "aa");') + tdSql.execute('insert into regular_table_cname_check values (now, 2, 3, 1.2, 2.3, "b", 2, 1, false, "aa");') + tdSql.execute('insert into regular_table_cname_check values (now, 3, 4, 1.3, 2.4, "c", 1, 3, true, "bb");') + + # select as cname with cname_list + sql_seq = f'select count(ts) as {cname_list[0]}, sum(pi1) as {cname_list[1]}, avg(pi2) as {cname_list[2]}, count(pf1) as {cname_list[3]}, count(pf2) as {cname_list[4]}, count(ps1) as {cname_list[5]}, min(pi3) as {cname_list[6]}, max(pi4) as {cname_list[7]}, count(pb1) as {cname_list[8]}, count(ps2) as {cname_list[9]} from regular_table_cname_check' + sql_seq_no_as = sql_seq.replace(' as ', ' ') + print(sql_seq) + print(sql_seq_no_as) + res = tdSql.getColNameList(sql_seq) + res_no_as = tdSql.getColNameList(sql_seq_no_as) + # cname[1] > 64, it is expected to be equal to 64 + cname_list_1_expected = cname_list[1][:-1] + cname_list[1] = cname_list_1_expected + checkColNameList = tdSql.checkColNameList(res, cname_list) + checkColNameList = tdSql.checkColNameList(res_no_as, cname_list) + + def checkSuperTableCname(self): + """ + check super table cname + """ + # len(colName) <=64, generate cname list and make first param = 63 and second param = 65 + cname_list = [] + for i in range(19): + cname_list.append(self.getLongName(64)) + cname_list[0] = self.getLongName(63) + cname_list[1] = self.getLongName(65) + + # create table and insert data + tdSql.execute("create table super_table_cname_check (ts timestamp, pi1 int, pi2 bigint, pf1 float, pf2 double, ps1 binary(10), pi3 smallint, pi4 tinyint, pb1 bool, ps2 nchar(20)) tags (si1 int, si2 bigint, sf1 float, sf2 double, ss1 binary(10), si3 smallint, si4 tinyint, sb1 bool, ss2 nchar(20));") + tdSql.execute('create table st1 using super_table_cname_check tags (1, 2, 1.1, 2.2, "a", 1, 1, true, "aa");') + tdSql.execute('insert into st1 values (now, 1, 2, 1.1, 2.2, "a", 1, 1, true, "aa");') + tdSql.execute('insert into st1 values (now, 1, 1, 1.4, 2.3, "b", 3, 2, true, "aa");') + tdSql.execute('insert into st1 values (now, 1, 2, 1.1, 2.2, "a", 1, 1, false, "bb");') + + # select as cname with cname_list + sql_seq1 = f'select count(ts) as {cname_list[0]}, sum(pi1) as {cname_list[1]}, avg(pi2) as {cname_list[2]}, count(pf1) as {cname_list[3]}, count(pf2) as {cname_list[4]}, count(ps1) as {cname_list[5]}, min(pi3) as {cname_list[6]}, max(pi4) as {cname_list[7]}, count(pb1) as {cname_list[8]}, count(ps2) as {cname_list[9]} from super_table_cname_check' + sql_seq2 = f'select count(si1) as {cname_list[10]}, count(si2) as {cname_list[11]}, count(sf1) as {cname_list[12]}, count(sf2) as {cname_list[13]}, count(ss1) as {cname_list[14]}, count(si3) as {cname_list[15]}, count(si4) as {cname_list[16]}, count(sb1) as {cname_list[17]}, count(ss2) as {cname_list[18]} from super_table_cname_check' + sql_seq_no_as1 = sql_seq1.replace(' as ', ' ') + sql_seq_no_as2 = sql_seq2.replace(' as ', ' ') + res1 = tdSql.getColNameList(sql_seq1) + res2 = tdSql.getColNameList(sql_seq2) + res_no_as1 = tdSql.getColNameList(sql_seq_no_as1) + res_no_as2 = tdSql.getColNameList(sql_seq_no_as2) + + # cname[1] > 64, it is expected to be equal to 64 + cname_list_1_expected = cname_list[1][:-1] + cname_list[1] = cname_list_1_expected + tdSql.checkColNameList(res1, cname_list[:10]) + tdSql.checkColNameList(res2, cname_list[10:]) + tdSql.checkColNameList(res_no_as1, cname_list[:10]) + tdSql.checkColNameList(res_no_as2, cname_list[10:]) + + def run(self): + tdSql.prepare() + self.checkRegularTableCname() + self.checkSuperTableCname() + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) + diff --git a/tests/pytest/query/queryConnection.py b/tests/pytest/query/queryConnection.py new file mode 100644 index 0000000000000000000000000000000000000000..ed05b5e6bda9d60701d6f957b00311e77aebe356 --- /dev/null +++ b/tests/pytest/query/queryConnection.py @@ -0,0 +1,52 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdSql.execute( + "create table if not exists st (ts timestamp, tagtype int) tags(dev nchar(50))") + tdSql.execute( + 'CREATE TABLE if not exists dev_001 using st tags("dev_01")') + tdSql.execute( + 'CREATE TABLE if not exists dev_002 using st tags("dev_02")') + + tdSql.execute( + """INSERT INTO dev_001(ts, tagtype) VALUES('2020-05-13 10:00:00.000', 1), + ('2020-05-13 10:00:00.001', 1) + dev_002 VALUES('2020-05-13 10:00:00.001', 1)""") + + for i in range(10): + for j in range(1000): + tdSql.query("select * from db.st") + tdLog.sleep(10) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/queryCountCSVData.py b/tests/pytest/query/queryCountCSVData.py new file mode 100644 index 0000000000000000000000000000000000000000..6c73425faec24afeed0c8a5a168f575ec182c771 --- /dev/null +++ b/tests/pytest/query/queryCountCSVData.py @@ -0,0 +1,71 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +from util.dnodes import tdDnodes + + +class TDTestCase: + """ + create table and insert data from disordered.csv which timestamp is disordered and + ordered.csv which timestamp is ordered. + then execute 'select count(*) from table xx;' + """ + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + print("==============step1") + tdSql.execute("create database if not exists demo;"); + tdSql.execute("use demo;") + tdSql.execute("CREATE TABLE IF NOT EXISTS test1 (ts TIMESTAMP, ValueID int, " + "VariantValue float, Quality int, Flags int);") + tdSql.execute("CREATE TABLE IF NOT EXISTS test2 (ts TIMESTAMP, ValueID int, " + "VariantValue float, Quality int, Flags int);") + ordered_csv = __file__.split('query')[0] + 'test_data/ordered.csv' + disordered_csv = __file__.split('query')[0] + 'test_data/disordered.csv' + + tdSql.execute(" insert into test1 file '{file}';".format(file=ordered_csv)) + tdSql.execute(" insert into test2 file '{file}';".format(file=disordered_csv)) + print("==============insert into test1 and test2 form test file") + + + print("==============step2") + tdSql.query('select * from test1;') + with open(ordered_csv) as f1: + num1 = len(f1.readlines()) + tdSql.checkRows(num1) + + + tdSql.query('select * from test2;') + with open(disordered_csv) as f2: + num2 = len(f2.readlines()) + tdSql.checkRows(num2) + print("=============execute select count(*) from xxx") + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/queryDiffColsOr.py b/tests/pytest/query/queryDiffColsOr.py new file mode 100644 index 0000000000000000000000000000000000000000..feeab84a7ec577c9b48f19416400bcc7b348d543 --- /dev/null +++ b/tests/pytest/query/queryDiffColsOr.py @@ -0,0 +1,545 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- +from copy import deepcopy +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +from util.common import tdCom + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def insertData(self, tb_name): + insert_sql_list = [f'insert into {tb_name} values ("2021-01-01 12:00:00", 1, 1, 1, 3, 1.1, 1.1, "binary", "nchar", true, 1)', + f'insert into {tb_name} values ("2021-01-05 12:00:00", 2, 2, 1, 3, 1.1, 1.1, "binary", "nchar", true, 2)', + f'insert into {tb_name} values ("2021-01-07 12:00:00", 1, 3, 1, 2, 1.1, 1.1, "binary", "nchar", true, 3)', + f'insert into {tb_name} values ("2021-01-09 12:00:00", 1, 2, 4, 3, 1.1, 1.1, "binary", "nchar", true, 4)', + f'insert into {tb_name} values ("2021-01-11 12:00:00", 1, 2, 5, 5, 1.1, 1.1, "binary", "nchar", true, 5)', + f'insert into {tb_name} values ("2021-01-13 12:00:00", 1, 2, 1, 3, 6.6, 1.1, "binary", "nchar", true, 6)', + f'insert into {tb_name} values ("2021-01-15 12:00:00", 1, 2, 1, 3, 1.1, 7.7, "binary", "nchar", true, 7)', + f'insert into {tb_name} values ("2021-01-17 12:00:00", 1, 2, 1, 3, 1.1, 1.1, "binary8", "nchar", true, 8)', + f'insert into {tb_name} values ("2021-01-19 12:00:00", 1, 2, 1, 3, 1.1, 1.1, "binary", "nchar9", true, 9)', + f'insert into {tb_name} values ("2021-01-21 12:00:00", 1, 2, 1, 3, 1.1, 1.1, "binary", "nchar", false, 10)', + f'insert into {tb_name} values ("2021-01-23 12:00:00", 1, 3, 1, 3, 1.1, 1.1, Null, Null, false, 11)' + ] + for sql in insert_sql_list: + tdSql.execute(sql) + + def initTb(self): + tdCom.cleanTb() + tb_name = tdCom.getLongName(8, "letters") + tdSql.execute( + f"CREATE TABLE {tb_name} (ts timestamp, c1 tinyint, c2 smallint, c3 int, c4 bigint, c5 float, c6 double, c7 binary(100), c8 nchar(200), c9 bool, c10 int)") + self.insertData(tb_name) + return tb_name + + def initStb(self): + tdCom.cleanTb() + tb_name = tdCom.getLongName(8, "letters") + tdSql.execute( + f"CREATE TABLE {tb_name} (ts timestamp, c1 tinyint, c2 smallint, c3 int, c4 bigint, c5 float, c6 double, c7 binary(100), c8 nchar(200), c9 bool, c10 int) tags (t1 tinyint, t2 smallint, t3 int, t4 bigint, t5 float, t6 double, t7 binary(100), t8 nchar(200), t9 bool, t10 int)") + tdSql.execute( + f'CREATE TABLE {tb_name}_sub using {tb_name} tags (1, 1, 1, 3, 1.1, 1.1, "binary", "nchar", true, 1)') + self.insertData(f'{tb_name}_sub') + return tb_name + + def queryLastC10(self, query_sql, multi=False): + if multi: + res = tdSql.query(query_sql.replace('c10', 'last(*)'), True) + else: + res = tdSql.query(query_sql.replace('*', 'last(*)'), True) + return int(res[0][-1]) + + def queryFullColType(self, tb_name): + ## ts + query_sql = f'select * from {tb_name} where ts > "2021-01-11 12:00:00" or ts < "2021-01-13 12:00:00"' + tdSql.query(query_sql) + tdSql.checkRows(11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + ## != or + query_sql = f'select * from {tb_name} where c1 != 1 or c2 = 3' + tdSql.query(query_sql) + tdSql.checkRows(3) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + ## <> or + query_sql = f'select * from {tb_name} where c1 <> 1 or c3 = 3' + tdSql.query(query_sql) + tdSql.checkRows(1) + tdSql.checkEqual(self.queryLastC10(query_sql), 2) + + ## >= or + query_sql = f'select * from {tb_name} where c1 >= 2 or c3 = 4' + tdSql.query(query_sql) + tdSql.checkRows(2) + tdSql.checkEqual(self.queryLastC10(query_sql), 4) + + ## <= or + query_sql = f'select * from {tb_name} where c1 <= 1 or c3 = 4' + tdSql.query(query_sql) + tdSql.checkRows(10) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + ## <> or is Null + query_sql = f'select * from {tb_name} where c1 <> 1 or c7 is Null' + tdSql.query(query_sql) + tdSql.checkRows(2) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + ## > or is not Null + query_sql = f'select * from {tb_name} where c2 > 2 or c8 is not Null' + tdSql.query(query_sql) + tdSql.checkRows(11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + ## > or < or >= or <= or != or <> or = Null + query_sql = f'select * from {tb_name} where c1 > 1 or c2 < 2 or c3 >= 4 or c4 <= 2 or c5 != 1.1 or c6 <> 1.1 or c7 is Null' + tdSql.query(query_sql) + tdSql.checkRows(8) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + ## tiny small int big or + query_sql = f'select * from {tb_name} where c1 = 2 or c2 = 3 or c3 = 4 or c4 = 5' + tdSql.query(query_sql) + tdSql.checkRows(5) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + ## float double binary nchar bool or + query_sql = f'select * from {tb_name} where c5=6.6 or c6=7.7 or c7="binary8" or c8="nchar9" or c9=false' + tdSql.query(query_sql) + tdSql.checkRows(6) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + ## all types or + query_sql = f'select * from {tb_name} where c1=2 or c2=3 or c3=4 or c4=5 or c5=6.6 or c6=7.7 or c7="binary8" or c8="nchar9" or c9=false' + tdSql.query(query_sql) + tdSql.checkRows(10) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + def queryMultiExpression(self, tb_name): + ## condition_A and condition_B or condition_C (> < >=) + query_sql = f'select * from {tb_name} where c1 > 2 and c2 < 4 or c3 >= 4' + tdSql.query(query_sql) + tdSql.checkRows(2) + tdSql.checkEqual(self.queryLastC10(query_sql), 5) + + ## (condition_A and condition_B) or condition_C (<= != <>) + query_sql = f'select * from {tb_name} where (c1 <= 1 and c2 != 2) or c4 <> 3' + tdSql.query(query_sql) + tdSql.checkRows(4) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + ## condition_A and (condition_B or condition_C) (Null not Null) + query_sql = f'select * from {tb_name} where c1 is not Null and (c6 = 7.7 or c8 is Null)' + tdSql.query(query_sql) + tdSql.checkRows(2) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + ## condition_A or condition_B and condition_C (> < >=) + query_sql = f'select * from {tb_name} where c1 > 2 or c2 < 4 and c3 >= 4' + tdSql.query(query_sql) + tdSql.checkRows(2) + tdSql.checkEqual(self.queryLastC10(query_sql), 5) + + ## (condition_A or condition_B) and condition_C (<= != <>) + query_sql = f'select * from {tb_name} where (c1 <= 1 or c2 != 2) and c4 <> 3' + tdSql.query(query_sql) + tdSql.checkRows(2) + tdSql.checkEqual(self.queryLastC10(query_sql), 5) + + ## condition_A or (condition_B and condition_C) (Null not Null) + query_sql = f'select * from {tb_name} where c6 >= 7.7 or (c1 is not Null and c3 =5)' + tdSql.query(query_sql) + tdSql.checkRows(2) + tdSql.checkEqual(self.queryLastC10(query_sql), 7) + + ## condition_A or (condition_B and condition_C) or condition_D (> != < Null) + query_sql = f'select * from {tb_name} where c1 != 1 or (c2 >2 and c3 < 1) or c7 is Null' + tdSql.query(query_sql) + tdSql.checkRows(2) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + ## condition_A and (condition_B or condition_C) and condition_D (>= = <= not Null) + query_sql = f'select * from {tb_name} where c4 >= 4 and (c1 = 2 or c5 <= 1.1) and c7 is not Null' + tdSql.query(query_sql) + tdSql.checkRows(1) + tdSql.checkEqual(self.queryLastC10(query_sql), 5) + + ## (condition_A and condition_B) or (condition_C or condition_D) (Null >= > =) + query_sql = f'select * from {tb_name} where (c8 is Null and c1 >= 1) or (c3 > 3 or c4 =2)' + tdSql.query(query_sql) + tdSql.checkRows(4) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + ## (condition_A or condition_B) or condition_C or (condition_D and condition_E) (>= <= = not Null <>) + query_sql = f'select * from {tb_name} where (c1 >= 2 or c2 <= 1) or c3 = 4 or (c7 is not Null and c6 <> 1.1)' + tdSql.query(query_sql) + tdSql.checkRows(4) + tdSql.checkEqual(self.queryLastC10(query_sql), 7) + + ## condition_A or (condition_B and condition_C) or (condition_D and condition_E) and condition_F + query_sql = f'select * from {tb_name} where c1 != 1 or (c2 <= 1 and c3 <4) or (c3 >= 4 or c7 is not Null) and c9 <> true' + tdSql.query(query_sql) + tdSql.checkRows(3) + tdSql.checkEqual(self.queryLastC10(query_sql), 10) + + ## (condition_A or (condition_B and condition_C) or (condition_D and condition_E)) and condition_F + query_sql = f'select * from {tb_name} where (c1 != 1 or (c2 <= 2 and c3 >= 4) or (c3 >= 4 or c7 is not Null)) and c9 != false' + tdSql.query(query_sql) + tdSql.checkRows(9) + tdSql.checkEqual(self.queryLastC10(query_sql), 9) + + ## (condition_A or condition_B) or (condition_C or condition_D) and (condition_E or condition_F or condition_G) + query_sql = f'select * from {tb_name} where c1 != 1 or (c2 <= 3 and c3 > 4) and c3 <= 5 and (c7 is not Null and c9 != false)' + tdSql.query(query_sql) + tdSql.checkRows(2) + tdSql.checkEqual(self.queryLastC10(query_sql), 5) + + def queryMultiIn(self, tb_name): + ## in and in + query_sql = f'select * from {tb_name} where c7 in ("binary") and c8 in ("nchar")' + tdSql.query(query_sql) + tdSql.checkRows(8) + tdSql.checkEqual(self.queryLastC10(query_sql), 10) + + ## in or in + query_sql = f'select * from {tb_name} where c1 in (2, 4) or c2 in (1, 4)' + tdSql.query(query_sql) + tdSql.checkRows(2) + tdSql.checkEqual(self.queryLastC10(query_sql), 2) + + ## in and in or condition_A + query_sql = f'select * from {tb_name} where c7 in ("binary") and c8 in ("nchar") or c10 != 10' + tdSql.query(query_sql) + tdSql.checkRows(11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + ## in or in and condition_A + query_sql = f'select * from {tb_name} where c7 in ("binary") or c8 in ("nchar") and c10 != 10' + tdSql.query(query_sql) + tdSql.checkRows(10) + tdSql.checkEqual(self.queryLastC10(query_sql), 10) + + ## in or in or condition_A + query_sql = f'select * from {tb_name} where c1 in (2, 4) or c2 in (3, 4) or c9 != true' + tdSql.query(query_sql) + tdSql.checkRows(4) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + ## in or in or in or in + query_sql = f'select * from {tb_name} where c1 in (2, 4) or c2 in (3, 4) or c9 in (false) or c10 in (5, 6 ,22)' + tdSql.query(query_sql) + tdSql.checkRows(6) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + ## in or in and in or in + query_sql = f'select * from {tb_name} where c1 in (2, 4) or c2 in (3, 4) and c9 in (false) or c10 in (5, 6 ,22)' + tdSql.query(query_sql) + tdSql.checkRows(4) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + ## condition_A or in or condition_B and in + query_sql = f'select * from {tb_name} where c1 = 2 or c2 in (2, 4) and c9 = false or c10 in (6 ,22)' + tdSql.query(query_sql) + tdSql.checkRows(3) + tdSql.checkEqual(self.queryLastC10(query_sql), 10) + + ## in and condition_A or in and in and condition_B + query_sql = f'select * from {tb_name} where c1 in (2, 3) and c2 <> 3 or c10 <= 4 and c10 in (4 ,22) and c9 != false' + tdSql.query(query_sql) + tdSql.checkRows(2) + tdSql.checkEqual(self.queryLastC10(query_sql), 4) + + ## (in and condition_A or in) and in and condition_B + query_sql = f'select * from {tb_name} where (c1 in (2, 3) and c2 <> 3 or c10 <= 4) and c10 in (4 ,22) and c9 != false' + tdSql.query(query_sql) + tdSql.checkRows(1) + tdSql.checkEqual(self.queryLastC10(query_sql), 4) + + def queryMultiLike(self, tb_name): + ## like and like + query_sql = f'select * from {tb_name} where c7 like "bi%" and c8 like ("ncha_")' + tdSql.query(query_sql) + tdSql.checkRows(9) + tdSql.checkEqual(self.queryLastC10(query_sql), 10) + + ## like or like + query_sql = f'select * from {tb_name} where c7 like "binar12345" or c8 like "nchar_"' + tdSql.query(query_sql) + tdSql.checkRows(1) + tdSql.checkEqual(self.queryLastC10(query_sql), 9) + + ## like and like or condition_A + query_sql = f'select * from {tb_name} where c7 like "binary_" and c8 like "ncha_" or c1 != 1' + tdSql.query(query_sql) + tdSql.checkRows(2) + tdSql.checkEqual(self.queryLastC10(query_sql), 8) + + ## like or like and condition_A + query_sql = f'select * from {tb_name} where c7 like ("binar_") or c8 like ("nchar_") and c10 != 8' + tdSql.query(query_sql) + tdSql.checkRows(9) + tdSql.checkEqual(self.queryLastC10(query_sql), 10) + + ## like or like or condition_A + query_sql = f'select * from {tb_name} where c7 like ("binary_") or c8 like ("nchar_") or c10 = 6' + tdSql.query(query_sql) + tdSql.checkRows(3) + tdSql.checkEqual(self.queryLastC10(query_sql), 9) + + ## like or like or like or like + query_sql = f'select * from {tb_name} where c7 like ("binary_") or c8 like ("nchar_") or c10 = 6 or c7 is Null' + tdSql.query(query_sql) + tdSql.checkRows(4) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + ## like or like and like or like + query_sql = f'select * from {tb_name} where c7 like ("binary_") or c8 like ("ncha_") and c10 = 6 or c10 = 9' + tdSql.query(query_sql) + tdSql.checkRows(3) + tdSql.checkEqual(self.queryLastC10(query_sql), 9) + + ## condition_A or like or condition_B and like + query_sql = f'select * from {tb_name} where c1 = 2 or c7 like "binary_" or c10 = 3 and c8 like "ncha%"' + tdSql.query(query_sql) + tdSql.checkRows(3) + tdSql.checkEqual(self.queryLastC10(query_sql), 8) + + ## like and condition_A or like and like and condition_B + query_sql = f'select * from {tb_name} where c7 like "bin%" and c2 = 3 or c10 <= 4 and c7 like "binar_" and c8 like "ncha_"' + tdSql.query(query_sql) + tdSql.checkRows(4) + tdSql.checkEqual(self.queryLastC10(query_sql), 4) + + ## (like and condition_A or like) and like and condition_B + query_sql = f'select * from {tb_name} where (c7 like "bin%" and c2 = 3 or c8 like "nchar_") and c7 like "binar_" and c9 != false' + tdSql.query(query_sql) + tdSql.checkRows(2) + tdSql.checkEqual(self.queryLastC10(query_sql), 9) + + def queryPreCal(self, tb_name): + ## avg sum condition_A or condition_B + query_sql = f'select avg(c3), sum(c3) from {tb_name} where c10 = 5 or c8 is Null' + res = tdSql.query(query_sql, True)[0] + tdSql.checkEqual(int(res[0]), 3) + tdSql.checkEqual(int(res[1]), 6) + + ## avg sum condition_A or condition_B or condition_C + query_sql = f'select avg(c3), sum(c3) from {tb_name} where c10 = 4 or c8 is Null or c9 = false ' + res = tdSql.query(query_sql, True)[0] + tdSql.checkEqual(int(res[0]), 2) + tdSql.checkEqual(int(res[1]), 6) + + ## count avg sum condition_A or condition_B or condition_C interval + query_sql = f'select count(*), avg(c3), sum(c3) from {tb_name} where c10 = 4 or c8 is Null or c9 = false interval(16d)' + res = tdSql.query(query_sql, True) + tdSql.checkRows(2) + tdSql.checkEqual(int(res[0][1]), 1) + tdSql.checkEqual(int(res[0][2]), 4) + tdSql.checkEqual(int(res[0][3]), 4) + tdSql.checkEqual(int(res[1][1]), 2) + tdSql.checkEqual(int(res[1][2]), 1) + tdSql.checkEqual(int(res[1][3]), 2) + + ## count avg sum condition_A or condition_B or in and like or condition_C interval + query_sql = f'select count(*), sum(c3) from {tb_name} where c10 = 4 or c8 is Null or c2 in (1, 2) and c7 like "binary_" or c1 <> 1 interval(16d)' + res = tdSql.query(query_sql, True) + tdSql.checkRows(2) + tdSql.checkEqual(int(res[0][1]), 2) + tdSql.checkEqual(int(res[0][2]), 5) + tdSql.checkEqual(int(res[1][1]), 2) + tdSql.checkEqual(int(res[1][2]), 2) + + def queryMultiTb(self, tb_name): + ## select from (condition_A or condition_B) + query_sql = f'select c10 from (select * from {tb_name} where c1 >1 or c2 >=3)' + res = tdSql.query(query_sql, True) + tdSql.checkRows(3) + tdSql.checkEqual(int(res[2][0]), 11) + + ## select from (condition_A or condition_B) where condition_A or condition_B + query_sql = f'select c10 from (select * from {tb_name} where c1 >1 or c2 >=3) where c1 =2 or c4 = 2' + res = tdSql.query(query_sql, True) + tdSql.checkRows(2) + tdSql.checkEqual(int(res[1][0]), 3) + + ## select from (condition_A or condition_B and like and in) where condition_A or condition_B or like and in + query_sql = f'select c10 from (select * from {tb_name} where c1 >1 or c2 = 2 and c7 like "binar_" and c4 in (3, 5)) where c1 != 2 or c3 = 1 or c8 like "ncha_" and c9 in (true)' + res = tdSql.query(query_sql, True) + tdSql.checkRows(7) + tdSql.checkEqual(int(res[6][0]), 10) + + ## select count avg sum from (condition_A or condition_B and like and in) where condition_A or condition_B or like and in interval + query_sql = f'select count(*), avg(c6), sum(c3) from (select * from {tb_name} where c1 >1 or c2 = 2 and c7 like "binar_" and c4 in (3, 5)) where c1 != 2 or c3 = 1 or c8 like "ncha_" and c9 in (true) interval(8d)' + res = tdSql.query(query_sql, True) + tdSql.checkRows(3) + tdSql.checkEqual(int(res[0][1]), 3) + tdSql.checkEqual(int(res[0][2]), 1) + tdSql.checkEqual(int(res[0][3]), 10) + tdSql.checkEqual(int(res[1][1]), 3) + tdSql.checkEqual(int(res[1][2]), 3) + tdSql.checkEqual(int(res[1][3]), 3) + tdSql.checkEqual(int(res[2][1]), 1) + tdSql.checkEqual(int(res[2][2]), 1) + tdSql.checkEqual(int(res[2][3]), 1) + + ## cname + query_sql = f'select c10 from (select * from {tb_name} where c1 >1 or c2 = 2 and c7 like "binar_" and c4 in (3, 5)) a where a.c1 != 2 or a.c3 = 1 or a.c8 like "ncha_" and a.c9 in (true)' + res = tdSql.query(query_sql, True) + tdSql.checkRows(7) + tdSql.checkEqual(int(res[6][0]), 10) + + ## multi cname + query_sql = f'select b.c10 from (select * from {tb_name} where c9 = true or c2 = 2) a, (select * from {tb_name} where c7 like "binar_" or c4 in (3, 5)) b where a.ts = b.ts' + res = tdSql.query(query_sql, True) + tdSql.checkRows(10) + tdSql.checkEqual(int(res[9][0]), 10) + + def checkTbColTypeOperator(self): + ''' + Ordinary table full column type and operator + ''' + tb_name = self.initTb() + self.queryFullColType(tb_name) + + def checkStbColTypeOperator(self): + ''' + Super table full column type and operator + ''' + tb_name = self.initStb() + self.queryFullColType(tb_name) + + def checkTbMultiExpression(self): + ''' + Ordinary table multiExpression + ''' + tb_name = self.initTb() + self.queryMultiExpression(tb_name) + + def checkStbMultiExpression(self): + ''' + Super table multiExpression + ''' + tb_name = self.initStb() + self.queryMultiExpression(tb_name) + + def checkTbMultiIn(self): + ''' + Ordinary table multiIn + ''' + tb_name = self.initTb() + self.queryMultiIn(tb_name) + + def checkStbMultiIn(self): + ''' + Super table multiIn + ''' + tb_name = self.initStb() + self.queryMultiIn(tb_name) + + def checkTbMultiLike(self): + ''' + Ordinary table multiLike + ''' + tb_name = self.initTb() + self.queryMultiLike(tb_name) + + def checkStbMultiLike(self): + ''' + Super table multiLike + ''' + tb_name = self.initStb() + self.queryMultiLike(tb_name) + + def checkTbPreCal(self): + ''' + Ordinary table precal + ''' + tb_name = self.initTb() + self.queryPreCal(tb_name) + + def checkStbPreCal(self): + ''' + Super table precal + ''' + tb_name = self.initStb() + self.queryPreCal(tb_name) + + def checkMultiTb(self): + ''' + test "or" in multi ordinary table + ''' + tb_name = self.initTb() + self.queryMultiTb(tb_name) + + def checkMultiStb(self): + ''' + test "or" in multi super table + ''' + tb_name = self.initStb() + self.queryMultiTb(tb_name) + + + # tb_name1 = tdCom.getLongName(8, "letters") + # tb_name2 = tdCom.getLongName(8, "letters") + # tb_name3 = tdCom.getLongName(8, "letters") + # tdSql.execute( + # f"CREATE TABLE {tb_name1} (ts timestamp, c1 tinyint, c2 smallint, c3 int)") + # tdSql.execute( + # f"CREATE TABLE {tb_name2} (ts timestamp, c1 tinyint, c2 smallint, c3 int)") + # tdSql.execute( + # f"CREATE TABLE {tb_name3} (ts timestamp, c1 tinyint, c2 smallint, c3 int)") + # insert_sql_list = [f'insert into {tb_name1} values ("2021-01-01 12:00:00", 1, 5, 1)', + # f'insert into {tb_name1} values ("2021-01-03 12:00:00", 2, 4, 1)', + # f'insert into {tb_name1} values ("2021-01-05 12:00:00", 3, 2, 1)', + # f'insert into {tb_name2} values ("2021-01-01 12:00:00", 4, 2, 1)', + # f'insert into {tb_name2} values ("2021-01-02 12:00:00", 5, 1, 1)', + # f'insert into {tb_name2} values ("2021-01-04 12:00:00", 1, 2, 1)', + # f'insert into {tb_name3} values ("2021-01-02 12:00:00", 4, 2, 1)', + # f'insert into {tb_name3} values ("2021-01-06 12:00:00", 5, 1, 1)', + # f'insert into {tb_name3} values ("2021-01-07 12:00:00", 1, 2, 1)', + # ] + # for sql in insert_sql_list: + # tdSql.execute(sql) + # tdSql.query( + # f'select * from {tb_name1} t1, {tb_name2}, {tb_name3} t3 t2 where (t1.ts=t2.ts or t2.ts=t3.ts)') + # tdSql.checkRows(4) + + + def run(self): + tdSql.prepare() + self.checkTbColTypeOperator() + self.checkStbColTypeOperator() + self.checkTbMultiExpression() + self.checkStbMultiExpression() + self.checkTbMultiIn() + self.checkStbMultiIn() + self.checkTbMultiLike() + self.checkStbMultiLike() + self.checkTbPreCal() + self.checkStbPreCal() + self.checkMultiTb() + self.checkMultiStb() + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/queryError.py b/tests/pytest/query/queryError.py new file mode 100644 index 0000000000000000000000000000000000000000..e5c468600ba56a251057f204971084fe2844a85e --- /dev/null +++ b/tests/pytest/query/queryError.py @@ -0,0 +1,78 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + print("==============step1") + tdSql.execute( + "create table if not exists st (ts timestamp, tagtype int, name nchar(16)) tags(dev nchar(50))") + tdSql.execute( + 'CREATE TABLE if not exists dev_001 using st tags("dev_01")') + tdSql.execute( + 'CREATE TABLE if not exists dev_002 using st tags("dev_02")') + + print("==============step2") + + tdSql.execute( + """INSERT INTO dev_001(ts, tagtype, name) VALUES('2020-05-13 10:00:00.000', 1, 'first'),('2020-05-13 10:00:00.001', 2, 'second'), + ('2020-05-13 10:00:00.002', 3, 'third') dev_002 VALUES('2020-05-13 10:00:00.003', 1, 'first'), ('2020-05-13 10:00:00.004', 2, 'second'), + ('2020-05-13 10:00:00.005', 3, 'third')""") + + # query first .. as .. + tdSql.error("select first(*) as one from st") + + # query last .. as .. + tdSql.error("select last(*) as latest from st") + + # query last row .. as .. + tdSql.error("select last_row as latest from st") + + # query distinct on normal colnum + #tdSql.error("select distinct tagtype from st") + + # query .. order by non-time field + tdSql.error("select * from st order by name") + + # TD-2133 + tdSql.error("select diff(tagtype),bottom(tagtype,1) from dev_001") + + # TD-2190 + tdSql.error("select min(tagtype),max(tagtype) from dev_002 interval(1n) fill(prev)") + + # TD-2208 + tdSql.error("select diff(tagtype),top(tagtype,1) from dev_001") + + # TD-6006 + tdSql.error("select * from dev_001 where 'name' is not null") + tdSql.error("select * from dev_001 where \"name\" = 'first'") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/queryFillTest.py b/tests/pytest/query/queryFillTest.py new file mode 100644 index 0000000000000000000000000000000000000000..e50d02faf27f33191f4a76c535443f6802e0ed28 --- /dev/null +++ b/tests/pytest/query/queryFillTest.py @@ -0,0 +1,95 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.ts = 1537146000000 + + def run(self): + tdSql.prepare() + + print("==============step1") + tdSql.execute( + "create table if not exists stb (ts timestamp, col1 int, col2 int, col3 int) tags(loc nchar(20), id int)") + + currTs = self.ts + + for i in range(100): + sql = "create table tb%d using stb tags('city%d', 1)" % (i, i) + tdSql.execute(sql) + + sql = "insert into tb%d values" % i + for j in range(5): + val = 1 + j + sql += "(%d, %d, %d, %d)" % (currTs, val, val, val) + currTs += 1000000 + tdSql.execute(sql) + + tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h)") + tdSql.checkRows(139) + tdSql.checkData(0, 1, -1.5) + tdSql.checkData(138, 1, -1.0) + + tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h) fill(none)") + tdSql.checkRows(139) + tdSql.checkData(0, 1, -1.5) + tdSql.checkData(138, 1, -1.0) + + tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h) fill(value, 2.0)") + tdSql.checkRows(141) + tdSql.checkData(0, 1, 2.0) + tdSql.checkData(140, 1, 2.0) + + tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h) fill(prev)") + tdSql.checkRows(141) + tdSql.checkData(0, 1, None) + tdSql.checkData(140, 1, -1.0) + + tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h) fill(null)") + tdSql.checkRows(141) + tdSql.checkData(0, 1, None) + tdSql.checkData(140, 1, None) + + tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h) fill(linear)") + tdSql.checkRows(141) + tdSql.checkData(0, 1, None) + tdSql.checkData(140, 1, None) + + tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h) fill(next)") + tdSql.checkRows(141) + tdSql.checkData(0, 1, -1.5) + tdSql.checkData(140, 1, None) + + tdSql.query("select max(col1) - min(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' and id = 1 group by loc, id") + rows = tdSql.queryRows + + tdSql.query("select spread(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' and id = 1 group by loc, id") + tdSql.checkRows(rows) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/query/queryFilterTswithDateUnit.py b/tests/pytest/query/queryFilterTswithDateUnit.py new file mode 100644 index 0000000000000000000000000000000000000000..eb9eb02afd27aaef75c9afe2af4765fd748e636b --- /dev/null +++ b/tests/pytest/query/queryFilterTswithDateUnit.py @@ -0,0 +1,169 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug(f"start to execute {__file__}") + tdSql.init(conn.cursor(), logSql) + + def insertnow(self, tsp1, tsp2, tsp3): + + tdSql.execute( + "create table stbts (ts timestamp, ts1 timestamp, c1 int, ts2 timestamp) TAGS(t1 int)" + ) + tdSql.execute("create table tts1 using stbts tags(1)") + + tdSql.execute("insert into tts1 values (now+1d, now+1d, 6, now+1d)") + tdSql.execute("insert into tts1 values (now, now, 5, now)") + tdSql.execute("insert into tts1 values (now-1d, now-1d, 4, now-1d)") + tdSql.execute(f"insert into tts1 values ({tsp1}, {tsp1}, 3, {tsp1})") + tdSql.execute(f"insert into tts1 values ({tsp2}, {tsp2}, 2, {tsp2})") + tdSql.execute(f"insert into tts1 values ({tsp3}, {tsp3}, 1, {tsp3})") + + + def querynow(self): + + tdLog.printNoPrefix("==========step query: execute query operation") + time.sleep(1) + + cols = ["ts", "ts1", "ts2"] + + for col in cols: + tdSql.error(f" select * from tts1 where {col} = 1d ") + tdSql.error(f" select * from tts1 where {col} < -1d ") + tdSql.error(f" select * from tts1 where {col} > 1d ") + tdSql.error(f" select * from tts1 where {col} >= -1d ") + tdSql.error(f" select * from tts1 where {col} <= 1d ") + tdSql.error(f" select * from tts1 where {col} <> 1d ") + + tdSql.error(f" select * from tts1 where {col} = -1m ") + tdSql.error(f" select * from tts1 where {col} < 1m ") + tdSql.error(f" select * from tts1 where {col} > 1m ") + tdSql.error(f" select * from tts1 where {col} >= -1m ") + tdSql.error(f" select * from tts1 where {col} <= 1m ") + tdSql.error(f" select * from tts1 where {col} <> 1m ") + + tdSql.error(f" select * from tts1 where {col} = -1s ") + tdSql.error(f" select * from tts1 where {col} < 1s ") + tdSql.error(f" select * from tts1 where {col} > 1s ") + tdSql.error(f" select * from tts1 where {col} >= -1s ") + tdSql.error(f" select * from tts1 where {col} <= 1s ") + tdSql.error(f" select * from tts1 where {col} <> 1s ") + + tdSql.error(f" select * from tts1 where {col} = -1a ") + tdSql.error(f" select * from tts1 where {col} < 1a ") + tdSql.error(f" select * from tts1 where {col} > 1a ") + tdSql.error(f" select * from tts1 where {col} >= -1a ") + tdSql.error(f" select * from tts1 where {col} <= 1a ") + tdSql.error(f" select * from tts1 where {col} <> 1a ") + + tdSql.error(f" select * from tts1 where {col} = -1h ") + tdSql.error(f" select * from tts1 where {col} < 1h ") + tdSql.error(f" select * from tts1 where {col} > 1h ") + tdSql.error(f" select * from tts1 where {col} >= -1h ") + tdSql.error(f" select * from tts1 where {col} <= 1h ") + tdSql.error(f" select * from tts1 where {col} <> 1h ") + + tdSql.error(f" select * from tts1 where {col} = -1w ") + tdSql.error(f" select * from tts1 where {col} < 1w ") + tdSql.error(f" select * from tts1 where {col} > 1w ") + tdSql.error(f" select * from tts1 where {col} >= -1w ") + tdSql.error(f" select * from tts1 where {col} <= 1w ") + tdSql.error(f" select * from tts1 where {col} <> 1w ") + + tdSql.error(f" select * from tts1 where {col} = -1u ") + tdSql.error(f" select * from tts1 where {col} < 1u ") + tdSql.error(f" select * from tts1 where {col} > 1u ") + tdSql.error(f" select * from tts1 where {col} >= -1u ") + tdSql.error(f" select * from tts1 where {col} <= 1u ") + tdSql.error(f" select * from tts1 where {col} <> u ") + + tdSql.error(f" select * from tts1 where {col} = 0d ") + tdSql.error(f" select * from tts1 where {col} < 0s ") + tdSql.error(f" select * from tts1 where {col} > 0a ") + tdSql.error(f" select * from tts1 where {col} >= 0m ") + tdSql.error(f" select * from tts1 where {col} <= 0h ") + tdSql.error(f" select * from tts1 where {col} <> 0u ") + tdSql.error(f" select * from tts1 where {col} <> 0w ") + + tdSql.error(f" select * from tts1 where {col} = 1m+1h ") + tdSql.error(f" select * from tts1 where {col} < 1w-1d ") + tdSql.error(f" select * from tts1 where {col} > 0a/1u ") + tdSql.error(f" select * from tts1 where {col} >= 1d/0s ") + tdSql.error(f" select * from tts1 where {col} <= 1s*1a ") + tdSql.error(f" select * from tts1 where {col} <> 0w/0d ") + + tdSql.error(f" select * from tts1 where {col} = 1m+1h ") + tdSql.error(f" select * from tts1 where {col} < 1w-1d ") + tdSql.error(f" select * from tts1 where {col} > 0a/1u ") + tdSql.error(f" select * from tts1 where {col} >= 1d/0s ") + tdSql.error(f" select * from tts1 where {col} <= 1s*1a ") + tdSql.error(f" select * from tts1 where {col} <> 0w/0d ") + + tdSql.error(f" select * from tts1 where {col} = 1u+1 ") + tdSql.error(f" select * from tts1 where {col} < 1a-1 ") + tdSql.error(f" select * from tts1 where {col} > 1s*1 ") + tdSql.error(f" select * from tts1 where {col} >= 1m/1 ") + tdSql.error(f" select * from tts1 where {col} <= 1h/0 ") + tdSql.error(f" select * from tts1 where {col} <> 0/1d ") + tdSql.error(f" select * from tts1 where {col} <> 1w+'2010-01-01 00:00:00' ") + + tdSql.error(f" select * from tts1 where {col} = 1-1h ") + tdSql.error(f" select * from tts1 where {col} < 1w-d ") + tdSql.error(f" select * from tts1 where {col} > 0/u ") + tdSql.error(f" select * from tts1 where {col} >= d/s ") + tdSql.error(f" select * from tts1 where {col} <= 1/a ") + tdSql.error(f" select * from tts1 where {col} <> d/1 ") + + def run(self): + tdSql.execute("drop database if exists dbms") + tdSql.execute("drop database if exists dbus") + + # timestamp list: + # 0 -> "1970-01-01 08:00:00" | -28800000 -> "1970-01-01 00:00:00" | -946800000000 -> "1940-01-01 00:00:00" + # -631180800000 -> "1950-01-01 00:00:00" + + tdLog.printNoPrefix("==========step1:create table precision ms && insert data && query") + # create databases precision is ms + tdSql.execute("create database if not exists dbms keep 36500") + tdSql.execute("use dbms") + tsp1 = 0 + tsp2 = -28800000 + tsp3 = -946800000000 + self.insertnow(tsp1,tsp2,tsp3) + self.querynow() + + tdLog.printNoPrefix("==========step2:create table precision us && insert data && query") + # create databases precision is us + tdSql.execute("create database if not exists dbus keep 36500 precision 'us' ") + tdSql.execute("use dbus") + tsp2 = tsp2 * 1000 + tsp3 = tsp3 * 1000 + self.insertnow(tsp1,tsp2,tsp3) + self.querynow() + + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/queryGroupTbname.py b/tests/pytest/query/queryGroupTbname.py new file mode 100644 index 0000000000000000000000000000000000000000..73ee5f0fa8d2f358e34bab3336d6f64364b6af83 --- /dev/null +++ b/tests/pytest/query/queryGroupTbname.py @@ -0,0 +1,81 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +from util.common import tdCom +import random + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def queryGroupTbname(self): + ''' + select a1,a2...a10 from stb where tbname in (t1,t2,...t10) and ts... + ''' + tdCom.cleanTb() + table_name = tdCom.getLongName(8, "letters_mixed") + tbname_list = list(map(lambda x: f'table_name_sub{x}', range(1, 11))) + tb_str = "" + + for tbname in tbname_list: + globals()[tbname] = tdCom.getLongName(8, "letters_mixed") + tdSql.execute(f'CREATE TABLE {table_name} (ts timestamp, {table_name_sub1} tinyint, \ + {table_name_sub2} smallint, {table_name_sub3} int, {table_name_sub4} bigint, \ + {table_name_sub5} float, {table_name_sub6} double, {table_name_sub7} binary(20),\ + {table_name_sub8} nchar(20), {table_name_sub9} bool) tags ({table_name_sub10} binary(20))') + + for tbname in tbname_list: + tb_str += tbname + tdSql.execute(f'create table {globals()[tbname]} using {table_name} tags ("{globals()[tbname]}")') + + for i in range(10): + for tbname in tbname_list: + tdSql.execute(f'insert into {globals()[tbname]} values (now, 1, 2, 3, 4, 1.1, 2.2, "{globals()[tbname]}", "{globals()[tbname]}", True)') + + for i in range(100): + tdSql.query(f'select {table_name_sub1},{table_name_sub2},{table_name_sub3},{table_name_sub4},{table_name_sub5},{table_name_sub6},{table_name_sub7},{table_name_sub8},{table_name_sub9} from {table_name} where tbname in ("{table_name_sub1}","{table_name_sub2}","{table_name_sub3}","{table_name_sub4}","{table_name_sub5}","{table_name_sub6}","{table_name_sub7}","{table_name_sub8}","{table_name_sub9}") and ts >= "1980-01-01 00:00:00.000"') + tdSql.checkRows(90) + + # TS-634 + tdLog.info("test case for bug TS-634") + tdSql.execute("create database test") + tdSql.execute("use test") + tdSql.execute("create table meters (ts TIMESTAMP,voltage INT) TAGS (tableid INT)") + tdSql.execute("CREATE TABLE t1 USING meters TAGS (1)") + tdSql.execute("CREATE TABLE t2 USING meters TAGS (2)") + + ts = 1605381041000 + for i in range(10): + tdSql.execute("INSERT INTO t1 values(%d, %d)" % (ts + i, random.randint(0, 100))) + tdSql.execute("INSERT INTO t2 values(%d, %d)" % (ts + i, random.randint(0, 100))) + + tdSql.query("select last_row(*), tbname from meters group by tbname order by ts desc") + tdSql.checkRows(2) + + tdSql.execute("INSERT INTO t2 values(now, 2)") + tdSql.query("select last_row(*), tbname from meters group by tbname order by ts desc") + tdSql.checkRows(2) + + def run(self): + tdSql.prepare() + self.queryGroupTbname() + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/query/queryGroupbySort.py b/tests/pytest/query/queryGroupbySort.py new file mode 100644 index 0000000000000000000000000000000000000000..063db936087c125e45051da0094b57a9fd184b9b --- /dev/null +++ b/tests/pytest/query/queryGroupbySort.py @@ -0,0 +1,66 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.ts = 1537146000000 + + def run(self): + tdSql.prepare() + + tdSql.execute("CREATE TABLE meters (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupId int, t3 float, t4 double)") + tdSql.execute("CREATE TABLE D1001 USING meters TAGS ('Beijing.Chaoyang', 2 , NULL, NULL)") + tdSql.execute("CREATE TABLE D1002 USING meters TAGS ('Beijing.Chaoyang', 3 , NULL , 1.7)") + tdSql.execute("CREATE TABLE D1003 USING meters TAGS ('Beijing.Chaoyang', 3 , 1.1 , 1.7)") + tdSql.execute("INSERT INTO D1001 VALUES (1538548685000, 10.3, 219, 0.31) (1538548695000, 12.6, 218, 0.33) (1538548696800, 12.3, 221, 0.31)") + tdSql.execute("INSERT INTO D1002 VALUES (1538548685001, 10.5, 220, 0.28) (1538548696800, 12.3, 221, 0.31)") + tdSql.execute("INSERT INTO D1003 VALUES (1538548685001, 10.5, 220, 0.28) (1538548696800, 12.3, 221, 0.31)") + tdSql.query("SELECT SUM(current), AVG(voltage) FROM meters WHERE groupId > 1 INTERVAL(1s) GROUP BY location order by ts DESC") + tdSql.checkRows(3) + tdSql.checkData(0, 0, "2018-10-03 14:38:16") + tdSql.checkData(1, 0, "2018-10-03 14:38:15") + tdSql.checkData(2, 0, "2018-10-03 14:38:05") + + tdSql.query("SELECT SUM(current), AVG(voltage) FROM meters WHERE groupId > 1 INTERVAL(1s) GROUP BY location order by ts ASC") + tdSql.checkRows(3) + tdSql.checkData(0, 0, "2018-10-03 14:38:05") + tdSql.checkData(1, 0, "2018-10-03 14:38:15") + tdSql.checkData(2, 0, "2018-10-03 14:38:16") + + tdSql.error("SELECT SUM(current) as s, AVG(voltage) FROM meters WHERE groupId > 1 INTERVAL(1s) GROUP BY location order by s ASC") + + tdSql.error("SELECT SUM(current) as s, AVG(voltage) FROM meters WHERE groupId > 1 INTERVAL(1s) GROUP BY location order by s DESC") + + #add for TD-3170 + tdSql.query("select avg(current) from meters group by t3;") + tdSql.checkData(0, 0, 11.6) + tdSql.query("select avg(current) from meters group by t4;") + tdSql.query("select avg(current) from meters group by t3,t4;") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/queryGroupbyWithInterval.py b/tests/pytest/query/queryGroupbyWithInterval.py new file mode 100644 index 0000000000000000000000000000000000000000..14f6999021f23764bef95afdaa33cbcb695f2f55 --- /dev/null +++ b/tests/pytest/query/queryGroupbyWithInterval.py @@ -0,0 +1,53 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdSql.execute( + "create table stest(ts timestamp,size INT,filenum INT) tags (appname binary(500),tenant binary(500))") + tdSql.execute( + "insert into test1 using stest tags('test1','aaa') values ('2020-09-04 16:53:54.003',210,3)") + tdSql.execute( + "insert into test2 using stest tags('test1','aaa') values ('2020-09-04 16:53:56.003',210,3)") + tdSql.execute( + "insert into test11 using stest tags('test11','bbb') values ('2020-09-04 16:53:57.003',210,3)") + tdSql.execute( + "insert into test12 using stest tags('test11','bbb') values ('2020-09-04 16:53:58.003',210,3)") + tdSql.execute( + "insert into test21 using stest tags('test21','ccc') values ('2020-09-04 16:53:59.003',210,3)") + tdSql.execute( + "insert into test22 using stest tags('test21','ccc') values ('2020-09-04 16:54:54.003',210,3)") + + tdSql.query("select sum(size) from stest interval(1d) group by appname") + tdSql.checkRows(3) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/queryInsertValue.py b/tests/pytest/query/queryInsertValue.py new file mode 100644 index 0000000000000000000000000000000000000000..a6b2a88008a8f61a910b5bc6dfa7e41433da1758 --- /dev/null +++ b/tests/pytest/query/queryInsertValue.py @@ -0,0 +1,65 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.numOfRecords = 10 + self.ts = 1537146000000 + + def restartTaosd(self): + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.execute("use db") + + def run(self): + tdSql.prepare() + + print("==============step1") + + tdSql.execute( + "create table st (ts timestamp, speed int) tags(areaid int, loc nchar(20))") + tdSql.execute("create table t1 using st tags(1, 'beijing')") + tdSql.execute("insert into t1 values(now, 1)") + tdSql.query("select * from st") + tdSql.checkRows(1) + + tdSql.execute("alter table st add column len int") + tdSql.execute("insert into t1 values(now, 1, 2)") + tdSql.query("select last(*) from st") + tdSql.checkData(0, 2, 2); + + self.restartTaosd(); + + tdSql.query("select last(*) from st") + tdSql.checkData(0, 2, 2); + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/queryInterval.py b/tests/pytest/query/queryInterval.py new file mode 100644 index 0000000000000000000000000000000000000000..129d3adc92255cfd8bb20f4622b23b2141824f88 --- /dev/null +++ b/tests/pytest/query/queryInterval.py @@ -0,0 +1,172 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +from util.dnodes import tdDnodes + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.ts = 1593548685000 + + def run(self): + tdSql.prepare() + + tdSql.execute("create table st (ts timestamp, voltage int) tags (loc nchar(30))") + tdSql.execute("insert into t0 using st tags('beijing') values(%d, 220) (%d, 221) (%d, 225) (%d, 228) (%d, 222)" + % (self.ts, self.ts + 1000000000, self.ts + 2000000000, self.ts + 3000000000, self.ts + 6000000000)) + tdSql.execute("insert into t1 using st tags('shanghai') values(%d, 220) (%d, 221) (%d, 225) (%d, 228) (%d, 222)" + % (self.ts, self.ts + 2000000000, self.ts + 4000000000, self.ts + 5000000000, self.ts + 7000000000)) + + + tdSql.query("select avg(voltage) from st interval(1n)") + tdSql.checkRows(3) + tdSql.checkData(0, 0, "2020-07-01 00:00:00") + tdSql.checkData(0, 1, 221.4) + tdSql.checkData(1, 0, "2020-08-01 00:00:00") + tdSql.checkData(1, 1, 227.0) + tdSql.checkData(2, 0, "2020-09-01 00:00:00") + tdSql.checkData(2, 1, 222.0) + + tdSql.query("select avg(voltage) from st interval(1n, 15d)") + tdSql.checkRows(4) + tdSql.checkData(0, 0, "2020-06-16 00:00:00") + tdSql.checkData(0, 1, 220.333333) + tdSql.checkData(1, 0, "2020-07-16 00:00:00") + tdSql.checkData(1, 1, 224.666666) + tdSql.checkData(2, 0, "2020-08-16 00:00:00") + tdSql.checkData(2, 1, 225.0) + tdSql.checkData(3, 0, "2020-09-16 00:00:00") + tdSql.checkData(3, 1, 222.0) + + tdSql.query("select avg(voltage) from st interval(1n, 15d) group by loc") + tdSql.checkRows(7) + tdSql.checkData(0, 0, "2020-06-16 00:00:00") + tdSql.checkData(0, 1, 220.5) + tdSql.checkData(1, 0, "2020-07-16 00:00:00") + tdSql.checkData(1, 1, 226.5) + tdSql.checkData(2, 0, "2020-08-16 00:00:00") + tdSql.checkData(2, 1, 222.0) + tdSql.checkData(3, 0, "2020-06-16 00:00:00") + tdSql.checkData(3, 1, 220.0) + tdSql.checkData(4, 0, "2020-07-16 00:00:00") + tdSql.checkData(4, 1, 221.0) + tdSql.checkData(5, 0, "2020-08-16 00:00:00") + tdSql.checkData(5, 1, 226.5) + tdSql.checkData(6, 0, "2020-09-16 00:00:00") + tdSql.checkData(6, 1, 222.0) + + # test case for https://jira.taosdata.com:18080/browse/TD-5338 + tdSql.query("select loc,max(voltage) from st interval(1m);") + tdSql.checkRows(8) + tdSql.checkData(0, 0, "2020-07-01 04:24:00.000") + tdSql.checkData(0, 1, "beijing") + tdSql.checkData(0, 2, 220) + tdSql.checkData(1, 0, "2020-07-12 18:11:00.000") + tdSql.checkData(1, 1, "beijing") + tdSql.checkData(1, 2, 221) + tdSql.checkData(2, 0, "2020-07-24 07:58:00.000") + tdSql.checkData(2, 1, "beijing") + tdSql.checkData(2, 2, 225) + tdSql.checkData(3, 0, "2020-08-04 21:44:00.000") + tdSql.checkData(2, 1, "beijing") + tdSql.checkData(3, 2, 228) + tdSql.checkData(4, 0, "2020-08-16 11:31:00.000") + tdSql.checkData(4, 1, "shanghai") + tdSql.checkData(4, 2, 225) + tdSql.checkData(5, 0, "2020-08-28 01:18:00.000") + tdSql.checkData(5, 1, "shanghai") + tdSql.checkData(5, 2, 228) + tdSql.checkData(6, 0, "2020-09-08 15:04:00.000") + tdSql.checkData(6, 1, "beijing") + tdSql.checkData(6, 2, 222) + tdSql.checkData(7, 0, "2020-09-20 04:51:00.000") + tdSql.checkData(7, 1, "shanghai") + tdSql.checkData(7, 2, 222) + tdSql.query("select loc,max(voltage) from t0 interval(1m);") + tdSql.checkRows(5) + tdSql.checkData(0, 0, "2020-07-01 04:24:00.000") + tdSql.checkData(0, 1, "beijing") + tdSql.checkData(0, 2, 220) + tdSql.checkData(1, 0, "2020-07-12 18:11:00.000") + tdSql.checkData(1, 1, "beijing") + tdSql.checkData(1, 2, 221) + tdSql.checkData(2, 0, "2020-07-24 07:58:00.000") + tdSql.checkData(2, 1, "beijing") + tdSql.checkData(2, 2, 225) + tdSql.checkData(3, 0, "2020-08-04 21:44:00.000") + tdSql.checkData(2, 1, "beijing") + tdSql.checkData(3, 2, 228) + tdSql.checkData(4, 0, "2020-09-08 15:04:00.000") + tdSql.checkData(4, 1, "beijing") + tdSql.checkData(4, 2, 222) + + + # test case for https://jira.taosdata.com:18080/browse/TD-2298 + tdSql.execute("create database test keep 36500") + tdSql.execute("use test") + tdSql.execute("create table t (ts timestamp, voltage int)") + for i in range(10000): + tdSql.execute("insert into t values(%d, 0)" % (1000000 + i * 6000)) + + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select last(*) from t interval(1s)") + tdSql.checkRows(10000) + + # test case for https://jira.taosdata.com:18080/browse/TD-2601 + newTs = 1601481600000 + + tdSql.execute("create database test2") + tdSql.execute("use test2") + tdSql.execute("create table t (ts timestamp, voltage int)") + for i in range(100): + tdSql.execute("insert into t values(%d, %d)" % (newTs + i * 10000000, i)) + + tdSql.query("select sum(voltage) from t where ts >='2020-10-01 00:00:00' and ts <='2020-12-01 00:00:00' interval(1n) fill(NULL)") + tdSql.checkRows(3) + tdSql.checkData(0, 1, 4950) + tdSql.checkData(1, 1, None) + tdSql.checkData(2, 1, None) + + # test case for https://jira.taosdata.com:18080/browse/TD-2659, https://jira.taosdata.com:18080/browse/TD-2660 + tdSql.execute("create database test3") + tdSql.execute("use test3") + tdSql.execute("create table tb(ts timestamp, c int)") + tdSql.execute("insert into tb values('2020-10-30 18:11:56.680', -111)") + tdSql.execute("insert into tb values('2020-11-19 18:11:45.773', null)") + tdSql.execute("insert into tb values('2020-12-09 18:11:17.098', null)") + tdSql.execute("insert into tb values('2020-12-29 11:00:49.412', 1)") + tdSql.execute("insert into tb values('2020-12-29 11:00:50.412', 2)") + tdSql.execute("insert into tb values('2020-12-29 11:00:52.412', 3)") + + tdSql.query("select first(ts),twa(c) from tb interval(14a)") + tdSql.checkRows(6) + + tdSql.error("select twa(c) from tb group by c") + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/queryJoin.py b/tests/pytest/query/queryJoin.py new file mode 100644 index 0000000000000000000000000000000000000000..6d028049e516b4b0f399fcb055793a16ec093eec --- /dev/null +++ b/tests/pytest/query/queryJoin.py @@ -0,0 +1,216 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +import string +import random +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + def get_random_string(self, length): + letters = string.ascii_lowercase + result_str = ''.join(random.choice(letters) for i in range(length)) + return result_str + + def run(self): + tdSql.prepare() + + print("======= Step 1 prepare data=========") + tdSql.execute( + "create table stb1 (ts timestamp, c1 int, c2 float) tags(t1 int, t2 binary(10), t3 nchar(10))") + tdSql.execute( + '''insert into tb1 using stb1 tags(1,'tb1', '表1') values ('2020-04-18 15:00:00.000', 1, 0.1) + ('2020-04-18 15:00:01.000', 1,0.1) ('2020-04-18 15:00:03.000', 3, 0.3) ('2020-04-18 15:00:04.000', 4,0.4)''') + tdSql.execute( + '''insert into tb2 using stb1 tags(2,'tb2', '表2') values ('2020-04-18 15:00:00.000', 21, 2.1) + ('2020-04-18 15:00:01.000', 22,2.2) ('2020-04-18 15:00:02.000', 22, 2.1) ('2020-04-18 15:00:03.000', 23,2.2)''') + + tdSql.execute( + "create table stb_t (ts timestamp, temperature int, humidity float) tags(id int, name binary(10), dscrption nchar(10))") + tdSql.execute( + '''insert into tb_t1 using stb_t tags(1,'tb_t1', '温度表1') values ('2020-04-18 15:00:00.000', 25, 0.5) + ('2020-04-18 15:00:01.000', 25, 0.5) ('2020-04-18 15:00:02.000', 26, 0.7) ('2020-04-18 15:00:03.000', 27, 0.8)''') + tdSql.execute( + '''insert into tb_t2 using stb_t tags(2,'tb_t2', '温度表2') values ('2020-04-18 15:00:00.000', 33, 0.9) + ('2020-04-18 15:00:01.000', 35, 1.1) ('2020-04-18 15:00:03.000', 36, 1.3) ('2020-04-18 15:00:04.000', 37, 1.4)''') + + tdSql.execute( + "create table stb_p (ts timestamp, pressure float) tags(id int, name binary(10), dscrption nchar(10), location binary(20))") + tdSql.execute( + '''insert into tb_p1 using stb_p tags(1,'tb_p1', '压力计1', 'beijing') values ('2020-04-18 15:00:00.000', 76.6) + ('2020-04-18 15:00:01.000', 76.5) ('2020-04-18 15:00:01.500', 77.1) ('2020-04-18 15:00:02.000', 75.3) + ('2020-04-18 15:00:03.000', 75.1) ('2020-04-18 15:00:04.500', 77.3)''') + tdSql.execute( + '''insert into tb_p2 using stb_p tags(2,'tb_p2', '压力计2', 'shenzhen') values ('2020-04-18 14:59:59.000', 74.6) + ('2020-04-18 15:00:01.000', 74.5) ('2020-04-18 15:00:01.500', 73.6) ('2020-04-18 15:00:02.000', 74.5) + ('2020-04-18 15:00:02.500', 73.9) ('2020-04-18 15:00:03.000', 73.5)''') + + tdSql.execute( + "create table stb_v (ts timestamp, velocity float) tags(id int, name binary(10), dscrption nchar(10), location binary(20))") + tdSql.execute( + '''insert into tb_v1 using stb_v tags(1,'tb_v1', '速度计1', 'beijing ') values ('2020-04-18 15:00:00.000', 176.6) + ('2020-04-18 15:00:01.000', 176.5)''') + tdSql.execute( + '''insert into tb_v2 using stb_v tags(2,'tb_v2', '速度计2', 'shenzhen') values ('2020-04-18 15:00:00.000', 171.6) + ('2020-04-18 15:00:01.000', 171.5)''') + + # explicit join should not work + tdSql.error("select * from stb_p join stb_t on (stb_p.id = stb_t.id)") + tdSql.error("select * from tb1 join tb2 on (tb1.ts=tb2.ts)") + tdSql.error( + "select * from stb_p join stb_t on (stb_p.ts=stb_t.ts and stb_p.id = stb_t.id)") + + # alias should not work + tdSql.error("select * from stb_p p join stb_t t on (p.id = t.id)") + + # join queries + tdSql.query( + "select * from stb_p, stb_t where stb_p.ts=stb_t.ts and stb_p.id = stb_t.id") + tdSql.checkRows(6) + + tdSql.error( + "select ts, pressure, temperature, id, dscrption from stb_p, stb_t where stb_p.ts=stb_t.ts and stb_p.id = stb_t.id") + + tdSql.query("select stb_p.ts, pressure, stb_t.temperature, stb_p.id, stb_p.dscrption from stb_p, stb_t where stb_p.ts=stb_t.ts and stb_p.id = stb_t.id") + tdSql.checkRows(6) + + tdSql.query("select stb_t.ts, stb_p.pressure, stb_t.temperature,stb_p.id,stb_p.dscrption from stb_p, stb_t where stb_p.ts=stb_t.ts and stb_p.id = stb_t.id") + tdSql.checkRows(6) + + tdSql.error( + "select stb_t.ts, stb_t.dscrption, stb_t.temperature, stb_t.id, stb_p.dscrption, stb_p.pressure from stb_p, stb_t where stb_p.ts=stb_t.ts and stb_p.id = stb_t.id group by name") + tdSql.error( + "select stb_t.ts, stb_t.dscrption, stb_t.temperature, stb_t.id, stb_p.dscrption, stb_p.pressure from stb_p, stb_t where stb_p.ts=stb_t.ts and stb_p.id = stb_t.id group by stb_t.name") + tdSql.error( + "select stb_t.ts, stb_t.dscrption, stb_t.temperature, stb_t.id, stb_p.dscrption, stb_p.pressure from stb_p, stb_t where stb_p.ts=stb_t.ts and stb_p.id = stb_t.id group by stb_t.id") + tdSql.error( + "select stb_t.ts, stb_t.dscrption, stb_t.temperature, stb_t.id, stb_p.dscrption, stb_p.pressure from stb_p, stb_t where stb_p.ts=stb_t.ts and stb_p.id = stb_t.name;") + + tdSql.execute("alter table stb_t add tag pid int") + tdSql.execute("alter table tb_t1 set tag pid=2") + tdSql.execute("alter table tb_t2 set tag pid=1") + + tdSql.query( + "select stb_t.ts, stb_t.dscrption, stb_t.temperature, stb_t.id, stb_p.dscrption, stb_p.pressure from stb_p, stb_t where stb_p.ts=stb_t.ts and stb_p.location = stb_t.name") + tdSql.checkRows(0) + + tdSql.query("select stb_t.ts, stb_t.dscrption, stb_t.temperature, stb_t.id, stb_p.dscrption, stb_p.pressure from stb_p, stb_t where stb_p.ts=stb_t.ts and stb_p.id = stb_t.pid") + tdSql.checkRows(6) + + tdSql.query("select stb_t.ts, stb_t.dscrption, stb_t.temperature, stb_t.id, stb_p.dscrption, stb_p.pressure from stb_p, stb_t where stb_p.ts=stb_t.ts and stb_p.id = stb_t.id") + tdSql.checkRows(6) + + tdSql.query("select stb_t.ts, stb_t.dscrption, stb_t.temperature, stb_t.id, stb_p.dscrption, stb_p.pressure from stb_p, stb_t where stb_p.ts=stb_t.ts and stb_p.id = stb_t.id") + tdSql.checkRows(6) + + tdSql.error("select stb_t.ts, stb_t.dscrption, stb_t.temperature, stb_t.pid, stb_p.id, stb_p.dscrption, stb_p.pressure,stb_v.velocity from stb_p, stb_t, stb_v where stb_p.ts=stb_t.ts and stb_p.ts=stb_v.ts and stb_p.id = stb_t.id") + + # test case for https://jira.taosdata.com:18080/browse/TD-1250 + + tdSql.execute("create table meters1(ts timestamp, voltage int) tags(tag1 binary(20), tag2 nchar(20))") + tdSql.execute("create table t1 using meters1 tags('beijing', 'chaoyang')") + tdSql.execute("create table t2 using meters1 tags('shanghai', 'xuhui')") + tdSql.execute("insert into t1 values(1538548685000, 1) (1538548685001, 2) (1538548685002, 3)") + tdSql.execute("insert into t1 values(1538548685004, 4) (1538548685004, 5) (1538548685005, 6)") + + tdSql.execute("create table meters2(ts timestamp, voltage int) tags(tag1 binary(20), tag2 nchar(20))") + tdSql.execute("create table t3 using meters2 tags('beijing', 'chaoyang')") + tdSql.execute("create table t4 using meters2 tags('shenzhen', 'nanshan')") + tdSql.execute("insert into t3 values(1538548685000, 7) (1538548685001, 8) (1538548685002, 9)") + tdSql.execute("insert into t4 values(1538548685000, 10) (1538548685001, 11) (1538548685002, 12)") + + tdSql.execute("create table meters3(ts timestamp, voltage int) tags(tag1 binary(20), tag2 nchar(20))") + + tdSql.query("select * from meters1, meters2 where meters1.ts = meters2.ts and meters1.tag1 = meters2.tag1") + tdSql.checkRows(3) + + tdSql.query("select * from meters1, meters2 where meters1.ts = meters2.ts and meters1.tag2 = meters2.tag2") + tdSql.checkRows(3) + + tdSql.query("select * from meters1, meters3 where meters1.ts = meters3.ts and meters1.tag1 = meters3.tag1") + tdSql.checkRows(0) + + tdSql.execute("create table join_mt0(ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) tags(t1 int, t2 binary(12))") + tdSql.execute("create table join_mt1(ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) tags(t1 int, t2 binary(12), t3 int)") + + ts = 1538548685000 + for i in range(3): + tdSql.execute("create table join_tb%d using join_mt0 tags(%d, 'abc')" % (i, i)) + sql = "insert into join_tb%d values" % i + for j in range(500): + val = j % 100 + sql += "(%d, %d, %f, %d, %d, %d, %f, %d, 'binary%d', 'nchar%d')" % (ts + j, val, val * 1.0, val, val, val, val * 1.0, val % 2, val, val) + tdSql.execute(sql) + sql = "insert into join_tb%d values" % i + for j in range(500, 1000): + val = j % 100 + sql += "(%d, %d, %f, %d, %d, %d, %f, %d, 'binary%d', 'nchar%d')" % (ts + 500 + j, val, val * 1.0, val, val, val, val * 1.0, val % 2, val, val) + tdSql.execute(sql) + + for i in range(3): + tdSql.execute("create table join_1_tb%d using join_mt1 tags(%d, 'abc%d', %d)" % (i, i, i, i)) + sql = "insert into join_1_tb%d values" % i + for j in range(500): + val = j % 100 + sql += "(%d, %d, %f, %d, %d, %d, %f, %d, 'binary%d', 'nchar%d')" % (ts + j, val, val * 1.0, val, val, val, val * 1.0, val % 2, val, val) + tdSql.execute(sql) + sql = "insert into join_1_tb%d values" % i + for j in range(500, 1000): + val = j % 100 + sql += "(%d, %d, %f, %d, %d, %d, %f, %d, 'binary%d', 'nchar%d')" % (ts + 500 + j, val, val * 1.0, val, val, val, val * 1.0, val % 2, val, val) + tdSql.execute(sql) + + tdSql.error("select count(join_mt0.c1), sum(join_mt1.c2), first(join_mt0.c5), last(join_mt1.c7) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts interval(10a) group by join_mt0.t1 order by join_mt0.ts desc") + tdSql.error("select count(join_mt0.c1), first(join_mt0.c1)-first(join_mt1.c1), first(join_mt1.c9) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts") + tdSql.error("select count(join_mt0.c1), first(join_mt0.c1), first(join_mt1.c9) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts interval(10a) group by join_mt0.t1, join_mt0.t2 order by join_mt0.t1 desc slimit 3") + tdSql.error("select count(join_mt0.c1), first(join_mt0.c1) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts interval(10a) group by join_mt0.t1, join_mt0.t2, join_mt1.t1 order by join_mt0.ts desc, join_mt1.ts asc limit 10;") + tdSql.error("select join_mt1.c1,join_mt0.c1 from join_mt1,join_mt0 where join_mt1.ts = join_mt0.ts and join_mt1.t1 = join_mt0.t1 order by t") + #TD-4458 join on database which using precision us + tdSql.execute("create database test_join_us precision 'us'") + tdSql.execute("use test_join_us") + ts = 1538548685000000 + for i in range(2): + tdSql.execute("create table t%d (ts timestamp, i int)"%i) + tdSql.execute("insert into t%d values(%d,11)(%d,12)"%(i,ts,ts+1)) + tdSql.query("select t1.ts from t0,t1 where t0.ts = t1.ts") + tdSql.checkData(0,0,'2018-10-03 14:38:05.000000') + + #TD-6425 join result more than 1MB + tdSql.execute("create database test_join") + tdSql.execute("use test_join") + + ts = 1538548685000 + tdSql.execute("create table stb(ts timestamp, c1 nchar(200)) tags(id int, loc binary(20))") + for i in range(2): + tdSql.execute("create table tb%d using stb tags(1, 'city%d')" % (i, i)) + for j in range(1000): + tdSql.execute("insert into tb%d values(%d, '%s')" % (i, ts + j, self.get_random_string(200))) + + tdSql.query("select tb0.c1, tb1.c1 from tb0, tb1 where tb0.ts = tb1.ts") + tdSql.checkRows(1000) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/queryJoin10tables.py b/tests/pytest/query/queryJoin10tables.py new file mode 100644 index 0000000000000000000000000000000000000000..01a7397d445a26c2176dddd65c2350cc6682f84a --- /dev/null +++ b/tests/pytest/query/queryJoin10tables.py @@ -0,0 +1,201 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import taos +import sys + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * + +class TDTestCase: + + def init(self, conn, logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + + def createtable(self): + + # create stbles + tdSql.execute("create table if not exists stb1 (ts timestamp, c1 int) tags(t11 int, t12 int)") + tdSql.execute("create table if not exists stb2 (ts timestamp, c2 int) tags(t21 int, t22 int)") + tdSql.execute("create table if not exists stb3 (ts timestamp, c3 int) tags(t31 int, t32 int)") + tdSql.execute("create table if not exists stb4 (ts timestamp, c4 int) tags(t41 int, t42 int)") + tdSql.execute("create table if not exists stb5 (ts timestamp, c5 int) tags(t51 int, t52 int)") + tdSql.execute("create table if not exists stb6 (ts timestamp, c6 int) tags(t61 int, t62 int)") + tdSql.execute("create table if not exists stb7 (ts timestamp, c7 int) tags(t71 int, t72 int)") + tdSql.execute("create table if not exists stb8 (ts timestamp, c8 int) tags(t81 int, t82 int)") + tdSql.execute("create table if not exists stb9 (ts timestamp, c9 int) tags(t91 int, t92 int)") + tdSql.execute("create table if not exists stb10 (ts timestamp, c10 int) tags(t101 int, t102 int)") + tdSql.execute("create table if not exists stb11 (ts timestamp, c11 int) tags(t111 int, t112 int)") + + # create normal tables + tdSql.execute("create table t10 using stb1 tags(0, 9)") + tdSql.execute("create table t11 using stb1 tags(1, 8)") + tdSql.execute("create table t12 using stb1 tags(2, 7)") + tdSql.execute("create table t13 using stb1 tags(3, 6)") + tdSql.execute("create table t14 using stb1 tags(4, 5)") + tdSql.execute("create table t15 using stb1 tags(5, 4)") + tdSql.execute("create table t16 using stb1 tags(6, 3)") + tdSql.execute("create table t17 using stb1 tags(7, 2)") + tdSql.execute("create table t18 using stb1 tags(8, 1)") + tdSql.execute("create table t19 using stb1 tags(9, 0)") + tdSql.execute("create table t110 using stb1 tags(10, 10)") + + tdSql.execute("create table t20 using stb2 tags(0, 9)") + tdSql.execute("create table t21 using stb2 tags(1, 8)") + tdSql.execute("create table t22 using stb2 tags(2, 7)") + + tdSql.execute("create table t30 using stb3 tags(0, 9)") + tdSql.execute("create table t31 using stb3 tags(1, 8)") + tdSql.execute("create table t32 using stb3 tags(2, 7)") + + def inserttable(self): + for i in range(100): + if i<60: + tdSql.execute(f"insert into t20 values('2020-10-01 00:00:{i}.000', {i})") + tdSql.execute(f"insert into t21 values('2020-10-01 00:00:{i}.000', {i})") + tdSql.execute(f"insert into t22 values('2020-10-01 00:00:{i}.000', {i})") + tdSql.execute(f"insert into t30 values('2020-10-01 00:00:{i}.000', {i})") + tdSql.execute(f"insert into t31 values('2020-10-01 00:00:{i}.000', {i})") + tdSql.execute(f"insert into t32 values('2020-10-01 00:00:{i}.000', {i})") + else: + tdSql.execute(f"insert into t20 values('2020-10-01 00:01:{i-60}.000', {i})") + tdSql.execute(f"insert into t21 values('2020-10-01 00:01:{i-60}.000', {i})") + tdSql.execute(f"insert into t22 values('2020-10-01 00:01:{i-60}.000', {i})") + tdSql.execute(f"insert into t30 values('2020-10-01 00:01:{i-60}.000', {i})") + tdSql.execute(f"insert into t31 values('2020-10-01 00:01:{i-60}.000', {i})") + tdSql.execute(f"insert into t32 values('2020-10-01 00:01:{i-60}.000', {i})") + for j in range(11): + if i<60: + tdSql.execute(f"insert into t1{j} values('2020-10-01 00:00:{i}.000', {i})") + else: + tdSql.execute(f"insert into t1{j} values('2020-10-01 00:01:{i-60}.000', {i})") + + def queryjointable(self): + tdSql.error( + '''select from t10,t11,t12,t13,t14,t15,t16,t17,t18,t19 + where t10.ts=t11.ts and t10.ts=t12.ts and t10.ts=t13.ts and t10.ts=t14.ts and t10.ts=t15.ts + and t10.ts=t16.ts and t10.ts=t17.ts and t10.ts=t18.ts and t10.ts=t19.ts''' + ) + tdSql.error("select * from t10 where t10.ts=t11.ts") + tdSql.error("select * from where t10.ts=t11.ts") + tdSql.error("select * from t10,t11,t12,t13,t14,t15,t16,t17,t18,t19") + tdSql.error("select * from stb1, stb2, stb3 where stb1.ts=stb2.ts and stb1.ts=stb3.ts") + tdSql.error("select * from stb1, stb2, stb3 where stb1.t11=stb2.t21 and stb1.t11=stb3.t31") + tdSql.error("select * from stb1, stb2, stb3") + tdSql.error( + '''select * from stb1 + join stb2 on stb1.ts=stb2.ts and stb1.t11=stb2.t21 + join stb3 on stb1.ts=stb3.ts and stb1.t11=stb3.t31''' + ) + tdSql.error("select * from t10 join t11 on t10.ts=t11.ts join t12 on t11.ts=t12.ts") + tdSql.query( + '''select * from stb1,stb2,stb3 + where stb1.ts=stb2.ts and stb1.ts=stb3.ts and stb1.t11=stb2.t21 and stb1.t11 =stb3.t31''' + ) + tdSql.checkRows(300) + tdSql.query("select * from t11,t12,t13 where t11.ts=t12.ts and t11.ts=t13.ts") + tdSql.checkRows(100) + tdSql.error("selec * from t11,t12,t13 where t11.ts=t12.ts and t11.ts=t13.ts") + tdSql.error("select * form t11,t12,t13 where t11.ts=t12.ts and t11.ts=t13.ts") + tdSql.error("select * from t11,t12,t13 when t11.ts=t12.ts and t11.ts=t13.ts") + tdSql.error("select * from t11,t12,t13 when t11.ts <> t12.ts and t11.ts=t13.ts") + tdSql.error("select * from t11,t12,t13 when t11.ts != t12.ts and t11.ts=t13.ts") + tdSql.error("select * from t11,t12,t13 when t11.ts=t12.ts or t11.ts=t13.ts") + tdSql.error("select * from t11,t12,t13 when t11.ts=t12.ts=t13.ts") + tdSql.error("select * from t11,t12,t13 when t11.c1=t12.c2 and t11.c1=t13.c3") + tdSql.error("select * from t11,t12,t13 when t11.ts=t12.ts and t11.ts=t13.c3 and t11.c1=t13.ts") + tdSql.error("select ts from t11,t12,t13 when t11.ts=t12.ts and t11.ts=t13.ts") + tdSql.error("select * from t11,t12,t13 when t11.ts=ts and t11.ts=t13.ts") + tdSql.error("select * from t11,t12,t13 when t11.ts=t12.ts and t11.ts=t13.ts and ts>100") + tdSql.error("select * from t11,t12,stb1 when t11.ts=t12.ts and t11.ts=stb1.ts") + tdSql.error("select t14.ts from t11,t12,t13 when t11.ts=t12.ts and t11.ts=t13.ts") + tdSql.error("select * from t11,t12,t13 when t11.ts=t12.ts and t11.ts=t13.ts1") + tdSql.error("select * from t11,t12,t13 when t11.ts=t12.ts and t11.ts=t14.ts") + tdSql.error("select * from t11,t12,t13 when t11.ts=t12.ts") + tdSql.error("select * from t11,t12,t13 when t11.ts=t12.ts and t11.ts=t13.ts and t11.c1=t13.c3") + tdSql.error( + '''select * from t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20 + where t10.ts=t11.ts and t10.ts=t12.ts and t10.ts=t13.ts and t10.ts=t14.ts and t10.ts=t15.ts + and t10.ts=t16.ts and t10.ts=t17.ts and t10.ts=t18.ts and t10.ts=t19.ts and t10.ts=t20.ts''' + ) + tdSql.error( + '''select * from t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20 + where t10.ts=t11.ts and t10.ts=t12.ts and t10.ts=t13.ts and t10.ts=t14.ts and t10.ts=t15.ts + and t10.ts=t16.ts and t10.ts=t17.ts and t10.ts=t18.ts and t10.ts=t19.ts''' + ) + tdSql.error( + '''select * from t10,t11,t12,t13,t14,t15,t16,t17,t18,t19 + where t10.ts=t11.ts and t10.ts=t12.ts and t10.ts=t13.ts and t10.ts=t14.ts and t10.ts=t15.ts + and t10.ts=t16.ts and t10.ts=t17.ts and t10.ts=t18.ts and t10.ts=t19.ts and t10.c1=t19.c1''' + ) + tdSql.error( + '''select * from stb1,stb2,stb3 + where stb1.ts=stb2.ts and stb1.ts=stb3.ts and stb1.t11=stb2.t21''' + ) + tdSql.error( + '''select * from stb1,stb2,stb3 + where stb1.ts=stb2.ts and stb1.t11=stb2.t21 and stb1.t11=stb3.t31''' + ) + tdSql.error( + '''select * from stb1,stb2,stb3 + where stb1.ts=stb2.ts and stb1.ts=stb3.ts and stb1.t11=stb2.t21 and stb1.t11=stb3.t31 + and stb1.t12=stb3=t32''' + ) + tdSql.error( + '''select * from stb1,stb2,stb3,stb4,stb5,stb6,stb7,stb8,stb9,stb10,stb11 + where stb1.ts=stb2.ts and stb1.ts=stb3.ts and stb1.ts=stb4.ts and stb1.ts=stb5.ts and stb1.ts=stb6.ts + and stb1.ts=stb7.ts and stb1.ts=stb8.ts and stb1.ts=stb9.ts and stb1.ts=stb10.ts and stb1.ts=stb11.ts + and stb1.t11=stb2.t21 and stb1.t11=stb3.t31 and stb1.t11=stb4.t41 and stb1.t11=stb5.t51 + and stb1.t11=stb6.t61 and stb1.t11=stb7.t71 and stb1.t11=stb8.t81 and stb1.t11=stb9.t91 + and stb1.t11=stb10.t101 and stb1.t11=stb11.t111''' + ) + tdSql.error( + '''select * from stb1,stb2,stb3,stb4,stb5,stb6,stb7,stb8,stb9,stb10 + where stb1.ts=stb2.ts and stb1.ts=stb3.ts and stb1.ts=stb4.ts and stb1.ts=stb5.ts and stb1.ts=stb6.ts + and stb1.ts=stb7.ts and stb1.ts=stb8.ts and stb1.ts=stb9.ts and stb1.ts=stb10.ts and stb1.t11=stb2.t21 + and stb1.t11=stb3.t31 and stb1.t11=stb4.t41 and stb1.t11=stb5.t51 and stb1.t11=stb6.t61 + and stb1.t11=stb7.t71 and stb1.t11=stb8.t81 and stb1.t11=stb9.t91 and stb1.t11=stb10.t101 + and stb1.t12=stb11.t102''' + ) + + def run(self): + tdSql.prepare() + + tdLog.printNoPrefix("==========step1:create table") + self.createtable() + + tdLog.printNoPrefix("==========step2:insert data") + self.inserttable() + + tdLog.printNoPrefix("==========step3:query timestamp type") + self.queryjointable() + + # after wal and sync, check again + tdSql.query("show dnodes") + index = tdSql.getData(0, 0) + tdDnodes.stop(index) + tdDnodes.start(index) + + tdLog.printNoPrefix("==========step4:query again after wal") + self.queryjointable() + + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/query/queryLike.py b/tests/pytest/query/queryLike.py new file mode 100644 index 0000000000000000000000000000000000000000..07e2786c12b8663679bb3fa315c08542d4af1339 --- /dev/null +++ b/tests/pytest/query/queryLike.py @@ -0,0 +1,56 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + def run(self): + tdSql.prepare() + + tdSql.execute("create table cars(ts timestamp, c nchar(2)) tags(t1 nchar(2))") + tdSql.execute("insert into car0 using cars tags('aa') values(now, 'bb');") + tdSql.query("select count(*) from cars where t1 like '%50 90 30 04 00 00%'") + tdSql.checkRows(0) + + tdSql.execute("create table test_cars(ts timestamp, c nchar(2)) tags(t1 nchar(20))") + tdSql.execute("insert into car1 using test_cars tags('150 90 30 04 00 002') values(now, 'bb');") + tdSql.query("select * from test_cars where t1 like '%50 90 30 04 00 00%'") + tdSql.checkRows(1) + + tdSql.execute("create table stb(ts timestamp, c0 int) tags(t0 nchar(64))") + tdSql.execute("insert into tb1 using stb tags('测试ABCabc') values(now, 1)") + tdSql.query("select * from stb where t0 like '%试AB%'") + tdSql.checkRows(1) + + tdSql.query("select * from stb where t0 like '测试AB%'") + tdSql.checkRows(1) + + tdSql.query("select * from stb where t0 like '%ABCabc'") + tdSql.checkRows(1) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/queryLimit.py b/tests/pytest/query/queryLimit.py new file mode 100644 index 0000000000000000000000000000000000000000..b7761ddf2a5594637140ae2b4748df1b1df157f5 --- /dev/null +++ b/tests/pytest/query/queryLimit.py @@ -0,0 +1,194 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys + +from numpy.lib.function_base import insert +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + +# constant define +WAITS = 5 # wait seconds + +class TDTestCase: + # + # --------------- main frame ------------------- + # + + def caseDescription(self): + ''' + limit and offset keyword function test cases; + case1: limit offset base function test + case2: limit offset advance test + ''' + return + + # init + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + tdSql.prepare() + self.create_tables(); + self.ts = 1500000000000 + + + # run case + def run(self): + # insert data + self.insert_data("t1", self.ts, 300*10000, 30000); + # test base case + self.test_case1() + tdLog.debug(" LIMIT test_case1 ............ [OK]") + # test advance case + self.test_case2() + tdLog.debug(" LIMIT test_case2 ............ [OK]") + + + # stop + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + # + # --------------- case ------------------- + # + + # create table + def create_tables(self): + # super table + tdSql.execute("create table st(ts timestamp, i1 int) tags(area int)"); + # child table + tdSql.execute("create table t1 using st tags(1)"); + tdSql.execute("create table t2 using st tags(2)"); + tdSql.execute("create table t3 using st tags(3)"); + return + + # insert data1 + def insert_data(self, tbname, ts_start, count, batch_num): + pre_insert = "insert into %s values"%tbname + sql = pre_insert + tdLog.debug("doing insert table %s rows=%d ..."%(tbname, count)) + for i in range(count): + sql += " (%d,%d)"%(ts_start + i*1000, i) + if i >0 and i%batch_num == 0: + tdSql.execute(sql) + sql = pre_insert + # end sql + if sql != pre_insert: + tdSql.execute(sql) + + tdLog.debug("INSERT TABLE DATA ............ [OK]") + return + + # test case1 base + def test_case1(self): + # + # limit base function + # + # base no where + sql = "select * from t1 limit 10" + tdSql.waitedQuery(sql, 10, WAITS) + tdSql.checkData(0, 1, 0) + tdSql.checkData(9, 1, 9) + sql = "select * from t1 order by ts desc limit 10" # desc + tdSql.waitedQuery(sql, 10, WAITS) + tdSql.checkData(0, 1, 2999999) + tdSql.checkData(9, 1, 2999990) + + # have where + sql = "select * from t1 where ts>='2017-07-14 10:40:01' and ts<'2017-07-14 10:40:06' limit 10" + tdSql.waitedQuery(sql, 5, WAITS) + tdSql.checkData(0, 1, 1) + tdSql.checkData(4, 1, 5) + sql = "select * from t1 where ts>='2017-08-18 03:59:52' and ts<'2017-08-18 03:59:57' order by ts desc limit 10" # desc + tdSql.waitedQuery(sql, 5, WAITS) + tdSql.checkData(0, 1, 2999996) + tdSql.checkData(4, 1, 2999992) + + # + # offset base function + # + # no where + sql = "select * from t1 limit 10 offset 5" + tdSql.waitedQuery(sql, 10, WAITS) + tdSql.checkData(0, 1, 5) + tdSql.checkData(9, 1, 14) + sql = "select * from t1 order by ts desc limit 10 offset 5" # desc + tdSql.waitedQuery(sql, 10, WAITS) + tdSql.checkData(0, 1, 2999994) + tdSql.checkData(9, 1, 2999985) + + # have where only ts + sql = "select * from t1 where ts>='2017-07-14 10:40:10' and ts<'2017-07-14 10:40:20' limit 10 offset 5" + tdSql.waitedQuery(sql, 5, WAITS) + tdSql.checkData(0, 1, 15) + tdSql.checkData(4, 1, 19) + sql = "select * from t1 where ts>='2017-08-18 03:59:52' and ts<'2017-08-18 03:59:57' order by ts desc limit 10 offset 4" # desc + tdSql.waitedQuery(sql, 1, WAITS) + tdSql.checkData(0, 1, 2999992) + + # have where with other column condition + sql = "select * from t1 where i1>=1 and i1<11 limit 10 offset 5" + tdSql.waitedQuery(sql, 5, WAITS) + tdSql.checkData(0, 1, 6) + tdSql.checkData(4, 1, 10) + sql = "select * from t1 where i1>=300000 and i1<=500000 order by ts desc limit 10 offset 100000" # desc + tdSql.waitedQuery(sql, 10, WAITS) + tdSql.checkData(0, 1, 400000) + tdSql.checkData(9, 1, 399991) + + # have where with ts and other column condition + sql = "select * from t1 where ts>='2017-07-14 10:40:10' and ts<'2017-07-14 10:40:50' and i1>=20 and i1<=25 limit 10 offset 5" + tdSql.waitedQuery(sql, 1, WAITS) + tdSql.checkData(0, 1, 25) + + return + + # test advance + def test_case2(self): + # + # OFFSET merge file data with memory data + # + + # offset + sql = "select * from t1 limit 10 offset 72000" + tdSql.waitedQuery(sql, 10, WAITS) + tdSql.checkData(0, 1, 72000) + + # each insert one row into NO.0 NO.2 NO.7 blocks + sql = "insert into t1 values (%d, 0) (%d, 2) (%d, 7)"%(self.ts+1, self.ts + 2*3300*1000+1, self.ts + 7*3300*1000+1) + tdSql.execute(sql) + # query result + sql = "select * from t1 limit 10 offset 72000" + tdSql.waitedQuery(sql, 10, WAITS) + tdSql.checkData(0, 1, 72000 - 3) + + # have where + sql = "select * from t1 where ts>='2017-07-14 10:40:10' and ts<'2017-07-22 18:40:10' limit 10 offset 72000" + tdSql.waitedQuery(sql, 10, WAITS) + tdSql.checkData(0, 1, 72000 - 3 + 10 + 1) + + # have where desc + sql = "select * from t1 where ts<'2017-07-14 20:40:00' order by ts desc limit 15 offset 36000" + tdSql.waitedQuery(sql, 3, WAITS) + tdSql.checkData(0, 1, 1) + + +# +# add case with filename +# +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/query/queryMetaData.py b/tests/pytest/query/queryMetaData.py new file mode 100755 index 0000000000000000000000000000000000000000..67df20cb9ad6c399715927c6be5925932e4c2f71 --- /dev/null +++ b/tests/pytest/query/queryMetaData.py @@ -0,0 +1,184 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +import threading +import time +from datetime import datetime + + +class MetadataQuery: + def initConnection(self): + self.tables = 100000 + self.records = 10 + self.numOfTherads = 20 + self.ts = 1537146000000 + self.host = "127.0.0.1" + self.user = "root" + self.password = "taosdata" + self.config = "/etc/taos" + + def connectDB(self): + self.conn = taos.connect( + self.host, + self.user, + self.password, + self.config) + return self.conn.cursor() + + def createStable(self): + print("================= Create stable meters =================") + cursor = self.connectDB() + cursor.execute("drop database if exists test") + cursor.execute("create database test") + cursor.execute("use test") + cursor.execute('''create table if not exists meters (ts timestamp, speed int) tags( + tgcol1 tinyint, tgcol2 smallint, tgcol3 int, tgcol4 bigint, tgcol5 float, tgcol6 double, tgcol7 bool, tgcol8 binary(20), tgcol9 nchar(20), + tgcol10 tinyint, tgcol11 smallint, tgcol12 int, tgcol13 bigint, tgcol14 float, tgcol15 double, tgcol16 bool, tgcol17 binary(20), tgcol18 nchar(20), + tgcol19 tinyint, tgcol20 smallint, tgcol21 int, tgcol22 bigint, tgcol23 float, tgcol24 double, tgcol25 bool, tgcol26 binary(20), tgcol27 nchar(20), + tgcol28 tinyint, tgcol29 smallint, tgcol30 int, tgcol31 bigint, tgcol32 float, tgcol33 double, tgcol34 bool, tgcol35 binary(20), tgcol36 nchar(20), + tgcol37 tinyint, tgcol38 smallint, tgcol39 int, tgcol40 bigint, tgcol41 float, tgcol42 double, tgcol43 bool, tgcol44 binary(20), tgcol45 nchar(20), + tgcol46 tinyint, tgcol47 smallint, tgcol48 int, tgcol49 bigint, tgcol50 float, tgcol51 double, tgcol52 bool, tgcol53 binary(20), tgcol54 nchar(20))''') + cursor.close() + self.conn.close() + + def createTablesAndInsertData(self, threadID): + cursor = self.connectDB() + cursor.execute("use test") + + tablesPerThread = int(self.tables / self.numOfTherads) + base = threadID * tablesPerThread + for i in range(tablesPerThread): + cursor.execute( + '''create table t%d using meters tags( + %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', + %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', + %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', + %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', + %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', + %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')''' % + (base + i + 1, (base + i) % + 100, (base + i) % + 10000, (base + i) % + 1000000, (base + i) % + 100000000, (base + i) % + 100 * 1.1, (base + i) % + 100 * 2.3, (base + i) % + 2, (base + i) % + 100, (base + i) % + 100, (base + i) % + 100, (base + i) % + 10000, (base + i) % + 1000000, (base + i) % + 100000000, (base + i) % + 100 * 1.1, (base + i) % + 100 * 2.3, (base + i) % + 2, (base + i) % + 100, (base + i) % + 100, (base + i) % + 100, (base + i) % + 10000, (base + i) % + 1000000, (base + i) % + 100000000, (base + i) % + 100 * 1.1, (base + i) % + 100 * 2.3, (base + i) % + 2, (base + i) % + 100, (base + i) % + 100, (base + i) % + 100, (base + i) % + 10000, (base + i) % + 1000000, (base + i) % + 100000000, (base + i) % + 100 * 1.1, (base + i) % + 100 * 2.3, (base + i) % + 2, (base + i) % + 100, (base + i) % + 100, (base + i) % + 100, (base + i) % + 10000, (base + i) % + 1000000, (base + i) % + 100000000, (base + i) % + 100 * 1.1, (base + i) % + 100 * 2.3, (base + i) % + 2, (base + i) % + 100, (base + i) % + 100, (base + i) % + 100, (base + i) % + 10000, (base + i) % + 1000000, (base + i) % + 100000000, (base + i) % + 100 * 1.1, (base + i) % + 100 * 2.3, (base + i) % + 2, (base + i) % + 100, (base + i) % + 100)) + + cursor.execute( + "insert into t%d values(%d, 1) (%d, 2) (%d, 3) (%d, 4) (%d, 5)" % + (base + i + 1, self.ts + 1, self.ts + 2, self.ts + 3, self.ts + 4, self.ts + 5)) + cursor.close() + + def queryData(self, query): + cursor = self.connectDB() + cursor.execute("use test") + + print("================= query tag data =================") + startTime = datetime.now() + cursor.execute(query) + cursor.fetchall() + endTime = datetime.now() + print( + "Query time for the above query is %d seconds" % + (endTime - startTime).seconds) + + cursor.close() + self.conn.close() + + +if __name__ == '__main__': + + t = MetadataQuery() + t.initConnection() + t.createStable() + + print( + "================= Create %d tables and insert %d records into each table =================" % + (t.tables, t.records)) + startTime = datetime.now() + threads = [] + for i in range(t.numOfTherads): + thread = threading.Thread( + target=t.createTablesAndInsertData, args=(i,)) + thread.start() + threads.append(thread) + + for th in threads: + th.join() + + endTime = datetime.now() + diff = (endTime - startTime).seconds + print( + "spend %d seconds to create %d tables and insert %d records into each table" % + (diff, t.tables, t.records)) + + query = '''select tgcol1, tgcol2, tgcol3, tgcol4, tgcol5, tgcol6, tgcol7, tgcol8, tgcol9, + tgcol10, tgcol11, tgcol12, tgcol13, tgcol14, tgcol15, tgcol16, tgcol17, tgcol18, + tgcol19, tgcol20, tgcol21, tgcol22, tgcol23, tgcol24, tgcol25, tgcol26, tgcol27, + tgcol28, tgcol29, tgcol30, tgcol31, tgcol32, tgcol33, tgcol34, tgcol35, tgcol36, + tgcol37, tgcol38, tgcol39, tgcol40, tgcol41, tgcol42, tgcol43, tgcol44, tgcol45, + tgcol46, tgcol47, tgcol48, tgcol49, tgcol50, tgcol51, tgcol52, tgcol53, tgcol54 + from meters where tgcol1 > 10 AND tgcol1 < 100 and tgcol2 > 100 and tgcol2 < 1000 or tgcol3 > 10000 or tgcol7 = true + or tgcol8 like '%2' and tgcol10 < 10''' + + t.queryData(query) diff --git a/tests/pytest/query/queryMetaPerformace.py b/tests/pytest/query/queryMetaPerformace.py new file mode 100644 index 0000000000000000000000000000000000000000..8ab7105c9d92c57ff06e39d308c9e80eb6f09814 --- /dev/null +++ b/tests/pytest/query/queryMetaPerformace.py @@ -0,0 +1,221 @@ + +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +import threading +import time +from datetime import datetime +import numpy as np + + +class MyThread(threading.Thread): + + def __init__(self, func, args=()): + super(MyThread, self).__init__() + self.func = func + self.args = args + + def run(self): + self.result = self.func(*self.args) + + def get_result(self): + try: + return self.result # 如果子线程不使用join方法,此处可能会报没有self.result的错误 + except Exception: + return None + + +class MetadataQuery: + def initConnection(self): + self.tables = 100 + self.records = 10 + self.numOfTherads = 5 + self.ts = 1537146000000 + self.host = "127.0.0.1" + self.user = "root" + self.password = "taosdata" + self.config = "/etc/taos" + self.conn = taos.connect( + self.host, + self.user, + self.password, + self.config) + + def connectDB(self): + return self.conn.cursor() + + def createStable(self): + print("================= Create stable meters =================") + cursor = self.connectDB() + cursor.execute("drop database if exists test") + cursor.execute("create database test") + cursor.execute("use test") + cursor.execute('''create table if not exists meters (ts timestamp, speed int) tags( + tgcol1 tinyint, tgcol2 smallint, tgcol3 int, tgcol4 bigint, tgcol5 float, tgcol6 double, tgcol7 bool, tgcol8 binary(20), tgcol9 nchar(20), + tgcol10 tinyint, tgcol11 smallint, tgcol12 int, tgcol13 bigint, tgcol14 float, tgcol15 double, tgcol16 bool, tgcol17 binary(20), tgcol18 nchar(20), + tgcol19 tinyint, tgcol20 smallint, tgcol21 int, tgcol22 bigint, tgcol23 float, tgcol24 double, tgcol25 bool, tgcol26 binary(20), tgcol27 nchar(20), + tgcol28 tinyint, tgcol29 smallint, tgcol30 int, tgcol31 bigint, tgcol32 float, tgcol33 double, tgcol34 bool, tgcol35 binary(20), tgcol36 nchar(20), + tgcol37 tinyint, tgcol38 smallint, tgcol39 int, tgcol40 bigint, tgcol41 float, tgcol42 double, tgcol43 bool, tgcol44 binary(20), tgcol45 nchar(20), + tgcol46 tinyint, tgcol47 smallint, tgcol48 int, tgcol49 bigint, tgcol50 float, tgcol51 double, tgcol52 bool, tgcol53 binary(20), tgcol54 nchar(20))''') + cursor.close() + + def createTablesAndInsertData(self, threadID): + cursor = self.connectDB() + cursor.execute("use test") + base = threadID * self.tables + + tablesPerThread = int(self.tables / self.numOfTherads) + for i in range(tablesPerThread): + cursor.execute( + '''create table t%d using meters tags( + %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', + %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', + %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', + %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', + %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', + %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')''' % + (base + i + 1, (base + i) % + 100, (base + i) % + 10000, (base + i) % + 1000000, (base + i) % + 100000000, (base + i) % + 100 * 1.1, (base + i) % + 100 * 2.3, (base + i) % + 2, (base + i) % + 100, (base + i) % + 100, (base + i) % + 100, (base + i) % + 10000, (base + i) % + 1000000, (base + i) % + 100000000, (base + i) % + 100 * 1.1, (base + i) % + 100 * 2.3, (base + i) % + 2, (base + i) % + 100, (base + i) % + 100, (base + i) % + 100, (base + i) % + 10000, (base + i) % + 1000000, (base + i) % + 100000000, (base + i) % + 100 * 1.1, (base + i) % + 100 * 2.3, (base + i) % + 2, (base + i) % + 100, (base + i) % + 100, (base + i) % + 100, (base + i) % + 10000, (base + i) % + 1000000, (base + i) % + 100000000, (base + i) % + 100 * 1.1, (base + i) % + 100 * 2.3, (base + i) % + 2, (base + i) % + 100, (base + i) % + 100, (base + i) % + 100, (base + i) % + 10000, (base + i) % + 1000000, (base + i) % + 100000000, (base + i) % + 100 * 1.1, (base + i) % + 100 * 2.3, (base + i) % + 2, (base + i) % + 100, (base + i) % + 100, (base + i) % + 100, (base + i) % + 10000, (base + i) % + 1000000, (base + i) % + 100000000, (base + i) % + 100 * 1.1, (base + i) % + 100 * 2.3, (base + i) % + 2, (base + i) % + 100, (base + i) % + 100)) + for j in range(self.records): + cursor.execute( + "insert into t%d values(%d, %d)" % + (base + i + 1, self.ts + j, j)) + cursor.close() + + def queryWithTagId(self, threadId, tagId, queryNum): + print("---------thread%d start-----------" % threadId) + query = '''select tgcol1, tgcol2, tgcol3, tgcol4, tgcol5, tgcol6, tgcol7, tgcol8, tgcol9, + tgcol10, tgcol11, tgcol12, tgcol13, tgcol14, tgcol15, tgcol16, tgcol17, tgcol18, + tgcol19, tgcol20, tgcol21, tgcol22, tgcol23, tgcol24, tgcol25, tgcol26, tgcol27, + tgcol28, tgcol29, tgcol30, tgcol31, tgcol32, tgcol33, tgcol34, tgcol35, tgcol36, + tgcol37, tgcol38, tgcol39, tgcol40, tgcol41, tgcol42, tgcol43, tgcol44, tgcol45, + tgcol46, tgcol47, tgcol48, tgcol49, tgcol50, tgcol51, tgcol52, tgcol53, tgcol54 + from meters where tgcol{id} > {condition}''' + latancy = [] + cursor = self.connectDB() + cursor.execute("use test") + for i in range(queryNum): + startTime = time.time() + cursor.execute(query.format(id=tagId, condition=i)) + cursor.fetchall() + latancy.append((time.time() - startTime)) + print("---------thread%d end-----------" % threadId) + return latancy + + def queryData(self, query): + cursor = self.connectDB() + cursor.execute("use test") + + print("================= query tag data =================") + startTime = datetime.now() + cursor.execute(query) + cursor.fetchall() + endTime = datetime.now() + print( + "Query time for the above query is %d seconds" % + (endTime - startTime).seconds) + + cursor.close() + # self.conn.close() + + +if __name__ == '__main__': + + t = MetadataQuery() + t.initConnection() + + latancys = [] + threads = [] + tagId = 1 + queryNum = 1000 + for i in range(t.numOfTherads): + thread = MyThread(t.queryWithTagId, args=(i, tagId, queryNum)) + threads.append(thread) + thread.start() + for i in range(t.numOfTherads): + threads[i].join() + latancys.extend(threads[i].get_result()) + print("Total query: %d" % (queryNum * t.numOfTherads)) + print( + "statistic(s): mean= %f, P50 = %f, P75 = %f, P95 = %f, P99 = %f" % + (sum(latancys) / + ( + queryNum * + t.numOfTherads), + np.percentile( + latancys, + 50), + np.percentile( + latancys, + 75), + np.percentile( + latancys, + 95), + np.percentile( + latancys, + 99))) diff --git a/tests/pytest/query/queryNormal.py b/tests/pytest/query/queryNormal.py new file mode 100644 index 0000000000000000000000000000000000000000..73f131faaed8cecde74abf81dfac7ab448ab8edb --- /dev/null +++ b/tests/pytest/query/queryNormal.py @@ -0,0 +1,180 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import platform + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + print("==============step1") + + tdSql.execute( + "create table stb1 (ts timestamp, c1 int, c2 float) tags(t1 int, t2 binary(10), t3 nchar(10))") + tdSql.execute( + "insert into tb1 using stb1 tags(1,'tb1', '表1') values ('2020-04-18 15:00:00.000', 1, 0.1), ('2020-04-18 15:00:01.000', 2, 0.1)") + tdSql.execute( + "insert into tb2 using stb1 tags(2,'tb2', '表2') values ('2020-04-18 15:00:02.000', 3, 2.1), ('2020-04-18 15:00:03.000', 4, 2.2)") + + tdSql.error("select * from tb 1") + + tdSql.query("select * from tb1 a, tb2 b where a.ts = b.ts") + tdSql.checkRows(0) + + # join 3 tables -- bug exists + tdSql.error("select stb_t.ts, stb_t.dscrption, stb_t.temperature, stb_p.id, stb_p.dscrption, stb_p.pressure,stb_v.velocity from stb_p, stb_t, stb_v where stb_p.ts=stb_t.ts and stb_p.ts=stb_v.ts and stb_p.id = stb_t.id") + + tdSql.error("select * from stb1 whern c1 > 'test' limit 100") + + # query show stable + tdSql.query("show stables") + tdSql.checkRows(1) + + # query show tables + tdSql.query("show tables") + tdSql.checkRows(2) + + # query count + tdSql.query("select count(*) from stb1") + tdSql.checkData(0, 0, 4) + + # query first + tdSql.query("select first(*) from stb1") + tdSql.checkData(0, 1, 1) + + # query last + tdSql.query("select last(*) from stb1") + tdSql.checkData(0, 1, 4) + + # query last_row + tdSql.query("select last_row(*) from stb1") + tdSql.checkData(0, 1, 4) + + # query as + tdSql.query("select t2 as number from stb1") + tdSql.checkRows(2) + + # query first ... as + tdSql.error("select first(*) as begin from stb1") + + # query last ... as + tdSql.error("select last(*) as end from stb1") + + # query last_row ... as + tdSql.error("select last_row(*) as end from stb1") + + # query group .. by + tdSql.query("select sum(c1), t2 from stb1 group by t2") + tdSql.checkRows(2) + + # query ... limit + tdSql.query("select * from stb1 limit 2") + tdSql.checkRows(2) + + # query ... limit offset + tdSql.query("select * from stb1 limit 2 offset 3") + tdSql.checkRows(1) + + # query ... alias for table + tdSql.query("select t.ts from tb1 t") + tdSql.checkRows(2) + + # query ... tbname + tdSql.query("select tbname from stb1") + tdSql.checkRows(2) + + # query ... tbname count ---- bug + tdSql.query("select count(tbname) from stb1") + tdSql.checkData(0, 0, 2) + + # query ... select database ---- bug + tdSql.query("SELECT database()") + tdSql.checkRows(1) + + # query ... select client_version ---- bug + tdSql.query("SELECT client_version()") + tdSql.checkRows(1) + + # query ... select server_version ---- bug + tdSql.query("SELECT server_version()") + tdSql.checkRows(1) + + # query ... select server_status ---- bug + tdSql.query("SELECT server_status()") + tdSql.checkRows(1) + + # https://jira.taosdata.com:18080/browse/TD-3800 + tdSql.execute("create table m1(ts timestamp, k int) tags(a int)") + tdSql.execute("create table tm0 using m1 tags(1)") + tdSql.execute("create table tm1 using m1 tags(2)") + tdSql.execute("insert into tm0 values('2020-3-1 1:1:1', 112)") + tdSql.execute("insert into tm1 values('2020-1-1 1:1:1', 1)('2020-3-1 0:1:1', 421)") + + tdSql.query("select last(*) from m1 group by tbname") + tdSql.checkData(0, 0, "2020-03-01 01:01:01") + tdSql.checkData(0, 1, 112) + tdSql.checkData(0, 2, "tm0") + tdSql.checkData(1, 0, "2020-03-01 00:01:01") + tdSql.checkData(1, 1, 421) + tdSql.checkData(1, 2, "tm1") + + if platform.system() == "Linux": + tdDnodes.stop(1) + tdDnodes.start(1) + + tdSql.query("select last(*) from m1 group by tbname") + tdSql.checkData(0, 0, "2020-03-01 01:01:01") + tdSql.checkData(0, 1, 112) + tdSql.checkData(0, 2, "tm0") + tdSql.checkData(1, 0, "2020-03-01 00:01:01") + tdSql.checkData(1, 1, 421) + tdSql.checkData(1, 2, "tm1") + + # TD-12980 + if platform.system() == "Linux": + types = ["tinyint unsigned", "smallint unsigned", "int unsigned", "bigint unsigned"] + ts = 1640000000000 + + for type in types: + tdSql.execute("drop table if exists csvtest") + tdSql.execute("create table csvtest(ts timestamp, c1 %s)" % type) + for i in range(10): + tdSql.execute("insert into csvtest values(%d, %d)" % (ts + i, i)) + + os.system("taos -s 'select c1 from db.csvtest >> a.csv'") + + tdSql.query("select c1 from csvtest") + for i in range(10): + r = os.popen("sed -n %dp a.csv" % (i + 2)) + data = r.read() + tdSql.checkData(i, 0, int(data)) + + os.system("rm -rf a.csv") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/queryNullValueTest.py b/tests/pytest/query/queryNullValueTest.py new file mode 100644 index 0000000000000000000000000000000000000000..5a95b369fe39d6bc1216847b3f108dff7d7171b7 --- /dev/null +++ b/tests/pytest/query/queryNullValueTest.py @@ -0,0 +1,86 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.types = ["tinyint", "smallint", "int", "bigint", "float", "double", "bool", "binary(10)", "nchar(10)", "tinyint unsigned", "smallint unsigned", "int unsigned", "bigint unsigned"] + self.ts = 1537146000000 + + def checkNullValue(self, result): + mx = np.array(result) + [rows, cols] = mx.shape + for i in range(rows): + for j in range(cols): + if j + 1 < cols and mx[i, j + 1] is not None: + print(mx[i, j + 1]) + return False + return True + + def run(self): + tdSql.prepare() + + for i in range(len(self.types)): + tdSql.execute("drop table if exists t0") + tdSql.execute("drop table if exists t1") + + print("======== checking type %s ==========" % self.types[i]) + tdSql.execute("create table t0 (ts timestamp, col %s)" % self.types[i]) + tdSql.execute("insert into t0 values (%d, NULL)" % (self.ts)) + + tdDnodes.stop(1) + # tdLog.sleep(10) + tdDnodes.start(1) + tdSql.execute("use db") + tdSql.query("select * from t0") + tdSql.checkRows(1) + + if self.checkNullValue(tdSql.queryResult) is False: + tdLog.exit("no None value is detected") + + tdSql.execute("create table t1 (ts timestamp, col %s)" % self.types[i]) + tdSql.execute("insert into t1 values (%d, NULL)" % (self.ts)) + tdDnodes.stop(1) + # tdLog.sleep(10) + tdDnodes.start(1) + tdSql.execute("use db") + + for j in range(150): + tdSql.execute("insert into t1 values (%d, NULL)" % (self.ts + j + 1)); + + tdSql.query("select * from t1") + tdSql.checkRows(151) + + if self.checkNullValue(tdSql.queryResult) is False: + tdLog.exit("no None value is detected") + + print("======== None value check for type %s is OK ==========" % self.types[i]) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/queryPerformance.py b/tests/pytest/query/queryPerformance.py new file mode 100644 index 0000000000000000000000000000000000000000..29e5cb19b75b0943c24382d268e81daebed01cdf --- /dev/null +++ b/tests/pytest/query/queryPerformance.py @@ -0,0 +1,237 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + + +import sys +import os +import taos +import time +import argparse +import json + + +class taosdemoQueryPerformace: + def __init__(self, clearCache, commitID, dbName, stbName, tbPerfix, branch, type): + self.clearCache = clearCache + self.commitID = commitID + self.dbName = dbName + self.stbName = stbName + self.tbPerfix = tbPerfix + self.branch = branch + self.type = type + self.host = "127.0.0.1" + self.user = "root" + self.password = "taosdata" + self.config = "/etc/perf" + self.conn = taos.connect( + self.host, + self.user, + self.password, + self.config) + self.host2 = "192.168.1.179" + self.conn2 = taos.connect( + host = self.host2, + user = self.user, + password = self.password, + config = self.config) + + def createPerfTables(self): + cursor2 = self.conn2.cursor() + cursor2.execute("create database if not exists %s" % self.dbName) + cursor2.execute("use %s" % self.dbName) + cursor2.execute("create table if not exists %s(ts timestamp, query_time_avg float, query_time_max float, query_time_min float, commit_id binary(50), branch binary(50), type binary(20)) tags(query_id int, query_sql binary(300))" % self.stbName) + + sql = "select count(*) from test.meters" + tableid = 1 + cursor2.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) + + sql = "select avg(f1), max(f2), min(f3) from test.meters" + tableid = 2 + cursor2.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) + + sql = "select count(*) from test.meters where loc='beijing'" + tableid = 3 + cursor2.execute("create table if not exists %s%d using %s tags(%d, \"%s\")" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) + + sql = "select avg(f1), max(f2), min(f3) from test.meters where areaid=10" + tableid = 4 + cursor2.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) + + sql = "select avg(f1), max(f2), min(f3) from test.t10 interval(10s)" + tableid = 5 + cursor2.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) + + sql = "select last_row(*) from meters" + tableid = 6 + cursor2.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) + + sql = "select * from meters limit 10000" + tableid = 7 + cursor2.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) + + sql = "select avg(f1), max(f2), min(f3) from meters where ts <= '2017-07-15 10:40:01.000' and ts <= '2017-07-15 14:00:40.000'" + tableid = 8 + cursor2.execute("create table if not exists %s%d using %s tags(%d, \"%s\")" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) + + sql = "select last(*) from meters" + tableid = 9 + cursor2.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) + + cursor2.close() + + def generateQueryJson(self): + + sqls = [] + cursor2 = self.conn2.cursor() + cursor2.execute("select query_id, query_sql from %s.%s" % (self.dbName, self.stbName)) + i = 0 + for data in cursor2: + sql = { + "sql": data[1], + "result_mode": "onlyformat", + "result_file": "./query_sql_res%d.txt" % i + } + sqls.append(sql) + i += 1 + + query_data = { + "filetype": "query", + "cfgdir": "/etc/perf", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "databases": "test", + "specified_table_query": { + "query_times": 100, + "concurrent": 1, + "sqls": sqls + } + } + + query_json_file = f"/tmp/query.json" + + with open(query_json_file, 'w') as f: + json.dump(query_data, f) + return query_json_file + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosdemo" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def getCMDOutput(self, cmd): + cmd = os.popen(cmd) + output = cmd.read() + cmd.close() + return output + + def query(self): + buildPath = self.getBuildPath() + if (buildPath == ""): + print("taosdemo not found!") + sys.exit(1) + + binPath = buildPath + "/build/bin/" + os.system( + "%sperfMonitor -f %s > query_res.txt" % + (binPath, self.generateQueryJson())) + + cursor = self.conn2.cursor() + print("==================== query performance ====================") + cursor.execute("use %s" % self.dbName) + cursor.execute("select tbname, query_sql from %s" % self.stbName) + + i = 0 + for data in cursor: + table_name = data[0] + sql = data[1] + + self.avgDelay = self.getCMDOutput("grep 'avgDelay' query_res.txt | awk 'NR==%d{print $2}'" % (i + 1)) + self.maxDelay = self.getCMDOutput("grep 'avgDelay' query_res.txt | awk 'NR==%d{print $5}'" % (i + 1)) + self.minDelay = self.getCMDOutput("grep 'avgDelay' query_res.txt | awk 'NR==%d{print $8}'" % (i + 1)) + i += 1 + + print("query time for: %s %f seconds" % (sql, float(self.avgDelay))) + c = self.conn2.cursor() + c.execute("insert into %s.%s values(now, %f, %f, %f, '%s', '%s', '%s')" % (self.dbName, table_name, float(self.avgDelay), float(self.maxDelay), float(self.minDelay), self.commitID, self.branch, self.type)) + + c.close() + cursor.close() + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + parser.add_argument( + '-r', + '--remove-cache', + action='store_true', + default=False, + help='clear cache before query (default: False)') + parser.add_argument( + '-c', + '--commit-id', + action='store', + default='null', + type=str, + help='git commit id (default: null)') + parser.add_argument( + '-d', + '--database-name', + action='store', + default='perf', + type=str, + help='Database name to be created (default: perf)') + parser.add_argument( + '-t', + '--stable-name', + action='store', + default='query_tb', + type=str, + help='table name to be created (default: query_tb)') + parser.add_argument( + '-p', + '--table-perfix', + action='store', + default='q', + type=str, + help='table name perfix (default: q)') + parser.add_argument( + '-b', + '--git-branch', + action='store', + default='master', + type=str, + help='git branch (default: master)') + parser.add_argument( + '-T', + '--build-type', + action='store', + default='glibc', + type=str, + help='build type (default: glibc)') + + args = parser.parse_args() + perftest = taosdemoQueryPerformace(args.remove_cache, args.commit_id, args.database_name, args.stable_name, args.table_perfix, args.git_branch, args.build_type) + perftest.createPerfTables() + perftest.query() \ No newline at end of file diff --git a/tests/pytest/query/queryPriKey.py b/tests/pytest/query/queryPriKey.py new file mode 100644 index 0000000000000000000000000000000000000000..c2a68b23ed681fef68c59f487af32c913a2abdfe --- /dev/null +++ b/tests/pytest/query/queryPriKey.py @@ -0,0 +1,54 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + tdSql.execute("drop database if exists tdb") + tdSql.execute("create database if not exists tdb keep 3650") + tdSql.execute("use tdb") + + tdSql.execute( + "create table stb1 (time timestamp, c1 int) TAGS (t1 int)" + ) + + tdSql.execute( + "insert into t1 using stb1 tags(1) values (now - 1m, 1)" + ) + tdSql.execute( + "insert into t1 using stb1 tags(1) values (now - 2m, 2)" + ) + tdSql.execute( + "insert into t1 using stb1 tags(1) values (now - 3m, 3)" + ) + + res = tdSql.getColNameList("select count(*) from t1 interval(1m)") + assert res[0] == 'time' + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/querySecondtscolumnTowherenow.py b/tests/pytest/query/querySecondtscolumnTowherenow.py new file mode 100644 index 0000000000000000000000000000000000000000..dae50abdf09b68c2815c43bccdf2faa8cb8b5316 --- /dev/null +++ b/tests/pytest/query/querySecondtscolumnTowherenow.py @@ -0,0 +1,131 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug(f"start to execute {__file__}") + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.execute("drop database if exists db") + tdSql.execute("create database if not exists db keep 36500") + tdSql.execute("use db") + + tdLog.printNoPrefix("==========step1:create table && insert data") + # timestamp list: + # 0->"1970-01-01 08:00:00" | -28800000->"1970-01-01 00:00:00" | -946800000000->"1940-01-01 00:00:00" + ts1 = 0 + ts2 = -28800000 + ts3 = -946800000000 + tdSql.execute( + "create table stb2ts (ts timestamp, ts1 timestamp, ts2 timestamp, c1 int, ts3 timestamp) TAGS(t1 int)" + ) + tdSql.execute("create table t2ts1 using stb2ts tags(1)") + + tdSql.execute("insert into t2ts1 values (now, now, now, 1, now)") + tdSql.execute("insert into t2ts1 values (now-1m, now-1m, now-1m, 1, now-1m)") + tdSql.execute(f"insert into t2ts1 values ({ts1}, {ts1}, {ts1}, 1, {ts1})") + # tdSql.execute(f"insert into t2ts1 values ({ts2}, {ts2}, {ts2}, 1, {ts2})") + # tdSql.execute(f"insert into t2ts1 values ({ts3}, {ts3}, {ts3}, 1, {ts3})") + + tdLog.printNoPrefix("==========step2:query") + time.sleep(1) + # query primary key timestamp column + tdSql.execute("select * from t2ts1 where ts < now") + ts_len1 = len(tdSql.cursor.fetchall()) + tdSql.execute("select * from t2ts1 where ts <= now") + ts_len2 = len(tdSql.cursor.fetchall()) + tdSql.execute("select * from t2ts1 where ts > now") + ts_len3 = len(tdSql.cursor.fetchall()) + tdSql.execute("select * from t2ts1 where ts >= now") + ts_len4 = len(tdSql.cursor.fetchall()) + tdSql.execute("select * from t2ts1 where ts = now") + ts_len5 = len(tdSql.cursor.fetchall()) + # tdSql.execute("select * from t2ts1 where ts <> now") + ts_len6 = 3 + tdSql.execute("select * from t2ts1 where ts between 0 and now") + ts_len7 = len(tdSql.cursor.fetchall()) + tdSql.execute("select * from t2ts1 where ts between now and now+100d") + ts_len8 = len(tdSql.cursor.fetchall()) + + # query noemal timestamp column + tdSql.query("select * from t2ts1 where ts1 < now") + tdSql.checkRows(ts_len1) + tdSql.query("select * from t2ts1 where ts2 < now") + tdSql.checkRows(ts_len1) + tdSql.query("select * from t2ts1 where ts3 < now") + tdSql.checkRows(ts_len1) + + tdSql.query("select * from t2ts1 where ts1 <= now") + tdSql.checkRows(ts_len2) + tdSql.query("select * from t2ts1 where ts2 <= now") + tdSql.checkRows(ts_len2) + tdSql.query("select * from t2ts1 where ts3 <= now") + tdSql.checkRows(ts_len2) + + tdSql.query("select * from t2ts1 where ts1 > now") + tdSql.checkRows(ts_len3) + tdSql.query("select * from t2ts1 where ts2 > now") + tdSql.checkRows(ts_len3) + tdSql.query("select * from t2ts1 where ts3 > now") + tdSql.checkRows(ts_len3) + + tdSql.query("select * from t2ts1 where ts1 >= now") + tdSql.checkRows(ts_len4) + tdSql.query("select * from t2ts1 where ts2 >= now") + tdSql.checkRows(ts_len4) + tdSql.query("select * from t2ts1 where ts3 >= now") + tdSql.checkRows(ts_len4) + + tdSql.query("select * from t2ts1 where ts1 = now") + tdSql.checkRows(ts_len5) + tdSql.query("select * from t2ts1 where ts2 = now") + tdSql.checkRows(ts_len5) + tdSql.query("select * from t2ts1 where ts2 = now") + tdSql.checkRows(ts_len5) + + tdSql.query("select * from t2ts1 where ts1 <> now") + tdSql.checkRows(ts_len6) + tdSql.query("select * from t2ts1 where ts2 <> now") + tdSql.checkRows(ts_len6) + tdSql.query("select * from t2ts1 where ts3 <> now") + tdSql.checkRows(ts_len6) + + tdSql.query("select * from t2ts1 where ts1 between 0 and now") + tdSql.checkRows(ts_len7) + tdSql.query("select * from t2ts1 where ts2 between 0 and now") + tdSql.checkRows(ts_len7) + tdSql.query("select * from t2ts1 where ts3 between 0 and now") + tdSql.checkRows(ts_len7) + + tdSql.query("select * from t2ts1 where ts1 between now and now+100d") + tdSql.checkRows(ts_len8) + tdSql.query("select * from t2ts1 where ts2 between now and now+100d") + tdSql.checkRows(ts_len8) + tdSql.query("select * from t2ts1 where ts3 between now and now+100d") + tdSql.checkRows(ts_len8) + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/query/querySession.py b/tests/pytest/query/querySession.py new file mode 100644 index 0000000000000000000000000000000000000000..216ff68b71e0286b1783056b7cbc1165a572f38b --- /dev/null +++ b/tests/pytest/query/querySession.py @@ -0,0 +1,180 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + def run(self): + tdSql.prepare() + + print("==============step1") + tdSql.execute( + "create table if not exists st (ts timestamp, tagtype int) tags(dev nchar(50), tag2 binary(16))") + tdSql.execute( + 'CREATE TABLE if not exists dev_001 using st tags("dev_01", "tag_01")') + tdSql.execute( + 'CREATE TABLE if not exists dev_002 using st tags("dev_02", "tag_02")') + + print("==============step2") + + tdSql.execute( + """INSERT INTO dev_001 VALUES('2020-05-13 10:00:00.000', 1)('2020-05-13 10:00:00.005', 2)('2020-05-13 10:00:00.011', 3) + ('2020-05-13 10:00:01.011', 4)('2020-05-13 10:00:01.611', 5)('2020-05-13 10:00:02.612', 6) + ('2020-05-13 10:01:02.612', 7)('2020-05-13 10:02:02.612', 8)('2020-05-13 10:03:02.613', 9) + ('2020-05-13 11:00:00.000', 10)('2020-05-13 12:00:00.000', 11)('2020-05-13 13:00:00.001', 12) + ('2020-05-14 13:00:00.001', 13)('2020-05-15 14:00:00.000', 14)('2020-05-20 10:00:00.000', 15) + ('2020-05-27 10:00:00.001', 16) dev_002 VALUES('2020-05-13 10:00:00.000', 1)('2020-05-13 10:00:00.005', 2)('2020-05-13 10:00:00.009', 3)('2020-05-13 10:00:00.0021', 4) + ('2020-05-13 10:00:00.031', 5)('2020-05-13 10:00:00.036', 6)('2020-05-13 10:00:00.51', 7) + """) + + # session(ts,5a) + tdSql.query("select count(*) from dev_001 session(ts,5a)") + tdSql.checkRows(15) + tdSql.checkData(0, 1, 2) + + # session(ts,5a) main query + tdSql.query("select count(*) from (select * from dev_001) session(ts,5a)") + tdSql.checkRows(15) + tdSql.checkData(0, 1, 2) + + + # session(ts,1s) + tdSql.query("select count(*) from dev_001 session(ts,1s)") + tdSql.checkRows(12) + tdSql.checkData(0, 1, 5) + + # session(ts,1s) main query + tdSql.query("select count(*) from (select * from dev_001) session(ts,1s)") + tdSql.checkRows(12) + tdSql.checkData(0, 1, 5) + + tdSql.query("select count(*) from dev_001 session(ts,1000a)") + tdSql.checkRows(12) + tdSql.checkData(0, 1, 5) + + tdSql.query("select count(*) from (select * from dev_001) session(ts,1000a)") + tdSql.checkRows(12) + tdSql.checkData(0, 1, 5) + + # session(ts,1m) + tdSql.query("select count(*) from dev_001 session(ts,1m)") + tdSql.checkRows(9) + tdSql.checkData(0, 1, 8) + + # session(ts,1m) + tdSql.query("select count(*) from (select * from dev_001) session(ts,1m)") + tdSql.checkRows(9) + tdSql.checkData(0, 1, 8) + + # session(ts,1h) + tdSql.query("select count(*) from dev_001 session(ts,1h)") + tdSql.checkRows(6) + tdSql.checkData(0, 1, 11) + + # session(ts,1h) + tdSql.query("select count(*) from (select * from dev_001) session(ts,1h)") + tdSql.checkRows(6) + tdSql.checkData(0, 1, 11) + + # session(ts,1d) + tdSql.query("select count(*) from dev_001 session(ts,1d)") + tdSql.checkRows(4) + tdSql.checkData(0, 1, 13) + + # session(ts,1d) + tdSql.query("select count(*) from (select * from dev_001) session(ts,1d)") + tdSql.checkRows(4) + tdSql.checkData(0, 1, 13) + + # session(ts,1w) + tdSql.query("select count(*) from dev_001 session(ts,1w)") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 15) + + # session(ts,1w) + tdSql.query("select count(*) from (select * from dev_001) session(ts,1w)") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 15) + + # session with where + tdSql.query("select count(*),first(tagtype),last(tagtype),avg(tagtype),sum(tagtype),min(tagtype),max(tagtype),leastsquares(tagtype, 1, 1),spread(tagtype),stddev(tagtype),percentile(tagtype,0) from dev_001 where ts <'2020-05-20 0:0:0' session(ts,1d)") + + tdSql.checkRows(2) + tdSql.checkData(0, 1, 13) + tdSql.checkData(0, 2, 1) + tdSql.checkData(0, 3, 13) + tdSql.checkData(0, 4, 7) + tdSql.checkData(0, 5, 91) + tdSql.checkData(0, 6, 1) + tdSql.checkData(0, 7, 13) + tdSql.checkData(0, 8, '{slop:1.000000, intercept:0.000000}') + tdSql.checkData(0, 9, 12) + tdSql.checkData(0, 10, 3.741657387) + tdSql.checkData(0, 11, 1) + tdSql.checkData(1, 11, 14) + + # session with where main + + tdSql.query("select count(*),first(tagtype),last(tagtype),avg(tagtype),sum(tagtype),min(tagtype),max(tagtype),leastsquares(tagtype, 1, 1) from (select * from dev_001 where ts <'2020-05-20 0:0:0') session(ts,1d)") + + tdSql.checkRows(2) + tdSql.checkData(0, 1, 13) + tdSql.checkData(0, 2, 1) + tdSql.checkData(0, 3, 13) + tdSql.checkData(0, 4, 7) + tdSql.checkData(0, 5, 91) + tdSql.checkData(0, 6, 1) + tdSql.checkData(0, 7, 13) + tdSql.checkData(0, 8, '{slop:1.000000, intercept:0.000000}') + + # tdsql err + tdSql.error("select * from dev_001 session(ts,1w)") + tdSql.error("select count(*) from st session(ts,1w)") + tdSql.error("select count(*) from dev_001 group by tagtype session(ts,1w) ") + tdSql.error("select count(*) from dev_001 session(ts,1n)") + tdSql.error("select count(*) from dev_001 session(ts,1y)") + tdSql.error("select count(*) from dev_001 session(ts,0s)") + tdSql.error("select count(*) from dev_001 session(i,1y)") + tdSql.error("select count(*) from dev_001 session(ts,1d) where ts <'2020-05-20 0:0:0'") + + #test precision us + tdSql.execute("create database test precision 'us'") + tdSql.execute("use test") + tdSql.execute("create table dev_001 (ts timestamp ,i timestamp ,j int)") + tdSql.execute("insert into dev_001 values(1623046993681000,now,1)(1623046993681001,now+1s,2)(1623046993681002,now+2s,3)(1623046993681004,now+5s,4)") + + # session(ts,1u) + tdSql.query("select count(*) from dev_001 session(ts,1u)") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 3) + tdSql.error("select count(*) from dev_001 session(i,1s)") + # test second timestamp fileds + tdSql.execute("create table secondts(ts timestamp,t2 timestamp,i int)") + tdSql.error("select count(*) from secondts session(t2,2s)") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/querySort.py b/tests/pytest/query/querySort.py new file mode 100644 index 0000000000000000000000000000000000000000..a50b9cbf8afd7052a78e1f6ef85b8c464e816e71 --- /dev/null +++ b/tests/pytest/query/querySort.py @@ -0,0 +1,188 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def checkColumnSorted(self, col, order): + frame = inspect.stack()[1] + callerModule = inspect.getmodule(frame[0]) + callerFilename = callerModule.__file__ + + if col < 0: + tdLog.exit( + "%s failed: sql:%s, col:%d is smaller than zero" % + (callerFilename, tdSql.sql, col)) + if col > tdSql.queryCols: + tdLog.exit( + "%s failed: sql:%s, col:%d is larger than queryCols:%d" % + (callerFilename, tdSql.sql, col, tdSql.queryCols)) + + matrix = np.array(tdSql.queryResult) + list = matrix[:, 0] + + if order == "" or order.upper() == "ASC": + if all(sorted(list) == list): + tdLog.info( + "sql:%s, column :%d is sorted in accending order as expected" % + (tdSql.sql, col)) + else: + tdLog.exit( + "%s failed: sql:%s, col:%d is not sorted in accesnind order" % + (callerFilename, tdSql.sql, col)) + elif order.upper() == "DESC": + if all(sorted(list, reverse=True) == list): + tdLog.info( + "sql:%s, column :%d is sorted in decending order as expected" % + (tdSql.sql, col)) + else: + tdLog.exit( + "%s failed: sql:%s, col:%d is not sorted in decending order" % + (callerFilename, tdSql.sql, col)) + else: + tdLog.exit( + "%s failed: sql:%s, the order provided for col:%d is not correct" % + (callerFilename, tdSql.sql, col)) + + def run(self): + tdSql.prepare() + + print("======= step 1: create table and insert data =========") + tdLog.debug( + ''' create table st(ts timestamp, tbcol1 tinyint, tbcol2 smallint, tbcol3 int, tbcol4 bigint, tbcol5 float, tbcol6 double, + tbcol7 bool, tbcol8 nchar(20), tbcol9 binary(20), tbcol11 tinyint unsigned, tbcol12 smallint unsigned, tbcol13 int unsigned, tbcol14 bigint unsigned) tags(tagcol1 tinyint, tagcol2 smallint, tagcol3 int, tagcol4 bigint, tagcol5 float, + tagcol6 double, tagcol7 bool, tagcol8 nchar(20), tagcol9 binary(20), tagcol11 tinyint unsigned, tagcol12 smallint unsigned, tagcol13 int unsigned, tagcol14 bigint unsigned)''') + tdSql.execute( + ''' create table st(ts timestamp, tbcol1 tinyint, tbcol2 smallint, tbcol3 int, tbcol4 bigint, tbcol5 float, tbcol6 double, + tbcol7 bool, tbcol8 nchar(20), tbcol9 binary(20), tbcol11 tinyint unsigned, tbcol12 smallint unsigned, tbcol13 int unsigned, tbcol14 bigint unsigned) tags(tagcol1 tinyint, tagcol2 smallint, tagcol3 int, tagcol4 bigint, tagcol5 float, + tagcol6 double, tagcol7 bool, tagcol8 nchar(20), tagcol9 binary(20), tagcol11 tinyint unsigned, tagcol12 smallint unsigned, tagcol13 int unsigned, tagcol14 bigint unsigned)''') + + for i in range(self.rowNum): + tdSql.execute("create table st%d using st tags(%d, %d, %d, %d, %f, %f, %d, 'tag%d', '标签%d', %d, %d, %d, %d)" % ( + i + 1, i + 1, i + 1, i + 1, i + 1, 1.1 * (i + 1), 1.23 * (i + 1), (i + 1) % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) + for j in range(self.rowNum): + tdSql.execute("insert into st%d values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" % ( + i + 1, self.ts + 10 * (i + 1) + j + 1, j + 1, j + 1, j + 1, j + 1, 1.1 * (j + 1), 1.23 * (j + 1), (j + 1) % 2, j + 1, j + 1, i + 1, i + 1, i + 1, i + 1)) + + print("======= step 2: verify order for each column =========") + # sort for timestamp in asc order + tdSql.query("select * from st order by ts asc") + self.checkColumnSorted(0, "asc") + + # sort for timestamp in desc order + tdSql.query("select * from st order by ts desc") + self.checkColumnSorted(0, "desc") + + print("======= step 2: verify order for special column =========") + + tdSql.query("select tbcol1 from st order by ts desc") + + tdSql.query("select tbcol6 from st order by ts desc") + + for i in range(1, 10): + tdSql.error("select * from st order by tbcol%d" % i) + tdSql.error("select * from st order by tbcol%d asc" % i) + tdSql.error("select * from st order by tbcol%d desc" % i) + + tdSql.query( + "select avg(tbcol1) from st group by tagcol%d order by tagcol%d" % + (i, i)) + self.checkColumnSorted(1, "") + + tdSql.query( + "select avg(tbcol1) from st group by tagcol%d order by tagcol%d asc" % + (i, i)) + self.checkColumnSorted(1, "asc") + + tdSql.query( + "select avg(tbcol1) from st group by tagcol%d order by tagcol%d desc" % + (i, i)) + self.checkColumnSorted(1, "desc") + + # order by rules: https://jira.taosdata.com:18090/pages/viewpage.action?pageId=123455481 + tdSql.error("select tbcol1 from st order by 123") + tdSql.error("select tbcol1 from st order by tbname") + tdSql.error("select tbcol1 from st order by tagcol1") + tdSql.error("select tbcol1 from st order by ''") + tdSql.error("select top(tbcol1, 12) from st1 order by tbcol1,ts") + tdSql.error("select top(tbcol1, 12) from st order by tbcol1,ts,tbcol2") + tdSql.error("select top(tbcol1, 12) from st order by ts, tbcol1") + tdSql.error("select top(tbcol1, 2) from st1 group by tbcol1 order by tbcol2") + + fun_list = ['avg','count','twa','sum','stddev','leastsquares','min', + 'max','first','last','top','bottom','percentile','apercentile', + 'last_row','diff','spread','distinct'] + key = ['tbol','tagcol'] + for i in range(1,15): + for k in key: + for j in fun_list: + if j == 'leastsquares': + pick_func=j+'('+ k + str(i) +',1,1)' + elif j == 'top' or j == 'bottom' : continue + elif j == 'percentile' or j == 'apercentile': + pick_func=j+'('+ k + str(i) +',1)' + else: + pick_func=j+'('+ k + str(i) +')' + sql = 'select %s from st group by %s order by %s' % (pick_func , k+str(i), k+str(i)) + tdSql.error(sql) + sql = 'select %s from st6 group by %s order by %s ' % (pick_func , k+str(i), k+str(i)) + tdSql.error(sql) + + tdSql.query("select top(tbcol1, 2) from st1 group by tbcol2 order by tbcol2") + tdSql.query("select top(tbcol1, 12) from st order by tbcol1, ts") + + tdSql.query("select avg(tbcol1) from st group by tbname order by tbname") + tdSql.checkData(1, 0, 5.5) + tdSql.checkData(5, 1, "st6") + + tdSql.query("select top(tbcol1, 2) from st group by tbname order by tbname") + tdSql.checkData(1, 1, 10) + tdSql.checkData(2, 2, "st2") + + tdSql.query("select top(tbcol1, 12) from st order by tbcol1") + tdSql.checkData(1, 1, 9) + + tdSql.error("select top(tbcol1, 12) from st1 order by tbcol1,ts") + tdSql.error("select top(tbcol1, 12),tbname from st order by tbcol1,tbname") + + tdSql.query("select top(tbcol1, 12) from st group by tbname order by tbname desc") + tdSql.checkData(1, 2, "st10") + tdSql.checkData(10, 2, "st9") + + tdSql.query("select top(tbcol1, 2) from st group by tbname order by tbname desc,ts") + tdSql.checkData(1, 2, "st10") + tdSql.checkData(10, 2, "st5") + tdSql.checkData(0, 0, "2018-09-17 09:00:00.109") + tdSql.checkData(1, 0, "2018-09-17 09:00:00.110") + tdSql.checkData(2, 0, "2018-09-17 09:00:00.099") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/queryStableJoin.py b/tests/pytest/query/queryStableJoin.py new file mode 100644 index 0000000000000000000000000000000000000000..825942bad8f867301281ffab46f1b7df20fa23f6 --- /dev/null +++ b/tests/pytest/query/queryStableJoin.py @@ -0,0 +1,300 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +import random + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.ts = 1600000000000 + self.num = 10 + + def run(self): + tdSql.prepare() + # test case for https://jira.taosdata.com:18080/browse/TD-5206 + + tdSql.execute('''create stable stable_1 + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint, + q_bool bool , q_binary binary(20) , q_nchar nchar(20) ,q_float float , q_double double , q_ts timestamp) + tags(loc nchar(20) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, + t_bool bool , t_binary binary(20) , t_nchar nchar(20) ,t_float float , t_double double );''') + tdSql.execute('''create stable stable_2 + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint, + q_bool bool , q_binary binary(20) , q_nchar nchar(20) ,q_float float , q_double double , q_ts timestamp) + tags(loc nchar(20) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, + t_bool bool , t_binary binary(20) , t_nchar nchar(20) ,t_float float , t_double double );''') + tdSql.execute('''create table table_0 using stable_1 + tags('table_0' , '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' )''') + tdSql.execute('''create table table_1 using stable_1 + tags('table_1' , '2147483647' , '9223372036854775807' , '32767' , '127' , 1 , + 'binary1' , 'nchar1' , '1' , '11' )''') + tdSql.execute('''create table table_2 using stable_1 + tags('table_2' , '-2147483647' , '-9223372036854775807' , '-32767' , '-127' , false , + 'binary2' , 'nchar2nchar2' , '-2.2' , '-22.22')''') + tdSql.execute('''create table table_3 using stable_1 + tags('table_3' , '3' , '3' , '3' , '3' , true , 'binary3' , 'nchar3' , '33.33' , '3333.3333' )''') + tdSql.execute('''create table table_4 using stable_1 + tags('table_4' , '4' , '4' , '4' , '4' , false , 'binary4' , 'nchar4' , '-444.444' , '-444444.444444' )''') + tdSql.execute('''create table table_5 using stable_1 + tags('table_5' , '5' , '5' , '5' , '5' , true , 'binary5' , 'nchar5' , '5555.5555' , '55555555.55555555' )''') + tdSql.execute('''create table table_21 using stable_2 + tags('table_5' , '5' , '5' , '5' , '5' , true , 'binary5' , 'nchar5' , '5555.5555' , '55555555.55555555' )''') + + for i in range(self.num): + tdSql.execute('''insert into table_0 values(%d, %d, %d, %d, %d, 0, 'binary.%s', 'nchar.%s', %f, %f, %d)''' + % (self.ts + i, i, i, i, i, i, i, i, i, self.ts + i)) + tdSql.execute('''insert into table_1 values(%d, %d, %d, %d, %d, 1, 'binary1.%s', 'nchar1.%s', %f, %f, %d)''' + % (self.ts + i, 2147483647-i, 9223372036854775807-i, 32767-i, 127-i, + i, i, random.random(), random.random(), 1262304000001 + i)) + tdSql.execute('''insert into table_2 values(%d, %d, %d, %d, %d, true, 'binary2.%s', 'nchar2nchar2.%s', %f, %f, %d)''' + % (self.ts + i, -2147483647+i, -9223372036854775807+i, -32767+i, -127+i, + i, i, random.uniform(-1,0), random.uniform(-1,0), 1577836800001 + i)) + tdSql.execute('''insert into table_3 values(%d, %d, %d, %d, %d, false, 'binary3.%s', 'nchar3.%s', %f, %f, %d)''' + % (self.ts + i, random.randint(-2147483647, 2147483647), + random.randint(-9223372036854775807, 9223372036854775807), random.randint(-32767, 32767), + random.randint(-127, 127), random.randint(-100, 100), random.randint(-10000, 10000), + random.uniform(-100000,100000), random.uniform(-1000000000,1000000000), self.ts + i)) + tdSql.execute('''insert into table_4 values(%d, %d, %d, %d, %d, true, 'binary4.%s', 'nchar4.%s', %f, %f, %d)''' + % (self.ts + i, i, i, i, i, i, i, i, i, self.ts + i)) + tdSql.execute('''insert into table_5 values(%d, %d, %d, %d, %d, false, 'binary5.%s', 'nchar5.%s', %f, %f, %d)''' + % (self.ts + i, i, i, i, i, i, i, i, i, self.ts + i)) + tdSql.execute('''insert into table_21 values(%d, %d, %d, %d, %d, false, 'binary5.%s', 'nchar5.%s', %f, %f, %d)''' + % (self.ts + i, i, i, i, i, i, i, i, i, self.ts + i)) + + + tdLog.info("==========TEST1:test all table data==========") + sql = '''select * from stable_1,stable_2 where stable_1.t_nchar = stable_2.t_nchar and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_tinyint = stable_2.t_tinyint and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_binary = stable_2.t_binary and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_double = stable_2.t_double and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_smallint = stable_2.t_smallint and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_bigint = stable_2.t_bigint and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_int = stable_2.t_int and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_float = stable_2.t_float and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_bool = stable_2.t_bool and stable_1.ts = stable_2.ts;''' + tdSql.error(sql) + + tdLog.info("==========TEST1:test drop table_0 data==========") + sql = '''drop table table_0;''' + tdSql.execute(sql) + sql = '''select * from stable_1,stable_2 where stable_1.t_nchar = stable_2.t_nchar and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_tinyint = stable_2.t_tinyint and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_binary = stable_2.t_binary and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_double = stable_2.t_double and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_smallint = stable_2.t_smallint and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_bigint = stable_2.t_bigint and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_int = stable_2.t_int and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_float = stable_2.t_float and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_bool = stable_2.t_bool and stable_1.ts = stable_2.ts;''' + tdSql.error(sql) + + tdLog.info("==========TEST1:test drop table_1 data==========") + sql = '''drop table table_1;''' + tdSql.execute(sql) + sql = '''select * from stable_1,stable_2 where stable_1.t_nchar = stable_2.t_nchar and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_tinyint = stable_2.t_tinyint and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_binary = stable_2.t_binary and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_double = stable_2.t_double and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_smallint = stable_2.t_smallint and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_bigint = stable_2.t_bigint and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_int = stable_2.t_int and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_float = stable_2.t_float and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_bool = stable_2.t_bool and stable_1.ts = stable_2.ts;''' + tdSql.error(sql) + + tdLog.info("==========TEST1:test drop table_2 data==========") + sql = '''drop table table_2;''' + tdSql.execute(sql) + sql = '''select * from stable_1,stable_2 where stable_1.t_nchar = stable_2.t_nchar and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_tinyint = stable_2.t_tinyint and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_binary = stable_2.t_binary and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_double = stable_2.t_double and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_smallint = stable_2.t_smallint and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_bigint = stable_2.t_bigint and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_int = stable_2.t_int and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_float = stable_2.t_float and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_bool = stable_2.t_bool and stable_1.ts = stable_2.ts;''' + tdSql.error(sql) + + tdLog.info("==========TEST1:test drop table_3 data==========") + sql = '''drop table table_3;''' + tdSql.execute(sql) + sql = '''select * from stable_1,stable_2 where stable_1.t_nchar = stable_2.t_nchar and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_tinyint = stable_2.t_tinyint and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_binary = stable_2.t_binary and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_double = stable_2.t_double and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_smallint = stable_2.t_smallint and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_bigint = stable_2.t_bigint and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_int = stable_2.t_int and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_float = stable_2.t_float and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_bool = stable_2.t_bool and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + + tdLog.info("==========TEST1:test drop table_4 data==========") + sql = '''drop table table_4;''' + tdSql.execute(sql) + sql = '''select * from stable_1,stable_2 where stable_1.t_nchar = stable_2.t_nchar and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_tinyint = stable_2.t_tinyint and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_binary = stable_2.t_binary and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_double = stable_2.t_double and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_smallint = stable_2.t_smallint and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_bigint = stable_2.t_bigint and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_int = stable_2.t_int and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_float = stable_2.t_float and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select * from stable_1,stable_2 where stable_1.t_bool = stable_2.t_bool and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(self.num) + + tdLog.info("==========TEST1:test drop table_5 data==========") + sql = '''drop table table_5;''' + tdSql.execute(sql) + sql = '''select * from stable_1,stable_2 where stable_1.t_nchar = stable_2.t_nchar and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(0) + sql = '''select * from stable_1,stable_2 where stable_1.t_tinyint = stable_2.t_tinyint and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(0) + sql = '''select * from stable_1,stable_2 where stable_1.t_binary = stable_2.t_binary and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(0) + sql = '''select * from stable_1,stable_2 where stable_1.t_double = stable_2.t_double and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(0) + sql = '''select * from stable_1,stable_2 where stable_1.t_smallint = stable_2.t_smallint and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(0) + sql = '''select * from stable_1,stable_2 where stable_1.t_bigint = stable_2.t_bigint and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(0) + sql = '''select * from stable_1,stable_2 where stable_1.t_int = stable_2.t_int and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(0) + sql = '''select * from stable_1,stable_2 where stable_1.t_float = stable_2.t_float and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(0) + sql = '''select * from stable_1,stable_2 where stable_1.t_bool = stable_2.t_bool and stable_1.ts = stable_2.ts;''' + tdSql.query(sql) + tdSql.checkRows(0) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/query/queryStateWindow.py b/tests/pytest/query/queryStateWindow.py new file mode 100644 index 0000000000000000000000000000000000000000..e43997eff3a8139b575537356dfb60f9692c35e3 --- /dev/null +++ b/tests/pytest/query/queryStateWindow.py @@ -0,0 +1,151 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + self.rowNum = 100000 + self.ts = 1537146000000 + + def run(self): + tdSql.prepare() + + print("==============step1") + tdSql.execute( + "create table if not exists st (ts timestamp, t1 int, t2 timestamp, t3 bigint, t4 float, t5 double, t6 binary(10), t7 smallint, t8 tinyint, t9 bool, t10 nchar(10), t11 int unsigned, t12 bigint unsigned, t13 smallint unsigned, t14 tinyint unsigned ,t15 int) tags(dev nchar(50), tag2 binary(16))") + tdSql.execute( + 'CREATE TABLE if not exists dev_001 using st tags("dev_01", "tag_01")') + tdSql.execute( + 'CREATE TABLE if not exists dev_002 using st tags("dev_02", "tag_02")') + + print("==============step2") + + tdSql.execute( + "INSERT INTO dev_001 VALUES('2020-05-13 10:00:00.000', 1, '2020-05-13 10:00:00.000', 10, 3.1, 3.14, 'test', -10, -126, true, '测试', 15, 10, 65534, 254, 1)('2020-05-13 10:00:01.000', 1, '2020-05-13 10:00:01.000', 10, 3.1, 3.14, 'test', -10, -126, true, '测试', 15, 10, 65534, 253, 5)('2020-05-13 10:00:02.000', 10, '2020-05-13 10:00:00.000', 11, 3.1, 3.14, 'test', 10, -127, false, '测试', 15, 10, 65534, 253, 10)('2020-05-13 10:00:03.000', 1, '2020-05-13 10:00:00.000', 11, 3.1, 3.14, 'test', -10, -126, true, '测试', 14, 12, 65532, 254, 15)") + + for i in range(10): + sql = "insert into dev_002(ts, t1) values" + batch = int(self.rowNum / 10) + for j in range(batch): + sql += "(%d, %d)" % (self.ts + batch * i + j, batch * i + j) + tdSql.execute(sql) + + tdSql.query("select count(ts) from dev_001 state_window(t1)") + tdSql.checkRows(3) + tdSql.checkData(0, 0, 2) + tdSql.query("select count(ts) from dev_001 state_window(t3)") + tdSql.checkRows(2) + tdSql.checkData(1, 0, 2) + tdSql.query("select count(ts) from dev_001 state_window(t7)") + tdSql.checkRows(3) + tdSql.checkData(1, 0, 1) + tdSql.query("select count(ts) from dev_001 state_window(t8)") + tdSql.checkRows(3) + tdSql.checkData(2, 0, 1) + tdSql.query("select count(ts) from dev_001 state_window(t11)") + tdSql.checkRows(2) + tdSql.checkData(0, 0, 3) + tdSql.query("select count(ts) from dev_001 state_window(t12)") + tdSql.checkRows(2) + tdSql.checkData(1, 0, 1) + tdSql.query("select count(ts) from dev_001 state_window(t13)") + tdSql.checkRows(2) + tdSql.checkData(1, 0, 1) + tdSql.query("select count(ts) from dev_001 state_window(t14)") + tdSql.checkRows(3) + tdSql.checkData(1, 0, 2) + tdSql.query("select count(ts) from dev_002 state_window(t1)") + tdSql.checkRows(100000) + + # with all aggregate function + tdSql.query("select count(*),sum(t1),avg(t1),twa(t1),stddev(t15),leastsquares(t15,1,1),first(t15),last(t15),spread(t15),percentile(t15,90),t9 from dev_001 state_window(t9);") + tdSql.checkRows(3) + tdSql.checkData(0, 0, 2) + tdSql.checkData(1, 1, 10) + tdSql.checkData(0, 2, 1) + # tdSql.checkData(0, 3, 1) + tdSql.checkData(0, 4, np.std([1,5])) + # tdSql.checkData(0, 5, 1) + tdSql.checkData(0, 6, 1) + tdSql.checkData(0, 7, 5) + tdSql.checkData(0, 8, 4) + tdSql.checkData(0, 9, 4.6) + tdSql.checkData(0, 10, 'True') + + # with where + tdSql.query("select avg(t15),t9 from dev_001 where t9='true' state_window(t9);") + tdSql.checkData(0, 0, 7) + tdSql.checkData(0, 1, 'True') + + # error + tdSql.error("select count(*) from dev_001 state_window(t2)") + tdSql.error("select count(*) from st state_window(t3)") + tdSql.error("select count(*) from dev_001 state_window(t4)") + tdSql.error("select count(*) from dev_001 state_window(t5)") + tdSql.error("select count(*) from dev_001 state_window(t6)") + tdSql.error("select count(*) from dev_001 state_window(t10)") + tdSql.error("select count(*) from dev_001 state_window(tag2)") + + # TS-537 + tdLog.info("case for TS-537") + tdSql.execute("create stable stb (ts timestamp, c1 int, c2 float) tags(tg1 int)") + tdSql.execute("CREATE TABLE IF NOT EXISTS db.tb1 USING db.stb TAGS (1)") + sql = "insert into tb1 values(1635398806734, 1, 1.000000)(1635398810062, 1, 2.000000)(1635398811528, 1, 3.000000)(1635398813301, 1, 4.000000)" + sql += "(1635398818507, 2, 1.000000)(1635398823464, 2, 1.000000)(1635398825150, 2, 1.000000)(1635398826453, 2, 1.000000)(1635399123037, 2, 2.000000)" + sql += "(1635399125335, 2, 2.000000)(1635399126292, 2, 2.000000)(1635399127288, 2, 2.000000)(1635399129361, 2, 2.000000)(1635399133331, 1, 2.000000)" + sql += "(1635399134179, 1, 2.000000)(1635399134909, 1, 2.000000)(1635399135617, 1, 2.000000)(1635399136372, 1, 2.000000)" + tdSql.execute(sql) + + tdSql.query("select * from (select first(ts), count(*), c1 from db.tb1 state_window(c1))") + tdSql.checkRows(3) + tdSql.checkData(0, 1, 4) + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 1, 9) + tdSql.checkData(1, 2, 2) + tdSql.checkData(2, 1, 5) + tdSql.checkData(2, 2, 1) + + tdSql.query("select fts, cnt, c1 from (select first(ts) fts, count(*) cnt, c1 from db.tb1 state_window(c1))") + tdSql.checkRows(3) + tdSql.checkData(0, 1, 4) + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 1, 9) + tdSql.checkData(1, 2, 2) + tdSql.checkData(2, 1, 5) + tdSql.checkData(2, 2, 1) + + tdSql.query("select * from (select first(ts) fts, count(*) cnt, c1 from db.tb1 state_window(c1))") + tdSql.checkRows(3) + tdSql.checkData(0, 1, 4) + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 1, 9) + tdSql.checkData(1, 2, 2) + tdSql.checkData(2, 1, 5) + tdSql.checkData(2, 2, 1) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/queryStddevWithGroupby.py b/tests/pytest/query/queryStddevWithGroupby.py new file mode 100644 index 0000000000000000000000000000000000000000..aee88ca9c5ae855f185d1cd8d0a7fabacd86062b --- /dev/null +++ b/tests/pytest/query/queryStddevWithGroupby.py @@ -0,0 +1,68 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def querysqls(self): + tdSql.query("select stddev(c1) from t10 group by c1") + tdSql.checkRows(6) + tdSql.checkData(0, 0, 0) + tdSql.checkData(1, 0, 0) + tdSql.checkData(2, 0, 0) + tdSql.checkData(3, 0, 0) + tdSql.checkData(4, 0, 0) + tdSql.checkData(5, 0, 0) + tdSql.query("select stddev(c2) from t10") + tdSql.checkData(0, 0, 0.5) + + def run(self): + tdSql.execute("drop database if exists db") + tdSql.execute("create database if not exists db keep 36500") + tdSql.execute("use db") + + tdLog.printNoPrefix("==========step1:create table && insert data") + tdSql.execute("create stable stb1 (ts timestamp , c1 int ,c2 float) tags(t1 int)") + tdSql.execute("create table t10 using stb1 tags(1)") + tdSql.execute("insert into t10 values ('1969-12-31 00:00:00.000', 2,1)") + tdSql.execute("insert into t10 values ('1970-01-01 00:00:00.000', 3,1)") + tdSql.execute("insert into t10 values (0, 4,1)") + tdSql.execute("insert into t10 values (now-18725d, 1,2)") + tdSql.execute("insert into t10 values ('2021-04-06 00:00:00.000', 5,2)") + tdSql.execute("insert into t10 values (now+1d,6,2)") + + tdLog.printNoPrefix("==========step2:query and check") + self.querysqls() + + tdLog.printNoPrefix("==========step3:after wal,check again") + tdSql.query("show dnodes") + index = tdSql.getData(0, 0) + tdDnodes.stop(index) + tdDnodes.start(index) + self.querysqls() + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/query/queryTbnameUpperLower.py b/tests/pytest/query/queryTbnameUpperLower.py new file mode 100644 index 0000000000000000000000000000000000000000..4818ee560a38e6c10891ad2ddb82efbab616aa75 --- /dev/null +++ b/tests/pytest/query/queryTbnameUpperLower.py @@ -0,0 +1,80 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +from util.common import tdCom + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def checkStbWhereIn(self): + ''' + where in ---> upper lower mixed + ''' + tdCom.cleanTb() + table_name = tdCom.getLongName(8, "letters_mixed") + while table_name.islower(): + table_name = tdCom.getLongName(8, "letters_mixed") + table_name_sub = f'{table_name}_sub' + tb_name_lower = table_name_sub.lower() + tb_name_upper = table_name_sub.upper() + + ## create stb and tb + tdSql.execute(f'CREATE TABLE {table_name} (ts timestamp, id int, bi1 binary(20)) tags (si1 binary(20))') + tdSql.execute(f'create table {table_name_sub}1 using {table_name} tags ("{table_name_sub}1")') + tdSql.execute(f'create table {tb_name_lower}2 using {table_name} tags ("{tb_name_lower}2")') + tdSql.execute(f'create table {tb_name_upper}3 using {table_name} tags ("{tb_name_upper}3")') + + ## insert values + tdSql.execute(f'insert into {table_name_sub}1 values (now-1s, 1, "{table_name_sub}1")') + tdSql.execute(f'insert into {tb_name_lower}2 values (now-2s, 2, "{tb_name_lower}21")') + tdSql.execute(f'insert into {tb_name_lower}2 values (now-3s, 3, "{tb_name_lower}22")') + tdSql.execute(f'insert into {tb_name_upper}3 values (now-4s, 4, "{tb_name_upper}31")') + tdSql.execute(f'insert into {tb_name_upper}3 values (now-5s, 5, "{tb_name_upper}32")') + tdSql.execute(f'insert into {tb_name_upper}3 values (now-6s, 6, "{tb_name_upper}33")') + + ## query where tbname in single + tdSql.query(f'select * from {table_name} where tbname in ("{table_name_sub}1")') + tdSql.checkRows(1) + tdSql.query(f'select * from {table_name} where tbname in ("{table_name_sub.upper()}1")') + tdSql.checkRows(1) + tdSql.query(f'select * from {table_name} where tbname in ("{table_name_sub.lower()}1")') + tdSql.checkRows(1) + tdSql.query(f'select * from {table_name} where tbname in ("{tb_name_lower}2")') + tdSql.checkRows(2) + tdSql.query(f'select * from {table_name} where tbname in ("{tb_name_lower.upper()}2")') + tdSql.checkRows(2) + tdSql.query(f'select * from {table_name} where tbname in ("{tb_name_upper}3")') + tdSql.checkRows(3) + tdSql.query(f'select * from {table_name} where tbname in ("{tb_name_upper.lower()}3")') + tdSql.checkRows(3) + + ## query where tbname in multi + tdSql.query(f'select * from {table_name} where id=5 and tbname in ("{table_name_sub}1", "{tb_name_lower.upper()}2", "{tb_name_upper.lower()}3")') + tdSql.checkRows(1) + tdSql.query(f'select * from {table_name} where tbname in ("{table_name_sub}1", "{tb_name_lower.upper()}2", "{tb_name_upper.lower()}3")') + tdSql.checkRows(6) + + def run(self): + tdSql.prepare() + self.checkStbWhereIn() + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/query/queryTscomputWithNow.py b/tests/pytest/query/queryTscomputWithNow.py new file mode 100644 index 0000000000000000000000000000000000000000..3b808d551c374a4af654beec5d9c386745385e2b --- /dev/null +++ b/tests/pytest/query/queryTscomputWithNow.py @@ -0,0 +1,177 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug(f"start to execute {__file__}") + tdSql.init(conn.cursor(), logSql) + + def inertnow(self): + tsp1 = 0 + tsp2 = -28800000 + tsp3 = -946800000000 + + tdSql.execute( + "create table stbts (ts timestamp, ts1 timestamp, c1 int, ts2 timestamp) TAGS(t1 int)" + ) + tdSql.execute("create table tts1 using stbts tags(1)") + + tdSql.execute("insert into tts1 values (now+1d, now+1d, 6, now+1d)") + tdSql.execute("insert into tts1 values (now, now, 5, now)") + tdSql.execute("insert into tts1 values (now-1d, now-1d, 4, now-1d)") + tdSql.execute(f"insert into tts1 values ({tsp1}, {tsp1}, 3, {tsp1})") + tdSql.execute(f"insert into tts1 values ({tsp2}, {tsp2}, 2, {tsp2})") + tdSql.execute(f"insert into tts1 values ({tsp3}, {tsp3}, 1, {tsp3})") + + def querynow(self): + interval_day1 = (datetime.date.today() - datetime.date(1970, 1, 1)).days + interval_day2 = (datetime.date.today() - datetime.date(1940, 1, 1)).days + + tdLog.printNoPrefix("==========step query: execute query operation") + time.sleep(1) + tdSql.execute(" select * from tts1 where ts > now+1d ") + ts_len1 = len(tdSql.cursor.fetchall()) + tdSql.execute(" select * from tts1 where ts < now+1d ") + ts_len2 = len(tdSql.cursor.fetchall()) + tdSql.execute(" select * from tts1 where ts > now-1d ") + ts_len3 = len(tdSql.cursor.fetchall()) + tdSql.execute(" select * from tts1 where ts < now-1d ") + ts_len4 = len(tdSql.cursor.fetchall()) + tdSql.execute(f" select * from tts1 where ts > now-{interval_day1+1}d ") + ts_len5 = len(tdSql.cursor.fetchall()) + tdSql.execute(f" select * from tts1 where ts < now-{interval_day1+1}d ") + ts_len6 = len(tdSql.cursor.fetchall()) + tdSql.execute(f" select * from tts1 where ts > now-{interval_day1-1}d ") + ts_len7 = len(tdSql.cursor.fetchall()) + tdSql.execute(f" select * from tts1 where ts < now-{interval_day1-1}d ") + ts_len8 = len(tdSql.cursor.fetchall()) + tdSql.execute(f" select * from tts1 where ts > now-{interval_day2+1}d ") + ts_len9 = len(tdSql.cursor.fetchall()) + tdSql.execute(f" select * from tts1 where ts < now-{interval_day2+1}d ") + ts_len10 = len(tdSql.cursor.fetchall()) + tdSql.execute(f" select * from tts1 where ts > now-{interval_day2-1}d ") + ts_len11 = len(tdSql.cursor.fetchall()) + tdSql.execute(f" select * from tts1 where ts < now-{interval_day2-1}d ") + ts_len12 = len(tdSql.cursor.fetchall()) + + tdSql.query(" select * from tts1 where ts1 > now+1d ") + tdSql.checkRows(ts_len1) + tdSql.query(" select * from tts1 where ts2 > now+1440m ") + tdSql.checkRows(ts_len1) + + tdSql.query(" select * from tts1 where ts1 < now+1d ") + tdSql.checkRows(ts_len2) + tdSql.query(" select * from tts1 where ts2 < now+1440m ") + tdSql.checkRows(ts_len2) + + tdSql.query(" select * from tts1 where ts1 > now-1d ") + tdSql.checkRows(ts_len3) + tdSql.query(" select * from tts1 where ts2 > now-1440m ") + tdSql.checkRows(ts_len3) + + tdSql.query(" select * from tts1 where ts1 < now-1d ") + tdSql.checkRows(ts_len4) + tdSql.query(" select * from tts1 where ts2 < now-1440m ") + tdSql.checkRows(ts_len4) + + tdSql.query(f" select * from tts1 where ts1 > now-{interval_day1+1}d ") + tdSql.checkRows(ts_len5) + tdSql.query(f" select * from tts1 where ts2 > now-{(interval_day1+1)*1440}m " ) + tdSql.checkRows(ts_len5) + + tdSql.query(f" select * from tts1 where ts1 < now-{interval_day1+1}d ") + tdSql.checkRows(ts_len6) + tdSql.query(f" select * from tts1 where ts2 < now-{(interval_day1+1)*1440}m ") + tdSql.checkRows(ts_len6) + + tdSql.query(f" select * from tts1 where ts1 > now-{interval_day1-1}d ") + tdSql.checkRows(ts_len7) + tdSql.query(f" select * from tts1 where ts2 > now-{(interval_day1-1)*1440}m ") + tdSql.checkRows(ts_len7) + + tdSql.query(f" select * from tts1 where ts1 < now-{interval_day1-1}d ") + tdSql.checkRows(ts_len8) + tdSql.query(f" select * from tts1 where ts2 < now-{(interval_day1-1)*1440}m ") + tdSql.checkRows(ts_len8) + + tdSql.query(f" select * from tts1 where ts1 > now-{interval_day2 + 1}d ") + tdSql.checkRows(ts_len9) + tdSql.query(f" select * from tts1 where ts2 > now-{(interval_day2 + 1)*1440}m ") + tdSql.checkRows(ts_len9) + + tdSql.query(f" select * from tts1 where ts1 < now-{interval_day2 + 1}d ") + tdSql.checkRows(ts_len10) + tdSql.query(f" select * from tts1 where ts2 < now-{(interval_day2 + 1)*1440}m ") + tdSql.checkRows(ts_len10) + + tdSql.query(f" select * from tts1 where ts1 > now-{interval_day2 - 1}d ") + tdSql.checkRows(ts_len11) + tdSql.query(f" select * from tts1 where ts2 > now-{(interval_day2 - 1)*1440}m ") + tdSql.checkRows(ts_len11) + + tdSql.query(f" select * from tts1 where ts1 < now-{interval_day2 - 1}d ") + tdSql.checkRows(ts_len12) + tdSql.query(f" select * from tts1 where ts2 < now-{(interval_day2 - 1)*1440}m ") + tdSql.checkRows(ts_len12) + + + + def run(self): + tdSql.execute("drop database if exists dbms") + tdSql.execute("drop database if exists dbus") + + # timestamp list: + # 0 -> "1970-01-01 08:00:00" | -28800000 -> "1970-01-01 00:00:00" | -946800000000 -> "1940-01-01 00:00:00" + # -631180800000 -> "1950-01-01 00:00:00" + + tdLog.printNoPrefix("==========step1:create table precision ms && insert data && query") + # create databases precision is ms + tdSql.execute("create database if not exists dbms keep 36500") + tdSql.execute("use dbms") + self.inertnow() + self.querynow() + + tdLog.printNoPrefix("==========step2:create table precision us && insert data && query") + # create databases precision is us + tdSql.execute("create database if not exists dbus keep 36500 precision 'us' ") + tdSql.execute("use dbus") + self.inertnow() + self.querynow() + + tdSql.query("show dnodes") + index = tdSql.getData(0, 0) + tdDnodes.stop(index) + tdDnodes.start(index) + + tdLog.printNoPrefix("==========step3:after wal, query table precision ms") + tdSql.execute("use dbus") + self.querynow() + + tdLog.printNoPrefix("==========step4: query table precision us") + tdSql.execute("use dbus") + self.querynow() + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/query/queryTsisNull.py b/tests/pytest/query/queryTsisNull.py new file mode 100644 index 0000000000000000000000000000000000000000..df783f2fb86ab600ac579093a391d88cfd9370c5 --- /dev/null +++ b/tests/pytest/query/queryTsisNull.py @@ -0,0 +1,53 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + tdSql.execute("drop database if exists db") + tdSql.execute("create database if not exists db keep 3650") + tdSql.execute("use db") + + tdLog.printNoPrefix("==========step1:create table and insert data") + tdSql.execute( + "create table stb1 (ts timestamp, c1 timestamp , c2 int) TAGS(t1 int )" + ) + + tdLog.printNoPrefix("==========step2:query data where timestamp data is null") + tdSql.execute( + "insert into t1 using stb1(t1) tags(1) (ts, c1, c2) values (now-1m, null, 1)" + ) + tdSql.execute( + "insert into t1 using stb1(t1) tags(1) (ts, c2) values (now-2m, 2)" + ) + tdSql.query("select * from t1 where c1 is NULL") + tdSql.checkRows(2) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/queryWildcardLength.py b/tests/pytest/query/queryWildcardLength.py new file mode 100644 index 0000000000000000000000000000000000000000..1fc46fe7d643d40c2768faf505102b9f579dd2d6 --- /dev/null +++ b/tests/pytest/query/queryWildcardLength.py @@ -0,0 +1,207 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- +from copy import deepcopy +import string +import random +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def cleanTb(self): + query_sql = "show stables" + res_row_list = tdSql.query(query_sql, True) + stb_list = map(lambda x: x[0], res_row_list) + for stb in stb_list: + tdSql.execute(f'drop table if exists {stb}') + + query_sql = "show tables" + res_row_list = tdSql.query(query_sql, True) + tb_list = map(lambda x: x[0], res_row_list) + for tb in tb_list: + tdSql.execute(f'drop table if exists {tb}') + + def getLongWildcardStr(self, len=None): + """ + generate long wildcard str + """ + maxWildCardsLength = int(tdSql.getVariable('maxWildCardsLength')[0]) + if len: + chars = ''.join(random.choice(string.ascii_letters.lower()) for i in range(len)) + else: + chars = ''.join(random.choice(string.ascii_letters.lower()) for i in range(maxWildCardsLength+1)) + return chars + + def genTableName(self): + ''' + generate table name + hp_name--->'%str' + lp_name--->'str%' + ul_name--->'st_r' + ''' + table_name = self.getLongWildcardStr() + table_name_list = list(table_name) + table_name_list.pop(-1) + + if len(table_name_list) > 1: + lp_name = deepcopy(table_name_list) + lp_name[-1] = '%' + lp_name = ''.join(lp_name) + + ul_name = list(lp_name) + ul_name[int(len(ul_name)/2)] = '_' + ul_name = ''.join(ul_name) + + table_name_list = list(table_name) + hp_name = deepcopy(table_name_list) + hp_name.pop(1) + hp_name[0] = '%' + hp_name = ''.join(hp_name) + else: + hp_name = '%' + lp_name = '%' + ul_name = '_' + return table_name, hp_name, lp_name, ul_name + + def checkRegularTableWildcardLength(self): + ''' + check regular table wildcard length with % and _ + ''' + self.cleanTb() + table_name, hp_name, lp_name, ul_name = self.genTableName() + tdSql.execute(f"CREATE TABLE {table_name} (ts timestamp, a1 int)") + sql_list = [f'show tables like "{hp_name}"', f'show tables like "{lp_name}"', f'show tables like "{ul_name}"'] + for sql in sql_list: + tdSql.query(sql) + if len(table_name) >= 1: + tdSql.checkRows(1) + else: + tdSql.error(sql) + + exceed_sql_list = [f'show tables like "%{hp_name}"', f'show tables like "{lp_name}%"', f'show tables like "{ul_name}%"'] + for sql in exceed_sql_list: + tdSql.error(sql) + + def checkSuperTableWildcardLength(self): + ''' + check super table wildcard length with % and _ + ''' + self.cleanTb() + table_name, hp_name, lp_name, ul_name = self.genTableName() + tdSql.execute(f"CREATE TABLE {table_name} (ts timestamp, c1 int) tags (t1 int)") + sql_list = [f'show stables like "{hp_name}"', f'show stables like "{lp_name}"', f'show stables like "{ul_name}"'] + for sql in sql_list: + tdSql.query(sql) + if len(table_name) >= 1: + tdSql.checkRows(1) + else: + tdSql.error(sql) + + exceed_sql_list = [f'show stables like "%{hp_name}"', f'show stables like "{lp_name}%"', f'show stables like "{ul_name}%"'] + for sql in exceed_sql_list: + tdSql.error(sql) + + def checkRegularWildcardSelectLength(self): + ''' + check regular table wildcard select length with % and _ + ''' + self.cleanTb() + table_name, hp_name, lp_name, ul_name = self.genTableName() + tdSql.execute(f"CREATE TABLE {table_name} (ts timestamp, bi1 binary(200), nc1 nchar(200))") + tdSql.execute(f'insert into {table_name} values (now, "{table_name}", "{table_name}")') + sql_list = [f'select * from {table_name} where bi1 like "{hp_name}"', + f'select * from {table_name} where bi1 like "{lp_name}"', + f'select * from {table_name} where bi1 like "{ul_name}"', + f'select * from {table_name} where nc1 like "{hp_name}"', + f'select * from {table_name} where nc1 like "{lp_name}"', + f'select * from {table_name} where nc1 like "{ul_name}"'] + for sql in sql_list: + tdSql.query(sql) + if len(table_name) >= 1: + tdSql.checkRows(1) + else: + tdSql.error(sql) + + exceed_sql_list = [f'select * from {table_name} where bi1 like "%{hp_name}"', + f'select * from {table_name} where bi1 like "{lp_name}%"', + f'select * from {table_name} where bi1 like "{ul_name}%"', + f'select * from {table_name} where nc1 like "%{hp_name}"', + f'select * from {table_name} where nc1 like "{lp_name}%"', + f'select * from {table_name} where nc1 like "{ul_name}%"'] + for sql in exceed_sql_list: + tdSql.error(sql) + + def checkStbWildcardSelectLength(self): + ''' + check stb wildcard select length with % and _ + ''' + self.cleanTb() + table_name, hp_name, lp_name, ul_name = self.genTableName() + + tdSql.execute(f'CREATE TABLE {table_name} (ts timestamp, bi1 binary(200), nc1 nchar(200)) tags (si1 binary(200), sc1 nchar(200))') + tdSql.execute(f'create table {table_name}_sub1 using {table_name} tags ("{table_name}", "{table_name}")') + tdSql.execute(f'insert into {table_name}_sub1 values (now, "{table_name}", "{table_name}");') + + sql_list = [f'select * from {table_name} where bi1 like "{hp_name}"', + f'select * from {table_name} where bi1 like "{lp_name}"', + f'select * from {table_name} where bi1 like "{ul_name}"', + f'select * from {table_name} where nc1 like "{hp_name}"', + f'select * from {table_name} where nc1 like "{lp_name}"', + f'select * from {table_name} where nc1 like "{ul_name}"', + f'select * from {table_name} where si1 like "{hp_name}"', + f'select * from {table_name} where si1 like "{lp_name}"', + f'select * from {table_name} where si1 like "{ul_name}"', + f'select * from {table_name} where sc1 like "{hp_name}"', + f'select * from {table_name} where sc1 like "{lp_name}"', + f'select * from {table_name} where sc1 like "{ul_name}"'] + + for sql in sql_list: + tdSql.query(sql) + if len(table_name) >= 1: + tdSql.checkRows(1) + else: + tdSql.error(sql) + exceed_sql_list = [f'select * from {table_name} where bi1 like "%{hp_name}"', + f'select * from {table_name} where bi1 like "{lp_name}%"', + f'select * from {table_name} where bi1 like "{ul_name}%"', + f'select * from {table_name} where nc1 like "%{hp_name}"', + f'select * from {table_name} where nc1 like "{lp_name}%"', + f'select * from {table_name} where nc1 like "{ul_name}%"', + f'select * from {table_name} where si1 like "%{hp_name}"', + f'select * from {table_name} where si1 like "{lp_name}%"', + f'select * from {table_name} where si1 like "{ul_name}%"', + f'select * from {table_name} where sc1 like "%{hp_name}"', + f'select * from {table_name} where sc1 like "{lp_name}%"', + f'select * from {table_name} where sc1 like "{ul_name}%"'] + for sql in exceed_sql_list: + tdSql.error(sql) + + def run(self): + tdSql.prepare() + self.checkRegularTableWildcardLength() + self.checkSuperTableWildcardLength() + self.checkRegularWildcardSelectLength() + self.checkStbWildcardSelectLength() + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) + diff --git a/tests/pytest/query/queryWithTaosdKilled.py b/tests/pytest/query/queryWithTaosdKilled.py new file mode 100644 index 0000000000000000000000000000000000000000..28f9b87636987559669952a5fa88c25963fa9388 --- /dev/null +++ b/tests/pytest/query/queryWithTaosdKilled.py @@ -0,0 +1,68 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + self.conn = conn + tdSql.init(conn.cursor()) + + self.rowNum = 10 + self.ts = 1537146000000 + + def createOldDir(self): + path = tdDnodes.dnodes[1].getDnodeRootDir(1) + print(path) + tdLog.info("sudo mkdir -p %s/data/vnode/vnode2/wal/old" % path) + os.system("sudo mkdir -p %s/data/vnode/vnode2/wal/old" % path) + + def run(self): + # os.system("rm -rf %s/ " % tdDnodes.getDnodesRootDir()) + tdSql.prepare() + + tdSql.execute("create table st(ts timestamp, speed int)") + tdSql.execute("insert into st values(now, 1)") + tdSql.query("select count(*) from st") + tdSql.checkRows(1) + + + self.createOldDir() + tdLog.sleep(10) + + print("force kill taosd") + os.system("sudo kill -9 $(pgrep -x taosd)") + os.system("") + tdDnodes.start(1) + + tdSql.init(self.conn.cursor()) + tdSql.execute("use db") + tdSql.query("select count(*) from st") + tdSql.checkRows(1) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/query_performance.py b/tests/pytest/query/query_performance.py new file mode 100644 index 0000000000000000000000000000000000000000..c31569ac1382aca17d3d5b37fbef981620c0df83 --- /dev/null +++ b/tests/pytest/query/query_performance.py @@ -0,0 +1,219 @@ +import time +import taos +import csv +import numpy as np +import random +import os +import requests +import json +import sys + +""" +需要第三方库: taos,requests,numpy +当前机器已经启动taosd服务 +使用方法见底部示例 +""" + + + +class Ding: + """ + 发送消息到钉钉, + urls: 钉钉群的token组成的list,可以发多个钉钉群,需要提前加白名单或其他放行策略 + at_mobiles: 需要@的人的手机号组成的list + msg: 要发送的str + """ + def __init__(self, url_list, at_mobiles): + self.urls = url_list + self.at_mobiles = at_mobiles + + def send_message(self, msg): + data1 = { + "msgtype": "text", + "text": { + "content": msg + }, + "at": { + "atMobiles": self.at_mobiles, + "isAtAll": False + } + } + + header = {'Content-Type': 'application/json; charset=utf-8'} + + for url in self.urls: + requests.post(url=url, data=json.dumps(data1), headers=header) + + + + +class TDConn: + def __init__(self, config:dict): + self.host = config['host'] + self.user = config['user'] + self.password = config['password'] + self.config = config['config'] + self.conn = None + self.cursor = None + + def connect(self): + conn = taos.connect(host=self.host, user=self.user, password=self.password, config=self.config) + cursor = conn.cursor() + self.conn = conn + self.cursor = cursor + print('connect ...') + return self.cursor + + def close(self): + self.cursor.close() + self.conn.close() + print('close ... ') + + +class Tool: + """ + 可能有用 + """ + @staticmethod + def str_gen(num): + return ''.join(random.sample('abcdefghijklmnopqrstuvwxyz', num)) + + @staticmethod + def float_gen(n, m): + return random.uniform(n, m) + + @staticmethod + def int_gen(n, m): + return random.randint(n, m) + +class Demo: + def __init__(self, engine): + self.engine = engine['engine'](engine['config']) + self.cursor = self.engine.connect() + + + def date_gen(self, db, number_per_table, type_of_cols, num_of_cols_per_record, num_of_tables): + """ + :目前都是 taosdemo 的参数 + :return: + """ + sql = 'yes | sudo taosdemo -d {db} -n {number_per_table} -b {type_of_cols} -l {num_of_cols_per_record} ' \ + '-t {num_of_tables}'.format(db=db, number_per_table=number_per_table, type_of_cols=type_of_cols, + num_of_cols_per_record=num_of_cols_per_record, num_of_tables=num_of_tables) + os.system(sql) + print('insert data completed') + + + # def main(self, db, circle, csv_name, case_func, result_csv, nums, ding_flag): + def main(self, every_num_per_table, result_csv, all_result_csv, values): + db = values['db_name'] + number_per_table = every_num_per_table + type_of_cols = values['col_type'] + num_of_cols_per_record = values['col_num'] + num_of_tables = values['table_num'] + self.date_gen(db=db, number_per_table=number_per_table, type_of_cols=type_of_cols, + num_of_cols_per_record=num_of_cols_per_record, num_of_tables=num_of_tables) + + circle = values['circle'] + # print(every_num_per_table, result_csv, values) + csv_name = result_csv + case_func = values['sql_func'] + nums = num_of_tables * number_per_table + ding_flag = values['ding_flag'] + + _data = [] + f = open(csv_name,'w',encoding='utf-8') + f1 = open(all_result_csv,'a',encoding='utf-8') + csv_writer = csv.writer(f) + csv_writer1 = csv.writer(f1) + csv_writer.writerow(["number", "elapse", 'sql']) + self.cursor.execute('use {db};'.format(db=db)) + + + for i in range(circle): + self.cursor.execute('reset query cache;') + sql = case_func() + start = time.time() + self.cursor.execute(sql) + self.cursor.fetchall() + end = time.time() + _data.append(end-start) + elapse = '%.4f' %(end -start) + print(sql, i, elapse, '\n') + csv_writer.writerow([i+1, elapse, sql]) + + # time.sleep(1) + _list = [nums, np.mean(_data)] + _str = '总数据: %s 条 , table数: %s , 每个table数据数: %s , 数据类型: %s \n' % \ + (nums, num_of_tables, number_per_table, type_of_cols) + # print('avg : ', np.mean(_data), '\n') + _str += '平均值 : %.4f 秒\n' % np.mean(_data) + for each in (50, 80, 90, 95): + _list.append(np.percentile(_data,each)) + _str += ' %d 分位数 : %.4f 秒\n' % (each , np.percentile(_data,each)) + + print(_str) + if ding_flag: + ding = Ding(values['ding_config']['urls'], values['ding_config']['at_mobiles']) + ding.send_message(_str) + csv_writer1.writerow(_list) + f.close() + f1.close() + self.engine.close() + + +def run(engine, test_cases: dict, result_dir): + for each_case, values in test_cases.items(): + for every_num_per_table in values['number_per_table']: + result_csv = result_dir + '{case}_table{table_num}_{number_per_table}.csv'.\ + format(case=each_case, table_num=values['table_num'], number_per_table=every_num_per_table) + all_result_csv = result_dir + '{case_all}_result.csv'.format(case_all=each_case) + d = Demo(engine) + # print(each_case, result_csv) + d.main(every_num_per_table, result_csv, all_result_csv, values) + + + +if __name__ == '__main__': + """ + 测试用例在test_cases中添加。 + result_dir: 报告生成目录,会生成每次测试结果,和具体某一用例的统计结果.需注意目录权限需要执行用户可写。 + case1、case2 : 具体用例名称 + engine: 数据库引擎,目前只有taosd。使用时需开启taosd服务。 + table_num: 造数据时的table数目 + circle: 循环测试次数,求平均值 + number_per_table:需要传list,多个数值代表会按照list内的数值逐个测试 + col_num:table col的数目 + col_type: 表中数据类型 + db_name: 造数据的db名,默认用test + sql_func: 当前测试的sql方法,需要自己定义 + ding_flag: 如果需要钉钉发送数据,flag设置真值, + ding_config: 如ding_flag 设置为真值,此项才有意义。ding_flag为假时此项可以为空。urls传入一list,内容为要发送的群的token, + 需提前设置白名单,at_mobiles传入一list,内容为在群内需要@的人的手机号 + """ + engine_dict = { + 'taosd': {'engine': TDConn, 'config': + {'host': '127.0.0.1', 'user': 'root', 'password': 'taosdata', 'config':'/etc/taos'}} + } + + def case1(): + return 'select * from meters where f1 = {n};'.format(n=random.randint(1,30)) + + def case2(): + return 'select * from meters where f1 = %.4f;' %random.uniform(1,30) + + + result_dir = '/usr/local/demo/benchmarktestdata/' + test_cases = { + 'case1': {'engine':'taosd', 'table_num': 10, 'circle': 100, 'number_per_table':[10, 100], 'col_num': 5, + 'col_type': 'INT', 'db_name': 'test', 'sql_func': case1, 'ding_flag': True, + 'ding_config': + {'urls': [r'https://oapi.dingtalk.com/robot/send?access_token=xxxxxxx0cd93'], + 'at_mobiles':[17000000000,],}}, + 'case2': {'engine':'taosd', 'table_num': 10, 'circle': 50, 'number_per_table':[10, 100], 'col_num': 5, + 'col_type': 'FLOAT', 'db_name': 'test', 'sql_func': case2, 'ding_flag': False, + 'ding_config': None + } + } + + run(engine_dict['taosd'], test_cases, result_dir) diff --git a/tests/pytest/query/removeDBAndSTable.py b/tests/pytest/query/removeDBAndSTable.py new file mode 100644 index 0000000000000000000000000000000000000000..4616c7e378326af633a89905d746c7d51ce92139 --- /dev/null +++ b/tests/pytest/query/removeDBAndSTable.py @@ -0,0 +1,70 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +from util.dnodes import tdDnodes + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + print("==============step1") + tdSql.execute("create database db_vplu"); + tdSql.execute("use db_vplu") + tdSql.execute("CREATE table if not exists st (ts timestamp, speed int) tags(id int)") + tdSql.execute("CREATE table if not exists st_vplu (ts timestamp, speed int) tags(id int)") + + print("==============step2") + + tdSql.execute("drop table st") + + tdSql.query("show stables") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "st_vplu") + + tdDnodes.stopAll() + tdDnodes.start(1) + + tdSql.execute("use db_vplu") + tdSql.query("show stables") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "st_vplu") + + tdSql.execute("drop database db") + tdSql.query("show databases") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "db_vplu") + + tdDnodes.stopAll() + tdDnodes.start(1) + + tdSql.query("show databases") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "db_vplu") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/select_last_crash.py b/tests/pytest/query/select_last_crash.py new file mode 100644 index 0000000000000000000000000000000000000000..4872f0d0f5ed94768a563e658e7af14816e272c4 --- /dev/null +++ b/tests/pytest/query/select_last_crash.py @@ -0,0 +1,78 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import random + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 5000 + self.ts = 1537146000000 + + def run(self): + tdSql.prepare() + + tdSql.execute( + "create table if not exists st (ts timestamp, value nchar(50), speed int) tags(dev nchar(50))") + tdSql.execute( + "create table t1 using st tags('dev_001')") + + for i in range(self.rowNum): + tdSql.execute( + "insert into t1 values(%d, 'taosdata%d', %d)" % + (self.ts + i, i + 1, i + 1)) + + tdSql.query("select last(*) from st") + tdSql.checkRows(1) + + # TS-717 + tdLog.info("case for TS-717") + cachelast_values = [0, 1, 3] + + for value in cachelast_values: + tdLog.info("case for cachelast value: %d" % value) + tdSql.execute("drop database if exists db") + tdLog.sleep(1) + tdSql.execute("create database db cachelast %d" % value) + tdSql.execute("use db") + tdSql.execute("create table stb(ts timestamp, c1 int, c2 binary(20), c3 binary(5)) tags(t1 int)") + + sql = "insert into t1 using stb tags(1) (ts, c1, c2) values" + for i in range(self.rowNum): + sql += "(%d, %d, 'test')" % (self.ts + i, random.randint(1,100)) + tdSql.execute(sql) + + tdSql.query("select * from stb") + tdSql.checkRows(self.rowNum) + + tdDnodes.stop(1) + tdDnodes.start(1) + + tdSql.query("select * from stb") + tdSql.checkRows(self.rowNum) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/sliding.py b/tests/pytest/query/sliding.py new file mode 100644 index 0000000000000000000000000000000000000000..d7a7c9a36964796dd530f913523f8f4d344d467a --- /dev/null +++ b/tests/pytest/query/sliding.py @@ -0,0 +1,71 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +import random + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.ts = 1500000000000 + + def run(self): + tdSql.prepare() + + tdSql.execute("create table meters(ts timestamp, col1 int) tags(id int, loc nchar(20))") + sql = "insert into t0 using meters tags(1, 'beijing') values" + for i in range(100): + sql += "(%d, %d)" % (self.ts + i * 1000, random.randint(1, 100)) + tdSql.execute(sql) + + sql = "insert into t1 using meters tags(2, 'shanghai') values" + for i in range(100): + sql += "(%d, %d)" % (self.ts + i * 1000, random.randint(1, 100)) + tdSql.execute(sql) + + tdSql.query("select count(*) from meters interval(10s) sliding(5s)") + tdSql.checkRows(21) + + tdSql.error("select count(*) from meters sliding(5s)") + + tdSql.error("select count(*) from meters sliding(5s) interval(10s)") + + tdSql.error("select * from meters sliding(5s) order by ts desc") + + tdSql.query("select count(*) from meters group by loc") + tdSql.checkRows(2) + + tdSql.error("select * from meters group by loc sliding(5s)") + + # Fix defect: https://jira.taosdata.com:18080/browse/TD-2700 + tdSql.execute("create database test") + tdSql.execute("use test") + tdSql.execute("create table t1(ts timestamp, k int)") + tdSql.execute("insert into t1 values(1500000001000, 0)") + tdSql.query("select sum(k) from t1 interval(1d) sliding(1h)") + tdSql.checkRows(24) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/subqueryFilter.py b/tests/pytest/query/subqueryFilter.py new file mode 100644 index 0000000000000000000000000000000000000000..5dca08b458dbe33a33dc3c93fd72478758c96915 --- /dev/null +++ b/tests/pytest/query/subqueryFilter.py @@ -0,0 +1,123 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +from util.dnodes import tdDnodes + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.ts = 1601481600000 + self.tables = 10 + self.perfix = 'dev' + + def insertData(self): + print("==============step1") + tdSql.execute( + "create table if not exists st (ts timestamp, tagtype int) tags(dev nchar(50))") + + for i in range(self.tables): + tdSql.execute("create table %s%d using st tags(%d)" % (self.perfix, i, i)) + rows = 15 + i + for j in range(rows): + tdSql.execute("insert into %s%d values(%d, %d)" %(self.perfix, i, self.ts + i * 20 * 10000 + j * 10000, j)) + + def run(self): + tdSql.prepare() + + self.insertData() + + tdSql.query("select count(*) val from st group by tbname") + tdSql.checkRows(10) + + tdSql.query("select * from (select count(*) val from st group by tbname)") + tdSql.checkRows(10) + + tdSql.query("select * from (select count(*) val from st group by tbname) a where a.val < 20") + tdSql.checkRows(5) + + tdSql.query("select * from (select count(*) val from st group by tbname) a where a.val > 20") + tdSql.checkRows(4) + + tdSql.query("select * from (select count(*) val from st group by tbname) a where a.val = 20") + tdSql.checkRows(1) + + tdSql.query("select * from (select count(*) val from st group by tbname) a where a.val <= 20") + tdSql.checkRows(6) + + tdSql.query("select * from (select count(*) val from st group by tbname) a where a.val >= 20") + tdSql.checkRows(5) + + tdSql.query("select count(*) from (select first(tagtype) val from st interval(30s)) a where a.val > 20") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query("select count(*) from (select first(tagtype) val from st interval(30s)) a where a.val >= 20") + tdSql.checkData(0, 0, 2) + + tdSql.query("select count(*) from (select first(tagtype) val from st interval(30s)) a where a.val < 20") + tdSql.checkData(0, 0, 63) + + tdSql.query("select count(*) from (select first(tagtype) val from st interval(30s)) a where a.val <= 20") + tdSql.checkData(0, 0, 64) + + tdSql.query("select count(*) from (select first(tagtype) val from st interval(30s)) a where a.val = 20") + tdSql.checkData(0, 0, 1) + + tdSql.query("select count(*) from (select first(tagtype) val from st interval(30s)) a where a.val > 20") + tdSql.checkData(0, 0, 1) + + tdSql.query("select count(*) from (select first(tagtype) val from st interval(30s)) a where a.val >= 20") + tdSql.checkData(0, 0, 2) + + tdSql.query("select count(*) from (select first(tagtype) val from st interval(30s)) a where a.val < 20") + tdSql.checkData(0, 0, 63) + + tdSql.query("select count(*) from (select first(tagtype) val from st interval(30s)) a where a.val <= 20") + tdSql.checkData(0, 0, 64) + + tdSql.query("select count(*) from (select first(tagtype) val from st interval(30s)) a where a.val = 20") + tdSql.checkData(0, 0, 1) + + tdSql.query("select count(*) from (select last(tagtype) val from st interval(30s)) a where a.val > 20") + tdSql.checkData(0, 0, 3) + + tdSql.query("select count(*) from (select last(tagtype) val from st interval(30s)) a where a.val >= 20") + tdSql.checkData(0, 0, 5) + + tdSql.query("select count(*) from (select last(tagtype) val from st interval(30s)) a where a.val < 20") + tdSql.checkData(0, 0, 60) + + tdSql.query("select count(*) from (select last(tagtype) val from st interval(30s)) a where a.val <= 20") + tdSql.checkData(0, 0, 62) + + tdSql.query("select count(*) from (select last(tagtype) val from st interval(30s)) a where a.val = 20") + tdSql.checkData(0, 0, 2) + + + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/tbname.py b/tests/pytest/query/tbname.py new file mode 100644 index 0000000000000000000000000000000000000000..30d90b1f9dd38077cdb942dac78a28cac0084c47 --- /dev/null +++ b/tests/pytest/query/tbname.py @@ -0,0 +1,83 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdSql.execute( + 'create table cars (ts timestamp, speed int) tags(id int)') + tdSql.execute("create table carzero using cars tags(0)") + tdSql.execute("create table carone using cars tags(1)") + tdSql.execute("create table cartwo using cars tags(2)") + + tdSql.execute( + "insert into carzero values(now, 100) carone values(now, 110)") + + tdSql.query("select * from cars where tbname in ('carzero', 'carone')") + tdSql.checkRows(2) + + tdSql.query("select * from cars where tbname in ('carzero', 'cartwo')") + tdSql.checkRows(1) + + tdSql.query( + "select * from cars where id=1 or tbname in ('carzero', 'cartwo')") + tdSql.checkRows(2) + + tdSql.query( + "select * from cars where id=1 and tbname in ('carzero', 'cartwo')") + tdSql.checkRows(0) + + tdSql.query( + "select * from cars where id=0 and tbname in ('carzero', 'cartwo')") + tdSql.checkRows(1) + + tdSql.query("select * from cars where tbname in ('carZero', 'CARONE')") + tdSql.checkRows(2) + + """ + tdSql.query("select * from cars where tbname like 'car%'") + tdSql.checkRows(2) + + tdSql.cursor.execute("use db") + tdSql.query("select * from cars where tbname like '%o'") + tdSql.checkRows(1) + + tdSql.query("select * from cars where id=1 and tbname like 'car%') + tdSql.checkRows(1) + + tdSql.query("select * from cars where id = 1 and tbname like '%o') + tdSql.checkRows(0) + + tdSql.query("select * from cars where id = 1 or tbname like '%o') + tdSql.checkRows(2) + """ + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/ts_2016.py b/tests/pytest/query/ts_2016.py new file mode 100644 index 0000000000000000000000000000000000000000..00bb7fd07a798d903f9d0e2bcddf51a95eb2b32b --- /dev/null +++ b/tests/pytest/query/ts_2016.py @@ -0,0 +1,62 @@ +################################################################### +# Copyright (c) 2021 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def caseDescription(self): + ''' + case1: [TS-2016]fix select * from (select * from empty_stable) + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self._conn = conn + + def run(self): + print("running {}".format(__file__)) + tdSql.execute("drop database if exists td12229") + tdSql.execute("create database if not exists td12229") + tdSql.execute('use td12229') + + tdSql.execute('create stable st(ts timestamp , value int ) tags (ind int)') + tdSql.execute('insert into tb1 using st tags(1) values(now ,1)') + tdSql.execute('insert into tb1 using st tags(1) values(now+1s ,2)') + tdSql.execute('insert into tb1 using st tags(1) values(now+2s ,3)') + tdSql.execute('create stable ste(ts timestamp , value int ) tags (ind int)') + tdSql.query('select * from st') + tdSql.checkRows(3) + tdSql.query('select * from (select * from ste)') + tdSql.checkRows(0) + tdSql.query('select * from st union all select * from ste') + tdSql.checkRows(3) + tdSql.query('select * from ste union all select * from st') + tdSql.checkRows(3) + tdSql.query('select count(ts) from ste group by tbname union all select count(ts) from st group by tbname;') + tdSql.checkRows(1) + tdSql.query('select count(ts) from st group by tbname union all select count(ts) from ste group by tbname;') + tdSql.checkRows(1) + tdSql.execute('drop database td12229') + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/udf.py b/tests/pytest/query/udf.py new file mode 100644 index 0000000000000000000000000000000000000000..7e04f8ad728d9197621c35fad46389804c8310ae --- /dev/null +++ b/tests/pytest/query/udf.py @@ -0,0 +1,615 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.ts = 1627750800000 + self.numberOfRecords = 10000 + + def pre_stable(self): + os.system("gcc -g -O0 -fPIC -shared ../script/sh/abs_max.c -o /tmp/abs_max.so") + os.system("gcc -g -O0 -fPIC -shared ../script/sh/add_one.c -o /tmp/add_one.so") + os.system("gcc -g -O0 -fPIC -shared ../script/sh/sum_double.c -o /tmp/sum_double.so") + tdSql.execute("create table stb(ts timestamp ,c1 int, c2 bigint) tags(t1 int)") + for i in range(50): + for j in range(200): + sql = "insert into t%d using stb tags(%d) values(%s,%d,%d)" % (i, i, self.ts + j, 1e2+j, 1e10+j) + tdSql.execute(sql) + for i in range(50): + for j in range(200): + sql = "insert into t%d using stb tags(%d) values(%s,%d,%d)" % (i, i, self.ts + j + 200 , -1e2-j, -j-1e10) + tdSql.execute(sql) + + def test_udf_null(self): + tdLog.info("test missing parameters") + tdSql.error("create aggregate function as '/tmp/abs_maxw.so' outputtype bigint;") + tdSql.error("create aggregate function abs_max as '' outputtype bigint;") + tdSql.error("create aggregate function abs_max as outputtype bigint;") + tdSql.error("create aggregate function abs_max as '/tmp/abs_maxw.so' ;") + tdSql.error("create aggregate abs_max as '/tmp/abs_maxw.so' outputtype bigint;") + tdSql.execute("create aggregate function abs_max as '/tmp/abs_max.so' outputtype bigint;") + tdSql.error("select abs_max() from stb") + tdSql.error("select abs_max(c2) from ") + tdSql.execute("drop function abs_max") + + def test_udf_format(self): + # tdSql.error("create aggregate function avg as '/tmp/abs_max.so' outputtype bigint;") + tdSql.error("create aggregate function .a as '/tmp/abs_max.so' outputtype bigint;") + tdSql.error("create aggregate function .11 as '/tmp/abs_max.so' outputtype bigint;") + tdSql.error("create aggregate function 1a as '/tmp/abs_max.so' outputtype bigint;") + tdSql.error("create aggregate function \"1+1\" as '/tmp/abs_max.so' outputtype bigint;") + # tdSql.error("create aggregate function [avg] as '/tmp/abs_max.so' outputtype bigint;") + tdSql.execute("create aggregate function abs_max as '/tmp/abs_max.so' outputtype bigint;") + # tdSql.error("create aggregate function abs_max2 as '/tmp/abs_max.so' outputtype bigint;") + tdSql.execute("drop function abs_max;") + tdSql.error("create aggregate function abs_max as '/tmp/add_onew.so' outputtype bigint;") + + def test_udf_test(self): + tdSql.execute("create aggregate function abs_max as '/tmp/abs_max.so' outputtype bigint;") + tdSql.error("create aggregate function abs_max as '/tmp/add_onew.so' outputtype bigint;") + sql = 'select abs_max() from db.stb' + tdSql.error(sql) + sql = 'select abs_max(c2) from db.stb' + tdSql.query(sql) + tdSql.checkData(0,0,10000000199) + + def test_udf_values(self): + tdSql.execute("drop function abs_max") + tdSql.execute("create function add_one as '/tmp/add_one.so' outputtype int") + tdSql.execute("create aggregate function abs_max as '/tmp/abs_max.so' outputtype bigint;") + tdSql.execute("create aggregate function sum_double as '/tmp/sum_double.so' outputtype bigint;") + + # tdSql.error("create aggregate function max as '/tmp/abs_max.so' outputtype bigint ;") + # tdSql.error("create aggregate function avg as '/tmp/abs_max.so' outputtype bigint ;") + # tdSql.error("create aggregate function dbs as '/tmp/abs_max.so' outputtype bigint ;") + + tdSql.execute("drop database if exists test") + tdSql.execute("create database test") + tdSql.execute("use test") + tdSql.execute("create stable st (ts timestamp,id int , val double , number bigint, chars binary(200)) tags (ind int)") + tdSql.execute("create table tb1 using st tags(1)") + tdSql.execute("create table tb2 using st tags(2)") + start_time = 1604298064000 + rows = 5 + tb_nums = 2 + for i in range(1, tb_nums + 1): + for j in range(rows): + start_time += 10 + tdSql.execute( + "insert into tb%d values(%d, %d,%f,%d,%s) " % (i, start_time, j, float(j),j*100, "'str" + str(j) + "'")) + tdSql.query("select count(*) from st") + tdSql.execute("create table bound using st tags(3)") + epoch_time=1604298064000 + intdata1 = -2**31+2 + intdata2 = 2**31-2 + bigintdata1 = -2**63+2 + bigintdata2 = 2**63-2 + print("insert into bound values(%d, %d , %f, %d , %s)"%(epoch_time,intdata1,float(intdata1),bigintdata1,"'binary"+str(intdata1)+"'")) + tdSql.execute("insert into bound values(%d, %d , %f, %d , %s)"%(epoch_time,intdata1,float(intdata1),bigintdata1,"'binary"+str(intdata1)+"'")) + + tdSql.execute("insert into bound values(%d, %d , %f, %d , %s)"%(epoch_time+10,intdata1+1,float(intdata1+1),bigintdata1+1,"'binary"+str(intdata1+1)+"'")) + tdSql.execute("insert into bound values(%d, %d , %f, %d , %s)"%(epoch_time+100,intdata2,float(intdata2),bigintdata2,"'binary"+str(intdata2)+"'")) + tdSql.execute("insert into bound values(%d, %d , %f, %d , %s)"%(epoch_time+1000,intdata2+1,float(intdata2+1),bigintdata2+1,"'binary"+str(intdata2+1)+"'")) + + # check super table calculation results + tdSql.query("select add_one(id) test from st") + tdSql.checkData(0,0,1) + tdSql.checkData(1,0,2) + tdSql.checkData(4,0,5) + tdSql.checkData(5,0,1) + tdSql.checkData(9,0,5) + tdSql.checkData(10,0,-2147483645) + tdSql.checkData(13,0,None) + # check common table calculation results + tdSql.query("select add_one(id) from tb1") + tdSql.checkData(0,0,1) + tdSql.checkData(1,0,2) + tdSql.checkData(4,0,5) + + tdSql.error("select add_one(col) from st") + + sqls= ["select add_one(chars) from st", + "select add_one(val) from st", + "select add_one(ts) from st"] + for sql in sqls: + res = tdSql.getResult(sql) + if res == []: + tdLog.info("====== this col not support use UDF , because datatype not match defind in UDF function ======") + else: + tdLog.info(" ====== unexpected error occured about UDF function =====") + sys.exit() + + tdLog.info("======= UDF function abs_max check ======") + + sqls= ["select abs_max(val) from st", + "select abs_max(id) from st", + "select abs_max(ts) from st"] + for sql in sqls: + res = tdSql.getResult(sql) + if res == []: + tdLog.info("====== this col not support use UDF , because datatype not match defind in UDF function ======") + else: + tdLog.info(" ====== unexpected error occured about UDF function =====") + sys.exit() + + tdSql.query("select abs_max(val) from st") + tdSql.error("select abs_max(val),count(tbname) from st") + tdSql.query("select abs_max(val) from tb1") + tdSql.checkRows(0) + tdSql.query("select sum_double(val) from st") + tdSql.query("select sum_double(val) from tb1") + tdSql.checkRows(0) + + # check super table calculation results + tdSql.query("select abs_max(number) from st") + tdSql.checkData(0,0,9223372036854775807) + + # check common table calculation results + tdSql.query("select abs_max(number) from tb1") + tdSql.checkData(0,0,400) + tdSql.query("select abs_max(number) from tb2") + tdSql.checkData(0,0,400) + tdSql.execute("select add_one(id) from st limit 10 offset 2") + tdSql.query("select add_one(id) from st where ts > 1604298064000 and ts < 1604298064020 ") + tdSql.checkData(0,0,1) + tdSql.checkData(1,0,-2147483644) + tdSql.query("select add_one(id) from tb1 where ts > 1604298064000 and ts < 1604298064020 ") + tdSql.checkData(0,0,1) + tdSql.query("select sum_double(id) from st where ts > 1604298064030 and ts < 1604298064060 ") + tdSql.checkData(0,0,14) + tdSql.query("select sum_double(id) from tb2 where ts > 1604298064030 and ts < 1604298064060 ") + tdSql.checkRows(0) + tdSql.query("select add_one(id) from st where ts = 1604298064000 ") + tdSql.checkData(0,0,-2147483645) + tdSql.query("select add_one(id) from st where ts > 1604298064000 and id in (2,3) and ind =1;") + tdSql.checkData(0,0,3) + tdSql.checkData(1,0,4) + tdSql.query("select id , add_one(id) from tb1 where ts > 1604298064000 and id in (2,3)") + tdSql.checkData(0,0,2) + tdSql.checkData(0,1,3) + tdSql.checkData(1,0,3) + tdSql.checkData(1,1,4) + tdSql.query("select sum_double(id) from tb1 where ts > 1604298064000 and id in (2,3)") + tdSql.checkData(0,0,10) + tdSql.query("select sum_double(id) from st where ts > 1604298064000 and id in (2,3) and ind =1") + tdSql.checkData(0,0,10) + tdSql.query("select abs_max(number) from st where ts > 1604298064000 and id in (2,3) and ind =1") + tdSql.checkData(0,0,300) + tdSql.query("select sum_double(id) from st where ts = 1604298064030 ") + tdSql.checkData(0,0,4) + tdSql.query("select abs_max(number) from st where ts = 1604298064100 ") + tdSql.checkData(0,0,9223372036854775806) + tdSql.query("select abs_max(number) from tb2 where ts = 1604298064100 ") + tdSql.checkData(0,0,400) + tdSql.query("select sum_double(id) from tb2 where ts = 1604298064100 ") + tdSql.checkData(0,0,8) + tdSql.query("select add_one(id) from st where ts >= 1604298064000 and ts <= 1604298064010") + tdSql.checkData(0,0,1) + tdSql.checkData(1,0,-2147483645) + tdSql.checkData(2,0,-2147483644) + tdSql.query("select add_one(id) from tb1 where ts >= 1604298064000 and ts <= 1604298064010") + tdSql.checkData(0,0,1) + tdSql.query("select sum_double(id) from st where ts >= 1604298064030 and ts <= 1604298064050") + tdSql.checkData(0,0,18) + tdSql.query("select sum_double(id) from tb2 where ts >= 1604298064030 and ts <= 1604298064100") + tdSql.checkData(0,0,20) + tdSql.query("select abs_max(number) from tb2 where ts >= 1604298064030 and ts <= 1604298064100") + tdSql.checkData(0,0,400) + tdSql.query("select abs_max(number) from st where ts >= 1604298064030 and ts <= 1604298064100") + tdSql.checkData(0,0,9223372036854775806) + tdSql.query("select id from st where id != 0 and ts >=1604298064070") + tdSql.checkData(0,0,1) + tdSql.query("select add_one(id) from st where id != 0 and ts >=1604298064070") + tdSql.checkData(0,0,2) + tdSql.query("select add_one(id) from st where id <> 0 and ts >=1604298064010") + tdSql.checkData(0,0,2) + tdSql.query("select sum_double(id) from st where id in (2,3,4) and ts >=1604298064070") + tdSql.checkData(0,0,18) + tdSql.query("select sum_double(id) from tb2 where id in (2,3,4) and ts >=1604298064070") + tdSql.checkData(0,0,18) + tdSql.query("select abs_max(number) from st where id in (2,3,4) and ts >=1604298064070") + tdSql.checkData(0,0,400) + tdSql.query("select add_one(id) from st where id = 0 ") + tdSql.checkData(0,0,1) + tdSql.checkData(1,0,1) + tdSql.query("select add_one(id) from tb2 where id = 0 ") + tdSql.checkData(0,0,1) + tdSql.query("select sum_double(id) from st where id = 1") + tdSql.checkData(0,0,4) + tdSql.query("select sum_double(id) from tb2 where id = 1") + tdSql.checkData(0,0,2) + + + tdSql.query("select add_one(id) from st where id is not null and ts >=1604298065000 ") + tdSql.checkData(0,0,None) + tdSql.query("select abs_max(number) from st where id is not null and ts >=1604298065000 ") + tdSql.checkData(0,0,9223372036854775807) + tdSql.query("select abs_max(number) from bound where id is not null and ts >=1604298065000 ") + tdSql.checkData(0,0,9223372036854775807) + tdSql.query("select sum_double(id) from st where id is not null and ts >=1604298064000 and ind = 1 ") + tdSql.checkData(0,0,20) + tdSql.query("select sum_double(id) from tb1 where id is not null and ts >=1604298064000 ") + tdSql.checkData(0,0,20) + tdSql.query("select add_one(id) from st where id is null and ts >=1604298065000 ") + tdSql.checkRows(0) + tdSql.query("select abs_max(number) from st where id is null and ts >=1604298065000 ") + tdSql.checkRows(0) + tdSql.query("select abs_max(number) from tb1 where id is null and ts >=1604298065000 ") + tdSql.checkRows(0) + tdSql.query("select add_one(id) from bound where id is not null and ts >=1604298065000;") + tdSql.checkData(0,0,None) + tdSql.query("select id,add_one(id) from bound;") + tdSql.checkRowCol(4,2) + tdSql.checkData(3,1,None) + tdSql.query("select add_one(id) from st where ts between 1604298064000 and 1604298064010") + tdSql.checkRows(3) + tdSql.query("select add_one(id) from tb1 where ts between 1604298064000 and 1604298064010") + tdSql.checkRows(1) + tdSql.query("select sum_double(id) from st where ts between 1604298064000 and 1604298064010 and id>=0") + tdSql.checkData(0,0,0) + tdSql.query("select sum_double(id) from tb1 where ts between 1604298064000 and 1604298064010 and id>=0") + tdSql.checkData(0,0,0) + tdSql.query("select add_one(id) from st where id in (1,2)") + tdSql.checkData(0,0,2) + tdSql.checkData(1,0,3) + tdSql.checkData(2,0,2) + tdSql.checkData(3,0,3) + tdSql.checkRows(4) + + tdSql.query("select sum_double(id) from st where ts < now and ind =1 interval(1s)") + tdSql.checkData(0,1,20) + tdSql.error("select sum_double(id) from st where ts < now and ind =1 interval(3s) sliding (1s) fill (NULL) ") + tdSql.error("select sum_double(id) from st session(ts, 1s)") + tdSql.query("select sum_double(id) from tb1 session(ts, 1s)") + tdSql.checkData(0,1,20) + + # intervals sliding values calculation + tdSql.query("select sum_double(id) from st where ts < now and ind =1 interval(3s) sliding (1s) limit 2") + tdSql.checkData(0,1,20) + tdSql.checkData(1,1,20) + + # scalar_function can't work when using interval and sliding ========= + tdSql.error("select add_one(id) from st where ts < now and ind =1 interval(3s) sliding (1s) limit 2 ") + tdSql.error("select add_one(id) from st order by ts") + tdSql.error("select ts,id,add_one(id) from st order by ts asc;") + + # # UDF not support order by + tdSql.error("select ts,id,add_one(id) from st order by ts desc;") + + # UDF function union all + tdSql.query("select add_one(id) from tb1 union all select add_one(id) from tb2;") + tdSql.checkRows(10) + tdSql.checkData(0,0,1) + tdSql.checkData(5,0,1) + tdSql.query("select sum_double(id) from tb1 union all select sum_double(id) from tb2;") + tdSql.checkRows(2) + tdSql.checkData(0,0,20) + tdSql.checkData(1,0,20) + tdSql.query("select abs_max(number) from tb1 union all select abs_max(number) from bound;") + tdSql.checkRows(2) + tdSql.checkData(0,0,400) + tdSql.checkData(1,0,9223372036854775807) + tdSql.execute("create stable stb (ts timestamp,id int , val double , number bigint, chars binary(200)) tags (ind int)") + tdSql.execute("create table stb1 using stb tags(3)") + tdSql.execute("insert into stb1 values(1604298064000 , 1 , 1.0 , 10000 ,'chars')") + tdSql.query("select add_one(id) from st union all select add_one(id) from stb;") + tdSql.checkRows(15) + tdSql.checkData(13,0,None) + tdSql.checkData(14,0,2) + tdSql.query("select add_one(id) from st union all select add_one(id) from stb1;") + tdSql.checkRows(15) + tdSql.checkData(13,0,None) + tdSql.checkData(14,0,2) + tdSql.query("select id ,add_one(id) from tb1 union all select id ,add_one(id) from stb1;") + tdSql.checkRows(6) + tdSql.checkData(0,0,0) + tdSql.checkData(0,1,1) + tdSql.checkData(1,0,1) + tdSql.checkData(1,1,2) + + # aggregate union all for different stables + tdSql.query("select sum_double(id) from st union all select sum_double(id) from stb;") + tdSql.checkRows(2) + tdSql.checkData(0,0,44) + tdSql.checkData(1,0,2) + tdSql.query("select id from st union all select id from stb1;") + tdSql.checkRows(15) + tdSql.query("select id from tb1 union all select id from stb1") + tdSql.checkRows(6) + tdSql.query("select sum_double(id) from tb1 union all select sum_double(id) from stb") + tdSql.checkData(0,0,20) + tdSql.checkData(1,0,2) + tdSql.query("select sum_double(id) from st union all select sum_double(id) from stb1;") + tdSql.checkRows(2) + tdSql.checkData(0,0,44) + tdSql.checkData(1,0,2) + tdSql.query("select abs_max(number) from st union all select abs_max(number) from stb;") + tdSql.checkData(0,0,9223372036854775807) + tdSql.query("select abs_max(number) from bound union all select abs_max(number) from stb1;") + tdSql.checkData(0,0,9223372036854775807) + tdSql.checkData(1,0,10000) + tdSql.query("select abs_max(number) from st union all select abs_max(number) from stb1;") + tdSql.checkData(0,0,9223372036854775807) + tdSql.checkData(1,0,10000) + + # group by for aggegate function ; + tdSql.query("select sum_double(id) from st group by tbname;") + tdSql.checkData(0,0,20) + tdSql.checkData(0,1,'tb1') + tdSql.checkData(1,0,20) + tdSql.checkData(1,1,'tb2') + tdSql.query("select sum_double(id) from st group by id;") + tdSql.checkRows(9) + tdSql.query("select sum_double(id) from st group by ts") + tdSql.checkRows(12) + tdSql.query("select sum_double(id) from st group by ind") + tdSql.checkRows(3) + tdSql.query("select sum_double(id) from st group by tbname order by ts asc;") + tdSql.query("select abs_max(number) from st group by id") + tdSql.checkRows(9) + tdSql.checkData(0,0,9223372036854775806) + tdSql.checkData(8,0,9223372036854775807) + tdSql.query("select abs_max(number) from st group by ts") + tdSql.checkRows(12) + tdSql.checkData(11,0,9223372036854775807) + tdSql.checkData(1,0,9223372036854775805) + tdSql.query("select abs_max(number) from st group by ind") + tdSql.checkRows(3) + tdSql.checkData(0,0,400) + tdSql.checkData(2,0,9223372036854775807) + + # UDF join + tdSql.query("select add_one(tb1.id),add_one(bound.id) from tb1,bound where tb1.ts=bound.ts;") + tdSql.checkData(0,0,1) + tdSql.checkData(0,1,-2147483644) + tdSql.query("select stb1.ts,add_one(stb1.id),bound.ts,add_one(bound.id) from stb1,bound where stb1.ts=bound.ts") + tdSql.checkData(0,1,2) + tdSql.checkData(0,3,-2147483645) + tdSql.query("select st.ts,add_one(st.id),stb.ts,add_one(stb.id) from st,stb where st.ts=stb.ts and st.ind=stb.ind") + tdSql.checkData(0,1,-2147483645) + tdSql.checkData(0,3,2) + + tdSql.query("select sum_double(tb1.id),sum_double(bound.id) from tb1,bound where tb1.ts=bound.ts;") + tdSql.checkData(0,0,0) + tdSql.checkData(0,1,-4294967290) + tdSql.query("select sum_double(stb1.id),sum_double(bound.id) from stb1,bound where stb1.ts=bound.ts") + tdSql.checkData(0,0,2) + tdSql.checkData(0,1,-4294967292) + + #UDF join for stables + tdSql.query("select sum_double(st.id),sum_double(stb.id) from st,stb where st.ts=stb.ts and st.ind=stb.ind") + tdSql.checkData(0,0,-4294967292) + tdSql.checkData(0,1,2) + tdSql.query("select abs_max(tb1.number),abs_max(bound.number) from tb1,bound where tb1.ts=bound.ts;") + tdSql.checkData(0,0,0) + tdSql.checkData(0,1,9223372036854775805) + tdSql.query("select abs_max(stb1.number),abs_max(bound.number) from stb1,bound where stb1.ts=bound.ts") + tdSql.checkData(0,0,10000) + tdSql.checkData(0,1,9223372036854775806) + tdSql.query("select abs_max(st.number),abs_max(stb.number) from st,stb where st.ts=stb.ts and st.ind=stb.ind") + tdSql.checkData(0,0,9223372036854775806) + tdSql.checkData(0,1,10000) + + # check boundary + tdSql.query("select abs_max(number) from bound") + tdSql.checkData(0,0,9223372036854775807) + + tdLog.info("======= UDF function sum_double check =======") + + + tdSql.query("select sum_double(id) from st") + tdSql.checkData(0,0,44) + tdSql.query("select sum_double(id) from tb1") + tdSql.checkData(0,0,20) + + # only one udf function in SQL can use ,follow errors notice. + tdSql.error("select sum_double(id) , abs_max(number) from tb1") + tdSql.error("select sum_double(id) , abs_max(number) from st") + + + # UDF not support mix up with build-in functions + # it seems like not support scalar_function mix up with aggregate functions + tdSql.error("select sum_double(id) ,add_one(id) from st") + tdSql.error("select sum_double(id) ,add_one(id) from tb1") + tdSql.error("select sum_double(id) ,max(id) from st") + tdSql.error("select sum_double(id) ,max(id) from tb1") + tdSql.error("select twa(id),add_one(id) from st") + tdSql.error("select twa(id),add_one(id) from tb1") + + # UDF function not support Arithmetic =================== + + tdSql.query("select max(id) + 5 from st") + tdSql.query("select max(id) + 5 from tb1") + tdSql.query("select max(id) + avg(val) from st") + tdSql.query("select abs_max(number)*5 from st") + tdSql.checkData(0,0,46116860184273879040.000000000) + tdSql.query("select abs_max(number)*5 from tb1") + tdSql.checkData(0,0,2000.000000000) + tdSql.query("select max(id) + avg(val) from tb1") + tdSql.query("select add_one(id) + 5 from st") + tdSql.checkData(4,0,10.000000000) + tdSql.query("select add_one(id)/5 from tb1") + tdSql.checkData(4,0,1.000000000) + tdSql.query("select sum_double(id)-5 from st") + tdSql.checkData(0,0,39.000000000) + tdSql.query("select sum_double(id)*5 from tb1") + tdSql.checkData(0,0,100.000000000) + + + tdSql.query("select abs_max(number) + 5 from tb1") + tdSql.error("select abs_max(number) + max(id) from st") + tdSql.query("select abs_max(number)*abs_max(val) from st") + tdSql.query("select sum_double(id) + sum_double(id) from st") + tdSql.checkData(0,0,88.000000000) + + tdLog.info("======= UDF Nested query test =======") + tdSql.query("select sum(id) from (select id from st)") + tdSql.checkData(0,0,22) + + + #UDF bug -> Nested query + # outer nest query + tdSql.query("select abs_max(number) from (select number from st)") + tdSql.checkData(0,0,9223372036854775807) + tdSql.query("select abs_max(number) from (select number from bound)") + tdSql.checkData(0,0,9223372036854775807) + tdSql.query("select sum_double(id) from (select id from st)") + tdSql.checkData(0,0,44) + tdSql.query("select sum_double(id) from (select id from bound)") + tdSql.checkData(0,0,4) + tdSql.query("select add_one(id) from (select id from st);") + tdSql.checkRows(14) + tdSql.checkData(1,0,2) + tdSql.query("select add_one(id) from (select id from bound);") + tdSql.checkRows(4) + tdSql.checkData(1,0,-2147483644) + + # inner nest query + tdSql.query("select id from (select add_one(id) id from st)") + tdSql.checkRows(14) + tdSql.checkData(13,0,None) + tdSql.query("select id from (select add_one(id) id from bound)") + tdSql.checkRows(4) + tdSql.checkData(3,0,None) + + tdSql.query("select id from (select sum_double(id) id from bound)") + tdSql.checkData(0,0,4) + tdSql.query("select id from (select sum_double(id) id from st)") # it will crash taos shell + tdSql.checkData(0,0,44) + + tdSql.query("select id from (select abs_max(number) id from st)") # it will crash taos shell + tdSql.checkData(0,0,9223372036854775807) + tdSql.query("select id from (select abs_max(number) id from bound)") + tdSql.checkData(0,0,9223372036854775807) + + # inner and outer nest query + + tdSql.query("select add_one(id) from (select add_one(id) id from st)") + tdSql.checkRows(14) + tdSql.checkData(0,0,2) + tdSql.checkData(1,0,3) + + tdSql.query("select add_one(id) from (select add_one(id) id from tb1)") + tdSql.checkRows(5) + tdSql.checkData(0,0,2) + tdSql.checkData(1,0,3) + + tdSql.query("select sum_double(sumdb) from (select sum_double(id) sumdb from st)") + tdSql.query("select sum_double(sumdb) from (select sum_double(id) sumdb from tb1)") + + tdSql.query("select abs_max(number) from (select abs_max(number) number from st)") + tdSql.checkData(0,0,9223372036854775807) + + tdSql.query("select abs_max(number) from (select abs_max(number) number from bound)") + tdSql.checkData(0,0,9223372036854775807) + + # nest inner and outer with build-in func + + tdSql.query("select max(number) from (select abs_max(number) number from st)") + tdSql.checkData(0,0,9223372036854775807) + + tdSql.query("select max(number) from (select abs_max(number) number from bound)") + tdSql.checkData(0,0,9223372036854775807) + + tdSql.query("select sum_double(sumdb) from (select sum_double(id) sumdb from st)") + + tdSql.query("select sum(sumdb) from (select sum_double(id) sumdb from tb1)") + tdSql.checkData(0,0,20) + + + tdLog.info(" =====================test illegal creation method =====================") + + # tdSql.execute("drop function add_one") + tdSql.execute("drop function abs_max") + tdSql.execute("drop function sum_double") + + tdSql.execute("create aggregate function error_use1 as '/tmp/abs_max.so' outputtype bigint ") + tdSql.error("select error_use1(number) from st") + + # illega UDF create aggregate functions as an scalar_function + # with no aggregate + tdSql.execute("create function abs_max as '/tmp/abs_max.so' outputtype bigint bufsize 128") + tdSql.error("select abs_max(number) from st") + tdSql.execute("create function sum_double as '/tmp/sum_double.so' outputtype bigint bufsize 128") + tdSql.error("select sum_double(id) from st") + + + # UDF -> improve : aggregate function with no bufsize : it seems with no affect + tdSql.execute("drop function abs_max") + tdSql.execute("drop function sum_double") + tdSql.execute("create aggregate function abs_max as '/tmp/abs_max.so' outputtype bigint ") + tdSql.execute("create aggregate function sum_double as '/tmp/sum_double.so' outputtype int ") + tdSql.query("select sum_double(id) from st") + tdSql.checkData(0,0,44) + tdSql.query("select sum_double(id) from tb1") + tdSql.checkData(0,0,20) + tdSql.query("select abs_max(number) from st") + tdSql.checkData(0,0,9223372036854775807) + tdSql.query("select abs_max(number) from tb1") + tdSql.checkData(0,0,400) + + tdSql.query("select abs_max(number) from tb1") # it seems work well + tdSql.checkData(0,0,400) + + + # UDF scalar function not support group by + tdSql.error("select add_one(id) from st group by tbname") + + # UDF : give aggregate for scalar_function add_one ,it can't work well + tdSql.execute("drop function add_one") + tdSql.execute("create aggregate function add_one as '/tmp/add_one.so' outputtype bigint bufsize 128") + tdSql.error("select add_one(id) from st") + + # udf must give col list + tdSql.error("select add_one(*) from st ") + tdSql.error("select add_one(*) from tb1 ") + + # one udf function can multi use + tdSql.query("select abs_max(id),abs_max(number) from st ") + tdSql.query("select abs_max(number),abs_max(number)*3 from st ") + tdSql.query("select abs_max(number),abs_max(number)*3 from tb1 ") + tdSql.query("select sum_double(id),sum_double(id) from st ") + + def run(self): + tdSql.prepare() + + tdLog.info("==============step1 prepare udf build=============") + self.pre_stable() + tdLog.info("==============step2 prepare udf null =============") + self.test_udf_null() + tdLog.info("==============step3 prepare udf format ===========") + self.test_udf_format() + tdLog.info("==============step4 test udf functions============") + self.test_udf_test() + tdLog.info("==============step4 test udf values ============") + self.test_udf_values() + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/query/unionAllTest.py b/tests/pytest/query/unionAllTest.py new file mode 100644 index 0000000000000000000000000000000000000000..eaef5d2d573ba3c0ab08ed7ede991d25913c2454 --- /dev/null +++ b/tests/pytest/query/unionAllTest.py @@ -0,0 +1,160 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +import random + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.ts = 1600000000000 + self.num = 10 + + def run(self): + tdSql.prepare() + + tdSql.execute("create table st(ts timestamp, c1 int) tags(loc nchar(20))") + tdSql.execute("create table t0 using st tags('nchar0')") + tdSql.execute("create table t1 using st tags('nchar1')") + tdSql.execute("create table t2 using st tags('nchar2')") + tdSql.execute("create table t3 using st tags('nchar3')") + tdSql.execute("create table t4 using st tags('nchar4')") + tdSql.execute("create table t5 using st tags('nchar5')") + + for i in range(self.num): + tdSql.execute("insert into t0 values(%d, %d)" % (self.ts + i, i)) + tdSql.execute("insert into t1 values(%d, %d)" % (self.ts + i, i)) + tdSql.execute("insert into t2 values(%d, %d)" % (self.ts + i, i)) + tdSql.execute("insert into t3 values(%d, %d)" % (self.ts + i, i)) + tdSql.execute("insert into t4 values(%d, %d)" % (self.ts + i, i)) + tdSql.execute("insert into t5 values(%d, %d)" % (self.ts + i, i)) + + sql = ''' select * from st where loc = 'nchar0' limit 1 union all select * from st where loc = 'nchar1' limit 1 union all select * from st where loc = 'nchar2' limit 1 + union all select * from st where loc = 'nchar3' limit 1 union all select * from st where loc = 'nchar4' limit 1''' + tdSql.query(sql) + tdSql.checkRows(5) + + sql = ''' select * from st where loc = 'nchar0' limit 1 union all select * from st where loc = 'nchar1' limit 1 union all select * from st where loc = 'nchar2' limit 1 + union all select * from st where loc = 'nchar3' limit 1 union all select * from st where loc = 'nchar4' limit 1 union all select * from st where loc = 'nchar5' limit 1''' + tdSql.query(sql) + tdSql.checkRows(6) + + tdSql.execute("create table stb(ts timestamp, options binary(7), city binary(10)) tags(type int)") + tdSql.execute("insert into tb1 using stb tags(1) values(%d, 'option1', 'beijing')" % self.ts) + tdSql.execute("insert into tb2 using stb tags(2) values(%d, 'option2', 'shanghai')" % self.ts) + + tdSql.query("select options from stb where type = 1 limit 1 union all select options from stb where type = 2 limit 1") + tdSql.checkData(0, 0, "option1") + tdSql.checkData(1, 0, "option2") + + tdSql.query("select 'dc' as options from stb where type = 1 limit 1 union all select 'ad' as options from stb where type = 2 limit 1") + tdSql.checkData(0, 0, "dc") + tdSql.checkData(1, 0, "ad") + + tdSql.query("select 'dc' as options from stb where type = 1 limit 1 union all select 'adc' as options from stb where type = 2 limit 1") + tdSql.checkData(0, 0, "dc") + tdSql.checkData(1, 0, "adc") + + tdSql.error("select 'dc' as options from stb where type = 1 limit 1 union all select 'ad' as city from stb where type = 2 limit 1") + + # for defect https://jira.taosdata.com:18080/browse/TD-4017 + tdSql.execute("alter table stb add column col int") + tdSql.execute("insert into tb1 values(%d, 'option1', 'beijing', 10)" % (self.ts + 1000)) + + tdSql.query("select 'dc' as options from stb where col > 10 limit 1") + tdSql.checkRows(0) + + tdSql.query("select 'dcs' as options from stb where col > 200 limit 1 union all select 'aaa' as options from stb limit 10") + tdSql.checkData(0, 0, 'aaa') + + # https://jira.taosdata.com:18080/browse/TS-444 + tdLog.info("test case for TS-444") + + tdSql.query("select count(*) as count, loc from st where ts between 1600000000000 and 1600000000010 group by loc") + tdSql.checkRows(6) + + tdSql.query("select count(*) as count, loc from st where ts between 1600000000020 and 1600000000030 group by loc") + tdSql.checkRows(0) + + tdSql.query(''' select count(*) as count, loc from st where ts between 1600000000000 and 1600000000010 group by loc + union all + select count(*) as count, loc from st where ts between 1600000000020 and 1600000000030 group by loc''') + tdSql.checkRows(6) + + tdSql.query(''' select count(*) as count, loc from st where ts between 1600000000020 and 1600000000030 group by loc + union all + select count(*) as count, loc from st where ts between 1600000000000 and 1600000000010 group by loc''') + tdSql.checkRows(6) + + # https://jira.taosdata.com:18080/browse/TS-715 + tdLog.info("test case for TS-715") + sql = "" + + tdSql.execute("create table st2(ts timestamp, c1 int, c2 int, c3 int) tags(loc nchar(20))") + + for i in range(101): + if i == 0: + sql = "select last(*) from sub0 " + else: + sql += f"union all select last(*) from sub{i} " + + tdSql.execute("create table sub%d using st2 tags('nchar%d')" % (i, i)) + tdSql.execute("insert into sub%d values(%d, %d, %d, %d)(%d, %d, %d, %d)" % (i, self.ts + i, i, i, i,self.ts + i + 101, i + 101, i + 101, i + 101)) + + tdSql.error(sql) + + # TS-795 + tdLog.info("test case for TS-795") + + functions = ["*", "count", "avg", "twa", "irate", "sum", "stddev", "leastsquares", "min", "max", "first", "last", "top", "bottom", "percentile", "apercentile", "last_row"] + + for func in functions: + expr = func + if func == "top" or func == "bottom": + expr += "(c1, 1)" + elif func == "percentile" or func == "apercentile": + expr += "(c1, 0.5)" + elif func == "leastsquares": + expr = func + "(c1, 1, 1)" + elif func == "*": + expr = func + else: + expr += "(c1)" + + for i in range(100): + if i == 0: + sql = f"select {expr} from sub0 " + else: + sql += f"union all select {expr} from sub{i} " + + tdSql.query(sql) + if func == "*": + tdSql.checkRows(200) + else: + tdSql.checkRows(100) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/queryCount.py b/tests/pytest/queryCount.py new file mode 100644 index 0000000000000000000000000000000000000000..7cc8f61f4dd4790cfc8c2229675eab87b440fadf --- /dev/null +++ b/tests/pytest/queryCount.py @@ -0,0 +1,91 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +import threading +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class QueryCountMultiThread: + def initConnection(self): + self.records = 10000000 + self.numOfTherads = 50 + self.ts = 1537146000000 + self.host = "127.0.0.1" + self.user = "root" + self.password = "taosdata" + self.config = "/home/xp/git/TDengine/sim/dnode1/cfg" + self.conn = taos.connect( + self.host, + self.user, + self.password, + self.config) + + def insertData(self, threadID): + cursor = self.conn.cursor() + print("Thread %d: starting" % threadID) + base = 200000 * threadID + for i in range(200): + query = "insert into tb values" + for j in range(1000): + query += "(%d, %d, 'test')" % (self.ts + base + i * 1000 + j, base + i * 1000 + j) + cursor.execute(query) + cursor.close() + print("Thread %d: finishing" % threadID) + + def run(self): + tdDnodes.init("") + tdDnodes.setTestCluster(False) + tdDnodes.setValgrind(False) + + tdDnodes.stopAll() + tdDnodes.deploy(1) + tdDnodes.start(1) + + cursor = self.conn.cursor() + cursor.execute("drop database if exists db") + cursor.execute("create database db") + cursor.execute("use db") + cursor.execute("create table tb (ts timestamp, id int, name nchar(30))") + cursor.close() + + threads = [] + for i in range(50): + thread = threading.Thread(target=self.insertData, args=(i,)) + threads.append(thread) + thread.start() + + for i in range(50): + threads[i].join() + + cursor = self.conn.cursor() + cursor.execute("use db") + sql = "select count(*) from tb" + cursor.execute(sql) + data = cursor.fetchall() + + if(data[0][0] == 10000000): + tdLog.info("sql:%s, row:%d col:%d data:%d == expect:%d" % (sql, 0, 0, data[0][0], 10000000)) + else: + tdLog.exit("queryCount.py failed: sql:%s failed, row:%d col:%d data:%d != expect:%d" % (sql, 0, 0, data[0][0], 10000000)) + + cursor.close() + self.conn.close() + +q = QueryCountMultiThread() +q.initConnection() +q.run() \ No newline at end of file diff --git a/tests/pytest/random-test/random-test-multi-threading-3.py b/tests/pytest/random-test/random-test-multi-threading-3.py new file mode 100644 index 0000000000000000000000000000000000000000..a8e2c26ae5fa4f4dffa7967b09919abfc670c8bf --- /dev/null +++ b/tests/pytest/random-test/random-test-multi-threading-3.py @@ -0,0 +1,391 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import random +from threading import Thread, Event + +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + +last_tb = "" +last_stb = "" +written = 0 +last_timestamp = 0 +colAdded = False +killed = False + + +class Test (Thread): + def __init__(self, threadId, name, events, q): + Thread.__init__(self) + self.threadId = threadId + self.name = name + self.dataEvent, self.dbEvent, self.queryEvent = events + self.q = q + + def create_table(self): + tdLog.info("create_table") + global last_tb + global written + global killed + + current_tb = "tb%d" % int(round(time.time() * 1000)) + + if (current_tb == last_tb): + return + else: + tdLog.info("will create table %s" % current_tb) + + try: + tdSql.execute( + 'create table %s (ts timestamp, speed int, c2 nchar(10))' % + current_tb) + last_tb = current_tb + written = 0 + killed = False + except Exception as e: + tdLog.info("killed: %d error: %s" % (killed, e.args[0])) + if killed and (e.args[0] == 'network unavailable'): + tdLog.info("database killed, expect failed") + return 0 + return -1 + return 0 + + def insert_data(self): + tdLog.info("insert_data") + global last_tb + global written + global last_timestamp + + if (last_tb == ""): + tdLog.info("no table, create first") + self.create_table() + + start_time = 1500000000000 + + tdLog.info("will insert data to table") + for i in range(0, 10): + insertRows = 1000 + tdLog.info("insert %d rows to %s" % (insertRows, last_tb)) + + for j in range(0, insertRows): + if (last_tb == ""): + tdLog.info("no table, return") + return 0 + try: + tdSql.execute( + 'insert into %s values (%d + %da, %d, "test")' % + (last_tb, start_time, last_timestamp, last_timestamp)) + written = written + 1 + last_timestamp = last_timestamp + 1 + except Exception as e: + if killed: + tdLog.info( + "database killed, expect failed %s" % + e.args[0]) + return 0 + tdLog.info(repr(e)) + return -1 + return 0 + + def query_data(self): + tdLog.info("query_data") + global last_tb + global killed + + if not killed and last_tb != "": + tdLog.info("query data from table") + tdSql.query("select * from %s" % last_tb) + tdSql.checkRows(written) + return 0 + + def create_stable(self): + tdLog.info("create_stable") + global last_tb + global last_stb + global written + global last_timestamp + + current_stb = "stb%d" % int(round(time.time() * 1000)) + + if (current_stb == last_stb): + return + else: + tdLog.info("will create stable %s" % current_stb) + tdSql.execute( + 'create table %s(ts timestamp, c1 int, c2 nchar(10)) tags (t1 int, t2 nchar(10))' % + current_stb) + last_stb = current_stb + + current_tb = "tb%d" % int(round(time.time() * 1000)) + tdSql.execute( + "create table %s using %s tags (1, '表1')" % + (current_tb, last_stb)) + last_tb = current_tb + written = 0 + + start_time = 1500000000000 + + tdSql.execute( + "insert into %s values (%d+%da, 27, '我是nchar字符串')" % + (last_tb, start_time, last_timestamp)) + written = written + 1 + last_timestamp = last_timestamp + 1 + return 0 + + def drop_stable(self): + tdLog.info("drop_stable") + global last_stb + global last_tb + global written + + if (last_stb == ""): + tdLog.info("no super table") + return + else: + tdLog.info("will drop last super table") + tdSql.execute('drop table %s' % last_stb) + last_stb = "" + last_tb = "" + written = 0 + return 0 + + def alter_table_to_add_col(self): + tdLog.info("alter_table_to_add_col") + global last_stb + global colAdded + + if last_stb != "" and colAdded == False: + tdSql.execute( + "alter table %s add column col binary(20)" % + last_stb) + colAdded = True + return 0 + + def alter_table_to_drop_col(self): + tdLog.info("alter_table_to_drop_col") + global last_stb + global colAdded + + if last_stb != "" and colAdded: + tdSql.execute("alter table %s drop column col" % last_stb) + colAdded = False + return 0 + + def restart_database(self): + tdLog.info("restart_database") + global last_tb + global written + global killed + + tdDnodes.stop(1) + killed = True + tdDnodes.start(1) + tdLog.sleep(10) + killed = False + return 0 + + def force_restart_database(self): + tdLog.info("force_restart_database") + global last_tb + global written + global killed + + tdDnodes.forcestop(1) + last_tb = "" + written = 0 + killed = True + tdDnodes.start(1) +# tdLog.sleep(10) + killed = False + return 0 + + def drop_table(self): + tdLog.info("drop_table") + global last_tb + global written + + for i in range(0, 10): + if (last_tb != ""): + tdLog.info("drop last_tb %s" % last_tb) + tdSql.execute("drop table %s" % last_tb) + last_tb = "" + written = 0 + return 0 + + def query_data_from_stable(self): + tdLog.info("query_data_from_stable") + global last_stb + + if (last_stb == ""): + tdLog.info("no super table") + return + else: + tdLog.info("will query data from super table") + tdSql.execute('select * from %s' % last_stb) + return 0 + + def reset_query_cache(self): + tdLog.info("reset_query_cache") + global last_tb + global written + + tdLog.info("reset query cache") + tdSql.execute("reset query cache") + tdLog.sleep(1) + return 0 + + def reset_database(self): + tdLog.info("reset_database") + global last_tb + global last_stb + global written + global killed + + tdDnodes.forcestop(1) + killed = True + tdDnodes.deploy(1) + tdDnodes.start(1) + tdSql.prepare() + killed = False + return 0 + + def delete_datafiles(self): + tdLog.info("delete_data_files") + global last_tb + global last_stb + global written + global killed + + dnodesDir = tdDnodes.getDnodesRootDir() + tdDnodes.forcestop(1) + killed = True + dataDir = dnodesDir + '/dnode1/data/*' + deleteCmd = 'rm -rf %s' % dataDir + os.system(deleteCmd) + last_tb = "" + last_stb = "" + written = 0 + + tdDnodes.start(1) + tdSql.prepare() + killed = False + return 0 + + def run(self): + dataOp = { + 1: self.insert_data, + } + + dbOp = { + 1: self.create_table, + 2: self.create_stable, + 3: self.restart_database, + 4: self.force_restart_database, + 5: self.drop_table, + 6: self.reset_query_cache, + 7: self.reset_database, + 8: self.delete_datafiles, + 9: self.drop_stable, + 10: self.alter_table_to_add_col, + 11: self.alter_table_to_drop_col, + } + + queryOp = { + 1: self.query_data, + 2: self.query_data_from_stable, + } + + if (self.threadId == 1): + while True: + self.dataEvent.wait() + tdLog.notice("first thread") + randDataOp = random.randint(1, 1) + ret1 = dataOp.get(randDataOp, lambda: "ERROR")() + + if ret1 == -1: + self.q.put(-1) + tdLog.exit("first thread failed") + else: + self.q.put(1) + + if (self.q.get() != -2): + self.dataEvent.clear() + self.queryEvent.clear() + self.dbEvent.set() + else: + self.q.put(-1) + tdLog.exit("second thread failed, first thread exit too") + + elif (self.threadId == 2): + while True: + self.dbEvent.wait() + tdLog.notice("second thread") + randDbOp = random.randint(1, 11) + dbOp.get(randDbOp, lambda: "ERROR")() + self.dbEvent.clear() + self.dataEvent.clear() + self.queryEvent.set() + + elif (self.threadId == 3): + while True: + self.queryEvent.wait() + tdLog.notice("third thread") + randQueryOp = random.randint(1, 2) + queryOp.get(randQueryOp, lambda: "ERROR")() + self.queryEvent.clear() + self.dbEvent.clear() + self.dataEvent.set() + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + events = [Event() for _ in range(3)] + events[0].set() + events[1].clear() + events[1].clear() + + test1 = Test(1, "data operation", events) + test2 = Test(2, "db operation", events) + test3 = Test(3, "query operation", events) + + test1.start() + test2.start() + test3.start() + + test1.join() + test2.join() + test3.join() + + while not q.empty(): + if (q.get() != 0): + tdLog.exit("failed to end of test") + + tdLog.info("end of test") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/random-test/random-test-multi-threading.py b/tests/pytest/random-test/random-test-multi-threading.py new file mode 100644 index 0000000000000000000000000000000000000000..81862edcf186674c920c07c01144ecbd8cf8c0f0 --- /dev/null +++ b/tests/pytest/random-test/random-test-multi-threading.py @@ -0,0 +1,383 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import random +import threading +import queue + +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + +last_tb = "" +last_stb = "" +written = 0 +last_timestamp = 0 +colAdded = False +killed = False + + +class Test (threading.Thread): + def __init__(self, threadId, name, q): + threading.Thread.__init__(self) + self.threadId = threadId + self.name = name + self.q = q + + self.threadLock = threading.Lock() + + def create_table(self): + tdLog.info("create_table") + global last_tb + global written + global killed + + current_tb = "tb%d" % int(round(time.time() * 1000)) + + if (current_tb == last_tb): + return 0 + else: + tdLog.info("will create table %s" % current_tb) + + try: + tdSql.execute( + 'create table %s (ts timestamp, speed int, c1 nchar(10))' % + current_tb) + last_tb = current_tb + written = 0 + killed = False + except Exception as e: + tdLog.info("killed: %d error: %s" % (killed, e.args[0])) + if killed and (e.args[0] == 'network unavailable'): + tdLog.info("database killed, expect failed") + return 0 + return -1 + return 0 + + def insert_data(self): + tdLog.info("insert_data") + global last_tb + global written + global last_timestamp + + if (last_tb == ""): + tdLog.info("no table, create first") + self.create_table() + + start_time = 1500000000000 + + tdLog.info("will insert data to table") + for i in range(0, 10): + insertRows = 1000 + tdLog.info("insert %d rows to %s" % (insertRows, last_tb)) + + for j in range(0, insertRows): + if (last_tb == ""): + tdLog.info("no table, return") + return 0 + + try: + tdSql.execute( + 'insert into %s values (%d + %da, %d, "test")' % + (last_tb, start_time, last_timestamp, last_timestamp)) + written = written + 1 + last_timestamp = last_timestamp + 1 + except Exception as e: + if killed: + tdLog.info( + "database killed, expect failed %s" % + e.args[0]) + return 0 + tdLog.info(repr(e)) + return -1 + return 0 + + def query_data(self): + tdLog.info("query_data") + global last_tb + global killed + + if not killed and last_tb != "": + tdLog.info("query data from table") + tdSql.query("select * from %s" % last_tb) + tdSql.checkRows(written) + return 0 + + def create_stable(self): + tdLog.info("create_stable") + global last_tb + global last_stb + global written + global last_timestamp + + current_stb = "stb%d" % int(round(time.time() * 1000)) + + if (current_stb != last_stb): + tdLog.info("will create stable %s" % current_stb) + tdLog.info( + 'create table %s(ts timestamp, c1 int, c2 nchar(10)) tags (t1 int, t2 nchar(10))' % + current_stb) + tdSql.execute( + 'create table %s(ts timestamp, c1 int, c2 nchar(10)) tags (t1 int, t2 nchar(10))' % + current_stb) + last_stb = current_stb + + current_tb = "tb%d" % int(round(time.time() * 1000)) + tdLog.info( + "create table %s using %s tags (1, '表1')" % + (current_tb, last_stb)) + tdSql.execute( + "create table %s using %s tags (1, '表1')" % + (current_tb, last_stb)) + last_tb = current_tb + written = 0 + + start_time = 1500000000000 + + tdSql.execute( + "insert into %s values (%d+%da, 27, '我是nchar字符串')" % + (last_tb, start_time, last_timestamp)) + written = written + 1 + last_timestamp = last_timestamp + 1 + + return 0 + + def drop_stable(self): + tdLog.info("drop_stable") + global last_stb + global last_tb + global written + + if (last_stb == ""): + tdLog.info("no super table") + else: + tdLog.info("will drop last super table %s" % last_stb) + tdSql.execute('drop table %s' % last_stb) + last_stb = "" + last_tb = "" + written = 0 + return 0 + + def alter_table_to_add_col(self): + tdLog.info("alter_table_to_add_col") + global last_stb + global colAdded + + if last_stb != "" and not colAdded: + tdSql.execute( + "alter table %s add column col binary(20)" % + last_stb) + colAdded = True + return 0 + + def alter_table_to_drop_col(self): + tdLog.info("alter_table_to_drop_col") + global last_stb + global colAdded + + if last_stb != "" and colAdded: + tdSql.execute("alter table %s drop column col" % last_stb) + colAdded = False + return 0 + + def restart_database(self): + tdLog.info("restart_database") + global last_tb + global written + global killed + + tdDnodes.stop(1) + killed = True + tdDnodes.start(1) + tdLog.sleep(10) + killed = False + return 0 + + def force_restart_database(self): + tdLog.info("force_restart_database") + global last_tb + global written + global killed + + tdDnodes.forcestop(1) + last_tb = "" + written = 0 + killed = True + tdDnodes.start(1) +# tdLog.sleep(10) + killed = False + return 0 + + def drop_table(self): + tdLog.info("drop_table") + global last_tb + global written + + for i in range(0, 10): + if (last_tb != ""): + tdLog.info("drop last_tb %s" % last_tb) + tdSql.execute("drop table %s" % last_tb) + last_tb = "" + written = 0 + return 0 + + def query_data_from_stable(self): + tdLog.info("query_data_from_stable") + global last_stb + + if (last_stb == ""): + tdLog.info("no super table") + else: + tdLog.info("will query data from super table") + tdSql.execute('select * from %s' % last_stb) + return 0 + + def reset_query_cache(self): + tdLog.info("reset_query_cache") + global last_tb + global written + + tdLog.info("reset query cache") + tdSql.execute("reset query cache") +# tdLog.sleep(1) + return 0 + + def reset_database(self): + tdLog.info("reset_database") + global last_tb + global last_stb + global written + global killed + + tdDnodes.forcestop(1) + killed = True + tdDnodes.deploy(1) + tdDnodes.start(1) + tdSql.prepare() + killed = False + return 0 + + def delete_datafiles(self): + tdLog.info("delete_data_files") + global last_tb + global last_stb + global written + global killed + + dnodesDir = tdDnodes.getDnodesRootDir() + tdDnodes.forcestop(1) + killed = True + dataDir = dnodesDir + '/dnode1/data/*' + deleteCmd = 'rm -rf %s' % dataDir + os.system(deleteCmd) + last_tb = "" + last_stb = "" + written = 0 + + tdDnodes.start(1) + tdSql.prepare() + killed = False + return 0 + + def run(self): + dataOp = { + 1: self.insert_data, + 2: self.query_data, + 3: self.query_data_from_stable, + } + + dbOp = { + 1: self.create_table, + 2: self.create_stable, + 3: self.restart_database, + 4: self.force_restart_database, + 5: self.drop_table, + 6: self.reset_query_cache, + 7: self.reset_database, + 8: self.delete_datafiles, + 9: self.drop_stable, + 10: self.alter_table_to_add_col, + 11: self.alter_table_to_drop_col, + } + + if (self.threadId == 1): + while True: + self.threadLock.acquire() + tdLog.notice("first thread") + randDataOp = random.randint(1, 3) + ret1 = dataOp.get(randDataOp, lambda: "ERROR")() + + if ret1 == -1: + self.q.put(-1) + tdLog.exit("first thread failed") + else: + self.q.put(1) + + if (self.q.get() != -2): + self.threadLock.release() + else: + self.q.put(-1) + tdLog.exit("second thread failed, first thread exit too") + + elif (self.threadId == 2): + while True: + self.threadLock.acquire() + tdLog.notice("second thread") + randDbOp = random.randint(1, 11) + ret2 = dbOp.get(randDbOp, lambda: "ERROR")() + + if ret2 == -1: + self.q.put(-2) + tdLog.exit("second thread failed") + else: + self.q.put(2) + + if (self.q.get() != -1): + self.threadLock.release() + else: + self.q.put(-2) + tdLog.exit("first thread failed, second exit too") + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + q = queue.Queue() + test1 = Test(1, "data operation", q) + test2 = Test(2, "db operation", q) + + test1.start() + test2.start() + test1.join() + test2.join() + + while not q.empty(): + if (q.get() != 0): + tdLog.exit("failed to end of test") + + tdLog.info("end of test") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/random-test/random-test.py b/tests/pytest/random-test/random-test.py new file mode 100644 index 0000000000000000000000000000000000000000..cecefe379de18b1b840d94b015b252d8fe494d36 --- /dev/null +++ b/tests/pytest/random-test/random-test.py @@ -0,0 +1,280 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import random +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import codecs + + +class Test: + def __init__(self): + self.last_tb = "" + self.last_stb = "" + self.written = 0 + self.colAdded = False + + def create_table(self): + tdLog.info("create_table") + current_tb = "tb%d" % int(round(time.time() * 1000)) + + if (current_tb == self.last_tb): + return + else: + tdLog.info("will create table %s" % current_tb) + tdSql.execute( + 'create table %s (ts timestamp, c1 int, c2 nchar(10))' % + current_tb) + self.last_tb = current_tb + self.written = 0 + self.colAdded = False + + def insert_data(self): + tdLog.info("insert_data") + if (self.last_tb == ""): + tdLog.info("no table, create first") + self.create_table() + + tdLog.info("will insert data to table") + insertRows = 10 + tdLog.info("insert %d rows to %s" % (insertRows, self.last_tb)) + for i in range(0, insertRows): + if self.colAdded: + ret = tdSql.execute( + 'insert into %s values (now + %dm, %d, "%s", "%s")' % + (self.last_tb, i, i, "->" + str(i)), "col") + else: + ret = tdSql.execute( + 'insert into %s values (now + %dm, %d, "%s")' % + (self.last_tb, i, i, "->" + str(i))) + + self.written = self.written + 1 + + tdLog.info("insert earlier data") + if self.colAdded: + tdSql.execute( + 'insert into %s values (now - 5m , 10, " - 5m", "col")' % + self.last_tb) + self.written = self.written + 1 + tdSql.execute( + 'insert into %s values (now - 6m , 10, " - 6m", "col")' % + self.last_tb) + self.written = self.written + 1 + tdSql.execute( + 'insert into %s values (now - 7m , 10, " - 7m", "col")' % + self.last_tb) + self.written = self.written + 1 + tdSql.execute( + 'insert into %s values (now - 8m , 10, " - 8m", "col")' % + self.last_tb) + self.written = self.written + 1 + else: + tdSql.execute( + 'insert into %s values (now - 5m , 10, " - 5m")' % + self.last_tb) + self.written = self.written + 1 + tdSql.execute( + 'insert into %s values (now - 6m , 10, " - 6m")' % + self.last_tb) + self.written = self.written + 1 + tdSql.execute( + 'insert into %s values (now - 7m , 10, " - 7m")' % + self.last_tb) + self.written = self.written + 1 + tdSql.execute( + 'insert into %s values (now - 8m , 10, " - 8m")' % + self.last_tb) + self.written = self.written + 1 + + def query_data(self): + tdLog.info("query_data") + if (self.written > 0): + tdLog.info("query data from table") + tdSql.query("select * from %s" % self.last_tb) + tdSql.checkRows(self.written) + + def create_stable(self): + tdLog.info("create_stable") + current_stb = "stb%d" % int(round(time.time() * 1000)) + + if (current_stb == self.last_stb): + return + else: + tdLog.info("will create stable %s" % current_stb) + + db = "db" + tdSql.execute("drop database if exists %s" % (db)) + tdSql.execute("reset query cache") + tdSql.execute("create database %s maxrows 200 maxtables 30" % (db)) + tdSql.execute("use %s" % (db)) + + tdSql.execute( + 'create table %s(ts timestamp, c1 int, c2 nchar(10)) tags (t1 int, t2 nchar(10))' % + current_stb) + self.last_stb = current_stb + self.colAdded = False + + for k in range(1, 300): + current_tb = "tb%d" % int(round(time.time() * 1000)) + sqlcmd = "create table %s using %s tags (1, 'test')" % ( + current_tb, self.last_stb) + tdSql.execute(sqlcmd) + self.last_tb = current_tb + self.written = 0 + + for j in range(1, 100): + tdSql.execute( + "insert into %s values (now + %da, 27, 'wsnchar')" % + (self.last_tb, j)) + self.written = self.written + 1 + + def alter_table_to_add_col(self): + tdLog.info("alter_table_to_add_col") + + if self.last_stb != "" and not self.colAdded: + tdSql.execute( + "alter table %s add column col binary(20)" % + self.last_stb) + self.colAdded = True + + def alter_table_to_drop_col(self): + tdLog.info("alter_table_to_drop_col") + + if self.last_stb != "" and self.colAdded: + tdSql.execute("alter table %s drop column col" % self.last_stb) + self.colAdded = False + + def drop_stable(self): + tdLog.info("drop_stable") + if (self.last_stb == ""): + tdLog.info("no super table") + return + else: + tdLog.info("will drop last super table") + tdSql.execute('drop table %s' % self.last_stb) + self.last_stb = "" + self.last_tb = "" + self.written = 0 + + def query_data_from_stable(self): + tdLog.info("query_data_from_stable") + if (self.last_stb == ""): + tdLog.info("no super table") + return + else: + tdLog.info("will query data from super table") + tdSql.execute('select * from %s' % self.last_stb) + + def restart_database(self): + tdLog.info("restart_database") + tdDnodes.stop(1) + tdDnodes.start(1) + tdLog.sleep(10) + + def force_restart_database(self): + tdLog.info("force_restart_database") + tdDnodes.forcestop(1) + tdDnodes.start(1) + tdLog.sleep(10) + tdSql.prepare() + self.last_tb = "" + self.last_stb = "" + self.written = 0 + + def drop_table(self): + tdLog.info("drop_table") + if (self.last_tb != ""): + tdLog.info("drop last tb %s" % self.last_tb) + tdSql.execute("drop table %s" % self.last_tb) + self.last_tb = "" + self.written = 0 + + def reset_query_cache(self): + tdLog.info("reset_query_cache") + tdSql.execute("reset query cache") + tdLog.sleep(1) + + def reset_database(self): + tdLog.info("reset_database") + tdDnodes.forcestop(1) + tdDnodes.deploy(1) + self.last_tb = "" + self.written = 0 + tdDnodes.start(1) + tdLog.sleep(10) + tdSql.prepare() + self.last_tb = "" + self.last_stb = "" + self.written = 0 + + def delete_datafiles(self): + tdLog.info("delete_datafiles") + dnodesDir = tdDnodes.getDnodesRootDir() + tdDnodes.forcestop(1) + dataDir = dnodesDir + '/dnode1/data/*' + deleteCmd = 'rm -rf %s' % dataDir + os.system(deleteCmd) + + self.last_tb = "" + self.last_stb = "" + self.written = 0 + tdDnodes.start(1) + tdLog.sleep(10) + tdSql.prepare() + self.last_tb = "" + self.last_stb = "" + self.written = 0 + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + test = Test() + + switch = { + 1: test.create_table, + 2: test.insert_data, + 3: test.query_data, + 4: test.create_stable, + 5: test.restart_database, + 6: test.force_restart_database, + 7: test.drop_table, + 8: test.reset_query_cache, + 9: test.reset_database, + 10: test.delete_datafiles, + 11: test.query_data_from_stable, + 12: test.drop_stable, + 13: test.alter_table_to_add_col, + 14: test.alter_table_to_drop_col, + } + + for x in range(1, 1000): + r = random.randint(1, 14) + tdLog.notice("iteration %d run func %d" % (x, r)) + switch.get(r, lambda: "ERROR")() + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/regressiontest.sh b/tests/pytest/regressiontest.sh new file mode 100755 index 0000000000000000000000000000000000000000..b69ee37a555da02e98c8227a6ea5ed81bdb58365 --- /dev/null +++ b/tests/pytest/regressiontest.sh @@ -0,0 +1,182 @@ +#!/bin/bash +ulimit -c unlimited + +python3 ./test.py -f insert/basic.py +python3 ./test.py -f insert/int.py +python3 ./test.py -f insert/float.py +python3 ./test.py -f insert/bigint.py +python3 ./test.py -f insert/bool.py +python3 ./test.py -f insert/double.py +python3 ./test.py -f insert/smallint.py +python3 ./test.py -f insert/tinyint.py +python3 ./test.py -f insert/date.py +python3 ./test.py -f insert/binary.py +python3 ./test.py -f insert/nchar.py +# python3 ./test.py -f insert/nchar-boundary.py +python3 ./test.py -f insert/nchar-unicode.py +python3 ./test.py -f insert/multi.py +python3 ./test.py -f insert/randomNullCommit.py + +python3 ./test.py -f table/column_name.py +python3 ./test.py -f table/column_num.py +python3 ./test.py -f table/db_table.py +# python3 ./test.py -f table/tablename-boundary.py + +# tag +python3 ./test.py -f tag_lite/filter.py +python3 ./test.py -f tag_lite/create-tags-boundary.py +python3 ./test.py -f tag_lite/3.py +python3 ./test.py -f tag_lite/4.py +python3 ./test.py -f tag_lite/5.py +python3 ./test.py -f tag_lite/6.py +python3 ./test.py -f tag_lite/add.py +python3 ./test.py -f tag_lite/bigint.py +python3 ./test.py -f tag_lite/binary_binary.py +python3 ./test.py -f tag_lite/binary.py +python3 ./test.py -f tag_lite/bool_binary.py +python3 ./test.py -f tag_lite/bool_int.py +python3 ./test.py -f tag_lite/bool.py +python3 ./test.py -f tag_lite/change.py +python3 ./test.py -f tag_lite/column.py +python3 ./test.py -f tag_lite/commit.py +python3 ./test.py -f tag_lite/create.py +python3 ./test.py -f tag_lite/datatype.py +python3 ./test.py -f tag_lite/datatype-without-alter.py +python3 ./test.py -f tag_lite/delete.py +python3 ./test.py -f tag_lite/double.py +python3 ./test.py -f tag_lite/float.py +python3 ./test.py -f tag_lite/int_binary.py +python3 ./test.py -f tag_lite/int_float.py +python3 ./test.py -f tag_lite/int.py +python3 ./test.py -f tag_lite/set.py +python3 ./test.py -f tag_lite/smallint.py +python3 ./test.py -f tag_lite/tinyint.py + +# python3 ./test.py -f dbmgmt/database-name-boundary.py + +python3 ./test.py -f import_merge/importBlock1HO.py +python3 ./test.py -f import_merge/importBlock1HPO.py +python3 ./test.py -f import_merge/importBlock1H.py +python3 ./test.py -f import_merge/importBlock1S.py +python3 ./test.py -f import_merge/importBlock1Sub.py +python3 ./test.py -f import_merge/importBlock1TO.py +python3 ./test.py -f import_merge/importBlock1TPO.py +python3 ./test.py -f import_merge/importBlock1T.py +python3 ./test.py -f import_merge/importBlock2HO.py +python3 ./test.py -f import_merge/importBlock2HPO.py +python3 ./test.py -f import_merge/importBlock2H.py +python3 ./test.py -f import_merge/importBlock2S.py +python3 ./test.py -f import_merge/importBlock2Sub.py +python3 ./test.py -f import_merge/importBlock2TO.py +python3 ./test.py -f import_merge/importBlock2TPO.py +python3 ./test.py -f import_merge/importBlock2T.py +python3 ./test.py -f import_merge/importBlockbetween.py +python3 ./test.py -f import_merge/importCacheFileHO.py +python3 ./test.py -f import_merge/importCacheFileHPO.py +python3 ./test.py -f import_merge/importCacheFileH.py +python3 ./test.py -f import_merge/importCacheFileS.py +python3 ./test.py -f import_merge/importCacheFileSub.py +python3 ./test.py -f import_merge/importCacheFileTO.py +python3 ./test.py -f import_merge/importCacheFileTPO.py +python3 ./test.py -f import_merge/importCacheFileT.py +python3 ./test.py -f import_merge/importDataH2.py +python3 ./test.py -f import_merge/importDataHO2.py +python3 ./test.py -f import_merge/importDataHO.py +python3 ./test.py -f import_merge/importDataHPO.py +python3 ./test.py -f import_merge/importDataLastHO.py +python3 ./test.py -f import_merge/importDataLastHPO.py +python3 ./test.py -f import_merge/importDataLastH.py +python3 ./test.py -f import_merge/importDataLastS.py +python3 ./test.py -f import_merge/importDataLastSub.py +python3 ./test.py -f import_merge/importDataLastTO.py +python3 ./test.py -f import_merge/importDataLastTPO.py +python3 ./test.py -f import_merge/importDataLastT.py +python3 ./test.py -f import_merge/importDataS.py +python3 ./test.py -f import_merge/importDataSub.py +python3 ./test.py -f import_merge/importDataTO.py +python3 ./test.py -f import_merge/importDataTPO.py +python3 ./test.py -f import_merge/importDataT.py +python3 ./test.py -f import_merge/importHeadOverlap.py +python3 ./test.py -f import_merge/importHeadPartOverlap.py +python3 ./test.py -f import_merge/importHead.py +python3 ./test.py -f import_merge/importHORestart.py +python3 ./test.py -f import_merge/importHPORestart.py +python3 ./test.py -f import_merge/importHRestart.py +python3 ./test.py -f import_merge/importLastHO.py +python3 ./test.py -f import_merge/importLastHPO.py +python3 ./test.py -f import_merge/importLastH.py +python3 ./test.py -f import_merge/importLastS.py +python3 ./test.py -f import_merge/importLastSub.py +python3 ./test.py -f import_merge/importLastTO.py +python3 ./test.py -f import_merge/importLastTPO.py +python3 ./test.py -f import_merge/importLastT.py +python3 ./test.py -f import_merge/importSpan.py +python3 ./test.py -f import_merge/importSRestart.py +python3 ./test.py -f import_merge/importSubRestart.py +python3 ./test.py -f import_merge/importTailOverlap.py +python3 ./test.py -f import_merge/importTailPartOverlap.py +python3 ./test.py -f import_merge/importTail.py +python3 ./test.py -f import_merge/importToCommit.py +python3 ./test.py -f import_merge/importTORestart.py +python3 ./test.py -f import_merge/importTPORestart.py +python3 ./test.py -f import_merge/importTRestart.py +python3 ./test.py -f import_merge/importInsertThenImport.py +python3 ./test.py -f import_merge/importCSV.py +# user +python3 ./test.py -f user/user_create.py +python3 ./test.py -f user/pass_len.py + +# table +python3 ./test.py -f table/del_stable.py + +#query +python3 ./test.py -f query/filter.py +python3 ./test.py -f query/filterAllIntTypes.py +python3 ./test.py -f query/filterFloatAndDouble.py +python3 ./test.py -f query/filterOtherTypes.py +python3 ./test.py -f query/queryError.py +python3 ./test.py -f query/querySort.py +python3 ./test.py -f query/queryJoin.py +python3 ./test.py -f query/filterCombo.py +python3 ./test.py -f query/queryNormal.py +python3 ./test.py -f query/select_last_crash.py +python3 ./test.py -f query/queryNullValueTest.py +python3 ./test.py -f query/queryInsertValue.py + +#stream +python3 ./test.py -f stream/stream1.py +python3 ./test.py -f stream/stream2.py + +#alter table +python3 ./test.py -f alter/alter_table_crash.py + +# client +python3 ./test.py -f client/client.py +python3 ./test.py -f client/version.py + +# Misc +python3 testCompress.py +python3 testNoCompress.py + + +# functions +python3 ./test.py -f functions/function_avg.py +python3 ./test.py -f functions/function_bottom.py +python3 ./test.py -f functions/function_count.py +python3 ./test.py -f functions/function_diff.py +python3 ./test.py -f functions/function_first.py +python3 ./test.py -f functions/function_last.py +python3 ./test.py -f functions/function_last_row.py +python3 ./test.py -f functions/function_leastsquares.py +python3 ./test.py -f functions/function_max.py +python3 ./test.py -f functions/function_min.py +python3 ./test.py -f functions/function_operations.py +python3 ./test.py -f functions/function_percentile.py +python3 ./test.py -f functions/function_spread.py +python3 ./test.py -f functions/function_stddev.py +python3 ./test.py -f functions/function_sum.py +python3 ./test.py -f functions/function_top.py +python3 ./test.py -f functions/function_twa.py + +# tools +python3 test.py -f tools/taosdemo.py \ No newline at end of file diff --git a/tests/pytest/restful/restful_bind_db1.py b/tests/pytest/restful/restful_bind_db1.py new file mode 100644 index 0000000000000000000000000000000000000000..9620535fd7c9388d08d0ebae9237b243fc0a099c --- /dev/null +++ b/tests/pytest/restful/restful_bind_db1.py @@ -0,0 +1,123 @@ +# ################################################################# +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. + +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao + +# ################################################################# + +# -*- coding: utf-8 -*- + +# TODO: after TD-4518 and TD-4510 is resolved, add the exception test case for these situations + +from distutils.log import error +import sys + +from requests.api import head +from requests.models import Response +from util.log import * +from util.cases import * +from util.sql import * +import time, datetime +import requests, json +import threading +import string +import random + + +def check_unbind_db(url, data, header): + resp = requests.post(url, data, headers = header ) + resp.encoding='utf-8' + resp = eval(resp.text) + status = resp['status'] + desc = resp['desc'] + sqls = data + if status=="error" and desc == "invalid url format": + print(" %s : check pass" %sqls) + else: + printf(" error occured , ") + sys.exit() + +def check_bind_db(url, data, header): + resp = requests.post(url, data, headers = header ) + resp.encoding='utf-8' + resp_dict = eval(resp.text) + status = resp_dict['status'] + if status =="succ": + print("%s run success!"%data) + # print(resp.text) + else : + print("%s run failed !"%data) + print(resp.text) + sys.exit() + +class TDTestCase(): + updatecfgDict={'httpDbNameMandatory':1} + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists test') + tdSql.execute('drop database if exists db') + tdSql.execute('drop database if exists des') + tdSql.execute('create database test') + tdSql.execute('create database des') + + header = {'Authorization': 'Basic cm9vdDp0YW9zZGF0YQ=='} + url = "http://127.0.0.1:6041/rest/sql/" + + # test with no bind databases + + sqls = ["show databases;", + "use test", + "show tables;", + "show dnodes;", + "show vgroups;", + "create database db;", + "drop database db;", + "select client_version();" , + "use test", + "ALTER DATABASE test COMP 2;", + "create table tb (ts timestamp, id int , data double)", + "insert into tb values (now , 1, 1.0) ", + "select * from tb", + "show test.tables", + "show tables", + "insert into tb values (now , 2, 2.0) ", + "create table test.tb (ts timestamp, id int , data double)", + "insert into test.tb values (now , 2, 2.0) ", + "select * from tb", + "select * from test.tb"] + + for sql in sqls: + print("===================") + check_unbind_db(url,sql,header) + + print("==================="*5) + print(" check bind db about restful ") + print("==================="*5) + url = "http://127.0.0.1:6041/rest/sql/des" + for sql in sqls: + print("===================") + check_bind_db(url,sql,header) + # check data + tdSql.query("select * from test.tb") + tdSql.checkRows(1) + tdSql.query("select * from des.tb") + tdSql.checkRows(2) + + os.system('sudo timedatectl set-ntp on') + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/restful/restful_bind_db2.py b/tests/pytest/restful/restful_bind_db2.py new file mode 100644 index 0000000000000000000000000000000000000000..35aa1408a7690798d66bc0303e64fe4843dab0d8 --- /dev/null +++ b/tests/pytest/restful/restful_bind_db2.py @@ -0,0 +1,133 @@ +# ################################################################# +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. + +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao + +# ################################################################# + +# -*- coding: utf-8 -*- + +# TODO: after TD-4518 and TD-4510 is resolved, add the exception test case for these situations + +from distutils.log import error +import sys + +from requests.api import head +from requests.models import Response +from util.log import * +from util.cases import * +from util.sql import * +import time, datetime +import requests, json +import threading +import string +import random + +def check_res(url, data, header): + resp = requests.post(url, data, headers = header ) + resp.encoding='utf-8' + resp_dict = eval(resp.text) + status = resp_dict['status'] + if status =="succ": + print("%s run success!"%data) + # print(resp.text) + else : + print("%s run failed !"%data) + print(resp.text) + sys.exit() + +class TDTestCase(): + # updatecfgDict={'httpDbNameMandatory':0} + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists test') + tdSql.execute('drop database if exists db') + tdSql.execute('drop database if exists des') + tdSql.execute('create database test') + tdSql.execute('create database des') + header = {'Authorization': 'Basic cm9vdDp0YW9zZGF0YQ=='} + url = "http://127.0.0.1:6041/rest/sql/" + + # test with no bind databases + + sqls = ["show databases;", + "use test", + "show tables;", + "show dnodes;", + "show vgroups;", + "create database db;", + "drop database db;", + "select client_version();" , + "use test", + "ALTER DATABASE test COMP 2;", + "create table tb (ts timestamp, id int , data double)", + "insert into tb values (now , 1, 1.0) ", + "select * from tb", + "show test.tables", + "show tables", + "insert into tb values (now , 2, 2.0) ", + "create table test.tb (ts timestamp, id int , data double)", + "insert into test.tb values (now , 3, 3.0) ", + "select * from tb", + "select * from test.tb", + "create table des.tb (ts timestamp, id int , data double)", + "insert into des.tb values (now , 3, 3.0)"] + for sql in sqls: + print("===================") + if sql == "create table test.tb (ts timestamp, id int , data double)": + resp = requests.post(url, sql, headers = header ) + print(resp.text) + print ("%s run occur error as expect ,check pass!" %(sql)) + else: + check_res(url,sql,header) + + tdSql.query("select * from test.tb") + tdSql.checkRows(3) + tdSql.query("select * from des.tb") + tdSql.checkRows(1) + + print("==================="*5) + print(" check bind db about restful ") + print("==================="*5) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists test') + tdSql.execute('drop database if exists db') + tdSql.execute('drop database if exists des') + tdSql.execute('create database test') + tdSql.execute('create database des') + + url = "http://127.0.0.1:6041/rest/sql/des" + for sql in sqls: + print("===================") + if sql in ["create table des.tb (ts timestamp, id int , data double)"]: + resp = requests.post(url, sql, headers = header ) + print(resp.text) + print ("%s run occur error as expect ,check pass!" %(sql)) + else: + check_res(url,sql,header) + # check data + tdSql.query("select * from test.tb") + tdSql.checkRows(1) + tdSql.query("select * from des.tb") + tdSql.checkRows(3) + + os.system('sudo timedatectl set-ntp on') + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/simpletest_no_sudo.sh b/tests/pytest/simpletest_no_sudo.sh new file mode 100755 index 0000000000000000000000000000000000000000..36edfc027fc12487a9e1d8fd66da623d219e8365 --- /dev/null +++ b/tests/pytest/simpletest_no_sudo.sh @@ -0,0 +1,13 @@ +# This is the script for us to run our Python test cases with 2 important constraints: +# +# 1. No root/sudo special rights is needed. +# 2. No files are needed outside the development tree, everything is done in the local source code directory + +# First we need to set up a path for Python to find our own TAOS modules, so that "import" can work. +export PYTHONPATH=$(pwd)/../../src/connector/python + +# Then let us set up the library path so that our compiled SO file can be loaded by Python +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/../../build/build/lib + +# Now we are all let, and let's run our cases! +python3 ./test.py -m 127.0.0.1 -f insert/basic.py diff --git a/tests/pytest/smoketest.sh b/tests/pytest/smoketest.sh new file mode 100755 index 0000000000000000000000000000000000000000..cbe80882fbb6dfb6cfa9695f66d0b22d09068ae5 --- /dev/null +++ b/tests/pytest/smoketest.sh @@ -0,0 +1,39 @@ +#!/bin/bash +ulimit -c unlimited + +# insert +python3 ./test.py $1 -f insert/basic.py +python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f insert/bigint.py +python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f insert/nchar.py +python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f insert/multi.py +python3 ./test.py $1 -s && sleep 1 + +# table +python3 ./test.py $1 -f table/column_name.py +python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f table/column_num.py +python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f table/db_table.py +python3 ./test.py $1 -s && sleep 1 + +# import +python3 ./test.py $1 -f import_merge/importDataLastSub.py +python3 ./test.py $1 -s && sleep 1 + +#tag +python3 ./test.py $1 -f tag_lite/filter.py +python3 ./test.py $1 -s && sleep 1 + +#query +python3 ./test.py $1 -f query/filter.py +python3 ./test.py $1 -s && sleep 1 + +# client +python3 ./test.py $1 -f client/client.py +python3 ./test.py $1 -s && sleep 1 + +# connector +python3 ./test.py $1 -f connector/lua.py diff --git a/tests/pytest/stable/__init__.py b/tests/pytest/stable/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/pytest/stable/insert.py b/tests/pytest/stable/insert.py new file mode 100644 index 0000000000000000000000000000000000000000..ef5635c77ce04ddd33354e1754dc70b2c9f8b6a5 --- /dev/null +++ b/tests/pytest/stable/insert.py @@ -0,0 +1,100 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + print("==============step1") + tdSql.execute( + "create table if not exists st (ts timestamp, tagtype int) tags(dev nchar(50))") + tdSql.execute( + 'CREATE TABLE if not exists dev_001 using st tags("dev_01")') + tdSql.execute( + 'CREATE TABLE if not exists dev_002 using st tags("dev_02")') + + print("==============step2") + + tdSql.execute( + """INSERT INTO dev_001(ts, tagtype) VALUES('2020-05-13 10:00:00.000', 1), + ('2020-05-13 10:00:00.001', 1) + dev_002 VALUES('2020-05-13 10:00:00.001', 1)""") + + tdSql.query("select * from db.st where dev='dev_01'") + tdSql.checkRows(2) + + tdSql.query("select * from db.st where dev='dev_02'") + tdSql.checkRows(1) + + #For: https://jira.taosdata.com:18080/browse/TD-2671 + print("==============step3") + tdSql.execute( + "create stable if not exists stb (ts timestamp, tagtype int) tags(dev nchar(50))") + tdSql.execute( + 'CREATE TABLE if not exists dev_01 using stb tags("dev_01")') + tdSql.execute( + 'CREATE TABLE if not exists dev_02 using stb tags("dev_02")') + + print("==============step4") + + tdSql.execute( + """INSERT INTO dev_01(ts, tagtype) VALUES('2020-05-13 10:00:00.000', 1), + ('2020-05-13 10:00:00.001', 1) + dev_02 VALUES('2020-05-13 10:00:00.001', 1)""") + + tdSql.query("select * from db.stb where dev='dev_01'") + tdSql.checkRows(2) + + tdSql.query("select * from db.stb where dev='dev_02'") + tdSql.checkRows(1) + + tdSql.query("describe db.stb") + tdSql.checkRows(3) + + tdSql.error("drop stable if exists db.dev_01") + tdSql.error("drop stable if exists db.dev_02") + + tdSql.execute("alter stable db.stb add tag t1 int") + tdSql.query("describe db.stb") + tdSql.checkRows(4) + + tdSql.execute("drop stable db.stb") + tdSql.query("show stables") + tdSql.checkRows(1) + + tdSql.error("drop stable if exists db.dev_001") + tdSql.error("drop stable if exists db.dev_002") + + for i in range(10): + tdSql.execute("drop stable if exists db.stb") + tdSql.query("show stables") + tdSql.checkRows(1) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/stable/query_after_reset-multi-threading.py b/tests/pytest/stable/query_after_reset-multi-threading.py new file mode 100644 index 0000000000000000000000000000000000000000..a177f589d166117c0d8de61a01a34040a1b1103b --- /dev/null +++ b/tests/pytest/stable/query_after_reset-multi-threading.py @@ -0,0 +1,259 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import random +import threading +import queue + +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + +current_tb = "" +last_tb = "" +written = 0 + + +class Test (threading.Thread): + def __init__(self, threadId, name, sleepTime, q): + threading.Thread.__init__(self) + self.threadId = threadId + self.name = name + self.sleepTime = sleepTime + self.q = q + + self.threadLock = threading.Lock() + + def create_table(self): + global current_tb + global last_tb + global written + + tdLog.info("create a table") + current_tb = "tb%d" % int(round(time.time() * 1000)) + tdLog.info("current table %s" % current_tb) + + if (current_tb == last_tb): + return + else: + tdSql.execute( + 'create table %s (ts timestamp, speed int)' % + current_tb) + last_tb = current_tb + written = 0 + + def insert_data(self): + global current_tb + global last_tb + global written + + tdLog.info("will insert data to table") + if (current_tb == ""): + tdLog.info("no table, create first") + self.create_table() + + tdLog.info("insert data to table") + for i in range(0, 10): + self.threadLock.acquire() + insertRows = 1000 + tdLog.info("insert %d rows to %s" % (insertRows, current_tb)) + + for j in range(0, insertRows): + ret = tdSql.execute( + 'insert into %s values (now + %dm, %d)' % + (current_tb, j, j)) + written = written + 1 + self.threadLock.release() + + def query_data(self): + global current_tb + global last_tb + global written + + if (written > 0): + tdLog.info("query data from table") + tdSql.query("select * from %s" % last_tb) + tdSql.checkRows(written) + + def query_stable(self): + tdLog.sleep(10) + self.threadLock.acquire() + tdLog.info("query super table") + + try: + tdSql.query("select * from st") + except Exception as e: + tdLog.info(repr(e)) + self.q.put(-1) + tdLog.exit("failed") + tdSql.checkRows(1) + self.threadLock.release() + + def create_stable(self): + global current_tb + global last_tb + global written + + self.threadLock.acquire() + + tdLog.info("create a super table and sub-table and insert data") + + try: + tdSql.execute( + "create table if not exists st (ts timestamp, tagtype int) tags(dev nchar(50))") + tdSql.execute( + 'CREATE TABLE if not exists dev_001 using st tags("dev_01")') + tdSql.execute( + "INSERT INTO dev_001(ts, tagtype) VALUES('2020-05-13 10:00:00.000', 1)") + except Exception as e: + tdLog.info(repr(e)) + self.q.put(-1) + tdLog.exit("failed") + self.stop_database() + self.delete_datafiles() + self.restart_database() + self.threadLock.release() + + def stop_database(self): + tdLog.info("stop databae") + tdDnodes.stop(1) + + def restart_database(self): + global current_tb + global last_tb + global written + + tdLog.info("restart databae") + tdDnodes.stop(1) + tdDnodes.start(1) + tdLog.sleep(5) + + def force_restart(self): + global current_tb + global last_tb + global written + + tdLog.info("force restart database") + tdDnodes.forcestop(1) + tdDnodes.start(1) + tdLog.sleep(5) + + def drop_table(self): + global current_tb + global last_tb + global written + + for i in range(0, 10): + self.threadLock.acquire() + + tdLog.info("current_tb %s" % current_tb) + + if (current_tb != ""): + tdLog.info("drop current tb %s" % current_tb) + tdSql.execute("drop table %s" % current_tb) + current_tb = "" + last_tb = "" + written = 0 + tdLog.sleep(self.sleepTime) + self.threadLock.release() + + def reset_query_cache(self): + global current_tb + global last_tb + global written + + tdLog.info("reset query cache") + tdSql.execute("reset query cache") + tdLog.sleep(1) + + def reset_database(self): + global current_tb + global last_tb + global written + + tdLog.info("reset database") + tdDnodes.forcestop(1) + tdDnodes.deploy(1) + current_tb = "" + last_tb = "" + written = 0 + tdDnodes.start(1) + tdSql.prepare() + + def delete_datafiles(self): + global current_tb + global last_tb + global written + + tdLog.info("delete data files") + dnodesDir = tdDnodes.getDnodesRootDir() + dataDir = dnodesDir + '/dnode1/*' + deleteCmd = 'rm -rf %s' % dataDir + os.system(deleteCmd) + + current_tb = "" + last_tb = "" + written = 0 + tdDnodes.start(1) + tdSql.prepare() + + def run(self): + switch = { + 1: self.create_table, + 2: self.insert_data, + 3: self.query_data, + 4: self.create_stable, + 5: self.restart_database, + 6: self.force_restart, + 7: self.drop_table, + 8: self.reset_query_cache, + 9: self.reset_database, + 10: self.delete_datafiles, + 11: self.query_stable, + } + + switch.get(self.threadId, lambda: "ERROR")() + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + q = queue.Queue() + test1 = Test(4, "create_stable", 1, q) + test2 = Test(11, "query_stable", 2, q) + + test1.start() + test2.start() + test1.join() + test2.join() + + while not q.empty(): + if (q.get() == -1): + tdLog.exit("failed to end of test") + + tdLog.info("end of test") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/stable/query_after_reset.py b/tests/pytest/stable/query_after_reset.py new file mode 100644 index 0000000000000000000000000000000000000000..b66fc2eff1e9269411168ecd38cf459eae16e6d5 --- /dev/null +++ b/tests/pytest/stable/query_after_reset.py @@ -0,0 +1,186 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import random +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class Test: + def __init__(self): + self.current_tb = "" + self.last_tb = "" + self.written = 0 + + def create_table(self): + tdLog.info("create a table") + self.current_tb = "tb%d" % int(round(time.time() * 1000)) + tdLog.info("current table %s" % self.current_tb) + + if (self.current_tb == self.last_tb): + return + else: + tdSql.execute( + 'create table %s (ts timestamp, speed int)' % + self.current_tb) + self.last_tb = self.current_tb + self.written = 0 + + def insert_data(self): + tdLog.info("will insert data to table") + if (self.current_tb == ""): + tdLog.info("no table, create first") + self.create_table() + + tdLog.info("insert data to table") + insertRows = 10 + tdLog.info("insert %d rows to %s" % (insertRows, self.last_tb)) + for i in range(0, insertRows): + ret = tdSql.execute( + 'insert into %s values (now + %dm, %d)' % + (self.last_tb, i, i)) + self.written = self.written + 1 + + tdLog.info("insert earlier data") + tdSql.execute('insert into %s values (now - 5m , 10)' % self.last_tb) + self.written = self.written + 1 + tdSql.execute('insert into %s values (now - 6m , 10)' % self.last_tb) + self.written = self.written + 1 + tdSql.execute('insert into %s values (now - 7m , 10)' % self.last_tb) + self.written = self.written + 1 + tdSql.execute('insert into %s values (now - 8m , 10)' % self.last_tb) + self.written = self.written + 1 + + def query_data(self): + if (self.written > 0): + tdLog.info("query data from table") + tdSql.query("select * from %s" % self.last_tb) + tdSql.checkRows(self.written) + + def query_stable(self): + tdLog.info("query super table") + try: + tdSql.query("select * from st") + except Exception as e: + tdLog.info("Exception catched: %s" % repr(e)) + if ('Table does not exist' not in repr(e)): + raise Exception(repr(e)) + + def create_stable(self): + tdLog.info("create a super table and sub-table and insert data") + tdSql.execute( + "create table if not exists st (ts timestamp, tagtype int) tags(dev nchar(50))") + tdSql.execute( + 'CREATE TABLE if not exists dev_001 using st tags("dev_01")') + tdSql.execute( + "INSERT INTO dev_001(ts, tagtype) VALUES('2020-05-13 10:00:00.000', 1)") + + def stop_database(self): + tdLog.info("stop databae") + tdDnodes.stop(1) + + def restart_database(self): + tdLog.info("restart databae") + tdDnodes.stop(1) + tdDnodes.start(1) + tdLog.sleep(5) + + def force_restart(self): + tdLog.info("force restart database") + tdDnodes.forcestop(1) + tdDnodes.start(1) + tdLog.sleep(5) + + def drop_table(self): + if (self.current_tb != ""): + tdLog.info("drop current tb %s" % self.current_tb) + tdSql.execute("drop table %s" % self.current_tb) + self.current_tb = "" + self.last_tb = "" + self.written = 0 + + def reset_query_cache(self): + tdLog.info("reset query cache") + tdSql.execute("reset query cache") + tdLog.sleep(1) + + def reset_database(self): + tdLog.info("reset database") + tdDnodes.forcestop(1) + tdDnodes.deploy(1) + self.current_tb = "" + self.last_tb = "" + self.written = 0 + tdDnodes.start(1) + tdSql.prepare() + + def delete_datafiles(self): + tdLog.info("delete data files") + dnodesDir = tdDnodes.getDnodesRootDir() + dataDir = dnodesDir + '/dnode1/data/*' + deleteCmd = 'rm -rf %s' % dataDir + os.system(deleteCmd) + + self.current_tb = "" + self.last_tb = "" + self.written = 0 + tdDnodes.start(1) + tdSql.prepare() + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + test = Test() + + switch = { + 1: test.create_table, + 2: test.insert_data, + 3: test.query_data, + 4: test.create_stable, + 5: test.restart_database, + 6: test.force_restart, + 7: test.drop_table, + 8: test.reset_query_cache, + 9: test.reset_database, + 10: test.delete_datafiles, + 11: test.query_stable, + 12: test.stop_database, + } + + tdLog.info("create stable") + switch.get(4, lambda: "ERROR")() + tdLog.info("stop database") + switch.get(12, lambda: "ERROR")() + tdLog.info("delete datafiles") + switch.get(10, lambda: "ERROR")() + tdLog.info("restart database") + switch.get(5, lambda: "ERROR")() + tdLog.info("query stable") + switch.get(11, lambda: "ERROR")() + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/stream/cqSupportBefore1970.py b/tests/pytest/stream/cqSupportBefore1970.py new file mode 100644 index 0000000000000000000000000000000000000000..01ba5234fcabb96a4c3c7c28e405c316d6e7dc7d --- /dev/null +++ b/tests/pytest/stream/cqSupportBefore1970.py @@ -0,0 +1,93 @@ +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug(f"start to execute {__file__}") + tdSql.init(conn.cursor(), logSql) + + def insertnow(self): + + # timestamp list: + # 0 -> "1970-01-01 08:00:00" | -28800000 -> "1970-01-01 00:00:00" | -946800000000 -> "1940-01-01 00:00:00" + # -631180800000 -> "1950-01-01 00:00:00" + + tsp1 = 0 + tsp2 = -28800000 + tsp3 = -946800000000 + tsp4 = "1969-01-01 00:00:00.000" + + tdSql.execute("insert into tcq1 values (now-11d, 5)") + tdSql.execute(f"insert into tcq1 values ({tsp1}, 4)") + tdSql.execute(f"insert into tcq1 values ({tsp2}, 3)") + tdSql.execute(f"insert into tcq1 values ('{tsp4}', 2)") + tdSql.execute(f"insert into tcq1 values ({tsp3}, 1)") + + def waitedQuery(self, sql, expectRows, timeout): + tdLog.info(f"sql: {sql}, try to retrieve {expectRows} rows in {timeout} seconds") + try: + for i in range(timeout): + tdSql.cursor.execute(sql) + self.queryResult = tdSql.cursor.fetchall() + self.queryRows = len(self.queryResult) + self.queryCols = len(tdSql.cursor.description) + # tdLog.info("sql: %s, try to retrieve %d rows,get %d rows" % (sql, expectRows, self.queryRows)) + if self.queryRows >= expectRows: + return (self.queryRows, i) + time.sleep(1) + except Exception as e: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + tdLog.notice(f"{caller.filename}({caller.lineno}) failed: sql:{sql}, {repr(e)}") + raise Exception(repr(e)) + return (self.queryRows, timeout) + + def cq(self): + tdSql.execute( + "create table cq1 as select avg(c1) from tcq1 where ts > -946800000000 interval(10d) sliding(1d)" + ) + self.waitedQuery("select * from cq1", 1, 120) + + def querycq(self): + tdSql.query("select * from cq1") + tdSql.checkData(0, 1, 1.0) + tdSql.checkData(10, 1, 2.0) + + def run(self): + tdSql.execute("drop database if exists dbcq") + tdSql.execute("create database if not exists dbcq keep 36500") + tdSql.execute("use dbcq") + + tdSql.execute("create table stbcq (ts timestamp, c1 int ) TAGS(t1 int)") + tdSql.execute("create table tcq1 using stbcq tags(1)") + + self.insertnow() + self.cq() + self.querycq() + + # after wal and sync, check again + tdSql.query("show dnodes") + index = tdSql.getData(0, 0) + tdDnodes.stop(index) + tdDnodes.start(index) + + self.querycq() + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/stream/history.py b/tests/pytest/stream/history.py new file mode 100644 index 0000000000000000000000000000000000000000..cb8a4d598651473f907aa05a0609c9ce68c78f82 --- /dev/null +++ b/tests/pytest/stream/history.py @@ -0,0 +1,67 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import time +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdSql.execute("create table cars(ts timestamp, s int) tags(id int)") + tdSql.execute("create table car0 using cars tags(0)") + tdSql.execute("create table car1 using cars tags(1)") + tdSql.execute("create table car2 using cars tags(2)") + tdSql.execute("create table car3 using cars tags(3)") + tdSql.execute("create table car4 using cars tags(4)") + + tdSql.execute("insert into car0 values('2019-01-01 00:00:00.103', 1)") + tdSql.execute("insert into car1 values('2019-01-01 00:00:00.234', 1)") + tdSql.execute("insert into car0 values('2019-01-01 00:00:01.012', 1)") + tdSql.execute("insert into car0 values('2019-01-01 00:00:02.003', 1)") + tdSql.execute("insert into car2 values('2019-01-01 00:00:02.328', 1)") + tdSql.execute("insert into car0 values('2019-01-01 00:00:03.139', 1)") + tdSql.execute("insert into car0 values('2019-01-01 00:00:04.348', 1)") + tdSql.execute("insert into car0 values('2019-01-01 00:00:05.783', 1)") + tdSql.execute("insert into car1 values('2019-01-01 00:00:01.893', 1)") + tdSql.execute("insert into car1 values('2019-01-01 00:00:02.712', 1)") + tdSql.execute("insert into car1 values('2019-01-01 00:00:03.982', 1)") + tdSql.execute("insert into car3 values('2019-01-01 00:00:01.389', 1)") + tdSql.execute("insert into car4 values('2019-01-01 00:00:01.829', 1)") + + tdSql.error("create table strm as select count(*) from cars") + + tdSql.execute("create table strm as select count(*) from cars interval(4s)") + tdSql.waitedQuery("select * from strm", 2, 100) + tdSql.checkData(0, 1, 11) + tdSql.checkData(1, 1, 2) + + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/stream/metric_1.py b/tests/pytest/stream/metric_1.py new file mode 100644 index 0000000000000000000000000000000000000000..7eeb3d8fd6b6b910b795a5fba370753e619423de --- /dev/null +++ b/tests/pytest/stream/metric_1.py @@ -0,0 +1,105 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import time +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def createFuncStream(self, expr, suffix, value): + tbname = "strm_" + suffix + tdLog.info("create stream table %s" % tbname) + tdSql.query("select %s from stb interval(1d)" % expr) + tdSql.checkData(0, 1, value) + tdSql.execute("create table %s as select %s from stb interval(1d)" % (tbname, expr)) + + def checkStreamData(self, suffix, value): + sql = "select * from strm_" + suffix + tdSql.waitedQuery(sql, 1, 120) + tdSql.checkData(0, 1, value) + + def run(self): + tbNum = 10 + rowNum = 20 + ts_begin = 1633017600000 + + tdSql.prepare() + + tdLog.info("===== preparing data =====") + tdSql.execute( + "create table stb(ts timestamp, tbcol int, tbcol2 float) tags(tgcol int)") + for i in range(tbNum): + tdSql.execute("create table tb%d using stb tags(%d)" % (i, i)) + for j in range(rowNum): + tdSql.execute( + "insert into tb%d values (%d, %d, %d)" % + (i, ts_begin + j, j, j)) + time.sleep(0.1) + + self.createFuncStream("count(*)", "c1", 200) + self.createFuncStream("count(tbcol)", "c2", 200) + self.createFuncStream("count(tbcol2)", "c3", 200) + self.createFuncStream("avg(tbcol)", "av", 9.5) + self.createFuncStream("sum(tbcol)", "su", 1900) + self.createFuncStream("min(tbcol)", "mi", 0) + self.createFuncStream("max(tbcol)", "ma", 19) + self.createFuncStream("first(tbcol)", "fi", 0) + self.createFuncStream("last(tbcol)", "la", 19) + #tdSql.query("select stddev(tbcol) from stb interval(1d)") + #tdSql.query("select leastsquares(tbcol, 1, 1) from stb interval(1d)") + tdSql.query("select top(tbcol, 1) from stb interval(1d)") + tdSql.query("select bottom(tbcol, 1) from stb interval(1d)") + #tdSql.query("select percentile(tbcol, 1) from stb interval(1d)") + #tdSql.query("select diff(tbcol) from stb interval(1d)") + + tdSql.query("select count(tbcol) from stb where ts < now + 4m interval(1d)") + tdSql.checkData(0, 1, 200) + #tdSql.execute("create table strm_wh as select count(tbcol) from stb where ts < now + 4m interval(1d)") + + self.createFuncStream("count(tbcol)", "as", 200) + + tdSql.query("select count(tbcol) from stb interval(1d) group by tgcol") + tdSql.checkData(0, 1, 20) + + tdSql.query("select count(tbcol) from stb where ts < now + 4m interval(1d) group by tgcol") + tdSql.checkData(0, 1, 20) + + self.checkStreamData("c1", 200) + self.checkStreamData("c2", 200) + self.checkStreamData("c3", 200) + self.checkStreamData("av", 9.5) + self.checkStreamData("su", 1900) + self.checkStreamData("mi", 0) + self.checkStreamData("ma", 19) + self.checkStreamData("fi", 0) + self.checkStreamData("la", 19) + #self.checkStreamData("wh", 200) + self.checkStreamData("as", 200) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) + + diff --git a/tests/pytest/stream/metric_n.py b/tests/pytest/stream/metric_n.py new file mode 100644 index 0000000000000000000000000000000000000000..d223fe81fc79835047bac8ca2341cdbeac2e6617 --- /dev/null +++ b/tests/pytest/stream/metric_n.py @@ -0,0 +1,123 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import time +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tbNum = 10 + rowNum = 20 + totalNum = tbNum * rowNum + + tdSql.prepare() + + tdLog.info("===== preparing data =====") + tdSql.execute( + "create table stb(ts timestamp, tbcol int, tbcol2 float) tags(tgcol int)") + for i in range(tbNum): + tdSql.execute("create table tb%d using stb tags(%d)" % (i, i)) + for j in range(rowNum): + tdSql.execute( + "insert into tb%d values (now - %dm, %d, %d)" % + (i, 1440 - j, j, j)) + time.sleep(0.1) + + tdLog.info("===== step 1 =====") + tdSql.query("select count(*), count(tbcol), count(tbcol2) from stb interval(1d)") + tdSql.checkData(0, 1, totalNum) + tdSql.checkData(0, 2, totalNum) + tdSql.checkData(0, 3, totalNum) + + tdLog.info("===== step 2 =====") + tdSql.execute("create table strm_c3 as select count(*), count(tbcol), count(tbcol2) from stb interval(1d)") + + tdLog.info("===== step 3 =====") + tdSql.execute("create table strm_c32 as select count(*), count(tbcol) as c1, count(tbcol2) as c2, count(tbcol) as c3, count(tbcol) as c4, count(tbcol) as c5, count(tbcol) as c6, count(tbcol) as c7, count(tbcol) as c8, count(tbcol) as c9, count(tbcol) as c10, count(tbcol) as c11, count(tbcol) as c12, count(tbcol) as c13, count(tbcol) as c14, count(tbcol) as c15, count(tbcol) as c16, count(tbcol) as c17, count(tbcol) as c18, count(tbcol) as c19, count(tbcol) as c20, count(tbcol) as c21, count(tbcol) as c22, count(tbcol) as c23, count(tbcol) as c24, count(tbcol) as c25, count(tbcol) as c26, count(tbcol) as c27, count(tbcol) as c28, count(tbcol) as c29, count(tbcol) as c30 from stb interval(1d)") + + tdLog.info("===== step 4 =====") + tdSql.query("select count(*), count(tbcol) as c1, count(tbcol2) as c2, count(tbcol) as c3, count(tbcol) as c4, count(tbcol) as c5, count(tbcol) as c6, count(tbcol) as c7, count(tbcol) as c8, count(tbcol) as c9, count(tbcol) as c10, count(tbcol) as c11, count(tbcol) as c12, count(tbcol) as c13, count(tbcol) as c14, count(tbcol) as c15, count(tbcol) as c16, count(tbcol) as c17, count(tbcol) as c18, count(tbcol) as c19, count(tbcol) as c20, count(tbcol) as c21, count(tbcol) as c22, count(tbcol) as c23, count(tbcol) as c24, count(tbcol) as c25, count(tbcol) as c26, count(tbcol) as c27, count(tbcol) as c28, count(tbcol) as c29, count(tbcol) as c30 from stb interval(1d)") + tdSql.checkData(0, 1, totalNum) + tdSql.checkData(0, 2, totalNum) + tdSql.checkData(0, 3, totalNum) + + tdLog.info("===== step 5 =====") + tdSql.execute("create table strm_c31 as select count(*), count(tbcol) as c1, count(tbcol2) as c2, count(tbcol) as c3, count(tbcol) as c4, count(tbcol) as c5, count(tbcol) as c6, count(tbcol) as c7, count(tbcol) as c8, count(tbcol) as c9, count(tbcol) as c10, count(tbcol) as c11, count(tbcol) as c12, count(tbcol) as c13, count(tbcol) as c14, count(tbcol) as c15, count(tbcol) as c16, count(tbcol) as c17, count(tbcol) as c18, count(tbcol) as c19, count(tbcol) as c20, count(tbcol) as c21, count(tbcol) as c22, count(tbcol) as c23, count(tbcol) as c24, count(tbcol) as c25, count(tbcol) as c26, count(tbcol) as c27, count(tbcol) as c28, count(tbcol) as c29, count(tbcol) as c30 from stb interval(1d)") + + tdLog.info("===== step 6 =====") + tdSql.query("select avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from stb interval(1d)") + tdSql.checkData(0, 1, 9.5) + tdSql.checkData(0, 2, 1900) + tdSql.checkData(0, 3, 0) + tdSql.checkData(0, 4, 19) + tdSql.checkData(0, 5, 0) + tdSql.checkData(0, 6, 19) + tdSql.execute("create table strm_avg as select avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from stb interval(1d)") + + tdLog.info("===== step 7 =====") + tdSql.query("select avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol), count(tbcol) from stb where ts < now + 4m interval(1d)") + tdSql.checkData(0, 1, 9.5) + tdSql.checkData(0, 2, 1900) + tdSql.checkData(0, 3, 0) + tdSql.checkData(0, 4, 19) + tdSql.checkData(0, 5, 0) + tdSql.checkData(0, 6, 19) + tdSql.checkData(0, 7, totalNum) + + tdLog.info("===== step 8 =====") + tdSql.query("select avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol), count(tbcol) from stb where ts < now + 4m interval(1d)") + tdSql.checkData(0, 1, 9.5) + tdSql.checkData(0, 2, 1900) + tdSql.checkData(0, 3, 0) + tdSql.checkData(0, 4, 19) + tdSql.checkData(0, 5, 0) + tdSql.checkData(0, 6, 19) + tdSql.checkData(0, 7, totalNum) + + tdLog.info("===== step 9 =====") + tdSql.waitedQuery("select * from strm_c3", 1, 120) + tdSql.checkData(0, 1, totalNum) + tdSql.checkData(0, 2, totalNum) + tdSql.checkData(0, 3, totalNum) + + tdLog.info("===== step 10 =====") + tdSql.waitedQuery("select * from strm_c31", 1, 30) + for i in range(1, 10): + tdSql.checkData(0, i, totalNum) + + tdLog.info("===== step 11 =====") + tdSql.waitedQuery("select * from strm_avg", 1, 20) + tdSql.checkData(0, 1, 9.5) + tdSql.checkData(0, 2, 1900) + tdSql.checkData(0, 3, 0) + tdSql.checkData(0, 4, 19) + tdSql.checkData(0, 5, 0) + tdSql.checkData(0, 6, 19) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/stream/new.py b/tests/pytest/stream/new.py new file mode 100644 index 0000000000000000000000000000000000000000..6b1b797d1a2bdae9c2a56d6ed1f8293e1a74c1d1 --- /dev/null +++ b/tests/pytest/stream/new.py @@ -0,0 +1,81 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import time +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + rowNum = 200 + tdSql.prepare() + ts_now = 1633017600000 + tdLog.info("=============== step1") + tdSql.execute("create table mt(ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int)") + for i in range(5): + tdSql.execute("create table tb%d using mt tags(%d)" % (i, i)) + for j in range(rowNum): + tdSql.execute("insert into tb%d values(%d, %d, %d)" % (i, ts_now, j, j)) + ts_now += 1000 + time.sleep(0.1) + + tdLog.info("=============== step2") + tdSql.query("select count(*), count(tbcol), count(tbcol2) from mt interval(10s)") + tdSql.execute("create table st as select count(*), count(tbcol), count(tbcol2) from mt interval(10s)") + + tdLog.info("=============== step3") + start = time.time() + tdSql.waitedQuery("select * from st", 1, 180) + delay = int(time.time() - start) + 80 + v = tdSql.getData(0, 3) + if v != 10: + tdLog.exit("value is %d, expect is 10." % v) + + tdLog.info("=============== step4") + for i in range(5, 10): + tdSql.execute("create table tb%d using mt tags(%d)" % (i, i)) + for j in range(rowNum): + tdSql.execute("insert into tb%d values(%d, %d, %d)" % (i, ts_now, j, j)) + ts_now += 1000 + + tdLog.info("=============== step5") + maxValue = 0 + for i in range(delay): + time.sleep(1) + tdSql.query("select * from st order by ts desc") + v = tdSql.getData(0, 3) + if v > maxValue: + maxValue = v + if v >= 10: + break + + if maxValue < 10: + tdLog.exit("value is %d, expect is 10" % maxValue) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) + + diff --git a/tests/pytest/stream/parser.py b/tests/pytest/stream/parser.py new file mode 100644 index 0000000000000000000000000000000000000000..3b231d2b391a8a5a92cb8924134555117c5bfed2 --- /dev/null +++ b/tests/pytest/stream/parser.py @@ -0,0 +1,182 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import time +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + ''' + def bug2222(self): + tdSql.prepare() + tdSql.execute("create table superreal(ts timestamp, addr binary(5), val float) tags (deviceNo binary(20))") + tdSql.execute("create table real_001 using superreal tags('001')") + tdSql.execute("create table tj_001 as select sum(val) from real_001 interval(1m)") + + t = datetime.datetime.now() + for i in range(60): + ts = t.strftime("%Y-%m-%d %H:%M") + t += datetime.timedelta(minutes=1) + sql = "insert into real_001 values('%s:0%d', '1', %d)" % (ts, 0, i) + for j in range(4): + sql += ",('%s:0%d', '%d', %d)" % (ts, j + 1, j + 1, i) + tdSql.execute(sql) + time.sleep(60 + random.random() * 60 - 30) + ''' + + def tbase300(self): + tdLog.debug("begin tbase300") + + tdSql.prepare() + tdSql.execute("create table mt(ts timestamp, c1 int, c2 int) tags(t1 int)") + tdSql.execute("create table tb1 using mt tags(1)"); + tdSql.execute("create table tb2 using mt tags(2)"); + tdSql.execute("create table strm as select count(*), avg(c1), sum(c2), max(c1), min(c2),first(c1), last(c2) from mt interval(4s) sliding(2s)") + #tdSql.execute("create table strm as select count(*), avg(c1), sum(c2), max(c1), min(c2), first(c1) from mt interval(4s) sliding(2s)") + tdLog.sleep(10) + tdSql.execute("insert into tb2 values(now, 1, 1)"); + tdSql.execute("insert into tb1 values(now, 1, 1)"); + tdLog.sleep(4) + tdSql.query("select * from mt") + tdSql.query("select * from strm") + tdSql.execute("drop table tb1") + + tdSql.waitedQuery("select * from strm", 1, 100) + if tdSql.queryRows < 1 or tdSql.queryRows > 2: + tdLog.exit("rows should be 1 or 2") + + tdSql.execute("drop table tb2") + tdSql.execute("drop table mt") + tdSql.execute("drop table strm") + + def tbase304(self): + tdLog.debug("begin tbase304") + # we cannot reset query cache in server side, as a workaround, + # set super table name to mt304, need to change back to mt later + tdSql.execute("create table mt304 (ts timestamp, c1 int) tags(t1 int, t2 int)") + tdSql.execute("create table tb1 using mt304 tags(1, 1)") + tdSql.execute("create table tb2 using mt304 tags(1, -1)") + time.sleep(0.1) + tdSql.execute("create table strm as select count(*), avg(c1) from mt304 where t2 >= 0 interval(4s) sliding(2s)") + tdSql.execute("insert into tb1 values (now,1)") + tdSql.execute("insert into tb2 values (now,2)") + + tdSql.waitedQuery("select * from strm", 1, 100) + if tdSql.queryRows < 1 or tdSql.queryRows > 2: + tdLog.exit("rows should be 1 or 2") + + tdSql.checkData(0, 1, 1) + tdSql.checkData(0, 2, 1.000000000) + tdSql.execute("alter table mt304 drop tag t2") + tdSql.execute("insert into tb2 values (now,2)") + tdSql.execute("insert into tb1 values (now,1)") + tdSql.query("select * from strm") + tdSql.execute("alter table mt304 add tag t2 int") + tdLog.sleep(1) + tdSql.query("select * from strm") + + def wildcardFilterOnTags(self): + tdLog.debug("begin wildcardFilterOnTag") + tdSql.prepare() + tdSql.execute("create table stb (ts timestamp, c1 int, c2 binary(10)) tags(t1 binary(10))") + tdSql.execute("create table tb1 using stb tags('a1')") + tdSql.execute("create table tb2 using stb tags('b2')") + tdSql.execute("create table tb3 using stb tags('a3')") + tdSql.execute("create table strm as select count(*), avg(c1), first(c2) from stb where t1 like 'a%' interval(4s) sliding(2s)") + tdSql.query("describe strm") + tdSql.checkRows(4) + + tdLog.sleep(1) + tdSql.execute("insert into tb1 values (now, 0, 'tb1')") + tdLog.sleep(4) + tdSql.execute("insert into tb2 values (now, 2, 'tb2')") + tdLog.sleep(4) + tdSql.execute("insert into tb3 values (now, 0, 'tb3')") + + tdSql.waitedQuery("select * from strm", 4, 60) + tdSql.checkRows(4) + tdSql.checkData(0, 2, 0.000000000) + if tdSql.getData(0, 3) == 'tb2': + tdLog.exit("unexpected value of data03") + if tdSql.getData(1, 3) == 'tb2': + tdLog.exit("unexpected value of data13") + if tdSql.getData(2, 3) == 'tb2': + tdLog.exit("unexpected value of data23") + if tdSql.getData(3, 3) == 'tb2': + tdLog.exit("unexpected value of data33") + + tdLog.info("add table tb4 to see if stream still works correctly") + # The vnode client needs to refresh metadata cache to allow strm calculate tb4's data. + # But the current refreshing frequency is every 10 min + # commented out the case below to save running time + tdSql.execute("create table tb4 using stb tags('a4')") + tdSql.execute("insert into tb4 values(now, 4, 'tb4')") + tdSql.waitedQuery("select * from strm order by ts desc", 6, 60) + tdSql.checkRows(6) + tdSql.checkData(0, 2, 4) + tdSql.checkData(0, 3, "tb4") + + tdLog.info("change tag values to see if stream still works correctly") + tdSql.execute("alter table tb4 set tag t1='b4'") + tdLog.sleep(3) + tdSql.execute("insert into tb1 values (now, 1, 'tb1_a1')") + tdLog.sleep(4) + tdSql.execute("insert into tb4 values (now, -4, 'tb4_b4')") + tdSql.waitedQuery("select * from strm order by ts desc", 8, 100) + tdSql.checkRows(8) + tdSql.checkData(0, 2, 1) + tdSql.checkData(0, 3, "tb1_a1") + + def datatypes(self): + tdLog.debug("begin data types") + tdSql.prepare() + tdSql.execute("create table stb3 (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 binary(15), c6 nchar(15), c7 bool) tags(t1 int, t2 binary(15))") + tdSql.execute("create table tb0 using stb3 tags(0, 'tb0')") + tdSql.execute("create table tb1 using stb3 tags(1, 'tb1')") + tdSql.execute("create table tb2 using stb3 tags(2, 'tb2')") + tdSql.execute("create table tb3 using stb3 tags(3, 'tb3')") + tdSql.execute("create table tb4 using stb3 tags(4, 'tb4')") + + tdSql.execute("create table strm0 as select count(ts), count(c1), max(c2), min(c4), first(c5), last(c6) from stb3 where ts < now + 30s interval(4s) sliding(2s)") + #tdSql.execute("create table strm0 as select count(ts), count(c1), max(c2), min(c4), first(c5) from stb where ts < now + 30s interval(4s) sliding(2s)") + tdLog.sleep(1) + tdSql.execute("insert into tb0 values (now, 0, 0, 0, 0, 'binary0', '涛思0', true) tb1 values (now, 1, 1, 1, 1, 'binary1', '涛思1', false) tb2 values (now, 2, 2, 2, 2, 'binary2', '涛思2', true) tb3 values (now, 3, 3, 3, 3, 'binary3', '涛思3', false) tb4 values (now, 4, 4, 4, 4, 'binary4', '涛思4', true) ") + + tdSql.waitedQuery("select * from strm0 order by ts desc", 2, 120) + tdSql.checkRows(2) + + tdSql.execute("insert into tb0 values (now, 10, 10, 10, 10, 'binary0', '涛思0', true) tb1 values (now, 11, 11, 11, 11, 'binary1', '涛思1', false) tb2 values (now, 12, 12, 12, 12, 'binary2', '涛思2', true) tb3 values (now, 13, 13, 13, 13, 'binary3', '涛思3', false) tb4 values (now, 14, 14, 14, 14, 'binary4', '涛思4', true) ") + tdSql.waitedQuery("select * from strm0 order by ts desc", 4, 120) + tdSql.checkRows(4) + + def run(self): + self.tbase300() + self.tbase304() + self.wildcardFilterOnTags() + self.datatypes() + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/stream/showStreamExecTimeisNull.py b/tests/pytest/stream/showStreamExecTimeisNull.py new file mode 100644 index 0000000000000000000000000000000000000000..8a2a09cec6f345d62fc821ba58f60f72d563249f --- /dev/null +++ b/tests/pytest/stream/showStreamExecTimeisNull.py @@ -0,0 +1,98 @@ +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug(f"start to execute {__file__}") + tdSql.init(conn.cursor(), logSql) + + def insertnow(self): + + # timestamp list: + # 0 -> "1970-01-01 08:00:00" | -28800000 -> "1970-01-01 00:00:00" | -946800000000 -> "1940-01-01 00:00:00" + # -631180800000 -> "1950-01-01 00:00:00" + + tsp1 = 0 + tsp2 = -28800000 + tsp3 = -946800000000 + tsp4 = "1969-01-01 00:00:00.000" + + tdSql.execute("insert into tcq1 values (now-11d, 5)") + tdSql.execute(f"insert into tcq1 values ({tsp1}, 4)") + tdSql.execute(f"insert into tcq1 values ({tsp2}, 3)") + tdSql.execute(f"insert into tcq1 values ('{tsp4}', 2)") + tdSql.execute(f"insert into tcq1 values ({tsp3}, 1)") + + def waitedQuery(self, sql, expectRows, timeout): + tdLog.info(f"sql: {sql}, try to retrieve {expectRows} rows in {timeout} seconds") + try: + for i in range(timeout): + tdSql.cursor.execute(sql) + self.queryResult = tdSql.cursor.fetchall() + self.queryRows = len(self.queryResult) + self.queryCols = len(tdSql.cursor.description) + # tdLog.info("sql: %s, try to retrieve %d rows,get %d rows" % (sql, expectRows, self.queryRows)) + if self.queryRows >= expectRows: + return (self.queryRows, i) + time.sleep(1) + except Exception as e: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + tdLog.notice(f"{caller.filename}({caller.lineno}) failed: sql:{sql}, {repr(e)}") + raise Exception(repr(e)) + return (self.queryRows, timeout) + + def showstream(self): + tdSql.execute( + "create table cq1 as select avg(c1) from tcq1 interval(10d) sliding(1d)" + ) + sql = "show streams" + timeout = 30 + exception = "ValueError('year -292275055 is out of range')" + try: + for i in range(timeout): + tdSql.cursor.execute(sql) + self.queryResult = tdSql.cursor.fetchall() + self.queryRows = len(self.queryResult) + self.queryCols = len(tdSql.cursor.description) + # tdLog.info("sql: %s, try to retrieve %d rows,get %d rows" % (sql, expectRows, self.queryRows)) + if self.queryRows >= 1: + tdSql.query(sql) + tdSql.checkData(0, 5, None) + return (self.queryRows, i) + time.sleep(1) + except Exception as e: + tdLog.exit(f"sql: {sql} except raise {exception}, actually raise {repr(e)} ") + # else: + # tdLog.exit(f"sql: {sql} except raise {exception}, actually not") + + def run(self): + tdSql.execute("drop database if exists dbcq") + tdSql.execute("create database if not exists dbcq keep 36500") + tdSql.execute("use dbcq") + + tdSql.execute("create table stbcq (ts timestamp, c1 int ) TAGS(t1 int)") + tdSql.execute("create table tcq1 using stbcq tags(1)") + + self.insertnow() + self.showstream() + + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/stream/stream1.py b/tests/pytest/stream/stream1.py new file mode 100644 index 0000000000000000000000000000000000000000..c657379441e6da3137e3a1ceb8148ba9fa5ba9a5 --- /dev/null +++ b/tests/pytest/stream/stream1.py @@ -0,0 +1,142 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import time +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tbNum = 10 + rowNum = 20 + + tdSql.prepare() + + tdLog.info("===== step1 =====") + tdSql.execute( + "create table stb0(ts timestamp, col1 int, col2 float) tags(tgcol int)") + for i in range(tbNum): + tdSql.execute("create table tb%d using stb0 tags(%d)" % (i, i)) + for j in range(rowNum): + tdSql.execute( + "insert into tb%d values (now - %dm, %d, %d)" % + (i, 1440 - j, j, j)) + time.sleep(0.1) + + tdLog.info("===== step2 =====") + tdSql.query( + "select count(*), count(col1), count(col2) from tb0 interval(1d)") + tdSql.checkData(0, 1, rowNum) + tdSql.checkData(0, 2, rowNum) + tdSql.checkData(0, 3, rowNum) + tdSql.query("show tables") + tdSql.checkRows(tbNum) + tdSql.execute( + "create table s0 as select count(*), count(col1), count(col2) from tb0 interval(1d)") + tdSql.query("show tables") + tdSql.checkRows(tbNum + 1) + + tdLog.info("===== step3 =====") + tdSql.waitedQuery("select * from s0", 1, 120) + try: + tdSql.checkData(0, 1, rowNum) + tdSql.checkData(0, 2, rowNum) + tdSql.checkData(0, 3, rowNum) + except Exception as e: + tdLog.info(repr(e)) + + tdLog.info("===== step4 =====") + tdSql.execute("drop table s0") + tdSql.query("show tables") + tdSql.checkRows(tbNum) + + tdLog.info("===== step5 =====") + tdSql.error("select * from s0") + + tdLog.info("===== step6 =====") + time.sleep(0.1) + tdSql.execute( + "create table s0 as select count(*), count(col1), count(col2) from tb0 interval(1d)") + tdSql.query("show tables") + tdSql.checkRows(tbNum + 1) + + tdLog.info("===== step7 =====") + tdSql.waitedQuery("select * from s0", 1, 120) + try: + tdSql.checkData(0, 1, rowNum) + tdSql.checkData(0, 2, rowNum) + tdSql.checkData(0, 3, rowNum) + except Exception as e: + tdLog.info(repr(e)) + + tdLog.info("===== step8 =====") + tdSql.query( + "select count(*), count(col1), count(col2) from stb0 interval(1d)") + tdSql.checkData(0, 1, rowNum * tbNum) + tdSql.checkData(0, 2, rowNum * tbNum) + tdSql.checkData(0, 3, rowNum * tbNum) + tdSql.query("show tables") + tdSql.checkRows(tbNum + 1) + + tdSql.execute( + "create table s1 as select count(*), count(col1), count(col2) from stb0 interval(1d)") + tdSql.query("show tables") + tdSql.checkRows(tbNum + 2) + + tdLog.info("===== step9 =====") + tdSql.waitedQuery("select * from s1", 1, 120) + try: + tdSql.checkData(0, 1, rowNum * tbNum) + tdSql.checkData(0, 2, rowNum * tbNum) + tdSql.checkData(0, 3, rowNum * tbNum) + except Exception as e: + tdLog.info(repr(e)) + + tdLog.info("===== step10 =====") + tdSql.execute("drop table s1") + tdSql.query("show tables") + tdSql.checkRows(tbNum + 1) + + tdLog.info("===== step11 =====") + tdSql.error("select * from s1") + + tdLog.info("===== step12 =====") + tdSql.execute( + "create table s1 as select count(*), count(col1), count(col2) from stb0 interval(1d)") + tdSql.query("show tables") + tdSql.checkRows(tbNum + 2) + + tdLog.info("===== step13 =====") + tdSql.waitedQuery("select * from s1", 1, 120) + try: + tdSql.checkData(0, 1, rowNum * tbNum) + tdSql.checkData(0, 2, rowNum * tbNum) + tdSql.checkData(0, 3, rowNum * tbNum) + except Exception as e: + tdLog.info(repr(e)) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/stream/stream2.py b/tests/pytest/stream/stream2.py new file mode 100644 index 0000000000000000000000000000000000000000..9b4eb8725c96f95196f251c55b0b773cd68e9ed5 --- /dev/null +++ b/tests/pytest/stream/stream2.py @@ -0,0 +1,164 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import time +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tbNum = 10 + rowNum = 20 + totalNum = tbNum * rowNum + + tdSql.prepare() + + tdLog.info("===== step1 =====") + tdSql.execute( + "create table stb0(ts timestamp, col1 int, col2 float) tags(tgcol int)") + for i in range(tbNum): + tdSql.execute("create table tb%d using stb0 tags(%d)" % (i, i)) + for j in range(rowNum): + tdSql.execute( + "insert into tb%d values (now - %dm, %d, %d)" % + (i, 1440 - j, j, j)) + time.sleep(0.1) + + tdLog.info("===== step2 =====") + tdSql.query("select count(col1) from tb0 interval(1d)") + tdSql.checkData(0, 1, rowNum) + tdSql.query("show tables") + tdSql.checkRows(tbNum) + tdSql.execute( + "create table s0 as select count(col1) from tb0 interval(1d)") + tdSql.query("show tables") + tdSql.checkRows(tbNum + 1) + + tdLog.info("===== step3 =====") + tdSql.waitedQuery("select * from s0", 1, 120) + try: + tdSql.checkData(0, 1, rowNum) + except Exception as e: + tdLog.info(repr(e)) + + tdLog.info("===== step4 =====") + tdSql.execute("drop table s0") + tdSql.query("show tables") + try: + tdSql.checkRows(tbNum) + except Exception as e: + tdLog.info(repr(e)) + + tdLog.info("===== step5 =====") + tdSql.error("select * from s0") + + tdLog.info("===== step6 =====") + tdSql.execute( + "create table s0 as select count(*), count(col1), count(col2) from tb0 interval(1d)") + tdSql.query("show tables") + try: + tdSql.checkRows(tbNum + 1) + except Exception as e: + tdLog.info(repr(e)) + + tdLog.info("===== step7 =====") + tdSql.waitedQuery("select * from s0", 1, 120) + try: + tdSql.checkData(0, 1, rowNum) + tdSql.checkData(0, 2, rowNum) + tdSql.checkData(0, 3, rowNum) + except Exception as e: + tdLog.info(repr(e)) + + + time.sleep(5) + tdSql.query("show streams") + tdSql.checkRows(1) + tdSql.checkData(0, 2, 's0') + + tdLog.info("===== step8 =====") + tdSql.query( + "select count(*), count(col1), count(col2) from stb0 interval(1d)") + try: + tdSql.checkData(0, 1, totalNum) + tdSql.checkData(0, 2, totalNum) + tdSql.checkData(0, 3, totalNum) + except Exception as e: + tdLog.info(repr(e)) + tdSql.query("show tables") + tdSql.checkRows(tbNum + 1) + tdSql.execute( + "create table s1 as select count(*), count(col1), count(col2) from stb0 interval(1d)") + tdSql.query("show tables") + tdSql.checkRows(tbNum + 2) + + tdLog.info("===== step9 =====") + tdSql.waitedQuery("select * from s1", 1, 120) + try: + tdSql.checkData(0, 1, totalNum) + tdSql.checkData(0, 2, totalNum) + tdSql.checkData(0, 3, totalNum) + except Exception as e: + tdLog.info(repr(e)) + + tdLog.info("===== step10 =====") + tdSql.execute("drop table s1") + tdSql.query("show tables") + try: + tdSql.checkRows(tbNum + 1) + except Exception as e: + tdLog.info(repr(e)) + + tdLog.info("===== step11 =====") + tdSql.error("select * from s1") + + tdLog.info("===== step12 =====") + tdSql.execute( + "create table s1 as select count(col1) from stb0 interval(1d)") + tdSql.query("show tables") + try: + tdSql.checkRows(tbNum + 2) + except Exception as e: + tdLog.info(repr(e)) + + tdLog.info("===== step13 =====") + tdSql.waitedQuery("select * from s1", 1, 120) + try: + tdSql.checkData(0, 1, totalNum) + #tdSql.checkData(0, 2, None) + #tdSql.checkData(0, 3, None) + except Exception as e: + tdLog.info(repr(e)) + + time.sleep(5) + tdSql.query("show streams") + tdSql.checkRows(2) + tdSql.checkData(0, 2, 's1') + tdSql.checkData(1, 2, 's0') + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/stream/stream3.py b/tests/pytest/stream/stream3.py new file mode 100644 index 0000000000000000000000000000000000000000..9a5c6c9aeca08bff1c94861255919255eef89100 --- /dev/null +++ b/tests/pytest/stream/stream3.py @@ -0,0 +1,108 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import time +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + ts = 1500000000000 + tbNum = 10 + rowNum = 20 + + tdSql.prepare() + + tdLog.info("===== step1 =====") + tdSql.execute( + "create table stb0(ts timestamp, col1 binary(20), col2 nchar(20)) tags(tgcol int)") + for i in range(tbNum): + tdSql.execute("create table tb%d using stb0 tags(%d)" % (i, i)) + for j in range(rowNum): + tdSql.execute( + "insert into tb%d values (%d, 'binary%d', 'nchar%d')" % + (i, ts + 60000 * j, j, j)) + tdSql.execute("insert into tb0 values(%d, null, null)" % (ts + 10000000)) + time.sleep(0.1) + + tdLog.info("===== step2 =====") + tdSql.query( + "select count(*), count(col1), count(col2) from stb0 interval(1d)") + tdSql.checkData(0, 1, rowNum * tbNum + 1) + tdSql.checkData(0, 2, rowNum * tbNum) + tdSql.checkData(0, 3, rowNum * tbNum) + + tdSql.query("show tables") + tdSql.checkRows(tbNum) + tdSql.execute( + "create table s0 as select count(*), count(col1), count(col2) from stb0 interval(1d)") + tdSql.query("show tables") + tdSql.checkRows(tbNum + 1) + + tdLog.info("===== step3 =====") + tdSql.waitedQuery("select * from s0", 1, 120) + try: + tdSql.checkData(0, 1, rowNum * tbNum + 1) + tdSql.checkData(0, 2, rowNum * tbNum) + tdSql.checkData(0, 3, rowNum * tbNum) + except Exception as e: + tdLog.info(repr(e)) + + tdLog.info("===== step4 =====") + tdSql.execute("drop table s0") + tdSql.query("show tables") + tdSql.checkRows(tbNum) + + tdLog.info("===== step5 =====") + tdSql.error("select * from s0") + + tdLog.info("===== step6 =====") + time.sleep(0.1) + tdSql.execute( + "create table s0 as select count(*), count(col1), count(col2) from tb0 interval(1d)") + tdSql.query("show tables") + tdSql.checkRows(tbNum + 1) + + tdLog.info("===== step7 =====") + tdSql.waitedQuery("select * from s0", 1, 120) + try: + tdSql.checkData(0, 1, rowNum + 1) + tdSql.checkData(0, 2, rowNum) + tdSql.checkData(0, 3, rowNum) + except Exception as e: + tdLog.info(repr(e)) + + tdLog.info("===== step8 =====") + tdSql.query( + "select count(*), count(col1), count(col2) from stb0 interval(1d)") + tdSql.checkData(0, 1, rowNum * tbNum + 1) + tdSql.checkData(0, 2, rowNum * tbNum) + tdSql.checkData(0, 3, rowNum * tbNum) + tdSql.query("show tables") + tdSql.checkRows(tbNum + 1) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/stream/sys.py b/tests/pytest/stream/sys.py new file mode 100644 index 0000000000000000000000000000000000000000..fc97934d3fda9d18fa3e745ed3fe6bab3f3d5437 --- /dev/null +++ b/tests/pytest/stream/sys.py @@ -0,0 +1,62 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# migrated from 'stream_on_sys.sim' +# -*- coding: utf-8 -*- +import sys +import time +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + updatecfgDict = {'monitor': 1} + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + + def run(self): + time.sleep(5) + tdSql.execute("use log") + + tdSql.execute("create table cpustrm as select count(*), avg(cpu_taosd), max(cpu_taosd), min(cpu_taosd), avg(cpu_system), max(cpu_cores), min(cpu_cores), last(cpu_cores) from log.dn1 interval(4s)") + tdSql.execute("create table memstrm as select count(*), avg(mem_taosd), max(mem_taosd), min(mem_taosd), avg(mem_system), first(mem_total), last(mem_total) from log.dn1 interval(4s)") + tdSql.execute("create table diskstrm as select count(*), avg(disk_used), last(disk_used), avg(disk_total), first(disk_total) from log.dn1 interval(4s)") + tdSql.execute("create table bandstrm as select count(*), avg(band_speed), last(band_speed) from log.dn1 interval(4s)") + tdSql.execute("create table reqstrm as select count(*), avg(req_http), last(req_http), avg(req_select), last(req_select), avg(req_insert), last(req_insert) from log.dn1 interval(4s)") + tdSql.execute("create table iostrm as select count(*), avg(io_read), last(io_read), avg(io_write), last(io_write) from log.dn1 interval(4s)") + + sqls = [ + "select * from cpustrm", + "select * from memstrm", + "select * from diskstrm", + "select * from bandstrm", + "select * from reqstrm", + "select * from iostrm", + ] + for sql in sqls: + (rows, _) = tdSql.waitedQuery(sql, 1, 600) + if rows < 1: + tdLog.exit("failed: sql:%s, expect at least one row" % sql) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) + diff --git a/tests/pytest/stream/table_1.py b/tests/pytest/stream/table_1.py new file mode 100644 index 0000000000000000000000000000000000000000..b205491fad181a51c991c16da65baa8370174e74 --- /dev/null +++ b/tests/pytest/stream/table_1.py @@ -0,0 +1,89 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import time +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def createFuncStream(self, expr, suffix, value): + tbname = "strm_" + suffix + tdLog.info("create stream table %s" % tbname) + tdSql.query("select %s from tb1 interval(1d)" % expr) + tdSql.checkData(0, 1, value) + tdSql.execute("create table %s as select %s from tb1 interval(1d)" % (tbname, expr)) + + def checkStreamData(self, suffix, value): + sql = "select * from strm_" + suffix + tdSql.waitedQuery(sql, 1, 120) + tdSql.checkData(0, 1, value) + + def run(self): + tbNum = 10 + rowNum = 20 + + tdSql.prepare() + + tdLog.info("===== step1 =====") + tdSql.execute( + "create table stb(ts timestamp, tbcol int, tbcol2 float) tags(tgcol int)") + for i in range(tbNum): + tdSql.execute("create table tb%d using stb tags(%d)" % (i, i)) + for j in range(rowNum): + tdSql.execute( + "insert into tb%d values (now - %dm, %d, %d)" % + (i, 1440 - j, j, j)) + time.sleep(1) + + self.createFuncStream("count(*)", "c1", rowNum) + self.createFuncStream("count(tbcol)", "c2", rowNum) + self.createFuncStream("count(tbcol2)", "c3", rowNum) + self.createFuncStream("avg(tbcol)", "av", 9.5) + self.createFuncStream("sum(tbcol)", "su", 190) + self.createFuncStream("min(tbcol)", "mi", 0) + self.createFuncStream("max(tbcol)", "ma", 19) + self.createFuncStream("first(tbcol)", "fi", 0) + self.createFuncStream("last(tbcol)", "la", 19) + self.createFuncStream("stddev(tbcol)", "st", 5.766281297335398) + self.createFuncStream("percentile(tbcol, 1)", "pe", 0.19) + self.createFuncStream("count(tbcol)", "as", rowNum) + + self.checkStreamData("c1", rowNum) + self.checkStreamData("c2", rowNum) + self.checkStreamData("c3", rowNum) + self.checkStreamData("av", 9.5) + self.checkStreamData("su", 190) + self.checkStreamData("mi", 0) + self.checkStreamData("ma", 19) + self.checkStreamData("fi", 0) + self.checkStreamData("la", 19) + self.checkStreamData("st", 5.766281297335398) + self.checkStreamData("pe", 0.19) + self.checkStreamData("as", rowNum) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/stream/table_n.py b/tests/pytest/stream/table_n.py new file mode 100644 index 0000000000000000000000000000000000000000..371af769778bce1eb1e6cf1bac89333006c582a8 --- /dev/null +++ b/tests/pytest/stream/table_n.py @@ -0,0 +1,143 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import time +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tbNum = 10 + rowNum = 20 + + tdSql.prepare() + + tdLog.info("===== preparing data =====") + tdSql.execute( + "create table stb(ts timestamp, tbcol int, tbcol2 float) tags(tgcol int)") + for i in range(tbNum): + tdSql.execute("create table tb%d using stb tags(%d)" % (i, i)) + for j in range(rowNum): + tdSql.execute( + "insert into tb%d values (now - %dm, %d, %d)" % + (i, 1440 - j, j, j)) + time.sleep(0.1) + + tdLog.info("===== step 1 =====") + tdSql.query("select count(*), count(tbcol), count(tbcol2) from tb1 interval(1d)") + tdSql.checkData(0, 1, rowNum) + tdSql.checkData(0, 2, rowNum) + tdSql.checkData(0, 3, rowNum) + + tdLog.info("===== step 2 =====") + tdSql.execute("create table strm_c3 as select count(*), count(tbcol), count(tbcol2) from tb1 interval(1d)") + + tdLog.info("===== step 3 =====") + tdSql.execute("create table strm_c32 as select count(*), count(tbcol) as c1, count(tbcol2) as c2, count(tbcol) as c3, count(tbcol) as c4, count(tbcol) as c5, count(tbcol) as c6, count(tbcol) as c7, count(tbcol) as c8, count(tbcol) as c9, count(tbcol) as c10, count(tbcol) as c11, count(tbcol) as c12, count(tbcol) as c13, count(tbcol) as c14, count(tbcol) as c15, count(tbcol) as c16, count(tbcol) as c17, count(tbcol) as c18, count(tbcol) as c19, count(tbcol) as c20, count(tbcol) as c21, count(tbcol) as c22, count(tbcol) as c23, count(tbcol) as c24, count(tbcol) as c25, count(tbcol) as c26, count(tbcol) as c27, count(tbcol) as c28, count(tbcol) as c29, count(tbcol) as c30 from tb1 interval(1d)") + + tdLog.info("===== step 4 =====") + tdSql.query("select count(*), count(tbcol) as c1, count(tbcol2) as c2, count(tbcol) as c3, count(tbcol) as c4, count(tbcol) as c5, count(tbcol) as c6, count(tbcol) as c7, count(tbcol) as c8, count(tbcol) as c9, count(tbcol) as c10, count(tbcol) as c11, count(tbcol) as c12, count(tbcol) as c13, count(tbcol) as c14, count(tbcol) as c15, count(tbcol) as c16, count(tbcol) as c17, count(tbcol) as c18, count(tbcol) as c19, count(tbcol) as c20, count(tbcol) as c21, count(tbcol) as c22, count(tbcol) as c23, count(tbcol) as c24, count(tbcol) as c25, count(tbcol) as c26, count(tbcol) as c27, count(tbcol) as c28, count(tbcol) as c29, count(tbcol) as c30 from tb1 interval(1d)") + tdSql.checkData(0, 1, rowNum) + tdSql.checkData(0, 2, rowNum) + tdSql.checkData(0, 3, rowNum) + + tdLog.info("===== step 5 =====") + tdSql.execute("create table strm_c31 as select count(*), count(tbcol) as c1, count(tbcol2) as c2, count(tbcol) as c3, count(tbcol) as c4, count(tbcol) as c5, count(tbcol) as c6, count(tbcol) as c7, count(tbcol) as c8, count(tbcol) as c9, count(tbcol) as c10, count(tbcol) as c11, count(tbcol) as c12, count(tbcol) as c13, count(tbcol) as c14, count(tbcol) as c15, count(tbcol) as c16, count(tbcol) as c17, count(tbcol) as c18, count(tbcol) as c19, count(tbcol) as c20, count(tbcol) as c21, count(tbcol) as c22, count(tbcol) as c23, count(tbcol) as c24, count(tbcol) as c25, count(tbcol) as c26, count(tbcol) as c27, count(tbcol) as c28, count(tbcol) as c29, count(tbcol) as c30 from tb1 interval(1d)") + + tdLog.info("===== step 6 =====") + tdSql.query("select avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from tb1 interval(1d)") + tdSql.checkData(0, 1, 9.5) + tdSql.checkData(0, 2, 190) + tdSql.checkData(0, 3, 0) + tdSql.checkData(0, 4, 19) + tdSql.checkData(0, 5, 0) + tdSql.checkData(0, 6, 19) + tdSql.execute("create table strm_avg as select avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from tb1 interval(1d)") + + tdLog.info("===== step 7 =====") + tdSql.query("select stddev(tbcol), leastsquares(tbcol, 1, 1), percentile(tbcol, 1) from tb1 interval(1d)") + tdSql.checkData(0, 1, 5.766281297335398) + tdSql.checkData(0, 3, 0.19) + tdSql.execute("create table strm_ot as select stddev(tbcol), leastsquares(tbcol, 1, 1), percentile(tbcol, 1) from tb1 interval(1d)") + + tdLog.info("===== step 8 =====") + tdSql.query("select avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol), stddev(tbcol), percentile(tbcol, 1), count(tbcol), leastsquares(tbcol, 1, 1) from tb1 interval(1d)") + tdSql.checkData(0, 1, 9.5) + tdSql.checkData(0, 2, 190) + tdSql.checkData(0, 3, 0) + tdSql.checkData(0, 4, 19) + tdSql.checkData(0, 5, 0) + tdSql.checkData(0, 6, 19) + tdSql.checkData(0, 7, 5.766281297335398) + tdSql.checkData(0, 8, 0.19) + tdSql.checkData(0, 9, rowNum) + tdSql.execute("create table strm_to as select avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol), stddev(tbcol), percentile(tbcol, 1), count(tbcol), leastsquares(tbcol, 1, 1) from tb1 interval(1d)") + + tdLog.info("===== step 9 =====") + tdSql.query("select avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol), stddev(tbcol), percentile(tbcol, 1), count(tbcol), leastsquares(tbcol, 1, 1) from tb1 where ts < now + 4m interval(1d)") + tdSql.checkData(0, 9, rowNum) + tdSql.execute("create table strm_wh as select avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol), stddev(tbcol), percentile(tbcol, 1), count(tbcol), leastsquares(tbcol, 1, 1) from tb1 where ts < now + 4m interval(1d)") + + tdLog.info("===== step 10 =====") + tdSql.waitedQuery("select * from strm_c3", 1, 120) + tdSql.checkData(0, 1, rowNum) + tdSql.checkData(0, 2, rowNum) + tdSql.checkData(0, 3, rowNum) + + tdLog.info("===== step 11 =====") + tdSql.waitedQuery("select * from strm_c31", 1, 30) + for i in range(1, 10): + tdSql.checkData(0, i, rowNum) + + tdLog.info("===== step 12 =====") + tdSql.waitedQuery("select * from strm_avg", 1, 20) + tdSql.checkData(0, 1, 9.5) + tdSql.checkData(0, 2, 190) + tdSql.checkData(0, 3, 0) + tdSql.checkData(0, 4, 19) + tdSql.checkData(0, 5, 0) + tdSql.checkData(0, 6, 19) + + tdLog.info("===== step 13 =====") + tdSql.waitedQuery("select * from strm_ot", 1, 20) + tdSql.checkData(0, 1, 5.766281297335398) + tdSql.checkData(0, 3, 0.19) + + tdLog.info("===== step 14 =====") + tdSql.waitedQuery("select * from strm_to", 1, 20) + tdSql.checkData(0, 1, 9.5) + tdSql.checkData(0, 2, 190) + tdSql.checkData(0, 3, 0) + tdSql.checkData(0, 4, 19) + tdSql.checkData(0, 5, 0) + tdSql.checkData(0, 6, 19) + tdSql.checkData(0, 7, 5.766281297335398) + tdSql.checkData(0, 8, 0.19) + tdSql.checkData(0, 9, rowNum) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/subscribe/__init__.py b/tests/pytest/subscribe/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/pytest/subscribe/singlemeter.py b/tests/pytest/subscribe/singlemeter.py new file mode 100644 index 0000000000000000000000000000000000000000..879e0a75ebdf29022990b5e2e250370620c74636 --- /dev/null +++ b/tests/pytest/subscribe/singlemeter.py @@ -0,0 +1,79 @@ +################################################################### + # Copyright (c) 2020 by TAOS Technologies, Inc. + # All rights reserved. + # + # This file is proprietary and confidential to TAOS Technologies. + # No part of this file may be reproduced, stored, transmitted, + # disclosed or used in any form or by any means other than as + # expressly provided by the written permission from Jianhui Tao + # +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +import time +from util.log import * +from util.cases import * +from util.sql import * +from util.sub import * + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self.conn = conn + + def run(self): + sqlstr = "select * from t0" + topic = "test" + now = int(time.time() * 1000) + tdSql.prepare() + + tdLog.info("create a table and insert 10 rows.") + tdSql.execute("create table t0(ts timestamp, a int, b int);") + for i in range(0, 10): + tdSql.execute("insert into t0 values (%d, %d, %d);" % (now + i, i, i)) + + tdLog.info("consumption 01.") + tdSub.init(self.conn.subscribe(True, topic, sqlstr, 0)) + tdSub.consume() + tdSub.checkRows(10) + + tdLog.info("consumption 02: no new rows inserted") + tdSub.consume() + tdSub.checkRows(0) + + tdLog.info("consumption 03: after one new rows inserted") + tdSql.execute("insert into t0 values (%d, 10, 10);" % (now + 10)) + tdSub.consume() + tdSub.checkRows(1) + + tdLog.info("consumption 04: keep progress and continue previous subscription") + tdSub.close(True) + tdSub.init(self.conn.subscribe(False, topic, sqlstr, 0)) + tdSub.consume() + tdSub.checkRows(0) + + tdLog.info("consumption 05: remove progress and continue previous subscription") + tdSub.close(False) + tdSub.init(self.conn.subscribe(False, topic, sqlstr, 0)) + tdSub.consume() + tdSub.checkRows(11) + + tdLog.info("consumption 06: keep progress and restart the subscription") + tdSub.close(True) + tdSub.init(self.conn.subscribe(True, topic, sqlstr, 0)) + tdSub.consume() + tdSub.checkRows(11) + + tdSub.close(True) + + def stop(self): + tdSub.close(False) + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/subscribe/stability.py b/tests/pytest/subscribe/stability.py new file mode 100644 index 0000000000000000000000000000000000000000..ddd8b3282a01843f912ce8e19b4baa790aa32bfa --- /dev/null +++ b/tests/pytest/subscribe/stability.py @@ -0,0 +1,93 @@ +################################################################### + # Copyright (c) 2020 by TAOS Technologies, Inc. + # All rights reserved. + # + # This file is proprietary and confidential to TAOS Technologies. + # No part of this file may be reproduced, stored, transmitted, + # disclosed or used in any form or by any means other than as + # expressly provided by the written permission from Jianhui Tao + # +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +import time +import random +import string +from util.log import * +from util.cases import * +from util.sql import * +from util.sub import * + +class TDTestCase: + maxTables = 10000 + maxCols = 50 + rowsPerSecond = 1000 + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdLog.notice("NOTE: this case does not stop automatically, Ctrl+C to stop") + tdSql.init(conn.cursor(), logSql) + self.conn = conn + + + def generateString(self, length): + chars = string.ascii_uppercase + string.ascii_lowercase + v = "" + for i in range(length): + v += random.choice(chars) + return v + + + def insert(self): + id = random.randint(0, self.maxTables - 1) + cola = self.generateString(40) + sql = "insert into car%d values(now, '%s', %f, %d" % (id, cola, random.random()*100, random.randint(0, 2)) + for i in range(self.maxCols): + sql += ", %d" % random.randint(0, self.maxTables) + sql += ")" + tdSql.execute(sql) + + + def prepare(self): + tdLog.info("prepare database: test") + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists test') + tdSql.execute('create database test') + tdSql.execute('use test') + + def run(self): + self.prepare() + + sql = "create table cars (ts timestamp, a binary(50), b float, c bool" + for i in range(self.maxCols): + sql += ", c%d int" % i + sql += ") tags(id int, category binary(30), brand binary(30));" + tdSql.execute(sql) + + for i in range(self.maxTables): + tdSql.execute("create table car%d using cars tags(%d, 'category%d', 'brand%d')" % (i, i, i % 30, i // 30)) + + time.sleep(0.1) + + total = 0 + while True: + start = time.time() + for i in range(self.rowsPerSecond): + self.insert() + total = total + 1 + d = time.time() - start + tdLog.info("%d rows inserted in %f seconds, total %d" % (self.rowsPerSecond, d, total)) + if d < 1: + time.sleep(1 - d) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/subscribe/supertable.py b/tests/pytest/subscribe/supertable.py new file mode 100644 index 0000000000000000000000000000000000000000..ee3aa225bd79a6709a06672df76d7e7163f7a831 --- /dev/null +++ b/tests/pytest/subscribe/supertable.py @@ -0,0 +1,122 @@ +################################################################### + # Copyright (c) 2020 by TAOS Technologies, Inc. + # All rights reserved. + # + # This file is proprietary and confidential to TAOS Technologies. + # No part of this file may be reproduced, stored, transmitted, + # disclosed or used in any form or by any means other than as + # expressly provided by the written permission from Jianhui Tao + # +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +import time +from util.log import * +from util.cases import * +from util.sql import * +from util.sub import * + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self.conn = conn + + def run(self): + sqlstr = "select * from meters" + topic = "test" + now = int(time.time() * 1000) + tdSql.prepare() + + numTables = 2000 + rowsPerTable = 5 + totalRows = numTables * rowsPerTable + tdLog.info("create a super table and %d sub-tables, then insert %d rows into each sub-table." % (numTables, rowsPerTable)) + tdSql.execute("create table meters(ts timestamp, a int, b int) tags(area int, loc binary(20));") + for i in range(0, numTables): + for j in range(0, rowsPerTable): + tdSql.execute("insert into t%d using meters tags(%d, 'area%d') values (%d, %d, %d);" % (i, i, i, now + j, j, j)) + + tdLog.info("consumption 01.") + tdSub.init(self.conn.subscribe(True, topic, sqlstr, 0)) + tdSub.consume() + tdSub.checkRows(totalRows) + + tdLog.info("consumption 02: no new rows inserted") + tdSub.consume() + tdSub.checkRows(0) + + tdLog.info("consumption 03: after one new rows inserted") + tdSql.execute("insert into t0 values (%d, 10, 10);" % (now + 10)) + tdSub.consume() + tdSub.checkRows(1) + + tdLog.info("consumption 04: keep progress and continue previous subscription") + tdSub.close(True) + tdSub.init(self.conn.subscribe(False, topic, sqlstr, 0)) + tdSub.consume() + tdSub.checkRows(0) + + tdLog.info("consumption 05: remove progress and continue previous subscription") + tdSub.close(False) + tdSub.init(self.conn.subscribe(False, topic, sqlstr, 0)) + tdSub.consume() + tdSub.checkRows(totalRows + 1) + + tdLog.info("consumption 06: keep progress and restart the subscription") + tdSub.close(True) + tdSub.init(self.conn.subscribe(True, topic, sqlstr, 0)) + tdSub.consume() + tdSub.checkRows(totalRows + 1) + + tdLog.info("consumption 07: insert one row to two table then remove one table") + tdSql.execute("insert into t0 values (%d, 11, 11);" % (now + 11)) + tdSql.execute("insert into t%d values (%d, 11, 11);" % ((numTables-1), (now + 11))) + tdSql.execute("drop table t0") + tdSub.consume() + tdSub.checkRows(1) + + tdLog.info("consumption 08: check timestamp criteria") + tdSub.close(False) + tdSub.init(self.conn.subscribe(True, topic, sqlstr + " where ts > %d" % now, 0)) + tdSub.consume() + tdSub.checkRows((numTables-1) * (rowsPerTable-1) + 1) + + tdLog.info("consumption 09: insert large timestamp to t2 then insert smaller timestamp to t1") + tdSql.execute("insert into t2 values (%d, 100, 100);" % (now + 100)) + tdSub.consume() + tdSub.checkRows(1) + tdSql.execute("insert into t1 values (%d, 12, 12);" % (now + 12)) + tdSub.consume() + tdSub.checkRows(1) + + tdLog.info("consumption 10: field criteria") + tdSub.close(True) + tdSub.init(self.conn.subscribe(False, topic, sqlstr + " where a > 100", 0)) + tdSql.execute("insert into t2 values (%d, 101, 100);" % (now + 101)) + tdSql.execute("insert into t2 values (%d, 100, 100);" % (now + 102)) + tdSql.execute("insert into t2 values (%d, 102, 100);" % (now + 103)) + tdSub.consume() + tdSub.checkRows(2) + + tdLog.info("consumption 11: two vnodes") + tdSql.execute("insert into t2 values (%d, 102, 100);" % (now + 104)) + tdSql.execute("insert into t1299 values (%d, 102, 100);" % (now + 104)) + tdSub.consume() + tdSub.checkRows(2) + + tdLog.info("consumption 12: create a new table") + tdSql.execute("insert into t%d using meters tags(%d, 'area%d') values (%d, 102, 100);" % (numTables, numTables, numTables, now + 105)) + tdSub.consume() + tdSub.checkRows(1) + + def stop(self): + tdSub.close(False) + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/table/__init__.py b/tests/pytest/table/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/pytest/table/alter_column.py b/tests/pytest/table/alter_column.py new file mode 100644 index 0000000000000000000000000000000000000000..73fdbe1ae91c71e0ce9a1574239dbee9ec3fd988 --- /dev/null +++ b/tests/pytest/table/alter_column.py @@ -0,0 +1,88 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, db_test.stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + print("==============step1") + + tdLog.info("create database and table") + tdSql.execute("create database db_test") + tdSql.execute( + "create table if not exists db_test.st(ts timestamp, tagtype int) tags(dev nchar(50))") + tdSql.execute( + "CREATE TABLE if not exists db_test.dev_001 using db_test.st tags('dev_01')") + + print("==============step2") + tdLog.info("alter table add column") + tdSql.execute( + "ALTER TABLE db_test.st add COLUMN tag_version nchar(20)") + tdSql.query("describe db_test.st") + tdSql.checkRows(4) + + print("==============step3") + tdLog.info("alter table drop column") + tdSql.execute("ALTER TABLE db_test.st drop COLUMN tag_version") + tdSql.query("describe db_test.st") + tdSql.checkRows(3) + + print("==============step4") + tdLog.info("drop table") + tdSql.execute("drop table db_test.st") + tdSql.execute( + "create table if not exists db_test.st(ts timestamp, tagtype int) tags(dev nchar(50))") + tdSql.execute( + "CREATE TABLE if not exists db_test.dev_001 using db_test.st tags('dev_01')") + tdSql.execute( + "INSERT INTO db_test.dev_001 VALUES ('2020-05-13 10:00:00.000', 1)") + tdSql.query("select * from db_test.dev_001") + tdSql.checkRows(1) + + print("==============step5") + tdLog.info("alter table add column") + tdSql.execute( + "ALTER TABLE db_test.st add COLUMN tag_version nchar(20)") + tdSql.query("describe db_test.st") + tdSql.checkRows(4) + + tdSql.execute( + "INSERT INTO db_test.dev_001 VALUES ('2020-05-13 10:00:00.010', 1, '1.2.1')") + tdSql.query("select * from db_test.st") + tdSql.checkRows(2) + + print("==============step6") + tdLog.info("alter table drop column") + tdSql.execute("ALTER TABLE db_test.st drop COLUMN tag_version") + tdSql.query("describe db_test.st") + tdSql.checkRows(3) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/table/alter_wal0.py b/tests/pytest/table/alter_wal0.py new file mode 100644 index 0000000000000000000000000000000000000000..807dd316f2f5b154817217c9cf28821242bc9176 --- /dev/null +++ b/tests/pytest/table/alter_wal0.py @@ -0,0 +1,76 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +from util.dnodes import tdDnodes + + +class TDTestCase: + """ + remove last tow bytes of file 'wal0',then restart taosd and create new tables. + """ + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + print("==============step1") + tdSql.execute("create database if not exists demo;"); + tdSql.execute("use demo;") + tdSql.execute("create table if not exists meters(ts timestamp, f1 int) tags(t1 int);"); + for i in range(1,11): + tdSql.execute("CREATE table if not exists test{num} using meters tags({num});".format(num=i)) + print("==============insert 10 tables") + + tdSql.query('show tables;') + tdSql.checkRows(10) + + print("==============step2") + tdDnodes.stopAll() + path = tdDnodes.getDnodesRootDir() + filename = path + '/dnode1/data/mnode/wal/wal0' + + with open(filename, 'rb') as f1: + temp = f1.read() + + with open(filename, 'wb') as f2: + f2.write(temp[:-2]) + + tdDnodes.start(1) + print("==============remove last tow bytes of file 'wal0' and restart taosd") + + print("==============step3") + tdSql.execute("use demo;") + tdSql.query('show tables;') + tdSql.checkRows(9) + for i in range(11,21): + tdSql.execute("CREATE table if not exists test{num} using meters tags({num});".format(num=i)) + + tdSql.query('show tables;') + tdSql.checkRows(19) + print("==============check table numbers and create 10 tables") + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/table/boundary.py b/tests/pytest/table/boundary.py new file mode 100644 index 0000000000000000000000000000000000000000..a1bf096499d7c3c4f3ad5ec3e57878a510935f5c --- /dev/null +++ b/tests/pytest/table/boundary.py @@ -0,0 +1,182 @@ +# -*- coding: utf-8 -*- + +import random +import string +import subprocess +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getLimitFromSourceCode(self, name): + cmd = "grep -w '#define %s' ../../src/inc/taosdef.h|awk '{print $3}'" % name + return int(subprocess.check_output(cmd, shell=True)) + + def generateString(self, length): + chars = string.ascii_uppercase + string.ascii_lowercase + v = "" + for i in range(length): + v += random.choice(chars) + return v + + def checkTagBoundaries(self): + tdLog.debug("checking tag boundaries") + tdSql.prepare() + + maxTags = self.getLimitFromSourceCode('TSDB_MAX_TAGS') + totalTagsLen = self.getLimitFromSourceCode('TSDB_MAX_TAGS_LEN') + tdLog.notice("max tags is %d" % maxTags) + tdLog.notice("max total tag length is %d" % totalTagsLen) + + # for binary tags, 2 bytes are used for length + tagLen = (totalTagsLen - maxTags * 2) // maxTags + firstTagLen = totalTagsLen - 2 * maxTags - tagLen * (maxTags - 1) + + sql = "create table cars(ts timestamp, f int) tags(t0 binary(%d)" % firstTagLen + for i in range(1, maxTags): + sql += ", t%d binary(%d)" % (i, tagLen) + sql += ");" + + tdLog.debug("creating super table: " + sql) + tdSql.execute(sql) + tdSql.query('show stables') + tdSql.checkRows(1) + + for i in range(10): + sql = "create table car%d using cars tags('%d'" % (i, i) + sql += ", '0'" * (maxTags - 1) + ");" + tdLog.debug("creating table: " + sql) + tdSql.execute(sql) + + sql = "insert into car%d values(now, 0);" % i + tdLog.debug("inserting data: " + sql) + tdSql.execute(sql) + + tdSql.query('show tables') + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + + tdSql.query('select * from cars;') + tdSql.checkRows(10) + + def checkColumnBoundaries(self): + tdLog.debug("checking column boundaries") + tdSql.prepare() + + # one column is for timestamp + maxCols = self.getLimitFromSourceCode('TSDB_MAX_COLUMNS') - 1 + + sql = "create table cars (ts timestamp" + for i in range(maxCols): + sql += ", c%d int" % i + sql += ");" + tdSql.execute(sql) + tdSql.query('show tables') + tdSql.checkRows(1) + + sql = "insert into cars values (now" + for i in range(maxCols): + sql += ", %d" % i + sql += ");" + tdSql.execute(sql) + tdSql.query('select * from cars') + tdSql.checkRows(1) + + def checkTableNameBoundaries(self): + tdLog.debug("checking table name boundaries") + tdSql.prepare() + + maxTableNameLen = self.getLimitFromSourceCode('TSDB_TABLE_NAME_LEN') + tdLog.notice("table name max length is %d" % maxTableNameLen) + + # create a super table with name exceed max length + sname = self.generateString(maxTableNameLen) + tdLog.info("create a super table with length %d" % len(sname)) + tdSql.error( + "create table %s (ts timestamp, value int) tags(id int)" % + sname) + + # create a super table with name of max length + sname = self.generateString(maxTableNameLen - 1) + tdLog.info("create a super table with length %d" % len(sname)) + tdSql.execute( + "create table %s (ts timestamp, value int) tags(id int)" % + sname) + tdLog.info("check table count, should be one") + tdSql.query('show stables') + tdSql.checkRows(1) + + # create a child table with name exceed max length + name = self.generateString(maxTableNameLen) + tdLog.info("create a child table with length %d" % len(name)) + tdSql.error("create table %s using %s tags(0)" % (name, sname)) + + # create a child table with name of max length + name = self.generateString(maxTableNameLen - 1) + tdLog.info("create a child table with length %d" % len(name)) + tdSql.execute("create table %s using %s tags(0)" % (name, sname)) + tdSql.query('show tables') + tdSql.checkRows(1) + + # insert one row + tdLog.info("insert one row of data") + tdSql.execute("insert into %s values(now, 0)" % name) + tdSql.query("select * from " + name) + tdSql.checkRows(1) + tdSql.query("select * from " + sname) + tdSql.checkRows(1) + + name = name[:len(name) - 1] + tdSql.error("select * from " + name) + tdSql.checkRows(0) + + def checkRowBoundaries(self): + tdLog.debug("checking row boundaries") + tdSql.prepare() + + # 8 bytes for timestamp + maxRowSize = self.getLimitFromSourceCode('TSDB_MAX_BYTES_PER_ROW') - 8 + maxCols = self.getLimitFromSourceCode('TSDB_MAX_COLUMNS') - 1 + + # for binary cols, 2 bytes are used for length + colLen = (maxRowSize - maxCols * 2) // maxCols + firstColLen = maxRowSize - 2 * maxCols - colLen * (maxCols - 1) + + sql = "create table cars (ts timestamp, c0 binary(%d)" % firstColLen + for i in range(1, maxCols): + sql += ", c%d binary(%d)" % (i, colLen) + sql += ");" + tdSql.execute(sql) + tdSql.query('show tables') + tdSql.checkRows(1) + + col = self.generateString(firstColLen) + sql = "insert into cars values (now, '%s'" % col + col = self.generateString(colLen) + for i in range(1, maxCols): + sql += ", '%s'" % col + sql += ");" + tdLog.info(sql) + tdSql.execute(sql) + tdSql.query("select * from cars") + tdSql.checkRows(1) + + def run(self): + self.checkTagBoundaries() + self.checkColumnBoundaries() + self.checkTableNameBoundaries() + self.checkRowBoundaries() + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/table/column_name.py b/tests/pytest/table/column_name.py new file mode 100644 index 0000000000000000000000000000000000000000..0f24b98f3a9cd1d697c3972f5c8df5f49e82ca72 --- /dev/null +++ b/tests/pytest/table/column_name.py @@ -0,0 +1,127 @@ +# -*- coding: utf-8 -*- + +import sys +import string +import random +import subprocess +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdLog.info('=============== step1') + tdLog.info('drop table dd -x step0') + tdSql.error('drop table dd') + tdLog.info('create table tb(ts timestamp, int) -x step1') + tdSql.error('create table tb(ts timestamp, int)') + # TSIM: return -1 + # TSIM: step1: + # TSIM: + # TSIM: sql show tables + tdLog.info('show tables') + tdSql.query('show tables') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sql create table $tb (ts timestamp, s int) + tdLog.info('create table tb (ts timestamp, s int)') + tdSql.execute('create table tb (ts timestamp, s int)') + # TSIM: sql show tables + tdLog.info('show tables') + tdSql.query('show tables') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql drop table $tb + tdLog.info('drop table tb') + tdSql.execute('drop table tb') + # TSIM: sql show tables + tdLog.info('show tables') + tdSql.query('show tables') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql create table $tb (ts timestamp, a0123456789 int) + tdLog.info('create table tb (ts timestamp, a0123456789 int)') + tdSql.execute('create table tb (ts timestamp, a0123456789 int)') + # TSIM: sql show tables + tdLog.info('show tables') + tdSql.query('show tables') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql drop table $tb + tdLog.info('drop table tb') + tdSql.execute('drop table tb') + # TSIM: sql show tables + tdLog.info('show tables') + tdSql.query('show tables') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql create table $tb (ts timestamp, a0123456789012345678901234567890123456789 int) + getMaxColNum = "grep -w '#define TSDB_COL_NAME_LEN' ../../src/inc/taosdef.h|awk '{print $3}'" + boundary = int(subprocess.check_output(getMaxColNum, shell=True)) - 1 + tdLog.info("get max column name length is %d" % boundary) + chars = string.ascii_uppercase + string.ascii_lowercase + +# col_name = ''.join(random.choices(chars, k=boundary+1)) +# tdLog.info( +# 'create table tb (ts timestamp, %s int), col_name length is %d' % (col_name, len(col_name))) +# tdSql.error( +# 'create table tb (ts timestamp, %s int)' % col_name) + + col_name = ''.join(random.choices(chars, k=boundary)) + tdLog.info( + 'create table tb (ts timestamp, %s int), col_name length is %d' % + (col_name, len(col_name))) + tdSql.execute( + 'create table tb (ts timestamp, %s int)' % col_name) + + # TSIM: sql insert into $tb values (now , 1) + tdLog.info("insert into tb values (now , 1)") + tdSql.execute("insert into tb values (now , 1)") + # TSIM: sql select * from $tb + tdLog.info('select * from tb') + tdSql.query('select * from tb') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/table/column_num.py b/tests/pytest/table/column_num.py new file mode 100644 index 0000000000000000000000000000000000000000..3abedb083c8b68c3f3f06b094e06a3d9c686b82e --- /dev/null +++ b/tests/pytest/table/column_num.py @@ -0,0 +1,123 @@ +# -*- coding: utf-8 -*- + +import sys +import subprocess +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdLog.info('=============== step1') + tdLog.info('create table tb() -x step1') + tdSql.error('create table tb()') + tdLog.info('show tables') + tdSql.query('show tables') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + tdLog.info('=============== step2') + # TSIM: sql create table $tb (ts timestamp) -x step2 + tdLog.info('create table tb (ts timestamp) -x step2') + tdSql.error('create table tb (ts timestamp) ') + tdLog.info('show tables') + tdSql.query('show tables') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + tdLog.info('=============== step3') + tdLog.info('create table tb (ts int) -x step3') + tdSql.error('create table tb (ts int) ') + tdLog.info('show tables') + tdSql.query('show tables') + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + tdLog.info('=============== step4') + tdLog.info('create table tb (ts timestamp, a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, a10 int, a11 int, a12 int, a13 int, a14 int, a15 int, a16 int, a17 int, a18 int, a19 int, a20 int, a21 int, a22 int, a23 int, a24 int, a25 int, a26 int, a27 int, a28 int,a29 int,a30 int,a31 int,a32 int, b1 int, b2 int, b3 int, b4 int, b5 int, b6 int, b7 int, b8 int, b9 int, b10 int, b11 int, b12 int, b13 int, b14 int, b15 int, b16 int, b17 int, b18 int, b19 int, b20 int, b21 int, b22 int, b23 int, b24 int, b25 int, b26 int, b27 int, b28 int,b29 int,b30 int,b31 int,b32 int)') + tdSql.execute('create table tb (ts timestamp, a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, a10 int, a11 int, a12 int, a13 int, a14 int, a15 int, a16 int, a17 int, a18 int, a19 int, a20 int, a21 int, a22 int, a23 int, a24 int, a25 int, a26 int, a27 int, a28 int,a29 int,a30 int,a31 int,a32 int, b1 int, b2 int, b3 int, b4 int, b5 int, b6 int, b7 int, b8 int, b9 int, b10 int, b11 int, b12 int, b13 int, b14 int, b15 int, b16 int, b17 int, b18 int, b19 int, b20 int, b21 int, b22 int, b23 int, b24 int, b25 int, b26 int, b27 int, b28 int,b29 int,b30 int,b31 int,b32 int)') + # TSIM: + # TSIM: sql show tables + tdLog.info('show tables') + tdSql.query('show tables') + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + + tdLog.info('=============== step5') + + getMaxColumnNum = "grep -w '#define TSDB_MAX_COLUMNS' ../../src/inc/taosdef.h|awk '{print $3}'" + boundary = int(subprocess.check_output(getMaxColumnNum, shell=True)) + tdLog.info("get max column number is %d" % boundary) + + columnSeq = "ts timestamp" + for x in range(0, boundary): + columnSeq = columnSeq + ", col%d int" % x + + tdLog.info("create table tb1 (%s)" % columnSeq) + tdSql.error('create table tb1 (%s)' % columnSeq) + + columnSeq = "ts timestamp" + for x in range(0, boundary - 1): + columnSeq = columnSeq + ", col%d int" % x + + tdLog.info("create table tb1 (%s)" % columnSeq) + tdSql.execute('create table tb1 (%s)' % columnSeq) + + tdLog.info('show tables') + tdSql.query('show tables') + # TSIM: if $rows != 2 then + tdLog.info('tdSql.checkRow(2)') + tdSql.checkRows(2) + + data = "now" + for x in range(0, boundary - 1): + data = data + ", %d" % x + tdLog.info("insert into tb1 values (%s)" % data) + tdSql.execute("insert into tb1 values (%s)" % data) + # TSIM: sql select * from $tb + tdLog.info('select * from tb1') + tdSql.query('select * from tb1') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql drop table $tb + tdLog.info('drop table tb1') + tdSql.execute('drop table tb1') + # TSIM: sql show tables + tdLog.info('show tables') + tdSql.query('show tables') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/table/create-a-lot.py b/tests/pytest/table/create-a-lot.py new file mode 100644 index 0000000000000000000000000000000000000000..7db4a8eacac9ede3d47e14bee1a4fc901c0ab270 --- /dev/null +++ b/tests/pytest/table/create-a-lot.py @@ -0,0 +1,45 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + print("==============step1") + print("prepare data") + + for x in range(0, 1000000): + tb_name = "tb%d" % x + tdLog.info("create table %s (ts timestamp, i int)" % tb_name) + tdSql.execute("create table %s (ts timestamp, i int)" % tb_name) + tdLog.info("insert into %s values(now, 1)" % tb_name) + tdSql.execute("insert into %s values(now, 1)" % tb_name) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/table/create.py b/tests/pytest/table/create.py new file mode 100644 index 0000000000000000000000000000000000000000..51277f28e05a6b9c2a9ce0b7375e6f3b9dd98b76 --- /dev/null +++ b/tests/pytest/table/create.py @@ -0,0 +1,76 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + print("==============step1") + print("prepare data") + tdSql.error("create table db.st1 (ts timestamp(8), i int) tags(j int)") + tdSql.error("create table db.st2 (ts timestamp, i int(2)) tags(j int)") + tdSql.execute("create table db.st (ts timestamp, i int) tags(j int)") + tdSql.execute("create table db.tb using st tags(1)") + tdSql.execute("insert into db.tb values(now, 1)") + + print("==============step2") + print("create table as select") + try: + tdSql.execute("create table db.test as select * from db.st") + except Exception as e: + tdLog.exit(e) + + # case for defect: https://jira.taosdata.com:18080/browse/TD-2560 + tdSql.execute("create table db.tb02 using st tags(2)") + tdSql.execute("create table db.tb03 using st tags(3)") + tdSql.execute("create table db.tb04 using st tags(4)") + + tdSql.query("show tables like 'tb%' ") + tdSql.checkRows(4) + + tdSql.query("show tables like 'tb0%' ") + tdSql.checkRows(3) + + tdSql.execute("create table db.st0 (ts timestamp, i int) tags(j int)") + tdSql.execute("create table db.st1 (ts timestamp, i int, c2 int) tags(j int, loc nchar(20))") + + tdSql.query("show stables like 'st%' ") + tdSql.checkRows(3) + + # case for defect: https://jira.taosdata.com:18080/browse/TD-2693 + tdSql.execute("create database db2") + tdSql.execute("use db2") + tdSql.execute("create table stb(ts timestamp, c int) tags(t int)") + tdSql.error("insert into db2.tb6 using db2.stb tags(1) values(now 1) tb2 using db2. tags( )values(now 2)") + + # case for TD-10691 + tdSql.error("create table ttb1(ts timestamp, file int )") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/table/createTableFromAnotherDb.py b/tests/pytest/table/createTableFromAnotherDb.py new file mode 100644 index 0000000000000000000000000000000000000000..b40e72404cd0eb2e887199eca9964a0765106124 --- /dev/null +++ b/tests/pytest/table/createTableFromAnotherDb.py @@ -0,0 +1,41 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + print("==============step1") + tdSql.execute("create table db.cars(ts timestamp, c int) tags(id int);") + tdSql.execute("create database db2") + tdSql.error("create table db2.car1 using db.cars tags(1)") + tdSql.error("insert into db2.car1 using db1.cars tags(1) values(now, 1);") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/table/create_db_from_normal_db.py b/tests/pytest/table/create_db_from_normal_db.py new file mode 100644 index 0000000000000000000000000000000000000000..8b5182c3b16ca31b2bbf966df294e2c4e4c12ff3 --- /dev/null +++ b/tests/pytest/table/create_db_from_normal_db.py @@ -0,0 +1,45 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + print("test case for TS-783") + tdSql.execute("drop table if exists db.state1;") + tdSql.execute("create table db.state1 (ts timestamp, c1 int);") + tdSql.error("create table db.test1 using db.state1 tags('tt');") + + tdSql.execute("drop table if exists db.state2;") + tdSql.execute("create table db.state2 (ts timestamp, c1 int) tags (t binary(20));") + tdSql.query("create table db.test2 using db.state2 tags('tt');") + tdSql.error("create table db.test22 using db.test2 tags('tt');") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/table/create_sensitive.py b/tests/pytest/table/create_sensitive.py new file mode 100644 index 0000000000000000000000000000000000000000..1934b662c7a57c13c2a1b8e8dfd65ab6ddbe13a4 --- /dev/null +++ b/tests/pytest/table/create_sensitive.py @@ -0,0 +1,63 @@ +# -*- coding: utf-8 -*- + +import sys +import string +import random +import subprocess +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdLog.info('=============== step1') + tdLog.info('create table TestSensitiveT(ts timestamp, i int)') + tdSql.execute('create table TestSensitiveT(ts timestamp, i int)') + tdLog.info('create table TestSensitiveSt(ts timestamp,i int) tags(j int)') + tdSql.execute('create table TestSensitiveSt(ts timestamp,i int) tags(j int)') + tdLog.info('create table Abcde using TestSensitiveSt tags(1)') + tdSql.execute('create table AbcdeFgh using TestSensitiveSt tags(1)') + tdLog.info('=============== step2') + tdLog.info('test normal table ') + tdSql.error('create table testsensitivet(ts timestamp, i int)') + tdSql.error('create table testsensitivet(ts timestamp, j int)') + tdSql.error('create table testsensItivet(ts timestamp, j int)') + tdSql.error('create table TESTSENSITIVET(ts timestamp, i int)') + tdLog.info('=============== step3') + tdLog.info('test super table ') + tdSql.error('create table testsensitivest(ts timestamp,i int) tags(j int)') + tdSql.error('create table testsensitivest(ts timestamp,i int) tags(k int)') + tdSql.error('create table TESTSENSITIVEST(ts timestamp,i int) tags(j int)') + tdSql.error('create table Testsensitivest(ts timestamp,i int) tags(j int)') + tdLog.info('=============== step4') + tdLog.info('test subtable ') + tdSql.error('create table abcdefgh using TestSensitiveSt tags(1)') + tdSql.error('create table ABCDEFGH using TestSensitiveSt tags(1)') + tdSql.error('create table Abcdefgh using TestSensitiveSt tags(1)') + tdSql.error('create table abcdeFgh using TestSensitiveSt tags(1)') + tdSql.error('insert into table abcdefgh using TestSensitiveSt tags(1) values(now,1)') + tdSql.error('insert into table ABCDEFGH using TestSensitiveSt tags(1) values(now,1)') + tdSql.error('insert into table Abcdefgh using TestSensitiveSt tags(1) values(now,1)') + tdSql.error('insert into table abcdeFgH using TestSensitiveSt tags(1) values(now,1)') + tdSql.query('show tables') + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(2) + + + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/table/db_table.py b/tests/pytest/table/db_table.py new file mode 100644 index 0000000000000000000000000000000000000000..5ead829e26e8e6a64fdb28af6ad34499663df7b2 --- /dev/null +++ b/tests/pytest/table/db_table.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdLog.info('=============== step1') + tdLog.info('=============== step2') + tdLog.info('create table tb (ts timestamp, speed int)') + tdSql.execute('create table tb (ts timestamp, speed int)') + tdLog.info('=============== step3') + tdLog.info("insert into tb values (now, 1)") + tdSql.execute("insert into tb values (now, 1)") + tdLog.info('=============== step4') + tdLog.info('select * from tb') + tdSql.query('select * from tb') + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + tdLog.info('=============== step5') + tdLog.info('describe tb') + tdSql.query('describe tb') + tdLog.info('=============== step6') + tdLog.info('drop database db') + tdSql.execute('drop database db') + tdLog.info('show databases') + tdSql.query('show databases') + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/table/del_stable.py b/tests/pytest/table/del_stable.py new file mode 100644 index 0000000000000000000000000000000000000000..1b078ac519df1e364e394c2b2fdd83e1ea424ca9 --- /dev/null +++ b/tests/pytest/table/del_stable.py @@ -0,0 +1,49 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + print("==============step1") + tdSql.execute("create table db.st (ts timestamp, i int) tags(j int)") + tdSql.execute("create table db.tb using st tags(1)") + tdSql.execute("insert into db.tb values(now, 1)") + + print("==============step2") + try: + tdSql.execute("drop table db.st") + except Exception as e: + tdLog.exit(e) + + tdSql.error("select * from db.st") + tdSql.error("select * from db.tb") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/table/max_table_length.py b/tests/pytest/table/max_table_length.py new file mode 100644 index 0000000000000000000000000000000000000000..366e20456ddbf71eabe7ff64c8d0597c3d5b5f6e --- /dev/null +++ b/tests/pytest/table/max_table_length.py @@ -0,0 +1,55 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, db_test.stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + print("==============step1") + + tdLog.info("check nchar") + tdSql.error("create database anal (ts timestamp ,i nchar(4094))") + tdSql.execute( + "create table anal (ts timestamp ,i nchar(4093))") + + print("==============step2") + tdLog.info("check binary") + tdSql.error("create database anal (ts timestamp ,i binary(16375))") + tdSql.execute( + "create table anal1 (ts timestamp ,i binary(16374))") + + print("==============step3") + tdLog.info("check int & binary") + # tdSql.error("create table anal2 (ts timestamp ,i binary(16371),j int)") + tdSql.execute("create table anal2 (ts timestamp ,i binary(16370),j int)") + tdSql.execute("create table anal3 (ts timestamp ,i binary(16366), j int, k int)") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/table/tablename-boundary.py b/tests/pytest/table/tablename-boundary.py new file mode 100644 index 0000000000000000000000000000000000000000..dc22c3343b403a93587b7f626061caa62fbf30d1 --- /dev/null +++ b/tests/pytest/table/tablename-boundary.py @@ -0,0 +1,97 @@ +# -*- coding: utf-8 -*- + +import sys +import string +import random +import subprocess +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.ts = 1622100000000 + + def get_random_string(self, length): + letters = string.ascii_lowercase + result_str = ''.join(random.choice(letters) for i in range(length)) + return result_str + + def run(self): + tdSql.prepare() + + getTableNameLen = "grep -w '#define TSDB_TABLE_NAME_LEN' ../../src/inc/taosdef.h|awk '{print $3}'" + tableNameMaxLen = int( + subprocess.check_output( + getTableNameLen, + shell=True)) - 1 + tdLog.info("table name max length is %d" % tableNameMaxLen) + chars = string.ascii_uppercase + string.ascii_lowercase + tb_name = ''.join(random.choices(chars, k=tableNameMaxLen + 1)) + tdLog.info('tb_name length %d' % len(tb_name)) + tdLog.info('create table %s (ts timestamp, value int)' % tb_name) + tdSql.error('create table %s (ts timestamp, speed binary(4089))' % tb_name) + + tb_name = ''.join(random.choices(chars, k=tableNameMaxLen)) + tdLog.info('tb_name length %d' % len(tb_name)) + tdLog.info('create table %s (ts timestamp, value int)' % tb_name) + tdSql.execute( + 'create table %s (ts timestamp, speed binary(4089))' % + tb_name) + + db_name = self.get_random_string(33) + tdSql.error("create database %s" % db_name) + + db_name = self.get_random_string(32) + tdSql.execute("create database %s" % db_name) + tdSql.execute("use %s" % db_name) + + tb_name = self.get_random_string(193) + tdSql.error("create table %s(ts timestamp, val int)" % tb_name) + + tb_name = self.get_random_string(192) + tdSql.execute("create table %s.%s(ts timestamp, val int)" % (db_name, tb_name)) + tdSql.query("show %s.tables" % db_name) + tdSql.checkRows(1) + tdSql.checkData(0, 0, tb_name) + + tdSql.execute("insert into %s.%s values(now, 1)" % (db_name, tb_name)) + tdSql.query("select * from %s.%s" %(db_name, tb_name)) + tdSql.checkRows(1) + + db_name = self.get_random_string(32) + tdSql.execute("create database %s update 1" % db_name) + + stb_name = self.get_random_string(192) + tdSql.execute("create table %s.%s(ts timestamp, val int) tags(id int)" % (db_name, stb_name)) + tb_name1 = self.get_random_string(192) + tdSql.execute("insert into %s.%s using %s.%s tags(1) values(%d, 1)(%d, 2)(%d, 3)" % (db_name, tb_name1, db_name, stb_name, self.ts, self.ts + 1, self.ts + 2)) + tb_name2 = self.get_random_string(192) + tdSql.execute("insert into %s.%s using %s.%s tags(2) values(%d, 1)(%d, 2)(%d, 3)" % (db_name, tb_name2, db_name, stb_name, self.ts, self.ts + 1, self.ts + 2)) + + tdSql.query("show %s.tables" % db_name) + tdSql.checkRows(2) + + tdSql.query("select * from %s.%s" % (db_name, stb_name)) + tdSql.checkRows(6) + + tdSql.execute("insert into %s.%s using %s.%s tags(1) values(%d, null)" % (db_name, tb_name1, db_name, stb_name, self.ts)) + + tdSql.query("select * from %s.%s" % (db_name, stb_name)) + tdSql.checkRows(6) + + + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/3.py b/tests/pytest/tag_lite/3.py new file mode 100644 index 0000000000000000000000000000000000000000..bbdf0868fae6d465525dbe7191172b4145b53f80 --- /dev/null +++ b/tests/pytest/tag_lite/3.py @@ -0,0 +1,1332 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + dbPrefix = "ta_3_db" + tbPrefix = "ta_3_tb" + mtPrefix = "ta_3_mt" + tbNum = 10 + rowNum = 20 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + i = 0 + db = "%s%d" % (dbPrefix, i) + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, + # tgcol2 int, tgcol3 float) + tdLog.info( + "create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 float)" % + mt) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 float)' % + mt) + # TSIM: + i = 0 + while (i < 5): + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using %s tags( 0, 0, 0 ) + tdLog.info("create table %s using %s tags( 0, 0, 0 )" % (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( 0, 0, 0 )' % + (tb, mt)) + + x = 0 + while (x < rowNum): + ms = x * 60000 + # TSIM: sql insert into $tb values (1605045600000 + $ms , $x ) + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + x = x + 1 + # TSIM: endw + i = i + 1 + # TSIM: endw + while (i < 10): + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using %s tags( 1, 1, 1 ) + tdLog.info("create table %s using %s tags( 1, 1, 1 )" % (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( 1, 1, 1 )' % + (tb, mt)) + x = 0 + while (x < rowNum): + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + x = x + 1 + # TSIM: endw + i = i + 1 + # TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sql select * from %s + tdLog.info('select * from %s' % mt) + tdSql.query('select * from %s' % mt) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow(%d)' % totalNum) + tdSql.checkRows(totalNum) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 + tdLog.info('select * from %s where ts < 1605045600000 + 240001' % mt) + tdSql.query('select * from %s where ts < 1605045600000 + 240001' % mt) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 + tdLog.info('select * from %s where ts > 1605045600000 + 240001' % mt) + tdSql.query('select * from %s where ts > 1605045600000 + 240001' % mt) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts = 1605045600000 + 240001 + tdLog.info('select * from %s where ts = 1605045600000 + 240001' % mt) + tdSql.query('select * from %s where ts = 1605045600000 + 240001' % mt) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + mt) + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from %s where tgcol1 = 0 + tdLog.info('select * from %s where tgcol1 = 0' % mt) + tdSql.query('select * from %s where tgcol1 = 0' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where tgcol1 <> 0 + tdLog.info('select * from %s where tgcol1 <> 0' % mt) + tdSql.query('select * from %s where tgcol1 <> 0' % mt) + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % mt) + tdSql.query('select * from %s where tgcol1 = 1' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where tgcol1 <> 1 + tdLog.info('select * from %s where tgcol1 <> 1' % mt) + tdSql.query('select * from %s where tgcol1 <> 1' % mt) + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where tgcol1 = true + tdLog.info('select * from %s where tgcol1 = true' % mt) + tdSql.query('select * from %s where tgcol1 = true' % mt) + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where tgcol1 <> true + tdLog.info('select * from %s where tgcol1 <> true' % mt) + tdSql.query('select * from %s where tgcol1 <> true' % mt) + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where tgcol1 = false + tdLog.info('select * from %s where tgcol1 = false' % mt) + tdSql.query('select * from %s where tgcol1 = false' % mt) + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where tgcol1 <> false + tdLog.info('select * from %s where tgcol1 <> false' % mt) + tdSql.query('select * from %s where tgcol1 <> false' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from %s where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % mt) + tdSql.query('select * from %s where tgcol2 = 0' % mt) + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where tgcol2 <> 0 + tdLog.info('select * from %s where tgcol2 <> 0' % mt) + tdSql.query('select * from %s where tgcol2 <> 0' % mt) + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where tgcol2 = 1 + tdLog.info('select * from %s where tgcol2 = 1' % mt) + tdSql.query('select * from %s where tgcol2 = 1' % mt) + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where tgcol2 <> 1 + tdLog.info('select * from %s where tgcol2 <> 1' % mt) + tdSql.query('select * from %s where tgcol2 <> 1' % mt) + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from %s where tgcol3 = 0 + tdLog.info('select * from %s where tgcol3 = 0' % mt) + tdSql.query('select * from %s where tgcol3 = 0' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where tgcol3 <> 0 + tdLog.info('select * from %s where tgcol3 <> 0' % mt) + tdSql.query('select * from %s where tgcol3 <> 0' % mt) + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where tgcol3 = 1 + tdLog.info('select * from %s where tgcol3 = 1' % mt) + tdSql.query('select * from %s where tgcol3 = 1' % mt) + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where tgcol3 <> 1 + tdLog.info('select * from %s where tgcol3 <> 1' % mt) + tdSql.query('select * from %s where tgcol3 <> 1' % mt) + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol1 = true + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 = true' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 = true' % + mt) + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> true + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> true' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> true' % + mt) + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol1 = false + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol1 = false' % + mt) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol1 = false' % + mt) + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol1 <> false + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol1 <> false' % + mt) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol1 <> false' % + mt) + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol1 = false + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol1 = false' % + mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol1 = false' % + mt) + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol1 <> false + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol1 <> false' % + mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol1 <> false' % + mt) + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol1 <> false + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol1 <> false' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol1 <> false' % + mt) + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> false + # and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> false and ts < 1605045600000 + 300001' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> false and ts < 1605045600000 + 300001' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol2 = 1 + tdLog.info('select * from %s where ts > 1605045600000 + 240001 and tgcol2 = 1' % mt) + tdSql.query('select * from %s where ts > 1605045600000 + 240001 and tgcol2 = 1' % mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 1 + tdLog.info('select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 1' % mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol2 = 0 + tdLog.info('select * from %s where ts < 1605045600000 + 240001 and tgcol2 = 0' % mt) + tdSql.query('select * from %s where ts < 1605045600000 + 240001 and tgcol2 = 0' % mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> 0 + tdLog.info('select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> 0' % mt) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = 0 + tdLog.info('select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = 0' % mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 0 and ts + # < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 0 and ts < 1605045600000 + 300001' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 0 and ts < 1605045600000 + 300001' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol3 = 1 + tdLog.info('select * from %s where ts > 1605045600000 + 240001 and tgcol3 = 1' % mt) + tdSql.query('select * from %s where ts > 1605045600000 + 240001 and tgcol3 = 1' % mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 1 + tdLog.info('select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 1' % mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol3 = 0 + tdLog.info('select * from %s where ts < 1605045600000 + 240001 and tgcol3 = 0' % mt) + tdSql.query('select * from %s where ts < 1605045600000 + 240001 and tgcol3 = 0' % mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol3 <> 0 + tdLog.info('select * from %s where ts < 1605045600000 + 240001 and tgcol3 <> 0' % mt) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol3 = 0 + tdLog.info('select * from %s where ts <= 1605045600000 + 240001 and tgcol3 = 0' % mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol3 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 0 and ts + # < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 0 and ts < 1605045600000 + 300001' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 0 and ts < 1605045600000 + 300001' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol2 = 1 and + # tgcol1 = true + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = 1 and tgcol1 = true' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = 1 and tgcol1 = true' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 1 and + # tgcol1 <> true + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 1 and tgcol1 <> true' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 1 and tgcol1 <> true' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol2 = 0 and + # tgcol1 = false + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = 0 and tgcol1 = false' % + mt) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = 0 and tgcol1 = false' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> 0 and + # tgcol1 <> false + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> 0 and tgcol1 <> false' % + mt) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> 0 and tgcol1 <> false' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = 0 and + # tgcol1 = false + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = 0 and tgcol1 = false' % + mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = 0 and tgcol1 = false' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> 0 and + # tgcol1 <> false + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> 0 and tgcol1 <> false' % + mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> 0 and tgcol1 <> false' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol2 <> 0 and tgcol1 <> false + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol1 <> false' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol1 <> false' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 0 and ts + # < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol1 <> false + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol1 <> false' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol1 <> false' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol3 = 1 and + # tgcol1 = true + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 = 1 and tgcol1 = true' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 = 1 and tgcol1 = true' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 1 and + # tgcol1 <> true + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 1 and tgcol1 <> true' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 1 and tgcol1 <> true' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol3 = 0 and + # tgcol1 = false + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 = 0 and tgcol1 = false' % + mt) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 = 0 and tgcol1 = false' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol3 <> 0 and + # tgcol1 <> false + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 <> 0 and tgcol1 <> false' % + mt) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 <> 0 and tgcol1 <> false' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol3 = 0 and + # tgcol1 = false + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 = 0 and tgcol1 = false' % + mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 = 0 and tgcol1 = false' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol3 <> 0 and + # tgcol1 <> false + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 <> 0 and tgcol1 <> false' % + mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 <> 0 and tgcol1 <> false' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol3 <> 0 and tgcol1 <> false + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol3 <> 0 and tgcol1 <> false' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol3 <> 0 and tgcol1 <> false' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 0 and ts + # < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol1 <> false + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol1 <> false' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol1 <> false' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol3 = 1 and + # tgcol2 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 = 1 and tgcol2 = 1' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 = 1 and tgcol2 = 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 1 and + # tgcol2 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 1 and tgcol2 <> 1' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 1 and tgcol2 <> 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol3 = 0 and + # tgcol2 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 = 0 and tgcol2 = 0' % + mt) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 = 0 and tgcol2 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol3 <> 0 and + # tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 <> 0 and tgcol2 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 <> 0 and tgcol2 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol3 = 0 and + # tgcol2 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 = 0 and tgcol2 = 0' % + mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 = 0 and tgcol2 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol3 <> 0 and + # tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 <> 0 and tgcol2 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 <> 0 and tgcol2 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol3 <> 0 and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol3 <> 0 and tgcol2 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol3 <> 0 and tgcol2 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 0 and ts + # < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> 1 and + # tgcol2 <> 1 and tgcol3 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol1 = 0 and + # tgcol2 = 0 and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0' % + mt) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol1 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol1 = 0 and + # tgcol2 = 0 and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0' % + mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol1 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> 0 and ts + # < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step13 + tdLog.info('=============== step13') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step14 + tdLog.info('=============== step14') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and + # tgcol2 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and tgcol2 = 1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and tgcol2 = 1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and + # tgcol2 = 1 and tgcol3 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step15 + tdLog.info('=============== step15') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and + # tgcol1 = true + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = true' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = true' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and + # tgcol1 = true and tgcol2 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = true and tgcol2 = 1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = true and tgcol2 = 1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and + # tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = true and tgcol2 = 1 and tgcol3 = 1' % mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = true and tgcol2 = 1 and tgcol3 = 1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step16 + tdLog.info('=============== step16') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol2 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol2' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol2' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol3 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol3' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol3' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step17 + tdLog.info('=============== step17') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true + # group by tgcol1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true group by tgcol1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true group by tgcol1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and + # tgcol2 = 1 group by tgcol1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and tgcol2 = 1 group by tgcol1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and tgcol2 = 1 group by tgcol1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and + # tgcol2 = 1 and tgcol3 = 1 group by tgcol1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 group by tgcol1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 group by tgcol1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step18 + tdLog.info('=============== step18') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 + # group by tgcol2 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol2' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol2' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and + # tgcol1 = true group by tgcol2 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = true group by tgcol2' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = true group by tgcol2' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and + # tgcol1 = true and tgcol2 = 1 group by tgcol2 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = true and tgcol2 = 1 group by tgcol2' % mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = true and tgcol2 = 1 group by tgcol2' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and + # tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 group by tgcol2 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 group by tgcol2' % mt) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 group by tgcol2' % mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step19 + tdLog.info('=============== step19') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and + # tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1' % mt) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1' % mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and + # tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2' % mt) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2' % mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and + # tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3' % mt) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3' % mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/4.py b/tests/pytest/tag_lite/4.py new file mode 100644 index 0000000000000000000000000000000000000000..df81dd81000c0698ea4ab1fb661d3b7f55059fbb --- /dev/null +++ b/tests/pytest/tag_lite/4.py @@ -0,0 +1,1876 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: sql reset query cache + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + dbPrefix = "ta_4_db" + tbPrefix = "ta_4_tb" + mtPrefix = "ta_4_mt" + tbNum = 10 + rowNum = 20 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + i = 0 + db = "%s%d" % (dbPrefix, i) + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table %s (ts timestamp, tbcol int) TAGS(tgcol1 + # smallint, tgcol2 bigint, tgcol3 float, tgcol4 double) + tdLog.info( + "create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 bigint, tgcol3 float, tgcol4 double)" % + mt) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 bigint, tgcol3 float, tgcol4 double)' % + mt) + # TSIM: + i = 0 + while (i < 5): + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using %s tags( 0, 0, 0, 0 ) + tdLog.info( + "create table %s using %s tags( 0, 0, 0, 0 )" % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( 0, 0, 0, 0 )' % + (tb, mt)) + x = 0 + while (x < rowNum): + ms = x * 60000 + # TSIM: sql insert into $tb values (1605045600000 + $ms , $x ) + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + x = x + 1 + # TSIM: endw + i = i + 1 + # TSIM: endw + while (i < 10): + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using %s tags( 1, 1, 1, 1 ) + tdLog.info( + "create table %s using %s tags( 1, 1, 1, 1 )" % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( 1, 1, 1, 1 )' % + (tb, mt)) + x = 0 + while (x < rowNum): + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + x = x + 1 + # TSIM: endw + i = i + 1 + # TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sql select * from %s + tdLog.info('select * from %s' % mt) + tdSql.query('select * from %s' % mt) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 + tdLog.info('select * from %s where ts < 1605045600000 + 240001' % mt) + tdSql.query('select * from %s where ts < 1605045600000 + 240001' % mt) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 + tdLog.info('select * from %s where ts > 1605045600000 + 240001' % mt) + tdSql.query('select * from %s where ts > 1605045600000 + 240001' % mt) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts = 1605045600000 + 240001 + tdLog.info('select * from %s where ts = 1605045600000 + 240001' % mt) + tdSql.query('select * from %s where ts = 1605045600000 + 240001' % mt) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + mt) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from %s where tgcol1 = 0 + tdLog.info('select * from %s where tgcol1 = 0' % mt) + tdSql.query('select * from %s where tgcol1 = 0' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where tgcol1 <> 0 + tdLog.info('select * from %s where tgcol1 <> 0' % mt) + tdSql.query('select * from %s where tgcol1 <> 0' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % mt) + tdSql.query('select * from %s where tgcol1 = 1' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where tgcol1 <> 1 + tdLog.info('select * from %s where tgcol1 <> 1' % mt) + tdSql.query('select * from %s where tgcol1 <> 1' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % mt) + tdSql.query('select * from %s where tgcol1 = 1' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where tgcol1 <> 1 + tdLog.info('select * from %s where tgcol1 <> 1' % mt) + tdSql.query('select * from %s where tgcol1 <> 1' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where tgcol1 = 0 + tdLog.info('select * from %s where tgcol1 = 0' % mt) + tdSql.query('select * from %s where tgcol1 = 0' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where tgcol1 <> 0 + tdLog.info('select * from %s where tgcol1 <> 0' % mt) + tdSql.query('select * from %s where tgcol1 <> 0' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from %s where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % mt) + tdSql.query('select * from %s where tgcol2 = 0' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where tgcol2 <> 0 + tdLog.info('select * from %s where tgcol2 <> 0' % mt) + tdSql.query('select * from %s where tgcol2 <> 0' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where tgcol2 = 1 + tdLog.info('select * from %s where tgcol2 = 1' % mt) + tdSql.query('select * from %s where tgcol2 = 1' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where tgcol2 <> 1 + tdLog.info('select * from %s where tgcol2 <> 1' % mt) + tdSql.query('select * from %s where tgcol2 <> 1' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from %s where tgcol3 = 0 + tdLog.info('select * from %s where tgcol3 = 0' % mt) + tdSql.query('select * from %s where tgcol3 = 0' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where tgcol3 <> 0 + tdLog.info('select * from %s where tgcol3 <> 0' % mt) + tdSql.query('select * from %s where tgcol3 <> 0' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where tgcol3 = 1 + tdLog.info('select * from %s where tgcol3 = 1' % mt) + tdSql.query('select * from %s where tgcol3 = 1' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where tgcol3 <> 1 + tdLog.info('select * from %s where tgcol3 <> 1' % mt) + tdSql.query('select * from %s where tgcol3 <> 1' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select * from %s where tgcol4 = 0 + tdLog.info('select * from %s where tgcol4 = 0' % mt) + tdSql.query('select * from %s where tgcol4 = 0' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where tgcol4 <> 0 + tdLog.info('select * from %s where tgcol4 <> 0' % mt) + tdSql.query('select * from %s where tgcol4 <> 0' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where tgcol4 = 1 + tdLog.info('select * from %s where tgcol4 = 1' % mt) + tdSql.query('select * from %s where tgcol4 = 1' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where tgcol4 <> 1 + tdLog.info('select * from %s where tgcol4 <> 1' % mt) + tdSql.query('select * from %s where tgcol4 <> 1' % mt) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol1 = 1 + tdLog.info('select * from %s where ts > 1605045600000 + 240001 and tgcol1 = 1' % mt) + tdSql.query('select * from %s where ts > 1605045600000 + 240001 and tgcol1 = 1' % mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> 1 + tdLog.info('select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> 1' % mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol1 = 0 + tdLog.info('select * from %s where ts < 1605045600000 + 240001 and tgcol1 = 0' % mt) + tdSql.query('select * from %s where ts < 1605045600000 + 240001 and tgcol1 = 0' % mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol1 <> 0 + tdLog.info('select * from %s where ts < 1605045600000 + 240001 and tgcol1 <> 0' % mt) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol1 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol1 = 0 + tdLog.info('select * from %s where ts <= 1605045600000 + 240001 and tgcol1 = 0' % mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol1 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol1 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol1 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol1 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol1 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> 0 and ts + # < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> 0 and ts < 1605045600000 + 300001' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> 0 and ts < 1605045600000 + 300001' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol2 = 1 + tdLog.info('select * from %s where ts > 1605045600000 + 240001 and tgcol2 = 1' % mt) + tdSql.query('select * from %s where ts > 1605045600000 + 240001 and tgcol2 = 1' % mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 1 + tdLog.info('select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 1' % mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol2 = 0 + tdLog.info('select * from %s where ts < 1605045600000 + 240001 and tgcol2 = 0' % mt) + tdSql.query('select * from %s where ts < 1605045600000 + 240001 and tgcol2 = 0' % mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> 0 + tdLog.info('select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> 0' % mt) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = 0 + tdLog.info('select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = 0' % mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 0 and ts + # < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 0 and ts < 1605045600000 + 300001' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 0 and ts < 1605045600000 + 300001' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol3 = 1 + tdLog.info('select * from %s where ts > 1605045600000 + 240001 and tgcol3 = 1' % mt) + tdSql.query('select * from %s where ts > 1605045600000 + 240001 and tgcol3 = 1' % mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 1 + tdLog.info('select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 1' % mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol3 = 0 + tdLog.info('select * from %s where ts < 1605045600000 + 240001 and tgcol3 = 0' % mt) + tdSql.query('select * from %s where ts < 1605045600000 + 240001 and tgcol3 = 0' % mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol3 <> 0 + tdLog.info('select * from %s where ts < 1605045600000 + 240001 and tgcol3 <> 0' % mt) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol3 = 0 + tdLog.info('select * from %s where ts <= 1605045600000 + 240001 and tgcol3 = 0' % mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol3 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 0 and ts + # < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 0 and ts < 1605045600000 + 300001' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 0 and ts < 1605045600000 + 300001' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol4 = 1 + tdLog.info('select * from %s where ts > 1605045600000 + 240001 and tgcol4 = 1' % mt) + tdSql.query('select * from %s where ts > 1605045600000 + 240001 and tgcol4 = 1' % mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 1 + tdLog.info('select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 1' % mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol4 = 0 + tdLog.info('select * from %s where ts < 1605045600000 + 240001 and tgcol4 = 0' % mt) + tdSql.query('select * from %s where ts < 1605045600000 + 240001 and tgcol4 = 0' % mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol4 <> 0 + tdLog.info('select * from %s where ts < 1605045600000 + 240001 and tgcol4 <> 0' % mt) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol4 = 0 + tdLog.info('select * from %s where ts <= 1605045600000 + 240001 and tgcol4 = 0' % mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol4 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol4 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 0 and ts + # < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 0 and ts < 1605045600000 + 300001' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 0 and ts < 1605045600000 + 300001' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol2 = 1 and + # tgcol1 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = 1 and tgcol1 = 1' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = 1 and tgcol1 = 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 1 and + # tgcol1 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 1 and tgcol1 <> 1' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 1 and tgcol1 <> 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol2 = 0 and + # tgcol1 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = 0 and tgcol1 = 0' % + mt) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = 0 and tgcol1 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> 0 and + # tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> 0 and tgcol1 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> 0 and tgcol1 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = 0 and + # tgcol1 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = 0 and tgcol1 = 0' % + mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = 0 and tgcol1 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> 0 and + # tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> 0 and tgcol1 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> 0 and tgcol1 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol2 <> 0 and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol1 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol1 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 0 and ts + # < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol1 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol1 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol3 = 1 and + # tgcol1 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 = 1 and tgcol1 = 1' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 = 1 and tgcol1 = 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 1 and + # tgcol1 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 1 and tgcol1 <> 1' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 1 and tgcol1 <> 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol3 = 0 and + # tgcol1 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 = 0 and tgcol1 = 0' % + mt) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 = 0 and tgcol1 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol3 <> 0 and + # tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 <> 0 and tgcol1 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 <> 0 and tgcol1 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol3 = 0 and + # tgcol1 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 = 0 and tgcol1 = 0' % + mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 = 0 and tgcol1 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol3 <> 0 and + # tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 <> 0 and tgcol1 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 <> 0 and tgcol1 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol3 <> 0 and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol3 <> 0 and tgcol1 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol3 <> 0 and tgcol1 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 0 and ts + # < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol1 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol1 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step13 + tdLog.info('=============== step13') + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol3 = 1 and + # tgcol2 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 = 1 and tgcol2 = 1' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 = 1 and tgcol2 = 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 1 and + # tgcol2 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 1 and tgcol2 <> 1' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 1 and tgcol2 <> 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol3 = 0 and + # tgcol2 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 = 0 and tgcol2 = 0' % + mt) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 = 0 and tgcol2 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol3 <> 0 and + # tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 <> 0 and tgcol2 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 <> 0 and tgcol2 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol3 = 0 and + # tgcol2 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 = 0 and tgcol2 = 0' % + mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 = 0 and tgcol2 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol3 <> 0 and + # tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 <> 0 and tgcol2 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 <> 0 and tgcol2 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol3 <> 0 and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol3 <> 0 and tgcol2 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol3 <> 0 and tgcol2 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 0 and ts + # < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step14 + tdLog.info('=============== step14') + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol3 = 1 and + # tgcol4 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 = 1 and tgcol4 = 1' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 = 1 and tgcol4 = 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 1 and + # tgcol4 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 1 and tgcol4 <> 1' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 1 and tgcol4 <> 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol3 = 0 and + # tgcol4 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 = 0 and tgcol4 = 0' % + mt) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 = 0 and tgcol4 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol3 <> 0 and + # tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 <> 0 and tgcol4 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 <> 0 and tgcol4 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol3 = 0 and + # tgcol4 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 = 0 and tgcol4 = 0' % + mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 = 0 and tgcol4 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol3 <> 0 and + # tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 <> 0 and tgcol4 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 <> 0 and tgcol4 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol3 <> 0 and tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol3 <> 0 and tgcol4 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol3 <> 0 and tgcol4 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 0 and ts + # < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol4 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol4 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step15 + tdLog.info('=============== step15') + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> 1 and + # tgcol2 <> 1 and tgcol3 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol1 = 0 and + # tgcol2 = 0 and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0' % + mt) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol1 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol1 = 0 and + # tgcol2 = 0 and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0' % + mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol1 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> 0 and ts + # < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step16 + tdLog.info('=============== step16') + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol4 = 1 and + # tgcol2 = 1 and tgcol3 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 1 and + # tgcol2 <> 1 and tgcol3 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0' % + mt) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0' % + mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 0 and ts + # < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step17 + tdLog.info('=============== step17') + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol4 = 1 and + # tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 1 and + # tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1' % + mt) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0' % + mt) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts < 1605045600000 + 240001 and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0' % + mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts <= 1605045600000 + 240001 and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + mt) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 0 and ts + # < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0 and + # tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + mt) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + mt) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step18 + tdLog.info('=============== step18') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step19 + tdLog.info('=============== step19') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and + # tgcol2 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step20 + tdLog.info('=============== step20') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and + # tgcol1 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and + # tgcol1 = 1 and tgcol2 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and + # tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and + # tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1' % mt) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1' % mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step21 + tdLog.info('=============== step21') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol2 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol2' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol2' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol3 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol3' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol3' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol4 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol4' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol4' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step22 + tdLog.info('=============== step22') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 group + # by tgcol1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 group by tgcol1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 group by tgcol1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and + # tgcol2 = 1 group by tgcol1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 group by tgcol1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 group by tgcol1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 group by tgcol1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol1' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol1' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol1 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol1' % mt) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol1' % mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step23 + tdLog.info('=============== step23') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 + # group by tgcol2 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol2' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol2' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and + # tgcol1 = 1 group by tgcol2 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 group by tgcol2' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 group by tgcol2' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and + # tgcol1 = 1 and tgcol2 = 1 group by tgcol2 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 group by tgcol2' % mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 group by tgcol2' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and + # tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol2 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol2' % mt) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol2' % mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and + # tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by + # tgcol2 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol2' % mt) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol2' % mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step24 + tdLog.info('=============== step24') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1' % mt) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1' % mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2' % mt) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2' % mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3' % mt) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3' % mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 interval(1d) group by tgcol4 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 interval(1d) group by tgcol4' % mt) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 interval(1d) group by tgcol4' % mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/5.py b/tests/pytest/tag_lite/5.py new file mode 100644 index 0000000000000000000000000000000000000000..28c8fc125a9c9f27230e63494e9d7f57c5505154 --- /dev/null +++ b/tests/pytest/tag_lite/5.py @@ -0,0 +1,2304 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: sql reset query cache + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_5_db + # TSIM: $tbPrefix = ta_5_tb + tbPrefix = "ta_5_tb" + # TSIM: $mtPrefix = ta_5_mt + mtPrefix = "ta_5_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # tinyint, tgcol2 int, tgcol3 bigint, tgcol4 double, tgcol5 binary(20)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 tinyint, tgcol2 int, tgcol3 bigint, tgcol4 double, tgcol5 binary(20))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 tinyint, tgcol2 int, tgcol3 bigint, tgcol4 double, tgcol5 binary(20))' % + (mt)) + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: while $i < 5 + while (i < 5): + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 0, 0, 0, 0, 0 ) + tdLog.info( + 'create table %s using %s tags( 0, 0, 0, 0, 0 )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( 0, 0, 0, 0, 0 )' % + (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: while $i < 10 + while (i < 10): + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 1, 1, 1, 1, 1 ) + tdLog.info( + 'create table %s using %s tags( 1, 1, 1, 1, 1 )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( 1, 1, 1, 1, 1 )' % + (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 + tdLog.info('select * from %s where ts < 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts < 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 + tdLog.info('select * from %s where ts > 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts > 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts = 1605045600000 + 240001 + tdLog.info('select * from %s where ts = 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts = 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from $mt where tgcol1 = 0 + tdLog.info('select * from %s where tgcol1 = 0' % (mt)) + tdSql.query('select * from %s where tgcol1 = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol1 <> 0 + tdLog.info('select * from %s where tgcol1 <> 0' % (mt)) + tdSql.query('select * from %s where tgcol1 <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol1 <> 1 + tdLog.info('select * from %s where tgcol1 <> 1' % (mt)) + tdSql.query('select * from %s where tgcol1 <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol1 <> 1 + tdLog.info('select * from %s where tgcol1 <> 1' % (mt)) + tdSql.query('select * from %s where tgcol1 <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol1 = 0 + tdLog.info('select * from %s where tgcol1 = 0' % (mt)) + tdSql.query('select * from %s where tgcol1 = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol1 <> 0 + tdLog.info('select * from %s where tgcol1 <> 0' % (mt)) + tdSql.query('select * from %s where tgcol1 <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 <> 0 + tdLog.info('select * from %s where tgcol2 <> 0' % (mt)) + tdSql.query('select * from %s where tgcol2 <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 1 + tdLog.info('select * from %s where tgcol2 = 1' % (mt)) + tdSql.query('select * from %s where tgcol2 = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 <> 1 + tdLog.info('select * from %s where tgcol2 <> 1' % (mt)) + tdSql.query('select * from %s where tgcol2 <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt where tgcol3 = 0 + tdLog.info('select * from %s where tgcol3 = 0' % (mt)) + tdSql.query('select * from %s where tgcol3 = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol3 <> 0 + tdLog.info('select * from %s where tgcol3 <> 0' % (mt)) + tdSql.query('select * from %s where tgcol3 <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol3 = 1 + tdLog.info('select * from %s where tgcol3 = 1' % (mt)) + tdSql.query('select * from %s where tgcol3 = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol3 <> 1 + tdLog.info('select * from %s where tgcol3 <> 1' % (mt)) + tdSql.query('select * from %s where tgcol3 <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select * from $mt where tgcol4 = 0 + tdLog.info('select * from %s where tgcol4 = 0' % (mt)) + tdSql.query('select * from %s where tgcol4 = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol4 <> 0 + tdLog.info('select * from %s where tgcol4 <> 0' % (mt)) + tdSql.query('select * from %s where tgcol4 <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol4 = 1 + tdLog.info('select * from %s where tgcol4 = 1' % (mt)) + tdSql.query('select * from %s where tgcol4 = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol4 <> 1 + tdLog.info('select * from %s where tgcol4 <> 1' % (mt)) + tdSql.query('select * from %s where tgcol4 <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select * from $mt where tgcol5 = 0 + tdLog.info('select * from %s where tgcol5 = 0' % (mt)) + tdSql.query('select * from %s where tgcol5 = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol5 <> 0 + tdLog.info('select * from %s where tgcol5 <> 0' % (mt)) + tdSql.query('select * from %s where tgcol5 <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol5 = 1 + tdLog.info('select * from %s where tgcol5 = 1' % (mt)) + tdSql.query('select * from %s where tgcol5 = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol5 <> 1 + tdLog.info('select * from %s where tgcol5 <> 1' % (mt)) + tdSql.query('select * from %s where tgcol5 <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol1 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol1 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol1 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol1 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol1 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol1 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol1 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol1 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol1 <> 0 and + # ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> 0 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> 0 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol2 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol2 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 <> 0 and + # ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 0 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 0 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol3 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol3 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol3 <> 0 and + # ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 0 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 0 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol4 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol4 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol4 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol4 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol4 <> 0 and + # ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 0 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 0 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol5 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol5 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol5 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol5 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol5 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol5 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol5 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol5 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol5 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol5 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol5 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol5 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol5 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol5 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol5 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol5 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol5 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol5 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol5 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol5 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol5 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol5 <> 0 and + # ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol5 <> 0 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol5 <> 0 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step13 + tdLog.info('=============== step13') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 = 1 and + # tgcol1 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = 1 and tgcol1 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = 1 and tgcol1 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 <> 1 and + # tgcol1 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 1 and tgcol1 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 1 and tgcol1 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol2 = 0 and + # tgcol1 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = 0 and tgcol1 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = 0 and tgcol1 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol2 <> 0 and + # tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> 0 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> 0 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol2 = 0 and + # tgcol1 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = 0 and tgcol1 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = 0 and tgcol1 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol2 <> 0 and + # tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> 0 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> 0 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol2 <> 0 and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 <> 0 and + # ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step14 + tdLog.info('=============== step14') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol3 = 1 and + # tgcol2 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 = 1 and tgcol2 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 = 1 and tgcol2 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol3 <> 1 and + # tgcol2 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 1 and tgcol2 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 1 and tgcol2 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol3 = 0 and + # tgcol2 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 = 0 and tgcol2 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 = 0 and tgcol2 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol3 <> 0 and + # tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 <> 0 and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 <> 0 and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol3 = 0 and + # tgcol2 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 = 0 and tgcol2 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 = 0 and tgcol2 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol3 <> 0 and + # tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 <> 0 and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 <> 0 and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol3 <> 0 and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol3 <> 0 and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol3 <> 0 and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol3 <> 0 and + # ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step15 + tdLog.info('=============== step15') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol3 = 1 and + # tgcol4 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 = 1 and tgcol4 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 = 1 and tgcol4 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol3 <> 1 and + # tgcol4 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 1 and tgcol4 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 1 and tgcol4 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol3 = 0 and + # tgcol4 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 = 0 and tgcol4 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 = 0 and tgcol4 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol3 <> 0 and + # tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 <> 0 and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 <> 0 and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol3 = 0 and + # tgcol4 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 = 0 and tgcol4 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 = 0 and tgcol4 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol3 <> 0 and + # tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 <> 0 and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 <> 0 and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol3 <> 0 and tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol3 <> 0 and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol3 <> 0 and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol3 <> 0 and + # ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step16 + tdLog.info('=============== step16') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol5 = 1 and + # tgcol4 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol5 = 1 and tgcol4 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol5 = 1 and tgcol4 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol5 <> 1 and + # tgcol4 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol5 <> 1 and tgcol4 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol5 <> 1 and tgcol4 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol5 = 0 and + # tgcol4 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol5 = 0 and tgcol4 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol5 = 0 and tgcol4 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol5 <> 0 and + # tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol5 <> 0 and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol5 <> 0 and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol5 = 0 and + # tgcol4 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol5 = 0 and tgcol4 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol5 = 0 and tgcol4 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol5 <> 0 and + # tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol5 <> 0 and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol5 <> 0 and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol5 <> 0 and tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol5 <> 0 and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol5 <> 0 and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol5 <> 0 and + # ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol5 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol5 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step17 + tdLog.info('=============== step17') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol1 <> 1 and + # tgcol2 <> 1 and tgcol3 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol1 = 0 and + # tgcol2 = 0 and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol1 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol1 = 0 and + # tgcol2 = 0 and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol1 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol1 <> 0 and + # ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step18 + tdLog.info('=============== step18') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol4 = 1 and + # tgcol2 = 1 and tgcol3 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol4 <> 1 and + # tgcol2 <> 1 and tgcol3 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol4 <> 0 and + # ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step19 + tdLog.info('=============== step19') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol4 = 1 and + # tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol4 <> 1 and + # tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol4 <> 0 and + # ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0 and + # tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step20 + tdLog.info('=============== step20') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol4 = 1 and + # tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 and tgcol5 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 and tgcol5 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 and tgcol5 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol4 <> 1 and + # tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 and tgcol5 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 and tgcol5 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 and tgcol5 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and + # tgcol5 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol4 <> 0 and + # ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0 and + # tgcol1 <> 0 and tgcol5 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step21 + tdLog.info('=============== step21') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step22 + tdLog.info('=============== step22') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and + # tgcol2 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1' % (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step23 + tdLog.info('=============== step23') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # and tgcol1 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # and tgcol1 = 1 and tgcol2 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1' % (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and + # tgcol5 = 1 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1' % (mt)) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1' % (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step24 + tdLog.info('=============== step24') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol2 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol2' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol2' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol3 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol3' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol3' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol4 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol4' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol4' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol5 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol5' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol5' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step25 + tdLog.info('=============== step25') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 group + # by tgcol1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 group by tgcol1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 group by tgcol1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and + # tgcol2 = 1 group by tgcol1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 group by tgcol1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 group by tgcol1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 group by tgcol1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol1 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol1' % (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by + # tgcol1 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by tgcol1' % (mt)) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by tgcol1' % (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step26 + tdLog.info('=============== step26') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # group by tgcol2 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol2' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol2' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # and tgcol1 = 1 group by tgcol2 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 group by tgcol2' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 group by tgcol2' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # and tgcol1 = 1 and tgcol2 = 1 group by tgcol2 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 group by tgcol2' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 group by tgcol2' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol2 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol2' % (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol2' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by + # tgcol2 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol2' % (mt)) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol2' % (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and + # tgcol5 = 1 group by tgcol2 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by tgcol2' % (mt)) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by tgcol2' % (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step27 + tdLog.info('=============== step27') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 interval(1d) group by tgcol4 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 interval(1d) group by tgcol4' % (mt)) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 interval(1d) group by tgcol4' % (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 interval(1d) + # group by tgcol5 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 interval(1d) group by tgcol5' % (mt)) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 interval(1d) group by tgcol5' % (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/6.py b/tests/pytest/tag_lite/6.py new file mode 100644 index 0000000000000000000000000000000000000000..5cf43f10475181202eaa901d0a7ef1d1d23e86e0 --- /dev/null +++ b/tests/pytest/tag_lite/6.py @@ -0,0 +1,2752 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: sql reset query cache + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_6_db + # TSIM: $tbPrefix = ta_6_tb + tbPrefix = "ta_6_tb" + # TSIM: $mtPrefix = ta_6_mt + mtPrefix = "ta_6_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # binary(10), tgcol2 bigint, tgcol3 smallint, tgcol4 bigint, tgcol5 + # binary(30), tgcol6 binary(20)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 bigint, tgcol3 smallint, tgcol4 bigint, tgcol5 binary(30), tgcol6 binary(20))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 bigint, tgcol3 smallint, tgcol4 bigint, tgcol5 binary(30), tgcol6 binary(20))' % + (mt)) + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: while $i < 5 + while (i < 5): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( '0', 0, 0, 0, '0', '0' + # ) + tdLog.info( + 'create table %s using %s tags( "0", 0, 0, 0, "0", "0" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( "0", 0, 0, 0, "0", "0" )' % + (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: while $i < 10 + while (i < 10): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( '1', 1, 1, 1, '1', '1' + # ) + tdLog.info( + 'create table %s using %s tags( "1", 1, 1, 1, "1", "1" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( "1", 1, 1, 1, "1", "1" )' % + (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 + tdLog.info('select * from %s where ts < 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts < 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 + tdLog.info('select * from %s where ts > 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts > 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts = 1605045600000 + 240001 + tdLog.info('select * from %s where ts = 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts = 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from $mt where tgcol1 = 0 + tdLog.info('select * from %s where tgcol1 = 0' % (mt)) + tdSql.query('select * from %s where tgcol1 = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol1 <> 0 + tdLog.info('select * from %s where tgcol1 <> 0' % (mt)) + tdSql.query('select * from %s where tgcol1 <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol1 <> 1 + tdLog.info('select * from %s where tgcol1 <> 1' % (mt)) + tdSql.query('select * from %s where tgcol1 <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol1 <> 1 + tdLog.info('select * from %s where tgcol1 <> 1' % (mt)) + tdSql.query('select * from %s where tgcol1 <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol1 = 0 + tdLog.info('select * from %s where tgcol1 = 0' % (mt)) + tdSql.query('select * from %s where tgcol1 = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol1 <> 0 + tdLog.info('select * from %s where tgcol1 <> 0' % (mt)) + tdSql.query('select * from %s where tgcol1 <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 <> 0 + tdLog.info('select * from %s where tgcol2 <> 0' % (mt)) + tdSql.query('select * from %s where tgcol2 <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 1 + tdLog.info('select * from %s where tgcol2 = 1' % (mt)) + tdSql.query('select * from %s where tgcol2 = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 <> 1 + tdLog.info('select * from %s where tgcol2 <> 1' % (mt)) + tdSql.query('select * from %s where tgcol2 <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt where tgcol3 = 0 + tdLog.info('select * from %s where tgcol3 = 0' % (mt)) + tdSql.query('select * from %s where tgcol3 = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol3 <> 0 + tdLog.info('select * from %s where tgcol3 <> 0' % (mt)) + tdSql.query('select * from %s where tgcol3 <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol3 = 1 + tdLog.info('select * from %s where tgcol3 = 1' % (mt)) + tdSql.query('select * from %s where tgcol3 = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol3 <> 1 + tdLog.info('select * from %s where tgcol3 <> 1' % (mt)) + tdSql.query('select * from %s where tgcol3 <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select * from $mt where tgcol4 = 0 + tdLog.info('select * from %s where tgcol4 = 0' % (mt)) + tdSql.query('select * from %s where tgcol4 = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol4 <> 0 + tdLog.info('select * from %s where tgcol4 <> 0' % (mt)) + tdSql.query('select * from %s where tgcol4 <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol4 = 1 + tdLog.info('select * from %s where tgcol4 = 1' % (mt)) + tdSql.query('select * from %s where tgcol4 = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol4 <> 1 + tdLog.info('select * from %s where tgcol4 <> 1' % (mt)) + tdSql.query('select * from %s where tgcol4 <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select * from $mt where tgcol5 = 0 + tdLog.info('select * from %s where tgcol5 = 0' % (mt)) + tdSql.query('select * from %s where tgcol5 = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol5 <> 0 + tdLog.info('select * from %s where tgcol5 <> 0' % (mt)) + tdSql.query('select * from %s where tgcol5 <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol5 = 1 + tdLog.info('select * from %s where tgcol5 = 1' % (mt)) + tdSql.query('select * from %s where tgcol5 = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol5 <> 1 + tdLog.info('select * from %s where tgcol5 <> 1' % (mt)) + tdSql.query('select * from %s where tgcol5 <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select * from $mt where tgcol6 = 0 + tdLog.info('select * from %s where tgcol6 = 0' % (mt)) + tdSql.query('select * from %s where tgcol6 = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol6 <> 0 + tdLog.info('select * from %s where tgcol6 <> 0' % (mt)) + tdSql.query('select * from %s where tgcol6 <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol6 = 1 + tdLog.info('select * from %s where tgcol6 = 1' % (mt)) + tdSql.query('select * from %s where tgcol6 = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol6 <> 1 + tdLog.info('select * from %s where tgcol6 <> 1' % (mt)) + tdSql.query('select * from %s where tgcol6 <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol1 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol1 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol1 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol1 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol1 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol1 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol1 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol1 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol1 <> 0 and + # ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> 0 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> 0 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol2 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol2 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 <> 0 and + # ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 0 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 0 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol3 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol3 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol3 <> 0 and + # ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 0 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 0 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol4 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol4 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol4 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol4 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol4 <> 0 and + # ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 0 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 0 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step13 + tdLog.info('=============== step13') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol5 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol5 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol5 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol5 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol5 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol5 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol5 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol5 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol5 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol5 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol5 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol5 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol5 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol5 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol5 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol5 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol5 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol5 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol5 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol5 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol5 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol5 <> 0 and + # ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol5 <> 0 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol5 <> 0 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step14 + tdLog.info('=============== step14') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol6 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol6 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol6 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol6 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol6 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol6 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol6 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol6 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol6 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol6 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol6 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol6 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol6 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol6 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol6 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol6 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol6 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol6 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol6 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol6 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol6 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol6 <> 0 and + # ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol6 <> 0 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol6 <> 0 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step15 + tdLog.info('=============== step15') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 = 1 and + # tgcol1 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = 1 and tgcol1 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = 1 and tgcol1 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 <> 1 and + # tgcol1 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 1 and tgcol1 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 1 and tgcol1 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol2 = 0 and + # tgcol1 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = 0 and tgcol1 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = 0 and tgcol1 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol2 <> 0 and + # tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> 0 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> 0 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol2 = 0 and + # tgcol1 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = 0 and tgcol1 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = 0 and tgcol1 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol2 <> 0 and + # tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> 0 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> 0 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol2 <> 0 and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 <> 0 and + # ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step16 + tdLog.info('=============== step16') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol3 = 1 and + # tgcol2 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 = 1 and tgcol2 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 = 1 and tgcol2 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol3 <> 1 and + # tgcol2 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 1 and tgcol2 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 1 and tgcol2 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol3 = 0 and + # tgcol2 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 = 0 and tgcol2 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 = 0 and tgcol2 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol3 <> 0 and + # tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 <> 0 and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 <> 0 and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol3 = 0 and + # tgcol2 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 = 0 and tgcol2 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 = 0 and tgcol2 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol3 <> 0 and + # tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 <> 0 and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 <> 0 and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol3 <> 0 and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol3 <> 0 and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol3 <> 0 and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol3 <> 0 and + # ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step17 + tdLog.info('=============== step17') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol3 = 1 and + # tgcol4 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 = 1 and tgcol4 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 = 1 and tgcol4 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol3 <> 1 and + # tgcol4 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 1 and tgcol4 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 1 and tgcol4 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol3 = 0 and + # tgcol4 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 = 0 and tgcol4 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 = 0 and tgcol4 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol3 <> 0 and + # tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 <> 0 and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol3 <> 0 and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol3 = 0 and + # tgcol4 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 = 0 and tgcol4 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 = 0 and tgcol4 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol3 <> 0 and + # tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 <> 0 and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol3 <> 0 and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol3 <> 0 and tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol3 <> 0 and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol3 <> 0 and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol3 <> 0 and + # ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol3 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step18 + tdLog.info('=============== step18') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol5 = 1 and + # tgcol4 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol5 = 1 and tgcol4 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol5 = 1 and tgcol4 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol5 <> 1 and + # tgcol4 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol5 <> 1 and tgcol4 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol5 <> 1 and tgcol4 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol5 = 0 and + # tgcol4 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol5 = 0 and tgcol4 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol5 = 0 and tgcol4 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol5 <> 0 and + # tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol5 <> 0 and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol5 <> 0 and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol5 = 0 and + # tgcol4 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol5 = 0 and tgcol4 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol5 = 0 and tgcol4 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol5 <> 0 and + # tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol5 <> 0 and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol5 <> 0 and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol5 <> 0 and tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol5 <> 0 and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol5 <> 0 and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol5 <> 0 and + # ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol4 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol5 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol4 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol5 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol4 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step19 + tdLog.info('=============== step19') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol5 = 1 and + # tgcol6 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol5 = 1 and tgcol6 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol5 = 1 and tgcol6 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol5 <> 1 and + # tgcol6 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol5 <> 1 and tgcol6 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol5 <> 1 and tgcol6 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol5 = 0 and + # tgcol6 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol5 = 0 and tgcol6 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol5 = 0 and tgcol6 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol5 <> 0 and + # tgcol6 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol5 <> 0 and tgcol6 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol5 <> 0 and tgcol6 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol5 = 0 and + # tgcol6 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol5 = 0 and tgcol6 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol5 = 0 and tgcol6 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol5 <> 0 and + # tgcol6 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol5 <> 0 and tgcol6 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol5 <> 0 and tgcol6 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol5 <> 0 and tgcol6 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol5 <> 0 and tgcol6 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol5 <> 0 and tgcol6 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol5 <> 0 and + # ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol6 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol5 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol6 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol5 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol6 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step20 + tdLog.info('=============== step20') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol1 <> 1 and + # tgcol2 <> 1 and tgcol3 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol1 = 0 and + # tgcol2 = 0 and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol1 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol1 = 0 and + # tgcol2 = 0 and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol1 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol1 <> 0 and + # ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol1 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step21 + tdLog.info('=============== step21') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol4 = 1 and + # tgcol2 = 1 and tgcol3 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol4 <> 1 and + # tgcol2 <> 1 and tgcol3 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol4 <> 0 and + # ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step22 + tdLog.info('=============== step22') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol4 = 1 and + # tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol4 <> 1 and + # tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol4 <> 0 and + # ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0 and + # tgcol1 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step23 + tdLog.info('=============== step23') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol4 = 1 and + # tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 and tgcol5 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 and tgcol5 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 and tgcol5 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol4 <> 1 and + # tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 and tgcol5 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 and tgcol5 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 and tgcol5 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and + # tgcol5 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol4 <> 0 and + # ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0 and + # tgcol1 <> 0 and tgcol5 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step24 + tdLog.info('=============== step24') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol4 = 1 and + # tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 and tgcol5 = 1 and tgcol6 = + # 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 and tgcol5 = 1 and tgcol6 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 and tgcol5 = 1 and tgcol6 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol4 <> 1 and + # tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 and tgcol5 <> 1 and + # tgcol6 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 and tgcol5 <> 1 and tgcol6 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 and tgcol5 <> 1 and tgcol6 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 and tgcol6 = + # 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 and tgcol6 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 and tgcol6 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and + # tgcol6 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and tgcol6 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and tgcol6 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol4 = 0 and + # tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 and tgcol6 = + # 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 and tgcol6 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 and tgcol6 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol4 <> 0 and + # tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and + # tgcol6 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and tgcol6 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and tgcol6 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and + # tgcol5 <> 0 and tgcol6 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and tgcol6 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and tgcol6 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol4 <> 0 and + # ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0 and + # tgcol1 <> 0 and tgcol5 <> 0 and tgcol6 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and tgcol6 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol4 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and tgcol6 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step25 + tdLog.info('=============== step25') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step26 + tdLog.info('=============== step26') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and + # tgcol2 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1' % (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 + # = 1 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1' % (mt)) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1' % (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step27 + tdLog.info('=============== step27') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # and tgcol1 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # and tgcol1 = 1 and tgcol2 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1' % (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and + # tgcol5 = 1 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1' % (mt)) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1' % (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and + # tgcol5 = 1 and tgcol6 = 1 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1' % (mt)) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1' % (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step28 + tdLog.info('=============== step28') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol2 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol2' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol2' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol3 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol3' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol3' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol4 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol4' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol4' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol5 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol5' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol5' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol6 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol6' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol6' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step29 + tdLog.info('=============== step29') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 group + # by tgcol1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 group by tgcol1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 group by tgcol1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and + # tgcol2 = 1 group by tgcol1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 group by tgcol1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 group by tgcol1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 group by tgcol1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol1 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol1' % (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by + # tgcol1 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by tgcol1' % (mt)) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by tgcol1' % (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = + # 1 group by tgcol1 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 group by tgcol1' % (mt)) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 group by tgcol1' % (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step30 + tdLog.info('=============== step30') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # group by tgcol2 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol2' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol2' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # and tgcol1 = 1 group by tgcol2 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 group by tgcol2' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 group by tgcol2' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # and tgcol1 = 1 and tgcol2 = 1 group by tgcol2 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 group by tgcol2' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 group by tgcol2' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol2 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol2' % (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol2' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by + # tgcol2 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol2' % (mt)) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol2' % (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and + # tgcol5 = 1 group by tgcol2 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by tgcol2' % (mt)) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by tgcol2' % (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and + # tgcol5 = 1 and tgcol6 = 1 group by tgcol2 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 group by tgcol2' % (mt)) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 group by tgcol2' % (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step31 + tdLog.info('=============== step31') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 interval(1d) group by tgcol4 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 interval(1d) group by tgcol4' % (mt)) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 interval(1d) group by tgcol4' % (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 interval(1d) + # group by tgcol5 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 interval(1d) group by tgcol5' % (mt)) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 interval(1d) group by tgcol5' % (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and + # tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 + # = 1 interval(1d) group by tgcol6 + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 interval(1d) group by tgcol6' % (mt)) + tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 interval(1d) group by tgcol6' % (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/TestModifyTag.py b/tests/pytest/tag_lite/TestModifyTag.py new file mode 100644 index 0000000000000000000000000000000000000000..acf63695f6dcc52d2ae9df8cdead96802cd1f4b3 --- /dev/null +++ b/tests/pytest/tag_lite/TestModifyTag.py @@ -0,0 +1,125 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.ts = 1625068800000000000 # this is timestamp "2021-07-01 00:00:00" + self.numberOfTables = 10 + self.numberOfRecords = 100 + + def checkCommunity(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + if ("community" in selfPath): + return False + else: + return True + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosdump" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + + + def run(self): + + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosdump not found!") + else: + tdLog.info("taosdump found in %s" % buildPath) + binPath = buildPath + "/build/bin/" + + # basic test for alter tags + tdSql.execute("create database tagdb ") + tdSql.execute(" use tagdb") + tdSql.execute("create table st (ts timestamp , a int) tags (tg1 binary(20), tg2 binary(20), tg3 binary(20))") + tdSql.execute("insert into t using st (tg3, tg2, tg1) tags ('tg3', 'tg2', 'tg1') values (now, 1)") + tdSql.execute("alter table t set tag tg1='newtg1'") + res = tdSql.getResult("select tg1,tg2,tg3 from t") + + if res == [('newtg1', 'tg2', 'tg3')]: + tdLog.info(" alter tag check has pass!") + else: + tdLog.info(" alter tag failed , please check !") + + tdSql.error("alter stable st modify tag tg2 binary(2)") + tdSql.execute("alter stable st modify tag tg2 binary(30) ") + tdSql.execute("alter table t set tag tg2 = 'abcdefghijklmnopqrstuvwxyz1234'") + res = tdSql.getResult("select tg1,tg2,tg3 from t") + if res == [('newtg1', 'abcdefghijklmnopqrstuvwxyz1234', 'tg3')]: + tdLog.info(" alter tag check has pass!") + else: + tdLog.info(" alter tag failed , please check !") + + # test boundary about tags + tdSql.execute("create stable stb1 (ts timestamp , a int) tags (tg1 binary(16374))") + tdSql.error("create stable stb1 (ts timestamp , a int) tags (tg1 binary(16375))") + bound_sql = "create stable stb2 (ts timestamp , a int) tags (tg1 binary(10)," + for i in range(127): + bound_sql+="tag"+str(i)+" binary(10)," + sql1 = bound_sql[:-1]+")" + tdSql.execute(sql1) + sql2 = bound_sql[:-1]+"tag127 binary(10))" + tdSql.error(sql2) + tdSql.execute("create stable stb3 (ts timestamp , a int) tags (tg1 nchar(4093))") + tdSql.error("create stable stb3 (ts timestamp , a int) tags (tg1 nchar(4094))") + tdSql.execute("create stable stb4 (ts timestamp , a int) tags (tg1 nchar(4093),tag2 binary(8))") + tdSql.error("create stable stb4 (ts timestamp , a int) tags (tg1 nchar(4093),tag2 binary(9))") + tdSql.execute("create stable stb5 (ts timestamp , a int) tags (tg1 nchar(4093),tag2 binary(4),tag3 binary(2))") + tdSql.error("create stable stb5 (ts timestamp , a int) tags (tg1 nchar(4093),tag2 binary(4),tag3 binary(3))") + + tdSql.execute("create table stt (ts timestamp , a binary(100)) tags (tg1 binary(20), tg2 binary(20), tg3 binary(20))") + tdSql.execute("insert into tt using stt (tg3, tg2, tg1) tags ('tg3', 'tg2', 'tg1') values (now, 1)") + tags = "t"*16337 + sql3 = "alter table tt set tag tg1=" +"'"+tags+"'" + tdSql.error(sql3) + tdSql.execute("alter stable stt modify tag tg1 binary(16337)") + tdSql.execute(sql3) + res = tdSql.getResult("select tg1,tg2,tg3 from tt") + if res == [(tags, 'tg2', 'tg3')]: + tdLog.info(" alter tag check has pass!") + else: + tdLog.info(" alter tag failed , please check !") + + os.system("rm -rf ./tag_lite/TestModifyTag.py.sql") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/tag_lite/__init__.py b/tests/pytest/tag_lite/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/pytest/tag_lite/add.py b/tests/pytest/tag_lite/add.py new file mode 100644 index 0000000000000000000000000000000000000000..eb52e9cb9b8f595d77e4d816c2fb2c1317501cfb --- /dev/null +++ b/tests/pytest/tag_lite/add.py @@ -0,0 +1,2076 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_ad_db + # TSIM: $tbPrefix = ta_ad_tb + tbPrefix = "ta_ad_tb" + # TSIM: $mtPrefix = ta_ad_mt + mtPrefix = "ta_ad_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: $i = 2 + i = 2 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bool, tgcol2 int) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt add tag tgcol4 int + tdLog.info('alter table %s add tag tgcol4 int' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 int' % (mt)) + tdLog.info('select * from %s where tgcol4=6' % (mt)) + tdSql.query('select * from %s where tgcol4=6' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4 =4 + tdLog.info('alter table %s set tag tgcol4 =4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4 =4' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 4 + tdLog.info('select * from %s where tgcol4 = 4' % (mt)) + tdSql.query('select * from %s where tgcol4 = 4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step2 + tdLog.info('select * from %s where tgcol2 = 1 -x step2' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) + tdLog.info('=============== step2-1') + # TSIM: $i = 2 + i = 21 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bool, tgcol2 int) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int unsigned)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int unsigned)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt add tag tgcol4 int + tdLog.info('alter table %s add tag tgcol4 int unsigned' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 int unsigned' % (mt)) + tdLog.info('select * from %s where tgcol4=6' % (mt)) + tdSql.query('select * from %s where tgcol4=6' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4 =4 + tdLog.info('alter table %s set tag tgcol4 =4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4 =4' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 4 + tdLog.info('select * from %s where tgcol4 = 4' % (mt)) + tdSql.query('select * from %s where tgcol4 = 4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step2 + tdLog.info('select * from %s where tgcol2 = 1 -x step2' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step2: + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: $i = 3 + i = 3 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # smallint, tgcol2 tinyint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt add tag tgcol4 tinyint + tdLog.info('alter table %s add tag tgcol4 tinyint' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 tinyint' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=4 + tdLog.info('alter table %s set tag tgcol4=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=4' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 4 + tdLog.info('select * from %s where tgcol4 = 4' % (mt)) + tdSql.query('select * from %s where tgcol4 = 4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step3 + tdLog.info('select * from %s where tgcol2 = 1 -x step3' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) + tdLog.info('=============== step3-1') + # TSIM: $i = 3 + i = 31 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # smallint, tgcol2 tinyint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint unsigned, tgcol2 tinyint unsigned)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint unsigned, tgcol2 tinyint unsigned)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt add tag tgcol4 tinyint + tdLog.info('alter table %s add tag tgcol4 tinyint unsigned' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 tinyint unsigned' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=4 + tdLog.info('alter table %s set tag tgcol4=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=4' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 4 + tdLog.info('select * from %s where tgcol4 = 4' % (mt)) + tdSql.query('select * from %s where tgcol4 = 4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step3 + tdLog.info('select * from %s where tgcol2 = 1 -x step3' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step3: + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: $i = 4 + i = 4 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bigint, tgcol2 float) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2.00000 then + tdLog.info('tdSql.checkData(0, 3, 2.00000)') + tdSql.checkData(0, 3, 2.00000) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql describe $tb + tdLog.info('describe %s' % (tb)) + tdSql.query('describe %s' % (tb)) + # TSIM: if $data21 != BIGINT then + tdLog.info('tdSql.checkDataType(2, 1, "BIGINT")') + tdSql.checkDataType(2, 1, "BIGINT") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data31 != FLOAT then + tdLog.info('tdSql.checkDataType(3, 1, "FLOAT")') + tdSql.checkDataType(3, 1, "FLOAT") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data23 != 1 then + tdLog.info('tdSql.checkData(2, 3, TAG)') + tdSql.checkData(2, 3, "TAG") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data33 != 2.000000 then + tdLog.info('tdSql.checkData(3, 3, 2.000000)') + tdSql.checkData(3, 3, "TAG") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt add tag tgcol4 float + tdLog.info('alter table %s add tag tgcol4 float' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 float' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=4 + tdLog.info('alter table %s set tag tgcol4=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=4' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 4 + tdLog.info('select * from %s where tgcol4 = 4' % (mt)) + tdSql.query('select * from %s where tgcol4 = 4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 4.00000 then + tdLog.info('tdSql.checkData(0, 3, 4.00000)') + tdSql.checkData(0, 3, 4.00000) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step4 + tdLog.info('select * from %s where tgcol2 = 1 -x step4' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) + tdLog.info('=============== step4-1') + # TSIM: $i = 4 + i = 41 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bigint, tgcol2 float) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bigint unsigned, tgcol2 float)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bigint unsigned, tgcol2 float)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2.00000 then + tdLog.info('tdSql.checkData(0, 3, 2.00000)') + tdSql.checkData(0, 3, 2.00000) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql describe $tb + tdLog.info('describe %s' % (tb)) + tdSql.query('describe %s' % (tb)) + # TSIM: if $data21 != BIGINT then + tdLog.info('tdSql.checkDataType(2, 1, "BIGINT UNSIGNED")') + tdSql.checkDataType(2, 1, "BIGINT") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data31 != FLOAT then + tdLog.info('tdSql.checkDataType(3, 1, "FLOAT")') + tdSql.checkDataType(3, 1, "FLOAT") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data23 != 1 then + tdLog.info('tdSql.checkData(2, 3, TAG)') + tdSql.checkData(2, 3, "TAG") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data33 != 2.000000 then + tdLog.info('tdSql.checkData(3, 3, 2.000000)') + tdSql.checkData(3, 3, "TAG") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt add tag tgcol4 float + tdLog.info('alter table %s add tag tgcol4 float' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 float' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=4 + tdLog.info('alter table %s set tag tgcol4=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=4' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 4 + tdLog.info('select * from %s where tgcol4 = 4' % (mt)) + tdSql.query('select * from %s where tgcol4 = 4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 4.00000 then + tdLog.info('tdSql.checkData(0, 3, 4.00000)') + tdSql.checkData(0, 3, 4.00000) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step4 + tdLog.info('select * from %s where tgcol2 = 1 -x step4' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step4: + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: $i = 5 + i = 5 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # double, tgcol2 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, '2' ) + tdLog.info('create table %s using %s tags( 1, "2" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, "2" )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = '2' + tdLog.info('select * from %s where tgcol2 = "2"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "2"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1.000000000 then + tdLog.info('tdSql.checkData(0, 2, 1.000000000)') + tdSql.checkData(0, 2, 1.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, "2") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt add tag tgcol4 smallint + tdLog.info('alter table %s add tag tgcol4 smallint' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 smallint' % (mt)) + # TSIM: sql alter table $mt add tag tgcol5 smallint unsigned + tdLog.info('alter table %s add tag tgcol5 smallint unsigned' % (mt)) + tdSql.execute('alter table %s add tag tgcol5 smallint unsigned' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=4 + tdLog.info('alter table %s set tag tgcol4=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=4' % (tb)) + # TSIM: sql alter table $tb set tag tgcol5=5 + tdLog.info('alter table %s set tag tgcol5=5' % (tb)) + tdSql.execute('alter table %s set tag tgcol5=5' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 4 + tdLog.info('select * from %s where tgcol4 = 4' % (mt)) + tdSql.query('select * from %s where tgcol4 = 4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1.000000000 then + tdLog.info('tdSql.checkData(0, 2, 1.000000000)') + tdSql.checkData(0, 2, 1.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + tdSql.query('select * from %s where tgcol5 = 5' % (mt)) + tdSql.checkRows(1) + tdSql.checkData(0, 1, 1) + tdSql.checkData(0, 2, 1.000000000) + tdSql.checkData(0, 4, 5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol3 = '1' -x step5 + tdLog.info('select * from %s where tgcol3 = "1" -x step5' % (mt)) + tdSql.error('select * from %s where tgcol3 = "1"' % (mt)) + # TSIM: return -1 + # TSIM: step5: + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: $i = 6 + i = 6 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bool, tgcol2 int, tgcol3 tinyint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 tinyint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 tinyint)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, 3 ) + tdLog.info('create table %s using %s tags( 1, 2, 3 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2, 3 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, 3) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt change tag tgcol1 tgcol4 + tdLog.info('alter table %s change tag tgcol1 tgcol4' % (mt)) + tdSql.execute('alter table %s change tag tgcol1 tgcol4' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt add tag tgcol5 binary(10) + tdLog.info('alter table %s add tag tgcol5 binary(10)' % (mt)) + tdSql.execute('alter table %s add tag tgcol5 binary(10)' % (mt)) + # TSIM: sql alter table $mt add tag tgcol6 binary(10) + tdLog.info('alter table %s add tag tgcol6 binary(10)' % (mt)) + tdSql.execute('alter table %s add tag tgcol6 binary(10)' % (mt)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=false + tdLog.info('alter table %s set tag tgcol4=false' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=false' % (tb)) + # TSIM: sql alter table $tb set tag tgcol5=5 + tdLog.info('alter table %s set tag tgcol5=5' % (tb)) + tdSql.execute('alter table %s set tag tgcol5=5' % (tb)) + # TSIM: sql alter table $tb set tag tgcol6=6 + tdLog.info('alter table %s set tag tgcol6=6' % (tb)) + tdSql.execute('alter table %s set tag tgcol6=6' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol5 = '5' + tdLog.info('select * from %s where tgcol5 = "5"' % (mt)) + tdSql.query('select * from %s where tgcol5 = "5"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 0 then + tdLog.info('tdSql.checkData(0, 2, 0)') + tdSql.checkData(0, 2, 0) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 5 then + tdLog.info('tdSql.checkData(0, 3, 5)') + tdSql.checkData(0, 3, "5") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 6 then + tdLog.info('tdSql.checkData(0, 4, 6)') + tdSql.checkData(0, 4, "6") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol6 = '6' + tdLog.info('select * from %s where tgcol6 = "6"' % (mt)) + tdSql.query('select * from %s where tgcol6 = "6"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 0 then + tdLog.info('tdSql.checkData(0, 2, 0)') + tdSql.checkData(0, 2, 0) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 5 then + tdLog.info('tdSql.checkData(0, 3, 5)') + tdSql.checkData(0, 3, "5") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 6 then + tdLog.info('tdSql.checkData(0, 4, 6)') + tdSql.checkData(0, 4, "6") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 1 + tdLog.info('select * from %s where tgcol4 = 1' % (mt)) + tdSql.query('select * from %s where tgcol4 = 1' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol3 = 1 -x step52 + tdLog.info('select * from %s where tgcol3 = 1 -x step52' % (mt)) + tdSql.error('select * from %s where tgcol3 = 12' % (mt)) + # TSIM: return -1 + # TSIM: step52: + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: $i = 7 + i = 7 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # smallint, tgcol2 tinyint, tgcol3 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint, tgcol3 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint, tgcol3 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, '3' ) + tdLog.info('create table %s using %s tags( 1, 2, "3" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2, "3" )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol3 = '3' + tdLog.info('select * from %s where tgcol3 = "3"' % (mt)) + tdSql.query('select * from %s where tgcol3 = "3"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, "3") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt change tag tgcol1 tgcol4 + tdLog.info('alter table %s change tag tgcol1 tgcol4' % (mt)) + tdSql.execute('alter table %s change tag tgcol1 tgcol4' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt add tag tgcol5 bigint + tdLog.info('alter table %s add tag tgcol5 bigint' % (mt)) + tdSql.execute('alter table %s add tag tgcol5 bigint' % (mt)) + # TSIM: sql alter table $mt add tag tgcol6 tinyint + tdLog.info('alter table %s add tag tgcol6 tinyint' % (mt)) + tdSql.execute('alter table %s add tag tgcol6 tinyint' % (mt)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=4 + tdLog.info('alter table %s set tag tgcol4=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=4' % (tb)) + # TSIM: sql alter table $tb set tag tgcol5=5 + tdLog.info('alter table %s set tag tgcol5=5' % (tb)) + tdSql.execute('alter table %s set tag tgcol5=5' % (tb)) + # TSIM: sql alter table $tb set tag tgcol6=6 + tdLog.info('alter table %s set tag tgcol6=6' % (tb)) + tdSql.execute('alter table %s set tag tgcol6=6' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol6 = 6 + tdLog.info('select * from %s where tgcol6 = 6' % (mt)) + tdSql.query('select * from %s where tgcol6 = 6' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 4 then + tdLog.info('tdSql.checkData(0, 2, 4)') + tdSql.checkData(0, 2, 4) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 5 then + tdLog.info('tdSql.checkData(0, 3, 5)') + tdSql.checkData(0, 3, 5) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 6 then + tdLog.info('tdSql.checkData(0, 4, 6)') + tdSql.checkData(0, 4, 6) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step71 + tdLog.info('select * from %s where tgcol2 = 1 -x step71' % (mt)) + tdSql.error('select * from %s where tgcol2 = 11' % (mt)) + # TSIM: return -1 + # TSIM: step71: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step72 + tdLog.info('select * from %s where tgcol3 = 1 -x step72' % (mt)) + tdSql.error('select * from %s where tgcol3 = 12' % (mt)) + # TSIM: return -1 + # TSIM: step72: + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: $i = 8 + i = 8 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bigint, tgcol2 float, tgcol3 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float, tgcol3 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float, tgcol3 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, '3' ) + tdLog.info('create table %s using %s tags( 1, 2, "3" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2, "3" )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol3 = '3' + tdLog.info('select * from %s where tgcol3 = "3"' % (mt)) + tdSql.query('select * from %s where tgcol3 = "3"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2.00000 then + tdLog.info('tdSql.checkData(0, 3, 2.00000)') + tdSql.checkData(0, 3, 2.00000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, "3") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt change tag tgcol1 tgcol4 + tdLog.info('alter table %s change tag tgcol1 tgcol4' % (mt)) + tdSql.execute('alter table %s change tag tgcol1 tgcol4' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt add tag tgcol5 binary(17) + tdLog.info('alter table %s add tag tgcol5 binary(17)' % (mt)) + tdSql.execute('alter table %s add tag tgcol5 binary(17)' % (mt)) + # TSIM: sql alter table $mt add tag tgcol6 bool + tdLog.info('alter table %s add tag tgcol6 bool' % (mt)) + tdSql.execute('alter table %s add tag tgcol6 bool' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=4 + tdLog.info('alter table %s set tag tgcol4=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=4' % (tb)) + # TSIM: sql alter table $tb set tag tgcol5=5 + tdLog.info('alter table %s set tag tgcol5=5' % (tb)) + tdSql.execute('alter table %s set tag tgcol5=5' % (tb)) + # TSIM: sql alter table $tb set tag tgcol6=1 + tdLog.info('alter table %s set tag tgcol6=1' % (tb)) + tdSql.execute('alter table %s set tag tgcol6=1' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol5 = '5' + tdLog.info('select * from %s where tgcol5 = "5"' % (mt)) + tdSql.query('select * from %s where tgcol5 = "5"' % (mt)) + # TSIM: print select * from $mt where tgcol5 = 5 + tdLog.info('select * from $mt where tgcol5 = 5') + # TSIM: print $data01 $data02 $data03 $data04 + tdLog.info('$data01 $data02 $data03 $data04') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 4 then + tdLog.info('tdSql.checkData(0, 2, 4)') + tdSql.checkData(0, 2, 4) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 5 then + tdLog.info('tdSql.checkData(0, 3, 5)') + tdSql.checkData(0, 3, "5") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 1 then + tdLog.info('tdSql.checkData(0, 4, 1)') + tdSql.checkData(0, 4, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step81 + tdLog.info('select * from %s where tgcol2 = 1 -x step81' % (mt)) + tdSql.error('select * from %s where tgcol2 = 11' % (mt)) + # TSIM: return -1 + # TSIM: step81: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step82 + tdLog.info('select * from %s where tgcol3 = 1 -x step82' % (mt)) + tdSql.error('select * from %s where tgcol3 = 12' % (mt)) + # TSIM: return -1 + # TSIM: step82: + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: $i = 9 + i = 9 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # double, tgcol2 binary(10), tgcol3 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10), tgcol3 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10), tgcol3 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, '3' ) + tdLog.info('create table %s using %s tags( 1, 2, "3" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2, "3" )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = '2' + tdLog.info('select * from %s where tgcol2 = "2"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "2"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1.000000000 then + tdLog.info('tdSql.checkData(0, 2, 1.000000000)') + tdSql.checkData(0, 2, 1.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, "2") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, "3") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt change tag tgcol1 tgcol4 + tdLog.info('alter table %s change tag tgcol1 tgcol4' % (mt)) + tdSql.execute('alter table %s change tag tgcol1 tgcol4' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt add tag tgcol5 bool + tdLog.info('alter table %s add tag tgcol5 bool' % (mt)) + tdSql.execute('alter table %s add tag tgcol5 bool' % (mt)) + # TSIM: sql alter table $mt add tag tgcol6 float + tdLog.info('alter table %s add tag tgcol6 float' % (mt)) + tdSql.execute('alter table %s add tag tgcol6 float' % (mt)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=4 + tdLog.info('alter table %s set tag tgcol4=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=4' % (tb)) + # TSIM: sql alter table $tb set tag tgcol5=1 + tdLog.info('alter table %s set tag tgcol5=1' % (tb)) + tdSql.execute('alter table %s set tag tgcol5=1' % (tb)) + # TSIM: sql alter table $tb set tag tgcol6=6 + tdLog.info('alter table %s set tag tgcol6=6' % (tb)) + tdSql.execute('alter table %s set tag tgcol6=6' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol5 = 1 + tdLog.info('select * from %s where tgcol5 = 1' % (mt)) + tdSql.query('select * from %s where tgcol5 = 1' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 4.000000000 then + tdLog.info('tdSql.checkData(0, 2, 4.000000000)') + tdSql.checkData(0, 2, 4.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 1 then + tdLog.info('tdSql.checkData(0, 3, 1)') + tdSql.checkData(0, 3, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 6.00000 then + tdLog.info('tdSql.checkData(0, 4, 6.00000)') + tdSql.checkData(0, 4, 6.00000) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step91 + tdLog.info('select * from %s where tgcol3 = 1 -x step91' % (mt)) + tdSql.error('select * from %s where tgcol3 = 11' % (mt)) + # TSIM: return -1 + # TSIM: step91: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step92 + tdLog.info('select * from %s where tgcol2 = 1 -x step92' % (mt)) + tdSql.error('select * from %s where tgcol2 = 12' % (mt)) + # TSIM: return -1 + # TSIM: step92: + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: $i = 10 + i = 10 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( '1', '2', '3', '4' ) + tdLog.info( + 'create table %s using %s tags( "1", "2", "3", "4" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( "1", "2", "3", "4" )' % + (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol4 = '4' + tdLog.info('select * from %s where tgcol4 = "4"' % (mt)) + tdSql.query('select * from %s where tgcol4 = "4"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, "1") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, "2") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, "3") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != 4 then + tdLog.info('tdSql.checkData(0, 5, 4)') + tdSql.checkData(0, 5, "4") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt change tag tgcol1 tgcol4 -x step103 + tdLog.info('alter table %s change tag tgcol1 tgcol4 -x step103' % (mt)) + tdSql.error('alter table %s change tag tgcol1 tgcol4' % (mt)) + # TSIM: return -1 + # TSIM: step103: + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol4 + tdLog.info('alter table %s drop tag tgcol4' % (mt)) + tdSql.execute('alter table %s drop tag tgcol4' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $mt add tag tgcol4 binary(10) + tdLog.info('alter table %s add tag tgcol4 binary(10)' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 binary(10)' % (mt)) + # TSIM: sql alter table $mt add tag tgcol5 bool + tdLog.info('alter table %s add tag tgcol5 bool' % (mt)) + tdSql.execute('alter table %s add tag tgcol5 bool' % (mt)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=4 + tdLog.info('alter table %s set tag tgcol4=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=4' % (tb)) + # TSIM: sql alter table $tb set tag tgcol5=false + tdLog.info('alter table %s set tag tgcol5=false' % (tb)) + tdSql.execute('alter table %s set tag tgcol5=false' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = '4' + tdLog.info('select * from %s where tgcol4 = "4"' % (mt)) + tdSql.query('select * from %s where tgcol4 = "4"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, "1") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, "4") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 0 then + tdLog.info('tdSql.checkData(0, 4, 0)') + tdSql.checkData(0, 4, 0) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != NULL then + #tdLog.info('tdSql.checkData(0, 5, NULL)') + # tdSql.checkData(0, 5, None) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step101 + tdLog.info('select * from %s where tgcol2 = 1 -x step101' % (mt)) + tdSql.error('select * from %s where tgcol2 = 101' % (mt)) + # TSIM: return -1 + # TSIM: step101: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step102 + tdLog.info('select * from %s where tgcol3 = 1 -x step102' % (mt)) + tdSql.error('select * from %s where tgcol3 = 102' % (mt)) + # TSIM: return -1 + # TSIM: step102: + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: $i = 11 + i = 11 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bool, tgcol2 int, tgcol3 smallint, tgcol4 float, tgcol5 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 smallint, tgcol4 float, tgcol5 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 smallint, tgcol4 float, tgcol5 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, 3, 4, '5' ) + tdLog.info( + 'create table %s using %s tags( 1, 2, 3, 4, "5" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( 1, 2, 3, 4, "5" )' % + (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, 3) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != 4.00000 then + tdLog.info('tdSql.checkData(0, 5, 4.00000)') + tdSql.checkData(0, 5, 4.00000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data06 != 5 then + tdLog.info('tdSql.checkData(0, 6, 5)') + tdSql.checkData(0, 6, "5") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt change tag tgcol1 tgcol4 -x step114 + tdLog.info('alter table %s change tag tgcol1 tgcol4 -x step114' % (mt)) + tdSql.error('alter table %s change tag tgcol1 tgcol4' % (mt)) + # TSIM: return -1 + # TSIM: step114: + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol4 + tdLog.info('alter table %s drop tag tgcol4' % (mt)) + tdSql.execute('alter table %s drop tag tgcol4' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol5 + tdLog.info('alter table %s drop tag tgcol5' % (mt)) + tdSql.execute('alter table %s drop tag tgcol5' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $mt add tag tgcol4 binary(10) + tdLog.info('alter table %s add tag tgcol4 binary(10)' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 binary(10)' % (mt)) + # TSIM: sql alter table $mt add tag tgcol5 int + tdLog.info('alter table %s add tag tgcol5 int' % (mt)) + tdSql.execute('alter table %s add tag tgcol5 int' % (mt)) + # TSIM: sql alter table $mt add tag tgcol6 binary(10) + tdLog.info('alter table %s add tag tgcol6 binary(10)' % (mt)) + tdSql.execute('alter table %s add tag tgcol6 binary(10)' % (mt)) + # TSIM: sql alter table $mt add tag tgcol7 bigint + tdLog.info('alter table %s add tag tgcol7 bigint' % (mt)) + tdSql.execute('alter table %s add tag tgcol7 bigint' % (mt)) + # TSIM: sql alter table $mt add tag tgcol8 smallint + tdLog.info('alter table %s add tag tgcol8 smallint' % (mt)) + tdSql.execute('alter table %s add tag tgcol8 smallint' % (mt)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=4 + tdLog.info('alter table %s set tag tgcol4=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=4' % (tb)) + # TSIM: sql alter table $tb set tag tgcol5=5 + tdLog.info('alter table %s set tag tgcol5=5' % (tb)) + tdSql.execute('alter table %s set tag tgcol5=5' % (tb)) + # TSIM: sql alter table $tb set tag tgcol6=6 + tdLog.info('alter table %s set tag tgcol6=6' % (tb)) + tdSql.execute('alter table %s set tag tgcol6=6' % (tb)) + # TSIM: sql alter table $tb set tag tgcol7=7 + tdLog.info('alter table %s set tag tgcol7=7' % (tb)) + tdSql.execute('alter table %s set tag tgcol7=7' % (tb)) + # TSIM: sql alter table $tb set tag tgcol8=8 + tdLog.info('alter table %s set tag tgcol8=8' % (tb)) + tdSql.execute('alter table %s set tag tgcol8=8' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol5 =5 + tdLog.info('select * from %s where tgcol5 =5' % (mt)) + tdSql.query('select * from %s where tgcol5 =5' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, "4") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 5 then + tdLog.info('tdSql.checkData(0, 4, 5)') + tdSql.checkData(0, 4, 5) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != 6 then + tdLog.info('tdSql.checkData(0, 5, 6)') + tdSql.checkData(0, 5, "6") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data06 != 7 then + tdLog.info('tdSql.checkData(0, 6, 7)') + tdSql.checkData(0, 6, 7) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data07 != 8 then + tdLog.info('tdSql.checkData(0, 7, 8)') + tdSql.checkData(0, 7, 8) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step111 + tdLog.info('select * from %s where tgcol2 = 1 -x step111' % (mt)) + tdSql.error('select * from %s where tgcol2 = 111' % (mt)) + # TSIM: return -1 + # TSIM: step111: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step112 + tdLog.info('select * from %s where tgcol3 = 1 -x step112' % (mt)) + tdSql.error('select * from %s where tgcol3 = 112' % (mt)) + # TSIM: return -1 + # TSIM: step112: + # TSIM: sql select * from $mt where tgcol9 = 1 -x step113 + tdLog.info('select * from %s where tgcol9 = 1 -x step113' % (mt)) + tdSql.error('select * from %s where tgcol9 = 113' % (mt)) + # TSIM: return -1 + # TSIM: step113: + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: $i = 12 + i = 12 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bool, tgcol2 smallint, tgcol3 float, tgcol4 double, tgcol5 + # binary(10), tgcol6 binary(20)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 smallint, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 binary(20))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 smallint, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 binary(20))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, 3, 4, '5', '6' ) + tdLog.info( + 'create table %s using %s tags( 1, 2, 3, 4, "5", "6" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( 1, 2, 3, 4, "5", "6" )' % + (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 3.00000 then + tdLog.info('tdSql.checkData(0, 4, 3.00000)') + tdSql.checkData(0, 4, 3.00000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != 4.000000000 then + tdLog.info('tdSql.checkData(0, 5, 4.000000000)') + tdSql.checkData(0, 5, 4.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data06 != 5 then + tdLog.info('tdSql.checkData(0, 6, 5)') + tdSql.checkData(0, 6, "5") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data07 != 6 then + tdLog.info('tdSql.checkData(0, 7, 6)') + tdSql.checkData(0, 7, "6") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol4 + tdLog.info('alter table %s drop tag tgcol4' % (mt)) + tdSql.execute('alter table %s drop tag tgcol4' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol5 + tdLog.info('alter table %s drop tag tgcol5' % (mt)) + tdSql.execute('alter table %s drop tag tgcol5' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $mt add tag tgcol2 binary(10) + tdLog.info('alter table %s add tag tgcol2 binary(10)' % (mt)) + tdSql.execute('alter table %s add tag tgcol2 binary(10)' % (mt)) + # TSIM: sql alter table $mt add tag tgcol3 int + tdLog.info('alter table %s add tag tgcol3 int' % (mt)) + tdSql.execute('alter table %s add tag tgcol3 int' % (mt)) + # TSIM: sql alter table $mt add tag tgcol4 binary(10) + tdLog.info('alter table %s add tag tgcol4 binary(10)' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 binary(10)' % (mt)) + # TSIM: sql alter table $mt add tag tgcol5 bigint + tdLog.info('alter table %s add tag tgcol5 bigint' % (mt)) + tdSql.execute('alter table %s add tag tgcol5 bigint' % (mt)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol1=false + tdLog.info('alter table %s set tag tgcol1=false' % (tb)) + tdSql.execute('alter table %s set tag tgcol1=false' % (tb)) + # TSIM: sql alter table $tb set tag tgcol2=5 + tdLog.info('alter table %s set tag tgcol2=5' % (tb)) + tdSql.execute('alter table %s set tag tgcol2=5' % (tb)) + # TSIM: sql alter table $tb set tag tgcol3=4 + tdLog.info('alter table %s set tag tgcol3=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol3=4' % (tb)) + # TSIM: sql alter table $tb set tag tgcol4=3 + tdLog.info('alter table %s set tag tgcol4=3' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=3' % (tb)) + # TSIM: sql alter table $tb set tag tgcol5=2 + tdLog.info('alter table %s set tag tgcol5=2' % (tb)) + tdSql.execute('alter table %s set tag tgcol5=2' % (tb)) + # TSIM: sql alter table $tb set tag tgcol6=1 + tdLog.info('alter table %s set tag tgcol6=1' % (tb)) + tdSql.execute('alter table %s set tag tgcol6=1' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = '3' + tdLog.info('select * from %s where tgcol4 = "3"' % (mt)) + tdSql.query('select * from %s where tgcol4 = "3"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 0 then + tdLog.info('tdSql.checkData(0, 2, 0)') + tdSql.checkData(0, 2, 0) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 1 then + tdLog.info('tdSql.checkData(0, 3, 1)') + tdSql.checkData(0, 3, "1") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 5 then + tdLog.info('tdSql.checkData(0, 4, 5)') + tdSql.checkData(0, 4, "5") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != 4 then + tdLog.info('tdSql.checkData(0, 5, 4)') + tdSql.checkData(0, 5, 4) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data06 != 3 then + tdLog.info('tdSql.checkData(0, 6, 3)') + tdSql.checkData(0, 6, "3") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data07 != 2 then + tdLog.info('tdSql.checkData(0, 7, 2)') + tdSql.checkData(0, 7, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = '5' + tdLog.info('select * from %s where tgcol2 = "5"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "5"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol3 = 4 + tdLog.info('select * from %s where tgcol3 = 4' % (mt)) + tdSql.query('select * from %s where tgcol3 = 4' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol5 = 2 + tdLog.info('select * from %s where tgcol5 = 2' % (mt)) + tdSql.query('select * from %s where tgcol5 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol6 = '1' + tdLog.info('select * from %s where tgcol6 = "1"' % (mt)) + tdSql.query('select * from %s where tgcol6 = "1"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step13 + tdLog.info('=============== step13') + # TSIM: $i = 13 + i = 13 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 + # double, tgcol6 binary(20)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' ) + tdLog.info( + 'create table %s using %s tags( "1", 2, 3, "4", 5, "6" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( "1", 2, 3, "4", 5, "6" )' % + (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol1 = '1' + tdLog.info('select * from %s where tgcol1 = "1"' % (mt)) + tdSql.query('select * from %s where tgcol1 = "1"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, "1") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, 3) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != 4 then + tdLog.info('tdSql.checkData(0, 5, 4)') + tdSql.checkData(0, 5, "4") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data06 != 5.000000000 then + tdLog.info('tdSql.checkData(0, 6, 5.000000000)') + tdSql.checkData(0, 6, 5.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data07 != 6 then + tdLog.info('tdSql.checkData(0, 7, 6)') + tdSql.checkData(0, 7, "6") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol4 + tdLog.info('alter table %s drop tag tgcol4' % (mt)) + tdSql.execute('alter table %s drop tag tgcol4' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol6 + tdLog.info('alter table %s drop tag tgcol6' % (mt)) + tdSql.execute('alter table %s drop tag tgcol6' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $mt add tag tgcol2 binary(10) + tdLog.info('alter table %s add tag tgcol2 binary(10)' % (mt)) + tdSql.execute('alter table %s add tag tgcol2 binary(10)' % (mt)) + # TSIM: sql alter table $mt add tag tgcol4 int + tdLog.info('alter table %s add tag tgcol4 int' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 int' % (mt)) + # TSIM: sql alter table $mt add tag tgcol6 bigint + tdLog.info('alter table %s add tag tgcol6 bigint' % (mt)) + tdSql.execute('alter table %s add tag tgcol6 bigint' % (mt)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol1=7 + tdLog.info('alter table %s set tag tgcol1=7' % (tb)) + tdSql.execute('alter table %s set tag tgcol1=7' % (tb)) + # TSIM: sql alter table $tb set tag tgcol2=8 + tdLog.info('alter table %s set tag tgcol2=8' % (tb)) + tdSql.execute('alter table %s set tag tgcol2=8' % (tb)) + # TSIM: sql alter table $tb set tag tgcol3=9 + tdLog.info('alter table %s set tag tgcol3=9' % (tb)) + tdSql.execute('alter table %s set tag tgcol3=9' % (tb)) + # TSIM: sql alter table $tb set tag tgcol4=10 + tdLog.info('alter table %s set tag tgcol4=10' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=10' % (tb)) + # TSIM: sql alter table $tb set tag tgcol5=11 + tdLog.info('alter table %s set tag tgcol5=11' % (tb)) + tdSql.execute('alter table %s set tag tgcol5=11' % (tb)) + # TSIM: sql alter table $tb set tag tgcol6=12 + tdLog.info('alter table %s set tag tgcol6=12' % (tb)) + tdSql.execute('alter table %s set tag tgcol6=12' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = '8' + tdLog.info('select * from %s where tgcol2 = "8"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "8"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 7 then + tdLog.info('tdSql.checkData(0, 2, 7)') + tdSql.checkData(0, 2, "7") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 9 then + tdLog.info('tdSql.checkData(0, 3, 9)') + tdSql.checkData(0, 3, 9) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 11.000000000 then + tdLog.info('tdSql.checkData(0, 4, 11.000000000)') + tdSql.checkData(0, 4, 11.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != 8 then + tdLog.info('tdSql.checkData(0, 5, 8)') + tdSql.checkData(0, 5, "8") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data06 != 10 then + tdLog.info('tdSql.checkData(0, 6, 10)') + tdSql.checkData(0, 6, 10) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data07 != 12 then + tdLog.info('tdSql.checkData(0, 7, 12)') + tdSql.checkData(0, 7, 12) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step14 + tdLog.info('=============== step14') + # TSIM: $i = 14 + i = 14 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bool, tgcol2 bigint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 bigint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 bigint)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 1 ) + tdLog.info('create table %s using %s tags( 1, 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 1 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: + # TSIM: sql alter table $mt add tag tgcol3 binary(10) + tdLog.info('alter table %s add tag tgcol3 binary(10)' % (mt)) + tdSql.execute('alter table %s add tag tgcol3 binary(10)' % (mt)) + # TSIM: sql alter table $mt add tag tgcol4 int + tdLog.info('alter table %s add tag tgcol4 int' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 int' % (mt)) + # TSIM: sql alter table $mt add tag tgcol5 bigint + tdLog.info('alter table %s add tag tgcol5 bigint' % (mt)) + tdSql.execute('alter table %s add tag tgcol5 bigint' % (mt)) + # TSIM: sql alter table $mt add tag tgcol6 bigint + tdLog.info('alter table %s add tag tgcol6 bigint' % (mt)) + tdSql.execute('alter table %s add tag tgcol6 bigint' % (mt)) + # TSIM: + # TSIM: return + # TSIM: sql alter table $mt add tag tgcol7 bigint -x step141 + tdLog.info('alter table %s add tag tgcol7 bigint -x step141' % (mt)) + tdSql.error('alter table %s add tag tgcol7 bigint41' % (mt)) + # TSIM: return -1 + # TSIM: step141: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $mt drop tag tgcol6 + tdLog.info('alter table %s drop tag tgcol6' % (mt)) + tdSql.execute('alter table %s drop tag tgcol6' % (mt)) + # TSIM: sql alter table $mt add tag tgcol7 bigint + tdLog.info('alter table %s add tag tgcol7 bigint' % (mt)) + tdSql.execute('alter table %s add tag tgcol7 bigint' % (mt)) + # TSIM: sql alter table $mt add tag tgcol8 bigint -x step142 + tdLog.info('alter table %s add tag tgcol8 bigint -x step142' % (mt)) + tdSql.error('alter table %s add tag tgcol8 bigint42' % (mt)) + # TSIM: return -1 + # TSIM: step142: + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('sql drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/alter_tag.py b/tests/pytest/tag_lite/alter_tag.py new file mode 100644 index 0000000000000000000000000000000000000000..c4d738e4cf0d9bd63f7813e9d267080f9f045fac --- /dev/null +++ b/tests/pytest/tag_lite/alter_tag.py @@ -0,0 +1,68 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +from util.dnodes import tdDnodes + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.ts = 1538548685000 + + def run(self): + tdSql.prepare() + + print("==============step1") + tdSql.execute( + "CREATE TABLE IF NOT EXISTS ampere (ts TIMESTAMP,ampere DOUBLE) TAGS (device_name BINARY(50),build_id BINARY(50),project_id BINARY(50),alias BINARY(50))") + tdSql.execute("insert into d1001 using ampere tags('test', '2', '2', '2') VALUES (now, 123)") + tdSql.execute("ALTER TABLE ampere ADD TAG variable_id BINARY(50)") + + print("==============step2") + + tdSql.execute("insert into d1002 using ampere tags('test', '2', '2', '2', 'test') VALUES (now, 124)") + + tdSql.query("select * from ampere") + tdSql.checkRows(2) + tdSql.checkData(0, 6, None) + tdSql.checkData(1, 6, 'test') + + # Test case for: https://jira.taosdata.com:18080/browse/TD-2423 + tdSql.execute("create table stb(ts timestamp, col1 int, col2 nchar(20)) tags(tg1 int, tg2 binary(20), tg3 nchar(25))") + tdSql.execute("insert into tb1 using stb(tg1, tg3) tags(1, 'test1') values(now, 1, 'test1')") + tdSql.query("select *, tg1, tg2, tg3 from tb1") + tdSql.checkRows(1) + tdSql.checkData(0, 3, 1) + tdSql.checkData(0, 4, None) + tdSql.checkData(0, 5, 'test1') + + tdSql.execute("create table tb2 using stb(tg3, tg2) tags('test3', 'test2')") + tdSql.query("select tg1, tg2, tg3 from tb2") + tdSql.checkRows(1) + tdSql.checkData(0, 0, None) + tdSql.checkData(0, 1, 'test2') + tdSql.checkData(0, 2, 'test3') + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/bigint.py b/tests/pytest/tag_lite/bigint.py new file mode 100644 index 0000000000000000000000000000000000000000..733d30983d07ab9e2c30076b76084edb354e289f --- /dev/null +++ b/tests/pytest/tag_lite/bigint.py @@ -0,0 +1,596 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_bi_db + # TSIM: $tbPrefix = ta_bi_tb + tbPrefix = "ta_bi_tb" + # TSIM: $mtPrefix = ta_bi_mt + mtPrefix = "ta_bi_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # bigint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bigint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bigint)' % + (mt)) + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: while $i < 5 + while (i < 5): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 0 ) + tdLog.info('create table %s using %s tags( 0 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 0 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: while $i < 10 + while (i < 10): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 1 ) + tdLog.info('create table %s using %s tags( 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sleep 100 + # TSIM: sql select * from $tb + tdLog.info('select * from %s' % (tb)) + tdSql.query('select * from %s' % (tb)) + # TSIM: if $rows != $rowNum then + tdLog.info('tdSql.checkRow($rowNum)') + tdSql.checkRows(rowNum) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts < 1605045600000 + 240001 + tdLog.info('select * from %s where ts < 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts < 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts <= 1605045600000 + 240001 + tdLog.info('select * from %s where ts <= 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts <= 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 + tdLog.info('select * from %s where ts > 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts > 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts >= 1605045600000 + 240001 + tdLog.info('select * from %s where ts >= 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts >= 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001' % + (tb)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 100000 and ts < 100000 + tdLog.info('select * from %s where ts > 100000 and ts < 100000' % (tb)) + tdSql.query( + 'select * from %s where ts > 100000 and ts < 100000' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and + # ts < 1605045600000 + 360001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and ts < 1605045600000 + 360001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and ts < 1605045600000 + 360001' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 + tdLog.info('select * from %s where ts < 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts < 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 + tdLog.info('select * from %s where ts > 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts > 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts = 1605045600000 + 240001 + tdLog.info('select * from %s where ts = 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts = 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol = 1 + tdLog.info('select * from %s where ts > 1605045600000 + 240001 and tgcol = 1' % (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol = 0 + tdLog.info('select * from %s where ts < 1605045600000 + 240001 and tgcol = 0' % (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> 0 and ts + # < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 0 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 0 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group + # by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by + # tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + tdSql.execute("create database db") + tdSql.execute("use db") + tdSql.execute( + "create table if not exists st (ts timestamp, tagtype int) tags(dev bigint)") + + tdSql.execute( + 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (pow(2, 63) - 1)) + tdSql.execute( + 'CREATE TABLE if not exists dev_002 using st tags(%d)' % (-1 * pow(2, 63) + 1)) + + print("==============step2") + tdSql.query("show tables") + tdSql.checkRows(2) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/binary.py b/tests/pytest/tag_lite/binary.py new file mode 100644 index 0000000000000000000000000000000000000000..3825c6637f9357e00bc8491be1d8c2960dde2109 --- /dev/null +++ b/tests/pytest/tag_lite/binary.py @@ -0,0 +1,600 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_by_db + # TSIM: $tbPrefix = ta_by_tb + tbPrefix = "ta_by_tb" + # TSIM: $mtPrefix = ta_by_mt + mtPrefix = "ta_by_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(10))' % + (mt)) + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: while $i < 5 + while (i < 5): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( '0' ) + tdLog.info('create table %s using %s tags( "0" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( "0" )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: while $i < 10 + while (i < 10): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( '1' ) + tdLog.info('create table %s using %s tags( "1" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( "1" )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sleep 100 + # TSIM: sql select * from $tb + tdLog.info('select * from %s' % (tb)) + tdSql.query('select * from %s' % (tb)) + # TSIM: if $rows != $rowNum then + tdLog.info('tdSql.checkRow($rowNum)') + tdSql.checkRows(rowNum) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts < 1605045600000 + 240001 + tdLog.info('select * from %s where ts < 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts < 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts <= 1605045600000 + 240001 + tdLog.info('select * from %s where ts <= 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts <= 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 + tdLog.info('select * from %s where ts > 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts > 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts >= 1605045600000 + 240001 + tdLog.info('select * from %s where ts >= 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts >= 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001' % + (tb)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 100000 and ts < 100000 + tdLog.info('select * from %s where ts > 100000 and ts < 100000' % (tb)) + tdSql.query( + 'select * from %s where ts > 100000 and ts < 100000' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and + # ts < 1605045600000 + 360001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and ts < 1605045600000 + 360001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and ts < 1605045600000 + 360001' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 + tdLog.info('select * from %s where ts < 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts < 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 + tdLog.info('select * from %s where ts > 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts > 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts = 1605045600000 + 240001 + tdLog.info('select * from %s where ts = 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts = 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol = '0' + tdLog.info('select * from %s where tgcol = "0"' % (mt)) + tdSql.query('select * from %s where tgcol = "0"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> '0' + tdLog.info('select * from %s where tgcol <> "0"' % (mt)) + tdSql.query('select * from %s where tgcol <> "0"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = '1' + tdLog.info('select * from %s where tgcol = "1"' % (mt)) + tdSql.query('select * from %s where tgcol = "1"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> '1' + tdLog.info('select * from %s where tgcol <> "1"' % (mt)) + tdSql.query('select * from %s where tgcol <> "1"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = '1' + tdLog.info('select * from %s where tgcol = "1"' % (mt)) + tdSql.query('select * from %s where tgcol = "1"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> '1' + tdLog.info('select * from %s where tgcol <> "1"' % (mt)) + tdSql.query('select * from %s where tgcol <> "1"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = '0' + tdLog.info('select * from %s where tgcol = "0"' % (mt)) + tdSql.query('select * from %s where tgcol = "0"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> '0' + tdLog.info('select * from %s where tgcol <> "0"' % (mt)) + tdSql.query('select * from %s where tgcol <> "0"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol = '1' + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol = "1"' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol = "1"' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> '1' + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> "1"' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> "1"' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol = '0' + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol = "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol = "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol <> '0' + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol <> "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol = '0' + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol = "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol = "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol <> '0' + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol <> '0' + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> "0"' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> '0' and + # ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> "0" and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> "0" and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = "1"' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = "1"' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = "1" group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = "1" group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by + # tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + tdSql.execute("create database db") + tdSql.execute("use db") + tdSql.execute( + "create table if not exists st (ts timestamp, tagtype int) tags(dev binary(5))") + tdSql.error( + 'CREATE TABLE if not exists dev_001 using st tags("dev_001")') + + tdSql.execute( + 'CREATE TABLE if not exists dev_002 using st tags("dev")') + + print("==============step2") + tdSql.query("show tables") + tdSql.checkRows(1) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/binary_binary.py b/tests/pytest/tag_lite/binary_binary.py new file mode 100644 index 0000000000000000000000000000000000000000..2a76238f595ce5b079f0d36453197875d214145c --- /dev/null +++ b/tests/pytest/tag_lite/binary_binary.py @@ -0,0 +1,797 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_bib_db + # TSIM: $tbPrefix = ta_bib_tb + tbPrefix = "ta_bib_tb" + # TSIM: $mtPrefix = ta_bib_mt + mtPrefix = "ta_bib_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # binary(5), tgcol2 binary(5)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(5), tgcol2 binary(5))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(5), tgcol2 binary(5))' % + (mt)) + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: while $i < 5 + while (i < 5): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( '0', '0' ) + tdLog.info('create table %s using %s tags( "0", "0" )' % (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( "0", "0" )' % + (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: while $i < 10 + while (i < 10): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( '1', '1' ) + tdLog.info('create table %s using %s tags( "1", "1" )' % (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( "1", "1" )' % + (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 + tdLog.info('select * from %s where ts < 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts < 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 + tdLog.info('select * from %s where ts > 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts > 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts = 1605045600000 + 240001 + tdLog.info('select * from %s where ts = 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts = 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from $mt where tgcol = '0' + tdLog.info('select * from %s where tgcol = "0"' % (mt)) + tdSql.query('select * from %s where tgcol = "0"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> '0' + tdLog.info('select * from %s where tgcol <> "0"' % (mt)) + tdSql.query('select * from %s where tgcol <> "0"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = '1' + tdLog.info('select * from %s where tgcol = "1"' % (mt)) + tdSql.query('select * from %s where tgcol = "1"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> '1' + tdLog.info('select * from %s where tgcol <> "1"' % (mt)) + tdSql.query('select * from %s where tgcol <> "1"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = '1' + tdLog.info('select * from %s where tgcol = "1"' % (mt)) + tdSql.query('select * from %s where tgcol = "1"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> '1' + tdLog.info('select * from %s where tgcol <> "1"' % (mt)) + tdSql.query('select * from %s where tgcol <> "1"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = '0' + tdLog.info('select * from %s where tgcol = "0"' % (mt)) + tdSql.query('select * from %s where tgcol = "0"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> '0' + tdLog.info('select * from %s where tgcol <> "0"' % (mt)) + tdSql.query('select * from %s where tgcol <> "0"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol2 = '0' + tdLog.info('select * from %s where tgcol2 = "0"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "0"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 <> '0' + tdLog.info('select * from %s where tgcol2 <> "0"' % (mt)) + tdSql.query('select * from %s where tgcol2 <> "0"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = '1' + tdLog.info('select * from %s where tgcol2 = "1"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "1"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 <> '1' + tdLog.info('select * from %s where tgcol2 <> "1"' % (mt)) + tdSql.query('select * from %s where tgcol2 <> "1"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol = '1' + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol = "1"' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol = "1"' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> '1' + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> "1"' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> "1"' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol = '0' + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol = "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol = "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol <> '0' + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol <> "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol = '0' + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol = "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol = "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol <> '0' + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol <> '0' + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> "0"' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> '0' and + # ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> "0" and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> "0" and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 = '1' + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = "1"' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = "1"' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 <> '1' + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> "1"' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> "1"' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol2 = '0' + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol2 <> '0' + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol2 = '0' + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol2 <> '0' + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol2 <> '0' + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> "0"' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 <> '0' and + # ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> "0" and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> "0" and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 = '1' and + # tgcol = '1' + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = "1" and tgcol = "1"' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = "1" and tgcol = "1"' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 <> '1' and + # tgcol <> '1' + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> "1" and tgcol <> "1"' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> "1" and tgcol <> "1"' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol2 = '0' and + # tgcol = '0' + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = "0" and tgcol = "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = "0" and tgcol = "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol2 <> '0' and + # tgcol <> '0' + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> "0" and tgcol <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> "0" and tgcol <> "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol2 = '0' and + # tgcol = '0' + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = "0" and tgcol = "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = "0" and tgcol = "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol2 <> '0' + # and tgcol <> '0' + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> "0" and tgcol <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> "0" and tgcol <> "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol2 <> '0' and tgcol <> '0' + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> "0" and tgcol <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> "0" and tgcol <> "0"' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 <> '0' and + # ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol <> '0' + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> "0" and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> "0" and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol <> "0"' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = "1"' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = "1"' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = "1"' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = "1"' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' and + # tgcol2 = '1' + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = "1" and tgcol2 = "1"' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = "1" and tgcol2 = "1"' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = "1" group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = "1" group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = "1" group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = "1" group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' and + # tgcol2 = '1' group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = "1" and tgcol2 = "1" group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = "1" and tgcol2 = "1" group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step13 + tdLog.info('=============== step13') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step14 + tdLog.info('=============== step14') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by + # tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/bool.py b/tests/pytest/tag_lite/bool.py new file mode 100644 index 0000000000000000000000000000000000000000..11ce9eb7f8126e9d0adf4bedeaf055e3f4ab2c1b --- /dev/null +++ b/tests/pytest/tag_lite/bool.py @@ -0,0 +1,581 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_bo_db + # TSIM: $tbPrefix = ta_bo_tb + tbPrefix = "ta_bo_tb" + # TSIM: $mtPrefix = ta_bo_mt + mtPrefix = "ta_bo_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool)' % + (mt)) + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: while $i < 5 + while (i < 5): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 0 ) + tdLog.info('create table %s using %s tags( 0 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 0 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: while $i < 10 + while (i < 10): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 1 ) + tdLog.info('create table %s using %s tags( 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sleep 100 + # TSIM: sql select * from $tb + tdLog.info('select * from %s' % (tb)) + tdSql.query('select * from %s' % (tb)) + # TSIM: if $rows != $rowNum then + tdLog.info('tdSql.checkRow($rowNum)') + tdSql.checkRows(rowNum) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts < 1605045600000 + 240001 + tdLog.info('select * from %s where ts < 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts < 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts <= 1605045600000 + 240001 + tdLog.info('select * from %s where ts <= 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts <= 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 + tdLog.info('select * from %s where ts > 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts > 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts >= 1605045600000 + 240001 + tdLog.info('select * from %s where ts >= 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts >= 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001' % + (tb)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and + # ts < 1605045600000 + 360001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and ts < 1605045600000 + 360001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and ts < 1605045600000 + 360001' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 + tdLog.info('select * from %s where ts < 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts < 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 + tdLog.info('select * from %s where ts > 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts > 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts = 1605045600000 + 240001 + tdLog.info('select * from %s where ts = 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts = 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: print expect 100, actual:$rows + tdLog.info('expect 100, actual:$rows') + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = true + tdLog.info('select * from %s where tgcol = true' % (mt)) + tdSql.query('select * from %s where tgcol = true' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> true + tdLog.info('select * from %s where tgcol <> true' % (mt)) + tdSql.query('select * from %s where tgcol <> true' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = false + tdLog.info('select * from %s where tgcol = false' % (mt)) + tdSql.query('select * from %s where tgcol = false' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> false + tdLog.info('select * from %s where tgcol <> false' % (mt)) + tdSql.query('select * from %s where tgcol <> false' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol = true + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol = true' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol = true' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> true + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> true' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> true' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol = false + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol = false' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol = false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol <> false + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol <> false' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol <> false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol = false + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol = false' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol = false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol <> false + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> false' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol <> false + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> false' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> false' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> false + # and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> false and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> false and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by + # tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + # TSIM: print select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by + # tgcol + tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol') + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/bool_binary.py b/tests/pytest/tag_lite/bool_binary.py new file mode 100644 index 0000000000000000000000000000000000000000..934d91c9084e7631feb6c34c596b23a7e0314cb7 --- /dev/null +++ b/tests/pytest/tag_lite/bool_binary.py @@ -0,0 +1,791 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_bob_db + # TSIM: $tbPrefix = ta_bob_tb + tbPrefix = "ta_bob_tb" + # TSIM: $mtPrefix = ta_bob_mt + mtPrefix = "ta_bob_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, + # tgcol2 binary(5)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 binary(5))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 binary(5))' % + (mt)) + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: while $i < 5 + while (i < 5): + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 0, '0' ) + tdLog.info('create table %s using %s tags( 0, "0" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 0, "0" )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: while $i < 10 + while (i < 10): + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 1, '1' ) + tdLog.info('create table %s using %s tags( 1, "1" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, "1" )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 + tdLog.info('select * from %s where ts < 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts < 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 + tdLog.info('select * from %s where ts > 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts > 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts = 1605045600000 + 240001 + tdLog.info('select * from %s where ts = 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts = 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = true + tdLog.info('select * from %s where tgcol = true' % (mt)) + tdSql.query('select * from %s where tgcol = true' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> true + tdLog.info('select * from %s where tgcol <> true' % (mt)) + tdSql.query('select * from %s where tgcol <> true' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = false + tdLog.info('select * from %s where tgcol = false' % (mt)) + tdSql.query('select * from %s where tgcol = false' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> false + tdLog.info('select * from %s where tgcol <> false' % (mt)) + tdSql.query('select * from %s where tgcol <> false' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol2 = '0' + tdLog.info('select * from %s where tgcol2 = "0"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "0"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 <> '0' + tdLog.info('select * from %s where tgcol2 <> "0"' % (mt)) + tdSql.query('select * from %s where tgcol2 <> "0"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = '1' + tdLog.info('select * from %s where tgcol2 = "1"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "1"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 <> "1" + tdLog.info('select * from %s where tgcol2 <> "1"' % (mt)) + tdSql.query('select * from %s where tgcol2 <> "1"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol = true + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol = true' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol = true' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> true + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> true' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> true' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol = false + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol = false' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol = false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol <> false + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol <> false' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol <> false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol = false + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol = false' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol = false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol <> false + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> false' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol <> false + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> false' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> false' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> false + # and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> false and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> false and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 = '1' + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = "1"' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = "1"' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 <> '1' + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> "1"' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> "1"' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol2 = '0' + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol2 <> '0' + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol2 = '0' + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol2 <> '0' + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol2 <> '0' + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> "0"' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 <> '0' and + # ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> "0" and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> "0" and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 = '1' and + # tgcol = true + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = "1" and tgcol = true' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = "1" and tgcol = true' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 <> '1' and + # tgcol <> true + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> "1" and tgcol <> true' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> "1" and tgcol <> true' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol2 = '0' and + # tgcol = false + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = "0" and tgcol = false' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = "0" and tgcol = false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol2 <> '0' and + # tgcol <> false + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> "0" and tgcol <> false' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> "0" and tgcol <> false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol2 = '0' and + # tgcol = false + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = "0" and tgcol = false' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = "0" and tgcol = false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol2 <> '0' + # and tgcol <> false + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> "0" and tgcol <> false' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> "0" and tgcol <> false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol2 <> '0' and tgcol <> false + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> "0" and tgcol <> false' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> "0" and tgcol <> false' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 <> '0' and + # ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol <> false + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> "0" and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol <> false' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> "0" and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol <> false' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = "1"' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = "1"' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true and + # tgcol2 = '1' + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true and tgcol2 = "1"' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true and tgcol2 = "1"' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = "1" group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = "1" group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true and + # tgcol2 = '1' group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true and tgcol2 = "1" group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true and tgcol2 = "1" group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step13 + tdLog.info('=============== step13') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step14 + tdLog.info('=============== step14') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by + # tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/bool_int.py b/tests/pytest/tag_lite/bool_int.py new file mode 100644 index 0000000000000000000000000000000000000000..1e857192ede0602c8aa5e279da12ea488559ec07 --- /dev/null +++ b/tests/pytest/tag_lite/bool_int.py @@ -0,0 +1,823 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_boi_db + # TSIM: $tbPrefix = ta_boi_tb + tbPrefix = "ta_boi_tb" + # TSIM: $mtPrefix = ta_boi_mt + mtPrefix = "ta_boi_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, + # tgcol2 int) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 int)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 int)' % + (mt)) + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: while $i < 5 + while (i < 5): + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 0, 0 ) + tdLog.info('create table %s using %s tags( 0, 0 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 0, 0 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: while $i < 10 + while (i < 10): + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 1, 1 ) + tdLog.info('create table %s using %s tags( 1, 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 1 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 + tdLog.info('select * from %s where ts < 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts < 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 + tdLog.info('select * from %s where ts > 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts > 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts = 1605045600000 + 240001 + tdLog.info('select * from %s where ts = 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts = 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = true + tdLog.info('select * from %s where tgcol = true' % (mt)) + tdSql.query('select * from %s where tgcol = true' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> true + tdLog.info('select * from %s where tgcol <> true' % (mt)) + tdSql.query('select * from %s where tgcol <> true' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = false + tdLog.info('select * from %s where tgcol = false' % (mt)) + tdSql.query('select * from %s where tgcol = false' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> false + tdLog.info('select * from %s where tgcol <> false' % (mt)) + tdSql.query('select * from %s where tgcol <> false' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 <> 0 + tdLog.info('select * from %s where tgcol2 <> 0' % (mt)) + tdSql.query('select * from %s where tgcol2 <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 1 + tdLog.info('select * from %s where tgcol2 = 1' % (mt)) + tdSql.query('select * from %s where tgcol2 = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 <> 1 + tdLog.info('select * from %s where tgcol2 <> 1' % (mt)) + tdSql.query('select * from %s where tgcol2 <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = true + tdLog.info('select * from %s where tgcol2 = true' % (mt)) + tdSql.query('select * from %s where tgcol2 = true' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 <> true + tdLog.info('select * from %s where tgcol2 <> true' % (mt)) + tdSql.query('select * from %s where tgcol2 <> true' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = false + tdLog.info('select * from %s where tgcol2 = false' % (mt)) + tdSql.query('select * from %s where tgcol2 = false' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 <> false + tdLog.info('select * from %s where tgcol2 <> false' % (mt)) + tdSql.query('select * from %s where tgcol2 <> false' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol = true + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol = true' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol = true' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> true + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> true' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> true' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol = false + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol = false' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol = false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol <> false + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol <> false' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol <> false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol = false + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol = false' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol = false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol <> false + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> false' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol <> false + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> false' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> false' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> false + # and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> false and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> false and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol2 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol2 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 <> 0 and + # ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 0 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 0 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 = 1 and + # tgcol = true + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = 1 and tgcol = true' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = 1 and tgcol = true' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 <> 1 and + # tgcol <> true + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 1 and tgcol <> true' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 1 and tgcol <> true' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol2 = 0 and + # tgcol = false + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = 0 and tgcol = false' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = 0 and tgcol = false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol2 <> 0 and + # tgcol <> false + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> 0 and tgcol <> false' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> 0 and tgcol <> false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol2 = 0 and + # tgcol = false + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = 0 and tgcol = false' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = 0 and tgcol = false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol2 <> 0 and + # tgcol <> false + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> 0 and tgcol <> false' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> 0 and tgcol <> false' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol2 <> 0 and tgcol <> false + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol <> false' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol <> false' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 <> 0 and + # ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol <> false + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol <> false' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol <> false' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true and + # tgcol2 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true and tgcol2 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true and tgcol2 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = 1 group + # by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = 1 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = 1 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true and + # tgcol2 = 1 group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true and tgcol2 = 1 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true and tgcol2 = 1 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step13 + tdLog.info('=============== step13') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step14 + tdLog.info('=============== step14') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by + # tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/change.py b/tests/pytest/tag_lite/change.py new file mode 100644 index 0000000000000000000000000000000000000000..b8ddc3ff87ae921c9958f3242e681971a1b865ab --- /dev/null +++ b/tests/pytest/tag_lite/change.py @@ -0,0 +1,945 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_ch_db + # TSIM: $tbPrefix = ta_ch_tb + # TSIM: $mtPrefix = ta_ch_mt + # TSIM: $tbNum = 10 + # TSIM: $rowNum = 20 + # TSIM: $totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: $i = 2 + # TSIM: $mt = $mtPrefix . $i + # TSIM: $tb = $tbPrefix . $i + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bool, tgcol2 int) + tdLog.info( + "create table ta_ch_mt2 (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int)") + tdSql.execute( + 'create table ta_ch_mt2 (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int)') + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info("create table tb2 using ta_ch_mt2 tags( 1, 2 )") + tdSql.execute('create table tb2 using ta_ch_mt2 tags( 1, 2 )') + # TSIM: sql insert into $tb values(now, 1) + tdLog.info("insert into tb2 values(now, 1)") + tdSql.execute("insert into tb2 values(now, 1)") + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from ta_ch_mt2 where tgcol1 = 1') + tdSql.query('select * from ta_ch_mt2 where tgcol1 = 1') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt change tag tagcx tgcol3 -x step21 + tdLog.info("alter table ta_ch_mt2 change tag tagcx tgcol3 -x step21") + tdSql.error("alter table ta_ch_mt2 change tag tagcx tgcol3") + # TSIM: return -1 + # TSIM: step21: + # TSIM: sql alter table $mt change tag tgcol1 tgcol2 -x step22 + tdLog.info("alter table ta_ch_mt2 change tag tgcol1 tgcol2 -x step22") + tdSql.error("alter table ta_ch_mt2 change tag tgcol1 tgcol2") + # TSIM: return -1 + # TSIM: step22: + # TSIM: sql alter table $mt change tag tgcol1 + # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -x + # step20 + tdLog.info( + "alter table ta_ch_mt2 change tag tgcol1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -x step20") + tdSql.error( + "alter table ta_ch_mt2 change tag tgcol1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -x step20") + # TSIM: return -1 + # TSIM: step20: + # TSIM: + # TSIM: sql alter table $mt change tag tgcol1 tgcol3 + tdLog.info("alter table ta_ch_mt2 change tag tgcol1 tgcol3") + tdSql.execute("alter table ta_ch_mt2 change tag tgcol1 tgcol3") + # TSIM: sql alter table $mt change tag tgcol2 tgcol4 + tdLog.info("alter table ta_ch_mt2 change tag tgcol2 tgcol4") + tdSql.execute("alter table ta_ch_mt2 change tag tgcol2 tgcol4") + # TSIM: sql alter table $mt change tag tgcol4 tgcol3 -x step23 + tdLog.info("alter table ta_ch_mt2 change tag tgcol4 tgcol3 -x step23") + tdSql.error("alter table ta_ch_mt2 change tag tgcol4 tgcol3") + # TSIM: return -1 + # TSIM: step23: + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: $i = 3 + # TSIM: $mt = $mtPrefix . $i + # TSIM: $tb = $tbPrefix . $i + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # smallint, tgcol2 tinyint) + tdLog.info( + "create table ta_ch_mt3 (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint)") + tdSql.execute( + 'create table ta_ch_mt3 (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint)') + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info("create table tb3 using ta_ch_mt3 tags( 1, 2 )") + tdSql.execute('create table tb3 using ta_ch_mt3 tags( 1, 2 )') + # TSIM: sql insert into $tb values(now, 1) + tdLog.info("insert into tb3 values(now, 1)") + tdSql.execute("insert into tb3 values(now, 1)") + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from ta_ch_mt3 where tgcol1 = 1') + tdSql.query('select * from ta_ch_mt3 where tgcol1 = 1') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt change tag tgcol1 tgcol3 + tdLog.info("alter table ta_ch_mt3 change tag tgcol1 tgcol3") + tdSql.execute("alter table ta_ch_mt3 change tag tgcol1 tgcol3") + # TSIM: sql alter table $mt change tag tgcol2 tgcol4 + tdLog.info("alter table ta_ch_mt3 change tag tgcol2 tgcol4") + tdSql.execute("alter table ta_ch_mt3 change tag tgcol2 tgcol4") + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: $i = 4 + # TSIM: $mt = $mtPrefix . $i + # TSIM: $tb = $tbPrefix . $i + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bigint, tgcol2 float) + tdLog.info( + "create table ta_ch_mt4 (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float)") + tdSql.execute( + 'create table ta_ch_mt4 (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float)') + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info("create table tb4 using ta_ch_mt4 tags( 1, 2 )") + tdSql.execute('create table tb4 using ta_ch_mt4 tags( 1, 2 )') + # TSIM: sql insert into $tb values(now, 1) + tdLog.info("insert into tb4 values(now, 1)") + tdSql.execute("insert into tb4 values(now, 1)") + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from ta_ch_mt4 where tgcol1 = 1') + tdSql.query('select * from ta_ch_mt4 where tgcol1 = 1') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2.00000 then + tdLog.info('tdSql.checkData(0, 3, 2.00000)') + tdSql.checkData(0, 3, 2.00000) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt change tag tgcol1 tgcol3 + tdLog.info("alter table ta_ch_mt4 change tag tgcol1 tgcol3") + tdSql.execute("alter table ta_ch_mt4 change tag tgcol1 tgcol3") + # TSIM: sql alter table $mt change tag tgcol2 tgcol4 + tdLog.info("alter table ta_ch_mt4 change tag tgcol2 tgcol4") + tdSql.execute("alter table ta_ch_mt4 change tag tgcol2 tgcol4") + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: $i = 5 + # TSIM: $mt = $mtPrefix . $i + # TSIM: $tb = $tbPrefix . $i + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # double, tgcol2 binary(10)) + tdLog.info( + "create table ta_ch_mt5 (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10))") + tdSql.execute( + 'create table ta_ch_mt5 (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10))') + # TSIM: sql create table $tb using $mt tags( 1, '2' ) + tdLog.info("create table tb5 using ta_ch_mt5 tags( 1, '2' )") + tdSql.execute("create table tb5 using ta_ch_mt5 tags( 1, '2' )") + # TSIM: sql insert into $tb values(now, 1) + tdLog.info("insert into tb5 values(now, 1)") + tdSql.execute("insert into tb5 values(now, 1)") + # TSIM: sql select * from $mt where tgcol2 = '2' + tdLog.info("select * from ta_ch_mt5 where tgcol2 = '2'") + tdSql.query("select * from ta_ch_mt5 where tgcol2 = '2'") + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1.000000000 then + tdLog.info('tdSql.checkData(0, 2, 1.000000000)') + tdSql.checkData(0, 2, 1.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, "2") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt change tag tgcol1 tgcol3 + tdLog.info("alter table ta_ch_mt5 change tag tgcol1 tgcol3") + tdSql.execute("alter table ta_ch_mt5 change tag tgcol1 tgcol3") + # TSIM: sql alter table $mt change tag tgcol2 tgcol4 + tdLog.info("alter table ta_ch_mt5 change tag tgcol2 tgcol4") + tdSql.execute("alter table ta_ch_mt5 change tag tgcol2 tgcol4") + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: $i = 6 + # TSIM: $mt = $mtPrefix . $i + # TSIM: $tb = $tbPrefix . $i + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 + # double, tgcol6 binary(20)) + tdLog.info("create table ta_ch_mt6 (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20))") + tdSql.execute( + 'create table ta_ch_mt6 (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20))') + # TSIM: sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' ) + tdLog.info( + "create table tb6 using ta_ch_mt6 tags( '1', 2, 3, '4', 5, '6' )") + tdSql.execute( + "create table tb6 using ta_ch_mt6 tags( '1', 2, 3, '4', 5, '6' )") + # TSIM: sql insert into $tb values(now, 1) + tdLog.info("insert into tb6 values(now, 1)") + tdSql.execute("insert into tb6 values(now, 1)") + # TSIM: sql select * from $mt where tgcol1 = '1' + tdLog.info("select * from ta_ch_mt6 where tgcol1 = '1'") + tdSql.query("select * from ta_ch_mt6 where tgcol1 = '1'") + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info("tdSql.checkData(0, 1, 1)") + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, "1")') + tdSql.checkData(0, 2, "1") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, 3) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != 4 then + tdLog.info('tdSql.checkData(0, 5, 4)') + tdSql.checkData(0, 5, '4') + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data06 != 5.000000000 then + tdLog.info('tdSql.checkData(0, 6, 5.000000000)') + tdSql.checkData(0, 6, 5.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data07 != 6 then + tdLog.info('tdSql.checkData(0, 7, 6)') + tdSql.checkData(0, 7, '6') + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info("alter table ta_ch_mt6 drop tag tgcol3") + tdSql.execute("alter table ta_ch_mt6 drop tag tgcol3") + # TSIM: sql reset query cache + tdLog.info("reset query cache") + tdSql.execute("reset query cache") + # TSIM: sql alter table $mt change tag tgcol4 tgcol3 + tdLog.info("alter table ta_ch_mt6 change tag tgcol4 tgcol3") + tdSql.execute("alter table ta_ch_mt6 change tag tgcol4 tgcol3") + # TSIM: sql alter table $mt change tag tgcol1 tgcol7 + tdLog.info("alter table ta_ch_mt6 change tag tgcol1 tgcol7") + tdSql.execute("alter table ta_ch_mt6 change tag tgcol1 tgcol7") + # TSIM: sql alter table $mt change tag tgcol2 tgcol8 + tdLog.info("alter table ta_ch_mt6 change tag tgcol2 tgcol8") + tdSql.execute("alter table ta_ch_mt6 change tag tgcol2 tgcol8") + # TSIM: sql reset query cache + tdLog.info("reset query cache") + tdSql.execute("reset query cache") + # TSIM: sql alter table $mt change tag tgcol3 tgcol9 + tdLog.info("alter table ta_ch_mt6 change tag tgcol3 tgcol9") + tdSql.execute("alter table ta_ch_mt6 change tag tgcol3 tgcol9") + # TSIM: sql alter table $mt change tag tgcol5 tgcol10 + tdLog.info("alter table ta_ch_mt6 change tag tgcol5 tgcol10") + tdSql.execute("alter table ta_ch_mt6 change tag tgcol5 tgcol10") + # TSIM: sql alter table $mt change tag tgcol6 tgcol11 + tdLog.info("alter table ta_ch_mt6 change tag tgcol6 tgcol11") + tdSql.execute("alter table ta_ch_mt6 change tag tgcol6 tgcol11") + # TSIM: + # TSIM: sleep 5000 + # TSIM: sql reset query cache + tdLog.info("reset query cache") + tdSql.execute("reset query cache") + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: $i = 2 + # TSIM: $mt = $mtPrefix . $i + # TSIM: $tb = $tbPrefix . $i + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = 1 -x step24 + tdLog.info('select * from ta_ch_mt2 where tgcol1 = 1 -x step24') + tdSql.error("select * from ta_ch_mt2 where tgcol1 = 1") + # TSIM: return -1 + # TSIM: step24: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step25 + tdLog.info('select * from ta_ch_mt2 where tgcol2 = 1 -x step25') + tdSql.error('select * from ta_ch_mt2 where tgcol2 = 1') + # TSIM: return -1 + # TSIM: step25: + # TSIM: + # TSIM: sql select * from $mt where tgcol3 = 1 + tdLog.info('select * from ta_ch_mt2 where tgcol3 = 1') + tdSql.query('select * from ta_ch_mt2 where tgcol3 = 1') + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 2 + tdLog.info('select * from ta_ch_mt2 where tgcol4 = 2') + tdSql.query('select * from ta_ch_mt2 where tgcol4 = 2') + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: $i = 3 + # TSIM: $mt = $mtPrefix . $i + # TSIM: $tb = $tbPrefix . $i + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = 1 -x step31 + tdLog.info('select * from ta_ch_mt3 where tgcol1 = 1 -x step31') + tdSql.error('select * from ta_ch_mt3 where tgcol1 = 1') + # TSIM: return -1 + # TSIM: step31: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step32 + tdLog.info('select * from ta_ch_mt3 where tgcol2 = 1 -x step32') + tdSql.error('select * from ta_ch_mt3 where tgcol2 = 1') + # TSIM: return -1 + # TSIM: step32: + # TSIM: + # TSIM: sql select * from $mt where tgcol3 = 1 + tdLog.info('select * from ta_ch_mt3 where tgcol3 = 1') + tdSql.query('select * from ta_ch_mt3 where tgcol3 = 1') + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 2 + tdLog.info('select * from ta_ch_mt3 where tgcol4 = 2') + tdSql.query('select * from ta_ch_mt3 where tgcol4 = 2') + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: $i = 4 + # TSIM: $mt = $mtPrefix . $i + # TSIM: $tb = $tbPrefix . $i + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = 1 -x step41 + tdLog.info('select * from ta_ch_mt4 where tgcol1 = 1 -x step41') + tdSql.error('select * from ta_ch_mt4 where tgcol1 = 11') + # TSIM: return -1 + # TSIM: step41: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step42 + tdLog.info('select * from ta_ch_mt4 where tgcol2 = 1 -x step42') + tdSql.error('select * from ta_ch_mt4 where tgcol2 = 12') + # TSIM: return -1 + # TSIM: step42: + # TSIM: + # TSIM: sql select * from $mt where tgcol3 = 1 + tdLog.info('select * from ta_ch_mt4 where tgcol3 = 1') + tdSql.query('select * from ta_ch_mt4 where tgcol3 = 1') + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2.00000 then + tdLog.info('tdSql.checkData(0, 3, 2.00000)') + tdSql.checkData(0, 3, 2.00000) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 2 + tdLog.info('select * from ta_ch_mt4 where tgcol4 = 2') + tdSql.query('select * from ta_ch_mt4 where tgcol4 = 2') + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2.00000 then + tdLog.info('tdSql.checkData(0, 3, 2.00000)') + tdSql.checkData(0, 3, 2.00000) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: $i = 5 + # TSIM: $mt = $mtPrefix . $i + # TSIM: $tb = $tbPrefix . $i + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = 1 -x step51 + tdLog.info('select * from ta_ch_mt5 where tgcol1 = 1 -x step51') + tdSql.error('select * from ta_ch_mt5 where tgcol1 = 11') + # TSIM: return -1 + # TSIM: step51: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step52 + tdLog.info('select * from ta_ch_mt5 where tgcol2 = 1 -x step52') + tdSql.error('select * from ta_ch_mt5 where tgcol2 = 12') + # TSIM: return -1 + # TSIM: step52: + # TSIM: + # TSIM: sql select * from $mt where tgcol3 = 1 + tdLog.info('select * from ta_ch_mt5 where tgcol3 = 1') + tdSql.query('select * from ta_ch_mt5 where tgcol3 = 1') + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1.000000000 then + tdLog.info('tdSql.checkData(0, 2, 1.000000000)') + tdSql.checkData(0, 2, 1.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, "2") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = '2' + tdLog.info("select * from ta_ch_mt5 where tgcol4 = '2'") + tdSql.query("select * from ta_ch_mt5 where tgcol4 = '2'") + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1.000000000 then + tdLog.info('tdSql.checkData(0, 2, 1.000000000)') + tdSql.checkData(0, 2, 1.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, "2") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: $i = 6 + # TSIM: $mt = $mtPrefix . $i + # TSIM: $tb = $tbPrefix . $i + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = 1 -x step61 + tdLog.info('select * from ta_ch_mt6 where tgcol1 = 1 -x step61') + tdSql.error('select * from ta_ch_mt6 where tgcol1 = 1') + # TSIM: return -1 + # TSIM: step61: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step62 + tdLog.info('select * from ta_ch_mt6 where tgcol2 = 1 -x step62') + tdSql.error('select * from ta_ch_mt6 where tgcol2 = 1') + # TSIM: return -1 + # TSIM: step62: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step63 + tdLog.info('select * from ta_ch_mt6 where tgcol3 = 1 -x step63') + tdSql.error('select * from ta_ch_mt6 where tgcol3 = 1') + # TSIM: return -1 + # TSIM: step63: + # TSIM: sql select * from $mt where tgcol4 = 1 -x step64 + tdLog.info('select * from ta_ch_mt6 where tgcol4 = 1 -x step64') + tdSql.error('select * from ta_ch_mt6 where tgcol4 = 1') + # TSIM: return -1 + # TSIM: step64: + # TSIM: sql select * from $mt where tgcol5 = 1 -x step65 + tdLog.info('select * from ta_ch_mt6 where tgcol5 = 1 -x step65') + tdSql.error('select * from ta_ch_mt6 where tgcol5 = 1') + # TSIM: return -1 + # TSIM: step65: + # TSIM: sql select * from $mt where tgcol6 = 1 -x step66 + tdLog.info('select * from ta_ch_mt6 where tgcol6 = 1 -x step66') + tdSql.error('select * from ta_ch_mt6 where tgcol6 = 1') + # TSIM: return -1 + # TSIM: step66: + # TSIM: + # TSIM: sql select * from $mt where tgcol7 = '1' + tdLog.info("select * from ta_ch_mt6 where tgcol7 = '1'") + tdSql.query("select * from ta_ch_mt6 where tgcol7 = '1'") + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, "1")') + tdSql.checkData(0, 2, "1") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 4 then + tdLog.info('tdSql.checkData(0, 4, "4")') + tdSql.checkData(0, 4, "4") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != 5.000000000 then + tdLog.info('tdSql.checkData(0, 5, 5.000000000)') + tdSql.checkData(0, 5, 5.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data06 != 6 then + tdLog.info('tdSql.checkData(0, 6, "6")') + tdSql.checkData(0, 6, "6") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data07 != NULL then + tdLog.info('tdSql.checkData(0, 7, NULL)') + + try: + tdSql.checkData(0, 7, None) + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("out of range") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol8 = 2 + tdLog.info('select * from ta_ch_mt6 where tgcol8 = 2') + tdSql.query('select * from ta_ch_mt6 where tgcol8 = 2') + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, "1")') + tdSql.checkData(0, 2, "1") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 4 then + tdLog.info('tdSql.checkData(0, 4, "4"")') + tdSql.checkData(0, 4, "4") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != 5.000000000 then + tdLog.info('tdSql.checkData(0, 5, 5.000000000)') + tdSql.checkData(0, 5, 5.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data06 != 6 then + tdLog.info('tdSql.checkData(0, 6, "6")') + tdSql.checkData(0, 6, "6") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data07 != NULL then + tdLog.info('tdSql.checkData(0, 7, NULL)') + try: + tdSql.checkData(0, 7, None) + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("out of range") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol9 = '4' + tdLog.info("select * from ta_ch_mt6 where tgcol9 = '4'") + tdSql.query("select * from ta_ch_mt6 where tgcol9 = '4'") + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, "1")') + tdSql.checkData(0, 2, "1") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 4 then + tdLog.info('tdSql.checkData(0, 4, "4")') + tdSql.checkData(0, 4, "4") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != 5.000000000 then + tdLog.info('tdSql.checkData(0, 5, 5.000000000)') + tdSql.checkData(0, 5, 5.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data06 != 6 then + tdLog.info('tdSql.checkData(0, 6, "6")') + tdSql.checkData(0, 6, "6") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data07 != NULL then + tdLog.info('tdSql.checkData(0, 7, NULL)') + try: + tdSql.checkData(0, 7, None) + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("out of range") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol10 = 5 + tdLog.info('select * from ta_ch_mt6 where tgcol10 = 5') + tdSql.query('select * from ta_ch_mt6 where tgcol10 = 5') + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, "1")') + tdSql.checkData(0, 2, "1") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 4 then + tdLog.info('tdSql.checkData(0, 4, "4")') + tdSql.checkData(0, 4, "4") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != 5.000000000 then + tdLog.info('tdSql.checkData(0, 5, 5.000000000)') + tdSql.checkData(0, 5, 5.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data06 != 6 then + tdLog.info('tdSql.checkData(0, 6, "6")') + tdSql.checkData(0, 6, "6") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data07 != NULL then + tdLog.info('tdSql.checkData(0, 7, NULL)') + try: + tdSql.checkData(0, 7, None) + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("out of range") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol11 = '6' + tdLog.info("select * from ta_ch_mt6 where tgcol11 = '6'") + tdSql.query("select * from ta_ch_mt6 where tgcol11 = '6'") + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, "1")') + tdSql.checkData(0, 2, "1") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 4 then + tdLog.info('tdSql.checkData(0, 4, "4")') + tdSql.checkData(0, 4, "4") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != 5.000000000 then + tdLog.info('tdSql.checkData(0, 5, 5.000000000)') + tdSql.checkData(0, 5, 5.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data06 != 6 then + tdLog.info('tdSql.checkData(0, 6, "6")') + tdSql.checkData(0, 6, "6") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data07 != NULL then + tdLog.info('tdSql.checkData(0, 7, NULL)') + try: + tdSql.checkData(0, 7, None) + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("out of range") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/column.py b/tests/pytest/tag_lite/column.py new file mode 100644 index 0000000000000000000000000000000000000000..f82f83c356b63cb0d7d3fe41b4f4d7c0ff875195 --- /dev/null +++ b/tests/pytest/tag_lite/column.py @@ -0,0 +1,197 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_co_db + # TSIM: $tbPrefix = ta_co_tb + tbPrefix = "ta_co_tb" + # TSIM: $mtPrefix = ta_co_mt + mtPrefix = "ta_co_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: sql create table $mt (ts timestamp, tbcol int, tbcol2 + # binary(10)) TAGS(tgcol int, tgcol2 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int, tbcol2 binary(10)) TAGS(tgcol int, tgcol2 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int, tbcol2 binary(10)) TAGS(tgcol int, tgcol2 binary(10))' % + (mt)) + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 0, '0' ) + tdLog.info('create table %s using %s tags( 0, "0" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 0, "0" )' % (tb, mt)) + # TSIM: + # TSIM: $i = 1 + i = 1 + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 1, 1 ) + tdLog.info('create table %s using %s tags( 1, 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 1 )' % (tb, mt)) + # TSIM: + # TSIM: $i = 2 + i = 2 + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( '2', '2' ) + tdLog.info('create table %s using %s tags( "2", "2" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( "2", "2" )' % (tb, mt)) + # TSIM: + # TSIM: $i = 3 + i = 3 + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( '3', 3 ) + tdLog.info('create table %s using %s tags( "3", 3 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( "3", 3 )' % (tb, mt)) + # TSIM: + # TSIM: sql show tables + tdLog.info('show tables') + tdSql.query('show tables') + # TSIM: if $rows != 4 then + tdLog.info('tdSql.checkRow(4)') + tdSql.checkRows(4) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql insert into $tb values(now, 0, '0') + tdLog.info('insert into %s values(now, 0, "0")' % (tb)) + tdSql.execute('insert into %s values(now, 0, "0")' % (tb)) + # TSIM: + # TSIM: $i = 1 + i = 1 + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql insert into $tb values(now, 1, 1 ) + tdLog.info('insert into %s values(now, 1, 1 )' % (tb)) + tdSql.execute('insert into %s values(now, 1, 1 )' % (tb)) + # TSIM: + # TSIM: $i = 2 + i = 2 + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql insert into $tb values(now, '2', '2') + tdLog.info('insert into %s values(now, "2", "2")' % (tb)) + tdSql.execute('insert into %s values(now, "2", "2")' % (tb)) + # TSIM: + # TSIM: $i = 3 + i = 3 + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql insert into $tb values(now, '3', 3) + tdLog.info('insert into %s values(now, "3", 3)' % (tb)) + tdSql.execute('insert into %s values(now, "3", 3)' % (tb)) + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol2 = '1' + tdLog.info('select * from %s where tgcol2 = "1"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "1"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != 4 then + tdLog.info('tdSql.checkRow(4)') + tdSql.checkRows(4) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/commit.py b/tests/pytest/tag_lite/commit.py new file mode 100644 index 0000000000000000000000000000000000000000..8b69d4aa5f482340012c53a4be1c2b9c8c1b2e92 --- /dev/null +++ b/tests/pytest/tag_lite/commit.py @@ -0,0 +1,2321 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = db + # TSIM: $tbPrefix = tb + tbPrefix = "tb" + # TSIM: $mtPrefix = mt + mtPrefix = "mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: $i = 2 + i = 2 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bool, tgcol2 int) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt add tag tgcol4 int + tdLog.info('alter table %s add tag tgcol4 int' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 int' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4 =4 + tdLog.info('alter table %s set tag tgcol4 =4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4 =4' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 4 + tdLog.info('select * from %s where tgcol4 = 4' % (mt)) + tdSql.query('select * from %s where tgcol4 = 4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step2 + tdLog.info('select * from %s where tgcol2 = 1 -x step2' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step2: + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: $i = 3 + i = 3 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # smallint, tgcol2 tinyint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt add tag tgcol4 tinyint + tdLog.info('alter table %s add tag tgcol4 tinyint' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 tinyint' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=4 + tdLog.info('alter table %s set tag tgcol4=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=4' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 4 + tdLog.info('select * from %s where tgcol4 = 4' % (mt)) + tdSql.query('select * from %s where tgcol4 = 4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step3 + tdLog.info('select * from %s where tgcol2 = 1 -x step3' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step3: + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: $i = 4 + i = 4 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bigint, tgcol2 float) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2.00000 then + tdLog.info('tdSql.checkData(0, 3, 2.00000)') + tdSql.checkData(0, 3, 2.00000) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql describe $tb + tdLog.info('describe %s' % (tb)) + tdSql.query('describe %s' % (tb)) + # TSIM: if $data21 != BIGINT then + tdLog.info('tdSql.checkDataType(2, 1, "BIGINT")') + tdSql.checkDataType(2, 1, "BIGINT") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data31 != FLOAT then + tdLog.info('tdSql.checkDataType(3, 1, "FLOAT")') + tdSql.checkDataType(3, 1, "FLOAT") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data23 != 1 then + tdLog.info('tdSql.checkData(2, 3, "TAG")') + tdSql.checkData(2, 3, "TAG") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data33 != 2.000000 then + tdLog.info('tdSql.checkData(3, 3, "TAG")') + tdSql.checkData(3, 3, "TAG") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt add tag tgcol4 float + tdLog.info('alter table %s add tag tgcol4 float' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 float' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=4 + tdLog.info('alter table %s set tag tgcol4=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=4' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 4 + tdLog.info('select * from %s where tgcol4 = 4' % (mt)) + tdSql.query('select * from %s where tgcol4 = 4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 4.00000 then + tdLog.info('tdSql.checkData(0, 3, 4.00000)') + tdSql.checkData(0, 3, 4.00000) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step4 + tdLog.info('select * from %s where tgcol2 = 1 -x step4' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step4: + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: $i = 5 + i = 5 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # double, tgcol2 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, '2' ) + tdLog.info('create table %s using %s tags( 1, "2" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, "2" )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = '2' + tdLog.info('select * from %s where tgcol2 = "2"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "2"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1.000000000 then + tdLog.info('tdSql.checkData(0, 2, 1.000000000)') + tdSql.checkData(0, 2, 1.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, "2")') + tdSql.checkData(0, 3, "2") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt add tag tgcol4 smallint + tdLog.info('alter table %s add tag tgcol4 smallint' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 smallint' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=4 + tdLog.info('alter table %s set tag tgcol4=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=4' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 4 + tdLog.info('select * from %s where tgcol4 = 4' % (mt)) + tdSql.query('select * from %s where tgcol4 = 4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1.000000000 then + tdLog.info('tdSql.checkData(0, 2, 1.000000000)') + tdSql.checkData(0, 2, 1.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol3 = '1' -x step5 + tdLog.info('select * from %s where tgcol3 = "1" -x step5' % (mt)) + tdSql.error('select * from %s where tgcol3 = "1"' % (mt)) + # TSIM: return -1 + # TSIM: step5: + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: $i = 6 + i = 6 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bool, tgcol2 int, tgcol3 tinyint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 tinyint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 tinyint)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, 3 ) + tdLog.info('create table %s using %s tags( 1, 2, 3 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2, 3 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, 3) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt change tag tgcol1 tgcol4 + tdLog.info('alter table %s change tag tgcol1 tgcol4' % (mt)) + tdSql.execute('alter table %s change tag tgcol1 tgcol4' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt add tag tgcol5 binary(10) + tdLog.info('alter table %s add tag tgcol5 binary(10)' % (mt)) + tdSql.execute('alter table %s add tag tgcol5 binary(10)' % (mt)) + # TSIM: sql alter table $mt add tag tgcol6 binary(10) + tdLog.info('alter table %s add tag tgcol6 binary(10)' % (mt)) + tdSql.execute('alter table %s add tag tgcol6 binary(10)' % (mt)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=false + tdLog.info('alter table %s set tag tgcol4=false' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=false' % (tb)) + # TSIM: sql alter table $tb set tag tgcol5=5 + tdLog.info('alter table %s set tag tgcol5=5' % (tb)) + tdSql.execute('alter table %s set tag tgcol5=5' % (tb)) + # TSIM: sql alter table $tb set tag tgcol6=6 + tdLog.info('alter table %s set tag tgcol6=6' % (tb)) + tdSql.execute('alter table %s set tag tgcol6=6' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol5 = '5' + tdLog.info('select * from %s where tgcol5 = "5"' % (mt)) + tdSql.query('select * from %s where tgcol5 = "5"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 0 then + tdLog.info('tdSql.checkData(0, 2, 0)') + tdSql.checkData(0, 2, 0) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 5 then + tdLog.info('tdSql.checkData(0, 3, "5")') + tdSql.checkData(0, 3, "5") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 6 then + tdLog.info('tdSql.checkData(0, 4, "6")') + tdSql.checkData(0, 4, "6") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol6 = '6' + tdLog.info('select * from %s where tgcol6 = "6"' % (mt)) + tdSql.query('select * from %s where tgcol6 = "6"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 0 then + tdLog.info('tdSql.checkData(0, 2, 0)') + tdSql.checkData(0, 2, 0) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 5 then + tdLog.info('tdSql.checkData(0, 3, "5")') + tdSql.checkData(0, 3, "5") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 6 then + tdLog.info('tdSql.checkData(0, 4, "6")') + tdSql.checkData(0, 4, "6") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 1 + tdLog.info('select * from %s where tgcol4 = 1' % (mt)) + tdSql.query('select * from %s where tgcol4 = 1' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol3 = 1 -x step52 + tdLog.info('select * from %s where tgcol3 = 1 -x step52' % (mt)) + tdSql.error('select * from %s where tgcol3 = 12' % (mt)) + # TSIM: return -1 + # TSIM: step52: + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: $i = 7 + i = 7 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # smallint, tgcol2 tinyint, tgcol3 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint, tgcol3 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint, tgcol3 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, '3' ) + tdLog.info('create table %s using %s tags( 1, 2, "3" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2, "3" )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol3 = '3' + tdLog.info('select * from %s where tgcol3 = "3"' % (mt)) + tdSql.query('select * from %s where tgcol3 = "3"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, "3")') + tdSql.checkData(0, 4, "3") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt change tag tgcol1 tgcol4 + tdLog.info('alter table %s change tag tgcol1 tgcol4' % (mt)) + tdSql.execute('alter table %s change tag tgcol1 tgcol4' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt add tag tgcol5 bigint + tdLog.info('alter table %s add tag tgcol5 bigint' % (mt)) + tdSql.execute('alter table %s add tag tgcol5 bigint' % (mt)) + # TSIM: sql alter table $mt add tag tgcol6 tinyint + tdLog.info('alter table %s add tag tgcol6 tinyint' % (mt)) + tdSql.execute('alter table %s add tag tgcol6 tinyint' % (mt)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=4 + tdLog.info('alter table %s set tag tgcol4=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=4' % (tb)) + # TSIM: sql alter table $tb set tag tgcol5=5 + tdLog.info('alter table %s set tag tgcol5=5' % (tb)) + tdSql.execute('alter table %s set tag tgcol5=5' % (tb)) + # TSIM: sql alter table $tb set tag tgcol6=6 + tdLog.info('alter table %s set tag tgcol6=6' % (tb)) + tdSql.execute('alter table %s set tag tgcol6=6' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol6 = 6 + tdLog.info('select * from %s where tgcol6 = 6' % (mt)) + tdSql.query('select * from %s where tgcol6 = 6' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 4 then + tdLog.info('tdSql.checkData(0, 2, 4)') + tdSql.checkData(0, 2, 4) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 5 then + tdLog.info('tdSql.checkData(0, 3, 5)') + tdSql.checkData(0, 3, 5) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 6 then + tdLog.info('tdSql.checkData(0, 4, 6)') + tdSql.checkData(0, 4, 6) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step71 + tdLog.info('select * from %s where tgcol2 = 1 -x step71' % (mt)) + tdSql.error('select * from %s where tgcol2 = 11' % (mt)) + # TSIM: return -1 + # TSIM: step71: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step72 + tdLog.info('select * from %s where tgcol3 = 1 -x step72' % (mt)) + tdSql.error('select * from %s where tgcol3 = 12' % (mt)) + # TSIM: return -1 + # TSIM: step72: + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: $i = 8 + i = 8 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bigint, tgcol2 float, tgcol3 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float, tgcol3 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float, tgcol3 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, '3' ) + tdLog.info('create table %s using %s tags( 1, 2, "3" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2, "3" )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol3 = '3' + tdLog.info('select * from %s where tgcol3 = "3"' % (mt)) + tdSql.query('select * from %s where tgcol3 = "3"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2.00000 then + tdLog.info('tdSql.checkData(0, 3, 2.00000)') + tdSql.checkData(0, 3, 2.00000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, "3")') + tdSql.checkData(0, 4, "3") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt change tag tgcol1 tgcol4 + tdLog.info('alter table %s change tag tgcol1 tgcol4' % (mt)) + tdSql.execute('alter table %s change tag tgcol1 tgcol4' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt add tag tgcol5 binary(17) + tdLog.info('alter table %s add tag tgcol5 binary(17)' % (mt)) + tdSql.execute('alter table %s add tag tgcol5 binary(17)' % (mt)) + # TSIM: sql alter table $mt add tag tgcol6 bool + tdLog.info('alter table %s add tag tgcol6 bool' % (mt)) + tdSql.execute('alter table %s add tag tgcol6 bool' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=4 + tdLog.info('alter table %s set tag tgcol4=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=4' % (tb)) + # TSIM: sql alter table $tb set tag tgcol5=5 + tdLog.info('alter table %s set tag tgcol5=5' % (tb)) + tdSql.execute('alter table %s set tag tgcol5=5' % (tb)) + # TSIM: sql alter table $tb set tag tgcol6=1 + tdLog.info('alter table %s set tag tgcol6=1' % (tb)) + tdSql.execute('alter table %s set tag tgcol6=1' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol5 = '5' + tdLog.info('select * from %s where tgcol5 = "5"' % (mt)) + tdSql.query('select * from %s where tgcol5 = "5"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 4 then + tdLog.info('tdSql.checkData(0, 2, 4)') + tdSql.checkData(0, 2, 4) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 5 then + tdLog.info('tdSql.checkData(0, 3, "5")') + tdSql.checkData(0, 3, "5") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 1 then + tdLog.info('tdSql.checkData(0, 4, 1)') + tdSql.checkData(0, 4, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step81 + tdLog.info('select * from %s where tgcol2 = 1 -x step81' % (mt)) + tdSql.error('select * from %s where tgcol2 = 11' % (mt)) + # TSIM: return -1 + # TSIM: step81: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step82 + tdLog.info('select * from %s where tgcol3 = 1 -x step82' % (mt)) + tdSql.error('select * from %s where tgcol3 = 12' % (mt)) + # TSIM: return -1 + # TSIM: step82: + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: $i = 9 + i = 9 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # double, tgcol2 binary(10), tgcol3 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10), tgcol3 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10), tgcol3 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, '3' ) + tdLog.info('create table %s using %s tags( 1, 2, "3" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2, "3" )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = '2' + tdLog.info('select * from %s where tgcol2 = "2"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "2"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1.000000000 then + tdLog.info('tdSql.checkData(0, 2, 1.000000000)') + tdSql.checkData(0, 2, 1.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, "2")') + tdSql.checkData(0, 3, "2") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, "3")') + tdSql.checkData(0, 4, "3") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt change tag tgcol1 tgcol4 + tdLog.info('alter table %s change tag tgcol1 tgcol4' % (mt)) + tdSql.execute('alter table %s change tag tgcol1 tgcol4' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt add tag tgcol5 bool + tdLog.info('alter table %s add tag tgcol5 bool' % (mt)) + tdSql.execute('alter table %s add tag tgcol5 bool' % (mt)) + # TSIM: sql alter table $mt add tag tgcol6 float + tdLog.info('alter table %s add tag tgcol6 float' % (mt)) + tdSql.execute('alter table %s add tag tgcol6 float' % (mt)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=4 + tdLog.info('alter table %s set tag tgcol4=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=4' % (tb)) + # TSIM: sql alter table $tb set tag tgcol5=1 + tdLog.info('alter table %s set tag tgcol5=1' % (tb)) + tdSql.execute('alter table %s set tag tgcol5=1' % (tb)) + # TSIM: sql alter table $tb set tag tgcol6=6 + tdLog.info('alter table %s set tag tgcol6=6' % (tb)) + tdSql.execute('alter table %s set tag tgcol6=6' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol5 = 1 + tdLog.info('select * from %s where tgcol5 = 1' % (mt)) + tdSql.query('select * from %s where tgcol5 = 1' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 4.000000000 then + tdLog.info('tdSql.checkData(0, 2, 4.000000000)') + tdSql.checkData(0, 2, 4.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 1 then + tdLog.info('tdSql.checkData(0, 3, 1)') + tdSql.checkData(0, 3, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 6.00000 then + tdLog.info('tdSql.checkData(0, 4, 6.00000)') + tdSql.checkData(0, 4, 6.00000) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step91 + tdLog.info('select * from %s where tgcol3 = 1 -x step91' % (mt)) + tdSql.error('select * from %s where tgcol3 = 11' % (mt)) + # TSIM: return -1 + # TSIM: step91: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step92 + tdLog.info('select * from %s where tgcol2 = 1 -x step92' % (mt)) + tdSql.error('select * from %s where tgcol2 = 12' % (mt)) + # TSIM: return -1 + # TSIM: step92: + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: $i = 10 + i = 10 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( '1', '2', '3', '4' ) + tdLog.info( + 'create table %s using %s tags( "1", "2", "3", "4" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( "1", "2", "3", "4" )' % + (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol4 = '4' + tdLog.info('select * from %s where tgcol4 = "4"' % (mt)) + tdSql.query('select * from %s where tgcol4 = "4"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, "1")') + tdSql.checkData(0, 2, "1") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, "2")') + tdSql.checkData(0, 3, "2") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, "3")') + tdSql.checkData(0, 4, "3") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != 4 then + tdLog.info('tdSql.checkData(0, 5, "4")') + tdSql.checkData(0, 5, "4") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt change tag tgcol1 tgcol4 -x step103 + tdLog.info('alter table %s change tag tgcol1 tgcol4 -x step103' % (mt)) + tdSql.error('alter table %s change tag tgcol1 tgcol4' % (mt)) + # TSIM: return -1 + # TSIM: step103: + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol4 + tdLog.info('alter table %s drop tag tgcol4' % (mt)) + tdSql.execute('alter table %s drop tag tgcol4' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $mt add tag tgcol4 binary(10) + tdLog.info('alter table %s add tag tgcol4 binary(10)' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 binary(10)' % (mt)) + # TSIM: sql alter table $mt add tag tgcol5 bool + tdLog.info('alter table %s add tag tgcol5 bool' % (mt)) + tdSql.execute('alter table %s add tag tgcol5 bool' % (mt)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=4 + tdLog.info('alter table %s set tag tgcol4=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=4' % (tb)) + # TSIM: sql alter table $tb set tag tgcol5=false + tdLog.info('alter table %s set tag tgcol5=false' % (tb)) + tdSql.execute('alter table %s set tag tgcol5=false' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = '4' + tdLog.info('select * from %s where tgcol4 = "4"' % (mt)) + tdSql.query('select * from %s where tgcol4 = "4"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, "1")') + tdSql.checkData(0, 2, "1") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, "4")') + tdSql.checkData(0, 3, "4") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 0 then + tdLog.info('tdSql.checkData(0, 4, 0)') + tdSql.checkData(0, 4, 0) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != NULL then + tdLog.info('tdSql.checkData(0, 5, NULL)') + try: + tdSql.checkData(0, 5, None) + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("out of range") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step101 + tdLog.info('select * from %s where tgcol2 = 1 -x step101' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step101: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step102 + tdLog.info('select * from %s where tgcol3 = 1 -x step102' % (mt)) + tdSql.error('select * from %s where tgcol3 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step102: + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: $i = 11 + i = 11 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bool, tgcol2 int, tgcol3 smallint, tgcol4 float, tgcol5 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 smallint, tgcol4 float, tgcol5 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 smallint, tgcol4 float, tgcol5 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, 3, 4, '5' ) + tdLog.info( + 'create table %s using %s tags( 1, 2, 3, 4, "5" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( 1, 2, 3, 4, "5" )' % + (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, 3) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != 4.00000 then + tdLog.info('tdSql.checkData(0, 5, 4.00000)') + tdSql.checkData(0, 5, 4.00000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data06 != 5 then + tdLog.info('tdSql.checkData(0, 6, "5")') + tdSql.checkData(0, 6, "5") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt change tag tgcol1 tgcol4 -x step114 + tdLog.info('alter table %s change tag tgcol1 tgcol4 -x step114' % (mt)) + tdSql.error('alter table %s change tag tgcol1 tgcol4' % (mt)) + # TSIM: return -1 + # TSIM: step114: + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol4 + tdLog.info('alter table %s drop tag tgcol4' % (mt)) + tdSql.execute('alter table %s drop tag tgcol4' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol5 + tdLog.info('alter table %s drop tag tgcol5' % (mt)) + tdSql.execute('alter table %s drop tag tgcol5' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $mt add tag tgcol4 binary(10) + tdLog.info('alter table %s add tag tgcol4 binary(10)' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 binary(10)' % (mt)) + # TSIM: sql alter table $mt add tag tgcol5 int + tdLog.info('alter table %s add tag tgcol5 int' % (mt)) + tdSql.execute('alter table %s add tag tgcol5 int' % (mt)) + # TSIM: sql alter table $mt add tag tgcol6 binary(10) + tdLog.info('alter table %s add tag tgcol6 binary(10)' % (mt)) + tdSql.execute('alter table %s add tag tgcol6 binary(10)' % (mt)) + # TSIM: sql alter table $mt add tag tgcol7 bigint + tdLog.info('alter table %s add tag tgcol7 bigint' % (mt)) + tdSql.execute('alter table %s add tag tgcol7 bigint' % (mt)) + # TSIM: sql alter table $mt add tag tgcol8 smallint + tdLog.info('alter table %s add tag tgcol8 smallint' % (mt)) + tdSql.execute('alter table %s add tag tgcol8 smallint' % (mt)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol4=4 + tdLog.info('alter table %s set tag tgcol4=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=4' % (tb)) + # TSIM: sql alter table $tb set tag tgcol5=5 + tdLog.info('alter table %s set tag tgcol5=5' % (tb)) + tdSql.execute('alter table %s set tag tgcol5=5' % (tb)) + # TSIM: sql alter table $tb set tag tgcol6=6 + tdLog.info('alter table %s set tag tgcol6=6' % (tb)) + tdSql.execute('alter table %s set tag tgcol6=6' % (tb)) + # TSIM: sql alter table $tb set tag tgcol7=7 + tdLog.info('alter table %s set tag tgcol7=7' % (tb)) + tdSql.execute('alter table %s set tag tgcol7=7' % (tb)) + # TSIM: sql alter table $tb set tag tgcol8=8 + tdLog.info('alter table %s set tag tgcol8=8' % (tb)) + tdSql.execute('alter table %s set tag tgcol8=8' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol5 =5 + tdLog.info('select * from %s where tgcol5 =5' % (mt)) + tdSql.query('select * from %s where tgcol5 =5' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, "4")') + tdSql.checkData(0, 3, "4") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 5 then + tdLog.info('tdSql.checkData(0, 4, 5)') + tdSql.checkData(0, 4, 5) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != 6 then + tdLog.info('tdSql.checkData(0, 5, "6")') + tdSql.checkData(0, 5, "6") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data06 != 7 then + tdLog.info('tdSql.checkData(0, 6, 7)') + tdSql.checkData(0, 6, 7) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data07 != 8 then + tdLog.info('tdSql.checkData(0, 7, 8)') + tdSql.checkData(0, 7, 8) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step111 + tdLog.info('select * from %s where tgcol2 = 1 -x step111' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step111: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step112 + tdLog.info('select * from %s where tgcol3 = 1 -x step112' % (mt)) + tdSql.error('select * from %s where tgcol3 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step112: + # TSIM: sql select * from $mt where tgcol9 = 1 -x step113 + tdLog.info('select * from %s where tgcol9 = 1 -x step113' % (mt)) + tdSql.error('select * from %s where tgcol9 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step113: + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: $i = 12 + i = 12 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bool, tgcol2 smallint, tgcol3 float, tgcol4 double, tgcol5 + # binary(10), tgcol6 binary(20)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 smallint, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 binary(20))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 smallint, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 binary(20))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, 3, 4, '5', '6' ) + tdLog.info( + 'create table %s using %s tags( 1, 2, 3, 4, "5", "6" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( 1, 2, 3, 4, "5", "6" )' % + (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 3.00000 then + tdLog.info('tdSql.checkData(0, 4, 3.00000)') + tdSql.checkData(0, 4, 3.00000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != 4.000000000 then + tdLog.info('tdSql.checkData(0, 5, 4.000000000)') + tdSql.checkData(0, 5, 4.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data06 != 5 then + tdLog.info('tdSql.checkData(0, 6, "5")') + tdSql.checkData(0, 6, "5") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data07 != 6 then + tdLog.info('tdSql.checkData(0, 7, "6")') + tdSql.checkData(0, 7, "6") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol4 + tdLog.info('alter table %s drop tag tgcol4' % (mt)) + tdSql.execute('alter table %s drop tag tgcol4' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol5 + tdLog.info('alter table %s drop tag tgcol5' % (mt)) + tdSql.execute('alter table %s drop tag tgcol5' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $mt add tag tgcol2 binary(10) + tdLog.info('alter table %s add tag tgcol2 binary(10)' % (mt)) + tdSql.execute('alter table %s add tag tgcol2 binary(10)' % (mt)) + # TSIM: sql alter table $mt add tag tgcol3 int + tdLog.info('alter table %s add tag tgcol3 int' % (mt)) + tdSql.execute('alter table %s add tag tgcol3 int' % (mt)) + # TSIM: sql alter table $mt add tag tgcol4 binary(10) + tdLog.info('alter table %s add tag tgcol4 binary(10)' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 binary(10)' % (mt)) + # TSIM: sql alter table $mt add tag tgcol5 bigint + tdLog.info('alter table %s add tag tgcol5 bigint' % (mt)) + tdSql.execute('alter table %s add tag tgcol5 bigint' % (mt)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol1=false + tdLog.info('alter table %s set tag tgcol1=false' % (tb)) + tdSql.execute('alter table %s set tag tgcol1=false' % (tb)) + # TSIM: sql alter table $tb set tag tgcol2=5 + tdLog.info('alter table %s set tag tgcol2=5' % (tb)) + tdSql.execute('alter table %s set tag tgcol2=5' % (tb)) + # TSIM: sql alter table $tb set tag tgcol3=4 + tdLog.info('alter table %s set tag tgcol3=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol3=4' % (tb)) + # TSIM: sql alter table $tb set tag tgcol4=3 + tdLog.info('alter table %s set tag tgcol4=3' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=3' % (tb)) + # TSIM: sql alter table $tb set tag tgcol5=2 + tdLog.info('alter table %s set tag tgcol5=2' % (tb)) + tdSql.execute('alter table %s set tag tgcol5=2' % (tb)) + # TSIM: sql alter table $tb set tag tgcol6=1 + tdLog.info('alter table %s set tag tgcol6=1' % (tb)) + tdSql.execute('alter table %s set tag tgcol6=1' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = '3' + tdLog.info('select * from %s where tgcol4 = "3"' % (mt)) + tdSql.query('select * from %s where tgcol4 = "3"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 0 then + tdLog.info('tdSql.checkData(0, 2, 0)') + tdSql.checkData(0, 2, 0) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 1 then + tdLog.info('tdSql.checkData(0, 3, "1")') + tdSql.checkData(0, 3, "1") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 5 then + tdLog.info('tdSql.checkData(0, 4, "5")') + tdSql.checkData(0, 4, "5") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != 4 then + tdLog.info('tdSql.checkData(0, 5, 4)') + tdSql.checkData(0, 5, 4) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data06 != 3 then + tdLog.info('tdSql.checkData(0, 6, "3")') + tdSql.checkData(0, 6, "3") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data07 != 2 then + tdLog.info('tdSql.checkData(0, 7, 2)') + tdSql.checkData(0, 7, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = '5' + tdLog.info('select * from %s where tgcol2 = "5"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "5"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol3 = 4 + tdLog.info('select * from %s where tgcol3 = 4' % (mt)) + tdSql.query('select * from %s where tgcol3 = 4' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol5 = 2 + tdLog.info('select * from %s where tgcol5 = 2' % (mt)) + tdSql.query('select * from %s where tgcol5 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol6 = '1' + tdLog.info('select * from %s where tgcol6 = "1"' % (mt)) + tdSql.query('select * from %s where tgcol6 = "1"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step13 + tdLog.info('=============== step13') + # TSIM: $i = 13 + i = 13 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 + # double, tgcol6 binary(20)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' ) + tdLog.info( + 'create table %s using %s tags( "1", 2, 3, "4", 5, "6" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( "1", 2, 3, "4", 5, "6" )' % + (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol1 = '1' + tdLog.info('select * from %s where tgcol1 = "1"' % (mt)) + tdSql.query('select * from %s where tgcol1 = "1"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, "1")') + tdSql.checkData(0, 2, "1") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, 3) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != 4 then + tdLog.info('tdSql.checkData(0, 5, "4")') + tdSql.checkData(0, 5, "4") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data06 != 5.000000000 then + tdLog.info('tdSql.checkData(0, 6, 5.000000000)') + tdSql.checkData(0, 6, 5.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data07 != 6 then + tdLog.info('tdSql.checkData(0, 7, "6")') + tdSql.checkData(0, 7, "6") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol4 + tdLog.info('alter table %s drop tag tgcol4' % (mt)) + tdSql.execute('alter table %s drop tag tgcol4' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol6 + tdLog.info('alter table %s drop tag tgcol6' % (mt)) + tdSql.execute('alter table %s drop tag tgcol6' % (mt)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $mt add tag tgcol2 binary(10) + tdLog.info('alter table %s add tag tgcol2 binary(10)' % (mt)) + tdSql.execute('alter table %s add tag tgcol2 binary(10)' % (mt)) + # TSIM: sql alter table $mt add tag tgcol4 int + tdLog.info('alter table %s add tag tgcol4 int' % (mt)) + tdSql.execute('alter table %s add tag tgcol4 int' % (mt)) + # TSIM: sql alter table $mt add tag tgcol6 bigint + tdLog.info('alter table %s add tag tgcol6 bigint' % (mt)) + tdSql.execute('alter table %s add tag tgcol6 bigint' % (mt)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql alter table $tb set tag tgcol1=7 + tdLog.info('alter table %s set tag tgcol1=7' % (tb)) + tdSql.execute('alter table %s set tag tgcol1=7' % (tb)) + # TSIM: sql alter table $tb set tag tgcol2=8 + tdLog.info('alter table %s set tag tgcol2=8' % (tb)) + tdSql.execute('alter table %s set tag tgcol2=8' % (tb)) + # TSIM: sql alter table $tb set tag tgcol3=9 + tdLog.info('alter table %s set tag tgcol3=9' % (tb)) + tdSql.execute('alter table %s set tag tgcol3=9' % (tb)) + # TSIM: sql alter table $tb set tag tgcol4=10 + tdLog.info('alter table %s set tag tgcol4=10' % (tb)) + tdSql.execute('alter table %s set tag tgcol4=10' % (tb)) + # TSIM: sql alter table $tb set tag tgcol5=11 + tdLog.info('alter table %s set tag tgcol5=11' % (tb)) + tdSql.execute('alter table %s set tag tgcol5=11' % (tb)) + # TSIM: sql alter table $tb set tag tgcol6=12 + tdLog.info('alter table %s set tag tgcol6=12' % (tb)) + tdSql.execute('alter table %s set tag tgcol6=12' % (tb)) + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = '8' + tdLog.info('select * from %s where tgcol2 = "8"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "8"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 7 then + tdLog.info('tdSql.checkData(0, 2, "7")') + tdSql.checkData(0, 2, "7") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 9 then + tdLog.info('tdSql.checkData(0, 3, 9)') + tdSql.checkData(0, 3, 9) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 11.000000000 then + tdLog.info('tdSql.checkData(0, 4, 11.000000000)') + tdSql.checkData(0, 4, 11.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != 8 then + tdLog.info('tdSql.checkData(0, 5, "8")') + tdSql.checkData(0, 5, "8") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data06 != 10 then + tdLog.info('tdSql.checkData(0, 6, 10)') + tdSql.checkData(0, 6, 10) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data07 != 12 then + tdLog.info('tdSql.checkData(0, 7, 12)') + tdSql.checkData(0, 7, 12) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT + # TSIM: sleep 5000 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: sleep 3000 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: + # TSIM: sql use $db + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: $i = 2 + i = 2 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 4 + tdLog.info('select * from %s where tgcol4 = 4' % (mt)) + tdSql.query('select * from %s where tgcol4 = 4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: $i = 3 + i = 3 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 4 + tdLog.info('select * from %s where tgcol4 = 4' % (mt)) + tdSql.query('select * from %s where tgcol4 = 4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: $i = 4 + i = 4 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 4 + tdLog.info('select * from %s where tgcol4 = 4' % (mt)) + tdSql.query('select * from %s where tgcol4 = 4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 4.00000 then + tdLog.info('tdSql.checkData(0, 3, 4.00000)') + tdSql.checkData(0, 3, 4.00000) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: $i = 5 + i = 5 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 4 + tdLog.info('select * from %s where tgcol4 = 4' % (mt)) + tdSql.query('select * from %s where tgcol4 = 4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1.000000000 then + tdLog.info('tdSql.checkData(0, 2, 1.000000000)') + tdSql.checkData(0, 2, 1.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: $i = 6 + i = 6 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol5 = '5' + tdLog.info('select * from %s where tgcol5 = "5"' % (mt)) + tdSql.query('select * from %s where tgcol5 = "5"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 0 then + tdLog.info('tdSql.checkData(0, 2, 0)') + tdSql.checkData(0, 2, 0) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 5 then + tdLog.info('tdSql.checkData(0, 3, "5")') + tdSql.checkData(0, 3, "5") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 6 then + tdLog.info('tdSql.checkData(0, 4, "6")') + tdSql.checkData(0, 4, "6") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol6 = '6' + tdLog.info('select * from %s where tgcol6 = "6"' % (mt)) + tdSql.query('select * from %s where tgcol6 = "6"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 0 then + tdLog.info('tdSql.checkData(0, 2, 0)') + tdSql.checkData(0, 2, 0) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 5 then + tdLog.info(': tdSql.checkData(0, 3, "5")') + tdSql.checkData(0, 3, "5") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 6 then + tdLog.info('tdSql.checkData(0, 4, "6")') + tdSql.checkData(0, 4, "6") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 1 + tdLog.info('select * from %s where tgcol4 = 1' % (mt)) + tdSql.query('select * from %s where tgcol4 = 1' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: $i = 7 + i = 7 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol6 = 6 + tdLog.info('select * from %s where tgcol6 = 6' % (mt)) + tdSql.query('select * from %s where tgcol6 = 6' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 4 then + tdLog.info('tdSql.checkData(0, 2, 4)') + tdSql.checkData(0, 2, 4) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 5 then + tdLog.info('tdSql.checkData(0, 3, 5)') + tdSql.checkData(0, 3, 5) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 6 then + tdLog.info('tdSql.checkData(0, 4, 6)') + tdSql.checkData(0, 4, 6) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: $i = 8 + i = 8 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol5 = '5' + tdLog.info('select * from %s where tgcol5 = "5"' % (mt)) + tdSql.query('select * from %s where tgcol5 = "5"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 4 then + tdLog.info('tdSql.checkData(0, 2, 4)') + tdSql.checkData(0, 2, 4) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 5 then + tdLog.info('tdSql.checkData(0, 3, "5")') + tdSql.checkData(0, 3, "5") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 1 then + tdLog.info('tdSql.checkData(0, 4, 1)') + tdSql.checkData(0, 4, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: $i = 9 + i = 9 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol5 = 1 + tdLog.info('select * from %s where tgcol5 = 1' % (mt)) + tdSql.query('select * from %s where tgcol5 = 1' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 4.000000000 then + tdLog.info('tdSql.checkData(0, 2, 4.000000000)') + tdSql.checkData(0, 2, 4.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 1 then + tdLog.info('tdSql.checkData(0, 3, 1)') + tdSql.checkData(0, 3, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 6.00000 then + tdLog.info('tdSql.checkData(0, 4, 6.00000)') + tdSql.checkData(0, 4, 6.00000) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: $i = 10 + i = 10 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = '4' + tdLog.info('select * from %s where tgcol4 = "4"' % (mt)) + tdSql.query('select * from %s where tgcol4 = "4"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, "1")') + tdSql.checkData(0, 2, "1") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, "4")') + tdSql.checkData(0, 3, "4") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 0 then + tdLog.info('tdSql.checkData(0, 4, 0)') + tdSql.checkData(0, 4, 0) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != NULL then + tdLog.info('tdSql.checkData(0, 5, NULL)') + try: + tdSql.checkData(0, 5, None) + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("out of range") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: $i = 11 + i = 11 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol5 =5 + tdLog.info('select * from %s where tgcol5 =5' % (mt)) + tdSql.query('select * from %s where tgcol5 =5' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, "4")') + tdSql.checkData(0, 3, "4") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 5 then + tdLog.info('tdSql.checkData(0, 4, 5)') + tdSql.checkData(0, 4, 5) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != 6 then + tdLog.info('tdSql.checkData(0, 5, "6")') + tdSql.checkData(0, 5, "6") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data06 != 7 then + tdLog.info('tdSql.checkData(0, 6, 7)') + tdSql.checkData(0, 6, 7) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data07 != 8 then + tdLog.info('tdSql.checkData(0, 7, 8)') + tdSql.checkData(0, 7, 8) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: $i = 12 + i = 12 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = '3' + tdLog.info('select * from %s where tgcol4 = "3"' % (mt)) + tdSql.query('select * from %s where tgcol4 = "3"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 0 then + tdLog.info('tdSql.checkData(0, 2, 0)') + tdSql.checkData(0, 2, 0) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 1 then + tdLog.info('tdSql.checkData(0, 3, "1")') + tdSql.checkData(0, 3, "1") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 5 then + tdLog.info('tdSql.checkData(0, 4, "5")') + tdSql.checkData(0, 4, "5") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != 4 then + tdLog.info('tdSql.checkData(0, 5, 4)') + tdSql.checkData(0, 5, 4) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data06 != 3 then + tdLog.info('tdSql.checkData(0, 6, "3")') + tdSql.checkData(0, 6, "3") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data07 != 2 then + tdLog.info('tdSql.checkData(0, 7, 2)') + tdSql.checkData(0, 7, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = '5' + tdLog.info('select * from %s where tgcol2 = "5"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "5"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol3 = 4 + tdLog.info('select * from %s where tgcol3 = 4' % (mt)) + tdSql.query('select * from %s where tgcol3 = 4' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol5 = 2 + tdLog.info('select * from %s where tgcol5 = 2' % (mt)) + tdSql.query('select * from %s where tgcol5 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol6 = '1' + tdLog.info('select * from %s where tgcol6 = "1"' % (mt)) + tdSql.query('select * from %s where tgcol6 = "1"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step13 + tdLog.info('=============== step13') + # TSIM: $i = 13 + i = 13 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = '8' + tdLog.info('select * from %s where tgcol2 = "8"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "8"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 7 then + tdLog.info('tdSql.checkData(0, 2, "7")') + tdSql.checkData(0, 2, "7") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 9 then + tdLog.info('tdSql.checkData(0, 3, 9)') + tdSql.checkData(0, 3, 9) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 11.000000000 then + tdLog.info('tdSql.checkData(0, 4, 11.000000000)') + tdSql.checkData(0, 4, 11.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != 8 then + tdLog.info('tdSql.checkData(0, 5, "8")') + tdSql.checkData(0, 5, "8") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data06 != 10 then + tdLog.info('tdSql.checkData(0, 6, 10)') + tdSql.checkData(0, 6, 10) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data07 != 12 then + tdLog.info('tdSql.checkData(0, 7, 12)') + tdSql.checkData(0, 7, 12) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/create-tags-boundary.py b/tests/pytest/tag_lite/create-tags-boundary.py new file mode 100644 index 0000000000000000000000000000000000000000..b98ae627c2999e96d233dd63ba8c1ce795531265 --- /dev/null +++ b/tests/pytest/tag_lite/create-tags-boundary.py @@ -0,0 +1,66 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import subprocess +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + getMaxTagNum = "grep -w TSDB_MAX_TAGS ../../src/inc/taosdef.h|awk '{print $3}'" + boundary = int(subprocess.check_output(getMaxTagNum, shell=True)) + tdLog.info("get max tags number is %d" % boundary) + for x in range(0, boundary): + stb_name = "stb%d" % x + + tagSeq = "tag0 int" + for y in range(1, x + 1): + tagSeq = tagSeq + ", tag%d int" % y + + tdLog.info( + "create table %s (ts timestamp, value int) tags (%s)" % + (stb_name, tagSeq)) + tdSql.execute( + "create table %s (ts timestamp, value int) tags (%s)" % + (stb_name, tagSeq)) + + tdSql.query("show stables") + tdSql.checkRows(boundary) + + stb_name = "stb%d" % (boundary + 1) + tagSeq = tagSeq + ", tag%d int" % (boundary) + tdLog.info( + "create table %s (ts timestamp, value int) tags (%s)" % + (stb_name, tagSeq)) + tdSql.error( + "create table %s (ts timestamp, value int) tags (%s)" % + (stb_name, tagSeq)) + tdSql.query("show stables") + tdSql.checkRows(boundary) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/create.py b/tests/pytest/tag_lite/create.py new file mode 100644 index 0000000000000000000000000000000000000000..83a14501437177fe9113efda31821ed1986cac7f --- /dev/null +++ b/tests/pytest/tag_lite/create.py @@ -0,0 +1,1398 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_cr_db + # TSIM: $tbPrefix = ta_cr_tb + tbPrefix = "ta_cr_tb" + # TSIM: $mtPrefix = ta_cr_mt + mtPrefix = "ta_cr_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: $i = 2 + i = 2 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1 ) + tdLog.info('create table %s using %s tags( 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: $i = 3 + i = 3 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # smallint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol smallint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol smallint)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1 ) + tdLog.info('create table %s using %s tags( 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: $i = 4 + i = 4 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # tinyint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol tinyint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol tinyint)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1 ) + tdLog.info('create table %s using %s tags( 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: $i = 5 + i = 5 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol int)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol int)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1 ) + tdLog.info('create table %s using %s tags( 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: $i = 6 + i = 6 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # bigint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bigint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bigint)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1 ) + tdLog.info('create table %s using %s tags( 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: $i = 7 + i = 7 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # float) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol float)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol float)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1 ) + tdLog.info('create table %s using %s tags( 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: print expect 0, actual: $rows + tdLog.info('expect 0, actual: $rows') + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: $i = 8 + i = 8 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # double) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol double)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol double)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1 ) + tdLog.info('create table %s using %s tags( 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: $i = 9 + i = 9 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( '1') + tdLog.info('create table %s using %s tags( "1")' % (tb, mt)) + tdSql.execute('create table %s using %s tags( "1")' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol = '1' + tdLog.info('select * from %s where tgcol = "1"' % (mt)) + tdSql.query('select * from %s where tgcol = "1"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = '0' + tdLog.info('select * from %s where tgcol = "0"' % (mt)) + tdSql.query('select * from %s where tgcol = "0"' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: $i = 10 + i = 10 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, + # tgcol2 bool) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 bool)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 bool)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: print expect 1, actual: $rows + tdLog.info('expect 1, actual: $rows') + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: $i = 11 + i = 11 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, + # tgcol2 smallint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 smallint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 smallint)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: $i = 12 + i = 12 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, + # tgcol2 tinyint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 tinyint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 tinyint)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step13 + tdLog.info('=============== step13') + # TSIM: $i = 13 + i = 13 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, + # tgcol2 int) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 int)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 int)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step14 + tdLog.info('=============== step14') + # TSIM: $i = 14 + i = 14 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, + # tgcol2 bigint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 bigint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 bigint)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: print =============== step15 + tdLog.info('=============== step15') + # TSIM: $i = 15 + i = 15 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, + # tgcol2 float) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 float)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 float)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step16 + tdLog.info('=============== step16') + # TSIM: $i = 16 + i = 16 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, + # tgcol2 double) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 double)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 double)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step17 + tdLog.info('=============== step17') + # TSIM: $i = 17 + i = 17 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, + # tgcol2 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, '2' ) + tdLog.info('create table %s using %s tags( 1, "2" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, "2" )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol = true + tdLog.info('select * from %s where tgcol = true' % (mt)) + tdSql.query('select * from %s where tgcol = true' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step18 + tdLog.info('=============== step18') + # TSIM: $i = 18 + i = 18 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # smallint, tgcol2 tinyint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol smallint, tgcol2 tinyint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol smallint, tgcol2 tinyint)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step19 + tdLog.info('=============== step19') + # TSIM: $i = 19 + i = 19 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # tinyint, tgcol2 int) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol tinyint, tgcol2 int)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol tinyint, tgcol2 int)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step20 + tdLog.info('=============== step20') + # TSIM: $i = 20 + i = 20 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int, + # tgcol2 bigint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol int, tgcol2 bigint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol int, tgcol2 bigint)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step21 + tdLog.info('=============== step21') + # TSIM: $i = 21 + i = 21 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # bigint, tgcol2 float) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bigint, tgcol2 float)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bigint, tgcol2 float)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step22 + tdLog.info('=============== step22') + # TSIM: $i = 22 + i = 22 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # float, tgcol2 double) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol float, tgcol2 double)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol float, tgcol2 double)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step23 + tdLog.info('=============== step23') + # TSIM: $i = 23 + i = 23 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # double, tgcol2 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol double, tgcol2 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol double, tgcol2 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, '2' ) + tdLog.info('create table %s using %s tags( 1, "2" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, "2" )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = '2' + tdLog.info('select * from %s where tgcol2 = "2"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "2"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step24 + tdLog.info('=============== step24') + # TSIM: $i = 24 + i = 24 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bool, tgcol2 bool, tgcol3 int, tgcol4 float, tgcol5 double, tgcol6 + # binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 bool, tgcol3 int, tgcol4 float, tgcol5 double, tgcol6 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 bool, tgcol3 int, tgcol4 float, tgcol5 double, tgcol6 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, 3, 4, 5, '6' ) + tdLog.info( + 'create table %s using %s tags( 1, 2, 3, 4, 5, "6" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( 1, 2, 3, 4, 5, "6" )' % + (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol3 = 3 + tdLog.info('select * from %s where tgcol3 = 3' % (mt)) + tdSql.query('select * from %s where tgcol3 = 3' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol4 = 4 + tdLog.info('select * from %s where tgcol4 = 4' % (mt)) + tdSql.query('select * from %s where tgcol4 = 4' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol5 = 5 + tdLog.info('select * from %s where tgcol5 = 5' % (mt)) + tdSql.query('select * from %s where tgcol5 = 5' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol6 = '6' + tdLog.info('select * from %s where tgcol6 = "6"' % (mt)) + tdSql.query('select * from %s where tgcol6 = "6"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol6 = '0' + tdLog.info('select * from %s where tgcol6 = "0"' % (mt)) + tdSql.query('select * from %s where tgcol6 = "0"' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step25 + tdLog.info('=============== step25') + # TSIM: $i = 25 + i = 25 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, + # tgcol2 int, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 + # binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 int, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 int, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, 3, 4, '5', '6' ) + tdLog.info( + 'create table %s using %s tags( 1, 2, 3, 4, "5", "6" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( 1, 2, 3, 4, "5", "6" )' % + (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol6 = '6' + tdLog.info('select * from %s where tgcol6 = "6"' % (mt)) + tdSql.query('select * from %s where tgcol6 = "6"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol6 = '0' + tdLog.info('select * from %s where tgcol6 = "0"' % (mt)) + tdSql.query('select * from %s where tgcol6 = "0"' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step26 + tdLog.info('=============== step26') + # TSIM: $i = 26 + i = 26 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10), + # tgcol5 binary(10), tgcol6 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10), tgcol5 binary(10), tgcol6 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10), tgcol5 binary(10), tgcol6 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( '1', '2', '3', '4', '5', + # '6' ) + tdLog.info( + 'create table %s using %s tags( "1", "2", "3", "4", "5", "6" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( "1", "2", "3", "4", "5", "6" )' % + (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol3 = '3' + tdLog.info('select * from %s where tgcol3 = "3"' % (mt)) + tdSql.query('select * from %s where tgcol3 = "3"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol3 = '0' + tdLog.info('select * from %s where tgcol3 = "0"' % (mt)) + tdSql.query('select * from %s where tgcol3 = "0"' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step27 + tdLog.info('=============== step27') + # TSIM: $i = 27 + i = 27 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, + # tgcol2 bool, tgcol3 int, tgcol4 float, tgcol5 double, tgcol6 + # binary(10), tgcol7) -x step27 + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 bool, tgcol3 int, tgcol4 float, tgcol5 double, tgcol6 binary(10), tgcol7) -x step27' % + (mt)) + tdSql.error( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 bool, tgcol3 int, tgcol4 float, tgcol5 double, tgcol6 binary(10), tgcol7)7' % + (mt)) + # TSIM: return -1 + # TSIM: step27: + # TSIM: + # TSIM: print =============== step28 + tdLog.info('=============== step28') + # TSIM: $i = 28 + i = 28 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # binary(250), tgcol2 binary(250)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(250), tgcol2 binary(250))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(250), tgcol2 binary(250))' % + (mt)) + # TSIM: sql create table $tb using $mt tags('1', '1') + tdLog.info('create table %s using %s tags("1", "1")' % (tb, mt)) + tdSql.execute('create table %s using %s tags("1", "1")' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol = '1' + tdLog.info('select * from %s where tgcol = "1"' % (mt)) + tdSql.query('select * from %s where tgcol = "1"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step29 + tdLog.info('=============== step29') + # TSIM: $i = 29 + i = 29 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # binary(25), tgcol2 binary(250)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(25), tgcol2 binary(250))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(25), tgcol2 binary(250))' % + (mt)) + # TSIM: sql create table $tb using $mt tags('1', '1') + tdLog.info('create table %s using %s tags("1", "1")' % (tb, mt)) + tdSql.execute('create table %s using %s tags("1", "1")' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol = '1' + tdLog.info('select * from %s where tgcol = "1"' % (mt)) + tdSql.query('select * from %s where tgcol = "1"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step30 + tdLog.info('=============== step30') + # TSIM: $i = 30 + i = 30 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # binary(250), tgcol2 binary(250), tgcol3 binary(30)) -x step30 + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(250), tgcol2 binary(250), tgcol3 binary(30)) -x step30' % + (mt)) + tdSql.error( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(250), tgcol2 binary(250), tgcol3 binary(30))0' % + (mt)) + # TSIM: return -1 + # TSIM: step30: + # TSIM: + # TSIM: print =============== step31 + tdLog.info('=============== step31') + # TSIM: $i = 31 + i = 31 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # binary(5)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(5))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(5))' % + (mt)) + # TSIM: sql_error create table $tb using $mt tags('1234567') + tdLog.info('create table %s using %s tags("1234567")' % (tb, mt)) + tdSql.error('create table %s using %s tags("1234567")' % (tb, mt)) + # TSIM: sql create table $tb using $mt tags('12345') + tdLog.info('create table %s using %s tags("12345")' % (tb, mt)) + tdSql.execute('create table %s using %s tags("12345")' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: print sql select * from $mt + tdLog.info('sql select * from $mt') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print $data00 $data01 $data02 + tdLog.info('$data00 $data01 $data02') + # TSIM: if $data02 != 12345 then + tdLog.info('tdSql.checkData(0, 2, "12345")') + tdSql.checkData(0, 2, "12345") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/datatype-without-alter.py b/tests/pytest/tag_lite/datatype-without-alter.py new file mode 100644 index 0000000000000000000000000000000000000000..da52e149a51c3128f82b8878ed8dc836fb726513 --- /dev/null +++ b/tests/pytest/tag_lite/datatype-without-alter.py @@ -0,0 +1,98 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 10 + self.rowsPerTable = 10 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdLog.info("================= step0") + tdSql.execute('reset query cache') + tdLog.info("drop database db if exits") + tdSql.execute('drop database if exists db') + tdLog.info("================= step1") + tdSql.execute('create database db') + tdLog.sleep(5) + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 super table") + tdSql.execute('create table stb (ts timestamp, i int) \ + tags (tin int, tfl float, tbg bigint, tdo double, tbi binary(10), tbl bool)') + + tdLog.info("================= step2") + tdLog.info("create %d tables" % self.ntables) + for tid in range(1, self.ntables + 1): + tdSql.execute( + 'create table tb%d using stb tags(%d,%f,%ld,%f,\'%s\',%d)' % + (tid, + tid % + 3, + 1.2 * + tid, + self.startTime + + tid, + 1.22 * + tid, + 't' + + str(tid), + tid % + 2)) + tdLog.sleep(5) + + tdLog.info("================= step3") + tdLog.info( + "insert %d data in to each %d tables" % + (self.rowsPerTable, self.ntables)) + for rid in range(1, self.rowsPerTable + 1): + sqlcmd = ['insert into'] + for tid in range(1, self.ntables + 1): + sqlcmd.append( + 'tb%d values(%ld,%d)' % + (tid, self.startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + tdSql.query('select count(*) from stb') + tdSql.checkData(0, 0, self.rowsPerTable * self.ntables) + + tdLog.info("================= step6") + tdLog.info("group and filter by tag1 int") + tdSql.query('select max(i) from stb where tbl=0 group by tin') + tdSql.checkRows(3) + tdSql.execute('reset query cache') + tdSql.query('select max(i) from stb where tbl=true group by tin') + tdSql.checkData(2, 0, self.rowsPerTable) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/datatype.py b/tests/pytest/tag_lite/datatype.py new file mode 100644 index 0000000000000000000000000000000000000000..40f0ed7a090683faf149e56620ff63db7a52acb3 --- /dev/null +++ b/tests/pytest/tag_lite/datatype.py @@ -0,0 +1,135 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 10 + self.rowsPerTable = 10 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + tdDnodes.deploy(1) + tdDnodes.start(1) + + tdLog.info("================= step0") + tdSql.execute('reset query cache') + tdLog.info("drop database db if exits") + tdSql.execute('drop database if exists db') + tdLog.info("================= step1") + tdSql.execute('create database db') + tdLog.sleep(5) + tdSql.execute('use db') + + tdLog.info("================= step1") + tdLog.info("create 1 super table") + tdSql.execute('create table stb (ts timestamp, i int) \ + tags (tin int, tfl float, tbg bigint, tdo double, tbi binary(10), tbl bool)') + + tdLog.info("================= step2") + tdLog.info("create %d tables" % self.ntables) + for tid in range(1, self.ntables + 1): + tdSql.execute( + 'create table tb%d using stb tags(%d,%f,%ld,%f,\'%s\',%d)' % + (tid, + tid % + 3, + 1.2 * + tid, + self.startTime + + tid, + 1.22 * + tid, + 't' + + str(tid), + tid % + 2)) + tdLog.sleep(5) + + tdLog.info("================= step3") + tdLog.info( + "insert %d data in to each %d tables" % + (self.rowsPerTable, self.ntables)) + for rid in range(1, self.rowsPerTable + 1): + sqlcmd = ['insert into'] + for tid in range(1, self.ntables + 1): + sqlcmd.append( + 'tb%d values(%ld,%d)' % + (tid, self.startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + tdSql.query('select count(*) from stb') + tdSql.checkData(0, 0, self.rowsPerTable * self.ntables) + + tdLog.info("================= step4") + tdLog.info("drop one tag") + tdSql.execute('alter table stb drop tag tbi') + tdLog.info("insert %d data in to each %d tables" % (2, self.ntables)) + for rid in range(self.rowsPerTable + 1, self.rowsPerTable + 3): + sqlcmd = ['insert into'] + for tid in range(1, self.ntables + 1): + sqlcmd.append( + 'tb%d values(%ld,%d)' % + (tid, self.startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + self.rowsPerTable += 2 + tdSql.query('select count(*) from stb') + tdSql.checkData(0, 0, self.rowsPerTable * self.ntables) + tdSql.query('describe tb1') + tdSql.checkRows(2 + 5) + + tdLog.info("================= step5") + tdLog.info("add one tag") + tdSql.execute('alter table stb add tag tnc nchar(10)') + for tid in range(1, self.ntables + 1): + tdSql.execute('alter table tb%d set tag tnc=\"%s\"' % + (tid, str(tid + 1000000000))) + tdLog.info("insert %d data in to each %d tables" % (2, self.ntables)) + for rid in range(self.rowsPerTable + 1, self.rowsPerTable + 3): + sqlcmd = ['insert into'] + for tid in range(1, self.ntables + 1): + sqlcmd.append( + 'tb%d values(%ld,%d)' % + (tid, self.startTime + rid, rid)) + tdSql.execute(" ".join(sqlcmd)) + self.rowsPerTable += 2 + tdSql.query('select count(*) from stb') + tdSql.checkData(0, 0, self.rowsPerTable * self.ntables) + tdSql.query('describe tb1') + tdSql.checkRows(2 + 6) + + tdLog.info("================= step6") + tdLog.info("group and filter by tag1 int") + tdSql.query('select max(i) from stb where tbl=0 group by tin') + tdSql.checkRows(3) + tdSql.execute('reset query cache') + tdSql.query('select max(i) from stb where tbl=true group by tin') + tdSql.checkData(2, 0, self.rowsPerTable) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/delete.py b/tests/pytest/tag_lite/delete.py new file mode 100644 index 0000000000000000000000000000000000000000..5e82a96bf41608782fca09d6aeb8b18aa1a727ef --- /dev/null +++ b/tests/pytest/tag_lite/delete.py @@ -0,0 +1,1718 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_de_db + # TSIM: $tbPrefix = ta_de_tb + tbPrefix = "ta_de_tb" + # TSIM: $mtPrefix = ta_de_mt + mtPrefix = "ta_de_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: $i = 2 + i = 2 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bool, tgcol2 int) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: $i = 3 + i = 3 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # smallint, tgcol2 tinyint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: $i = 4 + i = 4 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bigint, tgcol2 float) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 < 3 + tdLog.info('select * from %s where tgcol2 < 3' % (mt)) + tdSql.query('select * from %s where tgcol2 < 3' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2.00000 then + tdLog.info('tdSql.checkData(0, 3, 2.00000)') + tdSql.checkData(0, 3, 2.00000) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql describe $tb + tdLog.info('describe %s' % (tb)) + tdSql.query('describe %s' % (tb)) + # TSIM: if $data21 != BIGINT then + tdLog.info('tdSql.checkDataType(2, 1, "BIGINT")') + tdSql.checkDataType(2, 1, "BIGINT") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data31 != FLOAT then + tdLog.info('tdSql.checkDataType(3, 1, "FLOAT")') + tdSql.checkDataType(3, 1, "FLOAT") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data23 != 1 then + tdLog.info('tdSql.checkData(2, 3, "TAG")') + tdSql.checkData(2, 3, "TAG") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol1 -x step40 + tdLog.info('alter table %s drop tag tgcol1 -x step40' % (mt)) + tdSql.error('alter table %s drop tag tgcol1' % (mt)) + # TSIM: return -1 + # TSIM: step40: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: $i = 5 + i = 5 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # double, tgcol2 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, '2' ) + tdLog.info('create table %s using %s tags( 1, "2" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, "2" )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = '2' + tdLog.info('select * from %s where tgcol2 = "2"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "2"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1.000000000 then + tdLog.info('tdSql.checkData(0, 2, 1.000000000)') + tdSql.checkData(0, 2, 1.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, "2")') + tdSql.checkData(0, 3, "2") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol1 -x step50 + tdLog.info('alter table %s drop tag tgcol1 -x step50' % (mt)) + tdSql.error('alter table %s drop tag tgcol1' % (mt)) + # TSIM: return -1 + # TSIM: step50: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: $i = 6 + i = 6 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bool, tgcol2 int, tgcol3 tinyint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 tinyint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 tinyint)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, 3 ) + tdLog.info('create table %s using %s tags( 1, 2, 3 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2, 3 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, 3) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: $i = 7 + i = 7 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # smallint, tgcol2 tinyint, tgcol3 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint, tgcol3 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint, tgcol3 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, '3' ) + tdLog.info('create table %s using %s tags( 1, 2, "3" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2, "3" )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol3 = '3' + tdLog.info('select * from %s where tgcol3 = "3"' % (mt)) + tdSql.query('select * from %s where tgcol3 = "3"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, "3")') + tdSql.checkData(0, 4, "3") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql describe $tb + tdLog.info('describe %s' % (tb)) + tdSql.query('describe %s' % (tb)) + # TSIM: if $data21 != SMALLINT then + tdLog.info('tdSql.checkDataType(2, 1, "SMALLINT")') + tdSql.checkDataType(2, 1, "SMALLINT") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data31 != TINYINT then + tdLog.info('tdSql.checkDataType(3, 1, "TINYINT")') + tdSql.checkDataType(3, 1, "TINYINT") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data41 != BINARY then + tdLog.info('tdSql.checkDataType(4, 1, "BINARY")') + tdSql.checkDataType(4, 1, "BINARY") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data22 != 2 then + tdLog.info('tdSql.checkData(2, 2, 2)') + tdSql.checkData(2, 2, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data32 != 1 then + tdLog.info('tdSql.checkData(3, 2, 1)') + tdSql.checkData(3, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data42 != 10 then + tdLog.info('tdSql.checkData(4, 2, 10)') + tdSql.checkData(4, 2, 10) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data23 != 1 then + tdLog.info('tdSql.checkData(2, 3, "TAG")') + tdSql.checkData(2, 3, "TAG") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data33 != 2 then + tdLog.info('tdSql.checkData(3, 3, "TAG")') + tdSql.checkData(3, 3, "TAG") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data43 != 3 then + tdLog.info('tdSql.checkData(4, 3, "TAG")') + tdSql.checkData(4, 3, "TAG") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: $i = 8 + i = 8 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bigint, tgcol2 float, tgcol3 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float, tgcol3 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float, tgcol3 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, '3' ) + tdLog.info('create table %s using %s tags( 1, 2, "3" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2, "3" )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol3 = '3' + tdLog.info('select * from %s where tgcol3 = "3"' % (mt)) + tdSql.query('select * from %s where tgcol3 = "3"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2.00000 then + tdLog.info('tdSql.checkData(0, 3, 2.00000)') + tdSql.checkData(0, 3, 2.00000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, "3")') + tdSql.checkData(0, 4, "3") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: $i = 9 + i = 9 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # double, tgcol2 binary(10), tgcol3 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10), tgcol3 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10), tgcol3 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, '2', '3' ) + tdLog.info('create table %s using %s tags( 1, "2", "3" )' % (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( 1, "2", "3" )' % + (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1.000000000 then + tdLog.info('tdSql.checkData(0, 2, 1.000000000)') + tdSql.checkData(0, 2, 1.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, "2")') + tdSql.checkData(0, 3, "2") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, "3")') + tdSql.checkData(0, 4, "3") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: $i = 10 + i = 10 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( '1', '2', '3', '4' ) + tdLog.info( + 'create table %s using %s tags( "1", "2", "3", "4" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( "1", "2", "3", "4" )' % + (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol4 = '4' + tdLog.info('select * from %s where tgcol4 = "4"' % (mt)) + tdSql.query('select * from %s where tgcol4 = "4"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, "1")') + tdSql.checkData(0, 2, "1") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, "2")') + tdSql.checkData(0, 3, "2") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, "3")') + tdSql.checkData(0, 4, "3") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != 4 then + tdLog.info('tdSql.checkData(0, 5, "4")') + tdSql.checkData(0, 5, "4") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol4 + tdLog.info('alter table %s drop tag tgcol4' % (mt)) + tdSql.execute('alter table %s drop tag tgcol4' % (mt)) + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: $i = 11 + i = 11 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bool, tgcol2 int, tgcol3 smallint, tgcol4 float, tgcol5 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 smallint, tgcol4 float, tgcol5 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 smallint, tgcol4 float, tgcol5 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, 3, 4, '5' ) + tdLog.info( + 'create table %s using %s tags( 1, 2, 3, 4, "5" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( 1, 2, 3, 4, "5" )' % + (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, 3) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != 4.00000 then + tdLog.info('tdSql.checkData(0, 5, 4.00000)') + tdSql.checkData(0, 5, 4.00000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data06 != 5 then + tdLog.info('tdSql.checkData(0, 6, "5")') + tdSql.checkData(0, 6, "5") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol5 + tdLog.info('alter table %s drop tag tgcol5' % (mt)) + tdSql.execute('alter table %s drop tag tgcol5' % (mt)) + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: $i = 12 + i = 12 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bool, tgcol2 smallint, tgcol3 float, tgcol4 double, tgcol5 + # binary(10), tgcol6 binary(20)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 smallint, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 binary(20))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 smallint, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 binary(20))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2, 3, 4, '5', '6' ) + tdLog.info( + 'create table %s using %s tags( 1, 2, 3, 4, "5", "6" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( 1, 2, 3, 4, "5", "6" )' % + (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 3.00000 then + tdLog.info('tdSql.checkData(0, 4, 3.00000)') + tdSql.checkData(0, 4, 3.00000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != 4.000000000 then + tdLog.info('tdSql.checkData(0, 5, 4.000000000)') + tdSql.checkData(0, 5, 4.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data06 != 5 then + tdLog.info('tdSql.checkData(0, 6, "5")') + tdSql.checkData(0, 6, "5") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data07 != 6 then + tdLog.info('tdSql.checkData(0, 7, "6")') + tdSql.checkData(0, 7, "6") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol5 + tdLog.info('alter table %s drop tag tgcol5' % (mt)) + tdSql.execute('alter table %s drop tag tgcol5' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol6 + tdLog.info('alter table %s drop tag tgcol6' % (mt)) + tdSql.execute('alter table %s drop tag tgcol6' % (mt)) + # TSIM: + # TSIM: print =============== step13 + tdLog.info('=============== step13') + # TSIM: $i = 13 + i = 13 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 + # double, tgcol6 binary(20)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' ) + tdLog.info( + 'create table %s using %s tags( "1", 2, 3, "4", 5, "6" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( "1", 2, 3, "4", 5, "6" )' % + (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol1 = '1' + tdLog.info('select * from %s where tgcol1 = "1"' % (mt)) + tdSql.query('select * from %s where tgcol1 = "1"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, "1")') + tdSql.checkData(0, 2, "1") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, 3) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != 4 then + tdLog.info('tdSql.checkData(0, 5, "4")') + tdSql.checkData(0, 5, "4") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data06 != 5.000000000 then + tdLog.info('tdSql.checkData(0, 6, 5.000000000)') + tdSql.checkData(0, 6, 5.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data07 != 6 then + tdLog.info('tdSql.checkData(0, 7, "6")') + tdSql.checkData(0, 7, "6") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol4 + tdLog.info('alter table %s drop tag tgcol4' % (mt)) + tdSql.execute('alter table %s drop tag tgcol4' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol6 + tdLog.info('alter table %s drop tag tgcol6' % (mt)) + tdSql.execute('alter table %s drop tag tgcol6' % (mt)) + tdLog.info('=============== step14') + # TSIM: $i = 14 + i = 14 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 + # double, tgcol6 binary(20)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int unsigned, tgcol3 smallint unsigned, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20), tgcol7 tinyint unsigned, tgcol8 bigint unsigned)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int unsigned, tgcol3 smallint unsigned, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20), tgcol7 tinyint unsigned, tgcol8 bigint unsigned)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' ) + tdLog.info( + 'create table %s using %s tags( "1", 2, 3, "4", 5, "6", 7, 8 )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( "1", 2, 3, "4", 5, "6", 7, 8 )' % + (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol1 = '1' + tdLog.info('select * from %s where tgcol1 = "1"' % (mt)) + tdSql.query('select * from %s where tgcol1 = "1"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, "1")') + tdSql.checkData(0, 2, "1") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, 3) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != 4 then + tdLog.info('tdSql.checkData(0, 5, "4")') + tdSql.checkData(0, 5, "4") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data06 != 5.000000000 then + tdLog.info('tdSql.checkData(0, 6, 5.000000000)') + tdSql.checkData(0, 6, 5.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data07 != 6 then + tdLog.info('tdSql.checkData(0, 7, "6")') + tdSql.checkData(0, 7, "6") + tdLog.info('tdSql.checkData(0, 8, 7)') + tdSql.checkData(0, 8, 7) + tdLog.info('tdSql.checkData(0, 9, 8)') + tdSql.checkData(0, 9, 8) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol4 + tdLog.info('alter table %s drop tag tgcol4' % (mt)) + tdSql.execute('alter table %s drop tag tgcol4' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol6 + tdLog.info('alter table %s drop tag tgcol6' % (mt)) + tdSql.execute('alter table %s drop tag tgcol6' % (mt)) + tdLog.info('alter table %s drop tag tgcol8' % (mt)) + tdSql.execute('alter table %s drop tag tgcol8' % (mt)) + # TSIM: + # TSIM: sleep 5000 + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: $i = 2 + i = 2 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != NULL then + tdLog.info('tdSql.checkData(0, 3, NULL)') + try: + tdSql.checkData(0, 3, None) + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("out of range") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step2 + tdLog.info('select * from %s where tgcol2 = 1 -x step2' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step2: + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: $i = 3 + i = 3 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != NULL then + tdLog.info('tdSql.checkData(0, 3, NULL)') + try: + tdSql.checkData(0, 3, None) + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("out of range") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step3 + tdLog.info('select * from %s where tgcol2 = 1 -x step3' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step3: + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: $i = 4 + i = 4 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != NULL then + tdLog.info('tdSql.checkData(0, 3, NULL)') + try: + tdSql.checkData(0, 3, None) + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("out of range") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step4 + tdLog.info('select * from %s where tgcol2 = 1 -x step4' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step4: + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: $i = 5 + i = 5 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1.000000000 then + tdLog.info('tdSql.checkData(0, 2, 1.000000000)') + tdSql.checkData(0, 2, 1.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != NULL then + tdLog.info('tdSql.checkData(0, 3, NULL)') + try: + tdSql.checkData(0, 3, None) + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("out of range") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = '1' -x step5 + tdLog.info('select * from %s where tgcol2 = "1" -x step5' % (mt)) + tdSql.error('select * from %s where tgcol2 = "1"' % (mt)) + # TSIM: return -1 + # TSIM: step5: + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: $i = 6 + i = 6 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != NULL then + tdLog.info('tdSql.checkData(0, 3, NULL)') + try: + tdSql.checkData(0, 3, None) + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("out of range") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != NULL then + tdLog.info('tdSql.checkData(0, 4, NULL) out of range') + # tdSql.checkData(0, 4, None) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step51 + tdLog.info('select * from %s where tgcol2 = 1 -x step51' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step51: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step52 + tdLog.info('select * from %s where tgcol3 = 1 -x step52' % (mt)) + tdSql.error('select * from %s where tgcol3 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step52: + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: $i = 7 + i = 7 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != NULL then + tdLog.info('tdSql.checkData(0, 3, NULL)') + try: + tdSql.checkData(0, 3, None) + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("out of range") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != NULL then + tdLog.info('tdSql.checkData(0, 4, NULL) out of range') + # tdSql.checkData(0, 4, None) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step71 + tdLog.info('select * from %s where tgcol2 = 1 -x step71' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step71: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step72 + tdLog.info('select * from %s where tgcol3 = 1 -x step72' % (mt)) + tdSql.error('select * from %s where tgcol3 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step72: + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: $i = 8 + i = 8 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != NULL then + tdLog.info('tdSql.checkData(0, 3, NULL)') + try: + tdSql.checkData(0, 3, None) + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("out of range") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != NULL then + tdLog.info('tdSql.checkData(0, 4, NULL) out of range') + # tdSql.checkData(0, 4, None) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step81 + tdLog.info('select * from %s where tgcol2 = 1 -x step81' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step81: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step82 + tdLog.info('select * from %s where tgcol3 = 1 -x step82' % (mt)) + tdSql.error('select * from %s where tgcol3 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step82: + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: $i = 9 + i = 9 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1.000000000 then + tdLog.info('tdSql.checkData(0, 2, 1.000000000)') + tdSql.checkData(0, 2, 1.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != NULL then + tdLog.info('tdSql.checkData(0, 3, NULL)') + try: + tdSql.checkData(0, 3, None) + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("out of range") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != NULL then + tdLog.info('tdSql.checkData(0, 4, NULL) out of range') + # tdSql.checkData(0, 4, None) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step91 + tdLog.info('select * from %s where tgcol3 = 1 -x step91' % (mt)) + tdSql.error('select * from %s where tgcol3 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step91: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step92 + tdLog.info('select * from %s where tgcol2 = 1 -x step92' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step92: + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: $i = 10 + i = 10 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = '1' + tdLog.info('select * from %s where tgcol1 = "1"' % (mt)) + tdSql.query('select * from %s where tgcol1 = "1"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, "1")') + tdSql.checkData(0, 2, "1") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != NULL then + tdLog.info('tdSql.checkData(0, 3, NULL)') + try: + tdSql.checkData(0, 3, None) + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("out of range") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != NULL then + tdLog.info('tdSql.checkData(0, 4, NULL) out of range') + # tdSql.checkData(0, 4, None) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != NULL then + tdLog.info('tdSql.checkData(0, 5, NULL) out of range') + # tdSql.checkData(0, 5, None) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step101 + tdLog.info('select * from %s where tgcol2 = 1 -x step101' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step101: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step102 + tdLog.info('select * from %s where tgcol3 = 1 -x step102' % (mt)) + tdSql.error('select * from %s where tgcol3 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step102: + # TSIM: sql select * from $mt where tgcol4 = 1 -x step103 + tdLog.info('select * from %s where tgcol4 = 1 -x step103' % (mt)) + tdSql.error('select * from %s where tgcol4 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step103: + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: $i = 11 + i = 11 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol4=4 + tdLog.info('select * from %s where tgcol4=4' % (mt)) + tdSql.query('select * from %s where tgcol4=4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 4.00000 then + tdLog.info('tdSql.checkData(0, 3, 4.00000)') + tdSql.checkData(0, 3, 4.00000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != NULL then + tdLog.info('tdSql.checkData(0, 4, NULL) out of range') + # tdSql.checkData(0, 4, None) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != NULL then + tdLog.info('tdSql.checkData(0, 5, NULL) out of range') + # tdSql.checkData(0, 5, None) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data06 != NULL then + tdLog.info('tdSql.checkData(0, 6, NULL) out of range') + # tdSql.checkData(0, 6, None) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step111 + tdLog.info('select * from %s where tgcol2 = 1 -x step111' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step111: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step112 + tdLog.info('select * from %s where tgcol3 = 1 -x step112' % (mt)) + tdSql.error('select * from %s where tgcol3 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step112: + # TSIM: sql select * from $mt where tgcol5 = 1 -x step113 + tdLog.info('select * from %s where tgcol5 = 1 -x step113' % (mt)) + tdSql.error('select * from %s where tgcol5 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step113: + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: $i = 12 + i = 12 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = 4 + tdLog.info('select * from %s where tgcol4 = 4' % (mt)) + tdSql.query('select * from %s where tgcol4 = 4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 4.000000000 then + tdLog.info('tdSql.checkData(0, 3, 4.000000000)') + tdSql.checkData(0, 3, 4.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != NULL then + tdLog.info('tdSql.checkData(0, 4, NULL) out of range') + # tdSql.checkData(0, 4, None) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != NULL then + tdLog.info('tdSql.checkData(0, 5, NULL) out of range') + # tdSql.checkData(0, 5, None) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data06 != NULL then + tdLog.info('tdSql.checkData(0, 6, NULL) out of range') + # tdSql.checkData(0, 6, None) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data07 != NULL then + tdLog.info('tdSql.checkData(0, 7, NULL) out of range') + # tdSql.checkData(0, 7, None) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 1 -x step120 + tdLog.info('select * from %s where tgcol2 = 1 -x step120' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step120: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step121 + tdLog.info('select * from %s where tgcol3 = 1 -x step121' % (mt)) + tdSql.error('select * from %s where tgcol3 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step121: + # TSIM: sql select * from $mt where tgcol5 = 1 -x step122 + tdLog.info('select * from %s where tgcol5 = 1 -x step122' % (mt)) + tdSql.error('select * from %s where tgcol5 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step122: + # TSIM: sql select * from $mt where tgcol6 = 1 -x step123 + tdLog.info('select * from %s where tgcol6 = 1 -x step123' % (mt)) + tdSql.error('select * from %s where tgcol6 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step123: + # TSIM: + # TSIM: print =============== step13 + tdLog.info('=============== step13') + # TSIM: $i = 13 + i = 13 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, "1")') + tdSql.checkData(0, 2, "1") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 5.000000000 then + tdLog.info('tdSql.checkData(0, 4, 5.000000000)') + tdSql.checkData(0, 4, 5.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != NULL then + tdLog.info('tdSql.checkData(0, 5, NULL) out of range') + # tdSql.checkData(0, 5, None) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data06 != NULL then + tdLog.info('tdSql.checkData(0, 6, NULL) out of range') + # tdSql.checkData(0, 6, None) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data07 != NULL then + tdLog.info('tdSql.checkData(0, 7, NULL) out of range') + # tdSql.checkData(0, 7, None) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol3 = 1 -x step130 + tdLog.info('select * from %s where tgcol3 = 1 -x step130' % (mt)) + tdSql.error('select * from %s where tgcol3 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step130: + # TSIM: sql select * from $mt where tgcol4 = 1 -x step131 + tdLog.info('select * from %s where tgcol4 = 1 -x step131' % (mt)) + tdSql.error('select * from %s where tgcol4 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step131: + # TSIM: sql select * from $mt where tgcol6 = 1 -x step133 + tdLog.info('select * from %s where tgcol6 = 1 -x step133' % (mt)) + tdSql.error('select * from %s where tgcol6 = 1' % (mt)) + # TSIM: return -1 + # TSIM: step133: + # TSIM: + # TSIM: print =============== step14 + tdLog.info('=============== step14') + # TSIM: $i = 14 + i = 20 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bool, tgcol2 bigint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 bigint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 bigint)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 1 ) + tdLog.info('create table %s using %s tags( 1, 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 1 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: + # TSIM: sql alter table xxmt drop tag tag1 -x step141 + tdLog.info('alter table xxmt drop tag tag1 -x step141') + tdSql.error('alter table xxmt drop tag tag1') + # TSIM: return -1 + # TSIM: step141: + # TSIM: sql alter table $tb drop tag tag1 -x step142 + tdLog.info('alter table %s drop tag tag1 -x step142' % (tb)) + tdSql.error('alter table %s drop tag tag1' % (tb)) + # TSIM: return -1 + # TSIM: step142: + # TSIM: sql alter table $mt drop tag tag1 -x step143 + tdLog.info('alter table %s drop tag tag1 -x step143' % (mt)) + tdSql.error('alter table %s drop tag tag1' % (mt)) + # TSIM: return -1 + # TSIM: step143: + # TSIM: + # TSIM: sql alter table $mt drop tag tagcol1 -x step144 + tdLog.info('alter table %s drop tag tagcol1 -x step144' % (mt)) + tdSql.error('alter table %s drop tag tagcol1' % (mt)) + # TSIM: return -1 + # TSIM: step144: + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol2 + tdLog.info('alter table %s drop tag tgcol2' % (mt)) + tdSql.execute('alter table %s drop tag tgcol2' % (mt)) + # TSIM: sql alter table $mt drop tag tgcol1 -x step145 + tdLog.info('alter table %s drop tag tgcol1 -x step145' % (mt)) + tdSql.error('alter table %s drop tag tgcol1' % (mt)) + # TSIM: return -1 + # TSIM: step145: + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/double.py b/tests/pytest/tag_lite/double.py new file mode 100644 index 0000000000000000000000000000000000000000..c9d3a5af9e88a0c1faccfabd17245dcaf54b179f --- /dev/null +++ b/tests/pytest/tag_lite/double.py @@ -0,0 +1,582 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_do_db + # TSIM: $tbPrefix = ta_do_tb + tbPrefix = "ta_do_tb" + # TSIM: $mtPrefix = ta_do_mt + mtPrefix = "ta_do_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # double) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol double)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol double)' % + (mt)) + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: while $i < 5 + while (i < 5): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 0 ) + tdLog.info('create table %s using %s tags( 0 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 0 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: while $i < 10 + while (i < 10): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 1 ) + tdLog.info('create table %s using %s tags( 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sleep 100 + # TSIM: sql select * from $tb + tdLog.info('select * from %s' % (tb)) + tdSql.query('select * from %s' % (tb)) + # TSIM: if $rows != $rowNum then + tdLog.info('tdSql.checkRow($rowNum)') + tdSql.checkRows(rowNum) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts < 1605045600000 + 240001 + tdLog.info('select * from %s where ts < 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts < 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts <= 1605045600000 + 240001 + tdLog.info('select * from %s where ts <= 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts <= 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 + tdLog.info('select * from %s where ts > 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts > 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts >= 1605045600000 + 240001 + tdLog.info('select * from %s where ts >= 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts >= 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001' % + (tb)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 100000 and ts < 100000 + tdLog.info('select * from %s where ts > 100000 and ts < 100000' % (tb)) + tdSql.query( + 'select * from %s where ts > 100000 and ts < 100000' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and + # ts < 1605045600000 + 360001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and ts < 1605045600000 + 360001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and ts < 1605045600000 + 360001' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 + tdLog.info('select * from %s where ts < 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts < 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 + tdLog.info('select * from %s where ts > 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts > 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts = 1605045600000 + 240001 + tdLog.info('select * from %s where ts = 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts = 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol = 1 + tdLog.info('select * from %s where ts > 1605045600000 + 240001 and tgcol = 1' % (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol = 0 + tdLog.info('select * from %s where ts < 1605045600000 + 240001 and tgcol = 0' % (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> 0 and ts + # < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 0 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 0 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group + # by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by + # tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/drop_auto_create.py b/tests/pytest/tag_lite/drop_auto_create.py new file mode 100644 index 0000000000000000000000000000000000000000..f89b41008b167884f54cacde3eda11cbc81c0040 --- /dev/null +++ b/tests/pytest/tag_lite/drop_auto_create.py @@ -0,0 +1,47 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdSql.execute('create table m1(ts timestamp, k int) tags(a binary(12), b int, c double);') + tdSql.execute('insert into tm0 using m1(b,c) tags(1, 99) values(now, 1);') + tdSql.execute('insert into tm1 using m1(b,c) tags(2, 100) values(now, 2);') + tdLog.info("2 rows inserted") + tdSql.query('select * from m1;') + tdSql.checkRows(2) + tdSql.query('select *,tbname from m1;') + tdSql.execute("drop table tm0; ") + tdSql.query('select * from m1') + tdSql.checkRows(1) + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/filter.py b/tests/pytest/tag_lite/filter.py new file mode 100644 index 0000000000000000000000000000000000000000..aeb13a171527103765e7744b97b57d3965ba711b --- /dev/null +++ b/tests/pytest/tag_lite/filter.py @@ -0,0 +1,372 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + dbPrefix = "ta_fi_db" + tbPrefix = "ta_fi_tb" + mtPrefix = "ta_fi_mt" + # TSIM: $tbNum = 10 + rowNum = 20 + # TSIM: $totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + i = 0 + # TSIM: $db = $dbPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # binary(10)) + tdLog.info( + "create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(10))" % + mt) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(10))' % + mt) + # TSIM: + i = 0 + while (i < 5): + tb = "tbPrefix%d" % i + tdLog.info("create table %s using %s tags( '0' )" % (tb, mt)) + tdSql.execute("create table %s using %s tags( '0' )" % (tb, mt)) + + x = 0 + while (x < rowNum): + ms = "%dm" % x + tdLog.info( + "insert into %s values (now + %s , %d)" % + (tb, ms, x)) + tdSql.execute( + "insert into %s values (now + %s , %d)" % + (tb, ms, x)) + x = x + 1 + i = i + 1 + + while (i < 10): + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( '1' ) + tdLog.info("create table %s using %s tags( '1' )" % (tb, mt)) + tdSql.execute("create table %s using %s tags( '1' )" % (tb, mt)) + x = 0 + while (x < rowNum): + ms = "%dm" % x + # TSIM: sql insert into $tb values (now + $ms , $x ) + tdLog.info( + "insert into %s values (now + %s, %d )" % + (tb, ms, x)) + tdSql.execute( + "insert into %s values (now + %s, %d )" % + (tb, ms, x)) + x = x + 1 + i = i + 1 + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' + tdLog.info( + "select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = '1'" % + mt) + tdSql.query( + "select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = '1'" % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info( + "%s %s %s %s %s %s %s" % + (tdSql.getData( + 0, 0), tdSql.getData( + 0, 1), tdSql.getData( + 0, 2), tdSql.getData( + 0, 3), tdSql.getData( + 0, 4), tdSql.getData( + 0, 5), tdSql.getData( + 0, 6))) + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tg = '1' -x + # step2 + tdLog.info( + "select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tg = '1' -x step2" % + mt) + tdSql.error( + "select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tg = '1'" % + mt) + # TSIM: return -1 + # TSIM: step2: + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where noexist = '1' -x + # step3 + tdLog.info( + "select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where noexist = '1' -x step3" % + mt) + tdSql.error( + "select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where noexist = '1'" % + mt) + # TSIM: return -1 + # TSIM: step3: + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = '1' + tdLog.info( + "select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tbcol = '1'" % + mt) + tdSql.query( + "select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tbcol = '1'" % + mt) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data00 != 10 then + tdLog.info('tdSql.checkData(0, 0, 10)') + tdSql.checkData(0, 0, 10) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + "select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s" % + mt) + tdSql.query( + "select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s" % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info( + "%s %s %s %s %s %s %s" % + (tdSql.getData( + 0, 0), tdSql.getData( + 0, 1), tdSql.getData( + 0, 2), tdSql.getData( + 0, 3), tdSql.getData( + 0, 4), tdSql.getData( + 0, 5), tdSql.getData( + 0, 6))) + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select count(tbcol), avg(cc), sum(xx), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt -x step6 + tdLog.info( + "select count(tbcol), avg(cc), sum(xx), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s -x step6" % + mt) + tdSql.error( + "select count(tbcol), avg(cc), sum(xx), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s" % + mt) + # TSIM: return -1 + # TSIM: step6: + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select count(tgcol), avg(tgcol), sum(tgcol), min(tgcol), + # max(tgcol), first(tgcol), last(tgcol) from $mt -x step7 + tdLog.info( + "select count(tgcol), avg(tgcol), sum(tgcol), min(tgcol), max(tgcol), first(tgcol), last(tgcol) from %s -x step7" % + mt) + tdSql.error( + "select count(tgcol), avg(tgcol), sum(tgcol), min(tgcol), max(tgcol), first(tgcol), last(tgcol) from %s" % + mt) + # TSIM: return -1 + # TSIM: step7: + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tbcol + tdLog.info( + "select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s by tbcol" % + mt) + tdSql.query( + "select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tbcol" % + mt) + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by noexist -x + # step9 + tdLog.info( + "select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by noexist -x step9" % + mt) + tdSql.error( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by noexist ' % + mt) + # TSIM: return -1 + # TSIM: step9: + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + mt) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select count(tbcol) as c from $mt group by tbcol + tdLog.info('select count(tbcol) as c from %s group by tbcol' % mt) + tdSql.query('select count(tbcol) as c from %s group by tbcol' % mt) + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select count(tbcol) as c from $mt group by noexist -x + # step12 + tdLog.info( + 'select count(tbcol) as c from %s group by noexist -x step12' % + mt) + tdSql.error('select count(tbcol) as c from %s group by noexist2' % mt) + # TSIM: return -1 + # TSIM: step12: + # TSIM: + # TSIM: print =============== step13 + tdLog.info('=============== step13') + # TSIM: sql select count(tbcol) as c from $mt group by tgcol + tdLog.info('select count(tbcol) as c from %s group by tgcol' % mt) + tdSql.query('select count(tbcol) as c from %s group by tgcol' % mt) + # TSIM: print $data00 + tdLog.info('$data00') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step14 + tdLog.info('=============== step14') + # TSIM: sql select count(tbcol) as c from $mt where ts > 1000 group by + # tgcol + tdLog.info( + 'select count(tbcol) as c from %s where ts > 1000 group by tgcol' % + mt) + tdSql.query( + 'select count(tbcol) as c from %s where ts > 1000 group by tgcol' % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +# tdLog.info("%s %s %s %s %s %s %s" % (tdSql.getData(0, 0), tdSql.getData(0, 1), tdSql.getData(0, 2), tdSql.getData(0, 3), tdSql.getData(0, 4), tdSql.getData(0, 5), tdSql.getData(0, 6))) + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: print expect 100, actual $data00 + tdLog.info('expect 100, actual $data00') + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step15 + tdLog.info('=============== step15') + # TSIM: sql select count(tbcol) as c from $mt where noexist < 1 group + # by tgcol -x step15 + tdLog.info( + 'select count(tbcol) as c from %s where noexist < 1 group by tgcol -x step15' % + mt) + tdSql.error( + 'select count(tbcol) as c from %s where noexist < 1 group by tgcol5' % + mt) + # TSIM: return -1 + # TSIM: step15: + # TSIM: + # TSIM: print =============== step16 + tdLog.info('=============== step16') + # TSIM: sql select count(tbcol) as c from $mt where tgcol = '1' group + # by tgcol + tdLog.info( + "select count(tbcol) as c from %s where tgcol = '1' group by tgcol" % + mt) + tdSql.query( + "select count(tbcol) as c from %s where tgcol = '1' group by tgcol" % + mt) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +# tdLog.info("%s %s %s %s %s %s %s" % (tdSql.getData(0, 0), tdSql.getData(0, 1), tdSql.getData(0, 2), tdSql.getData(0, 3), tdSql.getData(0, 4), tdSql.getData(0, 5), tdSql.getData(0, 6))) + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/float.py b/tests/pytest/tag_lite/float.py new file mode 100644 index 0000000000000000000000000000000000000000..589df89ab9e000dae8c953bb64aaeda51ca0c86c --- /dev/null +++ b/tests/pytest/tag_lite/float.py @@ -0,0 +1,582 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_fl_db + # TSIM: $tbPrefix = ta_fl_tb + tbPrefix = "ta_fl_tb" + # TSIM: $mtPrefix = ta_fl_mt + mtPrefix = "ta_fl_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # float) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol float)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol float)' % + (mt)) + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: while $i < 5 + while (i < 5): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 0 ) + tdLog.info('create table %s using %s tags( 0 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 0 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: while $i < 10 + while (i < 10): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 1 ) + tdLog.info('create table %s using %s tags( 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sleep 100 + # TSIM: sql select * from $tb + tdLog.info('select * from %s' % (tb)) + tdSql.query('select * from %s' % (tb)) + # TSIM: if $rows != $rowNum then + tdLog.info('tdSql.checkRow($rowNum)') + tdSql.checkRows(rowNum) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts < 1605045600000 + 240001 + tdLog.info('select * from %s where ts < 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts < 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts <= 1605045600000 + 240001 + tdLog.info('select * from %s where ts <= 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts <= 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 + tdLog.info('select * from %s where ts > 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts > 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts >= 1605045600000 + 240001 + tdLog.info('select * from %s where ts >= 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts >= 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001' % + (tb)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 100000 and ts < 100000 + tdLog.info('select * from %s where ts > 100000 and ts < 100000' % (tb)) + tdSql.query( + 'select * from %s where ts > 100000 and ts < 100000' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and + # ts < 1605045600000 + 360001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and ts < 1605045600000 + 360001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and ts < 1605045600000 + 360001' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 + tdLog.info('select * from %s where ts < 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts < 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 + tdLog.info('select * from %s where ts > 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts > 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts = 1605045600000 + 240001 + tdLog.info('select * from %s where ts = 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts = 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol = 1 + tdLog.info('select * from %s where ts > 1605045600000 + 240001 and tgcol = 1' % (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol = 0 + tdLog.info('select * from %s where ts < 1605045600000 + 240001 and tgcol = 0' % (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> 0 and ts + # < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 0 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 0 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group + # by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by + # tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/int.py b/tests/pytest/tag_lite/int.py new file mode 100644 index 0000000000000000000000000000000000000000..1297d083a0d9aa30a21c3235c89a31236175a119 --- /dev/null +++ b/tests/pytest/tag_lite/int.py @@ -0,0 +1,599 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_in_db + # TSIM: $tbPrefix = ta_in_tb + tbPrefix = "ta_in_tb" + # TSIM: $mtPrefix = ta_in_mt + mtPrefix = "ta_in_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol int)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol int)' % + (mt)) + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: while $i < 5 + while (i < 5): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 0 ) + tdLog.info('create table %s using %s tags( 0 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 0 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: while $i < 10 + while (i < 10): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 1 ) + tdLog.info('create table %s using %s tags( 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sleep 100 + # TSIM: sql select * from $tb + tdLog.info('select * from %s' % (tb)) + tdSql.query('select * from %s' % (tb)) + # TSIM: if $rows != $rowNum then + tdLog.info('tdSql.checkRow($rowNum)') + tdSql.checkRows(rowNum) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts < 1605045600000 + 240001 + tdLog.info('select * from %s where ts < 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts < 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts <= 1605045600000 + 240001 + tdLog.info('select * from %s where ts <= 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts <= 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 + tdLog.info('select * from %s where ts > 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts > 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts >= 1605045600000 + 240001 + tdLog.info('select * from %s where ts >= 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts >= 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001' % + (tb)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 100000 and ts < 100000 + tdLog.info('select * from %s where ts > 100000 and ts < 100000' % (tb)) + tdSql.query( + 'select * from %s where ts > 100000 and ts < 100000' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and + # ts < 1605045600000 + 360001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and ts < 1605045600000 + 360001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and ts < 1605045600000 + 360001' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 + tdLog.info('select * from %s where ts < 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts < 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 + tdLog.info('select * from %s where ts > 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts > 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts = 1605045600000 + 240001 + tdLog.info('select * from %s where ts = 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts = 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol = 1 + tdLog.info('select * from %s where ts > 1605045600000 + 240001 and tgcol = 1' % (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol = 0 + tdLog.info('select * from %s where ts < 1605045600000 + 240001 and tgcol = 0' % (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> 0 and ts + # < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 0 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 0 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group + # by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by + # tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + tdSql.execute("create database db") + tdSql.execute("use db") + tdSql.execute( + "create table if not exists st (ts timestamp, tagtype int) tags(dev int)") + tdSql.error( + 'CREATE TABLE if not exists dev_001 using st tags(%d)' % pow(2, 31)) + tdSql.error( + 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (-1 * pow(2, 31))) + + tdSql.execute( + 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (pow(2, 31) - 1)) + tdSql.execute( + 'CREATE TABLE if not exists dev_002 using st tags(%d)' % (-1 * pow(2, 31) + 1)) + + print("==============step2") + tdSql.query("show tables") + tdSql.checkRows(2) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/int_binary.py b/tests/pytest/tag_lite/int_binary.py new file mode 100644 index 0000000000000000000000000000000000000000..6ce9a9a431f644e1a6c9e7c9dece955dc9f40bfd --- /dev/null +++ b/tests/pytest/tag_lite/int_binary.py @@ -0,0 +1,789 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_inb_db + # TSIM: $tbPrefix = ta_inb_tb + tbPrefix = "ta_inb_tb" + # TSIM: $mtPrefix = ta_inb_mt + mtPrefix = "ta_inb_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int, + # tgcol2 binary(5)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol int, tgcol2 binary(5))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol int, tgcol2 binary(5))' % + (mt)) + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: while $i < 5 + while (i < 5): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 0, '0' ) + tdLog.info('create table %s using %s tags( 0, "0" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 0, "0" )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: while $i < 10 + while (i < 10): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 1, '1' ) + tdLog.info('create table %s using %s tags( 1, "1" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, "1" )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 + tdLog.info('select * from %s where ts < 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts < 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 + tdLog.info('select * from %s where ts > 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts > 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts = 1605045600000 + 240001 + tdLog.info('select * from %s where ts = 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts = 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol2 = '0' + tdLog.info('select * from %s where tgcol2 = "0"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "0"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 <> '0' + tdLog.info('select * from %s where tgcol2 <> "0"' % (mt)) + tdSql.query('select * from %s where tgcol2 <> "0"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = '1' + tdLog.info('select * from %s where tgcol2 = "1"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "1"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 <> '1' + tdLog.info('select * from %s where tgcol2 <> "1"' % (mt)) + tdSql.query('select * from %s where tgcol2 <> "1"' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol = 1 + tdLog.info('select * from %s where ts > 1605045600000 + 240001 and tgcol = 1' % (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol = 0 + tdLog.info('select * from %s where ts < 1605045600000 + 240001 and tgcol = 0' % (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> 0 and ts + # < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 0 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 0 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 = '1' + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = "1"' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = "1"' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 <> '1' + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> "1"' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> "1"' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol2 = '0' + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol2 <> '0' + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol2 = '0' + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol2 <> '0' + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> "0"' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol2 <> '0' + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> "0"' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> "0"' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 <> '0' and + # ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> "0" and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> "0" and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 = '1' and + # tgcol = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = "1" and tgcol = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = "1" and tgcol = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 <> '1' and + # tgcol <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> "1" and tgcol <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> "1" and tgcol <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol2 = '0' and + # tgcol = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = "0" and tgcol = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = "0" and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol2 <> '0' and + # tgcol <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> "0" and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> "0" and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol2 = '0' and + # tgcol = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = "0" and tgcol = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = "0" and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol2 <> '0' + # and tgcol <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> "0" and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> "0" and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol2 <> '0' and tgcol <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> "0" and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> "0" and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 <> '0' and + # ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> "0" and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> "0" and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = "1"' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = "1"' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 and + # tgcol2 = '1' + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 and tgcol2 = "1"' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 and tgcol2 = "1"' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group + # by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = "1" group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = "1" group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 and + # tgcol2 = '1' group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 and tgcol2 = "1" group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 and tgcol2 = "1" group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step13 + tdLog.info('=============== step13') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step14 + tdLog.info('=============== step14') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by + # tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/int_float.py b/tests/pytest/tag_lite/int_float.py new file mode 100644 index 0000000000000000000000000000000000000000..341acfd5ae0784c0d0d46a0757490fdfe8bca599 --- /dev/null +++ b/tests/pytest/tag_lite/int_float.py @@ -0,0 +1,825 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_inf_db + # TSIM: $tbPrefix = ta_inf_tb + tbPrefix = "ta_inf_tb" + # TSIM: $mtPrefix = ta_inf_mt + mtPrefix = "ta_inf_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int, + # tgcol2 float) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol int, tgcol2 float)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol int, tgcol2 float)' % + (mt)) + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: while $i < 5 + while (i < 5): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 0, 0 ) + tdLog.info('create table %s using %s tags( 0, 0 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 0, 0 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: while $i < 10 + while (i < 10): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 1, 1 ) + tdLog.info('create table %s using %s tags( 1, 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 1 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 + tdLog.info('select * from %s where ts < 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts < 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 + tdLog.info('select * from %s where ts > 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts > 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts = 1605045600000 + 240001 + tdLog.info('select * from %s where ts = 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts = 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol2 > 0.5 + tdLog.info('select * from %s where tgcol2 > 0.5' % (mt)) + tdSql.query('select * from %s where tgcol2 > 0.5' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 < 0.5 + tdLog.info('select * from %s where tgcol2 < 0.5' % (mt)) + tdSql.query('select * from %s where tgcol2 < 0.5' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 > 0.5 and tgcol2 < 1.5 + tdLog.info( + 'select * from %s where tgcol2 > 0.5 and tgcol2 < 1.5' % + (mt)) + tdSql.query( + 'select * from %s where tgcol2 > 0.5 and tgcol2 < 1.5' % + (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 <> 1 + tdLog.info('select * from %s where tgcol2 <> 1' % (mt)) + tdSql.query('select * from %s where tgcol2 <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 1 + tdLog.info('select * from %s where tgcol2 = 1' % (mt)) + tdSql.query('select * from %s where tgcol2 = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 <> 1 + tdLog.info('select * from %s where tgcol2 <> 1' % (mt)) + tdSql.query('select * from %s where tgcol2 <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 = 0 + tdLog.info('select * from %s where tgcol2 = 0' % (mt)) + tdSql.query('select * from %s where tgcol2 = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol2 <> 0 + tdLog.info('select * from %s where tgcol2 <> 0' % (mt)) + tdSql.query('select * from %s where tgcol2 <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol = 1 + tdLog.info('select * from %s where ts > 1605045600000 + 240001 and tgcol = 1' % (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol = 0 + tdLog.info('select * from %s where ts < 1605045600000 + 240001 and tgcol = 0' % (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> 0 and ts + # < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 0 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 0 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol2 = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol2 = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol2 <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 <> 0 and + # ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 0 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 0 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 = 1 and + # tgcol = 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = 1 and tgcol = 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = 1 and tgcol = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 <> 1 and + # tgcol <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 1 and tgcol <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 1 and tgcol <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol2 = 0 and + # tgcol = 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = 0 and tgcol = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = 0 and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol2 <> 0 and + # tgcol <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> 0 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> 0 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol2 = 0 and + # tgcol = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = 0 and tgcol = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = 0 and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol2 <> 0 and + # tgcol <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> 0 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> 0 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol2 <> 0 and tgcol <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> 0 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 <> 0 and + # ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> 0 and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 and + # tgcol2 = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 and tgcol2 = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 and tgcol2 = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group + # by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = 1 group + # by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = 1 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = 1 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 and + # tgcol2 = 1 group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 and tgcol2 = 1 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 and tgcol2 = 1 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step13 + tdLog.info('=============== step13') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step14 + tdLog.info('=============== step14') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by + # tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/nchar.py b/tests/pytest/tag_lite/nchar.py new file mode 100644 index 0000000000000000000000000000000000000000..851cc32b56c9104e2f87d5c8ea58ffa0d56ac1a6 --- /dev/null +++ b/tests/pytest/tag_lite/nchar.py @@ -0,0 +1,48 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + print("==============step1") + tdSql.execute( + "create table if not exists st (ts timestamp, tagtype int) tags(dev nchar(5))") + tdSql.error( + 'CREATE TABLE if not exists dev_001 using st tags("dev_001")') + tdSql.execute( + 'CREATE TABLE if not exists dev_002 using st tags("dev")') + + + print("==============step2") + tdSql.query("show tables") + tdSql.checkRows(1) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/set.py b/tests/pytest/tag_lite/set.py new file mode 100644 index 0000000000000000000000000000000000000000..1e3cdfaa93b4df421d12837af0b0db043ea92abd --- /dev/null +++ b/tests/pytest/tag_lite/set.py @@ -0,0 +1,896 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_se_db + # TSIM: $tbPrefix = ta_se_tb + tbPrefix = "ta_se_tb" + # TSIM: $mtPrefix = ta_se_mt + mtPrefix = "ta_se_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: $i = 2 + i = 2 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bool, tgcol2 int) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $tb set tag tagcx 1 -x step21 + tdLog.info('alter table %s set tag tagcx 1 -x step21' % (tb)) + tdSql.error('alter table %s set tag tagcx 11' % (tb)) + # TSIM: return -1 + # TSIM: step21: + # TSIM: sql alter table $tb set tag tgcol1=false + tdLog.info('alter table %s set tag tgcol1=false' % (tb)) + tdSql.execute('alter table %s set tag tgcol1=false' % (tb)) + # TSIM: sql alter table $tb set tag tgcol2=4 + tdLog.info('alter table %s set tag tgcol2=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol2=4' % (tb)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = false + tdLog.info('select * from %s where tgcol1 = false' % (mt)) + tdSql.query('select * from %s where tgcol1 = false' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 0 then + tdLog.info('tdSql.checkData(0, 2, 0)') + tdSql.checkData(0, 2, 0) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 4 + tdLog.info('select * from %s where tgcol2 = 4' % (mt)) + tdSql.query('select * from %s where tgcol2 = 4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 0 then + tdLog.info('tdSql.checkData(0, 2, 0)') + tdSql.checkData(0, 2, 0) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql describe $tb + tdLog.info('describe %s' % (tb)) + tdSql.query('describe %s' % (tb)) + # TSIM: print $data21 $data23 $data32 $data33 + tdLog.info('$data21 $data23 $data32 $data33') + # TSIM: if $data21 != BOOL then + tdLog.info('tdSql.checkDataType(2, 1, "BOOL")') + tdSql.checkDataType(2, 1, "BOOL") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data31 != INT then + tdLog.info('tdSql.checkDataType(3, 1, "INT")') + tdSql.checkDataType(3, 1, "INT") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data23 != false then + tdLog.info('tdSql.checkData(2, 3, "TAG")') + tdSql.checkData(2, 3, "TAG") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data33 != 4 then + tdLog.info('tdSql.checkData(3, 3, "TAG")') + tdSql.checkData(3, 3, "TAG") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: $i = 3 + i = 3 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # smallint, tgcol2 tinyint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $tb set tag tgcol1=3 + tdLog.info('alter table %s set tag tgcol1=3' % (tb)) + tdSql.execute('alter table %s set tag tgcol1=3' % (tb)) + # TSIM: sql alter table $tb set tag tgcol2=4 + tdLog.info('alter table %s set tag tgcol2=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol2=4' % (tb)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = 3 + tdLog.info('select * from %s where tgcol1 = 3' % (mt)) + tdSql.query('select * from %s where tgcol1 = 3' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 3 then + tdLog.info('tdSql.checkData(0, 2, 3)') + tdSql.checkData(0, 2, 3) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 4 + tdLog.info('select * from %s where tgcol2 = 4' % (mt)) + tdSql.query('select * from %s where tgcol2 = 4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 3 then + tdLog.info('tdSql.checkData(0, 2, 3)') + tdSql.checkData(0, 2, 3) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, 4)') + tdSql.checkData(0, 3, 4) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 2 + tdLog.info('select * from %s where tgcol2 = 2' % (mt)) + tdSql.query('select * from %s where tgcol2 = 2' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: $i = 4 + i = 4 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # bigint, tgcol2 float) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float)' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, 2 ) + tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol1 = 1 + tdLog.info('select * from %s where tgcol1 = 1' % (mt)) + tdSql.query('select * from %s where tgcol1 = 1' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, 1)') + tdSql.checkData(0, 2, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2.00000 then + tdLog.info('tdSql.checkData(0, 3, 2.00000)') + tdSql.checkData(0, 3, 2.00000) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $tb set tag tgcol1=3 + tdLog.info('alter table %s set tag tgcol1=3' % (tb)) + tdSql.execute('alter table %s set tag tgcol1=3' % (tb)) + # TSIM: sql alter table $tb set tag tgcol2=4 + tdLog.info('alter table %s set tag tgcol2=4' % (tb)) + tdSql.execute('alter table %s set tag tgcol2=4' % (tb)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = 3 + tdLog.info('select * from %s where tgcol1 = 3' % (mt)) + tdSql.query('select * from %s where tgcol1 = 3' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 3 then + tdLog.info('tdSql.checkData(0, 2, 3)') + tdSql.checkData(0, 2, 3) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 4.00000 then + tdLog.info('tdSql.checkData(0, 3, 4.00000)') + tdSql.checkData(0, 3, 4.00000) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 4 + tdLog.info('select * from %s where tgcol2 = 4' % (mt)) + tdSql.query('select * from %s where tgcol2 = 4' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 3 then + tdLog.info('tdSql.checkData(0, 2, 3)') + tdSql.checkData(0, 2, 3) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 4.00000 then + tdLog.info('tdSql.checkData(0, 3, 4.00000)') + tdSql.checkData(0, 3, 4.00000) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: $i = 5 + i = 5 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # double, tgcol2 binary(10)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( 1, '2' ) + tdLog.info('create table %s using %s tags( 1, "2" )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1, "2" )' % (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol2 = '2' + tdLog.info('select * from %s where tgcol2 = "2"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "2"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1.000000000 then + tdLog.info('tdSql.checkData(0, 2, 1.000000000)') + tdSql.checkData(0, 2, 1.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, "2")') + tdSql.checkData(0, 3, "2") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $tb set tag tgcol1=3 + tdLog.info('alter table %s set tag tgcol1=3' % (tb)) + tdSql.execute('alter table %s set tag tgcol1=3' % (tb)) + # TSIM: sql alter table $tb set tag tgcol2='4' + tdLog.info('alter table %s set tag tgcol2="4"' % (tb)) + tdSql.execute('alter table %s set tag tgcol2="4"' % (tb)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = 3 + tdLog.info('select * from %s where tgcol1 = 3' % (mt)) + tdSql.query('select * from %s where tgcol1 = 3' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 3.000000000 then + tdLog.info('tdSql.checkData(0, 2, 3.000000000)') + tdSql.checkData(0, 2, 3.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, "4")') + tdSql.checkData(0, 3, "4") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = '4' + tdLog.info('select * from %s where tgcol2 = "4"' % (mt)) + tdSql.query('select * from %s where tgcol2 = "4"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 3.000000000 then + tdLog.info('tdSql.checkData(0, 2, 3.000000000)') + tdSql.checkData(0, 2, 3.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 4 then + tdLog.info('tdSql.checkData(0, 3, "4")') + tdSql.checkData(0, 3, "4") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: $i = 6 + i = 6 + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 + # binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 + # double, tgcol6 binary(20)) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20))' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20))' % + (mt)) + # TSIM: sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' ) + tdLog.info( + 'create table %s using %s tags( "1", 2, 3, "4", 5, "6" )' % + (tb, mt)) + tdSql.execute( + 'create table %s using %s tags( "1", 2, 3, "4", 5, "6" )' % + (tb, mt)) + # TSIM: sql insert into $tb values(now, 1) + tdLog.info('insert into %s values(now, 1)' % (tb)) + tdSql.execute('insert into %s values(now, 1)' % (tb)) + # TSIM: sql select * from $mt where tgcol1 = '1' + tdLog.info('select * from %s where tgcol1 = "1"' % (mt)) + tdSql.query('select * from %s where tgcol1 = "1"' % (mt)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 1 then + tdLog.info('tdSql.checkData(0, 2, "1")') + tdSql.checkData(0, 2, "1") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 2 then + tdLog.info('tdSql.checkData(0, 3, 2)') + tdSql.checkData(0, 3, 2) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 3 then + tdLog.info('tdSql.checkData(0, 4, 3)') + tdSql.checkData(0, 4, 3) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != 4 then + tdLog.info('tdSql.checkData(0, 5, "4")') + tdSql.checkData(0, 5, "4") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data06 != 5.000000000 then + tdLog.info('tdSql.checkData(0, 6, 5.000000000)') + tdSql.checkData(0, 6, 5.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data07 != 6 then + tdLog.info('tdSql.checkData(0, 7, "6")') + tdSql.checkData(0, 7, "6") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql alter table $mt drop tag tgcol3 + tdLog.info('alter table %s drop tag tgcol3' % (mt)) + tdSql.execute('alter table %s drop tag tgcol3' % (mt)) + # TSIM: sql alter table $tb set tag tgcol1='7' + tdLog.info('alter table %s set tag tgcol1="7"' % (tb)) + tdSql.execute('alter table %s set tag tgcol1="7"' % (tb)) + # TSIM: sql alter table $tb set tag tgcol2=8 + tdLog.info('alter table %s set tag tgcol2=8' % (tb)) + tdSql.execute('alter table %s set tag tgcol2=8' % (tb)) + # TSIM: sql alter table $tb set tag tgcol4='9' + tdLog.info('alter table %s set tag tgcol4="9"' % (tb)) + tdSql.execute('alter table %s set tag tgcol4="9"' % (tb)) + # TSIM: sql alter table $tb set tag tgcol5=10 + tdLog.info('alter table %s set tag tgcol5=10' % (tb)) + tdSql.execute('alter table %s set tag tgcol5=10' % (tb)) + # TSIM: sql alter table $tb set tag tgcol6='11' + tdLog.info('alter table %s set tag tgcol6="11"' % (tb)) + tdSql.execute('alter table %s set tag tgcol6="11"' % (tb)) + # TSIM: + # TSIM: sql reset query cache + tdLog.info('reset query cache') + tdSql.execute('reset query cache') + # TSIM: + # TSIM: sql select * from $mt where tgcol1 = '7' + tdLog.info('select * from %s where tgcol1 = "7"' % (mt)) + tdSql.query('select * from %s where tgcol1 = "7"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 7 then + tdLog.info('tdSql.checkData(0, 2, "7")') + tdSql.checkData(0, 2, "7") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 8 then + tdLog.info('tdSql.checkData(0, 3, 8)') + tdSql.checkData(0, 3, 8) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 9 then + tdLog.info('tdSql.checkData(0, 4, "9")') + tdSql.checkData(0, 4, "9") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != 10.000000000 then + tdLog.info('tdSql.checkData(0, 5, 10.000000000)') + tdSql.checkData(0, 5, 10.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data06 != 11 then + tdLog.info('tdSql.checkData(0, 6, "11")') + tdSql.checkData(0, 6, "11") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data07 != NULL then + tdLog.info('tdSql.checkData(0, 7, NULL)') + try: + tdSql.checkData(0, 7, None) + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("out of range") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol2 = 8 + tdLog.info('select * from %s where tgcol2 = 8' % (mt)) + tdSql.query('select * from %s where tgcol2 = 8' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 7 then + tdLog.info('tdSql.checkData(0, 2, "7")') + tdSql.checkData(0, 2, "7") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 8 then + tdLog.info('tdSql.checkData(0, 3, 8)') + tdSql.checkData(0, 3, 8) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 9 then + tdLog.info('tdSql.checkData(0, 4, "9")') + tdSql.checkData(0, 4, "9") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != 10.000000000 then + tdLog.info('tdSql.checkData(0, 5, 10.000000000)') + tdSql.checkData(0, 5, 10.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data06 != 11 then + tdLog.info('tdSql.checkData(0, 6, "11")') + tdSql.checkData(0, 6, "11") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data07 != NULL then + tdLog.info('tdSql.checkData(0, 7, NULL)') + try: + tdSql.checkData(0, 7, None) + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("out of range") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol4 = '9' + tdLog.info('select * from %s where tgcol4 = "9"' % (mt)) + tdSql.query('select * from %s where tgcol4 = "9"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 7 then + tdLog.info('tdSql.checkData(0, 2, "7")') + tdSql.checkData(0, 2, "7") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 8 then + tdLog.info('tdSql.checkData(0, 3, 8)') + tdSql.checkData(0, 3, 8) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 9 then + tdLog.info('tdSql.checkData(0, 4, "9")') + tdSql.checkData(0, 4, "9") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != 10.000000000 then + tdLog.info('tdSql.checkData(0, 5, 10.000000000)') + tdSql.checkData(0, 5, 10.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data06 != 11 then + tdLog.info('tdSql.checkData(0, 6, "11")') + tdSql.checkData(0, 6, "11") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data07 != NULL then + tdLog.info('tdSql.checkData(0, 7, NULL)') + try: + tdSql.checkData(0, 7, None) + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("out of range") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol5 = 10 + tdLog.info('select * from %s where tgcol5 = 10' % (mt)) + tdSql.query('select * from %s where tgcol5 = 10' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 7 then + tdLog.info('tdSql.checkData(0, 2, "7")') + tdSql.checkData(0, 2, "7") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 8 then + tdLog.info('tdSql.checkData(0, 3, 8)') + tdSql.checkData(0, 3, 8) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 9 then + tdLog.info('tdSql.checkData(0, 4, "9")') + tdSql.checkData(0, 4, "9") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != 10.000000000 then + tdLog.info('tdSql.checkData(0, 5, 10.000000000)') + tdSql.checkData(0, 5, 10.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data06 != 11 then + tdLog.info('tdSql.checkData(0, 6, "11")') + tdSql.checkData(0, 6, "11") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data07 != NULL then + tdLog.info('tdSql.checkData(0, 7, NULL)') + try: + tdSql.checkData(0, 7, None) + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("out of range") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where tgcol6 = '11' + tdLog.info('select * from %s where tgcol6 = "11"' % (mt)) + tdSql.query('select * from %s where tgcol6 = "11"' % (mt)) + # TSIM: print $data01 $data02 $data03 + tdLog.info('$data01 $data02 $data03') + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data01 != 1 then + tdLog.info('tdSql.checkData(0, 1, 1)') + tdSql.checkData(0, 1, 1) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data02 != 7 then + tdLog.info('tdSql.checkData(0, 2, "7")') + tdSql.checkData(0, 2, "7") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data03 != 8 then + tdLog.info('tdSql.checkData(0, 3, 8)') + tdSql.checkData(0, 3, 8) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data04 != 9 then + tdLog.info('tdSql.checkData(0, 4, "9")') + tdSql.checkData(0, 4, "9") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data05 != 10.000000000 then + tdLog.info('tdSql.checkData(0, 5, 10.000000000)') + tdSql.checkData(0, 5, 10.000000000) + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data06 != 11 then + tdLog.info('tdSql.checkData(0, 6, "11")') + tdSql.checkData(0, 6, "11") + # TSIM: return -1 + # TSIM: endi + # TSIM: if $data07 != NULL then + tdLog.info('tdSql.checkData(0, 7, NULL)') + try: + tdSql.checkData(0, 7, None) + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("out of range") + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/smallint.py b/tests/pytest/tag_lite/smallint.py new file mode 100644 index 0000000000000000000000000000000000000000..93fde22ca92219852426ac18c550231130d23384 --- /dev/null +++ b/tests/pytest/tag_lite/smallint.py @@ -0,0 +1,599 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_sm_db + # TSIM: $tbPrefix = ta_sm_tb + tbPrefix = "ta_sm_tb" + # TSIM: $mtPrefix = ta_sm_mt + mtPrefix = "ta_sm_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # smallint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol smallint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol smallint)' % + (mt)) + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: while $i < 5 + while (i < 5): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 0 ) + tdLog.info('create table %s using %s tags( 0 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 0 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: while $i < 10 + while (i < 10): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 1 ) + tdLog.info('create table %s using %s tags( 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sleep 100 + # TSIM: sql select * from $tb + tdLog.info('select * from %s' % (tb)) + tdSql.query('select * from %s' % (tb)) + # TSIM: if $rows != $rowNum then + tdLog.info('tdSql.checkRow($rowNum)') + tdSql.checkRows(rowNum) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts < 1605045600000 + 240001 + tdLog.info('select * from %s where ts < 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts < 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts <= 1605045600000 + 240001 + tdLog.info('select * from %s where ts <= 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts <= 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 + tdLog.info('select * from %s where ts > 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts > 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts >= 1605045600000 + 240001 + tdLog.info('select * from %s where ts >= 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts >= 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001' % + (tb)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 100000 and ts < 100000 + tdLog.info('select * from %s where ts > 100000 and ts < 100000' % (tb)) + tdSql.query( + 'select * from %s where ts > 100000 and ts < 100000' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and + # ts < 1605045600000 + 360001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and ts < 1605045600000 + 360001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and ts < 1605045600000 + 360001' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 + tdLog.info('select * from %s where ts < 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts < 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 + tdLog.info('select * from %s where ts > 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts > 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts = 1605045600000 + 240001 + tdLog.info('select * from %s where ts = 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts = 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol = 1 + tdLog.info('select * from %s where ts > 1605045600000 + 240001 and tgcol = 1' % (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol = 0 + tdLog.info('select * from %s where ts < 1605045600000 + 240001 and tgcol = 0' % (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> 0 and ts + # < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 0 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 0 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group + # by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by + # tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + tdSql.execute("create database db") + tdSql.execute("use db") + tdSql.execute( + "create table if not exists st (ts timestamp, tagtype int) tags(dev smallint)") + tdSql.error( + 'CREATE TABLE if not exists dev_001 using st tags(%d)' % pow(2, 15)) + tdSql.error( + 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (-1 * pow(2, 15))) + + tdSql.execute( + 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (pow(2, 15) - 1)) + tdSql.execute( + 'CREATE TABLE if not exists dev_002 using st tags(%d)' % (-1 * pow(2, 15) + 1)) + + print("==============step2") + tdSql.query("show tables") + tdSql.checkRows(2) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/timestamp.py b/tests/pytest/tag_lite/timestamp.py new file mode 100644 index 0000000000000000000000000000000000000000..fa71c2e15422e80076f2b6a6eb26e8198a69a569 --- /dev/null +++ b/tests/pytest/tag_lite/timestamp.py @@ -0,0 +1,102 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdLog.info('======================== dnode1 start') + tbPrefix = "ta_fl_tb" + mtPrefix = "ta_fl_mt" + tbNum = 10 + rowNum = 20 + totalNum = 200 + tdLog.info('=============== step1') + i = 0 + mt = "%s%d" % (mtPrefix, i) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol float, tgTs timestamp, tgcol2 int)' %(mt)) + i = 0 + ts = 1605045600000 + tsStr = "2020-11-11 06:00:00" + while (i < 5): + tb = "%s%d" % (tbPrefix, i) + tdLog.info('create table %s using %s tags(%d, %d, %d)' % (tb, mt, i, ts + i, i)) + tdSql.execute('create table %s using %s tags(%d, %d, %d)' % (tb, mt, i, ts + i, i)) + x = 0 + while (x < rowNum): + ms = x * 60000 + #tdLog.info( + # "insert into %s values (%d, %d)" % + # (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + x = x + 1 + i = i + 1 + tdLog.info('=============== step2') + tdSql.query('select * from %s' % (mt)) + tdSql.checkRows(5 * rowNum) + + tdSql.query('select * from %s where tgTs = %ld and tgcol2 = 0' % (mt, ts)) + tdSql.checkRows(rowNum) + + tdSql.query('select * from %s where tgTs = \"%s\" and tgcol2 = 0' % (mt, tsStr)) + tdSql.checkRows(rowNum) + + tdLog.info('=============== step3') + i = 0 + while (i < 5): + tb = "%s%d" % (tbPrefix, i + 100) + tdLog.info('create table %s using %s tags(%d, \"%s\", %d)' % (tb, mt, i + 100, tsStr, i + 100)) + tdSql.execute('create table %s using %s tags(%d, \"%s\", %d)' % (tb, mt, i + 100, tsStr, i + 100)) + x = 0 + while (x < rowNum): + ms = x * 60000 + #tdLog.info( + # "insert into %s values (%d, %d)" % + # (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + x = x + 1 + i = i + 1 + + tdSql.query('select * from %s where tgTs = %ld and tgcol2 = 100' % (mt, ts)) + tdSql.checkRows(rowNum) + + tdSql.query('select * from %s where tgTs = \"%s\" and tgcol2 = 100' % (mt, tsStr)) + tdSql.checkRows(rowNum) + + tdLog.info('=============== step4') + + i = 0 + tb = "%s%d"%(tbPrefix, i + 1000) + tdSql.execute('insert into %s using %s tags(%d, \"%s\", %d) values(now, 10)' % (tb, mt, i + 100, tsStr, i + 1000)) + tdSql.execute('insert into %s using %s tags(%d, \"%s\", %d) values(now+2s, 10)' % (tb, mt, i + 100, tsStr, i + 1000)) + tdSql.execute('insert into %s using %s tags(%d, \"%s\", %d) values(now+3s, 10)' % (tb, mt, i + 100, tsStr, i + 1000)) + tdSql.query('select * from %s where tgTs = \"%s\" and tgcol2 = 1000' % (mt, tsStr)) + tdSql.checkRows(3) + + i = 0 + tb = "%s%d"%(tbPrefix, i + 10000) + tdSql.execute('create table %s using %s tags(%d, now, %d)' % (tb, mt, i + 10000,i + 10000)) + tdSql.checkRows(3) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/tinyint.py b/tests/pytest/tag_lite/tinyint.py new file mode 100644 index 0000000000000000000000000000000000000000..fc4af4ee9648ef6aca5badeada5420063f76050b --- /dev/null +++ b/tests/pytest/tag_lite/tinyint.py @@ -0,0 +1,600 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_ti_db + # TSIM: $tbPrefix = ta_ti_tb + tbPrefix = "ta_ti_tb" + # TSIM: $mtPrefix = ta_ti_mt + mtPrefix = "ta_ti_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # tinyint) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol tinyint)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol tinyint)' % + (mt)) + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: while $i < 5 + while (i < 5): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 0 ) + tdLog.info('create table %s using %s tags( 0 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 0 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: while $i < 10 + while (i < 10): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 1 ) + tdLog.info('create table %s using %s tags( 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sleep 100 + # TSIM: sql select * from $tb + tdLog.info('select * from %s' % (tb)) + tdSql.query('select * from %s' % (tb)) + # TSIM: if $rows != $rowNum then + tdLog.info('tdSql.checkRow($rowNum)') + tdSql.checkRows(rowNum) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts < 1605045600000 + 240001 + tdLog.info('select * from %s where ts < 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts < 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts <= 1605045600000 + 240001 + tdLog.info('select * from %s where ts <= 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts <= 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 + tdLog.info('select * from %s where ts > 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts > 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts >= 1605045600000 + 240001 + tdLog.info('select * from %s where ts >= 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts >= 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001' % + (tb)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 100000 and ts < 100000 + tdLog.info('select * from %s where ts > 100000 and ts < 100000' % (tb)) + tdSql.query( + 'select * from %s where ts > 100000 and ts < 100000' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and + # ts < 1605045600000 + 360001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and ts < 1605045600000 + 360001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and ts < 1605045600000 + 360001' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 + tdLog.info('select * from %s where ts < 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts < 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 + tdLog.info('select * from %s where ts > 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts > 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts = 1605045600000 + 240001 + tdLog.info('select * from %s where ts = 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts = 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol = 1 + tdLog.info('select * from %s where ts > 1605045600000 + 240001 and tgcol = 1' % (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol = 0 + tdLog.info('select * from %s where ts < 1605045600000 + 240001 and tgcol = 0' % (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> 0 and ts + # < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 0 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 0 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group + # by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by + # tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + + tdSql.execute("create database db") + tdSql.execute("use db") + tdSql.execute( + "create table if not exists st (ts timestamp, tagtype int) tags(dev tinyint)") + tdSql.error( + 'CREATE TABLE if not exists dev_001 using st tags(%d)' % pow(2, 7)) + tdSql.error( + 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (-1 * pow(2, 7))) + + tdSql.execute( + 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (pow(2, 7) - 1)) + tdSql.execute( + 'CREATE TABLE if not exists dev_002 using st tags(%d)' % (-1 * pow(2, 7) + 1)) + + print("==============step2") + tdSql.query("show tables") + tdSql.checkRows(2) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/too_many_tag_condtions.py b/tests/pytest/tag_lite/too_many_tag_condtions.py new file mode 100644 index 0000000000000000000000000000000000000000..a40de405fffeff50ab5794a7838b869345430bf4 --- /dev/null +++ b/tests/pytest/tag_lite/too_many_tag_condtions.py @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdLog.info('======================== dnode1 start') + tbPrefix = "ta_cr_tb" + mtPrefix = "ta_cr_mt" + tbNum = 2 + rowNum = 10 + totalNum = 200 + tagCondsLimit = 1024 + tdLog.info('=============== step1: create tbl and prepare data') + i = 0 + i = 2 + mt = "%s%d" % (mtPrefix, i) + tb = "%s%d" % (tbPrefix, i) + + sql ='create table %s (ts timestamp, tbcol int) TAGS(tgcol int)'% (mt) + tdLog.info(sql) + tdSql.execute(sql) + for i in range(0, tbNum): + tblName = "%s%d"%(tbPrefix, i) + sql = 'create table %s using %s TAGS(%d)'%(tblName, mt, i) + tdSql.execute(sql) + for j in range(0, rowNum): + sql = "insert into %s values(now, %d)"%(tblName, j) + tdSql.execute(sql) + + sqlPrefix = "select * from %s where "%(mt) + for i in range(2, 2048, 1): + conds = "tgcol=1 and "* (i - 1) + conds = "%stgcol=1"%(conds) + sql = "%s%s"%(sqlPrefix, conds) + if i >= tagCondsLimit: + tdSql.error(sql) + else: + tdSql.query(sql) + #tdSql.checkRows(1) + + for i in range(2, 2048, 1): + conds = "" + for j in range(0, i - 1): + conds = conds + "tgcol=%d or "%(j%tbNum) + conds += "tgcol=%d"%(i%tbNum) + sql = sqlPrefix + conds + if i >= tagCondsLimit: + tdSql.error(sql) + else: + tdSql.query(sql) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/unsignedBigint.py b/tests/pytest/tag_lite/unsignedBigint.py new file mode 100644 index 0000000000000000000000000000000000000000..6a33812f8839bf8c329c35b9c700bf5479d14a64 --- /dev/null +++ b/tests/pytest/tag_lite/unsignedBigint.py @@ -0,0 +1,600 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_sm_db + # TSIM: $tbPrefix = ta_sm_tb + tbPrefix = "ta_sm_tb" + # TSIM: $mtPrefix = ta_sm_mt + mtPrefix = "ta_sm_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # bigint unsigned) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bigint unsigned)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol bigint unsigned)' % + (mt)) + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: while $i < 5 + while (i < 5): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 0 ) + tdLog.info('create table %s using %s tags( 0 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 0 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: while $i < 10 + while (i < 10): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 1 ) + tdLog.info('create table %s using %s tags( 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sleep 100 + # TSIM: sql select * from $tb + tdLog.info('select * from %s' % (tb)) + tdSql.query('select * from %s' % (tb)) + # TSIM: if $rows != $rowNum then + tdLog.info('tdSql.checkRow($rowNum)') + tdSql.checkRows(rowNum) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts < 1605045600000 + 240001 + tdLog.info('select * from %s where ts < 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts < 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts <= 1605045600000 + 240001 + tdLog.info('select * from %s where ts <= 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts <= 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 + tdLog.info('select * from %s where ts > 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts > 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts >= 1605045600000 + 240001 + tdLog.info('select * from %s where ts >= 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts >= 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001' % + (tb)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 100000 and ts < 100000 + tdLog.info('select * from %s where ts > 100000 and ts < 100000' % (tb)) + tdSql.query( + 'select * from %s where ts > 100000 and ts < 100000' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and + # ts < 1605045600000 + 360001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and ts < 1605045600000 + 360001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and ts < 1605045600000 + 360001' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 + tdLog.info('select * from %s where ts < 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts < 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 + tdLog.info('select * from %s where ts > 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts > 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts = 1605045600000 + 240001 + tdLog.info('select * from %s where ts = 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts = 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol = 1 + tdLog.info('select * from %s where ts > 1605045600000 + 240001 and tgcol = 1' % (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol = 0 + tdLog.info('select * from %s where ts < 1605045600000 + 240001 and tgcol = 0' % (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> 0 and ts + # < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 0 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 0 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group + # by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by + # tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + tdSql.execute("create database db") + tdSql.execute("use db") + tdSql.execute( + "create table if not exists st (ts timestamp, tagtype int) tags(dev bigint unsigned)") + tdSql.error( + 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (pow(2, 64) - 1)) + tdSql.error( + 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (-1)) + + tdSql.execute( + 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (pow(2, 64) - 2)) + tdSql.execute( + 'CREATE TABLE if not exists dev_002 using st tags(%d)' % (0)) + tdSql.execute( + 'CREATE TABLE if not exists dev_003 using st tags(%s)' % ('NULL')) + print("==============step2") + tdSql.query("show tables") + tdSql.checkRows(3) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/unsignedInt.py b/tests/pytest/tag_lite/unsignedInt.py new file mode 100644 index 0000000000000000000000000000000000000000..6e741d351abe5c5608f45e414bcabc6d40dd0980 --- /dev/null +++ b/tests/pytest/tag_lite/unsignedInt.py @@ -0,0 +1,601 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +import time + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_sm_db + # TSIM: $tbPrefix = ta_sm_tb + tbPrefix = "ta_sm_tb" + # TSIM: $mtPrefix = ta_sm_mt + mtPrefix = "ta_sm_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # int unsigned) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol int unsigned)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol int unsigned)' % + (mt)) + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: while $i < 5 + while (i < 5): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 0 ) + tdLog.info('create table %s using %s tags( 0 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 0 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: while $i < 10 + while (i < 10): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 1 ) + tdLog.info('create table %s using %s tags( 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: + # TSIM: print =============== step2 + time.sleep(1) + tdLog.info('=============== step2') + # TSIM: sleep 100 + # TSIM: sql select * from $tb + tdLog.info('select * from %s' % (tb)) + tdSql.query('select * from %s' % (tb)) + # TSIM: if $rows != $rowNum then + tdLog.info('tdSql.checkRow($rowNum)') + tdSql.checkRows(rowNum) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts < 1605045600000 + 240001 + tdLog.info('select * from %s where ts < 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts < 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts <= 1605045600000 + 240001 + tdLog.info('select * from %s where ts <= 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts <= 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 + tdLog.info('select * from %s where ts > 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts > 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts >= 1605045600000 + 240001 + tdLog.info('select * from %s where ts >= 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts >= 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001' % + (tb)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 100000 and ts < 100000 + tdLog.info('select * from %s where ts > 100000 and ts < 100000' % (tb)) + tdSql.query( + 'select * from %s where ts > 100000 and ts < 100000' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and + # ts < 1605045600000 + 360001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and ts < 1605045600000 + 360001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and ts < 1605045600000 + 360001' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 + tdLog.info('select * from %s where ts < 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts < 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 + tdLog.info('select * from %s where ts > 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts > 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts = 1605045600000 + 240001 + tdLog.info('select * from %s where ts = 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts = 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol = 1 + tdLog.info('select * from %s where ts > 1605045600000 + 240001 and tgcol = 1' % (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol = 0 + tdLog.info('select * from %s where ts < 1605045600000 + 240001 and tgcol = 0' % (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> 0 and ts + # < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 0 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 0 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group + # by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by + # tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + tdSql.execute("create database db") + tdSql.execute("use db") + tdSql.execute( + "create table if not exists st (ts timestamp, tagtype int) tags(dev int unsigned)") + tdSql.error( + 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (pow(2, 32) - 1)) + tdSql.error( + 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (-1)) + + tdSql.execute( + 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (pow(2, 32) - 2)) + tdSql.execute( + 'CREATE TABLE if not exists dev_002 using st tags(%d)' % (0)) + tdSql.execute( + 'CREATE TABLE if not exists dev_003 using st tags(%s)' % ('NULL')) + print("==============step2") + tdSql.query("show tables") + tdSql.checkRows(3) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/unsignedSmallint.py b/tests/pytest/tag_lite/unsignedSmallint.py new file mode 100644 index 0000000000000000000000000000000000000000..21c390d9dca81fc6eb6ef87435acb1bf6d12c406 --- /dev/null +++ b/tests/pytest/tag_lite/unsignedSmallint.py @@ -0,0 +1,601 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_sm_db + # TSIM: $tbPrefix = ta_sm_tb + tbPrefix = "ta_sm_tb" + # TSIM: $mtPrefix = ta_sm_mt + mtPrefix = "ta_sm_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # smallint unsigned) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol smallint unsigned)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol smallint unsigned)' % + (mt)) + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: while $i < 5 + while (i < 5): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 0 ) + tdLog.info('create table %s using %s tags( 0 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 0 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: while $i < 10 + while (i < 10): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 1 ) + tdLog.info('create table %s using %s tags( 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sleep 100 + # TSIM: sql select * from $tb + tdLog.info('select * from %s' % (tb)) + tdSql.query('select * from %s' % (tb)) + # TSIM: if $rows != $rowNum then + tdLog.info('tdSql.checkRow($rowNum)') + tdSql.checkRows(rowNum) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts < 1605045600000 + 240001 + tdLog.info('select * from %s where ts < 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts < 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts <= 1605045600000 + 240001 + tdLog.info('select * from %s where ts <= 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts <= 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 + tdLog.info('select * from %s where ts > 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts > 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts >= 1605045600000 + 240001 + tdLog.info('select * from %s where ts >= 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts >= 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001' % + (tb)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 100000 and ts < 100000 + tdLog.info('select * from %s where ts > 100000 and ts < 100000' % (tb)) + tdSql.query( + 'select * from %s where ts > 100000 and ts < 100000' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and + # ts < 1605045600000 + 360001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and ts < 1605045600000 + 360001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and ts < 1605045600000 + 360001' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 + tdLog.info('select * from %s where ts < 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts < 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 + tdLog.info('select * from %s where ts > 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts > 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts = 1605045600000 + 240001 + tdLog.info('select * from %s where ts = 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts = 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol = 1 + tdLog.info('select * from %s where ts > 1605045600000 + 240001 and tgcol = 1' % (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol = 0 + tdLog.info('select * from %s where ts < 1605045600000 + 240001 and tgcol = 0' % (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> 0 and ts + # < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 0 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 0 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group + # by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by + # tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + tdSql.execute("create database db") + tdSql.execute("use db") + tdSql.execute( + "create table if not exists st (ts timestamp, tagtype int) tags(dev smallint unsigned)") + tdSql.error( + 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (pow(2, 16)-1)) + tdSql.error( + 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (-1)) + + tdSql.execute( + 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (pow(2, 16) - 2)) + tdSql.execute( + 'CREATE TABLE if not exists dev_002 using st tags(%d)' % (0)) + tdSql.execute( + 'CREATE TABLE if not exists dev_003 using st tags(%s)' % ('NULL')) + + print("==============step2") + tdSql.query("show tables") + tdSql.checkRows(3) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/unsignedTinyint.py b/tests/pytest/tag_lite/unsignedTinyint.py new file mode 100644 index 0000000000000000000000000000000000000000..7ce3a8398444efae63ccdc93062c00c81c644da0 --- /dev/null +++ b/tests/pytest/tag_lite/unsignedTinyint.py @@ -0,0 +1,600 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + # TSIM: system sh/stop_dnodes.sh + # TSIM: + # TSIM: + # TSIM: system sh/deploy.sh -n dnode1 -i 1 + # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0 + # TSIM: system sh/exec.sh -n dnode1 -s start + # TSIM: + # TSIM: sleep 3000 + # TSIM: sql connect + # TSIM: + # TSIM: print ======================== dnode1 start + tdLog.info('======================== dnode1 start') + # TSIM: + # TSIM: $dbPrefix = ta_sm_db + # TSIM: $tbPrefix = ta_sm_tb + tbPrefix = "ta_sm_tb" + # TSIM: $mtPrefix = ta_sm_mt + mtPrefix = "ta_sm_mt" + # TSIM: $tbNum = 10 + tbNum = 10 + # TSIM: $rowNum = 20 + rowNum = 20 + # TSIM: $totalNum = 200 + totalNum = 200 + # TSIM: + # TSIM: print =============== step1 + tdLog.info('=============== step1') + # TSIM: $i = 0 + i = 0 + # TSIM: $db = $dbPrefix . $i + # TSIM: $mt = $mtPrefix . $i + mt = "%s%d" % (mtPrefix, i) + # TSIM: + # TSIM: sql create database $db + # TSIM: sql use $db + # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol + # tinyint unsigned) + tdLog.info( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol tinyint unsigned)' % + (mt)) + tdSql.execute( + 'create table %s (ts timestamp, tbcol int) TAGS(tgcol tinyint unsigned)' % + (mt)) + # TSIM: + # TSIM: $i = 0 + i = 0 + # TSIM: while $i < 5 + while (i < 5): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 0 ) + tdLog.info('create table %s using %s tags( 0 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 0 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: while $i < 10 + while (i < 10): + # TSIM: $tb = $tbPrefix . $i + tb = "%s%d" % (tbPrefix, i) + # TSIM: sql create table $tb using $mt tags( 1 ) + tdLog.info('create table %s using %s tags( 1 )' % (tb, mt)) + tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt)) + # TSIM: $x = 0 + x = 0 + # TSIM: while $x < $rowNum + while (x < rowNum): + # TSIM: $ms = $x . m + ms = x * 60000 + tdLog.info( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + tdSql.execute( + "insert into %s values (%d, %d)" % + (tb, 1605045600000 + ms, x)) + # TSIM: $x = $x + 1 + x = x + 1 + # TSIM: endw + # TSIM: $i = $i + 1 + i = i + 1 + # TSIM: endw + # TSIM: + # TSIM: print =============== step2 + tdLog.info('=============== step2') + # TSIM: sleep 100 + # TSIM: sql select * from $tb + tdLog.info('select * from %s' % (tb)) + tdSql.query('select * from %s' % (tb)) + # TSIM: if $rows != $rowNum then + tdLog.info('tdSql.checkRow($rowNum)') + tdSql.checkRows(rowNum) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts < 1605045600000 + 240001 + tdLog.info('select * from %s where ts < 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts < 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts <= 1605045600000 + 240001 + tdLog.info('select * from %s where ts <= 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts <= 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 + tdLog.info('select * from %s where ts > 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts > 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts >= 1605045600000 + 240001 + tdLog.info('select * from %s where ts >= 1605045600000 + 240001' % (tb)) + tdSql.query('select * from %s where ts >= 1605045600000 + 240001' % (tb)) + # TSIM: if $rows != 15 then + tdLog.info('tdSql.checkRow(15)') + tdSql.checkRows(15) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001' % + (tb)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 100000 and ts < 100000 + tdLog.info('select * from %s where ts > 100000 and ts < 100000' % (tb)) + tdSql.query( + 'select * from %s where ts > 100000 and ts < 100000' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001' % + (tb)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and + # ts < 1605045600000 + 360001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and ts < 1605045600000 + 360001' % + (tb)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and ts < 1605045600000 + 360001' % + (tb)) + # TSIM: if $rows != 1 then + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step3 + tdLog.info('=============== step3') + # TSIM: sql select * from $mt + tdLog.info('select * from %s' % (mt)) + tdSql.query('select * from %s' % (mt)) + # TSIM: if $rows != $totalNum then + tdLog.info('tdSql.checkRow($totalNum)') + tdSql.checkRows(totalNum) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 + tdLog.info('select * from %s where ts < 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts < 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 50 then + tdLog.info('tdSql.checkRow(50)') + tdSql.checkRows(50) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 + tdLog.info('select * from %s where ts > 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts > 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 150 then + tdLog.info('tdSql.checkRow(150)') + tdSql.checkRows(150) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts = 1605045600000 + 240001 + tdLog.info('select * from %s where ts = 1605045600000 + 240001' % (mt)) + tdSql.query('select * from %s where ts = 1605045600000 + 240001' % (mt)) + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 10 then + tdLog.info('tdSql.checkRow(10)') + tdSql.checkRows(10) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step4 + tdLog.info('=============== step4') + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 1 + tdLog.info('select * from %s where tgcol = 1' % (mt)) + tdSql.query('select * from %s where tgcol = 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 1 + tdLog.info('select * from %s where tgcol <> 1' % (mt)) + tdSql.query('select * from %s where tgcol <> 1' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol = 0 + tdLog.info('select * from %s where tgcol = 0' % (mt)) + tdSql.query('select * from %s where tgcol = 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where tgcol <> 0 + tdLog.info('select * from %s where tgcol <> 0' % (mt)) + tdSql.query('select * from %s where tgcol <> 0' % (mt)) + # TSIM: if $rows != 100 then + tdLog.info('tdSql.checkRow(100)') + tdSql.checkRows(100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step5 + tdLog.info('=============== step5') + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol = 1 + tdLog.info('select * from %s where ts > 1605045600000 + 240001 and tgcol = 1' % (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol = 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> 1 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 1' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 1' % + (mt)) + # TSIM: if $rows != 75 then + tdLog.info('tdSql.checkRow(75)') + tdSql.checkRows(75) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol = 0 + tdLog.info('select * from %s where ts < 1605045600000 + 240001 and tgcol = 0' % (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol <> 0 + tdLog.info( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts < 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol = 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol = 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol = 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol <> 0 + tdLog.info( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 25 then + tdLog.info('tdSql.checkRow(25)') + tdSql.checkRows(25) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and + # tgcol <> 0 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> 0' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> 0' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> 0 and ts + # < 1605045600000 + 300001 + tdLog.info( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 0 and ts < 1605045600000 + 300001' % + (mt)) + tdSql.query( + 'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 0 and ts < 1605045600000 + 300001' % + (mt)) + # TSIM: if $rows != 5 then + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step6 + tdLog.info('=============== step6') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 200 then + tdLog.info('tdSql.checkData(0, 0, 200)') + tdSql.checkData(0, 0, 200) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step7 + tdLog.info('=============== step7') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step8 + tdLog.info('=============== step8') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 50 then + tdLog.info('tdSql.checkData(0, 0, 50)') + tdSql.checkData(0, 0, 50) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step9 + tdLog.info('=============== step9') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step10 + tdLog.info('=============== step10') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group + # by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 100 then + tdLog.info('tdSql.checkData(0, 0, 100)') + tdSql.checkData(0, 0, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== step11 + tdLog.info('=============== step11') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001 + # group by tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data00 != 25 then + tdLog.info('tdSql.checkData(0, 0, 25)') + tdSql.checkData(0, 0, 25) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: + # TSIM: print =============== step12 + tdLog.info('=============== step12') + # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), + # max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by + # tgcol + tdLog.info( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + tdSql.query( + 'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' % + (mt)) + # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06') + # TSIM: if $data01 != 100 then + tdLog.info('tdSql.checkData(0, 1, 100)') + tdSql.checkData(0, 1, 100) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: print =============== clear + tdLog.info('=============== clear') + # TSIM: sql drop database $db + tdLog.info('drop database db') + tdSql.execute('drop database db') + # TSIM: sql show databases + tdLog.info('show databases') + tdSql.query('show databases') + # TSIM: if $rows != 0 then + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + # TSIM: return -1 + # TSIM: endi + # TSIM: + # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT +# convert end + tdSql.execute("create database db") + tdSql.execute("use db") + tdSql.execute( + "create table if not exists st (ts timestamp, tagtype int) tags(dev tinyint unsigned)") + tdSql.error( + 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (pow(2, 8) - 1)) + tdSql.error( + 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (-1)) + + tdSql.execute( + 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (pow(2, 8) - 2)) + tdSql.execute( + 'CREATE TABLE if not exists dev_002 using st tags(%d)' % (0)) + tdSql.execute( + 'CREATE TABLE if not exists dev_003 using st tags(%s)' % ('NULL')) + print("==============step2") + tdSql.query("show tables") + tdSql.checkRows(3) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/test-all.bat b/tests/pytest/test-all.bat new file mode 100644 index 0000000000000000000000000000000000000000..1f1e2c1727527e91f7632213992607d6221eac85 --- /dev/null +++ b/tests/pytest/test-all.bat @@ -0,0 +1,15 @@ +@echo off +SETLOCAL EnableDelayedExpansion +for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do ( set "DEL=%%a") +for /F "usebackq tokens=*" %%i in (fulltest.bat) do ( + echo Processing %%i + call %%i ARG1 -w 1 -m %1 > result.txt 2>error.txt + if errorlevel 1 ( call :colorEcho 0c "failed" &echo. && exit 8 ) else ( call :colorEcho 0a "Success" &echo. ) +) +exit + +:colorEcho +echo off + "%~2" +findstr /v /a:%1 /R "^$" "%~2" nul +del "%~2" > nul 2>&1i \ No newline at end of file diff --git a/tests/pytest/test.py b/tests/pytest/test.py new file mode 100644 index 0000000000000000000000000000000000000000..a96ac21496431b811f26fa82091c92f6ae8ecb9a --- /dev/null +++ b/tests/pytest/test.py @@ -0,0 +1,197 @@ +#!/usr/bin/python +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### +# install pip +# pip install src/connector/python/ + +# -*- coding: utf-8 -*- +import sys +import getopt +import subprocess +import time +from distutils.log import warn as printf +from fabric2 import Connection + +from util.log import * +from util.dnodes import * +from util.cases import * + +import taos + + +if __name__ == "__main__": + fileName = "all" + deployPath = "" + masterIp = "" + testCluster = False + valgrind = 0 + logSql = True + stop = 0 + restart = False + windows = 0 + opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghrw', [ + 'file=', 'path=', 'master', 'logSql', 'stop', 'cluster', 'valgrind', 'help', 'windows']) + for key, value in opts: + if key in ['-h', '--help']: + tdLog.printNoPrefix( + 'A collection of test cases written using Python') + tdLog.printNoPrefix('-f Name of test case file written by Python') + tdLog.printNoPrefix('-p Deploy Path for Simulator') + tdLog.printNoPrefix('-m Master Ip for Simulator') + tdLog.printNoPrefix('-l logSql Flag') + tdLog.printNoPrefix('-s stop All dnodes') + tdLog.printNoPrefix('-c Test Cluster Flag') + tdLog.printNoPrefix('-g valgrind Test Flag') + tdLog.printNoPrefix('-r taosd restart test') + tdLog.printNoPrefix('-w taos on windows') + sys.exit(0) + + if key in ['-r', '--restart']: + restart = True + + if key in ['-f', '--file']: + fileName = value + + if key in ['-p', '--path']: + deployPath = value + + if key in ['-m', '--master']: + masterIp = value + + if key in ['-l', '--logSql']: + if (value.upper() == "TRUE"): + logSql = True + elif (value.upper() == "FALSE"): + logSql = False + else: + tdLog.printNoPrefix("logSql value %s is invalid" % logSql) + sys.exit(0) + + if key in ['-c', '--cluster']: + testCluster = True + + if key in ['-g', '--valgrind']: + valgrind = 1 + + if key in ['-s', '--stop']: + stop = 1 + + if key in ['-w', '--windows']: + windows = 1 + + if (stop != 0): + if (valgrind == 0): + toBeKilled = "taosd" + else: + toBeKilled = "valgrind.bin" + + killCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs kill -TERM > /dev/null 2>&1" % toBeKilled + + psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled + processID = subprocess.check_output(psCmd, shell=True) + + while(processID): + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output(psCmd, shell=True) + + for port in range(6030, 6041): + usePortPID = "lsof -i tcp:%d | grep LISTEn | awk '{print $2}'" % port + processID = subprocess.check_output(usePortPID, shell=True) + + if processID: + killCmd = "kill -TERM %s" % processID + os.system(killCmd) + fuserCmd = "fuser -k -n tcp %d" % port + os.system(fuserCmd) + if valgrind: + time.sleep(2) + + tdLog.info('stop All dnodes') + + if masterIp == "": + host = '127.0.0.1' + else: + host = masterIp + + tdLog.info("Procedures for tdengine deployed in %s" % (host)) + if windows: + tdCases.logSql(logSql) + tdLog.info("Procedures for testing self-deployment") + td_clinet = TDSimClient("C:\\TDengine") + td_clinet.deploy() + remote_conn = Connection("root@%s"%host) + with remote_conn.cd('/var/lib/jenkins/workspace/TDinternal/community/tests/pytest'): + remote_conn.run("python3 ./test.py") + conn = taos.connect( + host="%s"%(host), + config=td_clinet.cfgDir) + tdCases.runOneWindows(conn, fileName) + else: + tdDnodes.init(deployPath) + tdDnodes.setTestCluster(testCluster) + tdDnodes.setValgrind(valgrind) + tdDnodes.stopAll() + is_test_framework = 0 + key_word = 'tdCases.addLinux' + try: + if key_word in open(fileName).read(): + is_test_framework = 1 + except: + pass + if is_test_framework: + moduleName = fileName.replace(".py", "").replace("/", ".") + uModule = importlib.import_module(moduleName) + try: + ucase = uModule.TDTestCase() + tdDnodes.deploy(1,ucase.updatecfgDict) + except : + tdDnodes.deploy(1,{}) + else: + pass + tdDnodes.deploy(1,{}) + tdDnodes.start(1) + + + + tdCases.logSql(logSql) + + if testCluster: + tdLog.info("Procedures for testing cluster") + if fileName == "all": + tdCases.runAllCluster() + else: + tdCases.runOneCluster(fileName) + else: + tdLog.info("Procedures for testing self-deployment") + conn = taos.connect( + host, + config=tdDnodes.getSimCfgPath()) + if fileName == "all": + tdCases.runAllLinux(conn) + else: + tdCases.runOneWindows(conn, fileName) + if restart: + if fileName == "all": + tdLog.info("not need to query ") + else: + sp = fileName.rsplit(".", 1) + if len(sp) == 2 and sp[1] == "py": + tdDnodes.stopAll() + tdDnodes.start(1) + time.sleep(1) + conn = taos.connect( host, config=tdDnodes.getSimCfgPath()) + tdLog.info("Procedures for tdengine deployed in %s" % (host)) + tdLog.info("query test after taosd restart") + tdCases.runOneLinux(conn, sp[0] + "_" + "restart.py") + else: + tdLog.info("not need to query") + conn.close() diff --git a/tests/pytest/test.sh b/tests/pytest/test.sh new file mode 100755 index 0000000000000000000000000000000000000000..4e74341f7075b50329a49aa3eccd09f68b733f20 --- /dev/null +++ b/tests/pytest/test.sh @@ -0,0 +1,23 @@ +EXEC_DIR=`dirname "$0"` +if [[ $EXEC_DIR != "." ]] +then + echo "ERROR: Please execute `basename "$0"` in its own directory (for now anyway, pardon the dust)" + exit -1 +fi +CURR_DIR=`pwd` +IN_TDINTERNAL="community" +if [[ "$CURR_DIR" == *"$IN_TDINTERNAL"* ]]; then + TAOS_DIR=$CURR_DIR/../../.. +else + TAOS_DIR=$CURR_DIR/../.. +fi +TAOSD_DIR=`find $TAOS_DIR -name "taosd"|grep bin|head -n1` +LIB_DIR=`echo $TAOSD_DIR|rev|cut -d '/' -f 3,4,5,6|rev`/lib +export PYTHONPATH=$(pwd)/../../src/connector/python +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LIB_DIR + +if [[ "$1" == *"test.py"* ]]; then + python3 ./test.py $@ +else + python3 $1 $@ +fi diff --git a/tests/pytest/testCompress.py b/tests/pytest/testCompress.py new file mode 100644 index 0000000000000000000000000000000000000000..1ad032f05f7ae0216ceb74747d25d49ed2146362 --- /dev/null +++ b/tests/pytest/testCompress.py @@ -0,0 +1,136 @@ +#!/usr/bin/python +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### +# install pip +# pip install src/connector/python/ + +# -*- coding: utf-8 -*- +import sys +import getopt +import subprocess +from distutils.log import warn as printf + +from util.log import * +from util.dnodes import * +from util.cases import * +from util.sql import * + +import taos + + +if __name__ == "__main__": + fileName = "all" + deployPath = "" + testCluster = False + valgrind = 0 + logSql = True + stop = 0 + opts, args = getopt.gnu_getopt(sys.argv[1:], 'l:sgh', [ + 'logSql', 'stop', 'valgrind', 'help']) + for key, value in opts: + if key in ['-h', '--help']: + tdLog.printNoPrefix( + 'A collection of test cases written using Python') + tdLog.printNoPrefix('-l logSql Flag') + tdLog.printNoPrefix('-s stop All dnodes') + tdLog.printNoPrefix('-g valgrind Test Flag') + sys.exit(0) + + if key in ['-l', '--logSql']: + if (value.upper() == "TRUE"): + logSql = True + elif (value.upper() == "FALSE"): + logSql = False + else: + tdLog.printNoPrefix("logSql value %s is invalid" % logSql) + sys.exit(0) + + if key in ['-g', '--valgrind']: + valgrind = 1 + + if key in ['-s', '--stop']: + stop = 1 + + if (stop != 0): + if (valgrind == 0): + toBeKilled = "taosd" + else: + toBeKilled = "valgrind.bin" + + killCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs kill -HUP > /dev/null 2>&1" % toBeKilled + + psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled + processID = subprocess.check_output(psCmd, shell=True) + + while(processID): + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output(psCmd, shell=True) + + for port in range(6030, 6041): + usePortPID = "lsof -i tcp:%d | grep LISTEn | awk '{print $2}'" % port + processID = subprocess.check_output(usePortPID, shell=True) + + if processID: + killCmd = "kill -9 %s" % processID + os.system(killCmd) + fuserCmd = "fuser -k -n tcp %d" % port + os.system(fuserCmd) + if valgrind: + time.sleep(2) + + tdLog.info('stop All dnodes') + sys.exit(0) + + tdDnodes.init(deployPath) + tdDnodes.setTestCluster(testCluster) + tdDnodes.setValgrind(valgrind) + + tdDnodes.stopAll() + tdDnodes.addSimExtraCfg("compressMsgSize", "10240") + tdDnodes.deploy(1) + tdDnodes.start(1) + + host = '127.0.0.1' + + tdLog.info("Procedures for tdengine deployed in %s" % (host)) + + tdCases.logSql(logSql) + + conn = taos.connect( + host, + config=tdDnodes.getSimCfgPath()) + + tdSql.init(conn.cursor(), True) + + tdSql.execute("CREATE DATABASE IF NOT EXISTS t10b") + tdSql.execute("USE t10b") + tdSql.execute( + "CREATE TABLE IF NOT EXISTS s_sensor_info (ts TIMESTAMP, temperature INT, humidity FLOAT)") + + start_time = int(round(time.time() * 1000)) + for i in range(1, 1000): + tdSql.execute("IMPORT INTO s_sensor_info VALUES (1575129600000, 16, 19.405090) (1575129601000, 22, 14.377142) (1575129602000, 16, 16.868231) (1575129603000, 20, 11.565193) (1575129604000, 31, 13.009119) (1575129605000, 29, 18.136400) (1575129606000, 17, 13.806572) (1575129607000, 23, 14.688898) (1575129608000, 26, 12.931019) (1575129609000, 32, 12.185531) (1575129610000, 30, 13.608714) (1575129611000, 23, 18.624914) (1575129612000, 22, 12.970826) (1575129613000, 22, 12.065827) (1575129614000, 25, 16.967192) (1575129615000, 16, 10.283031) (1575129616000, 22, 16.072535) (1575129617000, 24, 10.794536) (1575129618000, 32, 10.591207) (1575129619000, 20, 13.015227) (1575129620000, 28, 15.410999) (1575129621000, 29, 12.785076) (1575129622000, 28, 15.305857) (1575129623000, 33, 12.820810) (1575129624000, 34, 13.618055) (1575129625000, 32, 12.971123) (1575129626000, 24, 10.974546) (1575129627000, 15, 10.742910) (1575129628000, 23, 16.810783) (1575129629000, 18, 13.115224) (1575129630000, 26, 17.418489) (1575129631000, 20, 17.302315) (1575129632000, 21, 14.283571) (1575129633000, 16, 16.826534) (1575129634000, 18, 19.222122) (1575129635000, 18, 14.931420) (1575129636000, 17, 19.549454) (1575129637000, 22, 16.908388) (1575129638000, 32, 15.637796) (1575129639000, 31, 15.517650) (1575129640000, 18, 14.038033) (1575129641000, 32, 19.859648) (1575129642000, 16, 13.220840) (1575129643000, 28, 16.445398) (1575129644000, 26, 16.695753) (1575129645000, 33, 13.696928) (1575129646000, 21, 15.352819) (1575129647000, 15, 12.388407) (1575129648000, 27, 11.267529) (1575129649000, 20, 14.103228) (1575129650000, 20, 16.250950) (1575129651000, 30, 16.236088) (1575129652000, 22, 18.305340) (1575129653000, 25, 17.360685) (1575129654000, 25, 14.978681) (1575129655000, 33, 14.096183) (1575129656000, 26, 10.019039) (1575129657000, 19, 19.158213) (1575129658000, 22, 15.593924) (1575129659000, 26, 18.780119) (1575129660000, 21, 16.001656) (1575129661000, 16, 18.458328) (1575129662000, 21, 16.417843) (1575129663000, 28, 11.736558) (1575129664000, 34, 18.143946) (1575129665000, 27, 10.303225) (1575129666000, 20, 19.756748) (1575129667000, 22, 12.940063) (1575129668000, 23, 11.509640) (1575129669000, 19, 18.319309) (1575129670000, 19, 16.278345) (1575129671000, 27, 10.898361) (1575129672000, 31, 13.922162) (1575129673000, 15, 19.296116) (1575129674000, 26, 15.885763) (1575129675000, 15, 15.525804) (1575129676000, 19, 19.579538) (1575129677000, 20, 11.073811) (1575129678000, 16, 13.932510) (1575129679000, 17, 11.900328) (1575129680000, 22, 16.540415) (1575129681000, 33, 15.203803) (1575129682000, 17, 11.518434) (1575129683000, 17, 13.152081) (1575129684000, 18, 11.378041) (1575129685000, 21, 15.390745) (1575129686000, 30, 15.127818) (1575129687000, 19, 16.530401) (1575129688000, 32, 16.542702) (1575129689000, 26, 16.366442) (1575129690000, 25, 10.306822) (1575129691000, 15, 13.691117) (1575129692000, 15, 13.476817) (1575129693000, 25, 12.529998) (1575129694000, 22, 15.550021) (1575129695000, 20, 15.064971) (1575129696000, 24, 13.313683) (1575129697000, 23, 17.002878) (1575129698000, 30, 19.991594) (1575129699000, 15, 11.116746) (1575129699990, 16, 19.405090) (1575129700990, 22, 14.377142) (1575129701990, 16, 16.868231) (1575129702990, 20, 11.565193) (1575129703990, 31, 13.009119) (1575129704990, 29, 18.136400) (1575129705990, 17, 13.806572) (1575129706990, 23, 14.688898) (1575129707990, 26, 12.931019) (1575129708990, 32, 12.185531) (1575129709990, 30, 13.608714) (1575129710990, 23, 18.624914) (1575129711990, 22, 12.970826) (1575129712990, 22, 12.065827) (1575129713990, 25, 16.967192) (1575129714990, 16, 10.283031) (1575129715990, 22, 16.072535) (1575129716990, 24, 10.794536) (1575129717990, 32, 10.591207) (1575129718990, 20, 13.015227) (1575129719990, 28, 15.410999) (1575129720990, 29, 12.785076) (1575129721990, 28, 15.305857) (1575129722990, 33, 12.820810) (1575129723990, 34, 13.618055) (1575129724990, 32, 12.971123) (1575129725990, 24, 10.974546) (1575129726990, 15, 10.742910) (1575129727990, 23, 16.810783) (1575129728990, 18, 13.115224) (1575129729990, 26, 17.418489) (1575129730990, 20, 17.302315) (1575129731990, 21, 14.283571) (1575129732990, 16, 16.826534) (1575129733990, 18, 19.222122) (1575129734990, 18, 14.931420) (1575129735990, 17, 19.549454) (1575129736990, 22, 16.908388) (1575129737990, 32, 15.637796) (1575129738990, 31, 15.517650) (1575129739990, 18, 14.038033) (1575129740990, 32, 19.859648) (1575129741990, 16, 13.220840) (1575129742990, 28, 16.445398) (1575129743990, 26, 16.695753) (1575129744990, 33, 13.696928) (1575129745990, 21, 15.352819) (1575129746990, 15, 12.388407) (1575129747990, 27, 11.267529) (1575129748990, 20, 14.103228) (1575129749990, 20, 16.250950) (1575129750990, 30, 16.236088) (1575129751990, 22, 18.305340) (1575129752990, 25, 17.360685) (1575129753990, 25, 14.978681) (1575129754990, 33, 14.096183) (1575129755990, 26, 10.019039) (1575129756990, 19, 19.158213) (1575129757990, 22, 15.593924) (1575129758990, 26, 18.780119) (1575129759990, 21, 16.001656) (1575129760990, 16, 18.458328) (1575129761990, 21, 16.417843) (1575129762990, 28, 11.736558) (1575129763990, 34, 18.143946) (1575129764990, 27, 10.303225) (1575129765990, 20, 19.756748) (1575129766990, 22, 12.940063) (1575129767990, 23, 11.509640) (1575129768990, 19, 18.319309) (1575129769990, 19, 16.278345) (1575129770990, 27, 10.898361) (1575129771990, 31, 13.922162) (1575129772990, 15, 19.296116) (1575129773990, 26, 15.885763) (1575129774990, 15, 15.525804) (1575129775990, 19, 19.579538) (1575129776990, 20, 11.073811) (1575129777990, 16, 13.932510) (1575129778990, 17, 11.900328) (1575129779990, 22, 16.540415) (1575129780990, 33, 15.203803) (1575129781990, 17, 11.518434) (1575129782990, 17, 13.152081) (1575129783990, 18, 11.378041) (1575129784990, 21, 15.390745) (1575129785990, 30, 15.127818) (1575129786990, 19, 16.530401) (1575129787990, 32, 16.542702) (1575129788990, 26, 16.366442) (1575129789990, 25, 10.306822) (1575129790990, 15, 13.691117) (1575129791990, 15, 13.476817) (1575129792990, 25, 12.529998) (1575129793990, 22, 15.550021) (1575129794990, 20, 15.064971) (1575129795990, 24, 13.313683) (1575129796990, 23, 17.002878) (1575129797990, 30, 19.991594) (1575129798990, 15, 11.116746) (1575129799980, 16, 19.405090) (1575129800980, 22, 14.377142) (1575129801980, 16, 16.868231) (1575129802980, 20, 11.565193) (1575129803980, 31, 13.009119) (1575129804980, 29, 18.136400) (1575129805980, 17, 13.806572) (1575129806980, 23, 14.688898) (1575129807980, 26, 12.931019) (1575129808980, 32, 12.185531) (1575129809980, 30, 13.608714) (1575129810980, 23, 18.624914) (1575129811980, 22, 12.970826) (1575129812980, 22, 12.065827) (1575129813980, 25, 16.967192) (1575129814980, 16, 10.283031) (1575129815980, 22, 16.072535) (1575129816980, 24, 10.794536) (1575129817980, 32, 10.591207) (1575129818980, 20, 13.015227) (1575129819980, 28, 15.410999) (1575129820980, 29, 12.785076) (1575129821980, 28, 15.305857) (1575129822980, 33, 12.820810) (1575129823980, 34, 13.618055) (1575129824980, 32, 12.971123) (1575129825980, 24, 10.974546) (1575129826980, 15, 10.742910) (1575129827980, 23, 16.810783) (1575129828980, 18, 13.115224) (1575129829980, 26, 17.418489) (1575129830980, 20, 17.302315) (1575129831980, 21, 14.283571) (1575129832980, 16, 16.826534) (1575129833980, 18, 19.222122) (1575129834980, 18, 14.931420) (1575129835980, 17, 19.549454) (1575129836980, 22, 16.908388) (1575129837980, 32, 15.637796) (1575129838980, 31, 15.517650) (1575129839980, 18, 14.038033) (1575129840980, 32, 19.859648) (1575129841980, 16, 13.220840) (1575129842980, 28, 16.445398) (1575129843980, 26, 16.695753) (1575129844980, 33, 13.696928) (1575129845980, 21, 15.352819) (1575129846980, 15, 12.388407) (1575129847980, 27, 11.267529) (1575129848980, 20, 14.103228) (1575129849980, 20, 16.250950) (1575129850980, 30, 16.236088) (1575129851980, 22, 18.305340) (1575129852980, 25, 17.360685) (1575129853980, 25, 14.978681) (1575129854980, 33, 14.096183) (1575129855980, 26, 10.019039) (1575129856980, 19, 19.158213) (1575129857980, 22, 15.593924) (1575129858980, 26, 18.780119) (1575129859980, 21, 16.001656) (1575129860980, 16, 18.458328) (1575129861980, 21, 16.417843) (1575129862980, 28, 11.736558) (1575129863980, 34, 18.143946) (1575129864980, 27, 10.303225) (1575129865980, 20, 19.756748) (1575129866980, 22, 12.940063) (1575129867980, 23, 11.509640) (1575129868980, 19, 18.319309) (1575129869980, 19, 16.278345) (1575129870980, 27, 10.898361) (1575129871980, 31, 13.922162) (1575129872980, 15, 19.296116) (1575129873980, 26, 15.885763) (1575129874980, 15, 15.525804) (1575129875980, 19, 19.579538) (1575129876980, 20, 11.073811) (1575129877980, 16, 13.932510) (1575129878980, 17, 11.900328) (1575129879980, 22, 16.540415) (1575129880980, 33, 15.203803) (1575129881980, 17, 11.518434) (1575129882980, 17, 13.152081) (1575129883980, 18, 11.378041) (1575129884980, 21, 15.390745) (1575129885980, 30, 15.127818) (1575129886980, 19, 16.530401) (1575129887980, 32, 16.542702) (1575129888980, 26, 16.366442) (1575129889980, 25, 10.306822) (1575129890980, 15, 13.691117) (1575129891980, 15, 13.476817) (1575129892980, 25, 12.529998) (1575129893980, 22, 15.550021) (1575129894980, 20, 15.064971) (1575129895980, 24, 13.313683) (1575129896980, 23, 17.002878) (1575129897980, 30, 19.991594) (1575129898980, 15, 11.116746) (1575129899970, 16, 19.405090) (1575129900970, 22, 14.377142) (1575129901970, 16, 16.868231) (1575129902970, 20, 11.565193) (1575129903970, 31, 13.009119) (1575129904970, 29, 18.136400) (1575129905970, 17, 13.806572) (1575129906970, 23, 14.688898) (1575129907970, 26, 12.931019) (1575129908970, 32, 12.185531) (1575129909970, 30, 13.608714) (1575129910970, 23, 18.624914) (1575129911970, 22, 12.970826) (1575129912970, 22, 12.065827) (1575129913970, 25, 16.967192) (1575129914970, 16, 10.283031) (1575129915970, 22, 16.072535) (1575129916970, 24, 10.794536) (1575129917970, 32, 10.591207) (1575129918970, 20, 13.015227) (1575129919970, 28, 15.410999) (1575129920970, 29, 12.785076) (1575129921970, 28, 15.305857) (1575129922970, 33, 12.820810) (1575129923970, 34, 13.618055) (1575129924970, 32, 12.971123) (1575129925970, 24, 10.974546) (1575129926970, 15, 10.742910) (1575129927970, 23, 16.810783) (1575129928970, 18, 13.115224) (1575129929970, 26, 17.418489) (1575129930970, 20, 17.302315) (1575129931970, 21, 14.283571) (1575129932970, 16, 16.826534) (1575129933970, 18, 19.222122) (1575129934970, 18, 14.931420) (1575129935970, 17, 19.549454) (1575129936970, 22, 16.908388) (1575129937970, 32, 15.637796) (1575129938970, 31, 15.517650) (1575129939970, 18, 14.038033) (1575129940970, 32, 19.859648) (1575129941970, 16, 13.220840) (1575129942970, 28, 16.445398) (1575129943970, 26, 16.695753) (1575129944970, 33, 13.696928) (1575129945970, 21, 15.352819) (1575129946970, 15, 12.388407) (1575129947970, 27, 11.267529) (1575129948970, 20, 14.103228) (1575129949970, 20, 16.250950) (1575129950970, 30, 16.236088) (1575129951970, 22, 18.305340) (1575129952970, 25, 17.360685) (1575129953970, 25, 14.978681) (1575129954970, 33, 14.096183) (1575129955970, 26, 10.019039) (1575129956970, 19, 19.158213) (1575129957970, 22, 15.593924) (1575129958970, 26, 18.780119) (1575129959970, 21, 16.001656) (1575129960970, 16, 18.458328) (1575129961970, 21, 16.417843) (1575129962970, 28, 11.736558) (1575129963970, 34, 18.143946) (1575129964970, 27, 10.303225) (1575129965970, 20, 19.756748) (1575129966970, 22, 12.940063) (1575129967970, 23, 11.509640) (1575129968970, 19, 18.319309) (1575129969970, 19, 16.278345) (1575129970970, 27, 10.898361) (1575129971970, 31, 13.922162) (1575129972970, 15, 19.296116) (1575129973970, 26, 15.885763) (1575129974970, 15, 15.525804) (1575129975970, 19, 19.579538) (1575129976970, 20, 11.073811) (1575129977970, 16, 13.932510) (1575129978970, 17, 11.900328) (1575129979970, 22, 16.540415) (1575129980970, 33, 15.203803) (1575129981970, 17, 11.518434) (1575129982970, 17, 13.152081) (1575129983970, 18, 11.378041) (1575129984970, 21, 15.390745) (1575129985970, 30, 15.127818) (1575129986970, 19, 16.530401) (1575129987970, 32, 16.542702) (1575129988970, 26, 16.366442) (1575129989970, 25, 10.306822) (1575129990970, 15, 13.691117) (1575129991970, 15, 13.476817) (1575129992970, 25, 12.529998) (1575129993970, 22, 15.550021) (1575129994970, 20, 15.064971) (1575129995970, 24, 13.313683) (1575129996970, 23, 17.002878) (1575129997970, 30, 19.991594) (1575129998970, 15, 11.116746) (1575129999960, 16, 19.405090) (1575130000960, 22, 14.377142) (1575130001960, 16, 16.868231) (1575130002960, 20, 11.565193) (1575130003960, 31, 13.009119) (1575130004960, 29, 18.136400) (1575130005960, 17, 13.806572) (1575130006960, 23, 14.688898) (1575130007960, 26, 12.931019) (1575130008960, 32, 12.185531) (1575130009960, 30, 13.608714) (1575130010960, 23, 18.624914) (1575130011960, 22, 12.970826) (1575130012960, 22, 12.065827) (1575130013960, 25, 16.967192) (1575130014960, 16, 10.283031) (1575130015960, 22, 16.072535) (1575130016960, 24, 10.794536) (1575130017960, 32, 10.591207) (1575130018960, 20, 13.015227) (1575130019960, 28, 15.410999) (1575130020960, 29, 12.785076) (1575130021960, 28, 15.305857) (1575130022960, 33, 12.820810) (1575130023960, 34, 13.618055) (1575130024960, 32, 12.971123) (1575130025960, 24, 10.974546) (1575130026960, 15, 10.742910) (1575130027960, 23, 16.810783) (1575130028960, 18, 13.115224) (1575130029960, 26, 17.418489) (1575130030960, 20, 17.302315) (1575130031960, 21, 14.283571) (1575130032960, 16, 16.826534) (1575130033960, 18, 19.222122) (1575130034960, 18, 14.931420) (1575130035960, 17, 19.549454) (1575130036960, 22, 16.908388) (1575130037960, 32, 15.637796) (1575130038960, 31, 15.517650) (1575130039960, 18, 14.038033) (1575130040960, 32, 19.859648) (1575130041960, 16, 13.220840) (1575130042960, 28, 16.445398) (1575130043960, 26, 16.695753) (1575130044960, 33, 13.696928) (1575130045960, 21, 15.352819) (1575130046960, 15, 12.388407) (1575130047960, 27, 11.267529) (1575130048960, 20, 14.103228) (1575130049960, 20, 16.250950) (1575130050960, 30, 16.236088) (1575130051960, 22, 18.305340) (1575130052960, 25, 17.360685) (1575130053960, 25, 14.978681) (1575130054960, 33, 14.096183) (1575130055960, 26, 10.019039) (1575130056960, 19, 19.158213) (1575130057960, 22, 15.593924) (1575130058960, 26, 18.780119) (1575130059960, 21, 16.001656) (1575130060960, 16, 18.458328) (1575130061960, 21, 16.417843) (1575130062960, 28, 11.736558) (1575130063960, 34, 18.143946) (1575130064960, 27, 10.303225) (1575130065960, 20, 19.756748) (1575130066960, 22, 12.940063) (1575130067960, 23, 11.509640) (1575130068960, 19, 18.319309) (1575130069960, 19, 16.278345) (1575130070960, 27, 10.898361) (1575130071960, 31, 13.922162) (1575130072960, 15, 19.296116) (1575130073960, 26, 15.885763) (1575130074960, 15, 15.525804) (1575130075960, 19, 19.579538) (1575130076960, 20, 11.073811) (1575130077960, 16, 13.932510) (1575130078960, 17, 11.900328) (1575130079960, 22, 16.540415) (1575130080960, 33, 15.203803) (1575130081960, 17, 11.518434) (1575130082960, 17, 13.152081) (1575130083960, 18, 11.378041) (1575130084960, 21, 15.390745) (1575130085960, 30, 15.127818) (1575130086960, 19, 16.530401) (1575130087960, 32, 16.542702) (1575130088960, 26, 16.366442) (1575130089960, 25, 10.306822) (1575130090960, 15, 13.691117) (1575130091960, 15, 13.476817) (1575130092960, 25, 12.529998) (1575130093960, 22, 15.550021) (1575130094960, 20, 15.064971) (1575130095960, 24, 13.313683) (1575130096960, 23, 17.002878) (1575130097960, 30, 19.991594) (1575130098960, 15, 11.116746) (1575130099950, 16, 19.405090) (1575130100950, 22, 14.377142) (1575130101950, 16, 16.868231) (1575130102950, 20, 11.565193) (1575130103950, 31, 13.009119) (1575130104950, 29, 18.136400) (1575130105950, 17, 13.806572) (1575130106950, 23, 14.688898) (1575130107950, 26, 12.931019) (1575130108950, 32, 12.185531) (1575130109950, 30, 13.608714) (1575130110950, 23, 18.624914) (1575130111950, 22, 12.970826) (1575130112950, 22, 12.065827) (1575130113950, 25, 16.967192) (1575130114950, 16, 10.283031) (1575130115950, 22, 16.072535) (1575130116950, 24, 10.794536) (1575130117950, 32, 10.591207) (1575130118950, 20, 13.015227) (1575130119950, 28, 15.410999) (1575130120950, 29, 12.785076) (1575130121950, 28, 15.305857) (1575130122950, 33, 12.820810) (1575130123950, 34, 13.618055) (1575130124950, 32, 12.971123) (1575130125950, 24, 10.974546) (1575130126950, 15, 10.742910) (1575130127950, 23, 16.810783) (1575130128950, 18, 13.115224) (1575130129950, 26, 17.418489) (1575130130950, 20, 17.302315) (1575130131950, 21, 14.283571) (1575130132950, 16, 16.826534) (1575130133950, 18, 19.222122) (1575130134950, 18, 14.931420) (1575130135950, 17, 19.549454) (1575130136950, 22, 16.908388) (1575130137950, 32, 15.637796) (1575130138950, 31, 15.517650) (1575130139950, 18, 14.038033) (1575130140950, 32, 19.859648) (1575130141950, 16, 13.220840) (1575130142950, 28, 16.445398) (1575130143950, 26, 16.695753) (1575130144950, 33, 13.696928) (1575130145950, 21, 15.352819) (1575130146950, 15, 12.388407) (1575130147950, 27, 11.267529) (1575130148950, 20, 14.103228) (1575130149950, 20, 16.250950) (1575130150950, 30, 16.236088) (1575130151950, 22, 18.305340) (1575130152950, 25, 17.360685) (1575130153950, 25, 14.978681) (1575130154950, 33, 14.096183) (1575130155950, 26, 10.019039) (1575130156950, 19, 19.158213) (1575130157950, 22, 15.593924) (1575130158950, 26, 18.780119) (1575130159950, 21, 16.001656) (1575130160950, 16, 18.458328) (1575130161950, 21, 16.417843) (1575130162950, 28, 11.736558) (1575130163950, 34, 18.143946) (1575130164950, 27, 10.303225) (1575130165950, 20, 19.756748) (1575130166950, 22, 12.940063) (1575130167950, 23, 11.509640) (1575130168950, 19, 18.319309) (1575130169950, 19, 16.278345) (1575130170950, 27, 10.898361) (1575130171950, 31, 13.922162) (1575130172950, 15, 19.296116) (1575130173950, 26, 15.885763) (1575130174950, 15, 15.525804) (1575130175950, 19, 19.579538) (1575130176950, 20, 11.073811) (1575130177950, 16, 13.932510) (1575130178950, 17, 11.900328) (1575130179950, 22, 16.540415) (1575130180950, 33, 15.203803) (1575130181950, 17, 11.518434) (1575130182950, 17, 13.152081) (1575130183950, 18, 11.378041) (1575130184950, 21, 15.390745) (1575130185950, 30, 15.127818) (1575130186950, 19, 16.530401) (1575130187950, 32, 16.542702) (1575130188950, 26, 16.366442) (1575130189950, 25, 10.306822) (1575130190950, 15, 13.691117) (1575130191950, 15, 13.476817) (1575130192950, 25, 12.529998) (1575130193950, 22, 15.550021) (1575130194950, 20, 15.064971) (1575130195950, 24, 13.313683) (1575130196950, 23, 17.002878) (1575130197950, 30, 19.991594) (1575130198950, 15, 11.116746) (1575130199940, 16, 19.405090) (1575130200940, 22, 14.377142) (1575130201940, 16, 16.868231) (1575130202940, 20, 11.565193) (1575130203940, 31, 13.009119) (1575130204940, 29, 18.136400) (1575130205940, 17, 13.806572) (1575130206940, 23, 14.688898) (1575130207940, 26, 12.931019) (1575130208940, 32, 12.185531) (1575130209940, 30, 13.608714) (1575130210940, 23, 18.624914) (1575130211940, 22, 12.970826) (1575130212940, 22, 12.065827) (1575130213940, 25, 16.967192) (1575130214940, 16, 10.283031) (1575130215940, 22, 16.072535) (1575130216940, 24, 10.794536) (1575130217940, 32, 10.591207) (1575130218940, 20, 13.015227) (1575130219940, 28, 15.410999) (1575130220940, 29, 12.785076) (1575130221940, 28, 15.305857) (1575130222940, 33, 12.820810) (1575130223940, 34, 13.618055) (1575130224940, 32, 12.971123) (1575130225940, 24, 10.974546) (1575130226940, 15, 10.742910) (1575130227940, 23, 16.810783) (1575130228940, 18, 13.115224) (1575130229940, 26, 17.418489) (1575130230940, 20, 17.302315) (1575130231940, 21, 14.283571) (1575130232940, 16, 16.826534) (1575130233940, 18, 19.222122) (1575130234940, 18, 14.931420) (1575130235940, 17, 19.549454) (1575130236940, 22, 16.908388) (1575130237940, 32, 15.637796) (1575130238940, 31, 15.517650) (1575130239940, 18, 14.038033) (1575130240940, 32, 19.859648) (1575130241940, 16, 13.220840) (1575130242940, 28, 16.445398) (1575130243940, 26, 16.695753) (1575130244940, 33, 13.696928) (1575130245940, 21, 15.352819) (1575130246940, 15, 12.388407) (1575130247940, 27, 11.267529) (1575130248940, 20, 14.103228) (1575130249940, 20, 16.250950) (1575130250940, 30, 16.236088) (1575130251940, 22, 18.305340) (1575130252940, 25, 17.360685) (1575130253940, 25, 14.978681) (1575130254940, 33, 14.096183) (1575130255940, 26, 10.019039) (1575130256940, 19, 19.158213) (1575130257940, 22, 15.593924) (1575130258940, 26, 18.780119) (1575130259940, 21, 16.001656) (1575130260940, 16, 18.458328) (1575130261940, 21, 16.417843) (1575130262940, 28, 11.736558) (1575130263940, 34, 18.143946) (1575130264940, 27, 10.303225) (1575130265940, 20, 19.756748) (1575130266940, 22, 12.940063) (1575130267940, 23, 11.509640) (1575130268940, 19, 18.319309) (1575130269940, 19, 16.278345) (1575130270940, 27, 10.898361) (1575130271940, 31, 13.922162) (1575130272940, 15, 19.296116) (1575130273940, 26, 15.885763) (1575130274940, 15, 15.525804) (1575130275940, 19, 19.579538) (1575130276940, 20, 11.073811) (1575130277940, 16, 13.932510) (1575130278940, 17, 11.900328) (1575130279940, 22, 16.540415) (1575130280940, 33, 15.203803) (1575130281940, 17, 11.518434) (1575130282940, 17, 13.152081) (1575130283940, 18, 11.378041) (1575130284940, 21, 15.390745) (1575130285940, 30, 15.127818) (1575130286940, 19, 16.530401) (1575130287940, 32, 16.542702) (1575130288940, 26, 16.366442) (1575130289940, 25, 10.306822) (1575130290940, 15, 13.691117) (1575130291940, 15, 13.476817) (1575130292940, 25, 12.529998) (1575130293940, 22, 15.550021) (1575130294940, 20, 15.064971) (1575130295940, 24, 13.313683) (1575130296940, 23, 17.002878) (1575130297940, 30, 19.991594) (1575130298940, 15, 11.116746) (1575130299930, 16, 19.405090) (1575130300930, 22, 14.377142) (1575130301930, 16, 16.868231) (1575130302930, 20, 11.565193) (1575130303930, 31, 13.009119) (1575130304930, 29, 18.136400) (1575130305930, 17, 13.806572) (1575130306930, 23, 14.688898) (1575130307930, 26, 12.931019) (1575130308930, 32, 12.185531) (1575130309930, 30, 13.608714) (1575130310930, 23, 18.624914) (1575130311930, 22, 12.970826) (1575130312930, 22, 12.065827) (1575130313930, 25, 16.967192) (1575130314930, 16, 10.283031) (1575130315930, 22, 16.072535) (1575130316930, 24, 10.794536) (1575130317930, 32, 10.591207) (1575130318930, 20, 13.015227) (1575130319930, 28, 15.410999) (1575130320930, 29, 12.785076) (1575130321930, 28, 15.305857) (1575130322930, 33, 12.820810) (1575130323930, 34, 13.618055) (1575130324930, 32, 12.971123) (1575130325930, 24, 10.974546) (1575130326930, 15, 10.742910) (1575130327930, 23, 16.810783) (1575130328930, 18, 13.115224) (1575130329930, 26, 17.418489) (1575130330930, 20, 17.302315) (1575130331930, 21, 14.283571) (1575130332930, 16, 16.826534) (1575130333930, 18, 19.222122) (1575130334930, 18, 14.931420) (1575130335930, 17, 19.549454) (1575130336930, 22, 16.908388) (1575130337930, 32, 15.637796) (1575130338930, 31, 15.517650) (1575130339930, 18, 14.038033) (1575130340930, 32, 19.859648) (1575130341930, 16, 13.220840) (1575130342930, 28, 16.445398) (1575130343930, 26, 16.695753) (1575130344930, 33, 13.696928) (1575130345930, 21, 15.352819) (1575130346930, 15, 12.388407) (1575130347930, 27, 11.267529) (1575130348930, 20, 14.103228) (1575130349930, 20, 16.250950) (1575130350930, 30, 16.236088) (1575130351930, 22, 18.305340) (1575130352930, 25, 17.360685) (1575130353930, 25, 14.978681) (1575130354930, 33, 14.096183) (1575130355930, 26, 10.019039) (1575130356930, 19, 19.158213) (1575130357930, 22, 15.593924) (1575130358930, 26, 18.780119) (1575130359930, 21, 16.001656) (1575130360930, 16, 18.458328) (1575130361930, 21, 16.417843) (1575130362930, 28, 11.736558) (1575130363930, 34, 18.143946) (1575130364930, 27, 10.303225) (1575130365930, 20, 19.756748) (1575130366930, 22, 12.940063) (1575130367930, 23, 11.509640) (1575130368930, 19, 18.319309) (1575130369930, 19, 16.278345) (1575130370930, 27, 10.898361) (1575130371930, 31, 13.922162) (1575130372930, 15, 19.296116) (1575130373930, 26, 15.885763) (1575130374930, 15, 15.525804) (1575130375930, 19, 19.579538) (1575130376930, 20, 11.073811) (1575130377930, 16, 13.932510) (1575130378930, 17, 11.900328) (1575130379930, 22, 16.540415) (1575130380930, 33, 15.203803) (1575130381930, 17, 11.518434) (1575130382930, 17, 13.152081) (1575130383930, 18, 11.378041) (1575130384930, 21, 15.390745) (1575130385930, 30, 15.127818) (1575130386930, 19, 16.530401) (1575130387930, 32, 16.542702) (1575130388930, 26, 16.366442) (1575130389930, 25, 10.306822) (1575130390930, 15, 13.691117) (1575130391930, 15, 13.476817) (1575130392930, 25, 12.529998) (1575130393930, 22, 15.550021) (1575130394930, 20, 15.064971) (1575130395930, 24, 13.313683) (1575130396930, 23, 17.002878) (1575130397930, 30, 19.991594) (1575130398930, 15, 11.116746) (1575130399920, 16, 19.405090) (1575130400920, 22, 14.377142) (1575130401920, 16, 16.868231) (1575130402920, 20, 11.565193) (1575130403920, 31, 13.009119) (1575130404920, 29, 18.136400) (1575130405920, 17, 13.806572) (1575130406920, 23, 14.688898) (1575130407920, 26, 12.931019) (1575130408920, 32, 12.185531) (1575130409920, 30, 13.608714) (1575130410920, 23, 18.624914) (1575130411920, 22, 12.970826) (1575130412920, 22, 12.065827) (1575130413920, 25, 16.967192) (1575130414920, 16, 10.283031) (1575130415920, 22, 16.072535) (1575130416920, 24, 10.794536) (1575130417920, 32, 10.591207) (1575130418920, 20, 13.015227) (1575130419920, 28, 15.410999) (1575130420920, 29, 12.785076) (1575130421920, 28, 15.305857) (1575130422920, 33, 12.820810) (1575130423920, 34, 13.618055) (1575130424920, 32, 12.971123) (1575130425920, 24, 10.974546) (1575130426920, 15, 10.742910) (1575130427920, 23, 16.810783) (1575130428920, 18, 13.115224) (1575130429920, 26, 17.418489) (1575130430920, 20, 17.302315) (1575130431920, 21, 14.283571) (1575130432920, 16, 16.826534) (1575130433920, 18, 19.222122) (1575130434920, 18, 14.931420) (1575130435920, 17, 19.549454) (1575130436920, 22, 16.908388) (1575130437920, 32, 15.637796) (1575130438920, 31, 15.517650) (1575130439920, 18, 14.038033) (1575130440920, 32, 19.859648) (1575130441920, 16, 13.220840) (1575130442920, 28, 16.445398) (1575130443920, 26, 16.695753) (1575130444920, 33, 13.696928) (1575130445920, 21, 15.352819) (1575130446920, 15, 12.388407) (1575130447920, 27, 11.267529) (1575130448920, 20, 14.103228) (1575130449920, 20, 16.250950) (1575130450920, 30, 16.236088) (1575130451920, 22, 18.305340) (1575130452920, 25, 17.360685) (1575130453920, 25, 14.978681) (1575130454920, 33, 14.096183) (1575130455920, 26, 10.019039) (1575130456920, 19, 19.158213) (1575130457920, 22, 15.593924) (1575130458920, 26, 18.780119) (1575130459920, 21, 16.001656) (1575130460920, 16, 18.458328) (1575130461920, 21, 16.417843) (1575130462920, 28, 11.736558) (1575130463920, 34, 18.143946) (1575130464920, 27, 10.303225) (1575130465920, 20, 19.756748) (1575130466920, 22, 12.940063) (1575130467920, 23, 11.509640) (1575130468920, 19, 18.319309) (1575130469920, 19, 16.278345) (1575130470920, 27, 10.898361) (1575130471920, 31, 13.922162) (1575130472920, 15, 19.296116) (1575130473920, 26, 15.885763) (1575130474920, 15, 15.525804) (1575130475920, 19, 19.579538) (1575130476920, 20, 11.073811) (1575130477920, 16, 13.932510) (1575130478920, 17, 11.900328) (1575130479920, 22, 16.540415) (1575130480920, 33, 15.203803) (1575130481920, 17, 11.518434) (1575130482920, 17, 13.152081) (1575130483920, 18, 11.378041) (1575130484920, 21, 15.390745) (1575130485920, 30, 15.127818) (1575130486920, 19, 16.530401) (1575130487920, 32, 16.542702) (1575130488920, 26, 16.366442) (1575130489920, 25, 10.306822) (1575130490920, 15, 13.691117) (1575130491920, 15, 13.476817) (1575130492920, 25, 12.529998) (1575130493920, 22, 15.550021) (1575130494920, 20, 15.064971) (1575130495920, 24, 13.313683) (1575130496920, 23, 17.002878) (1575130497920, 30, 19.991594) (1575130498920, 15, 11.116746) (1575130499910, 16, 19.405090) (1575130500910, 22, 14.377142) (1575130501910, 16, 16.868231) (1575130502910, 20, 11.565193) (1575130503910, 31, 13.009119) (1575130504910, 29, 18.136400) (1575130505910, 17, 13.806572) (1575130506910, 23, 14.688898) (1575130507910, 26, 12.931019) (1575130508910, 32, 12.185531) (1575130509910, 30, 13.608714) (1575130510910, 23, 18.624914) (1575130511910, 22, 12.970826) (1575130512910, 22, 12.065827) (1575130513910, 25, 16.967192) (1575130514910, 16, 10.283031) (1575130515910, 22, 16.072535) (1575130516910, 24, 10.794536) (1575130517910, 32, 10.591207) (1575130518910, 20, 13.015227) (1575130519910, 28, 15.410999) (1575130520910, 29, 12.785076) (1575130521910, 28, 15.305857) (1575130522910, 33, 12.820810) (1575130523910, 34, 13.618055) (1575130524910, 32, 12.971123) (1575130525910, 24, 10.974546) (1575130526910, 15, 10.742910) (1575130527910, 23, 16.810783) (1575130528910, 18, 13.115224) (1575130529910, 26, 17.418489) (1575130530910, 20, 17.302315) (1575130531910, 21, 14.283571) (1575130532910, 16, 16.826534) (1575130533910, 18, 19.222122) (1575130534910, 18, 14.931420) (1575130535910, 17, 19.549454) (1575130536910, 22, 16.908388) (1575130537910, 32, 15.637796) (1575130538910, 31, 15.517650) (1575130539910, 18, 14.038033) (1575130540910, 32, 19.859648) (1575130541910, 16, 13.220840) (1575130542910, 28, 16.445398) (1575130543910, 26, 16.695753) (1575130544910, 33, 13.696928) (1575130545910, 21, 15.352819) (1575130546910, 15, 12.388407) (1575130547910, 27, 11.267529) (1575130548910, 20, 14.103228) (1575130549910, 20, 16.250950) (1575130550910, 30, 16.236088) (1575130551910, 22, 18.305340) (1575130552910, 25, 17.360685) (1575130553910, 25, 14.978681) (1575130554910, 33, 14.096183) (1575130555910, 26, 10.019039) (1575130556910, 19, 19.158213) (1575130557910, 22, 15.593924) (1575130558910, 26, 18.780119) (1575130559910, 21, 16.001656) (1575130560910, 16, 18.458328) (1575130561910, 21, 16.417843) (1575130562910, 28, 11.736558) (1575130563910, 34, 18.143946) (1575130564910, 27, 10.303225) (1575130565910, 20, 19.756748) (1575130566910, 22, 12.940063) (1575130567910, 23, 11.509640) (1575130568910, 19, 18.319309) (1575130569910, 19, 16.278345) (1575130570910, 27, 10.898361) (1575130571910, 31, 13.922162) (1575130572910, 15, 19.296116) (1575130573910, 26, 15.885763) (1575130574910, 15, 15.525804) (1575130575910, 19, 19.579538) (1575130576910, 20, 11.073811) (1575130577910, 16, 13.932510) (1575130578910, 17, 11.900328) (1575130579910, 22, 16.540415) (1575130580910, 33, 15.203803) (1575130581910, 17, 11.518434) (1575130582910, 17, 13.152081) (1575130583910, 18, 11.378041) (1575130584910, 21, 15.390745) (1575130585910, 30, 15.127818) (1575130586910, 19, 16.530401) (1575130587910, 32, 16.542702) (1575130588910, 26, 16.366442) (1575130589910, 25, 10.306822) (1575130590910, 15, 13.691117) (1575130591910, 15, 13.476817) (1575130592910, 25, 12.529998) (1575130593910, 22, 15.550021) (1575130594910, 20, 15.064971) (1575130595910, 24, 13.313683) (1575130596910, 23, 17.002878) (1575130597910, 30, 19.991594) (1575130598910, 15, 11.116746) (1575130599900, 16, 19.405090) (1575130600900, 22, 14.377142) (1575130601900, 16, 16.868231) (1575130602900, 20, 11.565193) (1575130603900, 31, 13.009119) (1575130604900, 29, 18.136400) (1575130605900, 17, 13.806572) (1575130606900, 23, 14.688898) (1575130607900, 26, 12.931019) (1575130608900, 32, 12.185531) (1575130609900, 30, 13.608714) (1575130610900, 23, 18.624914) (1575130611900, 22, 12.970826) (1575130612900, 22, 12.065827) (1575130613900, 25, 16.967192) (1575130614900, 16, 10.283031) (1575130615900, 22, 16.072535) (1575130616900, 24, 10.794536) (1575130617900, 32, 10.591207) (1575130618900, 20, 13.015227) (1575130619900, 28, 15.410999) (1575130620900, 29, 12.785076) (1575130621900, 28, 15.305857) (1575130622900, 33, 12.820810) (1575130623900, 34, 13.618055) (1575130624900, 32, 12.971123) (1575130625900, 24, 10.974546) (1575130626900, 15, 10.742910) (1575130627900, 23, 16.810783) (1575130628900, 18, 13.115224) (1575130629900, 26, 17.418489) (1575130630900, 20, 17.302315) (1575130631900, 21, 14.283571) (1575130632900, 16, 16.826534) (1575130633900, 18, 19.222122) (1575130634900, 18, 14.931420) (1575130635900, 17, 19.549454) (1575130636900, 22, 16.908388) (1575130637900, 32, 15.637796) (1575130638900, 31, 15.517650) (1575130639900, 18, 14.038033) (1575130640900, 32, 19.859648) (1575130641900, 16, 13.220840) (1575130642900, 28, 16.445398) (1575130643900, 26, 16.695753) (1575130644900, 33, 13.696928) (1575130645900, 21, 15.352819) (1575130646900, 15, 12.388407) (1575130647900, 27, 11.267529) (1575130648900, 20, 14.103228) (1575130649900, 20, 16.250950) (1575130650900, 30, 16.236088) (1575130651900, 22, 18.305340) (1575130652900, 25, 17.360685) (1575130653900, 25, 14.978681) (1575130654900, 33, 14.096183) (1575130655900, 26, 10.019039) (1575130656900, 19, 19.158213) (1575130657900, 22, 15.593924) (1575130658900, 26, 18.780119) (1575130659900, 21, 16.001656) (1575130660900, 16, 18.458328) (1575130661900, 21, 16.417843) (1575130662900, 28, 11.736558) (1575130663900, 34, 18.143946) (1575130664900, 27, 10.303225) (1575130665900, 20, 19.756748) (1575130666900, 22, 12.940063) (1575130667900, 23, 11.509640) (1575130668900, 19, 18.319309) (1575130669900, 19, 16.278345) (1575130670900, 27, 10.898361) (1575130671900, 31, 13.922162) (1575130672900, 15, 19.296116) (1575130673900, 26, 15.885763) (1575130674900, 15, 15.525804) (1575130675900, 19, 19.579538) (1575130676900, 20, 11.073811) (1575130677900, 16, 13.932510) (1575130678900, 17, 11.900328) (1575130679900, 22, 16.540415) (1575130680900, 33, 15.203803) (1575130681900, 17, 11.518434) (1575130682900, 17, 13.152081) (1575130683900, 18, 11.378041) (1575130684900, 21, 15.390745) (1575130685900, 30, 15.127818) (1575130686900, 19, 16.530401) (1575130687900, 32, 16.542702) (1575130688900, 26, 16.366442) (1575130689900, 25, 10.306822) (1575130690900, 15, 13.691117) (1575130691900, 15, 13.476817) (1575130692900, 25, 12.529998) (1575130693900, 22, 15.550021) (1575130694900, 20, 15.064971) (1575130695900, 24, 13.313683) (1575130696900, 23, 17.002878) (1575130697900, 30, 19.991594) (1575130698900, 15, 11.116746) (1575130699890, 16, 19.405090) (1575130700890, 22, 14.377142) (1575130701890, 16, 16.868231) (1575130702890, 20, 11.565193) (1575130703890, 31, 13.009119) (1575130704890, 29, 18.136400) (1575130705890, 17, 13.806572) (1575130706890, 23, 14.688898) (1575130707890, 26, 12.931019) (1575130708890, 32, 12.185531) (1575130709890, 30, 13.608714) (1575130710890, 23, 18.624914) (1575130711890, 22, 12.970826) (1575130712890, 22, 12.065827) (1575130713890, 25, 16.967192) (1575130714890, 16, 10.283031) (1575130715890, 22, 16.072535) (1575130716890, 24, 10.794536) (1575130717890, 32, 10.591207) (1575130718890, 20, 13.015227) (1575130719890, 28, 15.410999) (1575130720890, 29, 12.785076) (1575130721890, 28, 15.305857) (1575130722890, 33, 12.820810) (1575130723890, 34, 13.618055) (1575130724890, 32, 12.971123) (1575130725890, 24, 10.974546) (1575130726890, 15, 10.742910) (1575130727890, 23, 16.810783) (1575130728890, 18, 13.115224) (1575130729890, 26, 17.418489) (1575130730890, 20, 17.302315) (1575130731890, 21, 14.283571) (1575130732890, 16, 16.826534) (1575130733890, 18, 19.222122) (1575130734890, 18, 14.931420) (1575130735890, 17, 19.549454) (1575130736890, 22, 16.908388) (1575130737890, 32, 15.637796) (1575130738890, 31, 15.517650) (1575130739890, 18, 14.038033) (1575130740890, 32, 19.859648) (1575130741890, 16, 13.220840) (1575130742890, 28, 16.445398) (1575130743890, 26, 16.695753) (1575130744890, 33, 13.696928) (1575130745890, 21, 15.352819) (1575130746890, 15, 12.388407) (1575130747890, 27, 11.267529) (1575130748890, 20, 14.103228) (1575130749890, 20, 16.250950) (1575130750890, 30, 16.236088) (1575130751890, 22, 18.305340) (1575130752890, 25, 17.360685) (1575130753890, 25, 14.978681) (1575130754890, 33, 14.096183) (1575130755890, 26, 10.019039) (1575130756890, 19, 19.158213) (1575130757890, 22, 15.593924) (1575130758890, 26, 18.780119) (1575130759890, 21, 16.001656) (1575130760890, 16, 18.458328) (1575130761890, 21, 16.417843) (1575130762890, 28, 11.736558) (1575130763890, 34, 18.143946) (1575130764890, 27, 10.303225) (1575130765890, 20, 19.756748) (1575130766890, 22, 12.940063) (1575130767890, 23, 11.509640) (1575130768890, 19, 18.319309) (1575130769890, 19, 16.278345) (1575130770890, 27, 10.898361) (1575130771890, 31, 13.922162) (1575130772890, 15, 19.296116) (1575130773890, 26, 15.885763) (1575130774890, 15, 15.525804) (1575130775890, 19, 19.579538) (1575130776890, 20, 11.073811) (1575130777890, 16, 13.932510) (1575130778890, 17, 11.900328) (1575130779890, 22, 16.540415) (1575130780890, 33, 15.203803) (1575130781890, 17, 11.518434) (1575130782890, 17, 13.152081) (1575130783890, 18, 11.378041) (1575130784890, 21, 15.390745) (1575130785890, 30, 15.127818) (1575130786890, 19, 16.530401) (1575130787890, 32, 16.542702) (1575130788890, 26, 16.366442) (1575130789890, 25, 10.306822) (1575130790890, 15, 13.691117) (1575130791890, 15, 13.476817) (1575130792890, 25, 12.529998) (1575130793890, 22, 15.550021) (1575130794890, 20, 15.064971) (1575130795890, 24, 13.313683) (1575130796890, 23, 17.002878) (1575130797890, 30, 19.991594) (1575130798890, 15, 11.116746) (1575130799880, 16, 19.405090) (1575130800880, 22, 14.377142) (1575130801880, 16, 16.868231) (1575130802880, 20, 11.565193) (1575130803880, 31, 13.009119) (1575130804880, 29, 18.136400) (1575130805880, 17, 13.806572) (1575130806880, 23, 14.688898) (1575130807880, 26, 12.931019) (1575130808880, 32, 12.185531) (1575130809880, 30, 13.608714) (1575130810880, 23, 18.624914) (1575130811880, 22, 12.970826) (1575130812880, 22, 12.065827) (1575130813880, 25, 16.967192) (1575130814880, 16, 10.283031) (1575130815880, 22, 16.072535) (1575130816880, 24, 10.794536) (1575130817880, 32, 10.591207) (1575130818880, 20, 13.015227) (1575130819880, 28, 15.410999) (1575130820880, 29, 12.785076) (1575130821880, 28, 15.305857) (1575130822880, 33, 12.820810) (1575130823880, 34, 13.618055) (1575130824880, 32, 12.971123) (1575130825880, 24, 10.974546) (1575130826880, 15, 10.742910) (1575130827880, 23, 16.810783) (1575130828880, 18, 13.115224) (1575130829880, 26, 17.418489) (1575130830880, 20, 17.302315) (1575130831880, 21, 14.283571) (1575130832880, 16, 16.826534) (1575130833880, 18, 19.222122) (1575130834880, 18, 14.931420) (1575130835880, 17, 19.549454) (1575130836880, 22, 16.908388) (1575130837880, 32, 15.637796) (1575130838880, 31, 15.517650) (1575130839880, 18, 14.038033) (1575130840880, 32, 19.859648) (1575130841880, 16, 13.220840) (1575130842880, 28, 16.445398) (1575130843880, 26, 16.695753) (1575130844880, 33, 13.696928) (1575130845880, 21, 15.352819) (1575130846880, 15, 12.388407) (1575130847880, 27, 11.267529) (1575130848880, 20, 14.103228) (1575130849880, 20, 16.250950) (1575130850880, 30, 16.236088) (1575130851880, 22, 18.305340) (1575130852880, 25, 17.360685) (1575130853880, 25, 14.978681) (1575130854880, 33, 14.096183) (1575130855880, 26, 10.019039) (1575130856880, 19, 19.158213) (1575130857880, 22, 15.593924) (1575130858880, 26, 18.780119) (1575130859880, 21, 16.001656) (1575130860880, 16, 18.458328) (1575130861880, 21, 16.417843) (1575130862880, 28, 11.736558) (1575130863880, 34, 18.143946) (1575130864880, 27, 10.303225) (1575130865880, 20, 19.756748) (1575130866880, 22, 12.940063) (1575130867880, 23, 11.509640) (1575130868880, 19, 18.319309) (1575130869880, 19, 16.278345) (1575130870880, 27, 10.898361) (1575130871880, 31, 13.922162) (1575130872880, 15, 19.296116) (1575130873880, 26, 15.885763) (1575130874880, 15, 15.525804) (1575130875880, 19, 19.579538) (1575130876880, 20, 11.073811) (1575130877880, 16, 13.932510) (1575130878880, 17, 11.900328) (1575130879880, 22, 16.540415) (1575130880880, 33, 15.203803) (1575130881880, 17, 11.518434) (1575130882880, 17, 13.152081) (1575130883880, 18, 11.378041) (1575130884880, 21, 15.390745) (1575130885880, 30, 15.127818) (1575130886880, 19, 16.530401) (1575130887880, 32, 16.542702) (1575130888880, 26, 16.366442) (1575130889880, 25, 10.306822) (1575130890880, 15, 13.691117) (1575130891880, 15, 13.476817) (1575130892880, 25, 12.529998) (1575130893880, 22, 15.550021) (1575130894880, 20, 15.064971) (1575130895880, 24, 13.313683) (1575130896880, 23, 17.002878) (1575130897880, 30, 19.991594) (1575130898880, 15, 11.116746) (1575130899870, 16, 19.405090) (1575130900870, 22, 14.377142) (1575130901870, 16, 16.868231) (1575130902870, 20, 11.565193) (1575130903870, 31, 13.009119) (1575130904870, 29, 18.136400) (1575130905870, 17, 13.806572) (1575130906870, 23, 14.688898) (1575130907870, 26, 12.931019) (1575130908870, 32, 12.185531) (1575130909870, 30, 13.608714) (1575130910870, 23, 18.624914) (1575130911870, 22, 12.970826) (1575130912870, 22, 12.065827) (1575130913870, 25, 16.967192) (1575130914870, 16, 10.283031) (1575130915870, 22, 16.072535) (1575130916870, 24, 10.794536) (1575130917870, 32, 10.591207) (1575130918870, 20, 13.015227) (1575130919870, 28, 15.410999) (1575130920870, 29, 12.785076) (1575130921870, 28, 15.305857) (1575130922870, 33, 12.820810) (1575130923870, 34, 13.618055) (1575130924870, 32, 12.971123) (1575130925870, 24, 10.974546) (1575130926870, 15, 10.742910) (1575130927870, 23, 16.810783) (1575130928870, 18, 13.115224) (1575130929870, 26, 17.418489) (1575130930870, 20, 17.302315) (1575130931870, 21, 14.283571) (1575130932870, 16, 16.826534) (1575130933870, 18, 19.222122) (1575130934870, 18, 14.931420) (1575130935870, 17, 19.549454) (1575130936870, 22, 16.908388) (1575130937870, 32, 15.637796) (1575130938870, 31, 15.517650) (1575130939870, 18, 14.038033) (1575130940870, 32, 19.859648) (1575130941870, 16, 13.220840) (1575130942870, 28, 16.445398) (1575130943870, 26, 16.695753) (1575130944870, 33, 13.696928) (1575130945870, 21, 15.352819) (1575130946870, 15, 12.388407) (1575130947870, 27, 11.267529) (1575130948870, 20, 14.103228) (1575130949870, 20, 16.250950) (1575130950870, 30, 16.236088) (1575130951870, 22, 18.305340) (1575130952870, 25, 17.360685) (1575130953870, 25, 14.978681) (1575130954870, 33, 14.096183) (1575130955870, 26, 10.019039) (1575130956870, 19, 19.158213) (1575130957870, 22, 15.593924) (1575130958870, 26, 18.780119) (1575130959870, 21, 16.001656) (1575130960870, 16, 18.458328) (1575130961870, 21, 16.417843) (1575130962870, 28, 11.736558) (1575130963870, 34, 18.143946) (1575130964870, 27, 10.303225) (1575130965870, 20, 19.756748) (1575130966870, 22, 12.940063) (1575130967870, 23, 11.509640) (1575130968870, 19, 18.319309) (1575130969870, 19, 16.278345) (1575130970870, 27, 10.898361) (1575130971870, 31, 13.922162) (1575130972870, 15, 19.296116) (1575130973870, 26, 15.885763) (1575130974870, 15, 15.525804) (1575130975870, 19, 19.579538) (1575130976870, 20, 11.073811) (1575130977870, 16, 13.932510) (1575130978870, 17, 11.900328) (1575130979870, 22, 16.540415) (1575130980870, 33, 15.203803) (1575130981870, 17, 11.518434) (1575130982870, 17, 13.152081) (1575130983870, 18, 11.378041) (1575130984870, 21, 15.390745) (1575130985870, 30, 15.127818) (1575130986870, 19, 16.530401) (1575130987870, 32, 16.542702) (1575130988870, 26, 16.366442) (1575130989870, 25, 10.306822) (1575130990870, 15, 13.691117) (1575130991870, 15, 13.476817) (1575130992870, 25, 12.529998) (1575130993870, 22, 15.550021) (1575130994870, 20, 15.064971) (1575130995870, 24, 13.313683) (1575130996870, 23, 17.002878) (1575130997870, 30, 19.991594) (1575130998870, 15, 11.116746) (1575130999860, 16, 19.405090) (1575131000860, 22, 14.377142) (1575131001860, 16, 16.868231) (1575131002860, 20, 11.565193) (1575131003860, 31, 13.009119) (1575131004860, 29, 18.136400) (1575131005860, 17, 13.806572) (1575131006860, 23, 14.688898) (1575131007860, 26, 12.931019) (1575131008860, 32, 12.185531) (1575131009860, 30, 13.608714) (1575131010860, 23, 18.624914) (1575131011860, 22, 12.970826) (1575131012860, 22, 12.065827) (1575131013860, 25, 16.967192) (1575131014860, 16, 10.283031) (1575131015860, 22, 16.072535) (1575131016860, 24, 10.794536) (1575131017860, 32, 10.591207) (1575131018860, 20, 13.015227) (1575131019860, 28, 15.410999) (1575131020860, 29, 12.785076) (1575131021860, 28, 15.305857) (1575131022860, 33, 12.820810) (1575131023860, 34, 13.618055) (1575131024860, 32, 12.971123) (1575131025860, 24, 10.974546) (1575131026860, 15, 10.742910) (1575131027860, 23, 16.810783) (1575131028860, 18, 13.115224) (1575131029860, 26, 17.418489) (1575131030860, 20, 17.302315) (1575131031860, 21, 14.283571) (1575131032860, 16, 16.826534) (1575131033860, 18, 19.222122) (1575131034860, 18, 14.931420) (1575131035860, 17, 19.549454) (1575131036860, 22, 16.908388) (1575131037860, 32, 15.637796) (1575131038860, 31, 15.517650) (1575131039860, 18, 14.038033) (1575131040860, 32, 19.859648) (1575131041860, 16, 13.220840) (1575131042860, 28, 16.445398) (1575131043860, 26, 16.695753) (1575131044860, 33, 13.696928) (1575131045860, 21, 15.352819) (1575131046860, 15, 12.388407) (1575131047860, 27, 11.267529) (1575131048860, 20, 14.103228) (1575131049860, 20, 16.250950) (1575131050860, 30, 16.236088) (1575131051860, 22, 18.305340) (1575131052860, 25, 17.360685) (1575131053860, 25, 14.978681) (1575131054860, 33, 14.096183) (1575131055860, 26, 10.019039) (1575131056860, 19, 19.158213) (1575131057860, 22, 15.593924) (1575131058860, 26, 18.780119) (1575131059860, 21, 16.001656) (1575131060860, 16, 18.458328) (1575131061860, 21, 16.417843) (1575131062860, 28, 11.736558) (1575131063860, 34, 18.143946) (1575131064860, 27, 10.303225) (1575131065860, 20, 19.756748) (1575131066860, 22, 12.940063) (1575131067860, 23, 11.509640) (1575131068860, 19, 18.319309) (1575131069860, 19, 16.278345) (1575131070860, 27, 10.898361) (1575131071860, 31, 13.922162) (1575131072860, 15, 19.296116) (1575131073860, 26, 15.885763) (1575131074860, 15, 15.525804) (1575131075860, 19, 19.579538) (1575131076860, 20, 11.073811) (1575131077860, 16, 13.932510) (1575131078860, 17, 11.900328) (1575131079860, 22, 16.540415) (1575131080860, 33, 15.203803) (1575131081860, 17, 11.518434) (1575131082860, 17, 13.152081) (1575131083860, 18, 11.378041) (1575131084860, 21, 15.390745) (1575131085860, 30, 15.127818) (1575131086860, 19, 16.530401) (1575131087860, 32, 16.542702) (1575131088860, 26, 16.366442) (1575131089860, 25, 10.306822) (1575131090860, 15, 13.691117) (1575131091860, 15, 13.476817) (1575131092860, 25, 12.529998) (1575131093860, 22, 15.550021) (1575131094860, 20, 15.064971) (1575131095860, 24, 13.313683) (1575131096860, 23, 17.002878) (1575131097860, 30, 19.991594) (1575131098860, 15, 11.116746) (1575131099850, 16, 19.405090) (1575131100850, 22, 14.377142) (1575131101850, 16, 16.868231) (1575131102850, 20, 11.565193) (1575131103850, 31, 13.009119) (1575131104850, 29, 18.136400) (1575131105850, 17, 13.806572) (1575131106850, 23, 14.688898) (1575131107850, 26, 12.931019) (1575131108850, 32, 12.185531) (1575131109850, 30, 13.608714) (1575131110850, 23, 18.624914) (1575131111850, 22, 12.970826) (1575131112850, 22, 12.065827) (1575131113850, 25, 16.967192) (1575131114850, 16, 10.283031) (1575131115850, 22, 16.072535) (1575131116850, 24, 10.794536) (1575131117850, 32, 10.591207) (1575131118850, 20, 13.015227) (1575131119850, 28, 15.410999) (1575131120850, 29, 12.785076) (1575131121850, 28, 15.305857) (1575131122850, 33, 12.820810) (1575131123850, 34, 13.618055) (1575131124850, 32, 12.971123) (1575131125850, 24, 10.974546) (1575131126850, 15, 10.742910) (1575131127850, 23, 16.810783) (1575131128850, 18, 13.115224) (1575131129850, 26, 17.418489) (1575131130850, 20, 17.302315) (1575131131850, 21, 14.283571) (1575131132850, 16, 16.826534) (1575131133850, 18, 19.222122) (1575131134850, 18, 14.931420) (1575131135850, 17, 19.549454) (1575131136850, 22, 16.908388) (1575131137850, 32, 15.637796) (1575131138850, 31, 15.517650) (1575131139850, 18, 14.038033) (1575131140850, 32, 19.859648) (1575131141850, 16, 13.220840) (1575131142850, 28, 16.445398) (1575131143850, 26, 16.695753) (1575131144850, 33, 13.696928) (1575131145850, 21, 15.352819) (1575131146850, 15, 12.388407) (1575131147850, 27, 11.267529) (1575131148850, 20, 14.103228) (1575131149850, 20, 16.250950) (1575131150850, 30, 16.236088) (1575131151850, 22, 18.305340) (1575131152850, 25, 17.360685) (1575131153850, 25, 14.978681) (1575131154850, 33, 14.096183) (1575131155850, 26, 10.019039) (1575131156850, 19, 19.158213) (1575131157850, 22, 15.593924) (1575131158850, 26, 18.780119) (1575131159850, 21, 16.001656) (1575131160850, 16, 18.458328) (1575131161850, 21, 16.417843) (1575131162850, 28, 11.736558) (1575131163850, 34, 18.143946) (1575131164850, 27, 10.303225) (1575131165850, 20, 19.756748) (1575131166850, 22, 12.940063) (1575131167850, 23, 11.509640) (1575131168850, 19, 18.319309) (1575131169850, 19, 16.278345) (1575131170850, 27, 10.898361) (1575131171850, 31, 13.922162) (1575131172850, 15, 19.296116) (1575131173850, 26, 15.885763) (1575131174850, 15, 15.525804) (1575131175850, 19, 19.579538) (1575131176850, 20, 11.073811) (1575131177850, 16, 13.932510) (1575131178850, 17, 11.900328) (1575131179850, 22, 16.540415) (1575131180850, 33, 15.203803) (1575131181850, 17, 11.518434) (1575131182850, 17, 13.152081) (1575131183850, 18, 11.378041) (1575131184850, 21, 15.390745) (1575131185850, 30, 15.127818) (1575131186850, 19, 16.530401) (1575131187850, 32, 16.542702) (1575131188850, 26, 16.366442) (1575131189850, 25, 10.306822) (1575131190850, 15, 13.691117) (1575131191850, 15, 13.476817) (1575131192850, 25, 12.529998) (1575131193850, 22, 15.550021) (1575131194850, 20, 15.064971) (1575131195850, 24, 13.313683) (1575131196850, 23, 17.002878) (1575131197850, 30, 19.991594) (1575131198850, 15, 11.116746) (1575131199840, 16, 19.405090) (1575131200840, 22, 14.377142) (1575131201840, 16, 16.868231) (1575131202840, 20, 11.565193) (1575131203840, 31, 13.009119) (1575131204840, 29, 18.136400) (1575131205840, 17, 13.806572) (1575131206840, 23, 14.688898) (1575131207840, 26, 12.931019) (1575131208840, 32, 12.185531) (1575131209840, 30, 13.608714) (1575131210840, 23, 18.624914) (1575131211840, 22, 12.970826) (1575131212840, 22, 12.065827) (1575131213840, 25, 16.967192) (1575131214840, 16, 10.283031) (1575131215840, 22, 16.072535) (1575131216840, 24, 10.794536) (1575131217840, 32, 10.591207) (1575131218840, 20, 13.015227) (1575131219840, 28, 15.410999) (1575131220840, 29, 12.785076) (1575131221840, 28, 15.305857) (1575131222840, 33, 12.820810) (1575131223840, 34, 13.618055) (1575131224840, 32, 12.971123) (1575131225840, 24, 10.974546) (1575131226840, 15, 10.742910) (1575131227840, 23, 16.810783) (1575131228840, 18, 13.115224) (1575131229840, 26, 17.418489) (1575131230840, 20, 17.302315) (1575131231840, 21, 14.283571) (1575131232840, 16, 16.826534) (1575131233840, 18, 19.222122) (1575131234840, 18, 14.931420) (1575131235840, 17, 19.549454) (1575131236840, 22, 16.908388) (1575131237840, 32, 15.637796) (1575131238840, 31, 15.517650) (1575131239840, 18, 14.038033) (1575131240840, 32, 19.859648) (1575131241840, 16, 13.220840) (1575131242840, 28, 16.445398) (1575131243840, 26, 16.695753) (1575131244840, 33, 13.696928) (1575131245840, 21, 15.352819) (1575131246840, 15, 12.388407) (1575131247840, 27, 11.267529) (1575131248840, 20, 14.103228) (1575131249840, 20, 16.250950) (1575131250840, 30, 16.236088) (1575131251840, 22, 18.305340) (1575131252840, 25, 17.360685) (1575131253840, 25, 14.978681) (1575131254840, 33, 14.096183) (1575131255840, 26, 10.019039) (1575131256840, 19, 19.158213) (1575131257840, 22, 15.593924) (1575131258840, 26, 18.780119) (1575131259840, 21, 16.001656) (1575131260840, 16, 18.458328) (1575131261840, 21, 16.417843) (1575131262840, 28, 11.736558) (1575131263840, 34, 18.143946) (1575131264840, 27, 10.303225) (1575131265840, 20, 19.756748) (1575131266840, 22, 12.940063) (1575131267840, 23, 11.509640) (1575131268840, 19, 18.319309) (1575131269840, 19, 16.278345) (1575131270840, 27, 10.898361) (1575131271840, 31, 13.922162) (1575131272840, 15, 19.296116) (1575131273840, 26, 15.885763) (1575131274840, 15, 15.525804) (1575131275840, 19, 19.579538) (1575131276840, 20, 11.073811) (1575131277840, 16, 13.932510) (1575131278840, 17, 11.900328) (1575131279840, 22, 16.540415) (1575131280840, 33, 15.203803) (1575131281840, 17, 11.518434) (1575131282840, 17, 13.152081) (1575131283840, 18, 11.378041) (1575131284840, 21, 15.390745) (1575131285840, 30, 15.127818) (1575131286840, 19, 16.530401) (1575131287840, 32, 16.542702) (1575131288840, 26, 16.366442) (1575131289840, 25, 10.306822) (1575131290840, 15, 13.691117) (1575131291840, 15, 13.476817) (1575131292840, 25, 12.529998) (1575131293840, 22, 15.550021) (1575131294840, 20, 15.064971) (1575131295840, 24, 13.313683) (1575131296840, 23, 17.002878) (1575131297840, 30, 19.991594) (1575131298840, 15, 11.116746) (1575131299830, 16, 19.405090) (1575131300830, 22, 14.377142) (1575131301830, 16, 16.868231) (1575131302830, 20, 11.565193) (1575131303830, 31, 13.009119) (1575131304830, 29, 18.136400) (1575131305830, 17, 13.806572) (1575131306830, 23, 14.688898) (1575131307830, 26, 12.931019) (1575131308830, 32, 12.185531) (1575131309830, 30, 13.608714) (1575131310830, 23, 18.624914) (1575131311830, 22, 12.970826) (1575131312830, 22, 12.065827) (1575131313830, 25, 16.967192) (1575131314830, 16, 10.283031) (1575131315830, 22, 16.072535) (1575131316830, 24, 10.794536) (1575131317830, 32, 10.591207) (1575131318830, 20, 13.015227) (1575131319830, 28, 15.410999) (1575131320830, 29, 12.785076) (1575131321830, 28, 15.305857) (1575131322830, 33, 12.820810) (1575131323830, 34, 13.618055) (1575131324830, 32, 12.971123) (1575131325830, 24, 10.974546) (1575131326830, 15, 10.742910) (1575131327830, 23, 16.810783) (1575131328830, 18, 13.115224) (1575131329830, 26, 17.418489) (1575131330830, 20, 17.302315) (1575131331830, 21, 14.283571) (1575131332830, 16, 16.826534) (1575131333830, 18, 19.222122) (1575131334830, 18, 14.931420) (1575131335830, 17, 19.549454) (1575131336830, 22, 16.908388) (1575131337830, 32, 15.637796) (1575131338830, 31, 15.517650) (1575131339830, 18, 14.038033) (1575131340830, 32, 19.859648) (1575131341830, 16, 13.220840) (1575131342830, 28, 16.445398) (1575131343830, 26, 16.695753) (1575131344830, 33, 13.696928) (1575131345830, 21, 15.352819) (1575131346830, 15, 12.388407) (1575131347830, 27, 11.267529) (1575131348830, 20, 14.103228) (1575131349830, 20, 16.250950) (1575131350830, 30, 16.236088) (1575131351830, 22, 18.305340) (1575131352830, 25, 17.360685) (1575131353830, 25, 14.978681) (1575131354830, 33, 14.096183) (1575131355830, 26, 10.019039) (1575131356830, 19, 19.158213) (1575131357830, 22, 15.593924) (1575131358830, 26, 18.780119) (1575131359830, 21, 16.001656) (1575131360830, 16, 18.458328) (1575131361830, 21, 16.417843) (1575131362830, 28, 11.736558) (1575131363830, 34, 18.143946) (1575131364830, 27, 10.303225) (1575131365830, 20, 19.756748) (1575131366830, 22, 12.940063) (1575131367830, 23, 11.509640) (1575131368830, 19, 18.319309) (1575131369830, 19, 16.278345) (1575131370830, 27, 10.898361) (1575131371830, 31, 13.922162) (1575131372830, 15, 19.296116) (1575131373830, 26, 15.885763) (1575131374830, 15, 15.525804) (1575131375830, 19, 19.579538) (1575131376830, 20, 11.073811) (1575131377830, 16, 13.932510) (1575131378830, 17, 11.900328) (1575131379830, 22, 16.540415) (1575131380830, 33, 15.203803) (1575131381830, 17, 11.518434) (1575131382830, 17, 13.152081) (1575131383830, 18, 11.378041) (1575131384830, 21, 15.390745) (1575131385830, 30, 15.127818) (1575131386830, 19, 16.530401) (1575131387830, 32, 16.542702) (1575131388830, 26, 16.366442) (1575131389830, 25, 10.306822) (1575131390830, 15, 13.691117) (1575131391830, 15, 13.476817) (1575131392830, 25, 12.529998) (1575131393830, 22, 15.550021) (1575131394830, 20, 15.064971) (1575131395830, 24, 13.313683) (1575131396830, 23, 17.002878) (1575131397830, 30, 19.991594) (1575131398830, 15, 11.116746) (1575131399820, 16, 19.405090) (1575131400820, 22, 14.377142) (1575131401820, 16, 16.868231) (1575131402820, 20, 11.565193) (1575131403820, 31, 13.009119) (1575131404820, 29, 18.136400) (1575131405820, 17, 13.806572) (1575131406820, 23, 14.688898) (1575131407820, 26, 12.931019) (1575131408820, 32, 12.185531) (1575131409820, 30, 13.608714) (1575131410820, 23, 18.624914) (1575131411820, 22, 12.970826) (1575131412820, 22, 12.065827) (1575131413820, 25, 16.967192) (1575131414820, 16, 10.283031) (1575131415820, 22, 16.072535) (1575131416820, 24, 10.794536) (1575131417820, 32, 10.591207) (1575131418820, 20, 13.015227) (1575131419820, 28, 15.410999) (1575131420820, 29, 12.785076) (1575131421820, 28, 15.305857) (1575131422820, 33, 12.820810) (1575131423820, 34, 13.618055) (1575131424820, 32, 12.971123) (1575131425820, 24, 10.974546) (1575131426820, 15, 10.742910) (1575131427820, 23, 16.810783) (1575131428820, 18, 13.115224) (1575131429820, 26, 17.418489) (1575131430820, 20, 17.302315) (1575131431820, 21, 14.283571) (1575131432820, 16, 16.826534) (1575131433820, 18, 19.222122) (1575131434820, 18, 14.931420) (1575131435820, 17, 19.549454) (1575131436820, 22, 16.908388) (1575131437820, 32, 15.637796) (1575131438820, 31, 15.517650) (1575131439820, 18, 14.038033) (1575131440820, 32, 19.859648) (1575131441820, 16, 13.220840) (1575131442820, 28, 16.445398) (1575131443820, 26, 16.695753) (1575131444820, 33, 13.696928) (1575131445820, 21, 15.352819) (1575131446820, 15, 12.388407) (1575131447820, 27, 11.267529) (1575131448820, 20, 14.103228) (1575131449820, 20, 16.250950) (1575131450820, 30, 16.236088) (1575131451820, 22, 18.305340) (1575131452820, 25, 17.360685) (1575131453820, 25, 14.978681) (1575131454820, 33, 14.096183) (1575131455820, 26, 10.019039) (1575131456820, 19, 19.158213) (1575131457820, 22, 15.593924) (1575131458820, 26, 18.780119) (1575131459820, 21, 16.001656) (1575131460820, 16, 18.458328) (1575131461820, 21, 16.417843) (1575131462820, 28, 11.736558) (1575131463820, 34, 18.143946) (1575131464820, 27, 10.303225) (1575131465820, 20, 19.756748) (1575131466820, 22, 12.940063) (1575131467820, 23, 11.509640) (1575131468820, 19, 18.319309) (1575131469820, 19, 16.278345) (1575131470820, 27, 10.898361) (1575131471820, 31, 13.922162) (1575131472820, 15, 19.296116) (1575131473820, 26, 15.885763) (1575131474820, 15, 15.525804) (1575131475820, 19, 19.579538) (1575131476820, 20, 11.073811) (1575131477820, 16, 13.932510) (1575131478820, 17, 11.900328) (1575131479820, 22, 16.540415) (1575131480820, 33, 15.203803) (1575131481820, 17, 11.518434) (1575131482820, 17, 13.152081) (1575131483820, 18, 11.378041) (1575131484820, 21, 15.390745) (1575131485820, 30, 15.127818) (1575131486820, 19, 16.530401) (1575131487820, 32, 16.542702) (1575131488820, 26, 16.366442) (1575131489820, 25, 10.306822) (1575131490820, 15, 13.691117) (1575131491820, 15, 13.476817) (1575131492820, 25, 12.529998) (1575131493820, 22, 15.550021) (1575131494820, 20, 15.064971) (1575131495820, 24, 13.313683) (1575131496820, 23, 17.002878) (1575131497820, 30, 19.991594) (1575131498820, 15, 11.116746) (1575131499810, 16, 19.405090) (1575131500810, 22, 14.377142) (1575131501810, 16, 16.868231) (1575131502810, 20, 11.565193) (1575131503810, 31, 13.009119) (1575131504810, 29, 18.136400) (1575131505810, 17, 13.806572) (1575131506810, 23, 14.688898) (1575131507810, 26, 12.931019) (1575131508810, 32, 12.185531) (1575131509810, 30, 13.608714) (1575131510810, 23, 18.624914) (1575131511810, 22, 12.970826) (1575131512810, 22, 12.065827) (1575131513810, 25, 16.967192) (1575131514810, 16, 10.283031) (1575131515810, 22, 16.072535) (1575131516810, 24, 10.794536) (1575131517810, 32, 10.591207) (1575131518810, 20, 13.015227) (1575131519810, 28, 15.410999) (1575131520810, 29, 12.785076) (1575131521810, 28, 15.305857) (1575131522810, 33, 12.820810) (1575131523810, 34, 13.618055) (1575131524810, 32, 12.971123) (1575131525810, 24, 10.974546) (1575131526810, 15, 10.742910) (1575131527810, 23, 16.810783) (1575131528810, 18, 13.115224) (1575131529810, 26, 17.418489) (1575131530810, 20, 17.302315) (1575131531810, 21, 14.283571) (1575131532810, 16, 16.826534) (1575131533810, 18, 19.222122) (1575131534810, 18, 14.931420) (1575131535810, 17, 19.549454) (1575131536810, 22, 16.908388) (1575131537810, 32, 15.637796) (1575131538810, 31, 15.517650) (1575131539810, 18, 14.038033) (1575131540810, 32, 19.859648) (1575131541810, 16, 13.220840) (1575131542810, 28, 16.445398) (1575131543810, 26, 16.695753) (1575131544810, 33, 13.696928) (1575131545810, 21, 15.352819) (1575131546810, 15, 12.388407) (1575131547810, 27, 11.267529) (1575131548810, 20, 14.103228) (1575131549810, 20, 16.250950) (1575131550810, 30, 16.236088) (1575131551810, 22, 18.305340) (1575131552810, 25, 17.360685) (1575131553810, 25, 14.978681) (1575131554810, 33, 14.096183) (1575131555810, 26, 10.019039) (1575131556810, 19, 19.158213) (1575131557810, 22, 15.593924) (1575131558810, 26, 18.780119) (1575131559810, 21, 16.001656) (1575131560810, 16, 18.458328) (1575131561810, 21, 16.417843) (1575131562810, 28, 11.736558) (1575131563810, 34, 18.143946) (1575131564810, 27, 10.303225) (1575131565810, 20, 19.756748) (1575131566810, 22, 12.940063) (1575131567810, 23, 11.509640) (1575131568810, 19, 18.319309) (1575131569810, 19, 16.278345) (1575131570810, 27, 10.898361) (1575131571810, 31, 13.922162) (1575131572810, 15, 19.296116) (1575131573810, 26, 15.885763) (1575131574810, 15, 15.525804) (1575131575810, 19, 19.579538) (1575131576810, 20, 11.073811) (1575131577810, 16, 13.932510) (1575131578810, 17, 11.900328) (1575131579810, 22, 16.540415) (1575131580810, 33, 15.203803) (1575131581810, 17, 11.518434) (1575131582810, 17, 13.152081) (1575131583810, 18, 11.378041) (1575131584810, 21, 15.390745) (1575131585810, 30, 15.127818) (1575131586810, 19, 16.530401) (1575131587810, 32, 16.542702) (1575131588810, 26, 16.366442) (1575131589810, 25, 10.306822) (1575131590810, 15, 13.691117) (1575131591810, 15, 13.476817) (1575131592810, 25, 12.529998) (1575131593810, 22, 15.550021) (1575131594810, 20, 15.064971) (1575131595810, 24, 13.313683) (1575131596810, 23, 17.002878) (1575131597810, 30, 19.991594) (1575131598810, 15, 11.116746) (1575131599800, 16, 19.405090) (1575131600800, 22, 14.377142) (1575131601800, 16, 16.868231) (1575131602800, 20, 11.565193) (1575131603800, 31, 13.009119) (1575131604800, 29, 18.136400) (1575131605800, 17, 13.806572) (1575131606800, 23, 14.688898) (1575131607800, 26, 12.931019) (1575131608800, 32, 12.185531) (1575131609800, 30, 13.608714) (1575131610800, 23, 18.624914) (1575131611800, 22, 12.970826) (1575131612800, 22, 12.065827) (1575131613800, 25, 16.967192) (1575131614800, 16, 10.283031) (1575131615800, 22, 16.072535) (1575131616800, 24, 10.794536) (1575131617800, 32, 10.591207) (1575131618800, 20, 13.015227) (1575131619800, 28, 15.410999) (1575131620800, 29, 12.785076) (1575131621800, 28, 15.305857) (1575131622800, 33, 12.820810) (1575131623800, 34, 13.618055) (1575131624800, 32, 12.971123) (1575131625800, 24, 10.974546) (1575131626800, 15, 10.742910) (1575131627800, 23, 16.810783) (1575131628800, 18, 13.115224) (1575131629800, 26, 17.418489) (1575131630800, 20, 17.302315) (1575131631800, 21, 14.283571) (1575131632800, 16, 16.826534) (1575131633800, 18, 19.222122) (1575131634800, 18, 14.931420) (1575131635800, 17, 19.549454) (1575131636800, 22, 16.908388) (1575131637800, 32, 15.637796) (1575131638800, 31, 15.517650) (1575131639800, 18, 14.038033) (1575131640800, 32, 19.859648) (1575131641800, 16, 13.220840) (1575131642800, 28, 16.445398) (1575131643800, 26, 16.695753) (1575131644800, 33, 13.696928) (1575131645800, 21, 15.352819) (1575131646800, 15, 12.388407) (1575131647800, 27, 11.267529) (1575131648800, 20, 14.103228) (1575131649800, 20, 16.250950) (1575131650800, 30, 16.236088) (1575131651800, 22, 18.305340) (1575131652800, 25, 17.360685) (1575131653800, 25, 14.978681) (1575131654800, 33, 14.096183) (1575131655800, 26, 10.019039) (1575131656800, 19, 19.158213) (1575131657800, 22, 15.593924) (1575131658800, 26, 18.780119) (1575131659800, 21, 16.001656) (1575131660800, 16, 18.458328) (1575131661800, 21, 16.417843) (1575131662800, 28, 11.736558) (1575131663800, 34, 18.143946) (1575131664800, 27, 10.303225) (1575131665800, 20, 19.756748) (1575131666800, 22, 12.940063) (1575131667800, 23, 11.509640) (1575131668800, 19, 18.319309) (1575131669800, 19, 16.278345) (1575131670800, 27, 10.898361) (1575131671800, 31, 13.922162) (1575131672800, 15, 19.296116) (1575131673800, 26, 15.885763) (1575131674800, 15, 15.525804) (1575131675800, 19, 19.579538) (1575131676800, 20, 11.073811) (1575131677800, 16, 13.932510) (1575131678800, 17, 11.900328) (1575131679800, 22, 16.540415) (1575131680800, 33, 15.203803) (1575131681800, 17, 11.518434) (1575131682800, 17, 13.152081) (1575131683800, 18, 11.378041) (1575131684800, 21, 15.390745) (1575131685800, 30, 15.127818) (1575131686800, 19, 16.530401) (1575131687800, 32, 16.542702) (1575131688800, 26, 16.366442) (1575131689800, 25, 10.306822) (1575131690800, 15, 13.691117) (1575131691800, 15, 13.476817) (1575131692800, 25, 12.529998) (1575131693800, 22, 15.550021)") + + end_time = int(round(time.time() * 1000)) + tdLog.info("Execute time with compress: %dms" % (end_time - start_time)) + + simLogPath = tdDnodes.getSimLogPath() + grepCmd = "grep -a 'compress rpc msg, before:' -r %s | head -2" % simLogPath + output = subprocess.check_output(grepCmd, shell=True).decode("utf-8") + + if output != "": + tdLog.info("Find %s in log file." % output) + tdLog.success("%s successfully executed! Compress works as expected." % __file__) + else: + tdLog.exit("%s failed! Compress does NOT works." % __file__) + + conn.close() diff --git a/tests/pytest/testMinTablesPerVnode.py b/tests/pytest/testMinTablesPerVnode.py new file mode 100644 index 0000000000000000000000000000000000000000..a111113c07224377962d5acff66c058dde5e8439 --- /dev/null +++ b/tests/pytest/testMinTablesPerVnode.py @@ -0,0 +1,131 @@ +#!/usr/bin/python +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### +# install pip +# pip install src/connector/python/ + +# -*- coding: utf-8 -*- +import sys +import getopt +import subprocess +from distutils.log import warn as printf + +from util.log import * +from util.dnodes import * +from util.cases import * +from util.sql import * + +import taos + + +if __name__ == "__main__": + fileName = "all" + deployPath = "" + testCluster = False + valgrind = 0 + logSql = True + stop = 0 + opts, args = getopt.gnu_getopt(sys.argv[1:], 'l:sgh', [ + 'logSql', 'stop', 'valgrind', 'help']) + for key, value in opts: + if key in ['-h', '--help']: + tdLog.printNoPrefix( + 'A collection of test cases written using Python') + tdLog.printNoPrefix('-l logSql Flag') + tdLog.printNoPrefix('-s stop All dnodes') + tdLog.printNoPrefix('-g valgrind Test Flag') + sys.exit(0) + + if key in ['-l', '--logSql']: + if (value.upper() == "TRUE"): + logSql = True + elif (value.upper() == "FALSE"): + logSql = False + else: + tdLog.printNoPrefix("logSql value %s is invalid" % logSql) + sys.exit(0) + + if key in ['-g', '--valgrind']: + valgrind = 1 + + if key in ['-s', '--stop']: + stop = 1 + + if (stop != 0): + if (valgrind == 0): + toBeKilled = "taosd" + else: + toBeKilled = "valgrind.bin" + + killCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs kill -HUP > /dev/null 2>&1" % toBeKilled + + psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled + processID = subprocess.check_output(psCmd, shell=True) + + while(processID): + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output(psCmd, shell=True) + + for port in range(6030, 6041): + usePortPID = "lsof -i tcp:%d | grep LISTEn | awk '{print $2}'" % port + processID = subprocess.check_output(usePortPID, shell=True) + + if processID: + killCmd = "kill -TERM %s" % processID + os.system(killCmd) + fuserCmd = "fuser -k -n tcp %d" % port + os.system(fuserCmd) + if valgrind: + time.sleep(2) + + tdLog.info('stop All dnodes') + sys.exit(0) + + tdDnodes.init(deployPath) + tdDnodes.setTestCluster(testCluster) + tdDnodes.setValgrind(valgrind) + + tdDnodes.stopAll() + tdDnodes.addSimExtraCfg("minTablesPerVnode", "100") + tdDnodes.deploy(1) + tdDnodes.start(1) + + host = '127.0.0.1' + + tdLog.info("Procedures for tdengine deployed in %s" % (host)) + + tdCases.logSql(logSql) + + conn = taos.connect( + host, + config=tdDnodes.getSimCfgPath()) + + tdSql.init(conn.cursor(), True) + + tdSql.execute("DROP DATABASE IF EXISTS db") + tdSql.execute("CREATE DATABASE IF NOT EXISTS db") + tdSql.execute("USE db") + + for i in range(0, 100): + tdSql.execute( + "CREATE TABLE IF NOT EXISTS tb%d (ts TIMESTAMP, temperature INT, humidity FLOAT)" % i) + + for i in range(1, 6): + tdSql.execute("INSERT INTO tb99 values (now + %da, %d, %f)" % (i, i, i * 1.0)) + + tdSql.execute("DROP TABLE tb99") + tdSql.execute( + "CREATE TABLE IF NOT EXISTS tb99 (ts TIMESTAMP, temperature INT, humidity FLOAT)") + tdSql.query("SELECT * FROM tb99") + tdSql.checkRows(0) + + conn.close() diff --git a/tests/pytest/testNoCompress.py b/tests/pytest/testNoCompress.py new file mode 100644 index 0000000000000000000000000000000000000000..d41055c755264fbc503df4709b8bd3eedaa11b07 --- /dev/null +++ b/tests/pytest/testNoCompress.py @@ -0,0 +1,137 @@ +#!/usr/bin/python +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### +# install pip +# pip install src/connector/python/ + +# -*- coding: utf-8 -*- +import sys +import getopt +import subprocess +from distutils.log import warn as printf + +from util.log import * +from util.dnodes import * +from util.cases import * +from util.sql import * + +import taos + + +if __name__ == "__main__": + fileName = "all" + deployPath = "" + masterIp = "" + testCluster = False + valgrind = 0 + logSql = True + stop = 0 + opts, args = getopt.gnu_getopt(sys.argv[1:], 'l:sgh', [ + 'file=', 'path=', 'master', 'logSql', 'stop', 'cluster', 'valgrind', 'help']) + for key, value in opts: + if key in ['-h', '--help']: + tdLog.printNoPrefix( + 'A collection of test cases written using Python') + tdLog.printNoPrefix('-l logSql Flag') + tdLog.printNoPrefix('-s stop All dnodes') + tdLog.printNoPrefix('-g valgrind Test Flag') + sys.exit(0) + + if key in ['-l', '--logSql']: + if (value.upper() == "TRUE"): + logSql = True + elif (value.upper() == "FALSE"): + logSql = False + else: + tdLog.printNoPrefix("logSql value %s is invalid" % logSql) + sys.exit(0) + + if key in ['-g', '--valgrind']: + valgrind = 1 + + if key in ['-s', '--stop']: + stop = 1 + + if (stop != 0): + if (valgrind == 0): + toBeKilled = "taosd" + else: + toBeKilled = "valgrind.bin" + + killCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs kill -HUP > /dev/null 2>&1" % toBeKilled + + psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled + processID = subprocess.check_output(psCmd, shell=True) + + while(processID): + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output(psCmd, shell=True) + + for port in range(6030, 6041): + usePortPID = "lsof -i tcp:%d | grep LISTEn | awk '{print $2}'" % port + processID = subprocess.check_output(usePortPID, shell=True) + + if processID: + killCmd = "kill -9 %s" % processID + os.system(killCmd) + fuserCmd = "fuser -k -n tcp %d" % port + os.system(fuserCmd) + if valgrind: + time.sleep(2) + + tdLog.info('stop All dnodes') + sys.exit(0) + + tdDnodes.init(deployPath) + tdDnodes.setTestCluster(testCluster) + tdDnodes.setValgrind(valgrind) + + tdDnodes.stopAll() + tdDnodes.addSimExtraCfg("compressMsgSize", "-1") + tdDnodes.deploy(1) + tdDnodes.start(1) + + host = '127.0.0.1' + + tdLog.info("Procedures for tdengine deployed in %s" % (host)) + + tdCases.logSql(logSql) + + conn = taos.connect( + host, + config=tdDnodes.getSimCfgPath()) + + tdSql.init(conn.cursor(), logSql) + + tdSql.execute("CREATE DATABASE IF NOT EXISTS t10b") + tdSql.execute("USE t10b") + tdSql.execute( + "CREATE TABLE IF NOT EXISTS s_sensor_info (ts TIMESTAMP, temperature INT, humidity FLOAT)") + + start_time = int(round(time.time() * 1000)) + for i in range(1, 1000): + tdSql.execute("IMPORT INTO s_sensor_info VALUES (1575129600000, 16, 19.405090) (1575129601000, 22, 14.377142) (1575129602000, 16, 16.868231) (1575129603000, 20, 11.565193) (1575129604000, 31, 13.009119) (1575129605000, 29, 18.136400) (1575129606000, 17, 13.806572) (1575129607000, 23, 14.688898) (1575129608000, 26, 12.931019) (1575129609000, 32, 12.185531) (1575129610000, 30, 13.608714) (1575129611000, 23, 18.624914) (1575129612000, 22, 12.970826) (1575129613000, 22, 12.065827) (1575129614000, 25, 16.967192) (1575129615000, 16, 10.283031) (1575129616000, 22, 16.072535) (1575129617000, 24, 10.794536) (1575129618000, 32, 10.591207) (1575129619000, 20, 13.015227) (1575129620000, 28, 15.410999) (1575129621000, 29, 12.785076) (1575129622000, 28, 15.305857) (1575129623000, 33, 12.820810) (1575129624000, 34, 13.618055) (1575129625000, 32, 12.971123) (1575129626000, 24, 10.974546) (1575129627000, 15, 10.742910) (1575129628000, 23, 16.810783) (1575129629000, 18, 13.115224) (1575129630000, 26, 17.418489) (1575129631000, 20, 17.302315) (1575129632000, 21, 14.283571) (1575129633000, 16, 16.826534) (1575129634000, 18, 19.222122) (1575129635000, 18, 14.931420) (1575129636000, 17, 19.549454) (1575129637000, 22, 16.908388) (1575129638000, 32, 15.637796) (1575129639000, 31, 15.517650) (1575129640000, 18, 14.038033) (1575129641000, 32, 19.859648) (1575129642000, 16, 13.220840) (1575129643000, 28, 16.445398) (1575129644000, 26, 16.695753) (1575129645000, 33, 13.696928) (1575129646000, 21, 15.352819) (1575129647000, 15, 12.388407) (1575129648000, 27, 11.267529) (1575129649000, 20, 14.103228) (1575129650000, 20, 16.250950) (1575129651000, 30, 16.236088) (1575129652000, 22, 18.305340) (1575129653000, 25, 17.360685) (1575129654000, 25, 14.978681) (1575129655000, 33, 14.096183) (1575129656000, 26, 10.019039) (1575129657000, 19, 19.158213) (1575129658000, 22, 15.593924) (1575129659000, 26, 18.780119) (1575129660000, 21, 16.001656) (1575129661000, 16, 18.458328) (1575129662000, 21, 16.417843) (1575129663000, 28, 11.736558) (1575129664000, 34, 18.143946) (1575129665000, 27, 10.303225) (1575129666000, 20, 19.756748) (1575129667000, 22, 12.940063) (1575129668000, 23, 11.509640) (1575129669000, 19, 18.319309) (1575129670000, 19, 16.278345) (1575129671000, 27, 10.898361) (1575129672000, 31, 13.922162) (1575129673000, 15, 19.296116) (1575129674000, 26, 15.885763) (1575129675000, 15, 15.525804) (1575129676000, 19, 19.579538) (1575129677000, 20, 11.073811) (1575129678000, 16, 13.932510) (1575129679000, 17, 11.900328) (1575129680000, 22, 16.540415) (1575129681000, 33, 15.203803) (1575129682000, 17, 11.518434) (1575129683000, 17, 13.152081) (1575129684000, 18, 11.378041) (1575129685000, 21, 15.390745) (1575129686000, 30, 15.127818) (1575129687000, 19, 16.530401) (1575129688000, 32, 16.542702) (1575129689000, 26, 16.366442) (1575129690000, 25, 10.306822) (1575129691000, 15, 13.691117) (1575129692000, 15, 13.476817) (1575129693000, 25, 12.529998) (1575129694000, 22, 15.550021) (1575129695000, 20, 15.064971) (1575129696000, 24, 13.313683) (1575129697000, 23, 17.002878) (1575129698000, 30, 19.991594) (1575129699000, 15, 11.116746) (1575129699990, 16, 19.405090) (1575129700990, 22, 14.377142) (1575129701990, 16, 16.868231) (1575129702990, 20, 11.565193) (1575129703990, 31, 13.009119) (1575129704990, 29, 18.136400) (1575129705990, 17, 13.806572) (1575129706990, 23, 14.688898) (1575129707990, 26, 12.931019) (1575129708990, 32, 12.185531) (1575129709990, 30, 13.608714) (1575129710990, 23, 18.624914) (1575129711990, 22, 12.970826) (1575129712990, 22, 12.065827) (1575129713990, 25, 16.967192) (1575129714990, 16, 10.283031) (1575129715990, 22, 16.072535) (1575129716990, 24, 10.794536) (1575129717990, 32, 10.591207) (1575129718990, 20, 13.015227) (1575129719990, 28, 15.410999) (1575129720990, 29, 12.785076) (1575129721990, 28, 15.305857) (1575129722990, 33, 12.820810) (1575129723990, 34, 13.618055) (1575129724990, 32, 12.971123) (1575129725990, 24, 10.974546) (1575129726990, 15, 10.742910) (1575129727990, 23, 16.810783) (1575129728990, 18, 13.115224) (1575129729990, 26, 17.418489) (1575129730990, 20, 17.302315) (1575129731990, 21, 14.283571) (1575129732990, 16, 16.826534) (1575129733990, 18, 19.222122) (1575129734990, 18, 14.931420) (1575129735990, 17, 19.549454) (1575129736990, 22, 16.908388) (1575129737990, 32, 15.637796) (1575129738990, 31, 15.517650) (1575129739990, 18, 14.038033) (1575129740990, 32, 19.859648) (1575129741990, 16, 13.220840) (1575129742990, 28, 16.445398) (1575129743990, 26, 16.695753) (1575129744990, 33, 13.696928) (1575129745990, 21, 15.352819) (1575129746990, 15, 12.388407) (1575129747990, 27, 11.267529) (1575129748990, 20, 14.103228) (1575129749990, 20, 16.250950) (1575129750990, 30, 16.236088) (1575129751990, 22, 18.305340) (1575129752990, 25, 17.360685) (1575129753990, 25, 14.978681) (1575129754990, 33, 14.096183) (1575129755990, 26, 10.019039) (1575129756990, 19, 19.158213) (1575129757990, 22, 15.593924) (1575129758990, 26, 18.780119) (1575129759990, 21, 16.001656) (1575129760990, 16, 18.458328) (1575129761990, 21, 16.417843) (1575129762990, 28, 11.736558) (1575129763990, 34, 18.143946) (1575129764990, 27, 10.303225) (1575129765990, 20, 19.756748) (1575129766990, 22, 12.940063) (1575129767990, 23, 11.509640) (1575129768990, 19, 18.319309) (1575129769990, 19, 16.278345) (1575129770990, 27, 10.898361) (1575129771990, 31, 13.922162) (1575129772990, 15, 19.296116) (1575129773990, 26, 15.885763) (1575129774990, 15, 15.525804) (1575129775990, 19, 19.579538) (1575129776990, 20, 11.073811) (1575129777990, 16, 13.932510) (1575129778990, 17, 11.900328) (1575129779990, 22, 16.540415) (1575129780990, 33, 15.203803) (1575129781990, 17, 11.518434) (1575129782990, 17, 13.152081) (1575129783990, 18, 11.378041) (1575129784990, 21, 15.390745) (1575129785990, 30, 15.127818) (1575129786990, 19, 16.530401) (1575129787990, 32, 16.542702) (1575129788990, 26, 16.366442) (1575129789990, 25, 10.306822) (1575129790990, 15, 13.691117) (1575129791990, 15, 13.476817) (1575129792990, 25, 12.529998) (1575129793990, 22, 15.550021) (1575129794990, 20, 15.064971) (1575129795990, 24, 13.313683) (1575129796990, 23, 17.002878) (1575129797990, 30, 19.991594) (1575129798990, 15, 11.116746) (1575129799980, 16, 19.405090) (1575129800980, 22, 14.377142) (1575129801980, 16, 16.868231) (1575129802980, 20, 11.565193) (1575129803980, 31, 13.009119) (1575129804980, 29, 18.136400) (1575129805980, 17, 13.806572) (1575129806980, 23, 14.688898) (1575129807980, 26, 12.931019) (1575129808980, 32, 12.185531) (1575129809980, 30, 13.608714) (1575129810980, 23, 18.624914) (1575129811980, 22, 12.970826) (1575129812980, 22, 12.065827) (1575129813980, 25, 16.967192) (1575129814980, 16, 10.283031) (1575129815980, 22, 16.072535) (1575129816980, 24, 10.794536) (1575129817980, 32, 10.591207) (1575129818980, 20, 13.015227) (1575129819980, 28, 15.410999) (1575129820980, 29, 12.785076) (1575129821980, 28, 15.305857) (1575129822980, 33, 12.820810) (1575129823980, 34, 13.618055) (1575129824980, 32, 12.971123) (1575129825980, 24, 10.974546) (1575129826980, 15, 10.742910) (1575129827980, 23, 16.810783) (1575129828980, 18, 13.115224) (1575129829980, 26, 17.418489) (1575129830980, 20, 17.302315) (1575129831980, 21, 14.283571) (1575129832980, 16, 16.826534) (1575129833980, 18, 19.222122) (1575129834980, 18, 14.931420) (1575129835980, 17, 19.549454) (1575129836980, 22, 16.908388) (1575129837980, 32, 15.637796) (1575129838980, 31, 15.517650) (1575129839980, 18, 14.038033) (1575129840980, 32, 19.859648) (1575129841980, 16, 13.220840) (1575129842980, 28, 16.445398) (1575129843980, 26, 16.695753) (1575129844980, 33, 13.696928) (1575129845980, 21, 15.352819) (1575129846980, 15, 12.388407) (1575129847980, 27, 11.267529) (1575129848980, 20, 14.103228) (1575129849980, 20, 16.250950) (1575129850980, 30, 16.236088) (1575129851980, 22, 18.305340) (1575129852980, 25, 17.360685) (1575129853980, 25, 14.978681) (1575129854980, 33, 14.096183) (1575129855980, 26, 10.019039) (1575129856980, 19, 19.158213) (1575129857980, 22, 15.593924) (1575129858980, 26, 18.780119) (1575129859980, 21, 16.001656) (1575129860980, 16, 18.458328) (1575129861980, 21, 16.417843) (1575129862980, 28, 11.736558) (1575129863980, 34, 18.143946) (1575129864980, 27, 10.303225) (1575129865980, 20, 19.756748) (1575129866980, 22, 12.940063) (1575129867980, 23, 11.509640) (1575129868980, 19, 18.319309) (1575129869980, 19, 16.278345) (1575129870980, 27, 10.898361) (1575129871980, 31, 13.922162) (1575129872980, 15, 19.296116) (1575129873980, 26, 15.885763) (1575129874980, 15, 15.525804) (1575129875980, 19, 19.579538) (1575129876980, 20, 11.073811) (1575129877980, 16, 13.932510) (1575129878980, 17, 11.900328) (1575129879980, 22, 16.540415) (1575129880980, 33, 15.203803) (1575129881980, 17, 11.518434) (1575129882980, 17, 13.152081) (1575129883980, 18, 11.378041) (1575129884980, 21, 15.390745) (1575129885980, 30, 15.127818) (1575129886980, 19, 16.530401) (1575129887980, 32, 16.542702) (1575129888980, 26, 16.366442) (1575129889980, 25, 10.306822) (1575129890980, 15, 13.691117) (1575129891980, 15, 13.476817) (1575129892980, 25, 12.529998) (1575129893980, 22, 15.550021) (1575129894980, 20, 15.064971) (1575129895980, 24, 13.313683) (1575129896980, 23, 17.002878) (1575129897980, 30, 19.991594) (1575129898980, 15, 11.116746) (1575129899970, 16, 19.405090) (1575129900970, 22, 14.377142) (1575129901970, 16, 16.868231) (1575129902970, 20, 11.565193) (1575129903970, 31, 13.009119) (1575129904970, 29, 18.136400) (1575129905970, 17, 13.806572) (1575129906970, 23, 14.688898) (1575129907970, 26, 12.931019) (1575129908970, 32, 12.185531) (1575129909970, 30, 13.608714) (1575129910970, 23, 18.624914) (1575129911970, 22, 12.970826) (1575129912970, 22, 12.065827) (1575129913970, 25, 16.967192) (1575129914970, 16, 10.283031) (1575129915970, 22, 16.072535) (1575129916970, 24, 10.794536) (1575129917970, 32, 10.591207) (1575129918970, 20, 13.015227) (1575129919970, 28, 15.410999) (1575129920970, 29, 12.785076) (1575129921970, 28, 15.305857) (1575129922970, 33, 12.820810) (1575129923970, 34, 13.618055) (1575129924970, 32, 12.971123) (1575129925970, 24, 10.974546) (1575129926970, 15, 10.742910) (1575129927970, 23, 16.810783) (1575129928970, 18, 13.115224) (1575129929970, 26, 17.418489) (1575129930970, 20, 17.302315) (1575129931970, 21, 14.283571) (1575129932970, 16, 16.826534) (1575129933970, 18, 19.222122) (1575129934970, 18, 14.931420) (1575129935970, 17, 19.549454) (1575129936970, 22, 16.908388) (1575129937970, 32, 15.637796) (1575129938970, 31, 15.517650) (1575129939970, 18, 14.038033) (1575129940970, 32, 19.859648) (1575129941970, 16, 13.220840) (1575129942970, 28, 16.445398) (1575129943970, 26, 16.695753) (1575129944970, 33, 13.696928) (1575129945970, 21, 15.352819) (1575129946970, 15, 12.388407) (1575129947970, 27, 11.267529) (1575129948970, 20, 14.103228) (1575129949970, 20, 16.250950) (1575129950970, 30, 16.236088) (1575129951970, 22, 18.305340) (1575129952970, 25, 17.360685) (1575129953970, 25, 14.978681) (1575129954970, 33, 14.096183) (1575129955970, 26, 10.019039) (1575129956970, 19, 19.158213) (1575129957970, 22, 15.593924) (1575129958970, 26, 18.780119) (1575129959970, 21, 16.001656) (1575129960970, 16, 18.458328) (1575129961970, 21, 16.417843) (1575129962970, 28, 11.736558) (1575129963970, 34, 18.143946) (1575129964970, 27, 10.303225) (1575129965970, 20, 19.756748) (1575129966970, 22, 12.940063) (1575129967970, 23, 11.509640) (1575129968970, 19, 18.319309) (1575129969970, 19, 16.278345) (1575129970970, 27, 10.898361) (1575129971970, 31, 13.922162) (1575129972970, 15, 19.296116) (1575129973970, 26, 15.885763) (1575129974970, 15, 15.525804) (1575129975970, 19, 19.579538) (1575129976970, 20, 11.073811) (1575129977970, 16, 13.932510) (1575129978970, 17, 11.900328) (1575129979970, 22, 16.540415) (1575129980970, 33, 15.203803) (1575129981970, 17, 11.518434) (1575129982970, 17, 13.152081) (1575129983970, 18, 11.378041) (1575129984970, 21, 15.390745) (1575129985970, 30, 15.127818) (1575129986970, 19, 16.530401) (1575129987970, 32, 16.542702) (1575129988970, 26, 16.366442) (1575129989970, 25, 10.306822) (1575129990970, 15, 13.691117) (1575129991970, 15, 13.476817) (1575129992970, 25, 12.529998) (1575129993970, 22, 15.550021) (1575129994970, 20, 15.064971) (1575129995970, 24, 13.313683) (1575129996970, 23, 17.002878) (1575129997970, 30, 19.991594) (1575129998970, 15, 11.116746) (1575129999960, 16, 19.405090) (1575130000960, 22, 14.377142) (1575130001960, 16, 16.868231) (1575130002960, 20, 11.565193) (1575130003960, 31, 13.009119) (1575130004960, 29, 18.136400) (1575130005960, 17, 13.806572) (1575130006960, 23, 14.688898) (1575130007960, 26, 12.931019) (1575130008960, 32, 12.185531) (1575130009960, 30, 13.608714) (1575130010960, 23, 18.624914) (1575130011960, 22, 12.970826) (1575130012960, 22, 12.065827) (1575130013960, 25, 16.967192) (1575130014960, 16, 10.283031) (1575130015960, 22, 16.072535) (1575130016960, 24, 10.794536) (1575130017960, 32, 10.591207) (1575130018960, 20, 13.015227) (1575130019960, 28, 15.410999) (1575130020960, 29, 12.785076) (1575130021960, 28, 15.305857) (1575130022960, 33, 12.820810) (1575130023960, 34, 13.618055) (1575130024960, 32, 12.971123) (1575130025960, 24, 10.974546) (1575130026960, 15, 10.742910) (1575130027960, 23, 16.810783) (1575130028960, 18, 13.115224) (1575130029960, 26, 17.418489) (1575130030960, 20, 17.302315) (1575130031960, 21, 14.283571) (1575130032960, 16, 16.826534) (1575130033960, 18, 19.222122) (1575130034960, 18, 14.931420) (1575130035960, 17, 19.549454) (1575130036960, 22, 16.908388) (1575130037960, 32, 15.637796) (1575130038960, 31, 15.517650) (1575130039960, 18, 14.038033) (1575130040960, 32, 19.859648) (1575130041960, 16, 13.220840) (1575130042960, 28, 16.445398) (1575130043960, 26, 16.695753) (1575130044960, 33, 13.696928) (1575130045960, 21, 15.352819) (1575130046960, 15, 12.388407) (1575130047960, 27, 11.267529) (1575130048960, 20, 14.103228) (1575130049960, 20, 16.250950) (1575130050960, 30, 16.236088) (1575130051960, 22, 18.305340) (1575130052960, 25, 17.360685) (1575130053960, 25, 14.978681) (1575130054960, 33, 14.096183) (1575130055960, 26, 10.019039) (1575130056960, 19, 19.158213) (1575130057960, 22, 15.593924) (1575130058960, 26, 18.780119) (1575130059960, 21, 16.001656) (1575130060960, 16, 18.458328) (1575130061960, 21, 16.417843) (1575130062960, 28, 11.736558) (1575130063960, 34, 18.143946) (1575130064960, 27, 10.303225) (1575130065960, 20, 19.756748) (1575130066960, 22, 12.940063) (1575130067960, 23, 11.509640) (1575130068960, 19, 18.319309) (1575130069960, 19, 16.278345) (1575130070960, 27, 10.898361) (1575130071960, 31, 13.922162) (1575130072960, 15, 19.296116) (1575130073960, 26, 15.885763) (1575130074960, 15, 15.525804) (1575130075960, 19, 19.579538) (1575130076960, 20, 11.073811) (1575130077960, 16, 13.932510) (1575130078960, 17, 11.900328) (1575130079960, 22, 16.540415) (1575130080960, 33, 15.203803) (1575130081960, 17, 11.518434) (1575130082960, 17, 13.152081) (1575130083960, 18, 11.378041) (1575130084960, 21, 15.390745) (1575130085960, 30, 15.127818) (1575130086960, 19, 16.530401) (1575130087960, 32, 16.542702) (1575130088960, 26, 16.366442) (1575130089960, 25, 10.306822) (1575130090960, 15, 13.691117) (1575130091960, 15, 13.476817) (1575130092960, 25, 12.529998) (1575130093960, 22, 15.550021) (1575130094960, 20, 15.064971) (1575130095960, 24, 13.313683) (1575130096960, 23, 17.002878) (1575130097960, 30, 19.991594) (1575130098960, 15, 11.116746) (1575130099950, 16, 19.405090) (1575130100950, 22, 14.377142) (1575130101950, 16, 16.868231) (1575130102950, 20, 11.565193) (1575130103950, 31, 13.009119) (1575130104950, 29, 18.136400) (1575130105950, 17, 13.806572) (1575130106950, 23, 14.688898) (1575130107950, 26, 12.931019) (1575130108950, 32, 12.185531) (1575130109950, 30, 13.608714) (1575130110950, 23, 18.624914) (1575130111950, 22, 12.970826) (1575130112950, 22, 12.065827) (1575130113950, 25, 16.967192) (1575130114950, 16, 10.283031) (1575130115950, 22, 16.072535) (1575130116950, 24, 10.794536) (1575130117950, 32, 10.591207) (1575130118950, 20, 13.015227) (1575130119950, 28, 15.410999) (1575130120950, 29, 12.785076) (1575130121950, 28, 15.305857) (1575130122950, 33, 12.820810) (1575130123950, 34, 13.618055) (1575130124950, 32, 12.971123) (1575130125950, 24, 10.974546) (1575130126950, 15, 10.742910) (1575130127950, 23, 16.810783) (1575130128950, 18, 13.115224) (1575130129950, 26, 17.418489) (1575130130950, 20, 17.302315) (1575130131950, 21, 14.283571) (1575130132950, 16, 16.826534) (1575130133950, 18, 19.222122) (1575130134950, 18, 14.931420) (1575130135950, 17, 19.549454) (1575130136950, 22, 16.908388) (1575130137950, 32, 15.637796) (1575130138950, 31, 15.517650) (1575130139950, 18, 14.038033) (1575130140950, 32, 19.859648) (1575130141950, 16, 13.220840) (1575130142950, 28, 16.445398) (1575130143950, 26, 16.695753) (1575130144950, 33, 13.696928) (1575130145950, 21, 15.352819) (1575130146950, 15, 12.388407) (1575130147950, 27, 11.267529) (1575130148950, 20, 14.103228) (1575130149950, 20, 16.250950) (1575130150950, 30, 16.236088) (1575130151950, 22, 18.305340) (1575130152950, 25, 17.360685) (1575130153950, 25, 14.978681) (1575130154950, 33, 14.096183) (1575130155950, 26, 10.019039) (1575130156950, 19, 19.158213) (1575130157950, 22, 15.593924) (1575130158950, 26, 18.780119) (1575130159950, 21, 16.001656) (1575130160950, 16, 18.458328) (1575130161950, 21, 16.417843) (1575130162950, 28, 11.736558) (1575130163950, 34, 18.143946) (1575130164950, 27, 10.303225) (1575130165950, 20, 19.756748) (1575130166950, 22, 12.940063) (1575130167950, 23, 11.509640) (1575130168950, 19, 18.319309) (1575130169950, 19, 16.278345) (1575130170950, 27, 10.898361) (1575130171950, 31, 13.922162) (1575130172950, 15, 19.296116) (1575130173950, 26, 15.885763) (1575130174950, 15, 15.525804) (1575130175950, 19, 19.579538) (1575130176950, 20, 11.073811) (1575130177950, 16, 13.932510) (1575130178950, 17, 11.900328) (1575130179950, 22, 16.540415) (1575130180950, 33, 15.203803) (1575130181950, 17, 11.518434) (1575130182950, 17, 13.152081) (1575130183950, 18, 11.378041) (1575130184950, 21, 15.390745) (1575130185950, 30, 15.127818) (1575130186950, 19, 16.530401) (1575130187950, 32, 16.542702) (1575130188950, 26, 16.366442) (1575130189950, 25, 10.306822) (1575130190950, 15, 13.691117) (1575130191950, 15, 13.476817) (1575130192950, 25, 12.529998) (1575130193950, 22, 15.550021) (1575130194950, 20, 15.064971) (1575130195950, 24, 13.313683) (1575130196950, 23, 17.002878) (1575130197950, 30, 19.991594) (1575130198950, 15, 11.116746) (1575130199940, 16, 19.405090) (1575130200940, 22, 14.377142) (1575130201940, 16, 16.868231) (1575130202940, 20, 11.565193) (1575130203940, 31, 13.009119) (1575130204940, 29, 18.136400) (1575130205940, 17, 13.806572) (1575130206940, 23, 14.688898) (1575130207940, 26, 12.931019) (1575130208940, 32, 12.185531) (1575130209940, 30, 13.608714) (1575130210940, 23, 18.624914) (1575130211940, 22, 12.970826) (1575130212940, 22, 12.065827) (1575130213940, 25, 16.967192) (1575130214940, 16, 10.283031) (1575130215940, 22, 16.072535) (1575130216940, 24, 10.794536) (1575130217940, 32, 10.591207) (1575130218940, 20, 13.015227) (1575130219940, 28, 15.410999) (1575130220940, 29, 12.785076) (1575130221940, 28, 15.305857) (1575130222940, 33, 12.820810) (1575130223940, 34, 13.618055) (1575130224940, 32, 12.971123) (1575130225940, 24, 10.974546) (1575130226940, 15, 10.742910) (1575130227940, 23, 16.810783) (1575130228940, 18, 13.115224) (1575130229940, 26, 17.418489) (1575130230940, 20, 17.302315) (1575130231940, 21, 14.283571) (1575130232940, 16, 16.826534) (1575130233940, 18, 19.222122) (1575130234940, 18, 14.931420) (1575130235940, 17, 19.549454) (1575130236940, 22, 16.908388) (1575130237940, 32, 15.637796) (1575130238940, 31, 15.517650) (1575130239940, 18, 14.038033) (1575130240940, 32, 19.859648) (1575130241940, 16, 13.220840) (1575130242940, 28, 16.445398) (1575130243940, 26, 16.695753) (1575130244940, 33, 13.696928) (1575130245940, 21, 15.352819) (1575130246940, 15, 12.388407) (1575130247940, 27, 11.267529) (1575130248940, 20, 14.103228) (1575130249940, 20, 16.250950) (1575130250940, 30, 16.236088) (1575130251940, 22, 18.305340) (1575130252940, 25, 17.360685) (1575130253940, 25, 14.978681) (1575130254940, 33, 14.096183) (1575130255940, 26, 10.019039) (1575130256940, 19, 19.158213) (1575130257940, 22, 15.593924) (1575130258940, 26, 18.780119) (1575130259940, 21, 16.001656) (1575130260940, 16, 18.458328) (1575130261940, 21, 16.417843) (1575130262940, 28, 11.736558) (1575130263940, 34, 18.143946) (1575130264940, 27, 10.303225) (1575130265940, 20, 19.756748) (1575130266940, 22, 12.940063) (1575130267940, 23, 11.509640) (1575130268940, 19, 18.319309) (1575130269940, 19, 16.278345) (1575130270940, 27, 10.898361) (1575130271940, 31, 13.922162) (1575130272940, 15, 19.296116) (1575130273940, 26, 15.885763) (1575130274940, 15, 15.525804) (1575130275940, 19, 19.579538) (1575130276940, 20, 11.073811) (1575130277940, 16, 13.932510) (1575130278940, 17, 11.900328) (1575130279940, 22, 16.540415) (1575130280940, 33, 15.203803) (1575130281940, 17, 11.518434) (1575130282940, 17, 13.152081) (1575130283940, 18, 11.378041) (1575130284940, 21, 15.390745) (1575130285940, 30, 15.127818) (1575130286940, 19, 16.530401) (1575130287940, 32, 16.542702) (1575130288940, 26, 16.366442) (1575130289940, 25, 10.306822) (1575130290940, 15, 13.691117) (1575130291940, 15, 13.476817) (1575130292940, 25, 12.529998) (1575130293940, 22, 15.550021) (1575130294940, 20, 15.064971) (1575130295940, 24, 13.313683) (1575130296940, 23, 17.002878) (1575130297940, 30, 19.991594) (1575130298940, 15, 11.116746) (1575130299930, 16, 19.405090) (1575130300930, 22, 14.377142) (1575130301930, 16, 16.868231) (1575130302930, 20, 11.565193) (1575130303930, 31, 13.009119) (1575130304930, 29, 18.136400) (1575130305930, 17, 13.806572) (1575130306930, 23, 14.688898) (1575130307930, 26, 12.931019) (1575130308930, 32, 12.185531) (1575130309930, 30, 13.608714) (1575130310930, 23, 18.624914) (1575130311930, 22, 12.970826) (1575130312930, 22, 12.065827) (1575130313930, 25, 16.967192) (1575130314930, 16, 10.283031) (1575130315930, 22, 16.072535) (1575130316930, 24, 10.794536) (1575130317930, 32, 10.591207) (1575130318930, 20, 13.015227) (1575130319930, 28, 15.410999) (1575130320930, 29, 12.785076) (1575130321930, 28, 15.305857) (1575130322930, 33, 12.820810) (1575130323930, 34, 13.618055) (1575130324930, 32, 12.971123) (1575130325930, 24, 10.974546) (1575130326930, 15, 10.742910) (1575130327930, 23, 16.810783) (1575130328930, 18, 13.115224) (1575130329930, 26, 17.418489) (1575130330930, 20, 17.302315) (1575130331930, 21, 14.283571) (1575130332930, 16, 16.826534) (1575130333930, 18, 19.222122) (1575130334930, 18, 14.931420) (1575130335930, 17, 19.549454) (1575130336930, 22, 16.908388) (1575130337930, 32, 15.637796) (1575130338930, 31, 15.517650) (1575130339930, 18, 14.038033) (1575130340930, 32, 19.859648) (1575130341930, 16, 13.220840) (1575130342930, 28, 16.445398) (1575130343930, 26, 16.695753) (1575130344930, 33, 13.696928) (1575130345930, 21, 15.352819) (1575130346930, 15, 12.388407) (1575130347930, 27, 11.267529) (1575130348930, 20, 14.103228) (1575130349930, 20, 16.250950) (1575130350930, 30, 16.236088) (1575130351930, 22, 18.305340) (1575130352930, 25, 17.360685) (1575130353930, 25, 14.978681) (1575130354930, 33, 14.096183) (1575130355930, 26, 10.019039) (1575130356930, 19, 19.158213) (1575130357930, 22, 15.593924) (1575130358930, 26, 18.780119) (1575130359930, 21, 16.001656) (1575130360930, 16, 18.458328) (1575130361930, 21, 16.417843) (1575130362930, 28, 11.736558) (1575130363930, 34, 18.143946) (1575130364930, 27, 10.303225) (1575130365930, 20, 19.756748) (1575130366930, 22, 12.940063) (1575130367930, 23, 11.509640) (1575130368930, 19, 18.319309) (1575130369930, 19, 16.278345) (1575130370930, 27, 10.898361) (1575130371930, 31, 13.922162) (1575130372930, 15, 19.296116) (1575130373930, 26, 15.885763) (1575130374930, 15, 15.525804) (1575130375930, 19, 19.579538) (1575130376930, 20, 11.073811) (1575130377930, 16, 13.932510) (1575130378930, 17, 11.900328) (1575130379930, 22, 16.540415) (1575130380930, 33, 15.203803) (1575130381930, 17, 11.518434) (1575130382930, 17, 13.152081) (1575130383930, 18, 11.378041) (1575130384930, 21, 15.390745) (1575130385930, 30, 15.127818) (1575130386930, 19, 16.530401) (1575130387930, 32, 16.542702) (1575130388930, 26, 16.366442) (1575130389930, 25, 10.306822) (1575130390930, 15, 13.691117) (1575130391930, 15, 13.476817) (1575130392930, 25, 12.529998) (1575130393930, 22, 15.550021) (1575130394930, 20, 15.064971) (1575130395930, 24, 13.313683) (1575130396930, 23, 17.002878) (1575130397930, 30, 19.991594) (1575130398930, 15, 11.116746) (1575130399920, 16, 19.405090) (1575130400920, 22, 14.377142) (1575130401920, 16, 16.868231) (1575130402920, 20, 11.565193) (1575130403920, 31, 13.009119) (1575130404920, 29, 18.136400) (1575130405920, 17, 13.806572) (1575130406920, 23, 14.688898) (1575130407920, 26, 12.931019) (1575130408920, 32, 12.185531) (1575130409920, 30, 13.608714) (1575130410920, 23, 18.624914) (1575130411920, 22, 12.970826) (1575130412920, 22, 12.065827) (1575130413920, 25, 16.967192) (1575130414920, 16, 10.283031) (1575130415920, 22, 16.072535) (1575130416920, 24, 10.794536) (1575130417920, 32, 10.591207) (1575130418920, 20, 13.015227) (1575130419920, 28, 15.410999) (1575130420920, 29, 12.785076) (1575130421920, 28, 15.305857) (1575130422920, 33, 12.820810) (1575130423920, 34, 13.618055) (1575130424920, 32, 12.971123) (1575130425920, 24, 10.974546) (1575130426920, 15, 10.742910) (1575130427920, 23, 16.810783) (1575130428920, 18, 13.115224) (1575130429920, 26, 17.418489) (1575130430920, 20, 17.302315) (1575130431920, 21, 14.283571) (1575130432920, 16, 16.826534) (1575130433920, 18, 19.222122) (1575130434920, 18, 14.931420) (1575130435920, 17, 19.549454) (1575130436920, 22, 16.908388) (1575130437920, 32, 15.637796) (1575130438920, 31, 15.517650) (1575130439920, 18, 14.038033) (1575130440920, 32, 19.859648) (1575130441920, 16, 13.220840) (1575130442920, 28, 16.445398) (1575130443920, 26, 16.695753) (1575130444920, 33, 13.696928) (1575130445920, 21, 15.352819) (1575130446920, 15, 12.388407) (1575130447920, 27, 11.267529) (1575130448920, 20, 14.103228) (1575130449920, 20, 16.250950) (1575130450920, 30, 16.236088) (1575130451920, 22, 18.305340) (1575130452920, 25, 17.360685) (1575130453920, 25, 14.978681) (1575130454920, 33, 14.096183) (1575130455920, 26, 10.019039) (1575130456920, 19, 19.158213) (1575130457920, 22, 15.593924) (1575130458920, 26, 18.780119) (1575130459920, 21, 16.001656) (1575130460920, 16, 18.458328) (1575130461920, 21, 16.417843) (1575130462920, 28, 11.736558) (1575130463920, 34, 18.143946) (1575130464920, 27, 10.303225) (1575130465920, 20, 19.756748) (1575130466920, 22, 12.940063) (1575130467920, 23, 11.509640) (1575130468920, 19, 18.319309) (1575130469920, 19, 16.278345) (1575130470920, 27, 10.898361) (1575130471920, 31, 13.922162) (1575130472920, 15, 19.296116) (1575130473920, 26, 15.885763) (1575130474920, 15, 15.525804) (1575130475920, 19, 19.579538) (1575130476920, 20, 11.073811) (1575130477920, 16, 13.932510) (1575130478920, 17, 11.900328) (1575130479920, 22, 16.540415) (1575130480920, 33, 15.203803) (1575130481920, 17, 11.518434) (1575130482920, 17, 13.152081) (1575130483920, 18, 11.378041) (1575130484920, 21, 15.390745) (1575130485920, 30, 15.127818) (1575130486920, 19, 16.530401) (1575130487920, 32, 16.542702) (1575130488920, 26, 16.366442) (1575130489920, 25, 10.306822) (1575130490920, 15, 13.691117) (1575130491920, 15, 13.476817) (1575130492920, 25, 12.529998) (1575130493920, 22, 15.550021) (1575130494920, 20, 15.064971) (1575130495920, 24, 13.313683) (1575130496920, 23, 17.002878) (1575130497920, 30, 19.991594) (1575130498920, 15, 11.116746) (1575130499910, 16, 19.405090) (1575130500910, 22, 14.377142) (1575130501910, 16, 16.868231) (1575130502910, 20, 11.565193) (1575130503910, 31, 13.009119) (1575130504910, 29, 18.136400) (1575130505910, 17, 13.806572) (1575130506910, 23, 14.688898) (1575130507910, 26, 12.931019) (1575130508910, 32, 12.185531) (1575130509910, 30, 13.608714) (1575130510910, 23, 18.624914) (1575130511910, 22, 12.970826) (1575130512910, 22, 12.065827) (1575130513910, 25, 16.967192) (1575130514910, 16, 10.283031) (1575130515910, 22, 16.072535) (1575130516910, 24, 10.794536) (1575130517910, 32, 10.591207) (1575130518910, 20, 13.015227) (1575130519910, 28, 15.410999) (1575130520910, 29, 12.785076) (1575130521910, 28, 15.305857) (1575130522910, 33, 12.820810) (1575130523910, 34, 13.618055) (1575130524910, 32, 12.971123) (1575130525910, 24, 10.974546) (1575130526910, 15, 10.742910) (1575130527910, 23, 16.810783) (1575130528910, 18, 13.115224) (1575130529910, 26, 17.418489) (1575130530910, 20, 17.302315) (1575130531910, 21, 14.283571) (1575130532910, 16, 16.826534) (1575130533910, 18, 19.222122) (1575130534910, 18, 14.931420) (1575130535910, 17, 19.549454) (1575130536910, 22, 16.908388) (1575130537910, 32, 15.637796) (1575130538910, 31, 15.517650) (1575130539910, 18, 14.038033) (1575130540910, 32, 19.859648) (1575130541910, 16, 13.220840) (1575130542910, 28, 16.445398) (1575130543910, 26, 16.695753) (1575130544910, 33, 13.696928) (1575130545910, 21, 15.352819) (1575130546910, 15, 12.388407) (1575130547910, 27, 11.267529) (1575130548910, 20, 14.103228) (1575130549910, 20, 16.250950) (1575130550910, 30, 16.236088) (1575130551910, 22, 18.305340) (1575130552910, 25, 17.360685) (1575130553910, 25, 14.978681) (1575130554910, 33, 14.096183) (1575130555910, 26, 10.019039) (1575130556910, 19, 19.158213) (1575130557910, 22, 15.593924) (1575130558910, 26, 18.780119) (1575130559910, 21, 16.001656) (1575130560910, 16, 18.458328) (1575130561910, 21, 16.417843) (1575130562910, 28, 11.736558) (1575130563910, 34, 18.143946) (1575130564910, 27, 10.303225) (1575130565910, 20, 19.756748) (1575130566910, 22, 12.940063) (1575130567910, 23, 11.509640) (1575130568910, 19, 18.319309) (1575130569910, 19, 16.278345) (1575130570910, 27, 10.898361) (1575130571910, 31, 13.922162) (1575130572910, 15, 19.296116) (1575130573910, 26, 15.885763) (1575130574910, 15, 15.525804) (1575130575910, 19, 19.579538) (1575130576910, 20, 11.073811) (1575130577910, 16, 13.932510) (1575130578910, 17, 11.900328) (1575130579910, 22, 16.540415) (1575130580910, 33, 15.203803) (1575130581910, 17, 11.518434) (1575130582910, 17, 13.152081) (1575130583910, 18, 11.378041) (1575130584910, 21, 15.390745) (1575130585910, 30, 15.127818) (1575130586910, 19, 16.530401) (1575130587910, 32, 16.542702) (1575130588910, 26, 16.366442) (1575130589910, 25, 10.306822) (1575130590910, 15, 13.691117) (1575130591910, 15, 13.476817) (1575130592910, 25, 12.529998) (1575130593910, 22, 15.550021) (1575130594910, 20, 15.064971) (1575130595910, 24, 13.313683) (1575130596910, 23, 17.002878) (1575130597910, 30, 19.991594) (1575130598910, 15, 11.116746) (1575130599900, 16, 19.405090) (1575130600900, 22, 14.377142) (1575130601900, 16, 16.868231) (1575130602900, 20, 11.565193) (1575130603900, 31, 13.009119) (1575130604900, 29, 18.136400) (1575130605900, 17, 13.806572) (1575130606900, 23, 14.688898) (1575130607900, 26, 12.931019) (1575130608900, 32, 12.185531) (1575130609900, 30, 13.608714) (1575130610900, 23, 18.624914) (1575130611900, 22, 12.970826) (1575130612900, 22, 12.065827) (1575130613900, 25, 16.967192) (1575130614900, 16, 10.283031) (1575130615900, 22, 16.072535) (1575130616900, 24, 10.794536) (1575130617900, 32, 10.591207) (1575130618900, 20, 13.015227) (1575130619900, 28, 15.410999) (1575130620900, 29, 12.785076) (1575130621900, 28, 15.305857) (1575130622900, 33, 12.820810) (1575130623900, 34, 13.618055) (1575130624900, 32, 12.971123) (1575130625900, 24, 10.974546) (1575130626900, 15, 10.742910) (1575130627900, 23, 16.810783) (1575130628900, 18, 13.115224) (1575130629900, 26, 17.418489) (1575130630900, 20, 17.302315) (1575130631900, 21, 14.283571) (1575130632900, 16, 16.826534) (1575130633900, 18, 19.222122) (1575130634900, 18, 14.931420) (1575130635900, 17, 19.549454) (1575130636900, 22, 16.908388) (1575130637900, 32, 15.637796) (1575130638900, 31, 15.517650) (1575130639900, 18, 14.038033) (1575130640900, 32, 19.859648) (1575130641900, 16, 13.220840) (1575130642900, 28, 16.445398) (1575130643900, 26, 16.695753) (1575130644900, 33, 13.696928) (1575130645900, 21, 15.352819) (1575130646900, 15, 12.388407) (1575130647900, 27, 11.267529) (1575130648900, 20, 14.103228) (1575130649900, 20, 16.250950) (1575130650900, 30, 16.236088) (1575130651900, 22, 18.305340) (1575130652900, 25, 17.360685) (1575130653900, 25, 14.978681) (1575130654900, 33, 14.096183) (1575130655900, 26, 10.019039) (1575130656900, 19, 19.158213) (1575130657900, 22, 15.593924) (1575130658900, 26, 18.780119) (1575130659900, 21, 16.001656) (1575130660900, 16, 18.458328) (1575130661900, 21, 16.417843) (1575130662900, 28, 11.736558) (1575130663900, 34, 18.143946) (1575130664900, 27, 10.303225) (1575130665900, 20, 19.756748) (1575130666900, 22, 12.940063) (1575130667900, 23, 11.509640) (1575130668900, 19, 18.319309) (1575130669900, 19, 16.278345) (1575130670900, 27, 10.898361) (1575130671900, 31, 13.922162) (1575130672900, 15, 19.296116) (1575130673900, 26, 15.885763) (1575130674900, 15, 15.525804) (1575130675900, 19, 19.579538) (1575130676900, 20, 11.073811) (1575130677900, 16, 13.932510) (1575130678900, 17, 11.900328) (1575130679900, 22, 16.540415) (1575130680900, 33, 15.203803) (1575130681900, 17, 11.518434) (1575130682900, 17, 13.152081) (1575130683900, 18, 11.378041) (1575130684900, 21, 15.390745) (1575130685900, 30, 15.127818) (1575130686900, 19, 16.530401) (1575130687900, 32, 16.542702) (1575130688900, 26, 16.366442) (1575130689900, 25, 10.306822) (1575130690900, 15, 13.691117) (1575130691900, 15, 13.476817) (1575130692900, 25, 12.529998) (1575130693900, 22, 15.550021) (1575130694900, 20, 15.064971) (1575130695900, 24, 13.313683) (1575130696900, 23, 17.002878) (1575130697900, 30, 19.991594) (1575130698900, 15, 11.116746) (1575130699890, 16, 19.405090) (1575130700890, 22, 14.377142) (1575130701890, 16, 16.868231) (1575130702890, 20, 11.565193) (1575130703890, 31, 13.009119) (1575130704890, 29, 18.136400) (1575130705890, 17, 13.806572) (1575130706890, 23, 14.688898) (1575130707890, 26, 12.931019) (1575130708890, 32, 12.185531) (1575130709890, 30, 13.608714) (1575130710890, 23, 18.624914) (1575130711890, 22, 12.970826) (1575130712890, 22, 12.065827) (1575130713890, 25, 16.967192) (1575130714890, 16, 10.283031) (1575130715890, 22, 16.072535) (1575130716890, 24, 10.794536) (1575130717890, 32, 10.591207) (1575130718890, 20, 13.015227) (1575130719890, 28, 15.410999) (1575130720890, 29, 12.785076) (1575130721890, 28, 15.305857) (1575130722890, 33, 12.820810) (1575130723890, 34, 13.618055) (1575130724890, 32, 12.971123) (1575130725890, 24, 10.974546) (1575130726890, 15, 10.742910) (1575130727890, 23, 16.810783) (1575130728890, 18, 13.115224) (1575130729890, 26, 17.418489) (1575130730890, 20, 17.302315) (1575130731890, 21, 14.283571) (1575130732890, 16, 16.826534) (1575130733890, 18, 19.222122) (1575130734890, 18, 14.931420) (1575130735890, 17, 19.549454) (1575130736890, 22, 16.908388) (1575130737890, 32, 15.637796) (1575130738890, 31, 15.517650) (1575130739890, 18, 14.038033) (1575130740890, 32, 19.859648) (1575130741890, 16, 13.220840) (1575130742890, 28, 16.445398) (1575130743890, 26, 16.695753) (1575130744890, 33, 13.696928) (1575130745890, 21, 15.352819) (1575130746890, 15, 12.388407) (1575130747890, 27, 11.267529) (1575130748890, 20, 14.103228) (1575130749890, 20, 16.250950) (1575130750890, 30, 16.236088) (1575130751890, 22, 18.305340) (1575130752890, 25, 17.360685) (1575130753890, 25, 14.978681) (1575130754890, 33, 14.096183) (1575130755890, 26, 10.019039) (1575130756890, 19, 19.158213) (1575130757890, 22, 15.593924) (1575130758890, 26, 18.780119) (1575130759890, 21, 16.001656) (1575130760890, 16, 18.458328) (1575130761890, 21, 16.417843) (1575130762890, 28, 11.736558) (1575130763890, 34, 18.143946) (1575130764890, 27, 10.303225) (1575130765890, 20, 19.756748) (1575130766890, 22, 12.940063) (1575130767890, 23, 11.509640) (1575130768890, 19, 18.319309) (1575130769890, 19, 16.278345) (1575130770890, 27, 10.898361) (1575130771890, 31, 13.922162) (1575130772890, 15, 19.296116) (1575130773890, 26, 15.885763) (1575130774890, 15, 15.525804) (1575130775890, 19, 19.579538) (1575130776890, 20, 11.073811) (1575130777890, 16, 13.932510) (1575130778890, 17, 11.900328) (1575130779890, 22, 16.540415) (1575130780890, 33, 15.203803) (1575130781890, 17, 11.518434) (1575130782890, 17, 13.152081) (1575130783890, 18, 11.378041) (1575130784890, 21, 15.390745) (1575130785890, 30, 15.127818) (1575130786890, 19, 16.530401) (1575130787890, 32, 16.542702) (1575130788890, 26, 16.366442) (1575130789890, 25, 10.306822) (1575130790890, 15, 13.691117) (1575130791890, 15, 13.476817) (1575130792890, 25, 12.529998) (1575130793890, 22, 15.550021) (1575130794890, 20, 15.064971) (1575130795890, 24, 13.313683) (1575130796890, 23, 17.002878) (1575130797890, 30, 19.991594) (1575130798890, 15, 11.116746) (1575130799880, 16, 19.405090) (1575130800880, 22, 14.377142) (1575130801880, 16, 16.868231) (1575130802880, 20, 11.565193) (1575130803880, 31, 13.009119) (1575130804880, 29, 18.136400) (1575130805880, 17, 13.806572) (1575130806880, 23, 14.688898) (1575130807880, 26, 12.931019) (1575130808880, 32, 12.185531) (1575130809880, 30, 13.608714) (1575130810880, 23, 18.624914) (1575130811880, 22, 12.970826) (1575130812880, 22, 12.065827) (1575130813880, 25, 16.967192) (1575130814880, 16, 10.283031) (1575130815880, 22, 16.072535) (1575130816880, 24, 10.794536) (1575130817880, 32, 10.591207) (1575130818880, 20, 13.015227) (1575130819880, 28, 15.410999) (1575130820880, 29, 12.785076) (1575130821880, 28, 15.305857) (1575130822880, 33, 12.820810) (1575130823880, 34, 13.618055) (1575130824880, 32, 12.971123) (1575130825880, 24, 10.974546) (1575130826880, 15, 10.742910) (1575130827880, 23, 16.810783) (1575130828880, 18, 13.115224) (1575130829880, 26, 17.418489) (1575130830880, 20, 17.302315) (1575130831880, 21, 14.283571) (1575130832880, 16, 16.826534) (1575130833880, 18, 19.222122) (1575130834880, 18, 14.931420) (1575130835880, 17, 19.549454) (1575130836880, 22, 16.908388) (1575130837880, 32, 15.637796) (1575130838880, 31, 15.517650) (1575130839880, 18, 14.038033) (1575130840880, 32, 19.859648) (1575130841880, 16, 13.220840) (1575130842880, 28, 16.445398) (1575130843880, 26, 16.695753) (1575130844880, 33, 13.696928) (1575130845880, 21, 15.352819) (1575130846880, 15, 12.388407) (1575130847880, 27, 11.267529) (1575130848880, 20, 14.103228) (1575130849880, 20, 16.250950) (1575130850880, 30, 16.236088) (1575130851880, 22, 18.305340) (1575130852880, 25, 17.360685) (1575130853880, 25, 14.978681) (1575130854880, 33, 14.096183) (1575130855880, 26, 10.019039) (1575130856880, 19, 19.158213) (1575130857880, 22, 15.593924) (1575130858880, 26, 18.780119) (1575130859880, 21, 16.001656) (1575130860880, 16, 18.458328) (1575130861880, 21, 16.417843) (1575130862880, 28, 11.736558) (1575130863880, 34, 18.143946) (1575130864880, 27, 10.303225) (1575130865880, 20, 19.756748) (1575130866880, 22, 12.940063) (1575130867880, 23, 11.509640) (1575130868880, 19, 18.319309) (1575130869880, 19, 16.278345) (1575130870880, 27, 10.898361) (1575130871880, 31, 13.922162) (1575130872880, 15, 19.296116) (1575130873880, 26, 15.885763) (1575130874880, 15, 15.525804) (1575130875880, 19, 19.579538) (1575130876880, 20, 11.073811) (1575130877880, 16, 13.932510) (1575130878880, 17, 11.900328) (1575130879880, 22, 16.540415) (1575130880880, 33, 15.203803) (1575130881880, 17, 11.518434) (1575130882880, 17, 13.152081) (1575130883880, 18, 11.378041) (1575130884880, 21, 15.390745) (1575130885880, 30, 15.127818) (1575130886880, 19, 16.530401) (1575130887880, 32, 16.542702) (1575130888880, 26, 16.366442) (1575130889880, 25, 10.306822) (1575130890880, 15, 13.691117) (1575130891880, 15, 13.476817) (1575130892880, 25, 12.529998) (1575130893880, 22, 15.550021) (1575130894880, 20, 15.064971) (1575130895880, 24, 13.313683) (1575130896880, 23, 17.002878) (1575130897880, 30, 19.991594) (1575130898880, 15, 11.116746) (1575130899870, 16, 19.405090) (1575130900870, 22, 14.377142) (1575130901870, 16, 16.868231) (1575130902870, 20, 11.565193) (1575130903870, 31, 13.009119) (1575130904870, 29, 18.136400) (1575130905870, 17, 13.806572) (1575130906870, 23, 14.688898) (1575130907870, 26, 12.931019) (1575130908870, 32, 12.185531) (1575130909870, 30, 13.608714) (1575130910870, 23, 18.624914) (1575130911870, 22, 12.970826) (1575130912870, 22, 12.065827) (1575130913870, 25, 16.967192) (1575130914870, 16, 10.283031) (1575130915870, 22, 16.072535) (1575130916870, 24, 10.794536) (1575130917870, 32, 10.591207) (1575130918870, 20, 13.015227) (1575130919870, 28, 15.410999) (1575130920870, 29, 12.785076) (1575130921870, 28, 15.305857) (1575130922870, 33, 12.820810) (1575130923870, 34, 13.618055) (1575130924870, 32, 12.971123) (1575130925870, 24, 10.974546) (1575130926870, 15, 10.742910) (1575130927870, 23, 16.810783) (1575130928870, 18, 13.115224) (1575130929870, 26, 17.418489) (1575130930870, 20, 17.302315) (1575130931870, 21, 14.283571) (1575130932870, 16, 16.826534) (1575130933870, 18, 19.222122) (1575130934870, 18, 14.931420) (1575130935870, 17, 19.549454) (1575130936870, 22, 16.908388) (1575130937870, 32, 15.637796) (1575130938870, 31, 15.517650) (1575130939870, 18, 14.038033) (1575130940870, 32, 19.859648) (1575130941870, 16, 13.220840) (1575130942870, 28, 16.445398) (1575130943870, 26, 16.695753) (1575130944870, 33, 13.696928) (1575130945870, 21, 15.352819) (1575130946870, 15, 12.388407) (1575130947870, 27, 11.267529) (1575130948870, 20, 14.103228) (1575130949870, 20, 16.250950) (1575130950870, 30, 16.236088) (1575130951870, 22, 18.305340) (1575130952870, 25, 17.360685) (1575130953870, 25, 14.978681) (1575130954870, 33, 14.096183) (1575130955870, 26, 10.019039) (1575130956870, 19, 19.158213) (1575130957870, 22, 15.593924) (1575130958870, 26, 18.780119) (1575130959870, 21, 16.001656) (1575130960870, 16, 18.458328) (1575130961870, 21, 16.417843) (1575130962870, 28, 11.736558) (1575130963870, 34, 18.143946) (1575130964870, 27, 10.303225) (1575130965870, 20, 19.756748) (1575130966870, 22, 12.940063) (1575130967870, 23, 11.509640) (1575130968870, 19, 18.319309) (1575130969870, 19, 16.278345) (1575130970870, 27, 10.898361) (1575130971870, 31, 13.922162) (1575130972870, 15, 19.296116) (1575130973870, 26, 15.885763) (1575130974870, 15, 15.525804) (1575130975870, 19, 19.579538) (1575130976870, 20, 11.073811) (1575130977870, 16, 13.932510) (1575130978870, 17, 11.900328) (1575130979870, 22, 16.540415) (1575130980870, 33, 15.203803) (1575130981870, 17, 11.518434) (1575130982870, 17, 13.152081) (1575130983870, 18, 11.378041) (1575130984870, 21, 15.390745) (1575130985870, 30, 15.127818) (1575130986870, 19, 16.530401) (1575130987870, 32, 16.542702) (1575130988870, 26, 16.366442) (1575130989870, 25, 10.306822) (1575130990870, 15, 13.691117) (1575130991870, 15, 13.476817) (1575130992870, 25, 12.529998) (1575130993870, 22, 15.550021) (1575130994870, 20, 15.064971) (1575130995870, 24, 13.313683) (1575130996870, 23, 17.002878) (1575130997870, 30, 19.991594) (1575130998870, 15, 11.116746) (1575130999860, 16, 19.405090) (1575131000860, 22, 14.377142) (1575131001860, 16, 16.868231) (1575131002860, 20, 11.565193) (1575131003860, 31, 13.009119) (1575131004860, 29, 18.136400) (1575131005860, 17, 13.806572) (1575131006860, 23, 14.688898) (1575131007860, 26, 12.931019) (1575131008860, 32, 12.185531) (1575131009860, 30, 13.608714) (1575131010860, 23, 18.624914) (1575131011860, 22, 12.970826) (1575131012860, 22, 12.065827) (1575131013860, 25, 16.967192) (1575131014860, 16, 10.283031) (1575131015860, 22, 16.072535) (1575131016860, 24, 10.794536) (1575131017860, 32, 10.591207) (1575131018860, 20, 13.015227) (1575131019860, 28, 15.410999) (1575131020860, 29, 12.785076) (1575131021860, 28, 15.305857) (1575131022860, 33, 12.820810) (1575131023860, 34, 13.618055) (1575131024860, 32, 12.971123) (1575131025860, 24, 10.974546) (1575131026860, 15, 10.742910) (1575131027860, 23, 16.810783) (1575131028860, 18, 13.115224) (1575131029860, 26, 17.418489) (1575131030860, 20, 17.302315) (1575131031860, 21, 14.283571) (1575131032860, 16, 16.826534) (1575131033860, 18, 19.222122) (1575131034860, 18, 14.931420) (1575131035860, 17, 19.549454) (1575131036860, 22, 16.908388) (1575131037860, 32, 15.637796) (1575131038860, 31, 15.517650) (1575131039860, 18, 14.038033) (1575131040860, 32, 19.859648) (1575131041860, 16, 13.220840) (1575131042860, 28, 16.445398) (1575131043860, 26, 16.695753) (1575131044860, 33, 13.696928) (1575131045860, 21, 15.352819) (1575131046860, 15, 12.388407) (1575131047860, 27, 11.267529) (1575131048860, 20, 14.103228) (1575131049860, 20, 16.250950) (1575131050860, 30, 16.236088) (1575131051860, 22, 18.305340) (1575131052860, 25, 17.360685) (1575131053860, 25, 14.978681) (1575131054860, 33, 14.096183) (1575131055860, 26, 10.019039) (1575131056860, 19, 19.158213) (1575131057860, 22, 15.593924) (1575131058860, 26, 18.780119) (1575131059860, 21, 16.001656) (1575131060860, 16, 18.458328) (1575131061860, 21, 16.417843) (1575131062860, 28, 11.736558) (1575131063860, 34, 18.143946) (1575131064860, 27, 10.303225) (1575131065860, 20, 19.756748) (1575131066860, 22, 12.940063) (1575131067860, 23, 11.509640) (1575131068860, 19, 18.319309) (1575131069860, 19, 16.278345) (1575131070860, 27, 10.898361) (1575131071860, 31, 13.922162) (1575131072860, 15, 19.296116) (1575131073860, 26, 15.885763) (1575131074860, 15, 15.525804) (1575131075860, 19, 19.579538) (1575131076860, 20, 11.073811) (1575131077860, 16, 13.932510) (1575131078860, 17, 11.900328) (1575131079860, 22, 16.540415) (1575131080860, 33, 15.203803) (1575131081860, 17, 11.518434) (1575131082860, 17, 13.152081) (1575131083860, 18, 11.378041) (1575131084860, 21, 15.390745) (1575131085860, 30, 15.127818) (1575131086860, 19, 16.530401) (1575131087860, 32, 16.542702) (1575131088860, 26, 16.366442) (1575131089860, 25, 10.306822) (1575131090860, 15, 13.691117) (1575131091860, 15, 13.476817) (1575131092860, 25, 12.529998) (1575131093860, 22, 15.550021) (1575131094860, 20, 15.064971) (1575131095860, 24, 13.313683) (1575131096860, 23, 17.002878) (1575131097860, 30, 19.991594) (1575131098860, 15, 11.116746) (1575131099850, 16, 19.405090) (1575131100850, 22, 14.377142) (1575131101850, 16, 16.868231) (1575131102850, 20, 11.565193) (1575131103850, 31, 13.009119) (1575131104850, 29, 18.136400) (1575131105850, 17, 13.806572) (1575131106850, 23, 14.688898) (1575131107850, 26, 12.931019) (1575131108850, 32, 12.185531) (1575131109850, 30, 13.608714) (1575131110850, 23, 18.624914) (1575131111850, 22, 12.970826) (1575131112850, 22, 12.065827) (1575131113850, 25, 16.967192) (1575131114850, 16, 10.283031) (1575131115850, 22, 16.072535) (1575131116850, 24, 10.794536) (1575131117850, 32, 10.591207) (1575131118850, 20, 13.015227) (1575131119850, 28, 15.410999) (1575131120850, 29, 12.785076) (1575131121850, 28, 15.305857) (1575131122850, 33, 12.820810) (1575131123850, 34, 13.618055) (1575131124850, 32, 12.971123) (1575131125850, 24, 10.974546) (1575131126850, 15, 10.742910) (1575131127850, 23, 16.810783) (1575131128850, 18, 13.115224) (1575131129850, 26, 17.418489) (1575131130850, 20, 17.302315) (1575131131850, 21, 14.283571) (1575131132850, 16, 16.826534) (1575131133850, 18, 19.222122) (1575131134850, 18, 14.931420) (1575131135850, 17, 19.549454) (1575131136850, 22, 16.908388) (1575131137850, 32, 15.637796) (1575131138850, 31, 15.517650) (1575131139850, 18, 14.038033) (1575131140850, 32, 19.859648) (1575131141850, 16, 13.220840) (1575131142850, 28, 16.445398) (1575131143850, 26, 16.695753) (1575131144850, 33, 13.696928) (1575131145850, 21, 15.352819) (1575131146850, 15, 12.388407) (1575131147850, 27, 11.267529) (1575131148850, 20, 14.103228) (1575131149850, 20, 16.250950) (1575131150850, 30, 16.236088) (1575131151850, 22, 18.305340) (1575131152850, 25, 17.360685) (1575131153850, 25, 14.978681) (1575131154850, 33, 14.096183) (1575131155850, 26, 10.019039) (1575131156850, 19, 19.158213) (1575131157850, 22, 15.593924) (1575131158850, 26, 18.780119) (1575131159850, 21, 16.001656) (1575131160850, 16, 18.458328) (1575131161850, 21, 16.417843) (1575131162850, 28, 11.736558) (1575131163850, 34, 18.143946) (1575131164850, 27, 10.303225) (1575131165850, 20, 19.756748) (1575131166850, 22, 12.940063) (1575131167850, 23, 11.509640) (1575131168850, 19, 18.319309) (1575131169850, 19, 16.278345) (1575131170850, 27, 10.898361) (1575131171850, 31, 13.922162) (1575131172850, 15, 19.296116) (1575131173850, 26, 15.885763) (1575131174850, 15, 15.525804) (1575131175850, 19, 19.579538) (1575131176850, 20, 11.073811) (1575131177850, 16, 13.932510) (1575131178850, 17, 11.900328) (1575131179850, 22, 16.540415) (1575131180850, 33, 15.203803) (1575131181850, 17, 11.518434) (1575131182850, 17, 13.152081) (1575131183850, 18, 11.378041) (1575131184850, 21, 15.390745) (1575131185850, 30, 15.127818) (1575131186850, 19, 16.530401) (1575131187850, 32, 16.542702) (1575131188850, 26, 16.366442) (1575131189850, 25, 10.306822) (1575131190850, 15, 13.691117) (1575131191850, 15, 13.476817) (1575131192850, 25, 12.529998) (1575131193850, 22, 15.550021) (1575131194850, 20, 15.064971) (1575131195850, 24, 13.313683) (1575131196850, 23, 17.002878) (1575131197850, 30, 19.991594) (1575131198850, 15, 11.116746) (1575131199840, 16, 19.405090) (1575131200840, 22, 14.377142) (1575131201840, 16, 16.868231) (1575131202840, 20, 11.565193) (1575131203840, 31, 13.009119) (1575131204840, 29, 18.136400) (1575131205840, 17, 13.806572) (1575131206840, 23, 14.688898) (1575131207840, 26, 12.931019) (1575131208840, 32, 12.185531) (1575131209840, 30, 13.608714) (1575131210840, 23, 18.624914) (1575131211840, 22, 12.970826) (1575131212840, 22, 12.065827) (1575131213840, 25, 16.967192) (1575131214840, 16, 10.283031) (1575131215840, 22, 16.072535) (1575131216840, 24, 10.794536) (1575131217840, 32, 10.591207) (1575131218840, 20, 13.015227) (1575131219840, 28, 15.410999) (1575131220840, 29, 12.785076) (1575131221840, 28, 15.305857) (1575131222840, 33, 12.820810) (1575131223840, 34, 13.618055) (1575131224840, 32, 12.971123) (1575131225840, 24, 10.974546) (1575131226840, 15, 10.742910) (1575131227840, 23, 16.810783) (1575131228840, 18, 13.115224) (1575131229840, 26, 17.418489) (1575131230840, 20, 17.302315) (1575131231840, 21, 14.283571) (1575131232840, 16, 16.826534) (1575131233840, 18, 19.222122) (1575131234840, 18, 14.931420) (1575131235840, 17, 19.549454) (1575131236840, 22, 16.908388) (1575131237840, 32, 15.637796) (1575131238840, 31, 15.517650) (1575131239840, 18, 14.038033) (1575131240840, 32, 19.859648) (1575131241840, 16, 13.220840) (1575131242840, 28, 16.445398) (1575131243840, 26, 16.695753) (1575131244840, 33, 13.696928) (1575131245840, 21, 15.352819) (1575131246840, 15, 12.388407) (1575131247840, 27, 11.267529) (1575131248840, 20, 14.103228) (1575131249840, 20, 16.250950) (1575131250840, 30, 16.236088) (1575131251840, 22, 18.305340) (1575131252840, 25, 17.360685) (1575131253840, 25, 14.978681) (1575131254840, 33, 14.096183) (1575131255840, 26, 10.019039) (1575131256840, 19, 19.158213) (1575131257840, 22, 15.593924) (1575131258840, 26, 18.780119) (1575131259840, 21, 16.001656) (1575131260840, 16, 18.458328) (1575131261840, 21, 16.417843) (1575131262840, 28, 11.736558) (1575131263840, 34, 18.143946) (1575131264840, 27, 10.303225) (1575131265840, 20, 19.756748) (1575131266840, 22, 12.940063) (1575131267840, 23, 11.509640) (1575131268840, 19, 18.319309) (1575131269840, 19, 16.278345) (1575131270840, 27, 10.898361) (1575131271840, 31, 13.922162) (1575131272840, 15, 19.296116) (1575131273840, 26, 15.885763) (1575131274840, 15, 15.525804) (1575131275840, 19, 19.579538) (1575131276840, 20, 11.073811) (1575131277840, 16, 13.932510) (1575131278840, 17, 11.900328) (1575131279840, 22, 16.540415) (1575131280840, 33, 15.203803) (1575131281840, 17, 11.518434) (1575131282840, 17, 13.152081) (1575131283840, 18, 11.378041) (1575131284840, 21, 15.390745) (1575131285840, 30, 15.127818) (1575131286840, 19, 16.530401) (1575131287840, 32, 16.542702) (1575131288840, 26, 16.366442) (1575131289840, 25, 10.306822) (1575131290840, 15, 13.691117) (1575131291840, 15, 13.476817) (1575131292840, 25, 12.529998) (1575131293840, 22, 15.550021) (1575131294840, 20, 15.064971) (1575131295840, 24, 13.313683) (1575131296840, 23, 17.002878) (1575131297840, 30, 19.991594) (1575131298840, 15, 11.116746) (1575131299830, 16, 19.405090) (1575131300830, 22, 14.377142) (1575131301830, 16, 16.868231) (1575131302830, 20, 11.565193) (1575131303830, 31, 13.009119) (1575131304830, 29, 18.136400) (1575131305830, 17, 13.806572) (1575131306830, 23, 14.688898) (1575131307830, 26, 12.931019) (1575131308830, 32, 12.185531) (1575131309830, 30, 13.608714) (1575131310830, 23, 18.624914) (1575131311830, 22, 12.970826) (1575131312830, 22, 12.065827) (1575131313830, 25, 16.967192) (1575131314830, 16, 10.283031) (1575131315830, 22, 16.072535) (1575131316830, 24, 10.794536) (1575131317830, 32, 10.591207) (1575131318830, 20, 13.015227) (1575131319830, 28, 15.410999) (1575131320830, 29, 12.785076) (1575131321830, 28, 15.305857) (1575131322830, 33, 12.820810) (1575131323830, 34, 13.618055) (1575131324830, 32, 12.971123) (1575131325830, 24, 10.974546) (1575131326830, 15, 10.742910) (1575131327830, 23, 16.810783) (1575131328830, 18, 13.115224) (1575131329830, 26, 17.418489) (1575131330830, 20, 17.302315) (1575131331830, 21, 14.283571) (1575131332830, 16, 16.826534) (1575131333830, 18, 19.222122) (1575131334830, 18, 14.931420) (1575131335830, 17, 19.549454) (1575131336830, 22, 16.908388) (1575131337830, 32, 15.637796) (1575131338830, 31, 15.517650) (1575131339830, 18, 14.038033) (1575131340830, 32, 19.859648) (1575131341830, 16, 13.220840) (1575131342830, 28, 16.445398) (1575131343830, 26, 16.695753) (1575131344830, 33, 13.696928) (1575131345830, 21, 15.352819) (1575131346830, 15, 12.388407) (1575131347830, 27, 11.267529) (1575131348830, 20, 14.103228) (1575131349830, 20, 16.250950) (1575131350830, 30, 16.236088) (1575131351830, 22, 18.305340) (1575131352830, 25, 17.360685) (1575131353830, 25, 14.978681) (1575131354830, 33, 14.096183) (1575131355830, 26, 10.019039) (1575131356830, 19, 19.158213) (1575131357830, 22, 15.593924) (1575131358830, 26, 18.780119) (1575131359830, 21, 16.001656) (1575131360830, 16, 18.458328) (1575131361830, 21, 16.417843) (1575131362830, 28, 11.736558) (1575131363830, 34, 18.143946) (1575131364830, 27, 10.303225) (1575131365830, 20, 19.756748) (1575131366830, 22, 12.940063) (1575131367830, 23, 11.509640) (1575131368830, 19, 18.319309) (1575131369830, 19, 16.278345) (1575131370830, 27, 10.898361) (1575131371830, 31, 13.922162) (1575131372830, 15, 19.296116) (1575131373830, 26, 15.885763) (1575131374830, 15, 15.525804) (1575131375830, 19, 19.579538) (1575131376830, 20, 11.073811) (1575131377830, 16, 13.932510) (1575131378830, 17, 11.900328) (1575131379830, 22, 16.540415) (1575131380830, 33, 15.203803) (1575131381830, 17, 11.518434) (1575131382830, 17, 13.152081) (1575131383830, 18, 11.378041) (1575131384830, 21, 15.390745) (1575131385830, 30, 15.127818) (1575131386830, 19, 16.530401) (1575131387830, 32, 16.542702) (1575131388830, 26, 16.366442) (1575131389830, 25, 10.306822) (1575131390830, 15, 13.691117) (1575131391830, 15, 13.476817) (1575131392830, 25, 12.529998) (1575131393830, 22, 15.550021) (1575131394830, 20, 15.064971) (1575131395830, 24, 13.313683) (1575131396830, 23, 17.002878) (1575131397830, 30, 19.991594) (1575131398830, 15, 11.116746) (1575131399820, 16, 19.405090) (1575131400820, 22, 14.377142) (1575131401820, 16, 16.868231) (1575131402820, 20, 11.565193) (1575131403820, 31, 13.009119) (1575131404820, 29, 18.136400) (1575131405820, 17, 13.806572) (1575131406820, 23, 14.688898) (1575131407820, 26, 12.931019) (1575131408820, 32, 12.185531) (1575131409820, 30, 13.608714) (1575131410820, 23, 18.624914) (1575131411820, 22, 12.970826) (1575131412820, 22, 12.065827) (1575131413820, 25, 16.967192) (1575131414820, 16, 10.283031) (1575131415820, 22, 16.072535) (1575131416820, 24, 10.794536) (1575131417820, 32, 10.591207) (1575131418820, 20, 13.015227) (1575131419820, 28, 15.410999) (1575131420820, 29, 12.785076) (1575131421820, 28, 15.305857) (1575131422820, 33, 12.820810) (1575131423820, 34, 13.618055) (1575131424820, 32, 12.971123) (1575131425820, 24, 10.974546) (1575131426820, 15, 10.742910) (1575131427820, 23, 16.810783) (1575131428820, 18, 13.115224) (1575131429820, 26, 17.418489) (1575131430820, 20, 17.302315) (1575131431820, 21, 14.283571) (1575131432820, 16, 16.826534) (1575131433820, 18, 19.222122) (1575131434820, 18, 14.931420) (1575131435820, 17, 19.549454) (1575131436820, 22, 16.908388) (1575131437820, 32, 15.637796) (1575131438820, 31, 15.517650) (1575131439820, 18, 14.038033) (1575131440820, 32, 19.859648) (1575131441820, 16, 13.220840) (1575131442820, 28, 16.445398) (1575131443820, 26, 16.695753) (1575131444820, 33, 13.696928) (1575131445820, 21, 15.352819) (1575131446820, 15, 12.388407) (1575131447820, 27, 11.267529) (1575131448820, 20, 14.103228) (1575131449820, 20, 16.250950) (1575131450820, 30, 16.236088) (1575131451820, 22, 18.305340) (1575131452820, 25, 17.360685) (1575131453820, 25, 14.978681) (1575131454820, 33, 14.096183) (1575131455820, 26, 10.019039) (1575131456820, 19, 19.158213) (1575131457820, 22, 15.593924) (1575131458820, 26, 18.780119) (1575131459820, 21, 16.001656) (1575131460820, 16, 18.458328) (1575131461820, 21, 16.417843) (1575131462820, 28, 11.736558) (1575131463820, 34, 18.143946) (1575131464820, 27, 10.303225) (1575131465820, 20, 19.756748) (1575131466820, 22, 12.940063) (1575131467820, 23, 11.509640) (1575131468820, 19, 18.319309) (1575131469820, 19, 16.278345) (1575131470820, 27, 10.898361) (1575131471820, 31, 13.922162) (1575131472820, 15, 19.296116) (1575131473820, 26, 15.885763) (1575131474820, 15, 15.525804) (1575131475820, 19, 19.579538) (1575131476820, 20, 11.073811) (1575131477820, 16, 13.932510) (1575131478820, 17, 11.900328) (1575131479820, 22, 16.540415) (1575131480820, 33, 15.203803) (1575131481820, 17, 11.518434) (1575131482820, 17, 13.152081) (1575131483820, 18, 11.378041) (1575131484820, 21, 15.390745) (1575131485820, 30, 15.127818) (1575131486820, 19, 16.530401) (1575131487820, 32, 16.542702) (1575131488820, 26, 16.366442) (1575131489820, 25, 10.306822) (1575131490820, 15, 13.691117) (1575131491820, 15, 13.476817) (1575131492820, 25, 12.529998) (1575131493820, 22, 15.550021) (1575131494820, 20, 15.064971) (1575131495820, 24, 13.313683) (1575131496820, 23, 17.002878) (1575131497820, 30, 19.991594) (1575131498820, 15, 11.116746) (1575131499810, 16, 19.405090) (1575131500810, 22, 14.377142) (1575131501810, 16, 16.868231) (1575131502810, 20, 11.565193) (1575131503810, 31, 13.009119) (1575131504810, 29, 18.136400) (1575131505810, 17, 13.806572) (1575131506810, 23, 14.688898) (1575131507810, 26, 12.931019) (1575131508810, 32, 12.185531) (1575131509810, 30, 13.608714) (1575131510810, 23, 18.624914) (1575131511810, 22, 12.970826) (1575131512810, 22, 12.065827) (1575131513810, 25, 16.967192) (1575131514810, 16, 10.283031) (1575131515810, 22, 16.072535) (1575131516810, 24, 10.794536) (1575131517810, 32, 10.591207) (1575131518810, 20, 13.015227) (1575131519810, 28, 15.410999) (1575131520810, 29, 12.785076) (1575131521810, 28, 15.305857) (1575131522810, 33, 12.820810) (1575131523810, 34, 13.618055) (1575131524810, 32, 12.971123) (1575131525810, 24, 10.974546) (1575131526810, 15, 10.742910) (1575131527810, 23, 16.810783) (1575131528810, 18, 13.115224) (1575131529810, 26, 17.418489) (1575131530810, 20, 17.302315) (1575131531810, 21, 14.283571) (1575131532810, 16, 16.826534) (1575131533810, 18, 19.222122) (1575131534810, 18, 14.931420) (1575131535810, 17, 19.549454) (1575131536810, 22, 16.908388) (1575131537810, 32, 15.637796) (1575131538810, 31, 15.517650) (1575131539810, 18, 14.038033) (1575131540810, 32, 19.859648) (1575131541810, 16, 13.220840) (1575131542810, 28, 16.445398) (1575131543810, 26, 16.695753) (1575131544810, 33, 13.696928) (1575131545810, 21, 15.352819) (1575131546810, 15, 12.388407) (1575131547810, 27, 11.267529) (1575131548810, 20, 14.103228) (1575131549810, 20, 16.250950) (1575131550810, 30, 16.236088) (1575131551810, 22, 18.305340) (1575131552810, 25, 17.360685) (1575131553810, 25, 14.978681) (1575131554810, 33, 14.096183) (1575131555810, 26, 10.019039) (1575131556810, 19, 19.158213) (1575131557810, 22, 15.593924) (1575131558810, 26, 18.780119) (1575131559810, 21, 16.001656) (1575131560810, 16, 18.458328) (1575131561810, 21, 16.417843) (1575131562810, 28, 11.736558) (1575131563810, 34, 18.143946) (1575131564810, 27, 10.303225) (1575131565810, 20, 19.756748) (1575131566810, 22, 12.940063) (1575131567810, 23, 11.509640) (1575131568810, 19, 18.319309) (1575131569810, 19, 16.278345) (1575131570810, 27, 10.898361) (1575131571810, 31, 13.922162) (1575131572810, 15, 19.296116) (1575131573810, 26, 15.885763) (1575131574810, 15, 15.525804) (1575131575810, 19, 19.579538) (1575131576810, 20, 11.073811) (1575131577810, 16, 13.932510) (1575131578810, 17, 11.900328) (1575131579810, 22, 16.540415) (1575131580810, 33, 15.203803) (1575131581810, 17, 11.518434) (1575131582810, 17, 13.152081) (1575131583810, 18, 11.378041) (1575131584810, 21, 15.390745) (1575131585810, 30, 15.127818) (1575131586810, 19, 16.530401) (1575131587810, 32, 16.542702) (1575131588810, 26, 16.366442) (1575131589810, 25, 10.306822) (1575131590810, 15, 13.691117) (1575131591810, 15, 13.476817) (1575131592810, 25, 12.529998) (1575131593810, 22, 15.550021) (1575131594810, 20, 15.064971) (1575131595810, 24, 13.313683) (1575131596810, 23, 17.002878) (1575131597810, 30, 19.991594) (1575131598810, 15, 11.116746) (1575131599800, 16, 19.405090) (1575131600800, 22, 14.377142) (1575131601800, 16, 16.868231) (1575131602800, 20, 11.565193) (1575131603800, 31, 13.009119) (1575131604800, 29, 18.136400) (1575131605800, 17, 13.806572) (1575131606800, 23, 14.688898) (1575131607800, 26, 12.931019) (1575131608800, 32, 12.185531) (1575131609800, 30, 13.608714) (1575131610800, 23, 18.624914) (1575131611800, 22, 12.970826) (1575131612800, 22, 12.065827) (1575131613800, 25, 16.967192) (1575131614800, 16, 10.283031) (1575131615800, 22, 16.072535) (1575131616800, 24, 10.794536) (1575131617800, 32, 10.591207) (1575131618800, 20, 13.015227) (1575131619800, 28, 15.410999) (1575131620800, 29, 12.785076) (1575131621800, 28, 15.305857) (1575131622800, 33, 12.820810) (1575131623800, 34, 13.618055) (1575131624800, 32, 12.971123) (1575131625800, 24, 10.974546) (1575131626800, 15, 10.742910) (1575131627800, 23, 16.810783) (1575131628800, 18, 13.115224) (1575131629800, 26, 17.418489) (1575131630800, 20, 17.302315) (1575131631800, 21, 14.283571) (1575131632800, 16, 16.826534) (1575131633800, 18, 19.222122) (1575131634800, 18, 14.931420) (1575131635800, 17, 19.549454) (1575131636800, 22, 16.908388) (1575131637800, 32, 15.637796) (1575131638800, 31, 15.517650) (1575131639800, 18, 14.038033) (1575131640800, 32, 19.859648) (1575131641800, 16, 13.220840) (1575131642800, 28, 16.445398) (1575131643800, 26, 16.695753) (1575131644800, 33, 13.696928) (1575131645800, 21, 15.352819) (1575131646800, 15, 12.388407) (1575131647800, 27, 11.267529) (1575131648800, 20, 14.103228) (1575131649800, 20, 16.250950) (1575131650800, 30, 16.236088) (1575131651800, 22, 18.305340) (1575131652800, 25, 17.360685) (1575131653800, 25, 14.978681) (1575131654800, 33, 14.096183) (1575131655800, 26, 10.019039) (1575131656800, 19, 19.158213) (1575131657800, 22, 15.593924) (1575131658800, 26, 18.780119) (1575131659800, 21, 16.001656) (1575131660800, 16, 18.458328) (1575131661800, 21, 16.417843) (1575131662800, 28, 11.736558) (1575131663800, 34, 18.143946) (1575131664800, 27, 10.303225) (1575131665800, 20, 19.756748) (1575131666800, 22, 12.940063) (1575131667800, 23, 11.509640) (1575131668800, 19, 18.319309) (1575131669800, 19, 16.278345) (1575131670800, 27, 10.898361) (1575131671800, 31, 13.922162) (1575131672800, 15, 19.296116) (1575131673800, 26, 15.885763) (1575131674800, 15, 15.525804) (1575131675800, 19, 19.579538) (1575131676800, 20, 11.073811) (1575131677800, 16, 13.932510) (1575131678800, 17, 11.900328) (1575131679800, 22, 16.540415) (1575131680800, 33, 15.203803) (1575131681800, 17, 11.518434) (1575131682800, 17, 13.152081) (1575131683800, 18, 11.378041) (1575131684800, 21, 15.390745) (1575131685800, 30, 15.127818) (1575131686800, 19, 16.530401) (1575131687800, 32, 16.542702) (1575131688800, 26, 16.366442) (1575131689800, 25, 10.306822) (1575131690800, 15, 13.691117) (1575131691800, 15, 13.476817) (1575131692800, 25, 12.529998) (1575131693800, 22, 15.550021)") + + end_time = int(round(time.time() * 1000)) + tdLog.info("Execute time without compress: %dms" % (end_time - start_time)) + + simLogPath = tdDnodes.getSimLogPath() + grepCmd = "grep -a 'compress rpc msg, before:' -r %s | head -2" % simLogPath + output = subprocess.check_output(grepCmd, shell=True).decode("utf-8") + + if output != "": + tdLog.info("Find %s in log file." % output) + tdLog.exit("%s successfully executed! Compress works but NOT expected." % __file__) + else: + tdLog.success("%s failed! Compress does NOT works as expected." % __file__) + + conn.close() diff --git a/tests/pytest/test_data/__init__.py b/tests/pytest/test_data/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..1bd7af5b9db25bf22f960bfca6bf18b1518cc86f --- /dev/null +++ b/tests/pytest/test_data/__init__.py @@ -0,0 +1,15 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + + +""" +this directory contains test data files +""" \ No newline at end of file diff --git a/tests/pytest/test_data/disordered.csv b/tests/pytest/test_data/disordered.csv new file mode 100644 index 0000000000000000000000000000000000000000..0e6fd75e5b1a43da360541f57377236e0984093a --- /dev/null +++ b/tests/pytest/test_data/disordered.csv @@ -0,0 +1,500 @@ +"2020-03-01 20:01:49.493","130","7.595","128","8392704" +"2020-03-01 20:01:50.493","130","7.598","128","8392704" +"2020-03-01 20:01:51.493","130","7.602","128","8392704" +"2020-03-01 20:01:52.493","130","7.604","128","8392704" +"2020-03-01 20:01:53.493","130","7.604","128","8392704" +"2020-03-01 20:01:54.493","130","7.606","128","8392704" +"2020-03-01 20:01:55.493","130","7.607","128","8392704" +"2020-03-01 20:01:56.493","130","7.607","128","8392704" +"2020-03-01 20:01:57.493","130","7.607","128","8392704" +"2020-03-01 20:01:58.493","130","7.607","128","8392704" +"2020-03-01 20:01:59.493","130","7.606","128","8392704" +"2020-03-01 20:02:00.493","130","7.606","128","8392704" +"2020-03-01 20:02:01.493","130","7.606","128","8392704" +"2020-03-01 20:02:02.493","130","7.607","128","8392704" +"2020-03-01 20:02:03.493","130","7.608","128","8392704" +"2020-03-01 20:02:04.493","130","7.609","128","8392704" +"2020-03-01 20:02:05.493","130","7.609","128","8392704" +"2020-03-01 20:02:06.493","130","7.608","128","8392704" +"2020-03-01 20:02:07.493","130","7.606","128","8392704" +"2020-03-01 20:02:08.493","130","7.606","128","8392704" +"2020-03-01 20:02:09.493","130","7.607","128","8392704" +"2020-03-01 20:02:10.493","130","7.609","128","8392704" +"2020-03-01 20:02:11.493","130","7.61","128","8392704" +"2020-03-01 20:02:12.493","130","7.611","128","8392704" +"2020-03-01 20:02:13.493","130","7.61","128","8392704" +"2020-03-01 20:02:14.493","130","7.607","128","8392704" +"2020-03-01 20:02:15.493","130","7.605","128","8392704" +"2020-03-01 20:02:16.493","130","7.604","128","8392704" +"2020-03-01 20:02:17.493","130","7.603","128","8392704" +"2020-03-01 20:02:18.493","130","7.604","128","8392704" +"2020-03-01 20:02:19.493","130","7.604","128","8392704" +"2020-03-01 20:02:20.493","130","7.603","128","8392704" +"2020-03-01 20:02:21.493","130","7.601","128","8392704" +"2020-03-01 20:02:22.493","130","7.598","128","8392704" +"2020-03-01 20:02:23.493","130","7.595","128","8392704" +"2020-03-01 20:02:24.493","130","7.594","128","8392704" +"2020-03-01 20:02:25.493","130","7.594","128","8392704" +"2020-03-01 20:02:26.493","130","7.595","128","8392704" +"2020-03-01 20:02:27.493","130","7.596","128","8392704" +"2020-03-01 20:02:28.493","130","7.596","128","8392704" +"2020-03-01 20:02:29.493","130","7.598","128","8392704" +"2020-03-01 20:02:30.493","130","7.6","128","8392704" +"2020-03-01 20:02:31.493","130","7.6","128","8392704" +"2020-03-01 20:02:32.493","130","7.6","128","8392704" +"2020-03-01 20:02:33.493","130","7.601","128","8392704" +"2020-03-01 20:02:34.493","130","7.603","128","8392704" +"2020-03-01 20:02:35.493","130","7.604","128","8392704" +"2020-03-01 20:02:36.493","130","7.605","128","8392704" +"2020-03-01 20:02:37.493","130","7.606","128","8392704" +"2020-03-01 20:02:38.493","130","7.61","128","8392704" +"2020-03-01 20:02:39.493","130","7.611","128","8392704" +"2020-03-01 20:02:40.493","130","7.61","128","8392704" +"2020-03-01 20:02:41.493","130","7.609","128","8392704" +"2020-03-01 20:02:42.493","130","7.611","128","8392704" +"2020-03-01 20:02:43.493","130","7.61","128","8392704" +"2020-03-01 20:02:44.493","130","7.607","128","8392704" +"2020-03-01 20:02:45.493","130","7.605","128","8392704" +"2020-03-01 20:02:46.493","130","7.606","128","8392704" +"2020-03-01 20:02:47.493","130","7.604","128","8392704" +"2020-03-01 20:02:48.493","130","7.599","128","8392704" +"2020-03-01 20:02:49.493","130","7.595","128","8392704" +"2020-03-01 06:41:17.493","130","6.742","128","8392704" +"2020-03-01 06:41:18.493","130","6.741","128","8392704" +"2020-03-01 06:41:19.493","130","6.737","128","8392704" +"2020-03-01 06:41:20.493","130","6.734","128","8392704" +"2020-03-01 06:41:21.493","130","6.734","128","8392704" +"2020-03-01 06:41:22.493","130","6.733","128","8392704" +"2020-03-01 06:41:23.493","130","6.736","128","8392704" +"2020-03-01 06:41:24.493","130","6.739","128","8392704" +"2020-03-01 06:41:25.493","130","6.738","128","8392704" +"2020-03-01 06:41:26.493","130","6.74","128","8392704" +"2020-03-01 06:41:27.493","130","6.745","128","8392704" +"2020-03-01 06:41:28.493","130","6.749","128","8392704" +"2020-03-01 06:41:29.493","130","6.753","128","8392704" +"2020-03-01 06:41:30.493","130","6.753","128","8392704" +"2020-03-01 06:41:31.493","130","6.757","128","8392704" +"2020-03-01 06:41:32.493","130","6.763","128","8392704" +"2020-03-01 06:41:33.493","130","6.765","128","8392704" +"2020-03-01 06:41:34.493","130","6.764","128","8392704" +"2020-03-01 06:41:35.493","130","6.762","128","8392704" +"2020-03-01 06:41:36.493","130","6.758","128","8392704" +"2020-03-01 06:41:37.493","130","6.756","128","8392704" +"2020-03-01 06:41:38.493","130","6.755","128","8392704" +"2020-03-01 06:41:39.493","130","6.754","128","8392704" +"2020-03-01 06:41:40.493","130","6.755","128","8392704" +"2020-03-01 06:41:41.493","130","6.756","128","8392704" +"2020-03-01 06:41:42.493","130","6.757","128","8392704" +"2020-03-01 06:41:43.493","130","6.756","128","8392704" +"2020-03-01 06:41:44.493","130","6.756","128","8392704" +"2020-03-01 06:41:45.493","130","6.756","128","8392704" +"2020-03-01 06:41:46.493","130","6.759","128","8392704" +"2020-03-01 06:41:47.493","130","6.759","128","8392704" +"2020-03-01 06:41:48.493","130","6.758","128","8392704" +"2020-03-01 06:41:49.493","130","6.758","128","8392704" +"2020-03-01 06:41:50.493","130","6.756","128","8392704" +"2020-03-01 06:41:51.493","130","6.755","128","8392704" +"2020-03-01 06:41:52.493","130","6.755","128","8392704" +"2020-03-01 06:41:53.493","130","6.754","128","8392704" +"2020-03-01 06:41:54.493","130","6.751","128","8392704" +"2020-03-01 06:41:55.493","130","6.752","128","8392704" +"2020-03-01 06:41:56.493","130","6.753","128","8392704" +"2020-03-01 06:41:57.493","130","6.753","128","8392704" +"2020-03-01 06:41:58.493","130","6.753","128","8392704" +"2020-03-01 06:41:59.493","130","6.755","128","8392704" +"2020-03-01 06:42:00.493","130","6.752","128","8392704" +"2020-03-01 06:42:01.493","130","6.75","128","8392704" +"2020-03-01 06:42:02.493","130","6.75","128","8392704" +"2020-03-01 06:42:03.493","130","6.753","128","8392704" +"2020-03-01 06:42:04.493","130","6.755","128","8392704" +"2020-03-01 06:42:05.493","130","6.754","128","8392704" +"2020-03-01 06:42:06.493","130","6.754","128","8392704" +"2020-03-01 06:42:07.493","130","6.752","128","8392704" +"2020-03-01 06:42:08.493","130","6.748","128","8392704" +"2020-03-01 06:42:09.493","130","6.747","128","8392704" +"2020-03-01 06:42:10.493","130","6.747","128","8392704" +"2020-03-01 06:42:11.493","130","6.748","128","8392704" +"2020-03-01 06:42:12.493","130","6.748","128","8392704" +"2020-03-01 06:42:13.493","130","6.75","128","8392704" +"2020-03-01 06:42:14.493","130","6.754","128","8392704" +"2020-03-01 06:42:15.493","130","6.754","128","8392704" +"2020-03-01 06:42:16.493","130","6.756","128","8392704" +"2020-03-01 06:42:17.493","130","6.756","128","8392704" +"2020-03-01 06:42:18.493","130","6.757","128","8392704" +"2020-03-01 06:42:19.493","130","6.757","128","8392704" +"2020-03-01 06:42:20.493","130","6.76","128","8392704" +"2020-03-01 06:42:21.493","130","6.761","128","8392704" +"2020-03-01 06:42:22.493","130","6.76","128","8392704" +"2020-03-01 06:42:23.493","130","6.76","128","8392704" +"2020-03-01 06:42:24.493","130","6.76","128","8392704" +"2020-03-01 06:42:25.493","130","6.76","128","8392704" +"2020-03-01 06:42:26.493","130","6.758","128","8392704" +"2020-03-01 06:42:27.493","130","6.757","128","8392704" +"2020-03-01 06:42:28.493","130","6.752","128","8392704" +"2020-03-01 06:42:29.493","130","6.746","128","8392704" +"2020-03-01 06:42:30.493","130","6.742","128","8392704" +"2020-03-01 06:42:31.493","130","6.741","128","8392704" +"2020-03-01 06:42:32.493","130","6.739","128","8392704" +"2020-03-01 06:42:33.493","130","6.739","128","8392704" +"2020-03-01 06:42:34.493","130","6.737","128","8392704" +"2020-03-01 06:42:35.493","130","6.737","128","8392704" +"2020-03-01 06:42:36.493","130","6.738","128","8392704" +"2020-03-01 06:42:37.493","130","6.739","128","8392704" +"2020-03-01 06:42:38.493","130","6.743","128","8392704" +"2020-03-01 06:42:39.493","130","6.747","128","8392704" +"2020-03-01 06:42:40.493","130","6.748","128","8392704" +"2020-03-01 06:42:41.493","130","6.746","128","8392704" +"2020-03-01 06:42:42.493","130","6.746","128","8392704" +"2020-03-01 06:42:43.493","130","6.745","128","8392704" +"2020-03-01 06:42:44.493","130","6.742","128","8392704" +"2020-03-01 06:42:45.493","130","6.741","128","8392704" +"2020-03-01 06:42:46.493","130","6.74","128","8392704" +"2020-03-01 06:42:47.493","130","6.742","128","8392704" +"2020-03-01 06:42:48.493","130","6.743","128","8392704" +"2020-03-01 06:42:49.493","130","6.742","128","8392704" +"2020-03-01 06:42:50.493","130","6.742","128","8392704" +"2020-03-01 06:42:51.493","130","6.741","128","8392704" +"2020-03-01 06:42:52.493","130","6.741","128","8392704" +"2020-03-01 06:42:53.493","130","6.742","128","8392704" +"2020-03-01 06:42:54.493","130","6.742","128","8392704" +"2020-03-01 06:42:55.493","130","6.745","128","8392704" +"2020-03-01 06:42:56.493","130","6.747","128","8392704" +"2020-03-01 06:42:57.493","130","6.748","128","8392704" +"2020-03-01 06:42:58.493","130","6.75","128","8392704" +"2020-03-01 06:42:59.493","130","6.75","128","8392704" +"2020-03-01 06:43:00.493","130","6.748","128","8392704" +"2020-03-01 06:43:01.493","130","6.748","128","8392704" +"2020-03-01 06:43:02.493","130","6.746","128","8392704" +"2020-03-01 06:43:03.493","130","6.745","128","8392704" +"2020-03-01 06:43:04.493","130","6.745","128","8392704" +"2020-03-01 06:43:05.493","130","6.745","128","8392704" +"2020-03-01 06:43:06.493","130","6.744","128","8392704" +"2020-03-01 06:43:07.493","130","6.749","128","8392704" +"2020-03-01 06:43:08.493","130","6.756","128","8392704" +"2020-03-01 06:43:09.493","130","6.759","128","8392704" +"2020-03-01 06:43:10.493","130","6.759","128","8392704" +"2020-03-01 06:43:11.493","130","6.758","128","8392704" +"2020-03-01 06:43:12.493","130","6.758","128","8392704" +"2020-03-01 06:43:13.493","130","6.759","128","8392704" +"2020-03-01 06:43:14.493","130","6.759","128","8392704" +"2020-03-01 06:43:15.493","130","6.753","128","8392704" +"2020-03-01 06:43:16.493","130","6.751","128","8392704" +"2020-03-01 20:02:50.493","130","7.596","128","8392704" +"2020-03-01 20:02:51.493","130","7.597","128","8392704" +"2020-03-01 20:02:52.493","130","7.599","128","8392704" +"2020-03-01 20:02:53.493","130","7.6","128","8392704" +"2020-03-01 20:02:54.493","130","7.601","128","8392704" +"2020-03-01 20:02:55.493","130","7.603","128","8392704" +"2020-03-01 20:02:56.493","130","7.602","128","8392704" +"2020-03-01 20:02:57.493","130","7.601","128","8392704" +"2020-03-01 20:02:58.493","130","7.601","128","8392704" +"2020-03-01 20:02:59.493","130","7.6","128","8392704" +"2020-03-01 20:03:00.493","130","7.599","128","8392704" +"2020-03-01 20:03:01.493","130","7.599","128","8392704" +"2020-03-01 20:03:02.493","130","7.6","128","8392704" +"2020-03-01 20:03:03.493","130","7.601","128","8392704" +"2020-03-01 20:03:04.493","130","7.601","128","8392704" +"2020-03-01 20:03:05.493","130","7.601","128","8392704" +"2020-03-01 20:03:06.493","130","7.6","128","8392704" +"2020-03-01 20:03:07.493","130","7.602","128","8392704" +"2020-03-01 20:03:08.493","130","7.606","128","8392704" +"2020-03-01 20:03:09.493","130","7.609","128","8392704" +"2020-03-01 20:03:10.493","130","7.612","128","8392704" +"2020-03-01 20:03:11.493","130","7.614","128","8392704" +"2020-03-01 20:03:12.493","130","7.615","128","8392704" +"2020-03-01 20:03:13.493","130","7.614","128","8392704" +"2020-03-01 20:03:14.493","130","7.613","128","8392704" +"2020-03-01 20:03:15.493","130","7.614","128","8392704" +"2020-03-01 20:03:16.493","130","7.612","128","8392704" +"2020-03-01 20:03:17.493","130","7.609","128","8392704" +"2020-03-01 20:03:18.493","130","7.606","128","8392704" +"2020-03-01 20:03:19.493","130","7.604","128","8392704" +"2020-03-01 20:03:20.493","130","7.604","128","8392704" +"2020-03-01 20:03:21.493","130","7.605","128","8392704" +"2020-03-01 20:03:22.493","130","7.605","128","8392704" +"2020-03-01 20:03:23.493","130","7.605","128","8392704" +"2020-03-01 20:03:24.493","130","7.605","128","8392704" +"2020-03-01 20:03:25.493","130","7.604","128","8392704" +"2020-03-01 20:03:26.493","130","7.603","128","8392704" +"2020-03-01 20:03:27.493","130","7.604","128","8392704" +"2020-03-01 20:03:28.493","130","7.605","128","8392704" +"2020-03-01 20:03:29.493","130","7.607","128","8392704" +"2020-03-01 20:03:30.493","130","7.609","128","8392704" +"2020-03-01 20:03:31.493","130","7.609","128","8392704" +"2020-03-01 20:03:32.493","130","7.607","128","8392704" +"2020-03-01 20:03:33.493","130","7.606","128","8392704" +"2020-03-01 20:03:34.493","130","7.607","128","8392704" +"2020-03-01 20:03:35.493","130","7.608","128","8392704" +"2020-03-01 20:03:36.493","130","7.609","128","8392704" +"2020-03-01 20:03:37.493","130","7.609","128","8392704" +"2020-03-01 20:03:38.493","130","7.607","128","8392704" +"2020-03-01 20:03:39.493","130","7.602","128","8392704" +"2020-03-01 20:03:40.493","130","7.599","128","8392704" +"2020-03-01 20:03:41.493","130","7.598","128","8392704" +"2020-03-01 20:03:42.493","130","7.596","128","8392704" +"2020-03-01 20:03:43.493","130","7.595","128","8392704" +"2020-03-01 20:03:44.493","130","7.594","128","8392704" +"2020-03-01 20:03:45.493","130","7.595","128","8392704" +"2020-03-01 20:03:46.493","130","7.597","128","8392704" +"2020-03-01 20:03:47.493","130","7.596","128","8392704" +"2020-03-01 20:03:48.493","130","7.595","128","8392704" +"2020-03-01 20:03:49.493","130","7.596","128","8392704" +"2020-03-01 20:03:50.493","130","7.596","128","8392704" +"2020-03-01 20:03:51.493","130","7.595","128","8392704" +"2020-03-01 20:03:52.493","130","7.596","128","8392704" +"2020-03-01 20:03:53.493","130","7.597","128","8392704" +"2020-03-01 20:03:54.493","130","7.598","128","8392704" +"2020-03-01 20:03:55.493","130","7.596","128","8392704" +"2020-03-01 20:03:56.493","130","7.596","128","8392704" +"2020-03-01 20:03:57.493","130","7.599","128","8392704" +"2020-03-01 20:03:58.493","130","7.602","128","8392704" +"2020-03-01 20:03:59.493","130","7.603","128","8392704" +"2020-03-01 20:04:00.493","130","7.602","128","8392704" +"2020-03-01 20:04:01.493","130","7.6","128","8392704" +"2020-03-01 20:04:02.493","130","7.598","128","8392704" +"2020-03-01 20:04:03.493","130","7.595","128","8392704" +"2020-03-01 20:04:04.493","130","7.593","128","8392704" +"2020-03-01 20:04:05.493","130","7.592","128","8392704" +"2020-03-01 20:04:06.493","130","7.591","128","8392704" +"2020-03-01 20:04:07.493","130","7.591","128","8392704" +"2020-03-01 20:04:08.493","130","7.591","128","8392704" +"2020-03-01 20:04:09.493","130","7.592","128","8392704" +"2020-03-01 20:04:10.493","130","7.59","128","8392704" +"2020-03-01 20:04:11.493","130","7.587","128","8392704" +"2020-03-01 20:04:12.493","130","7.584","128","8392704" +"2020-03-01 20:04:13.493","130","7.583","128","8392704" +"2020-03-01 20:04:14.493","130","7.581","128","8392704" +"2020-03-01 20:04:15.493","130","7.578","128","8392704" +"2020-03-01 20:04:16.493","130","7.576","128","8392704" +"2020-03-01 20:04:17.493","130","7.577","128","8392704" +"2020-03-01 20:04:18.493","130","7.579","128","8392704" +"2020-03-01 20:04:19.493","130","7.583","128","8392704" +"2020-03-01 20:04:20.493","130","7.587","128","8392704" +"2020-03-01 20:04:21.493","130","7.588","128","8392704" +"2020-03-01 20:04:22.493","130","7.589","128","8392704" +"2020-03-01 20:04:23.493","130","7.59","128","8392704" +"2020-03-01 20:04:24.493","130","7.593","128","8392704" +"2020-03-01 20:04:25.493","130","7.597","128","8392704" +"2020-03-01 20:04:26.493","130","7.6","128","8392704" +"2020-03-01 20:04:27.493","130","7.603","128","8392704" +"2020-03-01 20:04:28.493","130","7.606","128","8392704" +"2020-03-01 20:04:29.493","130","7.608","128","8392704" +"2020-03-01 20:04:30.493","130","7.609","128","8392704" +"2020-03-01 20:04:31.493","130","7.607","128","8392704" +"2020-03-01 20:04:32.493","130","7.607","128","8392704" +"2020-03-01 20:04:33.493","130","7.607","128","8392704" +"2020-03-01 20:04:34.493","130","7.602","128","8392704" +"2020-03-01 20:04:35.493","130","7.599","128","8392704" +"2020-03-01 20:04:36.493","130","7.599","128","8392704" +"2020-03-01 20:04:37.493","130","7.599","128","8392704" +"2020-03-01 20:04:38.493","130","7.598","128","8392704" +"2020-03-01 20:04:39.493","130","7.596","128","8392704" +"2020-03-01 20:04:40.493","130","7.595","128","8392704" +"2020-03-01 20:04:41.493","130","7.592","128","8392704" +"2020-03-01 20:04:42.493","130","7.586","128","8392704" +"2020-03-01 20:04:43.493","130","7.582","128","8392704" +"2020-03-01 20:04:44.493","130","7.582","128","8392704" +"2020-03-01 20:04:45.493","130","7.584","128","8392704" +"2020-03-01 20:04:46.493","130","7.583","128","8392704" +"2020-03-01 20:04:47.493","130","7.582","128","8392704" +"2020-03-01 20:04:48.493","130","7.582","128","8392704" +"2020-03-01 20:04:49.493","130","7.585","128","8392704" +"2020-03-01 06:43:17.493","130","6.751","128","8392704" +"2020-03-01 06:43:18.493","130","6.75","128","8392704" +"2020-03-01 06:43:19.493","130","6.748","128","8392704" +"2020-03-01 06:43:20.493","130","6.751","128","8392704" +"2020-03-01 06:43:21.493","130","6.752","128","8392704" +"2020-03-01 06:43:22.493","130","6.751","128","8392704" +"2020-03-01 06:43:23.493","130","6.746","128","8392704" +"2020-03-01 06:43:24.493","130","6.739","128","8392704" +"2020-03-01 06:43:25.493","130","6.737","128","8392704" +"2020-03-01 06:43:26.493","130","6.735","128","8392704" +"2020-03-01 06:43:27.493","130","6.735","128","8392704" +"2020-03-01 06:43:28.493","130","6.734","128","8392704" +"2020-03-01 06:43:29.493","130","6.731","128","8392704" +"2020-03-01 06:43:30.493","130","6.729","128","8392704" +"2020-03-01 06:43:31.493","130","6.73","128","8392704" +"2020-03-01 06:43:32.493","130","6.736","128","8392704" +"2020-03-01 06:43:33.493","130","6.74","128","8392704" +"2020-03-01 06:43:34.493","130","6.741","128","8392704" +"2020-03-01 06:43:35.493","130","6.743","128","8392704" +"2020-03-01 06:43:36.493","130","6.743","128","8392704" +"2020-03-01 06:43:37.493","130","6.745","128","8392704" +"2020-03-01 06:43:38.493","130","6.747","128","8392704" +"2020-03-01 06:43:39.493","130","6.747","128","8392704" +"2020-03-01 06:43:40.493","130","6.746","128","8392704" +"2020-03-01 06:43:41.493","130","6.745","128","8392704" +"2020-03-01 06:43:42.493","130","6.743","128","8392704" +"2020-03-01 06:43:43.493","130","6.741","128","8392704" +"2020-03-01 06:43:44.493","130","6.737","128","8392704" +"2020-03-01 06:43:45.493","130","6.737","128","8392704" +"2020-03-01 06:43:46.493","130","6.74","128","8392704" +"2020-03-01 06:43:47.493","130","6.744","128","8392704" +"2020-03-01 06:43:48.493","130","6.746","128","8392704" +"2020-03-01 06:43:49.493","130","6.745","128","8392704" +"2020-03-01 06:43:50.493","130","6.743","128","8392704" +"2020-03-01 06:43:51.493","130","6.745","128","8392704" +"2020-03-01 06:43:52.493","130","6.747","128","8392704" +"2020-03-01 06:43:53.493","130","6.748","128","8392704" +"2020-03-01 06:43:54.493","130","6.748","128","8392704" +"2020-03-01 06:43:55.493","130","6.747","128","8392704" +"2020-03-01 06:43:56.493","130","6.746","128","8392704" +"2020-03-01 06:43:57.493","130","6.744","128","8392704" +"2020-03-01 06:43:58.493","130","6.742","128","8392704" +"2020-03-01 06:43:59.493","130","6.74","128","8392704" +"2020-03-01 06:44:00.493","130","6.739","128","8392704" +"2020-03-01 06:44:01.493","130","6.739","128","8392704" +"2020-03-01 06:44:02.493","130","6.742","128","8392704" +"2020-03-01 06:44:03.493","130","6.742","128","8392704" +"2020-03-01 06:44:04.493","130","6.756","128","8392704" +"2020-03-01 06:44:05.493","130","6.757","128","8392704" +"2020-03-01 06:44:06.493","130","6.757","128","8392704" +"2020-03-01 06:44:07.493","130","6.757","128","8392704" +"2020-03-01 06:44:08.493","130","6.759","128","8392704" +"2020-03-01 06:44:09.493","130","6.759","128","8392704" +"2020-03-01 06:44:10.493","130","6.75","128","8392704" +"2020-03-01 06:44:11.493","130","6.744","128","8392704" +"2020-03-01 06:44:12.493","130","6.739","128","8392704" +"2020-03-01 06:44:13.493","130","6.739","128","8392704" +"2020-03-01 06:44:14.493","130","6.736","128","8392704" +"2020-03-01 06:44:15.493","130","6.734","128","8392704" +"2020-03-01 06:44:16.493","130","6.735","128","8392704" +"2020-03-01 06:44:17.493","130","6.734","128","8392704" +"2020-03-01 06:44:18.493","130","6.736","128","8392704" +"2020-03-01 06:44:19.493","130","6.741","128","8392704" +"2020-03-01 06:44:20.493","130","6.744","128","8392704" +"2020-03-01 06:44:21.493","130","6.746","128","8392704" +"2020-03-01 06:44:22.493","130","6.746","128","8392704" +"2020-03-01 06:44:23.493","130","6.748","128","8392704" +"2020-03-01 06:44:24.493","130","6.751","128","8392704" +"2020-03-01 06:44:25.493","130","6.752","128","8392704" +"2020-03-01 06:44:26.493","130","6.752","128","8392704" +"2020-03-01 06:44:27.493","130","6.752","128","8392704" +"2020-03-01 06:44:28.493","130","6.753","128","8392704" +"2020-03-01 06:44:29.493","130","6.751","128","8392704" +"2020-03-01 06:44:30.493","130","6.751","128","8392704" +"2020-03-01 06:44:31.493","130","6.749","128","8392704" +"2020-03-01 06:44:32.493","130","6.747","128","8392704" +"2020-03-01 06:44:33.493","130","6.748","128","8392704" +"2020-03-01 06:44:34.493","130","6.749","128","8392704" +"2020-03-01 06:44:35.493","130","6.746","128","8392704" +"2020-03-01 06:44:36.493","130","6.742","128","8392704" +"2020-03-01 06:44:37.493","130","6.742","128","8392704" +"2020-03-01 06:44:38.493","130","6.743","128","8392704" +"2020-03-01 06:44:39.493","130","6.743","128","8392704" +"2020-03-01 06:44:40.493","130","6.743","128","8392704" +"2020-03-01 06:44:41.493","130","6.741","128","8392704" +"2020-03-01 06:44:42.493","130","6.741","128","8392704" +"2020-03-01 06:44:43.493","130","6.741","128","8392704" +"2020-03-01 06:44:44.493","130","6.74","128","8392704" +"2020-03-01 06:44:45.493","130","6.74","128","8392704" +"2020-03-01 06:44:46.493","130","6.739","128","8392704" +"2020-03-01 06:44:47.493","130","6.738","128","8392704" +"2020-03-01 06:44:48.493","130","6.738","128","8392704" +"2020-03-01 06:44:49.493","130","6.741","128","8392704" +"2020-03-01 06:44:50.493","130","6.749","128","8392704" +"2020-03-01 06:44:51.493","130","6.756","128","8392704" +"2020-03-01 06:44:52.493","130","6.763","128","8392704" +"2020-03-01 06:44:53.493","130","6.768","128","8392704" +"2020-03-01 06:44:54.493","130","6.771","128","8392704" +"2020-03-01 06:44:55.493","130","6.774","128","8392704" +"2020-03-01 06:44:56.493","130","6.774","128","8392704" +"2020-03-01 06:44:57.493","130","6.774","128","8392704" +"2020-03-01 06:44:58.493","130","6.765","128","8392704" +"2020-03-01 06:44:59.493","130","6.763","128","8392704" +"2020-03-01 06:45:00.493","130","6.761","128","8392704" +"2020-03-01 06:45:01.493","130","6.758","128","8392704" +"2020-03-01 06:45:02.493","130","6.756","128","8392704" +"2020-03-01 06:45:03.493","130","6.756","128","8392704" +"2020-03-01 06:45:04.493","130","6.756","128","8392704" +"2020-03-01 06:45:05.493","130","6.763","128","8392704" +"2020-03-01 06:45:06.493","130","6.763","128","8392704" +"2020-03-01 06:45:07.493","130","6.764","128","8392704" +"2020-03-01 06:45:08.493","130","6.762","128","8392704" +"2020-03-01 06:45:09.493","130","6.763","128","8392704" +"2020-03-01 06:45:10.493","130","6.764","128","8392704" +"2020-03-01 06:45:11.493","130","6.763","128","8392704" +"2020-03-01 06:45:12.493","130","6.76","128","8392704" +"2020-03-01 06:45:13.493","130","6.759","128","8392704" +"2020-03-01 06:45:14.493","130","6.758","128","8392704" +"2020-03-01 06:45:15.493","130","6.758","128","8392704" +"2020-03-01 06:45:16.493","130","6.755","128","8392704" +"2020-03-01 20:04:50.493","130","7.59","128","8392704" +"2020-03-01 20:04:51.493","130","7.592","128","8392704" +"2020-03-01 20:04:52.493","130","7.592","128","8392704" +"2020-03-01 20:04:53.493","130","7.593","128","8392704" +"2020-03-01 20:04:54.493","130","7.592","128","8392704" +"2020-03-01 20:04:55.493","130","7.592","128","8392704" +"2020-03-01 20:04:56.493","130","7.593","128","8392704" +"2020-03-01 20:04:57.493","130","7.593","128","8392704" +"2020-03-01 20:04:58.493","130","7.593","128","8392704" +"2020-03-01 20:04:59.493","130","7.594","128","8392704" +"2020-03-01 20:05:00.493","130","7.595","128","8392704" +"2020-03-01 20:05:01.493","130","7.596","128","8392704" +"2020-03-01 20:05:02.493","130","7.595","128","8392704" +"2020-03-01 20:05:03.493","130","7.595","128","8392704" +"2020-03-01 20:05:04.493","130","7.594","128","8392704" +"2020-03-01 20:05:05.493","130","7.595","128","8392704" +"2020-03-01 20:05:06.493","130","7.598","128","8392704" +"2020-03-01 20:05:07.493","130","7.597","128","8392704" +"2020-03-01 20:05:08.493","130","7.595","128","8392704" +"2020-03-01 20:05:09.493","130","7.597","128","8392704" +"2020-03-01 20:05:10.493","130","7.598","128","8392704" +"2020-03-01 20:05:11.493","130","7.598","128","8392704" +"2020-03-01 20:05:12.493","130","7.597","128","8392704" +"2020-03-01 20:05:13.493","130","7.595","128","8392704" +"2020-03-01 20:05:14.493","130","7.591","128","8392704" +"2020-03-01 20:05:15.493","130","7.589","128","8392704" +"2020-03-01 20:05:16.493","130","7.588","128","8392704" +"2020-03-01 20:05:17.493","130","7.589","128","8392704" +"2020-03-01 20:05:18.493","130","7.589","128","8392704" +"2020-03-01 20:05:19.493","130","7.589","128","8392704" +"2020-03-01 20:05:20.493","130","7.587","128","8392704" +"2020-03-01 20:05:21.493","130","7.584","128","8392704" +"2020-03-01 20:05:22.493","130","7.583","128","8392704" +"2020-03-01 20:05:23.493","130","7.585","128","8392704" +"2020-03-01 20:05:24.493","130","7.586","128","8392704" +"2020-03-01 20:05:25.493","130","7.586","128","8392704" +"2020-03-01 20:05:26.493","130","7.586","128","8392704" +"2020-03-01 20:05:27.493","130","7.586","128","8392704" +"2020-03-01 20:05:28.493","130","7.587","128","8392704" +"2020-03-01 20:05:29.493","130","7.585","128","8392704" +"2020-03-01 20:05:30.493","130","7.584","128","8392704" +"2020-03-01 20:05:31.493","130","7.586","128","8392704" +"2020-03-01 20:05:32.493","130","7.589","128","8392704" +"2020-03-01 20:05:33.493","130","7.59","128","8392704" +"2020-03-01 20:05:34.493","130","7.591","128","8392704" +"2020-03-01 20:05:35.493","130","7.591","128","8392704" +"2020-03-01 20:05:36.493","130","7.594","128","8392704" +"2020-03-01 20:05:37.493","130","7.599","128","8392704" +"2020-03-01 20:05:38.493","130","7.602","128","8392704" +"2020-03-01 20:05:39.493","130","7.604","128","8392704" +"2020-03-01 20:05:40.493","130","7.605","128","8392704" +"2020-03-01 20:05:41.493","130","7.607","128","8392704" +"2020-03-01 20:05:42.493","130","7.607","128","8392704" +"2020-03-01 20:05:43.493","130","7.604","128","8392704" +"2020-03-01 20:05:44.493","130","7.597","128","8392704" +"2020-03-01 20:05:45.493","130","7.592","128","8392704" +"2020-03-01 20:05:46.493","130","7.59","128","8392704" +"2020-03-01 20:05:47.493","130","7.59","128","8392704" +"2020-03-01 20:05:48.493","130","7.591","128","8392704" +"2020-03-01 20:05:49.493","130","7.591","128","8392704" +"2020-03-01 20:05:50.493","130","7.591","128","8392704" +"2020-03-01 20:05:51.493","130","7.594","128","8392704" +"2020-03-01 20:05:52.493","130","7.599","128","8392704" +"2020-03-01 20:05:53.493","130","7.601","128","8392704" +"2020-03-01 20:05:54.493","130","7.602","128","8392704" +"2020-03-01 20:05:55.493","130","7.602","128","8392704" +"2020-03-01 20:05:56.493","130","7.602","128","8392704" +"2020-03-01 20:05:57.493","130","7.603","128","8392704" +"2020-03-01 20:05:58.493","130","7.604","128","8392704" +"2020-03-01 20:05:59.493","130","7.604","128","8392704" +"2020-03-01 20:06:00.493","130","7.605","128","8392704" +"2020-03-01 20:06:01.493","130","7.606","128","8392704" +"2020-03-01 20:06:02.493","130","7.607","128","8392704" +"2020-03-01 20:06:03.493","130","7.605","128","8392704" +"2020-03-01 20:06:04.493","130","7.604","128","8392704" +"2020-03-01 20:06:05.493","130","7.603","128","8392704" +"2020-03-01 20:06:06.493","130","7.602","128","8392704" +"2020-03-01 20:06:07.493","130","7.603","128","8392704" +"2020-03-01 20:06:08.493","130","7.604","128","8392704" \ No newline at end of file diff --git a/tests/pytest/test_data/ordered.csv b/tests/pytest/test_data/ordered.csv new file mode 100644 index 0000000000000000000000000000000000000000..14da572d75e3c9bef32d6de7696ce65485b06d23 --- /dev/null +++ b/tests/pytest/test_data/ordered.csv @@ -0,0 +1,500 @@ +"2020-03-01 19:46:50.493","130","7.617","128","8392704" +"2020-03-01 19:46:51.493","130","7.615","128","8392704" +"2020-03-01 19:46:52.493","130","7.613","128","8392704" +"2020-03-01 19:46:53.493","130","7.612","128","8392704" +"2020-03-01 19:46:54.493","130","7.611","128","8392704" +"2020-03-01 19:46:55.493","130","7.612","128","8392704" +"2020-03-01 19:46:56.493","130","7.611","128","8392704" +"2020-03-01 19:46:57.493","130","7.61","128","8392704" +"2020-03-01 19:46:58.493","130","7.61","128","8392704" +"2020-03-01 19:46:59.493","130","7.613","128","8392704" +"2020-03-01 19:47:00.493","130","7.617","128","8392704" +"2020-03-01 19:47:01.493","130","7.618","128","8392704" +"2020-03-01 19:47:02.493","130","7.619","128","8392704" +"2020-03-01 19:47:03.493","130","7.62","128","8392704" +"2020-03-01 19:47:04.493","130","7.619","128","8392704" +"2020-03-01 19:47:05.493","130","7.62","128","8392704" +"2020-03-01 19:47:06.493","130","7.62","128","8392704" +"2020-03-01 19:47:07.493","130","7.618","128","8392704" +"2020-03-01 19:47:08.493","130","7.618","128","8392704" +"2020-03-01 19:47:09.493","130","7.616","128","8392704" +"2020-03-01 19:47:10.493","130","7.615","128","8392704" +"2020-03-01 19:47:11.493","130","7.614","128","8392704" +"2020-03-01 19:47:12.493","130","7.614","128","8392704" +"2020-03-01 19:47:13.493","130","7.615","128","8392704" +"2020-03-01 19:47:14.493","130","7.617","128","8392704" +"2020-03-01 19:47:15.493","130","7.617","128","8392704" +"2020-03-01 19:47:16.493","130","7.612","128","8392704" +"2020-03-01 19:47:17.493","130","7.609","128","8392704" +"2020-03-01 19:47:18.493","130","7.609","128","8392704" +"2020-03-01 19:47:19.493","130","7.609","128","8392704" +"2020-03-01 19:47:20.493","130","7.611","128","8392704" +"2020-03-01 19:47:21.493","130","7.613","128","8392704" +"2020-03-01 19:47:22.493","130","7.612","128","8392704" +"2020-03-01 19:47:23.493","130","7.612","128","8392704" +"2020-03-01 19:47:24.493","130","7.612","128","8392704" +"2020-03-01 19:47:25.493","130","7.613","128","8392704" +"2020-03-01 19:47:26.493","130","7.617","128","8392704" +"2020-03-01 19:47:27.493","130","7.62","128","8392704" +"2020-03-01 19:47:28.493","130","7.621","128","8392704" +"2020-03-01 19:47:29.493","130","7.621","128","8392704" +"2020-03-01 19:47:30.493","130","7.623","128","8392704" +"2020-03-01 19:47:31.493","130","7.624","128","8392704" +"2020-03-01 19:47:32.493","130","7.621","128","8392704" +"2020-03-01 19:47:33.493","130","7.619","128","8392704" +"2020-03-01 19:47:34.493","130","7.618","128","8392704" +"2020-03-01 19:47:35.493","130","7.616","128","8392704" +"2020-03-01 19:47:36.493","130","7.618","128","8392704" +"2020-03-01 19:47:37.493","130","7.618","128","8392704" +"2020-03-01 19:47:38.493","130","7.616","128","8392704" +"2020-03-01 19:47:39.493","130","7.615","128","8392704" +"2020-03-01 19:47:40.493","130","7.615","128","8392704" +"2020-03-01 19:47:41.493","130","7.614","128","8392704" +"2020-03-01 19:47:42.493","130","7.613","128","8392704" +"2020-03-01 19:47:43.493","130","7.612","128","8392704" +"2020-03-01 19:47:44.493","130","7.611","128","8392704" +"2020-03-01 19:47:45.493","130","7.612","128","8392704" +"2020-03-01 19:47:46.493","130","7.614","128","8392704" +"2020-03-01 19:47:47.493","130","7.618","128","8392704" +"2020-03-01 19:47:48.493","130","7.62","128","8392704" +"2020-03-01 19:47:49.493","130","7.62","128","8392704" +"2020-03-01 19:47:50.493","130","7.621","128","8392704" +"2020-03-01 19:47:51.493","130","7.62","128","8392704" +"2020-03-01 19:47:52.493","130","7.619","128","8392704" +"2020-03-01 19:47:53.493","130","7.621","128","8392704" +"2020-03-01 19:47:54.493","130","7.622","128","8392704" +"2020-03-01 19:47:55.493","130","7.622","128","8392704" +"2020-03-01 19:47:56.493","130","7.62","128","8392704" +"2020-03-01 19:47:57.493","130","7.617","128","8392704" +"2020-03-01 19:47:58.493","130","7.616","128","8392704" +"2020-03-01 19:47:59.493","130","7.618","128","8392704" +"2020-03-01 19:48:00.493","130","7.62","128","8392704" +"2020-03-01 19:48:01.493","130","7.62","128","8392704" +"2020-03-01 19:48:02.493","130","7.616","128","8392704" +"2020-03-01 19:48:03.493","130","7.612","128","8392704" +"2020-03-01 19:48:04.493","130","7.609","128","8392704" +"2020-03-01 19:48:05.493","130","7.608","128","8392704" +"2020-03-01 19:48:06.493","130","7.605","128","8392704" +"2020-03-01 19:48:07.493","130","7.604","128","8392704" +"2020-03-01 19:48:08.493","130","7.605","128","8392704" +"2020-03-01 19:48:09.493","130","7.604","128","8392704" +"2020-03-01 19:48:10.493","130","7.604","128","8392704" +"2020-03-01 19:48:11.493","130","7.608","128","8392704" +"2020-03-01 19:48:12.493","130","7.611","128","8392704" +"2020-03-01 19:48:13.493","130","7.614","128","8392704" +"2020-03-01 19:48:14.493","130","7.616","128","8392704" +"2020-03-01 19:48:15.493","130","7.618","128","8392704" +"2020-03-01 19:48:16.493","130","7.62","128","8392704" +"2020-03-01 19:48:17.493","130","7.617","128","8392704" +"2020-03-01 19:48:18.493","130","7.61","128","8392704" +"2020-03-01 19:48:19.493","130","7.607","128","8392704" +"2020-03-01 19:48:20.493","130","7.604","128","8392704" +"2020-03-01 19:48:21.493","130","7.601","128","8392704" +"2020-03-01 19:48:22.493","130","7.601","128","8392704" +"2020-03-01 19:48:23.493","130","7.601","128","8392704" +"2020-03-01 19:48:24.493","130","7.598","128","8392704" +"2020-03-01 19:48:25.493","130","7.598","128","8392704" +"2020-03-01 19:48:26.493","130","7.604","128","8392704" +"2020-03-01 19:48:27.493","130","7.608","128","8392704" +"2020-03-01 19:48:28.493","130","7.609","128","8392704" +"2020-03-01 19:48:29.493","130","7.61","128","8392704" +"2020-03-01 19:48:30.493","130","7.611","128","8392704" +"2020-03-01 19:48:31.493","130","7.614","128","8392704" +"2020-03-01 19:48:32.493","130","7.614","128","8392704" +"2020-03-01 19:48:33.493","130","7.611","128","8392704" +"2020-03-01 19:48:34.493","130","7.607","128","8392704" +"2020-03-01 19:48:35.493","130","7.601","128","8392704" +"2020-03-01 19:48:36.493","130","7.596","128","8392704" +"2020-03-01 19:48:37.493","130","7.593","128","8392704" +"2020-03-01 19:48:38.493","130","7.593","128","8392704" +"2020-03-01 19:48:39.493","130","7.593","128","8392704" +"2020-03-01 19:48:40.493","130","7.595","128","8392704" +"2020-03-01 19:48:41.493","130","7.596","128","8392704" +"2020-03-01 19:48:42.493","130","7.599","128","8392704" +"2020-03-01 19:48:43.493","130","7.603","128","8392704" +"2020-03-01 19:48:44.493","130","7.605","128","8392704" +"2020-03-01 19:48:45.493","130","7.607","128","8392704" +"2020-03-01 19:48:46.493","130","7.608","128","8392704" +"2020-03-01 19:48:47.493","130","7.609","128","8392704" +"2020-03-01 19:48:48.493","130","7.61","128","8392704" +"2020-03-01 19:48:49.493","130","7.608","128","8392704" +"2020-03-01 19:48:50.493","130","7.605","128","8392704" +"2020-03-01 19:48:51.493","130","7.605","128","8392704" +"2020-03-01 19:48:52.493","130","7.607","128","8392704" +"2020-03-01 19:48:53.493","130","7.608","128","8392704" +"2020-03-01 19:48:54.493","130","7.608","128","8392704" +"2020-03-01 19:48:55.493","130","7.608","128","8392704" +"2020-03-01 19:48:56.493","130","7.61","128","8392704" +"2020-03-01 19:48:57.493","130","7.613","128","8392704" +"2020-03-01 19:48:58.493","130","7.612","128","8392704" +"2020-03-01 19:48:59.493","130","7.61","128","8392704" +"2020-03-01 19:49:00.493","130","7.609","128","8392704" +"2020-03-01 19:49:01.493","130","7.61","128","8392704" +"2020-03-01 19:49:02.493","130","7.611","128","8392704" +"2020-03-01 19:49:03.493","130","7.61","128","8392704" +"2020-03-01 19:49:04.493","130","7.61","128","8392704" +"2020-03-01 19:49:05.493","130","7.613","128","8392704" +"2020-03-01 19:49:06.493","130","7.615","128","8392704" +"2020-03-01 19:49:07.493","130","7.614","128","8392704" +"2020-03-01 19:49:08.493","130","7.613","128","8392704" +"2020-03-01 19:49:09.493","130","7.613","128","8392704" +"2020-03-01 19:49:10.493","130","7.615","128","8392704" +"2020-03-01 19:49:11.493","130","7.619","128","8392704" +"2020-03-01 19:49:12.493","130","7.62","128","8392704" +"2020-03-01 19:49:13.493","130","7.618","128","8392704" +"2020-03-01 19:49:14.493","130","7.619","128","8392704" +"2020-03-01 19:49:15.493","130","7.618","128","8392704" +"2020-03-01 19:49:16.493","130","7.617","128","8392704" +"2020-03-01 19:49:17.493","130","7.617","128","8392704" +"2020-03-01 19:49:18.493","130","7.618","128","8392704" +"2020-03-01 19:49:19.493","130","7.617","128","8392704" +"2020-03-01 19:49:20.493","130","7.616","128","8392704" +"2020-03-01 19:49:21.493","130","7.615","128","8392704" +"2020-03-01 19:49:22.493","130","7.616","128","8392704" +"2020-03-01 19:49:23.493","130","7.617","128","8392704" +"2020-03-01 19:49:24.493","130","7.615","128","8392704" +"2020-03-01 19:49:25.493","130","7.613","128","8392704" +"2020-03-01 19:49:26.493","130","7.612","128","8392704" +"2020-03-01 19:49:27.493","130","7.613","128","8392704" +"2020-03-01 19:49:28.493","130","7.614","128","8392704" +"2020-03-01 19:49:29.493","130","7.612","128","8392704" +"2020-03-01 19:49:30.493","130","7.611","128","8392704" +"2020-03-01 19:49:31.493","130","7.611","128","8392704" +"2020-03-01 19:49:32.493","130","7.612","128","8392704" +"2020-03-01 19:49:33.493","130","7.613","128","8392704" +"2020-03-01 19:49:34.493","130","7.614","128","8392704" +"2020-03-01 19:49:35.493","130","7.612","128","8392704" +"2020-03-01 19:49:36.493","130","7.607","128","8392704" +"2020-03-01 19:49:37.493","130","7.603","128","8392704" +"2020-03-01 19:49:38.493","130","7.599","128","8392704" +"2020-03-01 19:49:39.493","130","7.599","128","8392704" +"2020-03-01 19:49:40.493","130","7.599","128","8392704" +"2020-03-01 19:49:41.493","130","7.599","128","8392704" +"2020-03-01 19:49:42.493","130","7.601","128","8392704" +"2020-03-01 19:49:43.493","130","7.605","128","8392704" +"2020-03-01 19:49:44.493","130","7.606","128","8392704" +"2020-03-01 19:49:45.493","130","7.606","128","8392704" +"2020-03-01 19:49:46.493","130","7.606","128","8392704" +"2020-03-01 19:49:47.493","130","7.604","128","8392704" +"2020-03-01 19:49:48.493","130","7.604","128","8392704" +"2020-03-01 19:49:49.493","130","7.603","128","8392704" +"2020-03-01 19:49:50.493","130","7.604","128","8392704" +"2020-03-01 19:49:51.493","130","7.608","128","8392704" +"2020-03-01 19:49:52.493","130","7.614","128","8392704" +"2020-03-01 19:49:53.493","130","7.618","128","8392704" +"2020-03-01 19:49:54.493","130","7.621","128","8392704" +"2020-03-01 19:49:55.493","130","7.623","128","8392704" +"2020-03-01 19:49:56.493","130","7.623","128","8392704" +"2020-03-01 19:49:57.493","130","7.624","128","8392704" +"2020-03-01 19:49:58.493","130","7.626","128","8392704" +"2020-03-01 19:49:59.493","130","7.628","128","8392704" +"2020-03-01 19:50:00.493","130","7.627","128","8392704" +"2020-03-01 19:50:01.493","130","7.625","128","8392704" +"2020-03-01 19:50:02.493","130","7.627","128","8392704" +"2020-03-01 19:50:03.493","130","7.63","128","8392704" +"2020-03-01 19:50:04.493","130","7.633","128","8392704" +"2020-03-01 19:50:05.493","130","7.635","128","8392704" +"2020-03-01 19:50:06.493","130","7.634","128","8392704" +"2020-03-01 19:50:07.493","130","7.632","128","8392704" +"2020-03-01 19:50:08.493","130","7.628","128","8392704" +"2020-03-01 19:50:09.493","130","7.625","128","8392704" +"2020-03-01 19:50:10.493","130","7.625","128","8392704" +"2020-03-01 19:50:11.493","130","7.623","128","8392704" +"2020-03-01 19:50:12.493","130","7.623","128","8392704" +"2020-03-01 19:50:13.493","130","7.623","128","8392704" +"2020-03-01 19:50:14.493","130","7.622","128","8392704" +"2020-03-01 19:50:15.493","130","7.621","128","8392704" +"2020-03-01 19:50:16.493","130","7.618","128","8392704" +"2020-03-01 19:50:17.493","130","7.618","128","8392704" +"2020-03-01 19:50:18.493","130","7.617","128","8392704" +"2020-03-01 19:50:19.493","130","7.616","128","8392704" +"2020-03-01 19:50:20.493","130","7.615","128","8392704" +"2020-03-01 19:50:21.493","130","7.615","128","8392704" +"2020-03-01 19:50:22.493","130","7.616","128","8392704" +"2020-03-01 19:50:23.493","130","7.619","128","8392704" +"2020-03-01 19:50:24.493","130","7.622","128","8392704" +"2020-03-01 19:50:25.493","130","7.624","128","8392704" +"2020-03-01 19:50:26.493","130","7.627","128","8392704" +"2020-03-01 19:50:27.493","130","7.627","128","8392704" +"2020-03-01 19:50:28.493","130","7.625","128","8392704" +"2020-03-01 19:50:29.493","130","7.625","128","8392704" +"2020-03-01 19:50:30.493","130","7.625","128","8392704" +"2020-03-01 19:50:31.493","130","7.624","128","8392704" +"2020-03-01 19:50:32.493","130","7.624","128","8392704" +"2020-03-01 19:50:33.493","130","7.624","128","8392704" +"2020-03-01 19:50:34.493","130","7.626","128","8392704" +"2020-03-01 19:50:35.493","130","7.627","128","8392704" +"2020-03-01 19:50:36.493","130","7.627","128","8392704" +"2020-03-01 19:50:37.493","130","7.626","128","8392704" +"2020-03-01 19:50:38.493","130","7.623","128","8392704" +"2020-03-01 19:50:39.493","130","7.619","128","8392704" +"2020-03-01 19:50:40.493","130","7.616","128","8392704" +"2020-03-01 19:50:41.493","130","7.616","128","8392704" +"2020-03-01 19:50:42.493","130","7.615","128","8392704" +"2020-03-01 19:50:43.493","130","7.613","128","8392704" +"2020-03-01 19:50:44.493","130","7.614","128","8392704" +"2020-03-01 19:50:45.493","130","7.614","128","8392704" +"2020-03-01 19:50:46.493","130","7.612","128","8392704" +"2020-03-01 19:50:47.493","130","7.611","128","8392704" +"2020-03-01 19:50:48.493","130","7.611","128","8392704" +"2020-03-01 19:50:49.493","130","7.611","128","8392704" +"2020-03-01 19:50:50.493","130","7.612","128","8392704" +"2020-03-01 19:50:51.493","130","7.613","128","8392704" +"2020-03-01 19:50:52.493","130","7.613","128","8392704" +"2020-03-01 19:50:53.493","130","7.615","128","8392704" +"2020-03-01 19:50:54.493","130","7.617","128","8392704" +"2020-03-01 19:50:55.493","130","7.617","128","8392704" +"2020-03-01 19:50:56.493","130","7.619","128","8392704" +"2020-03-01 19:50:57.493","130","7.622","128","8392704" +"2020-03-01 19:50:58.493","130","7.624","128","8392704" +"2020-03-01 19:50:59.493","130","7.625","128","8392704" +"2020-03-01 19:51:00.493","130","7.624","128","8392704" +"2020-03-01 19:51:01.493","130","7.624","128","8392704" +"2020-03-01 19:51:02.493","130","7.622","128","8392704" +"2020-03-01 19:51:03.493","130","7.62","128","8392704" +"2020-03-01 19:51:04.493","130","7.617","128","8392704" +"2020-03-01 19:51:05.493","130","7.617","128","8392704" +"2020-03-01 19:51:06.493","130","7.618","128","8392704" +"2020-03-01 19:51:07.493","130","7.618","128","8392704" +"2020-03-01 19:51:08.493","130","7.618","128","8392704" +"2020-03-01 19:51:09.493","130","7.62","128","8392704" +"2020-03-01 19:51:10.493","130","7.622","128","8392704" +"2020-03-01 19:51:11.493","130","7.623","128","8392704" +"2020-03-01 19:51:12.493","130","7.624","128","8392704" +"2020-03-01 19:51:13.493","130","7.625","128","8392704" +"2020-03-01 19:51:14.493","130","7.626","128","8392704" +"2020-03-01 19:51:15.493","130","7.626","128","8392704" +"2020-03-01 19:51:16.493","130","7.626","128","8392704" +"2020-03-01 19:51:17.493","130","7.627","128","8392704" +"2020-03-01 19:51:18.493","130","7.627","128","8392704" +"2020-03-01 19:51:19.493","130","7.629","128","8392704" +"2020-03-01 19:51:20.493","130","7.629","128","8392704" +"2020-03-01 19:51:21.493","130","7.626","128","8392704" +"2020-03-01 19:51:22.493","130","7.625","128","8392704" +"2020-03-01 19:51:23.493","130","7.625","128","8392704" +"2020-03-01 19:51:24.493","130","7.626","128","8392704" +"2020-03-01 19:51:25.493","130","7.626","128","8392704" +"2020-03-01 19:51:26.493","130","7.624","128","8392704" +"2020-03-01 19:51:27.493","130","7.623","128","8392704" +"2020-03-01 19:51:28.493","130","7.624","128","8392704" +"2020-03-01 19:51:29.493","130","7.624","128","8392704" +"2020-03-01 19:51:30.493","130","7.624","128","8392704" +"2020-03-01 19:51:31.493","130","7.624","128","8392704" +"2020-03-01 19:51:32.493","130","7.626","128","8392704" +"2020-03-01 19:51:33.493","130","7.626","128","8392704" +"2020-03-01 19:51:34.493","130","7.626","128","8392704" +"2020-03-01 19:51:35.493","130","7.625","128","8392704" +"2020-03-01 19:51:36.493","130","7.624","128","8392704" +"2020-03-01 19:51:37.493","130","7.623","128","8392704" +"2020-03-01 19:51:38.493","130","7.622","128","8392704" +"2020-03-01 19:51:39.493","130","7.62","128","8392704" +"2020-03-01 19:51:40.493","130","7.62","128","8392704" +"2020-03-01 19:51:41.493","130","7.62","128","8392704" +"2020-03-01 19:51:42.493","130","7.621","128","8392704" +"2020-03-01 19:51:43.493","130","7.62","128","8392704" +"2020-03-01 19:51:44.493","130","7.619","128","8392704" +"2020-03-01 19:51:45.493","130","7.62","128","8392704" +"2020-03-01 19:51:46.493","130","7.62","128","8392704" +"2020-03-01 19:51:47.493","130","7.618","128","8392704" +"2020-03-01 19:51:48.493","130","7.619","128","8392704" +"2020-03-01 19:51:49.493","130","7.62","128","8392704" +"2020-03-01 19:51:50.493","130","7.622","128","8392704" +"2020-03-01 19:51:51.493","130","7.622","128","8392704" +"2020-03-01 19:51:52.493","130","7.62","128","8392704" +"2020-03-01 19:51:53.493","130","7.62","128","8392704" +"2020-03-01 19:51:54.493","130","7.622","128","8392704" +"2020-03-01 19:51:55.493","130","7.624","128","8392704" +"2020-03-01 19:51:56.493","130","7.622","128","8392704" +"2020-03-01 19:51:57.493","130","7.616","128","8392704" +"2020-03-01 19:51:58.493","130","7.611","128","8392704" +"2020-03-01 19:51:59.493","130","7.61","128","8392704" +"2020-03-01 19:52:00.493","130","7.608","128","8392704" +"2020-03-01 19:52:01.493","130","7.606","128","8392704" +"2020-03-01 19:52:02.493","130","7.607","128","8392704" +"2020-03-01 19:52:03.493","130","7.608","128","8392704" +"2020-03-01 19:52:04.493","130","7.61","128","8392704" +"2020-03-01 19:52:05.493","130","7.612","128","8392704" +"2020-03-01 19:52:06.493","130","7.615","128","8392704" +"2020-03-01 19:52:07.493","130","7.62","128","8392704" +"2020-03-01 19:52:08.493","130","7.623","128","8392704" +"2020-03-01 19:52:09.493","130","7.624","128","8392704" +"2020-03-01 19:52:10.493","130","7.623","128","8392704" +"2020-03-01 19:52:11.493","130","7.623","128","8392704" +"2020-03-01 19:52:12.493","130","7.624","128","8392704" +"2020-03-01 19:52:13.493","130","7.622","128","8392704" +"2020-03-01 19:52:14.493","130","7.62","128","8392704" +"2020-03-01 19:52:15.493","130","7.621","128","8392704" +"2020-03-01 19:52:16.493","130","7.62","128","8392704" +"2020-03-01 19:52:17.493","130","7.622","128","8392704" +"2020-03-01 19:52:18.493","130","7.625","128","8392704" +"2020-03-01 19:52:19.493","130","7.627","128","8392704" +"2020-03-01 19:52:20.493","130","7.625","128","8392704" +"2020-03-01 19:52:21.493","130","7.621","128","8392704" +"2020-03-01 19:52:22.493","130","7.617","128","8392704" +"2020-03-01 19:52:23.493","130","7.617","128","8392704" +"2020-03-01 19:52:24.493","130","7.617","128","8392704" +"2020-03-01 19:52:25.493","130","7.616","128","8392704" +"2020-03-01 19:52:26.493","130","7.615","128","8392704" +"2020-03-01 19:52:27.493","130","7.616","128","8392704" +"2020-03-01 19:52:28.493","130","7.619","128","8392704" +"2020-03-01 19:52:29.493","130","7.621","128","8392704" +"2020-03-01 19:52:30.493","130","7.621","128","8392704" +"2020-03-01 19:52:31.493","130","7.621","128","8392704" +"2020-03-01 19:52:32.493","130","7.621","128","8392704" +"2020-03-01 19:52:33.493","130","7.621","128","8392704" +"2020-03-01 19:52:34.493","130","7.623","128","8392704" +"2020-03-01 19:52:35.493","130","7.621","128","8392704" +"2020-03-01 19:52:36.493","130","7.617","128","8392704" +"2020-03-01 19:52:37.493","130","7.615","128","8392704" +"2020-03-01 19:52:38.493","130","7.612","128","8392704" +"2020-03-01 19:52:39.493","130","7.609","128","8392704" +"2020-03-01 19:52:40.493","130","7.606","128","8392704" +"2020-03-01 19:52:41.493","130","7.606","128","8392704" +"2020-03-01 19:52:42.493","130","7.609","128","8392704" +"2020-03-01 19:52:43.493","130","7.612","128","8392704" +"2020-03-01 19:52:44.493","130","7.616","128","8392704" +"2020-03-01 19:52:45.493","130","7.619","128","8392704" +"2020-03-01 19:52:46.493","130","7.62","128","8392704" +"2020-03-01 19:52:47.493","130","7.622","128","8392704" +"2020-03-01 19:52:48.493","130","7.622","128","8392704" +"2020-03-01 19:52:49.493","130","7.621","128","8392704" +"2020-03-01 19:52:50.493","130","7.618","128","8392704" +"2020-03-01 19:52:51.493","130","7.616","128","8392704" +"2020-03-01 19:52:52.493","130","7.613","128","8392704" +"2020-03-01 19:52:53.493","130","7.612","128","8392704" +"2020-03-01 19:52:54.493","130","7.612","128","8392704" +"2020-03-01 19:52:55.493","130","7.611","128","8392704" +"2020-03-01 19:52:56.493","130","7.609","128","8392704" +"2020-03-01 19:52:57.493","130","7.608","128","8392704" +"2020-03-01 19:52:58.493","130","7.609","128","8392704" +"2020-03-01 19:52:59.493","130","7.611","128","8392704" +"2020-03-01 19:53:00.493","130","7.612","128","8392704" +"2020-03-01 19:53:01.493","130","7.614","128","8392704" +"2020-03-01 19:53:02.493","130","7.618","128","8392704" +"2020-03-01 19:53:03.493","130","7.62","128","8392704" +"2020-03-01 19:53:04.493","130","7.62","128","8392704" +"2020-03-01 19:53:05.493","130","7.62","128","8392704" +"2020-03-01 19:53:06.493","130","7.619","128","8392704" +"2020-03-01 19:53:07.493","130","7.617","128","8392704" +"2020-03-01 19:53:08.493","130","7.615","128","8392704" +"2020-03-01 19:53:09.493","130","7.612","128","8392704" +"2020-03-01 19:53:10.493","130","7.61","128","8392704" +"2020-03-01 19:53:11.493","130","7.609","128","8392704" +"2020-03-01 19:53:12.493","130","7.608","128","8392704" +"2020-03-01 19:53:13.493","130","7.61","128","8392704" +"2020-03-01 19:53:14.493","130","7.611","128","8392704" +"2020-03-01 19:53:15.493","130","7.609","128","8392704" +"2020-03-01 19:53:16.493","130","7.608","128","8392704" +"2020-03-01 19:53:17.493","130","7.608","128","8392704" +"2020-03-01 19:53:18.493","130","7.607","128","8392704" +"2020-03-01 19:53:19.493","130","7.607","128","8392704" +"2020-03-01 19:53:20.493","130","7.605","128","8392704" +"2020-03-01 19:53:21.493","130","7.603","128","8392704" +"2020-03-01 19:53:22.493","130","7.606","128","8392704" +"2020-03-01 19:53:23.493","130","7.611","128","8392704" +"2020-03-01 19:53:24.493","130","7.615","128","8392704" +"2020-03-01 19:53:25.493","130","7.618","128","8392704" +"2020-03-01 19:53:26.493","130","7.62","128","8392704" +"2020-03-01 19:53:27.493","130","7.622","128","8392704" +"2020-03-01 19:53:28.493","130","7.624","128","8392704" +"2020-03-01 19:53:29.493","130","7.626","128","8392704" +"2020-03-01 19:53:30.493","130","7.624","128","8392704" +"2020-03-01 19:53:31.493","130","7.617","128","8392704" +"2020-03-01 19:53:32.493","130","7.613","128","8392704" +"2020-03-01 19:53:33.493","130","7.613","128","8392704" +"2020-03-01 19:53:34.493","130","7.613","128","8392704" +"2020-03-01 19:53:35.493","130","7.61","128","8392704" +"2020-03-01 19:53:36.493","130","7.609","128","8392704" +"2020-03-01 19:53:37.493","130","7.611","128","8392704" +"2020-03-01 19:53:38.493","130","7.61","128","8392704" +"2020-03-01 19:53:39.493","130","7.609","128","8392704" +"2020-03-01 19:53:40.493","130","7.608","128","8392704" +"2020-03-01 19:53:41.493","130","7.605","128","8392704" +"2020-03-01 19:53:42.493","130","7.601","128","8392704" +"2020-03-01 19:53:43.493","130","7.6","128","8392704" +"2020-03-01 19:53:44.493","130","7.602","128","8392704" +"2020-03-01 19:53:45.493","130","7.604","128","8392704" +"2020-03-01 19:53:46.493","130","7.605","128","8392704" +"2020-03-01 19:53:47.493","130","7.606","128","8392704" +"2020-03-01 19:53:48.493","130","7.605","128","8392704" +"2020-03-01 19:53:49.493","130","7.605","128","8392704" +"2020-03-01 19:53:50.493","130","7.606","128","8392704" +"2020-03-01 19:53:51.493","130","7.606","128","8392704" +"2020-03-01 19:53:52.493","130","7.604","128","8392704" +"2020-03-01 19:53:53.493","130","7.606","128","8392704" +"2020-03-01 19:53:54.493","130","7.61","128","8392704" +"2020-03-01 19:53:55.493","130","7.612","128","8392704" +"2020-03-01 19:53:56.493","130","7.613","128","8392704" +"2020-03-01 19:53:57.493","130","7.613","128","8392704" +"2020-03-01 19:53:58.493","130","7.613","128","8392704" +"2020-03-01 19:53:59.493","130","7.615","128","8392704" +"2020-03-01 19:54:00.493","130","7.616","128","8392704" +"2020-03-01 19:54:01.493","130","7.616","128","8392704" +"2020-03-01 19:54:02.493","130","7.618","128","8392704" +"2020-03-01 19:54:03.493","130","7.621","128","8392704" +"2020-03-01 19:54:04.493","130","7.623","128","8392704" +"2020-03-01 19:54:05.493","130","7.623","128","8392704" +"2020-03-01 19:54:06.493","130","7.624","128","8392704" +"2020-03-01 19:54:07.493","130","7.624","128","8392704" +"2020-03-01 19:54:08.493","130","7.622","128","8392704" +"2020-03-01 19:54:09.493","130","7.62","128","8392704" +"2020-03-01 19:54:10.493","130","7.621","128","8392704" +"2020-03-01 19:54:11.493","130","7.62","128","8392704" +"2020-03-01 19:54:12.493","130","7.617","128","8392704" +"2020-03-01 19:54:13.493","130","7.617","128","8392704" +"2020-03-01 19:54:14.493","130","7.618","128","8392704" +"2020-03-01 19:54:15.493","130","7.617","128","8392704" +"2020-03-01 19:54:16.493","130","7.615","128","8392704" +"2020-03-01 19:54:17.493","130","7.613","128","8392704" +"2020-03-01 19:54:18.493","130","7.612","128","8392704" +"2020-03-01 19:54:19.493","130","7.609","128","8392704" +"2020-03-01 19:54:20.493","130","7.605","128","8392704" +"2020-03-01 19:54:21.493","130","7.604","128","8392704" +"2020-03-01 19:54:22.493","130","7.605","128","8392704" +"2020-03-01 19:54:23.493","130","7.608","128","8392704" +"2020-03-01 19:54:24.493","130","7.611","128","8392704" +"2020-03-01 19:54:25.493","130","7.613","128","8392704" +"2020-03-01 19:54:26.493","130","7.613","128","8392704" +"2020-03-01 19:54:27.493","130","7.611","128","8392704" +"2020-03-01 19:54:28.493","130","7.611","128","8392704" +"2020-03-01 19:54:29.493","130","7.611","128","8392704" +"2020-03-01 19:54:30.493","130","7.612","128","8392704" +"2020-03-01 19:54:31.493","130","7.614","128","8392704" +"2020-03-01 19:54:32.493","130","7.61","128","8392704" +"2020-03-01 19:54:33.493","130","7.603","128","8392704" +"2020-03-01 19:54:34.493","130","7.598","128","8392704" +"2020-03-01 19:54:35.493","130","7.594","128","8392704" +"2020-03-01 19:54:36.493","130","7.591","128","8392704" +"2020-03-01 19:54:37.493","130","7.591","128","8392704" +"2020-03-01 19:54:38.493","130","7.59","128","8392704" +"2020-03-01 19:54:39.493","130","7.588","128","8392704" +"2020-03-01 19:54:40.493","130","7.593","128","8392704" +"2020-03-01 19:54:41.493","130","7.599","128","8392704" +"2020-03-01 19:54:42.493","130","7.602","128","8392704" +"2020-03-01 19:54:43.493","130","7.604","128","8392704" +"2020-03-01 19:54:44.493","130","7.606","128","8392704" +"2020-03-01 19:54:45.493","130","7.609","128","8392704" +"2020-03-01 19:54:46.493","130","7.612","128","8392704" +"2020-03-01 19:54:47.493","130","7.614","128","8392704" +"2020-03-01 19:54:48.493","130","7.616","128","8392704" +"2020-03-01 19:54:49.493","130","7.617","128","8392704" +"2020-03-01 19:54:50.493","130","7.619","128","8392704" +"2020-03-01 19:54:51.493","130","7.623","128","8392704" +"2020-03-01 19:54:52.493","130","7.626","128","8392704" +"2020-03-01 19:54:53.493","130","7.626","128","8392704" +"2020-03-01 19:54:54.493","130","7.624","128","8392704" +"2020-03-01 19:54:55.493","130","7.623","128","8392704" +"2020-03-01 19:54:56.493","130","7.618","128","8392704" +"2020-03-01 19:54:57.493","130","7.613","128","8392704" +"2020-03-01 19:54:58.493","130","7.61","128","8392704" +"2020-03-01 19:54:59.493","130","7.605","128","8392704" +"2020-03-01 19:55:00.493","130","7.604","128","8392704" +"2020-03-01 19:55:01.493","130","7.603","128","8392704" +"2020-03-01 19:55:02.493","130","7.602","128","8392704" +"2020-03-01 19:55:03.493","130","7.602","128","8392704" +"2020-03-01 19:55:04.493","130","7.602","128","8392704" +"2020-03-01 19:55:05.493","130","7.603","128","8392704" +"2020-03-01 19:55:06.493","130","7.608","128","8392704" +"2020-03-01 19:55:07.493","130","7.609","128","8392704" +"2020-03-01 19:55:08.493","130","7.608","128","8392704" +"2020-03-01 19:55:09.493","130","7.609","128","8392704" \ No newline at end of file diff --git a/tests/pytest/tools/insert-interlace.json b/tests/pytest/tools/insert-interlace.json new file mode 100644 index 0000000000000000000000000000000000000000..cd72958115aa38280c028c0f0e91443d62f692a4 --- /dev/null +++ b/tests/pytest/tools/insert-interlace.json @@ -0,0 +1,57 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 5000, + "interlace_rows": 50, + "num_of_records_per_req": 100, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb", + "child_table_exists":"no", + "childtable_count": 9, + "childtable_prefix": "stb_", + "auto_create_table": "no", + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 250, + "interlace_rows": 80, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "INT", "count":1}] + }] + }] +} diff --git a/tests/pytest/tools/insert-tblimit-tboffset-createdb.json b/tests/pytest/tools/insert-tblimit-tboffset-createdb.json new file mode 100644 index 0000000000000000000000000000000000000000..025751bcd3c2d0800d6a02f62adb76d15b8b0131 --- /dev/null +++ b/tests/pytest/tools/insert-tblimit-tboffset-createdb.json @@ -0,0 +1,55 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "num_of_records_per_req": 100, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "stb_", + "auto_create_table": "no", + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":10}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/insert-tblimit-tboffset-insertrec.json b/tests/pytest/tools/insert-tblimit-tboffset-insertrec.json new file mode 100644 index 0000000000000000000000000000000000000000..6fa020433a05f8f989638357c9874fe8843dfe34 --- /dev/null +++ b/tests/pytest/tools/insert-tblimit-tboffset-insertrec.json @@ -0,0 +1,57 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "num_of_records_per_req": 100, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "no", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb", + "child_table_exists":"yes", + "childtable_count": 100, + "childtable_prefix": "stb_", + "auto_create_table": "no", + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 1000, + "childtable_limit": 33, + "childtable_offset": 33, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":10}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/insert-tblimit-tboffset.json b/tests/pytest/tools/insert-tblimit-tboffset.json new file mode 100644 index 0000000000000000000000000000000000000000..b4d4016ef926d64f85df9a85bfb75352caf2442e --- /dev/null +++ b/tests/pytest/tools/insert-tblimit-tboffset.json @@ -0,0 +1,57 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "num_of_records_per_req": 100, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "stb_", + "auto_create_table": "no", + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 1000, + "childtable_limit": 33, + "childtable_offset": 33, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":10}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/insert-tblimit-tboffset0.json b/tests/pytest/tools/insert-tblimit-tboffset0.json new file mode 100644 index 0000000000000000000000000000000000000000..8a7e39b17c13387e00167396d21a0c791601e390 --- /dev/null +++ b/tests/pytest/tools/insert-tblimit-tboffset0.json @@ -0,0 +1,57 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "num_of_records_per_req": 100, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "no", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb", + "child_table_exists":"yes", + "childtable_count": 100, + "childtable_prefix": "stb_", + "auto_create_table": "no", + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 1000, + "childtable_limit": 20, + "childtable_offset": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":10}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/insert-tblimit1-tboffset.json b/tests/pytest/tools/insert-tblimit1-tboffset.json new file mode 100644 index 0000000000000000000000000000000000000000..6e150203b3103eabc546f772ed9aad73ae879207 --- /dev/null +++ b/tests/pytest/tools/insert-tblimit1-tboffset.json @@ -0,0 +1,57 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "num_of_records_per_req": 100, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "no", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb", + "child_table_exists":"yes", + "childtable_count": 100, + "childtable_prefix": "stb_", + "auto_create_table": "no", + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 1000, + "childtable_limit": 1, + "childtable_offset": 50, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "TINYINT", "count":1}] + }] + }] +} diff --git a/tests/pytest/tools/insert.json b/tests/pytest/tools/insert.json new file mode 100644 index 0000000000000000000000000000000000000000..996b91ed06f283fdcd968df9cafc4f58583cbb8d --- /dev/null +++ b/tests/pytest/tools/insert.json @@ -0,0 +1,45 @@ +{ + "filetype":"insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 2, + "num_of_records_per_req": 10, + "thread_count_create_tbl": 4, + "databases": [{ + "dbinfo": { + "name": "db01", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "update": 0, + "maxtablesPerVnode": 1000 + }, + "super_tables": [{ + "name": "stb01", + "childtable_count": 3, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "data_source": "rand", + "insert_mode": "taosc", + "insert_rate": 0, + "insert_rows": 20, + "timestamp_step": 1000, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "/home/data/sample.csv", + "tags_file": "", + "columns": [{ + "type": "INT" + }], + "tags": [{ + "type": "INT" + }] + }] + }] +} diff --git a/tests/pytest/tools/query.json b/tests/pytest/tools/query.json new file mode 100644 index 0000000000000000000000000000000000000000..d486423865a7a21bdd4817b9b514131942806777 --- /dev/null +++ b/tests/pytest/tools/query.json @@ -0,0 +1,22 @@ +{ + "filetype": "query", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "confirm_parameter_prompt": "no", + "databases": "test", + "query_times": 1, + "super_table_query": { + "stblname": "meters", + "query_interval": 10, + "threads": 8, + "sqls": [ + { + "sql": "select last_row(ts) from xxxx", + "result": "" + } + ] + } +} diff --git a/tests/pytest/tools/sampledata.csv b/tests/pytest/tools/sampledata.csv new file mode 100644 index 0000000000000000000000000000000000000000..01e79c32a8c99c557f0757da7cb6d65b3414466d --- /dev/null +++ b/tests/pytest/tools/sampledata.csv @@ -0,0 +1,3 @@ +1 +2 +3 diff --git a/tests/pytest/tools/schemalessInsertPerformance.py b/tests/pytest/tools/schemalessInsertPerformance.py new file mode 100644 index 0000000000000000000000000000000000000000..14a9a21081dd96b8a48a5010f24abfcccec03b57 --- /dev/null +++ b/tests/pytest/tools/schemalessInsertPerformance.py @@ -0,0 +1,269 @@ +################################################################### +# Copyright (c) 2021 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import random +import time +from copy import deepcopy +from util.log import * +from util.cases import * +from util.sql import * +from util.common import tdCom +import threading +import itertools +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self._conn = conn + self.lock = threading.Lock() + + def genMultiColStr(self, int_count=4, double_count=0, binary_count=0): + ''' + related to self.getPerfSql() + :count = 4 ---> 4 int + :count = 1000 ---> 400 int 400 double 200 binary(128) + :count = 4000 ---> 1900 int 1900 double 200 binary(128) + ''' + col_str = "" + if double_count == 0 and binary_count == 0: + for i in range(0, int_count): + if i < (int_count-1): + col_str += f'c{i}={random.randint(0, 255)}i32,' + else: + col_str += f'c{i}={random.randint(0, 255)}i32 ' + elif double_count > 0 and binary_count == 0: + for i in range(0, int_count): + col_str += f'c{i}={random.randint(0, 255)}i32,' + for i in range(0, double_count): + if i < (double_count-1): + col_str += f'c{i+int_count}={random.randint(1, 255)}.{i}f64,' + else: + col_str += f'c{i+int_count}={random.randint(1, 255)}.{i}f64 ' + elif double_count == 0 and binary_count > 0: + for i in range(0, int_count): + col_str += f'c{i}={random.randint(0, 255)}i32,' + for i in range(0, binary_count): + if i < (binary_count-1): + col_str += f'c{i+int_count}=\"{tdCom.getLongName(5, "letters")}\",' + else: + col_str += f'c{i+int_count}=\"{tdCom.getLongName(5, "letters")}\" ' + elif double_count > 0 and binary_count > 0: + for i in range(0, int_count): + col_str += f'c{i}={random.randint(0, 255)}i32,' + for i in range(0, double_count): + col_str += f'c{i+int_count}={random.randint(1, 255)}.{i}f64,' + for i in range(0, binary_count): + if i < (binary_count-1): + col_str += f'c{i+int_count+double_count}=\"{tdCom.getLongName(5, "letters")}\",' + else: + col_str += f'c{i+int_count+double_count}=\"{tdCom.getLongName(5, "letters")}\" ' + return col_str + + def genLongSql(self, int_count=4, double_count=0, binary_count=0, init=False): + ''' + :init ---> stb insert line + ''' + if init: + tag_str = f'id="init",t0={random.randint(0, 65535)}i32,t1=\"{tdCom.getLongName(10, "letters")}\"' + else: + tag_str = f'id="sub_{tdCom.getLongName(5, "letters")}_{tdCom.getLongName(5, "letters")}",t0={random.randint(0, 65535)}i32,t1=\"{tdCom.getLongName(10, "letters")}\"' + col_str = self.genMultiColStr(int_count=int_count, double_count=double_count, binary_count=binary_count) + long_sql = 'stb' + ',' + tag_str + ' ' + col_str + '0' + return long_sql + + def getPerfSql(self, count=4, init=False): + ''' + :count = 4 ---> 4 int + :count = 1000 ---> 400 int 400 double 200 binary(128) + :count = 4000 ---> 1900 int 1900 double 200 binary(128) + ''' + if count == 4: + input_sql = self.genLongSql(init=init) + elif count == 1000: + input_sql = self.genLongSql(400, 400, 200, init=init) + elif count == 4000: + input_sql = self.genLongSql(1900, 1900, 200, init=init) + return input_sql + + def replaceLastStr(self, str, new): + ''' + replace last element of str to new element + ''' + list_ori = list(str) + list_ori[-1] = new + return ''.join(list_ori) + + def createStb(self, count=4): + ''' + create 1 stb + ''' + input_sql = self.getPerfSql(count=count, init=True) + print(threading.current_thread().name, "create stb line:", input_sql) + self._conn.insert_lines([input_sql]) + print(threading.current_thread().name, "create stb end") + + def batchCreateTable(self, batch_list): + ''' + schemaless insert api + ''' + print(threading.current_thread().name, "length=", len(batch_list)) + print(threading.current_thread().name, 'firstline', batch_list[0][0:50], '...', batch_list[0][-50:-1]) + print(threading.current_thread().name, 'lastline:', batch_list[-1][0:50], '...', batch_list[-1][-50:-1]) + begin = time.time_ns(); + self._conn.insert_lines(batch_list) + end = time.time_ns(); + print(threading.current_thread().name, 'end time:', (end-begin)/10**9) + + def splitGenerator(self, table_list, thread_count): + ''' + split a list to n piece of sub_list + [a, b, c, d] ---> [[a, b], [c, d]] + yield type ---> generator + ''' + sub_list_len = int(len(table_list)/thread_count) + for i in range(0, len(table_list), sub_list_len): + yield table_list[i:i + sub_list_len] + + def genTbListGenerator(self, table_list, thread_count): + ''' + split table_list, after split + ''' + table_list_generator = self.splitGenerator(table_list, thread_count) + return table_list_generator + + def genTableList(self, count=4, table_count=10000): + ''' + gen len(table_count) table_list + ''' + table_list = list() + for i in range(table_count): + table_list.append(self.getPerfSql(count=count)) + return table_list + + def threadCreateTables(self, table_list_generator, thread_count=10): + ''' + thread create tables + ''' + threads = list() + for i in range(thread_count): + t = threading.Thread(target=self.batchCreateTable, args=(next(table_list_generator),)) + threads.append(t) + return threads + + def batchInsertRows(self, table_list, rows_count): + ''' + add rows in each table ---> count=rows_count + ''' + for input_sql in table_list: + ts = int(time.time()) + input_sql_list = list() + for i in range(rows_count-1): + ts -= 1 + elm_new = self.replaceLastStr(input_sql, str(ts)) + 's' + input_sql_list.append(elm_new) + self.batchCreateTable(input_sql_list) + + def threadsInsertRows(self, rows_generator, rows_count=1000, thread_count=10): + ''' + multi insert rows in each table + ''' + threads = list() + for i in range(thread_count): + self.lock.acquire() + t = threading.Thread(target=self.batchInsertRows, args=(next(rows_generator), rows_count,)) + threads.append(t) + self.lock.release() + return threads + + def multiThreadRun(self, threads): + ''' + multi run threads + ''' + for t in threads: + t.start() + for t in threads: + t.join() + + def createTables(self, count, table_count=10000, thread_count=10): + ''' + create stb and tb + ''' + table_list = self.genTableList(count=count, table_count=table_count) + create_tables_start_time = time.time() + self.createStb(count=count) + table_list_generator = self.genTbListGenerator(table_list, thread_count) + create_tables_generator, insert_rows_generator = itertools.tee(table_list_generator, 2) + self.multiThreadRun(self.threadCreateTables(table_list_generator=create_tables_generator, thread_count=thread_count)) + create_tables_end_time = time.time() + create_tables_time = int(create_tables_end_time - create_tables_start_time) + return_str = f'create tables\' time of {count} columns ---> {create_tables_time}s' + return insert_rows_generator, create_tables_time, return_str + + def insertRows(self, count, rows_generator, rows_count=1000, thread_count=10): + ''' + insert rows + ''' + insert_rows_start_time = time.time() + self.multiThreadRun(self.threadsInsertRows(rows_generator=rows_generator, rows_count=rows_count, thread_count=thread_count)) + insert_rows_end_time = time.time() + insert_rows_time = int(insert_rows_end_time - insert_rows_start_time) + return_str = f'insert rows\' time of {count} columns ---> {insert_rows_time}s' + return insert_rows_time, return_str + + def schemalessPerfTest(self, count, table_count=10000, thread_count=10, rows_count=1000): + ''' + get performance + ''' + insert_rows_generator = self.createTables(count=count, table_count=table_count, thread_count=thread_count)[0] + return self.insertRows(count=count, rows_generator=insert_rows_generator, rows_count=rows_count, thread_count=thread_count) + + def getPerfResults(self, test_times=3, table_count=10000, thread_count=10): + col4_time = 0 + col1000_time = 0 + col4000_time = 0 + + for i in range(test_times): + tdCom.cleanTb() + time_used = self.schemalessPerfTest(count=4, table_count=table_count, thread_count=thread_count)[0] + col4_time += time_used + col4_time /= test_times + print(col4_time) + + # for i in range(test_times): + # tdCom.cleanTb() + # time_used = self.schemalessPerfTest(count=1000, table_count=table_count, thread_count=thread_count)[0] + # col1000_time += time_used + # col1000_time /= test_times + # print(col1000_time) + + # for i in range(test_times): + # tdCom.cleanTb() + # time_used = self.schemalessPerfTest(count=4000, table_count=table_count, thread_count=thread_count)[0] + # col4000_time += time_used + # col4000_time /= test_times + # print(col4000_time) + + return col4_time, col1000_time, col4000_time + + def run(self): + print("running {}".format(__file__)) + tdSql.prepare() + result = self.getPerfResults(test_times=1, table_count=1000, thread_count=10) + print(result) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemo-sampledata.json b/tests/pytest/tools/taosdemo-sampledata.json new file mode 100644 index 0000000000000000000000000000000000000000..ce1c68b3939e3905fcfba8924e25f6b09bdd53f6 --- /dev/null +++ b/tests/pytest/tools/taosdemo-sampledata.json @@ -0,0 +1,35 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 10, + "confirm_parameter_prompt": "no", + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes" + }, + "super_tables": [{ + "name": "stb", + "child_table_exists":"no", + "childtable_count": 20, + "childtable_prefix": "t_", + "auto_create_table": "no", + "data_source": "sample", + "insert_mode": "taosc", + "insert_rate": 0, + "insert_rows": 20, + "max_sql_len": 1048000, + "timestamp_step": 1000, + "start_timestamp": "2020-1-1 00:00:00", + "sample_format": "csv", + "sample_file": "./tools/sampledata.csv", + "columns": [{"type": "INT"}], + "tags": [{"type": "INT", "count":1}] + }] + }] + +} diff --git a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/nano_samples.csv b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/nano_samples.csv new file mode 100644 index 0000000000000000000000000000000000000000..5fc779b41b44eda002d246d9554f0abcea03c8d3 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/nano_samples.csv @@ -0,0 +1,100 @@ +8.855,"binary_str0" ,1626870128248246976 +8.75,"binary_str1" ,1626870128249060032 +5.44,"binary_str2" ,1626870128249067968 +8.45,"binary_str3" ,1626870128249072064 +4.07,"binary_str4" ,1626870128249075904 +6.97,"binary_str5" ,1626870128249078976 +6.86,"binary_str6" ,1626870128249082048 +1.585,"binary_str7" ,1626870128249085120 +1.4,"binary_str8" ,1626870128249087936 +5.135,"binary_str9" ,1626870128249092032 +3.15,"binary_str10" ,1626870128249095104 +1.765,"binary_str11" ,1626870128249097920 +7.71,"binary_str12" ,1626870128249100992 +3.91,"binary_str13" ,1626870128249104064 +5.615,"binary_str14" ,1626870128249106880 +9.495,"binary_str15" ,1626870128249109952 +3.825,"binary_str16" ,1626870128249113024 +1.94,"binary_str17" ,1626870128249117120 +5.385,"binary_str18" ,1626870128249119936 +7.075,"binary_str19" ,1626870128249123008 +5.715,"binary_str20" ,1626870128249126080 +1.83,"binary_str21" ,1626870128249128896 +6.365,"binary_str22" ,1626870128249131968 +6.55,"binary_str23" ,1626870128249135040 +6.315,"binary_str24" ,1626870128249138112 +3.82,"binary_str25" ,1626870128249140928 +2.455,"binary_str26" ,1626870128249145024 +7.795,"binary_str27" ,1626870128249148096 +2.47,"binary_str28" ,1626870128249150912 +1.37,"binary_str29" ,1626870128249155008 +5.39,"binary_str30" ,1626870128249158080 +5.13,"binary_str31" ,1626870128249160896 +4.09,"binary_str32" ,1626870128249163968 +5.855,"binary_str33" ,1626870128249167040 +0.17,"binary_str34" ,1626870128249170112 +1.955,"binary_str35" ,1626870128249173952 +0.585,"binary_str36" ,1626870128249178048 +0.33,"binary_str37" ,1626870128249181120 +7.925,"binary_str38" ,1626870128249183936 +9.685,"binary_str39" ,1626870128249187008 +2.6,"binary_str40" ,1626870128249191104 +5.705,"binary_str41" ,1626870128249193920 +3.965,"binary_str42" ,1626870128249196992 +4.43,"binary_str43" ,1626870128249200064 +8.73,"binary_str44" ,1626870128249202880 +3.105,"binary_str45" ,1626870128249205952 +9.39,"binary_str46" ,1626870128249209024 +2.825,"binary_str47" ,1626870128249212096 +9.675,"binary_str48" ,1626870128249214912 +9.99,"binary_str49" ,1626870128249217984 +4.51,"binary_str50" ,1626870128249221056 +4.94,"binary_str51" ,1626870128249223872 +7.72,"binary_str52" ,1626870128249226944 +4.135,"binary_str53" ,1626870128249231040 +2.325,"binary_str54" ,1626870128249234112 +4.585,"binary_str55" ,1626870128249236928 +8.76,"binary_str56" ,1626870128249240000 +4.715,"binary_str57" ,1626870128249243072 +0.56,"binary_str58" ,1626870128249245888 +5.35,"binary_str59" ,1626870128249249984 +5.075,"binary_str60" ,1626870128249253056 +6.665,"binary_str61" ,1626870128249256128 +7.13,"binary_str62" ,1626870128249258944 +2.775,"binary_str63" ,1626870128249262016 +5.775,"binary_str64" ,1626870128249265088 +1.62,"binary_str65" ,1626870128249267904 +1.625,"binary_str66" ,1626870128249270976 +8.15,"binary_str67" ,1626870128249274048 +0.75,"binary_str68" ,1626870128249277120 +3.265,"binary_str69" ,1626870128249280960 +8.585,"binary_str70" ,1626870128249284032 +1.88,"binary_str71" ,1626870128249287104 +8.44,"binary_str72" ,1626870128249289920 +5.12,"binary_str73" ,1626870128249295040 +2.58,"binary_str74" ,1626870128249298112 +9.42,"binary_str75" ,1626870128249300928 +1.765,"binary_str76" ,1626870128249304000 +2.66,"binary_str77" ,1626870128249308096 +1.405,"binary_str78" ,1626870128249310912 +5.595,"binary_str79" ,1626870128249315008 +2.28,"binary_str80" ,1626870128249318080 +9.24,"binary_str81" ,1626870128249320896 +9.03,"binary_str82" ,1626870128249323968 +6.055,"binary_str83" ,1626870128249327040 +1.74,"binary_str84" ,1626870128249330112 +5.77,"binary_str85" ,1626870128249332928 +1.97,"binary_str86" ,1626870128249336000 +0.3,"binary_str87" ,1626870128249339072 +7.145,"binary_str88" ,1626870128249342912 +0.88,"binary_str89" ,1626870128249345984 +8.025,"binary_str90" ,1626870128249349056 +4.81,"binary_str91" ,1626870128249351872 +0.725,"binary_str92" ,1626870128249355968 +3.85,"binary_str93" ,1626870128249359040 +9.455,"binary_str94" ,1626870128249362112 +2.265,"binary_str95" ,1626870128249364928 +3.985,"binary_str96" ,1626870128249368000 +9.375,"binary_str97" ,1626870128249371072 +0.2,"binary_str98" ,1626870128249373888 +6.95,"binary_str99" ,1626870128249377984 diff --git a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/nano_sampletags.csv b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/nano_sampletags.csv new file mode 100644 index 0000000000000000000000000000000000000000..18fb855d6d9f55c29325c6ea6f77120effa72884 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/nano_sampletags.csv @@ -0,0 +1,100 @@ +"string0",7,8.615 +"string1",4,9.895 +"string2",3,2.92 +"string3",3,5.62 +"string4",7,1.615 +"string5",6,1.45 +"string6",5,7.48 +"string7",7,3.01 +"string8",5,4.76 +"string9",10,7.09 +"string10",2,8.38 +"string11",7,8.65 +"string12",5,5.025 +"string13",10,5.765 +"string14",2,4.57 +"string15",2,1.03 +"string16",7,6.98 +"string17",10,0.23 +"string18",7,5.815 +"string19",1,2.37 +"string20",10,8.865 +"string21",3,1.235 +"string22",2,8.62 +"string23",9,1.045 +"string24",8,4.34 +"string25",1,5.455 +"string26",2,4.475 +"string27",1,6.95 +"string28",2,3.39 +"string29",3,6.79 +"string30",7,9.735 +"string31",1,9.79 +"string32",10,9.955 +"string33",1,5.095 +"string34",3,3.86 +"string35",9,5.105 +"string36",10,4.22 +"string37",1,2.78 +"string38",9,6.345 +"string39",1,0.975 +"string40",5,6.16 +"string41",4,7.735 +"string42",5,6.6 +"string43",8,2.845 +"string44",1,0.655 +"string45",3,2.995 +"string46",9,3.6 +"string47",8,3.47 +"string48",3,7.98 +"string49",6,2.225 +"string50",9,5.44 +"string51",4,6.335 +"string52",3,2.955 +"string53",1,0.565 +"string54",6,5.575 +"string55",6,9.905 +"string56",9,6.025 +"string57",8,0.94 +"string58",10,0.15 +"string59",8,1.555 +"string60",4,2.28 +"string61",2,8.29 +"string62",9,6.22 +"string63",6,3.35 +"string64",10,6.7 +"string65",3,9.345 +"string66",7,9.815 +"string67",1,5.365 +"string68",10,3.81 +"string69",1,6.405 +"string70",8,2.715 +"string71",3,8.58 +"string72",8,6.34 +"string73",2,7.49 +"string74",4,8.64 +"string75",3,8.995 +"string76",7,3.465 +"string77",1,7.64 +"string78",6,3.65 +"string79",6,1.4 +"string80",6,5.875 +"string81",2,1.22 +"string82",5,7.87 +"string83",9,8.41 +"string84",9,8.9 +"string85",9,3.89 +"string86",2,5.0 +"string87",2,4.495 +"string88",4,2.835 +"string89",3,5.895 +"string90",7,8.41 +"string91",5,5.125 +"string92",7,9.165 +"string93",5,8.315 +"string94",10,7.485 +"string95",7,4.635 +"string96",2,6.015 +"string97",8,0.595 +"string98",3,8.79 +"string99",4,1.72 diff --git a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoInsertMSDB.json b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoInsertMSDB.json new file mode 100644 index 0000000000000000000000000000000000000000..8bd5ddbae8d5ce81269626165b2d275d05135ea5 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoInsertMSDB.json @@ -0,0 +1,63 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 10, + "thread_count_create_tbl": 10, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 100, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "testdb3", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 3600, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "tb0_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 100, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1000, + "start_timestamp": "2021-07-01 00:00:00.000", + "sample_format": "", + "sample_file": "", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":3}, {"type": "BINARY", "len": 16, "count":2}, {"type": "BINARY", "len": 32, "count":2}, + {"type": "TIMESTAMP"}, {"type": "BIGINT", "count":3},{"type": "FLOAT", "count":1},{"type": "SMALLINT", "count":1},{"type": "TINYINT", "count":1}, + {"type": "BOOL"},{"type": "NCHAR","len":16}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5},{"type": "NCHAR","len":16, "count":1}] + }] + }] +} + diff --git a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoInsertNanoDB.json b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoInsertNanoDB.json new file mode 100644 index 0000000000000000000000000000000000000000..5408a9841ab8a40e4ca7564724b7f6c7f941e0e0 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoInsertNanoDB.json @@ -0,0 +1,63 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 10, + "thread_count_create_tbl": 10, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 100, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "testdb1", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ns", + "keep": 3600, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "tb0_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 100, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1000, + "start_timestamp": "2021-07-01 00:00:00.000", + "sample_format": "", + "sample_file": "", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":3}, {"type": "BINARY", "len": 16, "count":2}, {"type": "BINARY", "len": 32, "count":2}, + {"type": "TIMESTAMP"}, {"type": "BIGINT", "count":3},{"type": "FLOAT", "count":1},{"type": "SMALLINT", "count":1},{"type": "TINYINT", "count":1}, + {"type": "BOOL"},{"type": "NCHAR","len":16}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5},{"type": "NCHAR","len":16, "count":1}] + }] + }] +} + diff --git a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoInsertUSDB.json b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoInsertUSDB.json new file mode 100644 index 0000000000000000000000000000000000000000..13eb80f3cf7f751398babed8e922f9e5b3a4242e --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoInsertUSDB.json @@ -0,0 +1,63 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 10, + "thread_count_create_tbl": 10, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 100, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "testdb2", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "us", + "keep": 3600, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "tb0_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 100, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1000, + "start_timestamp": "2021-07-01 00:00:00.000", + "sample_format": "", + "sample_file": "", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":3}, {"type": "BINARY", "len": 16, "count":2}, {"type": "BINARY", "len": 32, "count":2}, + {"type": "TIMESTAMP"}, {"type": "BIGINT", "count":3},{"type": "FLOAT", "count":1},{"type": "SMALLINT", "count":1},{"type": "TINYINT", "count":1}, + {"type": "BOOL"},{"type": "NCHAR","len":16}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5},{"type": "NCHAR","len":16, "count":1}] + }] + }] +} + diff --git a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestInsertTime_step.py b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestInsertTime_step.py new file mode 100644 index 0000000000000000000000000000000000000000..b248eda6b0ce42d8cb681a74d5c807d0275e6e14 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestInsertTime_step.py @@ -0,0 +1,115 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def run(self): + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + + # insert: create one or mutiple tables per sql and insert multiple rows per sql + + # check the params of taosdemo about time_step is nano + os.system("%staosdemo -f tools/taosdemoAllTest/NanoTestCase/taosdemoInsertNanoDB.json -y " % binPath) + tdSql.execute("use testdb1") + tdSql.query("show stables") + tdSql.checkData(0, 4, 100) + tdSql.query("select count (tbname) from stb0") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from tb0_0") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 10000) + tdSql.query("describe stb0") + tdSql.getData(9, 1) + tdSql.checkDataType(9, 1,"TIMESTAMP") + tdSql.query("select last(ts) from stb0") + tdSql.checkData(0, 0,"2021-07-01 00:00:00.000099000") + + # check the params of taosdemo about time_step is us + os.system("%staosdemo -f tools/taosdemoAllTest/NanoTestCase/taosdemoInsertUSDB.json -y " % binPath) + tdSql.execute("use testdb2") + tdSql.query("show stables") + tdSql.checkData(0, 4, 100) + tdSql.query("select count (tbname) from stb0") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from tb0_0") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 10000) + tdSql.query("describe stb0") + tdSql.getData(9, 1) + tdSql.checkDataType(9, 1,"TIMESTAMP") + tdSql.query("select last(ts) from stb0") + tdSql.checkData(0, 0,"2021-07-01 00:00:00.099000") + + # check the params of taosdemo about time_step is ms + os.system("%staosdemo -f tools/taosdemoAllTest/NanoTestCase/taosdemoInsertMSDB.json -y " % binPath) + tdSql.execute("use testdb3") + tdSql.query("show stables") + tdSql.checkData(0, 4, 100) + tdSql.query("select count (tbname) from stb0") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from tb0_0") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 10000) + tdSql.query("describe stb0") + tdSql.checkDataType(9, 1,"TIMESTAMP") + tdSql.query("select last(ts) from stb0") + tdSql.checkData(0, 0,"2021-07-01 00:01:39.000") + + + os.system("rm -rf ./res.txt") + os.system("rm -rf ./*.py.sql") + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabase.json b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabase.json new file mode 100644 index 0000000000000000000000000000000000000000..38ac666fac5097d616c17bdfc7e900256827ddf4 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabase.json @@ -0,0 +1,88 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 10, + "thread_count_create_tbl": 10, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 100, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "nsdb", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ns", + "keep": 3600, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "tb0_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 100, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10000000, + "start_timestamp": "2021-07-01 00:00:00.000", + "sample_format": "", + "sample_file": "", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":3}, {"type": "BINARY", "len": 16, "count":2}, {"type": "BINARY", "len": 32, "count":2}, + {"type": "TIMESTAMP"}, {"type": "BIGINT", "count":3},{"type": "FLOAT", "count":1},{"type": "SMALLINT", "count":1},{"type": "TINYINT", "count":1}, + {"type": "BOOL"},{"type": "NCHAR","len":16}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5},{"type": "NCHAR","len":16, "count":1}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "tb1_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 100, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 10, + "disorder_range": 1000, + "timestamp_step": 10000000, + "start_timestamp": "2021-07-01 00:00:00.000", + "sample_format": "", + "sample_file": "", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":3}, {"type": "BINARY", "len": 16, "count":2}, {"type": "BINARY", "len": 32, "count":2}, + {"type": "TIMESTAMP"}, {"type": "BIGINT", "count":3},{"type": "FLOAT", "count":1},{"type": "SMALLINT", "count":1},{"type": "TINYINT", "count":1}, + {"type": "BOOL"},{"type": "NCHAR","len":16}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5},{"type": "NCHAR","len":16, "count":1}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseInsertForSub.json b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseInsertForSub.json new file mode 100644 index 0000000000000000000000000000000000000000..9ef4a0af66e852a01d8ca7d677de4467ea316097 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseInsertForSub.json @@ -0,0 +1,84 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 10, + "thread_count_create_tbl": 10, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 100, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "subnsdb", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ns", + "keep": 3600, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 10, + "childtable_prefix": "tb0_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "samples", + "insert_mode": "taosc", + "insert_rows": 10, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10000000, + "start_timestamp": "2021-07-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./tools/taosdemoAllTest/NanoTestCase/nano_samples.csv", + "tags_file": "./tools/taosdemoAllTest/NanoTestCase/nano_sampletags.csv", + "columns": [{"type": "DOUBLE"}, {"type": "BINARY", "len": 64, "count":1}, {"type": "TIMESTAMP", "count":1}], + "tags": [{"type": "BINARY", "len": 16, "count":1},{"type": "INT"},{"type": "DOUBLE"}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 10, + "childtable_prefix": "tb1_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "samples", + "insert_mode": "taosc", + "insert_rows": 10, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 10, + "disorder_range": 1000, + "timestamp_step": 10000000, + "start_timestamp": "2021-07-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./tools/taosdemoAllTest/NanoTestCase/nano_samples.csv", + "tags_file": "./tools/taosdemoAllTest/NanoTestCase/nano_sampletags.csv", + "columns": [{"type": "DOUBLE"}, {"type": "BINARY", "len": 64, "count":1}, {"type": "TIMESTAMP", "count":1}], + "tags": [{"type": "BINARY", "len": 16, "count":1},{"type": "INT"},{"type": "DOUBLE"}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseNow.json b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseNow.json new file mode 100644 index 0000000000000000000000000000000000000000..a09dec21fa9cf3720b68a1fa2e843b49be0544ee --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseNow.json @@ -0,0 +1,62 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 10, + "thread_count_create_tbl": 10, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 100, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "nsdb2", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ns", + "keep": 3600, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "tb0_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 100, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "now", + "sample_format": "", + "sample_file": "", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":3}, {"type": "BINARY", "len": 16, "count":2}, {"type": "BINARY", "len": 32, "count":2}, + {"type": "TIMESTAMP"}, {"type": "BIGINT", "count":3},{"type": "FLOAT", "count":1},{"type": "SMALLINT", "count":1},{"type": "TINYINT", "count":1}, + {"type": "BOOL"},{"type": "NCHAR","len":16}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5},{"type": "NCHAR","len":16, "count":1}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabasecsv.json b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabasecsv.json new file mode 100644 index 0000000000000000000000000000000000000000..e99c528c6d62e3b9ce59565e60d21fb562bb836d --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabasecsv.json @@ -0,0 +1,84 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 10, + "thread_count_create_tbl": 10, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 100, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "nsdbcsv", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ns", + "keep": 3600, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "tb0_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "samples", + "insert_mode": "taosc", + "insert_rows": 100, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10000000, + "start_timestamp": "2021-07-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./tools/taosdemoAllTest/NanoTestCase/nano_samples.csv", + "tags_file": "./tools/taosdemoAllTest/NanoTestCase/nano_sampletags.csv", + "columns": [{"type": "DOUBLE"}, {"type": "BINARY", "len": 64, "count":1}, {"type": "TIMESTAMP", "count":1}], + "tags": [{"type": "BINARY", "len": 16, "count":1},{"type": "INT"},{"type": "DOUBLE"}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "tb1_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "samples", + "insert_mode": "taosc", + "insert_rows": 100, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 10, + "disorder_range": 1000, + "timestamp_step": 10000000, + "start_timestamp": "2021-07-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./tools/taosdemoAllTest/NanoTestCase/nano_samples.csv", + "tags_file": "./tools/taosdemoAllTest/NanoTestCase/nano_sampletags.csv", + "columns": [{"type": "DOUBLE"}, {"type": "BINARY", "len": 64, "count":1}, {"type": "TIMESTAMP", "count":1}], + "tags": [{"type": "BINARY", "len": 16, "count":1},{"type": "INT"},{"type": "DOUBLE"}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoInsert.py b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoInsert.py new file mode 100644 index 0000000000000000000000000000000000000000..f069bb8f7030dbd8d4eec8c9c741d246f261671b --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoInsert.py @@ -0,0 +1,169 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def run(self): + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath + "/build/bin/" + + # insert: create one or mutiple tables per sql and insert multiple rows per sql + # insert data from a special timestamp + # check stable stb0 + + os.system( + "%staosdemo -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabase.json -y " % + binPath) + tdSql.execute("use nsdb") + tdSql.query("show stables") + tdSql.checkData(0, 4, 100) + tdSql.query("select count (tbname) from stb0") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from tb0_0") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 10000) + tdSql.query("describe stb0") + tdSql.checkDataType(9, 1, "TIMESTAMP") + tdSql.query("select last(ts) from stb0") + tdSql.checkData(0, 0, "2021-07-01 00:00:00.990000000") + + # check stable stb1 which is insert with disord + + tdSql.query("select count (tbname) from stb1") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from tb1_0") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from stb1") + tdSql.checkData(0, 0, 10000) + # check c8 is an nano timestamp + tdSql.query("describe stb1") + tdSql.checkDataType(9, 1, "TIMESTAMP") + # check insert timestamp_step is nano_second + tdSql.query("select last(ts) from stb1") + tdSql.checkData(0, 0, "2021-07-01 00:00:00.990000000") + + # insert data from now time + + # check stable stb0 + os.system( + "%staosdemo -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseNow.json -y " % + binPath) + + tdSql.execute("use nsdb2") + tdSql.query("show stables") + tdSql.checkData(0, 4, 100) + tdSql.query("select count (tbname) from stb0") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from tb0_0") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 10000) + # check c8 is an nano timestamp + tdSql.query("describe stb0") + tdSql.checkDataType(9, 1, "TIMESTAMP") + + # insert by csv files and timetamp is long int , strings in ts and + # cols + + os.system( + "%staosdemo -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabasecsv.json -y " % + binPath) + tdSql.execute("use nsdbcsv") + tdSql.query("show stables") + tdSql.checkData(0, 4, 100) + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 10000) + tdSql.query("describe stb0") + tdSql.checkDataType(3, 1, "TIMESTAMP") + tdSql.query( + "select count(*) from stb0 where ts > \"2021-07-01 00:00:00.490000000\"") + tdSql.checkData(0, 0, 5000) + tdSql.query("select count(*) from stb0 where ts < 1626918583000000000") + tdSql.checkData(0, 0, 10000) + + os.system("rm -rf ./insert_res.txt") + os.system( + "rm -rf tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNano*.py.sql") + + # taosdemo test insert with command and parameter , detals show + # taosdemo --help + os.system( + "%staosdemo -u root -ptaosdata -P 6030 -a 1 -m pre -n 10 -T 20 -t 60 -o res.txt -y " % + binPath) + tdSql.query("select count(*) from test.meters") + tdSql.checkData(0, 0, 600) + # check taosdemo -s + + sqls_ls = [ + 'drop database if exists nsdbsql;', + 'create database nsdbsql precision "ns" keep 3600 days 6 update 1;', + 'use nsdbsql;', + 'CREATE STABLE meters (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupdId int);', + 'CREATE TABLE d1001 USING meters TAGS ("Beijing.Chaoyang", 2);', + 'INSERT INTO d1001 USING METERS TAGS ("Beijng.Chaoyang", 2) VALUES (now, 10.2, 219, 0.32);', + 'INSERT INTO d1001 USING METERS TAGS ("Beijng.Chaoyang", 2) VALUES (now, 85, 32, 0.76);'] + + with open("./taosdemoTestNanoCreateDB.sql", mode="a") as sql_files: + for sql in sqls_ls: + sql_files.write(sql + "\n") + sql_files.close() + + sleep(10) + + os.system("%staosdemo -s taosdemoTestNanoCreateDB.sql -y " % binPath) + tdSql.query("select count(*) from nsdbsql.meters") + tdSql.checkData(0, 0, 2) + + os.system("rm -rf ./res.txt") + os.system("rm -rf ./*.py.sql") + os.system("rm -rf ./taosdemoTestNanoCreateDB.sql") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoQuery.json b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoQuery.json new file mode 100644 index 0000000000000000000000000000000000000000..fff1017588bb10f55a82aa2bd7bc6997df71abfd --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoQuery.json @@ -0,0 +1,92 @@ +{ + "filetype": "query", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "confirm_parameter_prompt": "no", + "databases": "nsdb", + "query_times": 10, + "query_mode": "taosc", + "specified_table_query": { + "query_interval": 1, + "concurrent": 2, + "sqls": [ + { + "sql": "select count(*) from stb0 where ts>\"2021-07-01 00:01:00.000000000 \" ;", + "result": "./query_res0.txt" + }, + { + "sql": "select count(*) from stb0 where ts>\"2021-07-01 00:01:00.000000000\" and ts <=\"2021-07-01 00:01:10.000000000\" ;", + "result": "./query_res1.txt" + }, + { + "sql": "select count(*) from stb0 where ts>now-20d ;", + "result": "./query_res2.txt" + }, + { + "sql": "select max(c10) from stb0;", + "result": "./query_res3.txt" + }, + { + "sql": "select min(c1) from stb0;", + "result": "./query_res4.txt" + }, + { + "sql": "select avg(c1) from stb0;", + "result": "./query_res5.txt" + }, + { + "sql":"select count(*) from stb0 group by tbname;", + "result":"./query_res6.txt" + } + + ] + }, + "super_table_query": { + "stblname": "stb0", + "query_interval": 0, + "threads": 4, + "sqls": [ + { + "sql": "select count(*) from xxxx where ts>\"2021-07-01 00:01:00.000000000 \" ;", + "result": "./query_res_tb0.txt" + }, + { + "sql":"select count(*) from xxxx where ts>\"2021-07-01 00:01:00.000000000\" and ts <=\"2021-07-01 00:01:10.000000000\" ;", + "result": "./query_res_tb1.txt" + }, + { + "sql":"select first(*) from xxxx ;", + "result": "./query_res_tb2.txt" + }, + { + "sql":"select last(*) from xxxx;", + "result": "./query_res_tb3.txt" + + }, + { + "sql":"select last_row(*) from xxxx ;", + "result": "./query_res_tb4.txt" + + }, + { + "sql":"select max(c10) from xxxx ;", + "result": "./query_res_tb5.txt" + + }, + { + "sql":"select min(c1) from xxxx ;", + "result": "./query_res_tb6.txt" + + }, + { + "sql":"select avg(c10) from xxxx ;", + "result": "./query_res_tb7.txt" + + } + + ] + } + } \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoQuery.py b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoQuery.py new file mode 100644 index 0000000000000000000000000000000000000000..6c3e4d6c8a0d72a4b468cca22b2b1a6a25659db5 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoQuery.py @@ -0,0 +1,157 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def run(self): + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + + # query: query test for nanoSecond with where and max min groupby order + os.system("%staosdemo -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabase.json -y " % binPath) + + tdSql.execute("use nsdb") + + # use where to filter + + tdSql.query("select count(*) from stb0 where ts>\"2021-07-01 00:00:00.590000000 \" ") + tdSql.checkData(0, 0, 4000) + tdSql.query("select count(*) from stb0 where ts>\"2021-07-01 00:00:00.000000000\" and ts <=\"2021-07-01 00:00:00.590000000\" ") + tdSql.checkData(0, 0, 5900) + + tdSql.query("select count(*) from tb0_0 where ts>\"2021-07-01 00:00:00.590000000 \" ;") + tdSql.checkData(0, 0, 40) + tdSql.query("select count(*) from tb0_0 where ts>\"2021-07-01 00:00:00.000000000\" and ts <=\"2021-07-01 00:00:00.590000000\" ") + tdSql.checkData(0, 0, 59) + + + # select max min avg from special col + tdSql.query("select max(c10) from stb0;") + print("select max(c10) from stb0 : " , tdSql.getData(0, 0)) + + tdSql.query("select max(c10) from tb0_0;") + print("select max(c10) from tb0_0 : " , tdSql.getData(0, 0)) + + + tdSql.query("select min(c1) from stb0;") + print( "select min(c1) from stb0 : " , tdSql.getData(0, 0)) + + tdSql.query("select min(c1) from tb0_0;") + print( "select min(c1) from tb0_0 : " , tdSql.getData(0, 0)) + + tdSql.query("select avg(c1) from stb0;") + print( "select avg(c1) from stb0 : " , tdSql.getData(0, 0)) + + tdSql.query("select avg(c1) from tb0_0;") + print( "select avg(c1) from tb0_0 : " , tdSql.getData(0, 0)) + + tdSql.query("select count(*) from stb0 group by tbname;") + tdSql.checkData(0, 0, 100) + tdSql.checkData(10, 0, 100) + + # query : query above sqls by taosdemo and continuously + + os.system("%staosdemo -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoQuery.json -y " % binPath) + + + os.system("%staosdemo -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabasecsv.json -y " % binPath) + tdSql.execute("use nsdbcsv") + tdSql.query("show stables") + tdSql.checkData(0, 4, 100) + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 10000) + tdSql.query("describe stb0") + tdSql.checkDataType(3, 1, "TIMESTAMP") + tdSql.query("select count(*) from stb0 where ts >\"2021-07-01 00:00:00.490000000\"") + tdSql.checkData(0, 0, 5000) + tdSql.query("select count(*) from stb0 where ts 162687012800000000') + tdSql.execute('select count(*) from stb0 where c2 < 162687012800000000') + tdSql.execute('select count(*) from stb0 where c2 = 162687012800000000') + tdSql.execute('select count(*) from stb0 where c2 != 162687012800000000') + tdSql.execute('select count(*) from stb0 where c2 <> 162687012800000000') + tdSql.execute('select count(*) from stb0 where c2 > "2021-07-21 20:22:08.248246976"') + tdSql.execute('select count(*) from stb0 where c2 < "2021-07-21 20:22:08.248246976"') + tdSql.execute('select count(*) from stb0 where c2 = "2021-07-21 20:22:08.248246976"') + tdSql.execute('select count(*) from stb0 where c2 != "2021-07-21 20:22:08.248246976"') + tdSql.execute('select count(*) from stb0 where c2 <> "2021-07-21 20:22:08.248246976"') + tdSql.execute('select count(*) from stb0 where ts between "2021-07-01 00:00:00.000000000" and "2021-07-01 00:00:00.990000000"') + tdSql.execute('select count(*) from stb0 where ts between 1625068800000000000 and 1625068801000000000') + tdSql.query('select avg(c0) from stb0 interval(5000000000b)') + tdSql.checkRows(1) + + tdSql.query('select avg(c0) from stb0 interval(100000000b)') + tdSql.checkRows(10) + + tdSql.error('select avg(c0) from stb0 interval(1b)') + tdSql.error('select avg(c0) from stb0 interval(999b)') + + tdSql.query('select avg(c0) from stb0 interval(1000b)') + tdSql.checkRows(100) + + tdSql.query('select avg(c0) from stb0 interval(1u)') + tdSql.checkRows(100) + + tdSql.query('select avg(c0) from stb0 interval(100000000b) sliding (100000000b)') + tdSql.checkRows(10) + + # query : query above sqls by taosdemo and continuously + os.system("%staosdemo -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoQuerycsv.json -y " % binPath) + + os.system("rm -rf ./query_res*.txt*") + os.system("rm -rf tools/taosdemoAllTest/NanoTestCase/*.py.sql") + + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoQuerycsv.json b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoQuerycsv.json new file mode 100644 index 0000000000000000000000000000000000000000..2323b0f3702b34bb56c4f82880e9820181891768 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoQuerycsv.json @@ -0,0 +1,110 @@ +{ + "filetype": "query", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "confirm_parameter_prompt": "no", + "databases": "nsdbcsv", + "query_times": 10, + "query_mode": "taosc", + "specified_table_query": { + "query_interval": 1, + "concurrent": 2, + "sqls": [ + { + "sql": "select count(*) from stb0 where ts> \"2021-07-01 00:00:00.490000000\" ;", + "result": "./query_res0.txt" + }, + { + "sql": "select count(*) from stb0 where ts < now -22d-1h-3s ;", + "result": "./query_res1.txt" + }, + { + "sql": "select count(*) from stb0 where ts < 1626918583000000000 ;", + "result": "./query_res2.txt" + }, + { + "sql": "select count(*) from stb0 where c2 <> 162687012800000000;", + "result": "./query_res3.txt" + }, + { + "sql": "select count(*) from stb0 where c2 != \"2021-07-21 20:22:08.248246976\";", + "result": "./query_res4.txt" + }, + { + "sql": "select count(*) from stb0 where ts between \"2021-07-01 00:00:00.000000000\" and \"2021-07-01 00:00:00.990000000\";", + "result": "./query_res5.txt" + }, + { + "sql":"select count(*) from stb0 group by tbname;", + "result":"./query_res6.txt" + }, + { + "sql":"select count(*) from stb0 where ts between 1625068800000000000 and 1625068801000000000;", + "result":"./query_res7.txt" + }, + { + "sql":"select avg(c0) from stb0 interval(5000000000b);", + "result":"./query_res8.txt" + }, + { + "sql":"select avg(c0) from stb0 interval(100000000b) sliding (100000000b);", + "result":"./query_res9.txt" + } + + ] + }, + "super_table_query": { + "stblname": "stb0", + "query_interval": 0, + "threads": 4, + "sqls": [ + { + "sql": "select count(*) from xxxx where ts > \"2021-07-01 00:00:00.490000000\" ;", + "result": "./query_res_tb0.txt" + }, + { + "sql":"select count(*) from xxxx where ts between \"2021-07-01 00:00:00.000000000\" and \"2021-07-01 00:00:00.990000000\" ;", + "result": "./query_res_tb1.txt" + }, + { + "sql":"select first(*) from xxxx ;", + "result": "./query_res_tb2.txt" + }, + { + "sql":"select last(*) from xxxx;", + "result": "./query_res_tb3.txt" + + }, + { + "sql":"select last_row(*) from xxxx ;", + "result": "./query_res_tb4.txt" + + }, + { + "sql":"select max(c0) from xxxx ;", + "result": "./query_res_tb5.txt" + + }, + { + "sql":"select min(c0) from xxxx ;", + "result": "./query_res_tb6.txt" + + }, + { + "sql":"select avg(c0) from xxxx ;", + "result": "./query_res_tb7.txt" + + }, + { + "sql":"select avg(c0) from xxxx interval(100000000b) sliding (100000000b) ;", + "result": "./query_res_tb8.txt" + + } + + + ] + } + } \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoSubscribe.json b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoSubscribe.json new file mode 100644 index 0000000000000000000000000000000000000000..1cc834164e7c966a9ce565f1ce481d823b1ed2d1 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoSubscribe.json @@ -0,0 +1,32 @@ +{ + "filetype":"subscribe", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "databases": "subnsdb", + "confirm_parameter_prompt": "no", + "specified_table_query": + { + "concurrent":2, + "mode":"sync", + "interval":10000, + "restart":"yes", + "keepProgress":"yes", + "sqls": [ + { + "sql": "select * from stb0 where ts>= \"2021-07-01 00:00:00.000000000\" ;", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb0 where ts < now -2d-1h-3s ;", + "result": "./subscribe_res1.txt" + }, + { + "sql": "select * from stb0 where ts < 1626918583000000000 ;", + "result": "./subscribe_res2.txt" + }] + + } +} diff --git a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanosubscribe.py b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanosubscribe.py new file mode 100644 index 0000000000000000000000000000000000000000..cd5a0b4c413d11b3030042f41faf2e1c6f3a4002 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanosubscribe.py @@ -0,0 +1,140 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import time +from datetime import datetime +import subprocess + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + # get the number of subscriptions + def subTimes(self,filename): + self.filename = filename + command = 'cat %s |wc -l'% filename + times = int(subprocess.getstatusoutput(command)[1]) + return times + + # assert results + def assertCheck(self,filename,subResult,expectResult): + self.filename = filename + self.subResult = subResult + self.expectResult = expectResult + args0 = (filename, subResult, expectResult) + assert subResult == expectResult , "Queryfile:%s ,result is %s != expect: %s" % args0 + + def run(self): + tdSql.prepare() + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + + # clear envs + + os.system("ps -aux |grep 'taosdemoAllTest/taosdemoTestSupportNanoSubscribe.json' |awk '{print $2}'|xargs kill -9 >/dev/null 2>&1") + os.system("ps -aux |grep 'tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseInsertForSub.json' |awk '{print $2}'|xargs kill -9 >/dev/null 2>&1") + os.system("rm -rf ./subscribe_res*") + os.system("rm -rf ./all_subscribe_res*") + + # insert data + os.system("nohup %staosdemo -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseInsertForSub.json & >/dev/null 2>&1" % binPath) + sleep(5) + tdSql.query("select count(*) from subnsdb.stb0") + if tdSql.checkData(0,0,100): + pass + else: + sleep(5) + tdSql.query("select count(*) from subnsdb.stb0") # if records not write done ,sleep and wait records write done! + + os.system(" nohup %staosdemo -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoSubscribe.json & >/dev/null 2>&1" % binPath) + sleep(5) + + if os.path.exists("./subscribe_res0.txt") and os.path.exists("./subscribe_res1.txt") and os.path.exists("./subscribe_res2.txt"): + pass + else: + sleep(5) # make sure query is ok + print('taosdemo query done!') + + # merge result files + + os.system("cat subscribe_res0.txt* > all_subscribe_res0.txt") + os.system("cat subscribe_res1.txt* > all_subscribe_res1.txt") + os.system("cat subscribe_res2.txt* > all_subscribe_res2.txt") + sleep(5) + + # correct subscribeTimes testcase + subTimes0 = self.subTimes("all_subscribe_res0.txt") + self.assertCheck("all_subscribe_res0.txt",subTimes0 ,200) + + subTimes1 = self.subTimes("all_subscribe_res1.txt") + self.assertCheck("all_subscribe_res1.txt",subTimes1 ,200) + + subTimes2 = self.subTimes("all_subscribe_res2.txt") + self.assertCheck("all_subscribe_res2.txt",subTimes2 ,200) + + + # insert extral data + tdSql.execute("use subnsdb") + tdSql.execute("insert into tb0_0 values(now,100.1000,'subtest1',now-1s)") + sleep(15) + + os.system("cat subscribe_res0.txt* > all_subscribe_res0.txt") + subTimes0 = self.subTimes("all_subscribe_res0.txt") + self.assertCheck("all_subscribe_res0.txt",subTimes0 ,202) + + sleep(3) + os.system("rm -rf ./subscribe_res*") + os.system("rm -rf ./all_subscribe*") + os.system("rm -rf ./*.py.sql") + os.system("rm -rf ./nohup*") + os.system("ps -aux |grep 'taosdemoAllTest/taosdemoTestSupportNanoSubscribe.json' |awk '{print $2}'|xargs kill -9 >/dev/null 2>&1") + os.system("ps -aux |grep 'tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoSubscribe.json' |awk '{print $2}'|xargs kill -9 >/dev/null 2>&1") + os.system("ps -aux |grep 'tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseInsertForSub.json' |awk '{print $2}'|xargs kill -9 >/dev/null 2>&1") + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) + diff --git a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdumpTestNanoSupport.py b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdumpTestNanoSupport.py new file mode 100644 index 0000000000000000000000000000000000000000..a2059ec924ad1e2239c2709bc99dd58fbafa1337 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdumpTestNanoSupport.py @@ -0,0 +1,362 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.ts = 1625068800000000000 # this is timestamp "2021-07-01 00:00:00" + self.numberOfTables = 10 + self.numberOfRecords = 100 + + def checkCommunity(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + if ("community" in selfPath): + return False + else: + return True + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + + + def createdb(self, precision="ns"): + tb_nums = self.numberOfTables + per_tb_rows = self.numberOfRecords + + def build_db(precision, start_time): + tdSql.execute("drop database if exists timedb1") + tdSql.execute( + "create database timedb1 days 10 keep 365 blocks 8 precision "+"\""+precision+"\"") + + tdSql.execute("use timedb1") + tdSql.execute( + "create stable st(ts timestamp, c1 int, c2 nchar(10),c3 timestamp) tags(t1 int, t2 binary(10))") + for tb in range(tb_nums): + tbname = "t"+str(tb) + tdSql.execute("create table " + tbname + + " using st tags(1, 'beijing')") + sql = "insert into " + tbname + " values" + currts = start_time + if precision == "ns": + ts_seed = 1000000000 + elif precision == "us": + ts_seed = 1000000 + else: + ts_seed = 1000 + + for i in range(per_tb_rows): + sql += "(%d, %d, 'nchar%d',%d)" % (currts + i*ts_seed, i % + 100, i % 100, currts + i*100) # currts +1000ms (1000000000ns) + tdSql.execute(sql) + + if precision == "ns": + start_time = 1625068800000000000 + build_db(precision, start_time) + + elif precision == "us": + start_time = 1625068800000000 + build_db(precision, start_time) + + elif precision == "ms": + start_time = 1625068800000 + build_db(precision, start_time) + + else: + print("other time precision not valid , please check! ") + + + def run(self): + + # clear envs + os.system("rm -rf ./taosdumptest/") + tdSql.execute("drop database if exists dumptmp1") + tdSql.execute("drop database if exists dumptmp2") + tdSql.execute("drop database if exists dumptmp3") + + if not os.path.exists("./taosdumptest/tmp1"): + os.makedirs("./taosdumptest/dumptmp1") + else: + print("path exist!") + + if not os.path.exists("./taosdumptest/dumptmp2"): + os.makedirs("./taosdumptest/dumptmp2") + + if not os.path.exists("./taosdumptest/dumptmp3"): + os.makedirs("./taosdumptest/dumptmp3") + + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosdump not found!") + else: + tdLog.info("taosdump found in %s" % buildPath) + binPath = buildPath + "/build/bin/" + + # create nano second database + + self.createdb(precision="ns") + + # dump all data + + os.system( + "%staosdump --databases timedb1 -o ./taosdumptest/dumptmp1" % binPath) + + # dump part data with -S -E + os.system( + '%staosdump --databases timedb1 -S 1625068810000000000 -E 1625068860000000000 -C ns -o ./taosdumptest/dumptmp2 ' % + binPath) + os.system( + '%staosdump --databases timedb1 -S 1625068810000000000 -o ./taosdumptest/dumptmp3 ' % + binPath) + + # replace strings to dump in databases + os.system( + "sed -i \"s/timedb1/dumptmp1/g\" `grep timedb1 -rl ./taosdumptest/dumptmp1`") + os.system( + "sed -i \"s/timedb1/dumptmp2/g\" `grep timedb1 -rl ./taosdumptest/dumptmp2`") + os.system( + "sed -i \"s/timedb1/dumptmp3/g\" `grep timedb1 -rl ./taosdumptest/dumptmp3`") + + os.system( "%staosdump -i ./taosdumptest/dumptmp1" %binPath) + os.system( "%staosdump -i ./taosdumptest/dumptmp2" %binPath) + os.system( "%staosdump -i ./taosdumptest/dumptmp3" %binPath) + + # dump data and check for taosdump + tdSql.query("select count(*) from dumptmp1.st") + tdSql.checkData(0,0,1000) + + tdSql.query("select count(*) from dumptmp2.st") + tdSql.checkData(0,0,510) + + tdSql.query("select count(*) from dumptmp3.st") + tdSql.checkData(0,0,900) + + # check data + origin_res = tdSql.getResult("select * from timedb1.st") + dump_res = tdSql.getResult("select * from dumptmp1.st") + if origin_res == dump_res: + tdLog.info("test nano second : dump check data pass for all data!" ) + else: + tdLog.info("test nano second : dump check data failed for all data!" ) + + origin_res = tdSql.getResult("select * from timedb1.st where ts >=1625068810000000000 and ts <= 1625068860000000000") + dump_res = tdSql.getResult("select * from dumptmp2.st") + if origin_res == dump_res: + tdLog.info(" test nano second : dump check data pass for data! " ) + else: + tdLog.info(" test nano second : dump check data failed for data !" ) + + origin_res = tdSql.getResult("select * from timedb1.st where ts >=1625068810000000000 ") + dump_res = tdSql.getResult("select * from dumptmp3.st") + if origin_res == dump_res: + tdLog.info(" test nano second : dump check data pass for data! " ) + else: + tdLog.info(" test nano second : dump check data failed for data !" ) + + + # us second support test case + + os.system("rm -rf ./taosdumptest/") + tdSql.execute("drop database if exists dumptmp1") + tdSql.execute("drop database if exists dumptmp2") + tdSql.execute("drop database if exists dumptmp3") + + if not os.path.exists("./taosdumptest/tmp1"): + os.makedirs("./taosdumptest/dumptmp1") + else: + print("path exits!") + + if not os.path.exists("./taosdumptest/dumptmp2"): + os.makedirs("./taosdumptest/dumptmp2") + + if not os.path.exists("./taosdumptest/dumptmp3"): + os.makedirs("./taosdumptest/dumptmp3") + + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosdump not found!") + else: + tdLog.info("taosdump found in %s" % buildPath) + binPath = buildPath + "/build/bin/" + + self.createdb(precision="us") + + os.system( + "%staosdump --databases timedb1 -o ./taosdumptest/dumptmp1" % binPath) + + os.system( + '%staosdump --databases timedb1 -S 1625068810000000 -E 1625068860000000 -C us -o ./taosdumptest/dumptmp2 ' % + binPath) + os.system( + '%staosdump --databases timedb1 -S 1625068810000000 -o ./taosdumptest/dumptmp3 ' % + binPath) + + os.system( + "sed -i \"s/timedb1/dumptmp1/g\" `grep timedb1 -rl ./taosdumptest/dumptmp1`") + os.system( + "sed -i \"s/timedb1/dumptmp2/g\" `grep timedb1 -rl ./taosdumptest/dumptmp2`") + os.system( + "sed -i \"s/timedb1/dumptmp3/g\" `grep timedb1 -rl ./taosdumptest/dumptmp3`") + + os.system( "%staosdump -i ./taosdumptest/dumptmp1" %binPath) + os.system( "%staosdump -i ./taosdumptest/dumptmp2" %binPath) + os.system( "%staosdump -i ./taosdumptest/dumptmp3" %binPath) + + + tdSql.query("select count(*) from dumptmp1.st") + tdSql.checkData(0,0,1000) + + tdSql.query("select count(*) from dumptmp2.st") + tdSql.checkData(0,0,510) + + tdSql.query("select count(*) from dumptmp3.st") + tdSql.checkData(0,0,900) + + + origin_res = tdSql.getResult("select * from timedb1.st") + dump_res = tdSql.getResult("select * from dumptmp1.st") + if origin_res == dump_res: + tdLog.info("test us second : dump check data pass for all data!" ) + else: + tdLog.info("test us second : dump check data failed for all data!" ) + + origin_res = tdSql.getResult("select * from timedb1.st where ts >=1625068810000000 and ts <= 1625068860000000") + dump_res = tdSql.getResult("select * from dumptmp2.st") + if origin_res == dump_res: + tdLog.info(" test us second : dump check data pass for data! " ) + else: + tdLog.info(" test us second : dump check data failed for data!" ) + + origin_res = tdSql.getResult("select * from timedb1.st where ts >=1625068810000000 ") + dump_res = tdSql.getResult("select * from dumptmp3.st") + if origin_res == dump_res: + tdLog.info(" test us second : dump check data pass for data! " ) + else: + tdLog.info(" test us second : dump check data failed for data! " ) + + + # ms second support test case + + os.system("rm -rf ./taosdumptest/") + tdSql.execute("drop database if exists dumptmp1") + tdSql.execute("drop database if exists dumptmp2") + tdSql.execute("drop database if exists dumptmp3") + + if not os.path.exists("./taosdumptest/tmp1"): + os.makedirs("./taosdumptest/dumptmp1") + else: + print("path exits!") + + if not os.path.exists("./taosdumptest/dumptmp2"): + os.makedirs("./taosdumptest/dumptmp2") + + if not os.path.exists("./taosdumptest/dumptmp3"): + os.makedirs("./taosdumptest/dumptmp3") + + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosdump not found!") + else: + tdLog.info("taosdump found in %s" % buildPath) + binPath = buildPath + "/build/bin/" + + self.createdb(precision="ms") + + os.system( + "%staosdump --databases timedb1 -o ./taosdumptest/dumptmp1" % binPath) + + os.system( + '%staosdump --databases timedb1 -S 1625068810000 -E 1625068860000 -C ms -o ./taosdumptest/dumptmp2 ' % + binPath) + os.system( + '%staosdump --databases timedb1 -S 1625068810000 -o ./taosdumptest/dumptmp3 ' % + binPath) + + os.system( + "sed -i \"s/timedb1/dumptmp1/g\" `grep timedb1 -rl ./taosdumptest/dumptmp1`") + os.system( + "sed -i \"s/timedb1/dumptmp2/g\" `grep timedb1 -rl ./taosdumptest/dumptmp2`") + os.system( + "sed -i \"s/timedb1/dumptmp3/g\" `grep timedb1 -rl ./taosdumptest/dumptmp3`") + + os.system( "%staosdump -i ./taosdumptest/dumptmp1" %binPath) + os.system( "%staosdump -i ./taosdumptest/dumptmp2" %binPath) + os.system( "%staosdump -i ./taosdumptest/dumptmp3" %binPath) + + + tdSql.query("select count(*) from dumptmp1.st") + tdSql.checkData(0,0,1000) + + tdSql.query("select count(*) from dumptmp2.st") + tdSql.checkData(0,0,510) + + tdSql.query("select count(*) from dumptmp3.st") + tdSql.checkData(0,0,900) + + + origin_res = tdSql.getResult("select * from timedb1.st") + dump_res = tdSql.getResult("select * from dumptmp1.st") + if origin_res == dump_res: + tdLog.info("test ms second : dump check data pass for all data!" ) + else: + tdLog.info("test ms second : dump check data failed for all data!" ) + + origin_res = tdSql.getResult("select * from timedb1.st where ts >=1625068810000 and ts <= 1625068860000") + dump_res = tdSql.getResult("select * from dumptmp2.st") + if origin_res == dump_res: + tdLog.info(" test ms second : dump check data pass for data! " ) + else: + tdLog.info(" test ms second : dump check data failed for data!" ) + + origin_res = tdSql.getResult("select * from timedb1.st where ts >=1625068810000 ") + dump_res = tdSql.getResult("select * from dumptmp3.st") + if origin_res == dump_res: + tdLog.info(" test ms second : dump check data pass for data! " ) + else: + tdLog.info(" test ms second : dump check data failed for data! " ) + + + os.system("rm -rf ./taosdumptest/") + os.system("rm -rf ./dump_result.txt") + os.system("rm -rf *.py.sql") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoAllTest/Resubjson/subSyncResubAC1endAfter1.json b/tests/pytest/tools/taosdemoAllTest/Resubjson/subSyncResubAC1endAfter1.json new file mode 100644 index 0000000000000000000000000000000000000000..93462d2c66cea62c21f0cc196652c94439f47bc0 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/Resubjson/subSyncResubAC1endAfter1.json @@ -0,0 +1,41 @@ +{ + "filetype":"subscribe", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "databases": "db", + "confirm_parameter_prompt": "no", + "specified_table_query": + { + "concurrent":2, + "mode":"sync", + "interval":0, + "resubAfterConsume":1, + "endAfterConsume":1, + "keepProgress":"yes", + "restart":"no", + "sqls": [ + { + "sql": "select * from stb00_0", + "result": "./subscribe_res0.txt" + }] + }, + "super_table_query": + { + "stblname": "stb0", + "threads":2, + "mode":"sync", + "interval":1000, + "resubAfterConsume":1, + "endAfterConsume":1, + "keepProgress":"yes", + "restart":"no", + "sqls": [ + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:01.000' ", + "result": "./subscribe_res2.txt" + }] + } + } \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/Resubjson/subSyncResubAC1endAfterMin1.json b/tests/pytest/tools/taosdemoAllTest/Resubjson/subSyncResubAC1endAfterMin1.json new file mode 100644 index 0000000000000000000000000000000000000000..4229f304e44fcda58a0e16b1e6445ebd339215d3 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/Resubjson/subSyncResubAC1endAfterMin1.json @@ -0,0 +1,41 @@ +{ + "filetype":"subscribe", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "databases": "db", + "confirm_parameter_prompt": "no", + "specified_table_query": + { + "concurrent":2, + "mode":"sync", + "interval":0, + "resubAfterConsume":1, + "endAfterConsume":-1, + "keepProgress":"no", + "restart":"yes", + "sqls": [ + { + "sql": "select * from stb00_0", + "result": "./subscribe_res0.txt" + }] + }, + "super_table_query": + { + "stblname": "stb0", + "threads":2, + "mode":"sync", + "interval":1000, + "resubAfterConsume":1, + "endAfterConsume":-1, + "keepProgress":"no", + "restart":"yes", + "sqls": [ + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:01.000' ", + "result": "./subscribe_res2.txt" + }] + } + } \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/Resubjson/subSyncResubACMinus1.json b/tests/pytest/tools/taosdemoAllTest/Resubjson/subSyncResubACMinus1.json new file mode 100644 index 0000000000000000000000000000000000000000..ac221905655e53e9053336be8fcaaa8b1070639c --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/Resubjson/subSyncResubACMinus1.json @@ -0,0 +1,41 @@ +{ + "filetype":"subscribe", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "databases": "db", + "confirm_parameter_prompt": "no", + "specified_table_query": + { + "concurrent":2, + "mode":"sync", + "interval":0, + "resubAfterConsume":-1, + "endAfterConsume":-1, + "keepProgress":"no", + "restart":"yes", + "sqls": [ + { + "sql": "select * from stb00_0", + "result": "./subscribe_res0.txt" + }] + }, + "super_table_query": + { + "stblname": "stb0", + "threads":2, + "mode":"sync", + "interval":1000, + "resubAfterConsume":-1, + "endAfterConsume":-1, + "keepProgress":"no", + "restart":"yes", + "sqls": [ + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:01.000' ", + "result": "./subscribe_res2.txt" + }] + } + } \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/Resubjson/subSyncResubACMinus1endAfter0.json b/tests/pytest/tools/taosdemoAllTest/Resubjson/subSyncResubACMinus1endAfter0.json new file mode 100644 index 0000000000000000000000000000000000000000..7d937212c94bd002307695c7059d67ad0a4e68d3 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/Resubjson/subSyncResubACMinus1endAfter0.json @@ -0,0 +1,41 @@ +{ + "filetype":"subscribe", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "databases": "db", + "confirm_parameter_prompt": "no", + "specified_table_query": + { + "concurrent":2, + "mode":"sync", + "interval":0, + "resubAfterConsume":-1, + "endAfterConsume":0, + "keepProgress":"no", + "restart":"yes", + "sqls": [ + { + "sql": "select * from stb00_0", + "result": "./subscribe_res0.txt" + }] + }, + "super_table_query": + { + "stblname": "stb0", + "threads":2, + "mode":"sync", + "interval":0, + "resubAfterConsume":-1, + "endAfterConsume":0, + "keepProgress":"no", + "restart":"yes", + "sqls": [ + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:01.000' ", + "result": "./subscribe_res2.txt" + }] + } + } \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/Resubjson/subSyncResubACMinus1endAfterNo0.json b/tests/pytest/tools/taosdemoAllTest/Resubjson/subSyncResubACMinus1endAfterNo0.json new file mode 100644 index 0000000000000000000000000000000000000000..bf8927a58badfa606103d4b11d09f871ed64260f --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/Resubjson/subSyncResubACMinus1endAfterNo0.json @@ -0,0 +1,41 @@ +{ + "filetype":"subscribe", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "databases": "db", + "confirm_parameter_prompt": "no", + "specified_table_query": + { + "concurrent":2, + "mode":"sync", + "interval":0, + "resubAfterConsume":-1, + "endAfterConsume":1, + "keepProgress":"no", + "restart":"yes", + "sqls": [ + { + "sql": "select * from stb00_0", + "result": "./subscribe_res0.txt" + }] + }, + "super_table_query": + { + "stblname": "stb0", + "threads":2, + "mode":"sync", + "interval":1000, + "resubAfterConsume":-1, + "endAfterConsume":2, + "keepProgress":"no", + "restart":"yes", + "sqls": [ + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:01.000' ", + "result": "./subscribe_res2.txt" + }] + } + } \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/TD-3453/query-interrupt.json b/tests/pytest/tools/taosdemoAllTest/TD-3453/query-interrupt.json new file mode 100644 index 0000000000000000000000000000000000000000..aa9e93694a01d3bf8845785cd6b999f4abdcbcb3 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/TD-3453/query-interrupt.json @@ -0,0 +1,62 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 100, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 60, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 100000, + "childtable_limit": -1, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 1000, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":10}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/TD-3453/query-interrupt.py b/tests/pytest/tools/taosdemoAllTest/TD-3453/query-interrupt.py new file mode 100644 index 0000000000000000000000000000000000000000..fe29409f296b310012773b9d78ca8735cfd52a13 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/TD-3453/query-interrupt.py @@ -0,0 +1,89 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +import subprocess +import time +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def run(self): + tdSql.prepare() + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + + # # insert 1000w rows in stb0 + os.system("%staosdemo -f tools/taosdemoAllTest/TD-3453/query-interrupt.json -y " % binPath) + tdSql.execute("use db") + tdSql.query("select count (tbname) from stb0") + tdSql.checkData(0, 0,60) + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 6000000) + os.system('%staosdemo -f tools/taosdemoAllTest/TD-3453/queryall.json -y & ' % binPath) + time.sleep(2) + query_pid = int(subprocess.getstatusoutput('ps aux|grep "TD-3453/queryall.json" |grep -v "grep"|awk \'{print $2}\'')[1]) + taosd_cpu_load_1 = float(subprocess.getstatusoutput('top -n 1 -b -p $(ps aux|grep "bin/taosd -c"|grep -v "grep" |awk \'{print $2}\')|awk \'END{print}\' |awk \'{print $9}\'')[1]) + if taosd_cpu_load_1 > 10.0 : + os.system("kill -9 %d" % query_pid) + time.sleep(5) + taosd_cpu_load_2 = float(subprocess.getstatusoutput('top -n 1 -b -p $(ps aux|grep "bin/taosd -c"|grep -v "grep" |awk \'{print $2}\')|awk \'END{print}\' |awk \'{print $9}\'')[1]) + if taosd_cpu_load_2 < 10.0 : + suc_kill = 60 + else: + suc_kill = 10 + print("taosd_cpu_load is higher than 10%") + else: + suc_kill = 20 + print("taosd_cpu_load is still less than 10%") + tdSql.query("select count (tbname) from stb0") + tdSql.checkData(0, 0, "%d" % suc_kill) + os.system("rm -rf querySystemInfo*") + os.system("rm -rf insert_res.txt") + os.system("rm -rf query_res.txt") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoAllTest/TD-3453/queryall.json b/tests/pytest/tools/taosdemoAllTest/TD-3453/queryall.json new file mode 100644 index 0000000000000000000000000000000000000000..62b6e7472aa779888a45603b06cf54a528923dec --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/TD-3453/queryall.json @@ -0,0 +1,20 @@ +{ + "filetype":"query", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "confirm_parameter_prompt": "no", + "databases": "db", + "specified_table_query":{ + "query_interval":1, + "concurrent":1, + "sqls":[ + { + "sql": "select * from stb0", + "result": "./query_res.txt" + } + ] + } +} \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/TD-4985/query-limit-offset.csv b/tests/pytest/tools/taosdemoAllTest/TD-4985/query-limit-offset.csv new file mode 100644 index 0000000000000000000000000000000000000000..d4138798e350bb1d0aff25819c01f87604b763bc --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/TD-4985/query-limit-offset.csv @@ -0,0 +1,10 @@ +0,0,'TAOSdata-0' +1,1,'TAOSdata-1' +2,22,'TAOSdata-2' +3,333,'TAOSdata-3' +4,4444,'TAOSdata-4' +5,55555,'TAOSdata-5' +6,666666,'TAOSdata-6' +7,7777777,'TAOSdata-7' +8,88888888,'TAOSdata-8' +9,999999999,'TAOSdata-9' \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/TD-4985/query-limit-offset.json b/tests/pytest/tools/taosdemoAllTest/TD-4985/query-limit-offset.json new file mode 100644 index 0000000000000000000000000000000000000000..ad85f9607b72c5d4562266508bfdcf68837c33bd --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/TD-4985/query-limit-offset.json @@ -0,0 +1,62 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 10, + "thread_count_create_tbl": 10, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10, + "num_of_records_per_req": 1, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 10000, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 1, + "data_source": "sample", + "insert_mode": "taosc", + "insert_rows": 10, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./tools/taosdemoAllTest/TD-4985/query-limit-offset.csv", + "tags_file": "./tools/taosdemoAllTest/TD-4985/query-limit-offset.csv", + "columns": [{"type": "INT","count":2}, {"type": "BINARY", "len": 16, "count":1}], + "tags": [{"type": "INT", "count":2}, {"type": "BINARY", "len": 16, "count":1}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/TD-4985/query-limit-offset.py b/tests/pytest/tools/taosdemoAllTest/TD-4985/query-limit-offset.py new file mode 100644 index 0000000000000000000000000000000000000000..aad28fee8188281fc94d8e20f728007630c3ab4b --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/TD-4985/query-limit-offset.py @@ -0,0 +1,196 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +import time +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + now = time.time() + + print(int(round(now * 1000))) + + self.ts = int(round(now * 1000)) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def run(self): + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + + # insert: create one or mutiple tables per sql and insert multiple rows per sql + # test case for https://jira.taosdata.com:18080/browse/TD-4985 + os.system("rm -rf tools/taosdemoAllTest/TD-4985/query-limit-offset.py.sql") + os.system("%staosdemo -f tools/taosdemoAllTest/TD-4985/query-limit-offset.json -y " % binPath) + tdSql.execute("use db") + tdSql.query("select count (tbname) from stb0") + tdSql.checkData(0, 0, 10000) + + for i in range(1000): + tdSql.execute('''insert into stb00_9999 values(%d, %d, %d,'test99.%s')''' + % (self.ts + i, i, -10000+i, i)) + tdSql.execute('''insert into stb00_8888 values(%d, %d, %d,'test98.%s')''' + % (self.ts + i, i, -10000+i, i)) + tdSql.execute('''insert into stb00_7777 values(%d, %d, %d,'test97.%s')''' + % (self.ts + i, i, -10000+i, i)) + tdSql.execute('''insert into stb00_6666 values(%d, %d, %d,'test96.%s')''' + % (self.ts + i, i, -10000+i, i)) + tdSql.execute('''insert into stb00_5555 values(%d, %d, %d,'test95.%s')''' + % (self.ts + i, i, -10000+i, i)) + tdSql.execute('''insert into stb00_4444 values(%d, %d, %d,'test94.%s')''' + % (self.ts + i, i, -10000+i, i)) + tdSql.execute('''insert into stb00_3333 values(%d, %d, %d,'test93.%s')''' + % (self.ts + i, i, -10000+i, i)) + tdSql.execute('''insert into stb00_2222 values(%d, %d, %d,'test92.%s')''' + % (self.ts + i, i, -10000+i, i)) + tdSql.execute('''insert into stb00_1111 values(%d, %d, %d,'test91.%s')''' + % (self.ts + i, i, -10000+i, i)) + tdSql.execute('''insert into stb00_100 values(%d, %d, %d,'test90.%s')''' + % (self.ts + i, i, -10000+i, i)) + tdSql.query("select * from stb0 where c2 like 'test99%' ") + tdSql.checkRows(1000) + + tdSql.query("select * from stb0 where tbname like 'stb00_9999' limit 10" ) + tdSql.checkData(0, 1, 0) + tdSql.checkData(1, 1, 1) + tdSql.checkData(2, 1, 2) + tdSql.query("select * from stb0 where tbname like 'stb00_9999' limit 10 offset 5" ) + tdSql.checkData(0, 1, 5) + tdSql.checkData(1, 1, 6) + tdSql.checkData(2, 1, 7) + tdSql.query("select * from stb0 where c2 like 'test98%' ") + tdSql.checkRows(1000) + tdSql.query("select * from stb0 where tbname like 'stb00_8888' limit 10" ) + tdSql.checkData(0, 1, 0) + tdSql.checkData(1, 1, 1) + tdSql.checkData(2, 1, 2) + tdSql.query("select * from stb0 where tbname like 'stb00_8888' limit 10 offset 5" ) + tdSql.checkData(0, 1, 5) + tdSql.checkData(1, 1, 6) + tdSql.checkData(2, 1, 7) + tdSql.query("select * from stb0 where c2 like 'test97%' ") + tdSql.checkRows(1000) + tdSql.query("select * from stb0 where tbname like 'stb00_7777' limit 10" ) + tdSql.checkData(0, 1, 0) + tdSql.checkData(1, 1, 1) + tdSql.checkData(2, 1, 2) + tdSql.query("select * from stb0 where tbname like 'stb00_7777' limit 10 offset 5" ) + tdSql.checkData(0, 1, 5) + tdSql.checkData(1, 1, 6) + tdSql.checkData(2, 1, 7) + tdSql.query("select * from stb0 where c2 like 'test96%' ") + tdSql.checkRows(1000) + tdSql.query("select * from stb0 where tbname like 'stb00_6666' limit 10" ) + tdSql.checkData(0, 1, 0) + tdSql.checkData(1, 1, 1) + tdSql.checkData(2, 1, 2) + tdSql.query("select * from stb0 where tbname like 'stb00_6666' limit 10 offset 5" ) + tdSql.checkData(0, 1, 5) + tdSql.checkData(1, 1, 6) + tdSql.checkData(2, 1, 7) + tdSql.query("select * from stb0 where c2 like 'test95%' ") + tdSql.checkRows(1000) + tdSql.query("select * from stb0 where tbname like 'stb00_5555' limit 10" ) + tdSql.checkData(0, 1, 0) + tdSql.checkData(1, 1, 1) + tdSql.checkData(2, 1, 2) + tdSql.query("select * from stb0 where tbname like 'stb00_5555' limit 10 offset 5" ) + tdSql.checkData(0, 1, 5) + tdSql.checkData(1, 1, 6) + tdSql.checkData(2, 1, 7) + tdSql.query("select * from stb0 where c2 like 'test94%' ") + tdSql.checkRows(1000) + tdSql.query("select * from stb0 where tbname like 'stb00_4444' limit 10" ) + tdSql.checkData(0, 1, 0) + tdSql.checkData(1, 1, 1) + tdSql.checkData(2, 1, 2) + tdSql.query("select * from stb0 where tbname like 'stb00_4444' limit 10 offset 5" ) + tdSql.checkData(0, 1, 5) + tdSql.checkData(1, 1, 6) + tdSql.checkData(2, 1, 7) + tdSql.query("select * from stb0 where c2 like 'test93%' ") + tdSql.checkRows(1000) + tdSql.query("select * from stb0 where tbname like 'stb00_3333' limit 100" ) + tdSql.checkData(0, 1, 0) + tdSql.checkData(1, 1, 1) + tdSql.checkData(2, 1, 2) + tdSql.query("select * from stb0 where tbname like 'stb00_3333' limit 100 offset 5" ) + tdSql.checkData(0, 1, 5) + tdSql.checkData(1, 1, 6) + tdSql.checkData(2, 1, 7) + tdSql.query("select * from stb0 where c2 like 'test92%' ") + tdSql.checkRows(1000) + tdSql.query("select * from stb0 where tbname like 'stb00_2222' limit 100" ) + tdSql.checkData(0, 1, 0) + tdSql.checkData(1, 1, 1) + tdSql.checkData(2, 1, 2) + tdSql.query("select * from stb0 where tbname like 'stb00_2222' limit 100 offset 5" ) + tdSql.checkData(0, 1, 5) + tdSql.checkData(1, 1, 6) + tdSql.checkData(2, 1, 7) + tdSql.query("select * from stb0 where c2 like 'test91%' ") + tdSql.checkRows(1000) + tdSql.query("select * from stb0 where tbname like 'stb00_1111' limit 100" ) + tdSql.checkData(0, 1, 0) + tdSql.checkData(1, 1, 1) + tdSql.checkData(2, 1, 2) + tdSql.query("select * from stb0 where tbname like 'stb00_1111' limit 100 offset 5" ) + tdSql.checkData(0, 1, 5) + tdSql.checkData(1, 1, 6) + tdSql.checkData(2, 1, 7) + tdSql.query("select * from stb0 where c2 like 'test90%' ") + tdSql.checkRows(1000) + tdSql.query("select * from stb0 where tbname like 'stb00_100' limit 100" ) + tdSql.checkData(0, 1, 0) + tdSql.checkData(1, 1, 1) + tdSql.checkData(2, 1, 2) + tdSql.query("select * from stb0 where tbname like 'stb00_100' limit 100 offset 5" ) + tdSql.checkData(0, 1, 5) + tdSql.checkData(1, 1, 6) + tdSql.checkData(2, 1, 7) + os.system("rm -rf tools/taosdemoAllTest/TD-4985/query-limit-offset.py.sql") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoAllTest/TD-5213/insert4096columns_not_use_taosdemo.py b/tests/pytest/tools/taosdemoAllTest/TD-5213/insert4096columns_not_use_taosdemo.py new file mode 100644 index 0000000000000000000000000000000000000000..5f10587032b5b114688af4f5f6bb3017c0d2cc8e --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/TD-5213/insert4096columns_not_use_taosdemo.py @@ -0,0 +1,704 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import random +import string +import os +import time +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +from util.dnodes import tdDnodes + +class TDTestCase: + updatecfgDict={'maxSQLLength':1048576} + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + now = time.time() + self.ts = int(round(now * 1000)) + self.num = 100 + + def get_random_string(self, length): + letters = string.ascii_lowercase + result_str = ''.join(random.choice(letters) for i in range(length)) + return result_str + + def run(self): + tdSql.prepare() + # test case for https://jira.taosdata.com:18080/browse/TD-5213 + + print("==============step1, regular table, 1 ts + 4094 cols + 1 binary==============") + startTime = time.time() + sql = "create table regular_table_1(ts timestamp, " + for i in range(4094): + sql += "col%d int, " % (i + 1) + sql += "col4095 binary(22))" + tdLog.info(len(sql)) + tdSql.execute(sql) + + for i in range(self.num): + sql = "insert into regular_table_1 values(%d, " + for j in range(4094): + str = "'%s', " % random.randint(0,1000) + sql += str + sql += "'%s')" % self.get_random_string(22) + tdSql.execute(sql % (self.ts + i)) + time.sleep(1) + tdSql.query("select count(*) from regular_table_1") + tdSql.checkData(0, 0, self.num) + tdSql.query("select * from regular_table_1") + tdSql.checkRows(self.num) + tdSql.checkCols(4096) + + endTime = time.time() + print("total time %ds" % (endTime - startTime)) + + #insert in order + tdLog.info('test insert in order') + for i in range(self.num): + sql = "insert into regular_table_1 (ts,col1,col2,col3,col4,col5,col6,col7,col8,col9,col10,col4095) values(%d, " + for j in range(10): + str = "'%s', " % random.randint(0,1000) + sql += str + sql += "'%s')" % self.get_random_string(22) + tdSql.execute(sql % (self.ts + i + 1000)) + time.sleep(1) + tdSql.query("select count(*) from regular_table_1") + tdSql.checkData(0, 0, 2*self.num) + tdSql.query("select * from regular_table_1") + tdSql.checkRows(2*self.num) + tdSql.checkCols(4096) + + #insert out of order + tdLog.info('test insert out of order') + for i in range(self.num): + sql = "insert into regular_table_1 (ts,col123,col2213,col331,col41,col523,col236,col71,col813,col912,col1320,col4095) values(%d, " + for j in range(10): + str = "'%s', " % random.randint(0,1000) + sql += str + sql += "'%s')" % self.get_random_string(22) + tdSql.execute(sql % (self.ts + i + 2000)) + time.sleep(1) + tdSql.query("select count(*) from regular_table_1") + tdSql.checkData(0, 0, 3*self.num) + tdSql.query("select * from regular_table_1") + tdSql.checkRows(3*self.num) + tdSql.checkCols(4096) + + + print("==============step2,regular table error col or value==============") + tdLog.info('test regular table exceeds row num') + # column > 4096 + sql = "create table regular_table_2(ts timestamp, " + for i in range(4095): + sql += "col%d int, " % (i + 1) + sql += "col4096 binary(22))" + tdLog.info(len(sql)) + tdSql.error(sql) + + # column > 4096 + sql = "insert into regular_table_1 values(%d, " + for j in range(4095): + str = "'%s', " % random.randint(0,1000) + sql += str + sql += "'%s')" % self.get_random_string(22) + tdSql.error(sql) + + # insert column < 4096 + sql = "insert into regular_table_1 values(%d, " + for j in range(4092): + str = "'%s', " % random.randint(0,1000) + sql += str + sql += "'%s')" % self.get_random_string(22) + tdSql.error(sql) + + # alter column > 4096 + sql = "alter table regular_table_1 add column max int; " + tdSql.error(sql) + + print("==============step3,regular table , mix data type==============") + startTime = time.time() + sql = "create table regular_table_3(ts timestamp, " + for i in range(2000): + sql += "col%d int, " % (i + 1) + for i in range(2000,4094): + sql += "col%d bigint, " % (i + 1) + sql += "col4095 binary(22))" + tdLog.info(len(sql)) + tdSql.execute(sql) + + for i in range(self.num): + sql = "insert into regular_table_3 values(%d, " + for j in range(4094): + str = "'%s', " % random.randint(0,1000) + sql += str + sql += "'%s')" % self.get_random_string(22) + tdSql.execute(sql % (self.ts + i)) + time.sleep(1) + tdSql.query("select count(*) from regular_table_3") + tdSql.checkData(0, 0, self.num) + tdSql.query("select * from regular_table_3") + tdSql.checkRows(self.num) + tdSql.checkCols(4096) + + endTime = time.time() + print("total time %ds" % (endTime - startTime)) + + sql = "create table regular_table_4(ts timestamp, " + for i in range(500): + sql += "int_%d int, " % (i + 1) + for i in range(500,1000): + sql += "smallint_%d smallint, " % (i + 1) + for i in range(1000,1500): + sql += "tinyint_%d tinyint, " % (i + 1) + for i in range(1500,2000): + sql += "double_%d double, " % (i + 1) + for i in range(2000,2500): + sql += "float_%d float, " % (i + 1) + for i in range(2500,3000): + sql += "bool_%d bool, " % (i + 1) + for i in range(3000,3500): + sql += "bigint_%d bigint, " % (i + 1) + for i in range(3500,3800): + sql += "nchar_%d nchar(4), " % (i + 1) + for i in range(3800,4090): + sql += "binary_%d binary(10), " % (i + 1) + for i in range(4090,4094): + sql += "timestamp_%d timestamp, " % (i + 1) + sql += "col4095 binary(22))" + tdLog.info(len(sql)) + tdSql.execute(sql) + + for i in range(self.num): + sql = "insert into regular_table_4 values(%d, " + for j in range(500): + str = "'%s', " % random.randint(-2147483647,2147483647) + sql += str + for j in range(500,1000): + str = "'%s', " % random.randint(-32767,32767 ) + sql += str + for j in range(1000,1500): + str = "'%s', " % random.randint(-127,127) + sql += str + for j in range(1500,2000): + str = "'%s', " % random.randint(-922337203685477580700,922337203685477580700) + sql += str + for j in range(2000,2500): + str = "'%s', " % random.randint(-92233720368547758070,92233720368547758070) + sql += str + for j in range(2500,3000): + str = "'%s', " % random.choice(['true','false']) + sql += str + for j in range(3000,3500): + str = "'%s', " % random.randint(-9223372036854775807,9223372036854775807) + sql += str + for j in range(3500,3800): + str = "'%s', " % self.get_random_string(4) + sql += str + for j in range(3800,4090): + str = "'%s', " % self.get_random_string(10) + sql += str + for j in range(4090,4094): + str = "%s, " % (self.ts + j) + sql += str + sql += "'%s')" % self.get_random_string(22) + tdSql.execute(sql % (self.ts + i)) + time.sleep(1) + tdSql.query("select count(*) from regular_table_4") + tdSql.checkData(0, 0, self.num) + tdSql.query("select * from regular_table_4") + tdSql.checkRows(self.num) + tdSql.checkCols(4096) + tdLog.info("end ,now new one") + + #insert null value + tdLog.info('test insert null value') + for i in range(self.num): + sql = "insert into regular_table_4 values(%d, " + for j in range(2500): + str = "'%s', " % random.choice(['NULL' ,'NULL' ,'NULL' ,1 , 10 ,100 ,-100 ,-10, 88 ,66 ,'NULL' ,'NULL' ,'NULL' ]) + sql += str + for j in range(2500,3000): + str = "'%s', " % random.choice(['true' ,'false']) + sql += str + for j in range(3000,3500): + str = "'%s', " % random.randint(-9223372036854775807,9223372036854775807) + sql += str + for j in range(3500,3800): + str = "'%s', " % self.get_random_string(4) + sql += str + for j in range(3800,4090): + str = "'%s', " % self.get_random_string(10) + sql += str + for j in range(4090,4094): + str = "%s, " % (self.ts + j) + sql += str + sql += "'%s')" % self.get_random_string(22) + tdSql.execute(sql % (self.ts + i + 10000)) + time.sleep(1) + tdSql.query("select count(*) from regular_table_4") + tdSql.checkData(0, 0, 2*self.num) + tdSql.query("select * from regular_table_4") + tdSql.checkRows(2*self.num) + tdSql.checkCols(4096) + + #insert in order + tdLog.info('test insert in order') + for i in range(self.num): + sql = "insert into regular_table_4 (ts,int_2,int_22,int_169,smallint_537,smallint_607,tinyint_1030,tinyint_1491,double_1629,double_1808,float_2075,col4095) values(%d, " + for j in range(10): + str = "'%s', " % random.randint(0,100) + sql += str + sql += "'%s')" % self.get_random_string(22) + tdSql.execute(sql % (self.ts + i + 1000)) + time.sleep(1) + tdSql.query("select count(*) from regular_table_4") + tdSql.checkData(0, 0, 3*self.num) + tdSql.query("select * from regular_table_4") + tdSql.checkRows(3*self.num) + tdSql.checkCols(4096) + + #insert out of order + tdLog.info('test insert out of order') + for i in range(self.num): + sql = "insert into regular_table_4 (ts,int_169,float_2075,int_369,tinyint_1491,tinyint_1030,float_2360,smallint_537,double_1808,double_1608,double_1629,col4095) values(%d, " + for j in range(10): + str = "'%s', " % random.randint(0,100) + sql += str + sql += "'%s')" % self.get_random_string(22) + tdSql.execute(sql % (self.ts + i + 2000)) + time.sleep(1) + tdSql.query("select count(*) from regular_table_4") + tdSql.checkData(0, 0, 4*self.num) + tdSql.query("select * from regular_table_4") + tdSql.checkRows(4*self.num) + tdSql.checkCols(4096) + + #define TSDB_MAX_BYTES_PER_ROW 49151[old:1024 && 16384] + #ts:8\int:4\smallint:2\bigint:8\bool:1\float:4\tinyint:1\nchar:4*()+2[offset]\binary:1*()+2[offset] + tdLog.info('test regular_table max bytes per row 49151') + sql = "create table regular_table_5(ts timestamp, " + for i in range(500): + sql += "int_%d int, " % (i + 1) + for i in range(500,1000): + sql += "smallint_%d smallint, " % (i + 1) + for i in range(1000,1500): + sql += "tinyint_%d tinyint, " % (i + 1) + for i in range(1500,2000): + sql += "double_%d double, " % (i + 1) + for i in range(2000,2500): + sql += "float_%d float, " % (i + 1) + for i in range(2500,3000): + sql += "bool_%d bool, " % (i + 1) + for i in range(3000,3500): + sql += "bigint_%d bigint, " % (i + 1) + for i in range(3500,3800): + sql += "nchar_%d nchar(20), " % (i + 1) + for i in range(3800,4090): + sql += "binary_%d binary(34), " % (i + 1) + for i in range(4090,4094): + sql += "timestamp_%d timestamp, " % (i + 1) + sql += "col4095 binary(69))" + tdSql.execute(sql) + tdSql.query("select * from regular_table_5") + tdSql.checkCols(4096) + # TD-5324 + sql = "alter table regular_table_5 modify column col4095 binary(70); " + tdSql.error(sql) + + # drop and add + sql = "alter table regular_table_5 drop column col4095; " + tdSql.execute(sql) + sql = "select * from regular_table_5; " + tdSql.query(sql) + tdSql.checkCols(4095) + sql = "alter table regular_table_5 add column col4095 binary(70); " + tdSql.error(sql) + sql = "alter table regular_table_5 add column col4095 binary(69); " + tdSql.execute(sql) + sql = "select * from regular_table_5; " + tdSql.query(sql) + tdSql.checkCols(4096) + + #out TSDB_MAX_BYTES_PER_ROW 49151 + tdLog.info('test regular_table max bytes per row out 49151') + sql = "create table regular_table_6(ts timestamp, " + for i in range(500): + sql += "int_%d int, " % (i + 1) + for i in range(500,1000): + sql += "smallint_%d smallint, " % (i + 1) + for i in range(1000,1500): + sql += "tinyint_%d tinyint, " % (i + 1) + for i in range(1500,2000): + sql += "double_%d double, " % (i + 1) + for i in range(2000,2500): + sql += "float_%d float, " % (i + 1) + for i in range(2500,3000): + sql += "bool_%d bool, " % (i + 1) + for i in range(3000,3500): + sql += "bigint_%d bigint, " % (i + 1) + for i in range(3500,3800): + sql += "nchar_%d nchar(20), " % (i + 1) + for i in range(3800,4090): + sql += "binary_%d binary(34), " % (i + 1) + for i in range(4090,4094): + sql += "timestamp_%d timestamp, " % (i + 1) + sql += "col4095 binary(70))" + tdLog.info(len(sql)) + tdSql.error(sql) + + + print("==============step4, super table , 1 ts + 4090 cols + 4 tags ==============") + startTime = time.time() + sql = "create stable stable_1(ts timestamp, " + for i in range(4090): + sql += "col%d int, " % (i + 1) + sql += "col4091 binary(22))" + sql += " tags (loc nchar(10),tag_1 int,tag_2 int,tag_3 int) " + tdLog.info(len(sql)) + tdSql.execute(sql) + sql = '''create table table_0 using stable_1 + tags('table_0' , '1' , '2' , '3' );''' + tdSql.execute(sql) + + for i in range(self.num): + sql = "insert into table_0 values(%d, " + for j in range(4090): + str = "'%s', " % random.randint(0,1000) + sql += str + sql += "'%s')" % self.get_random_string(22) + tdSql.execute(sql % (self.ts + i)) + time.sleep(1) + tdSql.query("select count(*) from table_0") + tdSql.checkData(0, 0, self.num) + tdSql.query("select * from table_0") + tdSql.checkRows(self.num) + tdSql.checkCols(4092) + + sql = '''create table table_1 using stable_1 + tags('table_1' , '1' , '2' , '3' );''' + tdSql.execute(sql) + + for i in range(self.num): + sql = "insert into table_1 values(%d, " + for j in range(2080): + sql += "'%d', " % random.randint(0,1000) + for j in range(2080,4080): + sql += "'%s', " % 'NULL' + for j in range(4080,4090): + sql += "'%s', " % random.randint(0,10000) + sql += "'%s')" % self.get_random_string(22) + tdSql.execute(sql % (self.ts + i)) + time.sleep(1) + tdSql.query("select count(*) from table_1") + tdSql.checkData(0, 0, self.num) + tdSql.query("select * from table_1") + tdSql.checkRows(self.num) + tdSql.checkCols(4092) + + endTime = time.time() + print("total time %ds" % (endTime - startTime)) + + #insert in order + tdLog.info('test insert in order') + for i in range(self.num): + sql = "insert into table_1 (ts,col1,col2,col3,col4,col5,col6,col7,col8,col9,col10,col4091) values(%d, " + for j in range(10): + str = "'%s', " % random.randint(0,1000) + sql += str + sql += "'%s')" % self.get_random_string(22) + tdSql.execute(sql % (self.ts + i + 1000)) + time.sleep(1) + tdSql.query("select count(*) from table_1") + tdSql.checkData(0, 0, 2*self.num) + tdSql.query("select * from table_1") + tdSql.checkRows(2*self.num) + tdSql.checkCols(4092) + + #insert out of order + tdLog.info('test insert out of order') + for i in range(self.num): + sql = "insert into table_1 (ts,col123,col2213,col331,col41,col523,col236,col71,col813,col912,col1320,col4091) values(%d, " + for j in range(10): + str = "'%s', " % random.randint(0,1000) + sql += str + sql += "'%s')" % self.get_random_string(22) + tdSql.execute(sql % (self.ts + i + 2000)) + time.sleep(1) + tdSql.query("select count(*) from table_1") + tdSql.checkData(0, 0, 3*self.num) + tdSql.query("select * from table_1") + tdSql.checkRows(3*self.num) + tdSql.checkCols(4092) + + print("==============step5,stable table , mix data type==============") + sql = "create stable stable_3(ts timestamp, " + for i in range(500): + sql += "int_%d int, " % (i + 1) + for i in range(500,1000): + sql += "smallint_%d smallint, " % (i + 1) + for i in range(1000,1500): + sql += "tinyint_%d tinyint, " % (i + 1) + for i in range(1500,2000): + sql += "double_%d double, " % (i + 1) + for i in range(2000,2500): + sql += "float_%d float, " % (i + 1) + for i in range(2500,3000): + sql += "bool_%d bool, " % (i + 1) + for i in range(3000,3500): + sql += "bigint_%d bigint, " % (i + 1) + for i in range(3500,3800): + sql += "nchar_%d nchar(4), " % (i + 1) + for i in range(3800,4090): + sql += "binary_%d binary(10), " % (i + 1) + sql += "col4091 binary(22))" + sql += " tags (loc nchar(10),tag_1 int,tag_2 int,tag_3 int) " + tdLog.info(len(sql)) + tdSql.execute(sql) + sql = '''create table table_30 using stable_3 + tags('table_30' , '1' , '2' , '3' );''' + tdSql.execute(sql) + + for i in range(self.num): + sql = "insert into table_30 values(%d, " + for j in range(500): + str = "'%s', " % random.randint(-2147483647,2147483647) + sql += str + for j in range(500,1000): + str = "'%s', " % random.randint(-32767,32767 ) + sql += str + for j in range(1000,1500): + str = "'%s', " % random.randint(-127,127) + sql += str + for j in range(1500,2000): + str = "'%s', " % random.randint(-922337203685477580700,922337203685477580700) + sql += str + for j in range(2000,2500): + str = "'%s', " % random.randint(-92233720368547758070,92233720368547758070) + sql += str + for j in range(2500,3000): + str = "'%s', " % random.choice(['true','false']) + sql += str + for j in range(3000,3500): + str = "'%s', " % random.randint(-9223372036854775807,9223372036854775807) + sql += str + for j in range(3500,3800): + str = "'%s', " % self.get_random_string(4) + sql += str + for j in range(3800,4090): + str = "'%s', " % self.get_random_string(10) + sql += str + sql += "'%s')" % self.get_random_string(22) + tdSql.execute(sql % (self.ts + i)) + time.sleep(1) + tdSql.query("select count(*) from table_30") + tdSql.checkData(0, 0, self.num) + tdSql.query("select * from table_30") + tdSql.checkRows(self.num) + tdSql.checkCols(4092) + + #insert null value + tdLog.info('test insert null value') + sql = '''create table table_31 using stable_3 + tags('table_31' , '1' , '2' , '3' );''' + tdSql.execute(sql) + + for i in range(self.num): + sql = "insert into table_31 values(%d, " + for j in range(2500): + str = "'%s', " % random.choice(['NULL' ,'NULL' ,'NULL' ,1 , 10 ,100 ,-100 ,-10, 88 ,66 ,'NULL' ,'NULL' ,'NULL' ]) + sql += str + for j in range(2500,3000): + str = "'%s', " % random.choice(['true' ,'false']) + sql += str + for j in range(3000,3500): + str = "'%s', " % random.randint(-9223372036854775807,9223372036854775807) + sql += str + for j in range(3500,3800): + str = "'%s', " % self.get_random_string(4) + sql += str + for j in range(3800,4090): + str = "'%s', " % self.get_random_string(10) + sql += str + sql += "'%s')" % self.get_random_string(22) + tdSql.execute(sql % (self.ts + i)) + time.sleep(1) + tdSql.query("select count(*) from table_31") + tdSql.checkData(0, 0, self.num) + tdSql.query("select * from table_31") + tdSql.checkRows(self.num) + tdSql.checkCols(4092) + + #insert in order + tdLog.info('test insert in order') + for i in range(self.num): + sql = "insert into table_31 (ts,int_2,int_22,int_169,smallint_537,smallint_607,tinyint_1030,tinyint_1491,double_1629,double_1808,float_2075,col4091) values(%d, " + for j in range(10): + str = "'%s', " % random.randint(0,100) + sql += str + sql += "'%s')" % self.get_random_string(22) + tdSql.execute(sql % (self.ts + i + 1000)) + time.sleep(1) + tdSql.query("select count(*) from table_31") + tdSql.checkData(0, 0, 2*self.num) + tdSql.query("select * from table_31") + tdSql.checkRows(2*self.num) + tdSql.checkCols(4092) + + #insert out of order + tdLog.info('test insert out of order') + for i in range(self.num): + sql = "insert into table_31 (ts,int_169,float_2075,int_369,tinyint_1491,tinyint_1030,float_2360,smallint_537,double_1808,double_1608,double_1629,col4091) values(%d, " + for j in range(10): + str = "'%s', " % random.randint(0,100) + sql += str + sql += "'%s')" % self.get_random_string(22) + tdSql.execute(sql % (self.ts + i + 2000)) + time.sleep(1) + tdSql.query("select count(*) from table_31") + tdSql.checkData(0, 0, 3*self.num) + tdSql.query("select * from table_31") + tdSql.checkRows(3*self.num) + tdSql.checkCols(4092) + + #define TSDB_MAX_BYTES_PER_ROW 49151 TSDB_MAX_TAGS_LEN 16384 + #ts:8\int:4\smallint:2\bigint:8\bool:1\float:4\tinyint:1\nchar:4*()+2[offset]\binary:1*()+2[offset] + tdLog.info('test super table max bytes per row 49151') + sql = "create table stable_4(ts timestamp, " + for i in range(500): + sql += "int_%d int, " % (i + 1) + for i in range(500,1000): + sql += "smallint_%d smallint, " % (i + 1) + for i in range(1000,1500): + sql += "tinyint_%d tinyint, " % (i + 1) + for i in range(1500,2000): + sql += "double_%d double, " % (i + 1) + for i in range(2000,2500): + sql += "float_%d float, " % (i + 1) + for i in range(2500,3000): + sql += "bool_%d bool, " % (i + 1) + for i in range(3000,3500): + sql += "bigint_%d bigint, " % (i + 1) + for i in range(3500,3800): + sql += "nchar_%d nchar(20), " % (i + 1) + for i in range(3800,4090): + sql += "binary_%d binary(34), " % (i + 1) + sql += "col4091 binary(101))" + sql += " tags (loc nchar(10),tag_1 int,tag_2 int,tag_3 int) " + tdSql.execute(sql) + sql = '''create table table_40 using stable_4 + tags('table_40' , '1' , '2' , '3' );''' + tdSql.execute(sql) + tdSql.query("select * from table_40") + tdSql.checkCols(4092) + tdSql.query("describe table_40") + tdSql.checkRows(4096) + + tdLog.info('test super table drop and add column or tag') + sql = "alter stable stable_4 drop column col4091; " + tdSql.execute(sql) + sql = "select * from stable_4; " + tdSql.query(sql) + tdSql.checkCols(4095) + sql = "alter table stable_4 add column col4091 binary(102); " + tdSql.error(sql) + sql = "alter table stable_4 add column col4091 binary(101); " + tdSql.execute(sql) + sql = "select * from stable_4; " + tdSql.query(sql) + tdSql.checkCols(4096) + + sql = "alter stable stable_4 drop tag tag_1; " + tdSql.execute(sql) + sql = "select * from stable_4; " + tdSql.query(sql) + tdSql.checkCols(4095) + sql = "alter table stable_4 add tag tag_1 int; " + tdSql.execute(sql) + sql = "select * from stable_4; " + tdSql.query(sql) + tdSql.checkCols(4096) + sql = "alter table stable_4 add tag loc1 nchar(10); " + tdSql.error(sql) + + tdLog.info('test super table max bytes per row 49151') + sql = "create table stable_5(ts timestamp, " + for i in range(500): + sql += "int_%d int, " % (i + 1) + for i in range(500,1000): + sql += "smallint_%d smallint, " % (i + 1) + for i in range(1000,1500): + sql += "tinyint_%d tinyint, " % (i + 1) + for i in range(1500,2000): + sql += "double_%d double, " % (i + 1) + for i in range(2000,2500): + sql += "float_%d float, " % (i + 1) + for i in range(2500,3000): + sql += "bool_%d bool, " % (i + 1) + for i in range(3000,3500): + sql += "bigint_%d bigint, " % (i + 1) + for i in range(3500,3800): + sql += "nchar_%d nchar(20), " % (i + 1) + for i in range(3800,4090): + sql += "binary_%d binary(34), " % (i + 1) + sql += "col4091 binary(102))" + sql += " tags (loc nchar(10),tag_1 int,tag_2 int,tag_3 int) " + tdSql.error(sql) + + print("==============step6, super table error col ==============") + tdLog.info('test exceeds row num') + # column + tag > 4096 + sql = "create stable stable_2(ts timestamp, " + for i in range(4091): + sql += "col%d int, " % (i + 1) + sql += "col4092 binary(22))" + sql += " tags (loc nchar(10),tag_1 int,tag_2 int,tag_3 int) " + tdLog.info(len(sql)) + tdSql.error(sql) + + # column + tag > 4096 + sql = "create stable stable_2(ts timestamp, " + for i in range(4090): + sql += "col%d int, " % (i + 1) + sql += "col4091 binary(22))" + sql += " tags (loc nchar(10),tag_1 int,tag_2 int,tag_3 int,tag_4 int) " + tdLog.info(len(sql)) + tdSql.error(sql) + + # alter column + tag > 4096 + sql = "alter table stable_1 add column max int; " + tdSql.error(sql) + # TD-5322 + sql = "alter table stable_1 add tag max int; " + tdSql.error(sql) + # TD-5324 + sql = "alter table stable_4 modify column col4091 binary(102); " + tdSql.error(sql) + sql = "alter table stable_4 modify tag loc nchar(20); " + tdSql.query("select * from table_40") + tdSql.checkCols(4092) + tdSql.query("describe table_40") + tdSql.checkRows(4096) + + os.system("rm -rf tools/taosdemoAllTest/TD-5213/insert4096columns_not_use_taosdemo.py.sql") + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.csv b/tests/pytest/tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.csv new file mode 100755 index 0000000000000000000000000000000000000000..5b30be5b4c4d5c323141097af6207ffb8bb93449 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.csv @@ -0,0 +1,3 @@ +1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 704, 705, 706, 707, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 729, 730, 731, 732, 733, 734, 735, 736, 737, 738, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 795, 796, 797, 798, 799, 800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835, 836, 837, 838, 839, 840, 841, 842, 843, 844, 845, 846, 847, 848, 849, 850, 851, 852, 853, 854, 855, 856, 857, 858, 859, 860, 861, 862, 863, 864, 865, 866, 867, 868, 869, 870, 871, 872, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, 890, 891, 892, 893, 894, 895, 896, 897, 898, 899, 900, 901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1120, 1121, 1122, 1123, 1124, 1125, 1126, 1127, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1138, 1139, 1140, 1141, 1142, 1143, 1144, 1145, 1146, 1147, 1148, 1149, 1150, 1151, 1152, 1153, 1154, 1155, 1156, 1157, 1158, 1159, 1160, 1161, 1162, 1163, 1164, 1165, 1166, 1167, 1168, 1169, 1170, 1171, 1172, 1173, 1174, 1175, 1176, 1177, 1178, 1179, 1180, 1181, 1182, 1183, 1184, 1185, 1186, 1187, 1188, 1189, 1190, 1191, 1192, 1193, 1194, 1195, 1196, 1197, 1198, 1199, 1200, 1201, 1202, 1203, 1204, 1205, 1206, 1207, 1208, 1209, 1210, 1211, 1212, 1213, 1214, 1215, 1216, 1217, 1218, 1219, 1220, 1221, 1222, 1223, 1224, 1225, 1226, 1227, 1228, 1229, 1230, 1231, 1232, 1233, 1234, 1235, 1236, 1237, 1238, 1239, 1240, 1241, 1242, 1243, 1244, 1245, 1246, 1247, 1248, 1249, 1250, 1251, 1252, 1253, 1254, 1255, 1256, 1257, 1258, 1259, 1260, 1261, 1262, 1263, 1264, 1265, 1266, 1267, 1268, 1269, 1270, 1271, 1272, 1273, 1274, 1275, 1276, 1277, 1278, 1279, 1280, 1281, 1282, 1283, 1284, 1285, 1286, 1287, 1288, 1289, 1290, 1291, 1292, 1293, 1294, 1295, 1296, 1297, 1298, 1299, 1300, 1301, 1302, 1303, 1304, 1305, 1306, 1307, 1308, 1309, 1310, 1311, 1312, 1313, 1314, 1315, 1316, 1317, 1318, 1319, 1320, 1321, 1322, 1323, 1324, 1325, 1326, 1327, 1328, 1329, 1330, 1331, 1332, 1333, 1334, 1335, 1336, 1337, 1338, 1339, 1340, 1341, 1342, 1343, 1344, 1345, 1346, 1347, 1348, 1349, 1350, 1351, 1352, 1353, 1354, 1355, 1356, 1357, 1358, 1359, 1360, 1361, 1362, 1363, 1364, 1365, 1366, 1367, 1368, 1369, 1370, 1371, 1372, 1373, 1374, 1375, 1376, 1377, 1378, 1379, 1380, 1381, 1382, 1383, 1384, 1385, 1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, 1395, 1396, 1397, 1398, 1399, 1400, 1401, 1402, 1403, 1404, 1405, 1406, 1407, 1408, 1409, 1410, 1411, 1412, 1413, 1414, 1415, 1416, 1417, 1418, 1419, 1420, 1421, 1422, 1423, 1424, 1425, 1426, 1427, 1428, 1429, 1430, 1431, 1432, 1433, 1434, 1435, 1436, 1437, 1438, 1439, 1440, 1441, 1442, 1443, 1444, 1445, 1446, 1447, 1448, 1449, 1450, 1451, 1452, 1453, 1454, 1455, 1456, 1457, 1458, 1459, 1460, 1461, 1462, 1463, 1464, 1465, 1466, 1467, 1468, 1469, 1470, 1471, 1472, 1473, 1474, 1475, 1476, 1477, 1478, 1479, 1480, 1481, 1482, 1483, 1484, 1485, 1486, 1487, 1488, 1489, 1490, 1491, 1492, 1493, 1494, 1495, 1496, 1497, 1498, 1499, 1500, 1501, 1502, 1503, 1504, 1505, 1506, 1507, 1508, 1509, 1510, 1511, 1512, 1513, 1514, 1515, 1516, 1517, 1518, 1519, 1520, 1521, 1522, 1523, 1524, 1525, 1526, 1527, 1528, 1529, 1530, 1531, 1532, 1533, 1534, 1535, 1536, 1537, 1538, 1539, 1540, 1541, 1542, 1543, 1544, 1545, 1546, 1547, 1548, 1549, 1550, 1551, 1552, 1553, 1554, 1555, 1556, 1557, 1558, 1559, 1560, 1561, 1562, 1563, 1564, 1565, 1566, 1567, 1568, 1569, 1570, 1571, 1572, 1573, 1574, 1575, 1576, 1577, 1578, 1579, 1580, 1581, 1582, 1583, 1584, 1585, 1586, 1587, 1588, 1589, 1590, 1591, 1592, 1593, 1594, 1595, 1596, 1597, 1598, 1599, 1600, 1601, 1602, 1603, 1604, 1605, 1606, 1607, 1608, 1609, 1610, 1611, 1612, 1613, 1614, 1615, 1616, 1617, 1618, 1619, 1620, 1621, 1622, 1623, 1624, 1625, 1626, 1627, 1628, 1629, 1630, 1631, 1632, 1633, 1634, 1635, 1636, 1637, 1638, 1639, 1640, 1641, 1642, 1643, 1644, 1645, 1646, 1647, 1648, 1649, 1650, 1651, 1652, 1653, 1654, 1655, 1656, 1657, 1658, 1659, 1660, 1661, 1662, 1663, 1664, 1665, 1666, 1667, 1668, 1669, 1670, 1671, 1672, 1673, 1674, 1675, 1676, 1677, 1678, 1679, 1680, 1681, 1682, 1683, 1684, 1685, 1686, 1687, 1688, 1689, 1690, 1691, 1692, 1693, 1694, 1695, 1696, 1697, 1698, 1699, 1700, 1701, 1702, 1703, 1704, 1705, 1706, 1707, 1708, 1709, 1710, 1711, 1712, 1713, 1714, 1715, 1716, 1717, 1718, 1719, 1720, 1721, 1722, 1723, 1724, 1725, 1726, 1727, 1728, 1729, 1730, 1731, 1732, 1733, 1734, 1735, 1736, 1737, 1738, 1739, 1740, 1741, 1742, 1743, 1744, 1745, 1746, 1747, 1748, 1749, 1750, 1751, 1752, 1753, 1754, 1755, 1756, 1757, 1758, 1759, 1760, 1761, 1762, 1763, 1764, 1765, 1766, 1767, 1768, 1769, 1770, 1771, 1772, 1773, 1774, 1775, 1776, 1777, 1778, 1779, 1780, 1781, 1782, 1783, 1784, 1785, 1786, 1787, 1788, 1789, 1790, 1791, 1792, 1793, 1794, 1795, 1796, 1797, 1798, 1799, 1800, 1801, 1802, 1803, 1804, 1805, 1806, 1807, 1808, 1809, 1810, 1811, 1812, 1813, 1814, 1815, 1816, 1817, 1818, 1819, 1820, 1821, 1822, 1823, 1824, 1825, 1826, 1827, 1828, 1829, 1830, 1831, 1832, 1833, 1834, 1835, 1836, 1837, 1838, 1839, 1840, 1841, 1842, 1843, 1844, 1845, 1846, 1847, 1848, 1849, 1850, 1851, 1852, 1853, 1854, 1855, 1856, 1857, 1858, 1859, 1860, 1861, 1862, 1863, 1864, 1865, 1866, 1867, 1868, 1869, 1870, 1871, 1872, 1873, 1874, 1875, 1876, 1877, 1878, 1879, 1880, 1881, 1882, 1883, 1884, 1885, 1886, 1887, 1888, 1889, 1890, 1891, 1892, 1893, 1894, 1895, 1896, 1897, 1898, 1899, 1900, 1901, 1902, 1903, 1904, 1905, 1906, 1907, 1908, 1909, 1910, 1911, 1912, 1913, 1914, 1915, 1916, 1917, 1918, 1919, 1920, 1921, 1922, 1923, 1924, 1925, 1926, 1927, 1928, 1929, 1930, 1931, 1932, 1933, 1934, 1935, 1936, 1937, 1938, 1939, 1940, 1941, 1942, 1943, 1944, 1945, 1946, 1947, 1948, 1949, 1950, 1951, 1952, 1953, 1954, 1955, 1956, 1957, 1958, 1959, 1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027, 2028, 2029, 2030, 2031, 2032, 2033, 2034, 2035, 2036, 2037, 2038, 2039, 2040, 2041, 2042, 2043, 2044, 2045, 2046, 2047, 2048, 2049, 2050, 2051, 2052, 2053, 2054, 2055, 2056, 2057, 2058, 2059, 2060, 2061, 2062, 2063, 2064, 2065, 2066, 2067, 2068, 2069, 2070, 2071, 2072, 2073, 2074, 2075, 2076, 2077, 2078, 2079, 2080, 2081, 2082, 2083, 2084, 2085, 2086, 2087, 2088, 2089, 2090, 2091, 2092, 2093, 2094, 2095, 2096, 2097, 2098, 2099, 2100, 2101, 2102, 2103, 2104, 2105, 2106, 2107, 2108, 2109, 2110, 2111, 2112, 2113, 2114, 2115, 2116, 2117, 2118, 2119, 2120, 2121, 2122, 2123, 2124, 2125, 2126, 2127, 2128, 2129, 2130, 2131, 2132, 2133, 2134, 2135, 2136, 2137, 2138, 2139, 2140, 2141, 2142, 2143, 2144, 2145, 2146, 2147, 2148, 2149, 2150, 2151, 2152, 2153, 2154, 2155, 2156, 2157, 2158, 2159, 2160, 2161, 2162, 2163, 2164, 2165, 2166, 2167, 2168, 2169, 2170, 2171, 2172, 2173, 2174, 2175, 2176, 2177, 2178, 2179, 2180, 2181, 2182, 2183, 2184, 2185, 2186, 2187, 2188, 2189, 2190, 2191, 2192, 2193, 2194, 2195, 2196, 2197, 2198, 2199, 2200, 2201, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209, 2210, 2211, 2212, 2213, 2214, 2215, 2216, 2217, 2218, 2219, 2220, 2221, 2222, 2223, 2224, 2225, 2226, 2227, 2228, 2229, 2230, 2231, 2232, 2233, 2234, 2235, 2236, 2237, 2238, 2239, 2240, 2241, 2242, 2243, 2244, 2245, 2246, 2247, 2248, 2249, 2250, 2251, 2252, 2253, 2254, 2255, 2256, 2257, 2258, 2259, 2260, 2261, 2262, 2263, 2264, 2265, 2266, 2267, 2268, 2269, 2270, 2271, 2272, 2273, 2274, 2275, 2276, 2277, 2278, 2279, 2280, 2281, 2282, 2283, 2284, 2285, 2286, 2287, 2288, 2289, 2290, 2291, 2292, 2293, 2294, 2295, 2296, 2297, 2298, 2299, 2300, 2301, 2302, 2303, 2304, 2305, 2306, 2307, 2308, 2309, 2310, 2311, 2312, 2313, 2314, 2315, 2316, 2317, 2318, 2319, 2320, 2321, 2322, 2323, 2324, 2325, 2326, 2327, 2328, 2329, 2330, 2331, 2332, 2333, 2334, 2335, 2336, 2337, 2338, 2339, 2340, 2341, 2342, 2343, 2344, 2345, 2346, 2347, 2348, 2349, 2350, 2351, 2352, 2353, 2354, 2355, 2356, 2357, 2358, 2359, 2360, 2361, 2362, 2363, 2364, 2365, 2366, 2367, 2368, 2369, 2370, 2371, 2372, 2373, 2374, 2375, 2376, 2377, 2378, 2379, 2380, 2381, 2382, 2383, 2384, 2385, 2386, 2387, 2388, 2389, 2390, 2391, 2392, 2393, 2394, 2395, 2396, 2397, 2398, 2399, 2400, 2401, 2402, 2403, 2404, 2405, 2406, 2407, 2408, 2409, 2410, 2411, 2412, 2413, 2414, 2415, 2416, 2417, 2418, 2419, 2420, 2421, 2422, 2423, 2424, 2425, 2426, 2427, 2428, 2429, 2430, 2431, 2432, 2433, 2434, 2435, 2436, 2437, 2438, 2439, 2440, 2441, 2442, 2443, 2444, 2445, 2446, 2447, 2448, 2449, 2450, 2451, 2452, 2453, 2454, 2455, 2456, 2457, 2458, 2459, 2460, 2461, 2462, 2463, 2464, 2465, 2466, 2467, 2468, 2469, 2470, 2471, 2472, 2473, 2474, 2475, 2476, 2477, 2478, 2479, 2480, 2481, 2482, 2483, 2484, 2485, 2486, 2487, 2488, 2489, 2490, 2491, 2492, 2493, 2494, 2495, 2496, 2497, 2498, 2499, 2500, 2501, 2502, 2503, 2504, 2505, 2506, 2507, 2508, 2509, 2510, 2511, 2512, 2513, 2514, 2515, 2516, 2517, 2518, 2519, 2520, 2521, 2522, 2523, 2524, 2525, 2526, 2527, 2528, 2529, 2530, 2531, 2532, 2533, 2534, 2535, 2536, 2537, 2538, 2539, 2540, 2541, 2542, 2543, 2544, 2545, 2546, 2547, 2548, 2549, 2550, 2551, 2552, 2553, 2554, 2555, 2556, 2557, 2558, 2559, 2560, 2561, 2562, 2563, 2564, 2565, 2566, 2567, 2568, 2569, 2570, 2571, 2572, 2573, 2574, 2575, 2576, 2577, 2578, 2579, 2580, 2581, 2582, 2583, 2584, 2585, 2586, 2587, 2588, 2589, 2590, 2591, 2592, 2593, 2594, 2595, 2596, 2597, 2598, 2599, 2600, 2601, 2602, 2603, 2604, 2605, 2606, 2607, 2608, 2609, 2610, 2611, 2612, 2613, 2614, 2615, 2616, 2617, 2618, 2619, 2620, 2621, 2622, 2623, 2624, 2625, 2626, 2627, 2628, 2629, 2630, 2631, 2632, 2633, 2634, 2635, 2636, 2637, 2638, 2639, 2640, 2641, 2642, 2643, 2644, 2645, 2646, 2647, 2648, 2649, 2650, 2651, 2652, 2653, 2654, 2655, 2656, 2657, 2658, 2659, 2660, 2661, 2662, 2663, 2664, 2665, 2666, 2667, 2668, 2669, 2670, 2671, 2672, 2673, 2674, 2675, 2676, 2677, 2678, 2679, 2680, 2681, 2682, 2683, 2684, 2685, 2686, 2687, 2688, 2689, 2690, 2691, 2692, 2693, 2694, 2695, 2696, 2697, 2698, 2699, 2700, 2701, 2702, 2703, 2704, 2705, 2706, 2707, 2708, 2709, 2710, 2711, 2712, 2713, 2714, 2715, 2716, 2717, 2718, 2719, 2720, 2721, 2722, 2723, 2724, 2725, 2726, 2727, 2728, 2729, 2730, 2731, 2732, 2733, 2734, 2735, 2736, 2737, 2738, 2739, 2740, 2741, 2742, 2743, 2744, 2745, 2746, 2747, 2748, 2749, 2750, 2751, 2752, 2753, 2754, 2755, 2756, 2757, 2758, 2759, 2760, 2761, 2762, 2763, 2764, 2765, 2766, 2767, 2768, 2769, 2770, 2771, 2772, 2773, 2774, 2775, 2776, 2777, 2778, 2779, 2780, 2781, 2782, 2783, 2784, 2785, 2786, 2787, 2788, 2789, 2790, 2791, 2792, 2793, 2794, 2795, 2796, 2797, 2798, 2799, 2800, 2801, 2802, 2803, 2804, 2805, 2806, 2807, 2808, 2809, 2810, 2811, 2812, 2813, 2814, 2815, 2816, 2817, 2818, 2819, 2820, 2821, 2822, 2823, 2824, 2825, 2826, 2827, 2828, 2829, 2830, 2831, 2832, 2833, 2834, 2835, 2836, 2837, 2838, 2839, 2840, 2841, 2842, 2843, 2844, 2845, 2846, 2847, 2848, 2849, 2850, 2851, 2852, 2853, 2854, 2855, 2856, 2857, 2858, 2859, 2860, 2861, 2862, 2863, 2864, 2865, 2866, 2867, 2868, 2869, 2870, 2871, 2872, 2873, 2874, 2875, 2876, 2877, 2878, 2879, 2880, 2881, 2882, 2883, 2884, 2885, 2886, 2887, 2888, 2889, 2890, 2891, 2892, 2893, 2894, 2895, 2896, 2897, 2898, 2899, 2900, 2901, 2902, 2903, 2904, 2905, 2906, 2907, 2908, 2909, 2910, 2911, 2912, 2913, 2914, 2915, 2916, 2917, 2918, 2919, 2920, 2921, 2922, 2923, 2924, 2925, 2926, 2927, 2928, 2929, 2930, 2931, 2932, 2933, 2934, 2935, 2936, 2937, 2938, 2939, 2940, 2941, 2942, 2943, 2944, 2945, 2946, 2947, 2948, 2949, 2950, 2951, 2952, 2953, 2954, 2955, 2956, 2957, 2958, 2959, 2960, 2961, 2962, 2963, 2964, 2965, 2966, 2967, 2968, 2969, 2970, 2971, 2972, 2973, 2974, 2975, 2976, 2977, 2978, 2979, 2980, 2981, 2982, 2983, 2984, 2985, 2986, 2987, 2988, 2989, 2990, 2991, 2992, 2993, 2994, 2995, 2996, 2997, 2998, 2999, 3000, 3001, 3002, 3003, 3004, 3005, 3006, 3007, 3008, 3009, 3010, 3011, 3012, 3013, 3014, 3015, 3016, 3017, 3018, 3019, 3020, 3021, 3022, 3023, 3024, 3025, 3026, 3027, 3028, 3029, 3030, 3031, 3032, 3033, 3034, 3035, 3036, 3037, 3038, 3039, 3040, 3041, 3042, 3043, 3044, 3045, 3046, 3047, 3048, 3049, 3050, 3051, 3052, 3053, 3054, 3055, 3056, 3057, 3058, 3059, 3060, 3061, 3062, 3063, 3064, 3065, 3066, 3067, 3068, 3069, 3070, 3071, 3072, 3073, 3074, 3075, 3076, 3077, 3078, 3079, 3080, 3081, 3082, 3083, 3084, 3085, 3086, 3087, 3088, 3089, 3090, 3091, 3092, 3093, 3094, 3095, 3096, 3097, 3098, 3099, 3100, 3101, 3102, 3103, 3104, 3105, 3106, 3107, 3108, 3109, 3110, 3111, 3112, 3113, 3114, 3115, 3116, 3117, 3118, 3119, 3120, 3121, 3122, 3123, 3124, 3125, 3126, 3127, 3128, 3129, 3130, 3131, 3132, 3133, 3134, 3135, 3136, 3137, 3138, 3139, 3140, 3141, 3142, 3143, 3144, 3145, 3146, 3147, 3148, 3149, 3150, 3151, 3152, 3153, 3154, 3155, 3156, 3157, 3158, 3159, 3160, 3161, 3162, 3163, 3164, 3165, 3166, 3167, 3168, 3169, 3170, 3171, 3172, 3173, 3174, 3175, 3176, 3177, 3178, 3179, 3180, 3181, 3182, 3183, 3184, 3185, 3186, 3187, 3188, 3189, 3190, 3191, 3192, 3193, 3194, 3195, 3196, 3197, 3198, 3199, 3200, 3201, 3202, 3203, 3204, 3205, 3206, 3207, 3208, 3209, 3210, 3211, 3212, 3213, 3214, 3215, 3216, 3217, 3218, 3219, 3220, 3221, 3222, 3223, 3224, 3225, 3226, 3227, 3228, 3229, 3230, 3231, 3232, 3233, 3234, 3235, 3236, 3237, 3238, 3239, 3240, 3241, 3242, 3243, 3244, 3245, 3246, 3247, 3248, 3249, 3250, 3251, 3252, 3253, 3254, 3255, 3256, 3257, 3258, 3259, 3260, 3261, 3262, 3263, 3264, 3265, 3266, 3267, 3268, 3269, 3270, 3271, 3272, 3273, 3274, 3275, 3276, 3277, 3278, 3279, 3280, 3281, 3282, 3283, 3284, 3285, 3286, 3287, 3288, 3289, 3290, 3291, 3292, 3293, 3294, 3295, 3296, 3297, 3298, 3299, 3300, 3301, 3302, 3303, 3304, 3305, 3306, 3307, 3308, 3309, 3310, 3311, 3312, 3313, 3314, 3315, 3316, 3317, 3318, 3319, 3320, 3321, 3322, 3323, 3324, 3325, 3326, 3327, 3328, 3329, 3330, 3331, 3332, 3333, 3334, 3335, 3336, 3337, 3338, 3339, 3340, 3341, 3342, 3343, 3344, 3345, 3346, 3347, 3348, 3349, 3350, 3351, 3352, 3353, 3354, 3355, 3356, 3357, 3358, 3359, 3360, 3361, 3362, 3363, 3364, 3365, 3366, 3367, 3368, 3369, 3370, 3371, 3372, 3373, 3374, 3375, 3376, 3377, 3378, 3379, 3380, 3381, 3382, 3383, 3384, 3385, 3386, 3387, 3388, 3389, 3390, 3391, 3392, 3393, 3394, 3395, 3396, 3397, 3398, 3399, 3400, 3401, 3402, 3403, 3404, 3405, 3406, 3407, 3408, 3409, 3410, 3411, 3412, 3413, 3414, 3415, 3416, 3417, 3418, 3419, 3420, 3421, 3422, 3423, 3424, 3425, 3426, 3427, 3428, 3429, 3430, 3431, 3432, 3433, 3434, 3435, 3436, 3437, 3438, 3439, 3440, 3441, 3442, 3443, 3444, 3445, 3446, 3447, 3448, 3449, 3450, 3451, 3452, 3453, 3454, 3455, 3456, 3457, 3458, 3459, 3460, 3461, 3462, 3463, 3464, 3465, 3466, 3467, 3468, 3469, 3470, 3471, 3472, 3473, 3474, 3475, 3476, 3477, 3478, 3479, 3480, 3481, 3482, 3483, 3484, 3485, 3486, 3487, 3488, 3489, 3490, 3491, 3492, 3493, 3494, 3495, 3496, 3497, 3498, 3499, 3500, 3501, 3502, 3503, 3504, 3505, 3506, 3507, 3508, 3509, 3510, 3511, 3512, 3513, 3514, 3515, 3516, 3517, 3518, 3519, 3520, 3521, 3522, 3523, 3524, 3525, 3526, 3527, 3528, 3529, 3530, 3531, 3532, 3533, 3534, 3535, 3536, 3537, 3538, 3539, 3540, 3541, 3542, 3543, 3544, 3545, 3546, 3547, 3548, 3549, 3550, 3551, 3552, 3553, 3554, 3555, 3556, 3557, 3558, 3559, 3560, 3561, 3562, 3563, 3564, 3565, 3566, 3567, 3568, 3569, 3570, 3571, 3572, 3573, 3574, 3575, 3576, 3577, 3578, 3579, 3580, 3581, 3582, 3583, 3584, 3585, 3586, 3587, 3588, 3589, 3590, 3591, 3592, 3593, 3594, 3595, 3596, 3597, 3598, 3599, 3600, 3601, 3602, 3603, 3604, 3605, 3606, 3607, 3608, 3609, 3610, 3611, 3612, 3613, 3614, 3615, 3616, 3617, 3618, 3619, 3620, 3621, 3622, 3623, 3624, 3625, 3626, 3627, 3628, 3629, 3630, 3631, 3632, 3633, 3634, 3635, 3636, 3637, 3638, 3639, 3640, 3641, 3642, 3643, 3644, 3645, 3646, 3647, 3648, 3649, 3650, 3651, 3652, 3653, 3654, 3655, 3656, 3657, 3658, 3659, 3660, 3661, 3662, 3663, 3664, 3665, 3666, 3667, 3668, 3669, 3670, 3671, 3672, 3673, 3674, 3675, 3676, 3677, 3678, 3679, 3680, 3681, 3682, 3683, 3684, 3685, 3686, 3687, 3688, 3689, 3690, 3691, 3692, 3693, 3694, 3695, 3696, 3697, 3698, 3699, 3700, 3701, 3702, 3703, 3704, 3705, 3706, 3707, 3708, 3709, 3710, 3711, 3712, 3713, 3714, 3715, 3716, 3717, 3718, 3719, 3720, 3721, 3722, 3723, 3724, 3725, 3726, 3727, 3728, 3729, 3730, 3731, 3732, 3733, 3734, 3735, 3736, 3737, 3738, 3739, 3740, 3741, 3742, 3743, 3744, 3745, 3746, 3747, 3748, 3749, 3750, 3751, 3752, 3753, 3754, 3755, 3756, 3757, 3758, 3759, 3760, 3761, 3762, 3763, 3764, 3765, 3766, 3767, 3768, 3769, 3770, 3771, 3772, 3773, 3774, 3775, 3776, 3777, 3778, 3779, 3780, 3781, 3782, 3783, 3784, 3785, 3786, 3787, 3788, 3789, 3790, 3791, 3792, 3793, 3794, 3795, 3796, 3797, 3798, 3799, 3800, 3801, 3802, 3803, 3804, 3805, 3806, 3807, 3808, 3809, 3810, 3811, 3812, 3813, 3814, 3815, 3816, 3817, 3818, 3819, 3820, 3821, 3822, 3823, 3824, 3825, 3826, 3827, 3828, 3829, 3830, 3831, 3832, 3833, 3834, 3835, 3836, 3837, 3838, 3839, 3840, 3841, 3842, 3843, 3844, 3845, 3846, 3847, 3848, 3849, 3850, 3851, 3852, 3853, 3854, 3855, 3856, 3857, 3858, 3859, 3860, 3861, 3862, 3863, 3864, 3865, 3866, 3867, 3868, 3869, 3870, 3871, 3872, 3873, 3874, 3875, 3876, 3877, 3878, 3879, 3880, 3881, 3882, 3883, 3884, 3885, 3886, 3887, 3888, 3889, 3890, 3891, 3892, 3893, 3894, 3895, 3896, 3897, 3898, 3899, 3900, 3901, 3902, 3903, 3904, 3905, 3906, 3907, 3908, 3909, 3910, 3911, 3912, 3913, 3914, 3915, 3916, 3917, 3918, 3919, 3920, 3921, 3922, 3923, 3924, 3925, 3926, 3927, 3928, 3929, 3930, 3931, 3932, 3933, 3934, 3935, 3936, 3937, 3938, 3939, 3940, 3941, 3942, 3943, 3944, 3945, 3946, 3947, 3948, 3949, 3950, 3951, 3952, 3953, 3954, 3955, 3956, 3957, 3958, 3959, 3960, 3961, 3962, 3963, 3964, 3965, 3966, 3967, 3968, 3969, 3970, 3971, 3972, 3973, 3974, 3975, 3976, 3977, 3978, 3979, 3980, 3981, 3982, 3983, 3984, 3985, 3986, 3987, 3988, 3989, 3990, 3991, 3992, 3993, 3994, 3995, 3996, 3997, 3998, 3999, 4000, 4001, 4002, 4003, 4004, 4005, 4006, 4007, 4008, 4009, 4010, 4011, 4012, 4013, 4014, 4015, 4016, 4017, 4018, 4019, 4020, 4021, 4022, 4023, 4024, 4025, 4026, 4027, 4028, 4029, 4030, 4031, 4032, 4033, 4034, 4035, 4036, 4037, 4038, 4039, 4040, 4041, 4042, 4043, 4044, 4045, 4046, 4047, 4048, 4049, 4050, 4051, 4052, 4053, 4054, 4055, 4056, 4057, 4058, 4059, 4060, 4061, 4062, 4063, 4064, 4065, 4066, 4067, 4068, 4069, 4070, 4071, 4072, 4073, 4074, 4075, 4076, 4077, 4078, 4079, 4080, 4081, 4082, 4083, 4084, 4085, 4086, 4087, 4088, 4089, 4090, 4091 +1,2,3,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL +1,2,3,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,4,NULL,NULL,NULL,NULL,NULL,NULL,5,NULL,NULL,6,NULL,NULL,NULL,7,NULL,NULL,NULL,8,NULL,NULL,NULL,9,NULL,NULL,10 \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.json b/tests/pytest/tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.json new file mode 100755 index 0000000000000000000000000000000000000000..c9c4ae2c1b650da99853d6c82106b3f6ee80d0c0 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.json @@ -0,0 +1,137 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 10, + "thread_count_create_tbl": 10, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10, + "num_of_records_per_req": 1, + "max_sql_len": 102400000, + "databases": [{ + "dbinfo": { + "name": "json", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb_old", + "child_table_exists":"no", + "childtable_count": 1, + "childtable_prefix": "stb_old_", + "auto_create_table": "no", + "batch_create_tbl_num": 5, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 10, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.csv", + "tags_file": "", + "columns": [{"type": "INT","count":1000}, {"type": "BINARY", "len": 16, "count":20}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":1}] + },{ + "name": "stb_new", + "child_table_exists":"no", + "childtable_count": 1, + "childtable_prefix": "stb_new_", + "auto_create_table": "no", + "batch_create_tbl_num": 5, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 10, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./tools/taosdemoAllTest/sample.csv", + "tags_file": "", + "columns": [{"type": "INT","count":4000}, {"type": "BINARY", "len": 16, "count":90}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":3}] + },{ + "name": "stb_mix", + "child_table_exists":"no", + "childtable_count": 1, + "childtable_prefix": "stb_mix_", + "auto_create_table": "no", + "batch_create_tbl_num": 5, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 10, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./tools/taosdemoAllTest/sample.csv", + "tags_file": "", + "columns": [{"type": "INT","count":500},{"type": "SMALLINT","count":500},{"type": "TINYINT","count":500},{"type": "DOUBLE","count":500},{"type": "FLOAT","count":500},{"type": "BOOL","count":500},{"type": "BIGINT","count":500},{"type": "NCHAR","len": 20,"count":300},{"type": "BINARY","len": 34,"count":290},{"type": "BINARY","len": 101,"count":1}], + "tags": [{"type": "INT", "count":3}, {"type": "NCHAR", "len": 10, "count":1}] + },{ + "name": "stb_excel", + "child_table_exists":"no", + "childtable_count": 1, + "childtable_prefix": "stb_excel_", + "auto_create_table": "no", + "batch_create_tbl_num": 5, + "data_source": "sample", + "insert_mode": "taosc", + "insert_rows": 10, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.csv", + "tags_file": "", + "columns": [{"type": "INT","count":500},{"type": "SMALLINT","count":500},{"type": "SMALLINT","count":500},{"type": "DOUBLE","count":500},{"type": "FLOAT","count":500},{"type": "BOOL","count":500},{"type": "BIGINT","count":500},{"type": "NCHAR","len": 19,"count":300},{"type": "BINARY","len": 34,"count":290},{"type": "BINARY","len": 101,"count":1}], + "tags": [{"type": "INT", "count":3}, {"type": "NCHAR", "len": 10, "count":1}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.py b/tests/pytest/tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.py new file mode 100755 index 0000000000000000000000000000000000000000..eb844b6fe24338b0301c45b918967faec7debcc0 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.py @@ -0,0 +1,176 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +import time +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def run(self): + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + + #-N:regular table -d:database name -t:table num -n:rows num per table -l:col num -y:force + #regular old && new + startTime = time.time() + os.system("%staosdemo -N -d regular_old -t 1 -n 10 -l 1023 -y" % binPath) + tdSql.execute("use regular_old") + tdSql.query("show tables;") + tdSql.checkRows(1) + tdSql.query("select * from d0;") + tdSql.checkCols(1024) + tdSql.query("describe d0;") + tdSql.checkRows(1024) + + os.system("%staosdemo -N -d regular_new -t 1 -n 10 -l 4095 -y" % binPath) + tdSql.execute("use regular_new") + tdSql.query("show tables;") + tdSql.checkRows(1) + tdSql.query("select * from d0;") + tdSql.checkCols(4096) + tdSql.query("describe d0;") + tdSql.checkRows(4096) + + #super table -d:database name -t:table num -n:rows num per table -l:col num -y:force + os.system("%staosdemo -d super_old -t 1 -n 10 -l 1021 -y" % binPath) + tdSql.execute("use super_old") + tdSql.query("show tables;") + tdSql.checkRows(1) + tdSql.query("select * from meters;") + tdSql.checkCols(1024) + tdSql.query("select * from d0;") + tdSql.checkCols(1022) + tdSql.query("describe meters;") + tdSql.checkRows(1024) + tdSql.query("describe d0;") + tdSql.checkRows(1024) + + os.system("%staosdemo -d super_new -t 1 -n 10 -l 4093 -y" % binPath) + tdSql.execute("use super_new") + tdSql.query("show tables;") + tdSql.checkRows(1) + tdSql.query("select * from meters;") + tdSql.checkCols(4096) + tdSql.query("select * from d0;") + tdSql.checkCols(4094) + tdSql.query("describe meters;") + tdSql.checkRows(4096) + tdSql.query("describe d0;") + tdSql.checkRows(4096) + tdSql.execute("create table stb_new1_1 using meters tags(1,2)") + tdSql.query("select * from stb_new1_1") + tdSql.checkCols(4094) + tdSql.query("describe stb_new1_1;") + tdSql.checkRows(4096) + + # insert: create one or mutiple tables per sql and insert multiple rows per sql + # test case for https://jira.taosdata.com:18080/browse/TD-5213 + os.system("%staosdemo -f tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.json -y " % binPath) + tdSql.execute("use json") + tdSql.query("select count (tbname) from stb_old") + tdSql.checkData(0, 0, 1) + + tdSql.query("select * from stb_old") + tdSql.checkRows(10) + tdSql.checkCols(1024) + + tdSql.query("select count (tbname) from stb_new") + tdSql.checkData(0, 0, 1) + + tdSql.query("select * from stb_new") + tdSql.checkRows(10) + tdSql.checkCols(4096) + tdSql.query("describe stb_new;") + tdSql.checkRows(4096) + tdSql.query("select * from stb_new_0") + tdSql.checkRows(10) + tdSql.checkCols(4091) + tdSql.query("describe stb_new_0;") + tdSql.checkRows(4096) + tdSql.execute("create table stb_new1_1 using stb_new tags(1,2,3,4,5)") + tdSql.query("select * from stb_new1_1") + tdSql.checkCols(4091) + tdSql.query("describe stb_new1_1;") + tdSql.checkRows(4096) + + tdSql.query("select count (tbname) from stb_mix") + tdSql.checkData(0, 0, 1) + + tdSql.query("select * from stb_mix") + tdSql.checkRows(10) + tdSql.checkCols(4096) + tdSql.query("describe stb_mix;") + tdSql.checkRows(4096) + tdSql.query("select * from stb_mix_0") + tdSql.checkRows(10) + tdSql.checkCols(4092) + tdSql.query("describe stb_mix_0;") + tdSql.checkRows(4096) + + tdSql.query("select count (tbname) from stb_excel") + tdSql.checkData(0, 0, 1) + + tdSql.query("select * from stb_excel") + tdSql.checkRows(10) + tdSql.checkCols(4096) + tdSql.query("describe stb_excel;") + tdSql.checkRows(4096) + tdSql.query("select * from stb_excel_0") + tdSql.checkRows(10) + tdSql.checkCols(4092) + tdSql.query("describe stb_excel_0;") + tdSql.checkRows(4096) + endTime = time.time() + print("total time %ds" % (endTime - startTime)) + + + os.system("rm -rf tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.py.sql") + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoAllTest/convertResFile.py b/tests/pytest/tools/taosdemoAllTest/convertResFile.py new file mode 100644 index 0000000000000000000000000000000000000000..5ed2fec13b1e0722937023d829e5e9b9fa1ad623 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/convertResFile.py @@ -0,0 +1,43 @@ +from datetime import datetime +import time +import os + +# class FileSeparaSpaceConvertcomma: +# def __init__(self): +# self.inputfile = "" +# self.oputfile = "" +# self.affectedRows = 0 + +# def ConvertFile(self, inputfile,): + +os.system("awk -v OFS=',' '{$1=$1;print$0}' ./all_query_res0.txt > ./new_query_res0.txt") +with open('./new_query_res0.txt','r+') as f0: + contents = f0.readlines() + if os.path.exists('./test_query_res0.txt'): + os.system("rm -rf ./test_query_res0.txt") + for i in range(len(contents)): + content = contents[i].rstrip('\n') + stimestamp = content.split(',')[0] + timestamp = int(stimestamp) + d = datetime.fromtimestamp(timestamp/1000) + str0 = d.strftime("%Y-%m-%d %H:%M:%S.%f")[:-3] + ts = "'"+str0+"'" + str1 = "'"+content.split(',')[1]+"'" + str2 = "'"+content.split(',')[2]+"'" + content = ts + "," + str1 + "," + str2 + "," + content.split(',',3)[3] + contents[i] = content + "\n" + with open('./test_query_res0.txt','a') as fi: + fi.write(contents[i]) + +os.system("rm -rf ./new_query_res0.txt") + + + + + + + +# timestamp = 1604160000099 +# d = datetime.fromtimestamp(timestamp/1000) +# str1 = d.strftime("%Y-%m-%d %H:%M:%S.%f") +# print(str1[:-3]) diff --git a/tests/pytest/tools/taosdemoAllTest/insert-1s1tnt1r.json b/tests/pytest/tools/taosdemoAllTest/insert-1s1tnt1r.json new file mode 100644 index 0000000000000000000000000000000000000000..0068a9c30463ff39d49cbd14d15b5d84747d0a59 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/insert-1s1tnt1r.json @@ -0,0 +1,88 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10, + "num_of_records_per_req": 1, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 1000, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 1, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 100, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1}, {"type": "BINARY", "len": 16, "count":1}, {"type": "BINARY", "len": 32, "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":1}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 1000, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 200, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1}, {"type": "BINARY", "len": 16, "count":1}, {"type": "BINARY", "len": 32, "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":1}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/insert-1s1tntmr.json b/tests/pytest/tools/taosdemoAllTest/insert-1s1tntmr.json new file mode 100644 index 0000000000000000000000000000000000000000..3f194f376a12772151c4d1c32f233e0d67e72857 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/insert-1s1tntmr.json @@ -0,0 +1,88 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 10, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 10000, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1}, {"type": "BINARY", "len": 16, "count":1}, {"type": "BINARY", "len": 32, "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":1}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 20, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 20000, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1}, {"type": "BINARY", "len": 16, "count":1}, {"type": "BINARY", "len": 32, "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":1}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/insert-disorder.json b/tests/pytest/tools/taosdemoAllTest/insert-disorder.json new file mode 100644 index 0000000000000000000000000000000000000000..d6420b100e5ad2bae887b3ae5fb5cc0f306d9762 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/insert-disorder.json @@ -0,0 +1,88 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file":"./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 1, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 10, + "childtable_limit": -1, + "childtable_offset": 0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 1, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 10, + "disorder_range": 100, + "timestamp_step": 1000, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count":1, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 1, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 10, + "childtable_limit": -1, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 100, + "disorder_range": 1, + "timestamp_step": 1000, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":10}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/insert-drop-exist-auto-N00.json b/tests/pytest/tools/taosdemoAllTest/insert-drop-exist-auto-N00.json new file mode 100644 index 0000000000000000000000000000000000000000..3ac8882699b11e62aa7486b6076f99b1c5b005d2 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/insert-drop-exist-auto-N00.json @@ -0,0 +1,181 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 100, + "num_of_records_per_req": 100, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "no", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 3650, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb", + "child_table_exists":"no", + "auto_create_table": "123", + "childtable_count": 20, + "childtable_prefix": "NN123_", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 5, + "childtable_limit": 40, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "now", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "TINYINT"}] + },{ + "name": "stb", + "child_table_exists":"no", + "auto_create_table": "no", + "childtable_count": 20, + "childtable_prefix": "NNN_", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 5, + "childtable_limit": 40, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "now", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "TINYINT"}] + },{ + "name": "stb", + "child_table_exists":"no", + "auto_create_table": "yes", + "childtable_count": 20, + "childtable_prefix": "NNY_", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 5, + "childtable_limit": 40, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "now", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "TINYINT"}] + },{ + "name": "stb", + "child_table_exists":"yes", + "auto_create_table": "123", + "childtable_count": 20, + "childtable_prefix": "NY123_", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 5, + "childtable_limit": 40, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "now", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "TINYINT"}] + },{ + "name": "stb", + "child_table_exists":"yes", + "auto_create_table": "no", + "childtable_count": 20, + "childtable_prefix": "NYN_", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 5, + "childtable_limit": 40, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "now", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "TINYINT"}] + },{ + "name": "stb", + "child_table_exists":"yes", + "auto_create_table": "yes", + "childtable_count": 20, + "childtable_prefix": "NYY_", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 5, + "childtable_limit": 40, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "now", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "TINYINT"}] + } + ] + }] +} \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/insert-drop-exist-auto-Y00.json b/tests/pytest/tools/taosdemoAllTest/insert-drop-exist-auto-Y00.json new file mode 100644 index 0000000000000000000000000000000000000000..ffa1c91b82db978bc14392126edbf6972bcf2481 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/insert-drop-exist-auto-Y00.json @@ -0,0 +1,181 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 100, + "num_of_records_per_req": 100, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 3650, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb", + "child_table_exists":"no", + "auto_create_table": "123", + "childtable_count": 20, + "childtable_prefix": "YN123_", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 5, + "childtable_limit": 40, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "now", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "TINYINT"}] + },{ + "name": "stb", + "child_table_exists":"no", + "auto_create_table": "no", + "childtable_count": 20, + "childtable_prefix": "YNN_", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 5, + "childtable_limit": 40, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "now", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "TINYINT"}] + },{ + "name": "stb", + "child_table_exists":"no", + "auto_create_table": "yes", + "childtable_count": 20, + "childtable_prefix": "YNY_", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 5, + "childtable_limit": 40, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "now", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "TINYINT"}] + },{ + "name": "stb", + "child_table_exists":"yes", + "auto_create_table": "123", + "childtable_count": 20, + "childtable_prefix": "YY123_", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 5, + "childtable_limit": 40, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "now", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "TINYINT"}] + },{ + "name": "stb", + "child_table_exists":"yes", + "auto_create_table": "no", + "childtable_count": 20, + "childtable_prefix": "YYN_", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 5, + "childtable_limit": 40, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "now", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "TINYINT"}] + },{ + "name": "stb", + "child_table_exists":"yes", + "auto_create_table": "yes", + "childtable_count": 20, + "childtable_prefix": "YYY_", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 5, + "childtable_limit": 40, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "now", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "TINYINT"}] + } + ] + }] +} \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/insert-illegal.json b/tests/pytest/tools/taosdemoAllTest/insert-illegal.json new file mode 100644 index 0000000000000000000000000000000000000000..c56f8f30402aa948828377b46e5cf8678a3b3472 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/insert-illegal.json @@ -0,0 +1,88 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10, + "num_of_records_per_req": "-asdf", + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 10, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 10000, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":-4, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":10}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 20, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": "asdf", + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 20000, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":10}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/insert-interlace-row.json b/tests/pytest/tools/taosdemoAllTest/insert-interlace-row.json new file mode 100644 index 0000000000000000000000000000000000000000..93bb92764d3e4ba141a8b8c9b2df4fda69cb9eaa --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/insert-interlace-row.json @@ -0,0 +1,62 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 100, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 150, + "childtable_limit": -1, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 151, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":10}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/insert-interval-speed.json b/tests/pytest/tools/taosdemoAllTest/insert-interval-speed.json new file mode 100644 index 0000000000000000000000000000000000000000..5f1c3fb6ca9ac7d088281f89e93e4c038d97ad56 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/insert-interval-speed.json @@ -0,0 +1,88 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 100, + "interlace_rows": 0, + "num_of_records_per_req": 2000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 20000, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 1000, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1}, {"type": "BINARY", "len": 16, "count":1}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 20000, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 1000, + "insert_interval": 2000, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1}, {"type": "BINARY", "len": 16, "count":1}, {"type": "BINARY", "len": 32, "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":1}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/insert-newdb.json b/tests/pytest/tools/taosdemoAllTest/insert-newdb.json new file mode 100644 index 0000000000000000000000000000000000000000..05a6f7606a22f7c4712ed7c1a4452c43c87f5428 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/insert-newdb.json @@ -0,0 +1,166 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 0, + "num_of_records_per_req": 3000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 1 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"yes", + "childtable_count": 5, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 10, + "childtable_limit": -1, + "childtable_offset": 0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1}, {"type": "BINARY", "len": 16, "count":1}, {"type": "BINARY", "len": 32, "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 6, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 20, + "childtable_limit": -1, + "childtable_offset": 0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb2", + "child_table_exists":"no", + "childtable_count": 7, + "childtable_prefix": "stb02_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 20, + "childtable_limit": 4, + "childtable_offset": 0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb3", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb03_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 20, + "childtable_limit": 2, + "childtable_offset": 7, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb4", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb04_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 20, + "childtable_limit": 0, + "childtable_offset": 7, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/insert-newtable.json b/tests/pytest/tools/taosdemoAllTest/insert-newtable.json new file mode 100644 index 0000000000000000000000000000000000000000..02b56bbfe8a5e0900467e0dc0537919465a406a7 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/insert-newtable.json @@ -0,0 +1,166 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 0, + "num_of_records_per_req": 3000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "no", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 1 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"yes", + "childtable_count": 5, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 20, + "childtable_limit": -1, + "childtable_offset": 0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-12-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 6, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 20, + "childtable_limit": -1, + "childtable_offset": 0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-12-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb2", + "child_table_exists":"no", + "childtable_count": 7, + "childtable_prefix": "stb02_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 20, + "childtable_limit": 4, + "childtable_offset": 0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-12-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb3", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb03_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 20, + "childtable_limit": 2, + "childtable_offset": 7, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-12-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb4", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb04_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 30, + "childtable_limit": 0, + "childtable_offset": 7, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-12-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/insert-nodbnodrop.json b/tests/pytest/tools/taosdemoAllTest/insert-nodbnodrop.json new file mode 100644 index 0000000000000000000000000000000000000000..5978e5529f8d3a3b29cb04f1744a045b56e7e5ba --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/insert-nodbnodrop.json @@ -0,0 +1,62 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 0, + "num_of_records_per_req": 3000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "dbno", + "drop": "no", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 1 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 5, + "childtable_prefix": "stb00_", + "auto_create_table": "yes", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 10, + "childtable_limit": -1, + "childtable_offset": 0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/insert-offset.json b/tests/pytest/tools/taosdemoAllTest/insert-offset.json new file mode 100644 index 0000000000000000000000000000000000000000..53edf41072a93b907da8af6648dab03691e039a8 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/insert-offset.json @@ -0,0 +1,166 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 0, + "num_of_records_per_req": 3000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "no", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"yes", + "childtable_count": 5, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 20, + "childtable_limit": 0, + "childtable_offset": 0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-11-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb1", + "child_table_exists":"yes", + "childtable_count": 6, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 20, + "childtable_limit": -1, + "childtable_offset": 0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-11-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb2", + "child_table_exists":"yes", + "childtable_count": 7, + "childtable_prefix": "stb02_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 20, + "childtable_limit": 4, + "childtable_offset": 0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-11-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb3", + "child_table_exists":"yes", + "childtable_count": 8, + "childtable_prefix": "stb03_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 20, + "childtable_limit": 2, + "childtable_offset":7, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-11-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb4", + "child_table_exists":"yes", + "childtable_count": 8, + "childtable_prefix": "stb04_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 20, + "childtable_limit": 0, + "childtable_offset": 7, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-11-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/insert-renewdb.json b/tests/pytest/tools/taosdemoAllTest/insert-renewdb.json new file mode 100644 index 0000000000000000000000000000000000000000..91c033c67711e0713f65a08a48351288470d565e --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/insert-renewdb.json @@ -0,0 +1,166 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 0, + "num_of_records_per_req": 3000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 1 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"yes", + "childtable_count": 5, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 10, + "childtable_limit": -1, + "childtable_offset": 0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 6, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 20, + "childtable_limit": -1, + "childtable_offset": 0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb2", + "child_table_exists":"no", + "childtable_count": 7, + "childtable_prefix": "stb02_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 20, + "childtable_limit": 4, + "childtable_offset": 0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb3", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb03_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 20, + "childtable_limit": 2, + "childtable_offset": 7, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb4", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb04_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 20, + "childtable_limit": 0, + "childtable_offset": 7, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/insert-sample.json b/tests/pytest/tools/taosdemoAllTest/insert-sample.json new file mode 100644 index 0000000000000000000000000000000000000000..87d442b7cbc981c8f3a86104c9d13856283f1815 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/insert-sample.json @@ -0,0 +1,88 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file":"./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "dbtest123", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 1, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "sample", + "insert_mode": "taosc", + "insert_rows": 10, + "childtable_limit": -1, + "childtable_offset": 0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./tools/taosdemoAllTest/sample.csv", + "tags_file": "", + "columns": [{"type": "INT", "count":3}, {"type": "DOUBLE", "count":3}, {"type": "BINARY", "len": 16, "count":1}, {"type": "BINARY", "len": 32, "count":1}, {"type": "BOOL"}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count":2, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 10, + "childtable_limit": -1, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "./tools/taosdemoAllTest/tags.csv", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":10}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":3}, {"type": "BINARY", "len": 16, "count":2}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/insert-timestep.json b/tests/pytest/tools/taosdemoAllTest/insert-timestep.json new file mode 100644 index 0000000000000000000000000000000000000000..c794c73c843607a7ef6bb84b288ac890a317bfa9 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/insert-timestep.json @@ -0,0 +1,88 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file":"./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 10, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 20, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":10}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count":20, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 20, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "2020-11-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":10}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/insertBinaryLenLarge16374AllcolLar49151.json b/tests/pytest/tools/taosdemoAllTest/insertBinaryLenLarge16374AllcolLar49151.json new file mode 100644 index 0000000000000000000000000000000000000000..02efafbbbe5657ab5a81e64fef0c43405ca6e317 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/insertBinaryLenLarge16374AllcolLar49151.json @@ -0,0 +1,166 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10, + "num_of_records_per_req": 10240000000, + "max_sql_len": 10240000000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 1, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 1, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 16374, "count":1}], + "tags": [{"type": "TINYINT", "count":12}, {"type": "BINARY", "len": 16, "count":2}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 1, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 12, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 1, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 16370, "count":1},{"type": "INT"}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb3", + "child_table_exists":"no", + "childtable_count": 1, + "childtable_prefix": "stb03_", + "auto_create_table": "no", + "batch_create_tbl_num": 12, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 1, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 16371, "count":3},{"type": "INT","count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb2", + "child_table_exists":"no", + "childtable_count": 1, + "childtable_prefix": "stb02_", + "auto_create_table": "no", + "batch_create_tbl_num": 12, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 1, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 16375, "count":1},{"type": "INT"}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb4", + "child_table_exists":"no", + "childtable_count": 1, + "childtable_prefix": "stb04_", + "auto_create_table": "no", + "batch_create_tbl_num": 12, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 1, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 100, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 16371, "count":3},{"type": "INT","count":6},{"type": "TINYINT"}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/insertChildTab0.json b/tests/pytest/tools/taosdemoAllTest/insertChildTab0.json new file mode 100644 index 0000000000000000000000000000000000000000..84aa75eca7ac5eaabfeef715471e9b91ee66dfec --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/insertChildTab0.json @@ -0,0 +1,88 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10, + "num_of_records_per_req": 10, + "max_sql_len": 10240000000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 0, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 1, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 1, "count":1}], + "tags": [{"type": "TINYINT", "count":1}, {"type": "BINARY", "len": 16, "count":2}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 10, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 12, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 2, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 1, "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/insertChildTabLess0.json b/tests/pytest/tools/taosdemoAllTest/insertChildTabLess0.json new file mode 100644 index 0000000000000000000000000000000000000000..58acd9bbd022bb55ef573f9a7e9434ed935b55bc --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/insertChildTabLess0.json @@ -0,0 +1,88 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10, + "num_of_records_per_req": 10, + "max_sql_len": 10240000000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": -1, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 1, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 1, "count":1}], + "tags": [{"type": "TINYINT", "count":1}, {"type": "BINARY", "len": 16, "count":2}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 10, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 12, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 2, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 1, "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/insertColumnsAndTagNum4096.json b/tests/pytest/tools/taosdemoAllTest/insertColumnsAndTagNum4096.json new file mode 100644 index 0000000000000000000000000000000000000000..c86ed978170d2a0c8fac12a3c9346dc5a87839f7 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/insertColumnsAndTagNum4096.json @@ -0,0 +1,62 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 0, + "num_of_records_per_req": 1000, + "max_sql_len": 10240000000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 10, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 1000, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1004}, {"type": "BINARY", "len": 5, "count":3075}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":7}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/insertColumnsAndTagNumLarge4096.json b/tests/pytest/tools/taosdemoAllTest/insertColumnsAndTagNumLarge4096.json new file mode 100644 index 0000000000000000000000000000000000000000..59cbedca72709fe10203926881160629658ae3bc --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/insertColumnsAndTagNumLarge4096.json @@ -0,0 +1,62 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10000, + "num_of_records_per_req": 10000, + "max_sql_len": 10240000000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 10, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 1000, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1005}, {"type": "BINARY", "len": 5, "count":3075}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":7}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/insertColumnsNum0.json b/tests/pytest/tools/taosdemoAllTest/insertColumnsNum0.json new file mode 100644 index 0000000000000000000000000000000000000000..52d6ae029de4a2c019545ac047526638237d701e --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/insertColumnsNum0.json @@ -0,0 +1,62 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10, + "num_of_records_per_req": 100, + "max_sql_len": 10240000000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 10, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 1000, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":0}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":7}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/insertInterlaceRowsLarge1M.json b/tests/pytest/tools/taosdemoAllTest/insertInterlaceRowsLarge1M.json new file mode 100644 index 0000000000000000000000000000000000000000..60a10d2501bb2644784ea24afe2319679c441a34 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/insertInterlaceRowsLarge1M.json @@ -0,0 +1,62 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 0, + "num_of_records_per_req": 1000, + "max_sql_len": 10240000000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 10, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 1001, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 1000, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1004}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":7}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/insertMaxNumPerReq.json b/tests/pytest/tools/taosdemoAllTest/insertMaxNumPerReq.json new file mode 100644 index 0000000000000000000000000000000000000000..91234d5e48af891c4dfd0fdfd88121e123bf4edc --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/insertMaxNumPerReq.json @@ -0,0 +1,86 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 50000, + "num_of_records_per_req": 50000, + "max_sql_len": 1025000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 3650, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows":50000, + "childtable_limit": -1, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1025000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2012-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "TINYINT", "count":1}], + "tags": [{"type": "TINYINT", "count":1}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows":50000, + "childtable_limit": -1, + "childtable_offset":0, + "interlace_rows": 32767, + "insert_interval":0, + "max_sql_len": 1025000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2012-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "TINYINT", "count":1}], + "tags": [{"type": "TINYINT", "count":1}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/insertNumOfrecordPerReq0.json b/tests/pytest/tools/taosdemoAllTest/insertNumOfrecordPerReq0.json new file mode 100644 index 0000000000000000000000000000000000000000..8247c5f0158e5cce4d3891dc88048e4a29a3d888 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/insertNumOfrecordPerReq0.json @@ -0,0 +1,88 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10, + "num_of_records_per_req": 0, + "max_sql_len": 10240000000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 1, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 1, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 1, "count":1}], + "tags": [{"type": "TINYINT", "count":1}, {"type": "BINARY", "len": 16, "count":2}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 2, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 12, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 2, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 1, "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/insertNumOfrecordPerReqless0.json b/tests/pytest/tools/taosdemoAllTest/insertNumOfrecordPerReqless0.json new file mode 100644 index 0000000000000000000000000000000000000000..138ebbadf63d16816e723462693684cfd2e4c2c0 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/insertNumOfrecordPerReqless0.json @@ -0,0 +1,88 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10, + "num_of_records_per_req": -1, + "max_sql_len": 10240000000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 1, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 1, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 1, "count":1}], + "tags": [{"type": "TINYINT", "count":1}, {"type": "BINARY", "len": 16, "count":2}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 2, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 12, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 2, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 1, "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/insertRestful.json b/tests/pytest/tools/taosdemoAllTest/insertRestful.json new file mode 100644 index 0000000000000000000000000000000000000000..682dcf2ce4393815590552e935578df26bb8f43c --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/insertRestful.json @@ -0,0 +1,88 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 100, + "num_of_records_per_req": 100, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 10, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "rest", + "insert_rows": 10, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1}, {"type": "BINARY", "len": 16, "count":1}, {"type": "BINARY", "len": 32, "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":1}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 10, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 20, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1}, {"type": "BINARY", "len": 16, "count":1}, {"type": "BINARY", "len": 32, "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":1}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/insertSigcolumnsNum4096.json b/tests/pytest/tools/taosdemoAllTest/insertSigcolumnsNum4096.json new file mode 100644 index 0000000000000000000000000000000000000000..e8468f5906a7ebdef62f6509a8968a0df7bdd775 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/insertSigcolumnsNum4096.json @@ -0,0 +1,62 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10, + "num_of_records_per_req": 100, + "max_sql_len": 10240000000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 10, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 1000, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "DOUBLE", "count":4096}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":7}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/insertTagsNumLarge128.json b/tests/pytest/tools/taosdemoAllTest/insertTagsNumLarge128.json new file mode 100644 index 0000000000000000000000000000000000000000..4dbe2940e2c7954e6b41a8f645d9e8d809d013d6 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/insertTagsNumLarge128.json @@ -0,0 +1,62 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10, + "num_of_records_per_req": 1000000, + "max_sql_len": 1024000000, + "databases": [{ + "dbinfo": { + "name": "db1", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 10, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 1000, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 10000, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1}, {"type": "BIGINT", "count":1}, {"type": "float", "count":1}, {"type": "double", "count":1}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":127}, {"type": "BINARY", "len": 16, "count":2}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/insertTimestepMulRowsLargeint16.json b/tests/pytest/tools/taosdemoAllTest/insertTimestepMulRowsLargeint16.json new file mode 100644 index 0000000000000000000000000000000000000000..b563dcc94b3c69256f4b2a754e9244cef7874944 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/insertTimestepMulRowsLargeint16.json @@ -0,0 +1,65 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "localhost", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "databases": [ + { + "dbinfo": { + "name": "blf", + "drop": "yes" + }, + "super_tables": [ + { + "name": "p_0_topics", + "child_table_exists": "no", + "childtable_count": 10, + "childtable_prefix": "p_0_topics_", + "auto_create_table": "no", + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 525600, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 1000, + "max_sql_len": 1048576, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 60000, + "start_timestamp": "2019-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [ + { + "type": "INT", + "count": 1 + }, + { + "type": "FLOAT", + "count": 1 + }, + { + "type": "BINARY", + "len": 12, + "count": 1 + } + ], + "tags": [ + { + "type": "BINARY", + "len": 12, + "count": 10 + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/insert_5M_rows.json b/tests/pytest/tools/taosdemoAllTest/insert_5M_rows.json new file mode 100644 index 0000000000000000000000000000000000000000..4637009ca36ef74dd445a166b5fedf782528d513 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/insert_5M_rows.json @@ -0,0 +1,60 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 100, + "num_of_records_per_req": 100, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 3650, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb", + "child_table_exists":"no", + "childtable_count": 500, + "childtable_prefix": "stb_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 10000, + "childtable_limit": 10, + "childtable_offset":100, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "TINYINT", "count":2}] + }] + }] +} \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/manual_block1_comp.json b/tests/pytest/tools/taosdemoAllTest/manual_block1_comp.json new file mode 100644 index 0000000000000000000000000000000000000000..a6ac674dd724db8647671114b8eb5290a0803044 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/manual_block1_comp.json @@ -0,0 +1,60 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 100, + "num_of_records_per_req": 32766, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "no", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 3, + "precision": "ms", + "keep": 3650, + "minRows": 1000, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb", + "child_table_exists":"no", + "childtable_count": 500, + "childtable_prefix": "stb_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "sample", + "insert_mode": "taosc", + "insert_rows": 10000, + "childtable_limit": 10, + "childtable_offset":100, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2019-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./tools/taosdemoAllTest/sample.csv", + "tags_file": "", + "columns": [{"type": "INT", "count":3}, {"type": "DOUBLE", "count":3}, {"type": "BINARY", "len": 16, "count":1}, {"type": "BINARY", "len": 32, "count":1}, {"type": "BOOL"}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/manual_block2.json b/tests/pytest/tools/taosdemoAllTest/manual_block2.json new file mode 100644 index 0000000000000000000000000000000000000000..434159159b4dfe942af1c334fd9520d81214e6cb --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/manual_block2.json @@ -0,0 +1,60 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 100, + "num_of_records_per_req": 32766, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "no", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 3650, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb", + "child_table_exists":"yes", + "childtable_count": 500, + "childtable_prefix": "stb_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 100000, + "childtable_limit": 500, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "now", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "TINYINT", "count":2}] + }] + }] +} \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/manual_change_time_1_1_A.json b/tests/pytest/tools/taosdemoAllTest/manual_change_time_1_1_A.json new file mode 100644 index 0000000000000000000000000000000000000000..7b8abd6d4e25991d38ff16c737bf8169c7311318 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/manual_change_time_1_1_A.json @@ -0,0 +1,60 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 100, + "num_of_records_per_req": 32766, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 1, + "cache": 4, + "blocks": 3, + "precision": "ms", + "keep": 10, + "minRows": 1000, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb", + "child_table_exists":"no", + "childtable_count": 1, + "childtable_prefix": "stb_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 864000, + "childtable_limit": 1, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1000, + "start_timestamp": "2020-10-11 00:00:00.000", + "sample_format": "csv", + "sample_file": "./tools/taosdemoAllTest/sample.csv", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 5120, "count":1}], + "tags": [{"type": "TINYINT", "count":2}] + }] + }] +} \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/manual_change_time_1_1_B.json b/tests/pytest/tools/taosdemoAllTest/manual_change_time_1_1_B.json new file mode 100644 index 0000000000000000000000000000000000000000..aeee6322e5c0e6b58c0433be5f345e7c4f84f339 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/manual_change_time_1_1_B.json @@ -0,0 +1,60 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 100, + "num_of_records_per_req": 32766, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "no", + "replica": 1, + "days": 1, + "cache": 4, + "blocks": 3, + "precision": "ms", + "keep": 10, + "minRows": 1000, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb", + "child_table_exists":"yes", + "childtable_count": 1, + "childtable_prefix": "stb_", + "auto_create_table": "yes", + "batch_create_tbl_num": 20, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 432000, + "childtable_limit": 1, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1000, + "start_timestamp": "2020-10-16 00:00:00.500", + "sample_format": "csv", + "sample_file": "./tools/taosdemoAllTest/sample.csv", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 5120, "count":1}], + "tags": [{"type": "TINYINT", "count":1}] + }] + }] +} \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/moredemo-insert-offset.py b/tests/pytest/tools/taosdemoAllTest/moredemo-insert-offset.py new file mode 100644 index 0000000000000000000000000000000000000000..077ced5d02c792b1c3344ea3e8b129038652b4b8 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/moredemo-insert-offset.py @@ -0,0 +1,72 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def run(self): + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + + # insert: drop and child_table_exists combination test + # insert: using parament "childtable_offset and childtable_limit" to control table'offset point and offset + os.system("%staosdemo -f tools/taosdemoAllTest/moredemo-offset-newdb.json" % binPath) + os.system("%staosdemo -f tools/taosdemoAllTest/moredemo-offset-limit1.json & " % binPath) + os.system("%staosdemo -f tools/taosdemoAllTest/moredemo-offset-limit94.json & " % binPath) + os.system("%staosdemo -f tools/taosdemoAllTest/moredemo-offset-limit5.json & " % binPath) + sleep(15) + tdSql.execute("use db") + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 1000000) + + os.system("rm -rf ./insert_res.txt") + os.system("rm -rf tools/taosdemoAllTest/moredemo-insert-offset.py.sql") + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoAllTest/moredemo-offset-limit1.json b/tests/pytest/tools/taosdemoAllTest/moredemo-offset-limit1.json new file mode 100644 index 0000000000000000000000000000000000000000..e30b7b0b1c6a136aa45c91da165ff8101eeb42e3 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/moredemo-offset-limit1.json @@ -0,0 +1,62 @@ + +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 0, + "num_of_records_per_req": 3000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "no", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"yes", + "childtable_count": 100, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 10000, + "childtable_limit": 1, + "childtable_offset": 99, + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-11-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/moredemo-offset-limit5.json b/tests/pytest/tools/taosdemoAllTest/moredemo-offset-limit5.json new file mode 100644 index 0000000000000000000000000000000000000000..d4ce2fee46d8848f574d75173818bff819c1d31f --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/moredemo-offset-limit5.json @@ -0,0 +1,62 @@ + +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 0, + "num_of_records_per_req": 3000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "no", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"yes", + "childtable_count": 100, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 10000, + "childtable_limit": 5, + "childtable_offset": 0, + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-11-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/moredemo-offset-limit94.json b/tests/pytest/tools/taosdemoAllTest/moredemo-offset-limit94.json new file mode 100644 index 0000000000000000000000000000000000000000..ce12accf06c101956ec6a9d025e63bb1814acbd0 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/moredemo-offset-limit94.json @@ -0,0 +1,62 @@ + +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 0, + "num_of_records_per_req": 3000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "no", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"yes", + "childtable_count": 100, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 10000, + "childtable_limit": 94, + "childtable_offset": 5, + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-11-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/moredemo-offset-newdb.json b/tests/pytest/tools/taosdemoAllTest/moredemo-offset-newdb.json new file mode 100644 index 0000000000000000000000000000000000000000..9ffb2953d3c46df5a6cbd4e6042748185254e62a --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/moredemo-offset-newdb.json @@ -0,0 +1,61 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 0, + "num_of_records_per_req": 3000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 0, + "childtable_limit": 0, + "childtable_offset": 0, + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-11-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/nano_samples.csv b/tests/pytest/tools/taosdemoAllTest/nano_samples.csv new file mode 100644 index 0000000000000000000000000000000000000000..5fc779b41b44eda002d246d9554f0abcea03c8d3 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/nano_samples.csv @@ -0,0 +1,100 @@ +8.855,"binary_str0" ,1626870128248246976 +8.75,"binary_str1" ,1626870128249060032 +5.44,"binary_str2" ,1626870128249067968 +8.45,"binary_str3" ,1626870128249072064 +4.07,"binary_str4" ,1626870128249075904 +6.97,"binary_str5" ,1626870128249078976 +6.86,"binary_str6" ,1626870128249082048 +1.585,"binary_str7" ,1626870128249085120 +1.4,"binary_str8" ,1626870128249087936 +5.135,"binary_str9" ,1626870128249092032 +3.15,"binary_str10" ,1626870128249095104 +1.765,"binary_str11" ,1626870128249097920 +7.71,"binary_str12" ,1626870128249100992 +3.91,"binary_str13" ,1626870128249104064 +5.615,"binary_str14" ,1626870128249106880 +9.495,"binary_str15" ,1626870128249109952 +3.825,"binary_str16" ,1626870128249113024 +1.94,"binary_str17" ,1626870128249117120 +5.385,"binary_str18" ,1626870128249119936 +7.075,"binary_str19" ,1626870128249123008 +5.715,"binary_str20" ,1626870128249126080 +1.83,"binary_str21" ,1626870128249128896 +6.365,"binary_str22" ,1626870128249131968 +6.55,"binary_str23" ,1626870128249135040 +6.315,"binary_str24" ,1626870128249138112 +3.82,"binary_str25" ,1626870128249140928 +2.455,"binary_str26" ,1626870128249145024 +7.795,"binary_str27" ,1626870128249148096 +2.47,"binary_str28" ,1626870128249150912 +1.37,"binary_str29" ,1626870128249155008 +5.39,"binary_str30" ,1626870128249158080 +5.13,"binary_str31" ,1626870128249160896 +4.09,"binary_str32" ,1626870128249163968 +5.855,"binary_str33" ,1626870128249167040 +0.17,"binary_str34" ,1626870128249170112 +1.955,"binary_str35" ,1626870128249173952 +0.585,"binary_str36" ,1626870128249178048 +0.33,"binary_str37" ,1626870128249181120 +7.925,"binary_str38" ,1626870128249183936 +9.685,"binary_str39" ,1626870128249187008 +2.6,"binary_str40" ,1626870128249191104 +5.705,"binary_str41" ,1626870128249193920 +3.965,"binary_str42" ,1626870128249196992 +4.43,"binary_str43" ,1626870128249200064 +8.73,"binary_str44" ,1626870128249202880 +3.105,"binary_str45" ,1626870128249205952 +9.39,"binary_str46" ,1626870128249209024 +2.825,"binary_str47" ,1626870128249212096 +9.675,"binary_str48" ,1626870128249214912 +9.99,"binary_str49" ,1626870128249217984 +4.51,"binary_str50" ,1626870128249221056 +4.94,"binary_str51" ,1626870128249223872 +7.72,"binary_str52" ,1626870128249226944 +4.135,"binary_str53" ,1626870128249231040 +2.325,"binary_str54" ,1626870128249234112 +4.585,"binary_str55" ,1626870128249236928 +8.76,"binary_str56" ,1626870128249240000 +4.715,"binary_str57" ,1626870128249243072 +0.56,"binary_str58" ,1626870128249245888 +5.35,"binary_str59" ,1626870128249249984 +5.075,"binary_str60" ,1626870128249253056 +6.665,"binary_str61" ,1626870128249256128 +7.13,"binary_str62" ,1626870128249258944 +2.775,"binary_str63" ,1626870128249262016 +5.775,"binary_str64" ,1626870128249265088 +1.62,"binary_str65" ,1626870128249267904 +1.625,"binary_str66" ,1626870128249270976 +8.15,"binary_str67" ,1626870128249274048 +0.75,"binary_str68" ,1626870128249277120 +3.265,"binary_str69" ,1626870128249280960 +8.585,"binary_str70" ,1626870128249284032 +1.88,"binary_str71" ,1626870128249287104 +8.44,"binary_str72" ,1626870128249289920 +5.12,"binary_str73" ,1626870128249295040 +2.58,"binary_str74" ,1626870128249298112 +9.42,"binary_str75" ,1626870128249300928 +1.765,"binary_str76" ,1626870128249304000 +2.66,"binary_str77" ,1626870128249308096 +1.405,"binary_str78" ,1626870128249310912 +5.595,"binary_str79" ,1626870128249315008 +2.28,"binary_str80" ,1626870128249318080 +9.24,"binary_str81" ,1626870128249320896 +9.03,"binary_str82" ,1626870128249323968 +6.055,"binary_str83" ,1626870128249327040 +1.74,"binary_str84" ,1626870128249330112 +5.77,"binary_str85" ,1626870128249332928 +1.97,"binary_str86" ,1626870128249336000 +0.3,"binary_str87" ,1626870128249339072 +7.145,"binary_str88" ,1626870128249342912 +0.88,"binary_str89" ,1626870128249345984 +8.025,"binary_str90" ,1626870128249349056 +4.81,"binary_str91" ,1626870128249351872 +0.725,"binary_str92" ,1626870128249355968 +3.85,"binary_str93" ,1626870128249359040 +9.455,"binary_str94" ,1626870128249362112 +2.265,"binary_str95" ,1626870128249364928 +3.985,"binary_str96" ,1626870128249368000 +9.375,"binary_str97" ,1626870128249371072 +0.2,"binary_str98" ,1626870128249373888 +6.95,"binary_str99" ,1626870128249377984 diff --git a/tests/pytest/tools/taosdemoAllTest/nano_sampletags.csv b/tests/pytest/tools/taosdemoAllTest/nano_sampletags.csv new file mode 100644 index 0000000000000000000000000000000000000000..18fb855d6d9f55c29325c6ea6f77120effa72884 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/nano_sampletags.csv @@ -0,0 +1,100 @@ +"string0",7,8.615 +"string1",4,9.895 +"string2",3,2.92 +"string3",3,5.62 +"string4",7,1.615 +"string5",6,1.45 +"string6",5,7.48 +"string7",7,3.01 +"string8",5,4.76 +"string9",10,7.09 +"string10",2,8.38 +"string11",7,8.65 +"string12",5,5.025 +"string13",10,5.765 +"string14",2,4.57 +"string15",2,1.03 +"string16",7,6.98 +"string17",10,0.23 +"string18",7,5.815 +"string19",1,2.37 +"string20",10,8.865 +"string21",3,1.235 +"string22",2,8.62 +"string23",9,1.045 +"string24",8,4.34 +"string25",1,5.455 +"string26",2,4.475 +"string27",1,6.95 +"string28",2,3.39 +"string29",3,6.79 +"string30",7,9.735 +"string31",1,9.79 +"string32",10,9.955 +"string33",1,5.095 +"string34",3,3.86 +"string35",9,5.105 +"string36",10,4.22 +"string37",1,2.78 +"string38",9,6.345 +"string39",1,0.975 +"string40",5,6.16 +"string41",4,7.735 +"string42",5,6.6 +"string43",8,2.845 +"string44",1,0.655 +"string45",3,2.995 +"string46",9,3.6 +"string47",8,3.47 +"string48",3,7.98 +"string49",6,2.225 +"string50",9,5.44 +"string51",4,6.335 +"string52",3,2.955 +"string53",1,0.565 +"string54",6,5.575 +"string55",6,9.905 +"string56",9,6.025 +"string57",8,0.94 +"string58",10,0.15 +"string59",8,1.555 +"string60",4,2.28 +"string61",2,8.29 +"string62",9,6.22 +"string63",6,3.35 +"string64",10,6.7 +"string65",3,9.345 +"string66",7,9.815 +"string67",1,5.365 +"string68",10,3.81 +"string69",1,6.405 +"string70",8,2.715 +"string71",3,8.58 +"string72",8,6.34 +"string73",2,7.49 +"string74",4,8.64 +"string75",3,8.995 +"string76",7,3.465 +"string77",1,7.64 +"string78",6,3.65 +"string79",6,1.4 +"string80",6,5.875 +"string81",2,1.22 +"string82",5,7.87 +"string83",9,8.41 +"string84",9,8.9 +"string85",9,3.89 +"string86",2,5.0 +"string87",2,4.495 +"string88",4,2.835 +"string89",3,5.895 +"string90",7,8.41 +"string91",5,5.125 +"string92",7,9.165 +"string93",5,8.315 +"string94",10,7.485 +"string95",7,4.635 +"string96",2,6.015 +"string97",8,0.595 +"string98",3,8.79 +"string99",4,1.72 diff --git a/tests/pytest/tools/taosdemoAllTest/querrThreads0.json b/tests/pytest/tools/taosdemoAllTest/querrThreads0.json new file mode 100644 index 0000000000000000000000000000000000000000..3999845dec12042eecd031a4731f3aa8403d067d --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/querrThreads0.json @@ -0,0 +1,37 @@ +{ + "filetype": "query", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "confirm_parameter_prompt": "no", + "databases": "db", + "query_times": 3, + "specified_table_query": { + "query_interval": 0, + "concurrent": 1, + "sqls": [ + { + "sql": "select last_row(*) from stb00_0", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_99 ", + "result": "./query_res1.txt" + + }] + }, + "super_table_query": { + "stblname": "stb1", + "query_interval":0, + "threads": 0, + "sqls": [ + { + "sql": "select last_row(ts) from xxxx", + "result": "./query_res2.txt" + } + ] + } + } + diff --git a/tests/pytest/tools/taosdemoAllTest/querrThreadsless0.json b/tests/pytest/tools/taosdemoAllTest/querrThreadsless0.json new file mode 100644 index 0000000000000000000000000000000000000000..646cbcfbe21a7fa7fd6f305eadda63fdce00dcf5 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/querrThreadsless0.json @@ -0,0 +1,37 @@ +{ + "filetype": "query", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "confirm_parameter_prompt": "no", + "databases": "db", + "query_times": 3, + "specified_table_query": { + "query_interval": 0, + "concurrent": 1, + "sqls": [ + { + "sql": "select last_row(*) from stb00_0", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_99 ", + "result": "./query_res1.txt" + + }] + }, + "super_table_query": { + "stblname": "stb1", + "query_interval":0, + "threads": -1, + "sqls": [ + { + "sql": "select last_row(ts) from xxxx", + "result": "./query_res2.txt" + } + ] + } + } + diff --git a/tests/pytest/tools/taosdemoAllTest/query-interrupt.json b/tests/pytest/tools/taosdemoAllTest/query-interrupt.json new file mode 100644 index 0000000000000000000000000000000000000000..896e484c258ed4f1418f48a74cd643defc9c6731 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/query-interrupt.json @@ -0,0 +1,62 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 100, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 150000, + "childtable_limit": -1, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 1000, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":10}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/query-interrupt.py b/tests/pytest/tools/taosdemoAllTest/query-interrupt.py new file mode 100644 index 0000000000000000000000000000000000000000..270bfd8b60f559c370eb921cf74fe4f7b82ae06e --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/query-interrupt.py @@ -0,0 +1,88 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +import subprocess +import time +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def run(self): + tdSql.prepare() + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + + # # insert 1000w rows in stb0 + os.system("%staosdemo -f tools/taosdemoAllTest/query-interrupt.json -y " % binPath) + tdSql.execute("use db") + tdSql.query("select count (tbname) from stb0") + tdSql.checkData(0, 0,60) + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 6000000) + os.system('%staosdemo -f tools/taosdemoAllTest/queryall.json -y & ' % binPath) + time.sleep(2) + query_pid = int(subprocess.getstatusoutput('ps aux|grep "taosdemoAllTest/queryall.json" |grep -v "grep"|awk \'{print $2}\'')[1]) + taosd_cpu_load_1 = float(subprocess.getstatusoutput('top -n 1 -b -p $(ps aux|grep "bin/taosd -c"|grep -v "grep" |awk \'{print $2}\')|awk \'END{print}\' |awk \'{print $9}\'')[1]) + if taosd_cpu_load_1 > 10.0 : + os.system("kill -9 %d" % query_pid) + time.sleep(5) + taosd_cpu_load_2 = float(subprocess.getstatusoutput('top -n 1 -b -p $(ps aux|grep "bin/taosd -c"|grep -v "grep" |awk \'{print $2}\')|awk \'END{print}\' |awk \'{print $9}\'')[1]) + if taosd_cpu_load_2 < 10.0 : + suc_kill = 60 + else: + suc_kill = 10 + print("taosd_cpu_load is higher than 10%") + else: + suc_kill = 20 + print("taosd_cpu_load is still less than 10%") + tdSql.query("select count (tbname) from stb0") + tdSql.checkData(0, 0, "%d" % suc_kill) + os.system("rm -rf querySystemInfo*") + os.system("rm -rf insert_res.txt") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoAllTest/queryConcurrent0.json b/tests/pytest/tools/taosdemoAllTest/queryConcurrent0.json new file mode 100644 index 0000000000000000000000000000000000000000..fd047dec9497c64f8b8f4300617fcc90563b67bc --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/queryConcurrent0.json @@ -0,0 +1,37 @@ +{ + "filetype": "query", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "confirm_parameter_prompt": "no", + "databases": "db", + "query_times":3, + "specified_table_query": { + "query_interval": 0, + "concurrent": 0, + "sqls": [ + { + "sql": "select last_row(*) from stb00_0", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_99 ", + "result": "./query_res1.txt" + + }] + }, + "super_table_query": { + "stblname": "stb1", + "query_interval":0, + "threads": 1, + "sqls": [ + { + "sql": "select last_row(ts) from xxxx", + "result": "./query_res2.txt" + } + ] + } + } + \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/queryConcurrentless0.json b/tests/pytest/tools/taosdemoAllTest/queryConcurrentless0.json new file mode 100644 index 0000000000000000000000000000000000000000..96a54cfd09cda09f8a9ebed169527c13092c7d57 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/queryConcurrentless0.json @@ -0,0 +1,37 @@ +{ + "filetype": "query", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "confirm_parameter_prompt": "no", + "databases": "db", + "query_times":3, + "specified_table_query": { + "query_interval": 0, + "concurrent": -1, + "sqls": [ + { + "sql": "select last_row(*) from stb00_0", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_99 ", + "result": "./query_res1.txt" + + }] + }, + "super_table_query": { + "stblname": "stb1", + "query_interval":0, + "threads": 1, + "sqls": [ + { + "sql": "select last_row(ts) from xxxx", + "result": "./query_res2.txt" + } + ] + } + } + \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/queryInsertdata.json b/tests/pytest/tools/taosdemoAllTest/queryInsertdata.json new file mode 100644 index 0000000000000000000000000000000000000000..eb196e4096d26f429f013a8936c910e5dc86c304 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/queryInsertdata.json @@ -0,0 +1,86 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 0, + "num_of_records_per_req": 3000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 10, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 100, + "childtable_limit": 0, + "childtable_offset": 0, + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-11-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 1, "count":1}, {"type": "BINARY", "len": 3, "count":1}, {"type": "INT"}, {"type": "DOUBLE", "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 10, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 200, + "childtable_limit": 0, + "childtable_offset": 0, + "interlace_rows": 0 , + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-11-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 1, "count":3}, {"type": "BINARY", "len": 2, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/queryInsertrestdata.json b/tests/pytest/tools/taosdemoAllTest/queryInsertrestdata.json new file mode 100644 index 0000000000000000000000000000000000000000..0febbdfa19d2ba8dd4db0b318d05c5af18fd1584 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/queryInsertrestdata.json @@ -0,0 +1,86 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 0, + "num_of_records_per_req": 3000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 2, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 10, + "childtable_limit": 0, + "childtable_offset": 0, + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-11-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 1, "count":1}, {"type": "BINARY", "len": 3, "count":1}, {"type": "INT"}, {"type": "DOUBLE", "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 2, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 5, + "childtable_limit": 0, + "childtable_offset": 0, + "interlace_rows": 0 , + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-11-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 1, "count":3}, {"type": "BINARY", "len": 2, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/queryQps.json b/tests/pytest/tools/taosdemoAllTest/queryQps.json new file mode 100644 index 0000000000000000000000000000000000000000..7ebad5e2b2f5af687656c8eed041579d7de1e2c2 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/queryQps.json @@ -0,0 +1,37 @@ +{ + "filetype": "query", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "confirm_parameter_prompt": "no", + "databases": "db", + "query_times": 1, + "specified_table_query": { + "query_interval": 10000, + "concurrent": 4, + "sqls": [ + { + "sql": "select last_row(*) from stb00_0", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_99 ", + "result": "./query_res1.txt" + + }] + }, + "super_table_query": { + "stblname": "stb1", + "query_interval":20000, + "threads": 4, + "sqls": [ + { + "sql": "select last_row(ts) from xxxx", + "result": "./query_res2.txt" + } + ] + } + } + \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/queryRestful.json b/tests/pytest/tools/taosdemoAllTest/queryRestful.json new file mode 100644 index 0000000000000000000000000000000000000000..bc3a66f43c598431b6f582f56f89cabb9bbe6efe --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/queryRestful.json @@ -0,0 +1,38 @@ +{ + "filetype": "query", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "confirm_parameter_prompt": "no", + "databases": "db", + "query_times": 2, + "query_mode": "rest", + "specified_table_query": { + "query_interval": 1, + "concurrent": 3, + "sqls": [ + { + "sql": "select last_row(*) from db.stb0 ", + "result": "./query_res0.txt" + }, + { + "sql": "select count(*) from db.stb00_1", + "result": "./query_res1.txt" + } + ] + }, + "super_table_query": { + "stblname": "stb1", + "query_interval": 1, + "threads": 3, + "sqls": [ + { + "sql": "select last_row(ts) from xxxx", + "result": "./query_res2.txt" + } + ] + } + } + diff --git a/tests/pytest/tools/taosdemoAllTest/querySpeciMutisql100.json b/tests/pytest/tools/taosdemoAllTest/querySpeciMutisql100.json new file mode 100644 index 0000000000000000000000000000000000000000..4aa1c0b4dd1c8522ebac4b032387c974331f1a5d --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/querySpeciMutisql100.json @@ -0,0 +1,429 @@ +{ + "filetype": "query", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "confirm_parameter_prompt": "no", + "databases": "db", + "query_times": 2, + "specified_table_query": { + "query_interval": 1, + "concurrent": 3, + "sqls": [ + { + "sql": "select last_row(*) from stb00_0", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_1", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_2", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_3", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_4", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_5", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_6", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_7", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_8", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_9", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_10 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_11 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_12 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_13 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_14 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_15 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_16 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_17 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_18 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_19 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_20 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_21 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_22 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_23 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_24 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_25 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_26 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_27 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_28 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_29 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_30 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_31 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_32 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_33 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_34 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_35 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_36 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_37 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_38 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_39 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_40 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_41 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_42 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_43 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_44 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_45 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_46 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_47 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_48 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_49 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_50 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_51 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_52 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_53 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_54 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_55 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_56 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_57 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_58 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_59 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_60", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_61", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_62", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_63", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_64", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_65", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_66", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_67", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_68", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_69", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_70 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_71 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_72 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_73 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_74 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_75 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_76 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_77 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_78 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_79 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_80 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_81 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_82 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_83 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_84 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_85 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_86 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_87 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_88 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_89 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_90 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_91 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_92 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_93 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_94 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_95 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_96 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_97 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_98 ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_99 ", + "result": "./query_res0.txt" + + }] + }, + "super_table_query": { + "stblname": "stb1", + "query_interval": 1, + "threads": 3, + "sqls": [ + { + "sql": "select last_row(ts) from xxxx", + "result": "./query_res2.txt" + } + ] + } +} + \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/querySuperMutisql100.json b/tests/pytest/tools/taosdemoAllTest/querySuperMutisql100.json new file mode 100644 index 0000000000000000000000000000000000000000..c85713c94c3dd6fe5ee55bcc36badcce474a746e --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/querySuperMutisql100.json @@ -0,0 +1,419 @@ +{ + "filetype": "query", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "confirm_parameter_prompt": "no", + "databases": "db", + "query_times": 3, + "super_table_query": { + "stblname": "stb0", + "query_interval": 10000, + "concurrent": 9, + "sqls": [ + { + "sql": "select last_row(*) from xxxx", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select * from xxxx ", + "result": "./query_res0.txt" + + }] + } + } + \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/queryTaosc.json b/tests/pytest/tools/taosdemoAllTest/queryTaosc.json new file mode 100644 index 0000000000000000000000000000000000000000..fece4e71c584ce18b14f70a54dbc7e9abd6130a5 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/queryTaosc.json @@ -0,0 +1,37 @@ +{ + "filetype": "query", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "confirm_parameter_prompt": "no", + "databases": "db", + "query_times": 2, + "query_mode": "taosc", + "specified_table_query": { + "query_interval": 1, + "concurrent": 3, + "sqls": [ + { + "sql": "select last_row(*) from stb0 ", + "result": "./query_res0.txt" + }, + { + "sql": "select count(*) from stb00_1", + "result": "./query_res1.txt" + } + ] + }, + "super_table_query": { + "stblname": "stb1", + "query_interval": 1, + "threads": 3, + "sqls": [ + { + "sql": "select last_row(ts) from xxxx", + "result": "./query_res2.txt" + } + ] + } +} diff --git a/tests/pytest/tools/taosdemoAllTest/queryTimes0.json b/tests/pytest/tools/taosdemoAllTest/queryTimes0.json new file mode 100644 index 0000000000000000000000000000000000000000..63a13587728fa797a65794994c04378edb87a0c5 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/queryTimes0.json @@ -0,0 +1,37 @@ +{ + "filetype": "query", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "confirm_parameter_prompt": "no", + "databases": "db", + "query_times": 0, + "specified_table_query": { + "query_interval": 0, + "concurrent": 1, + "sqls": [ + { + "sql": "select last_row(*) from stb00_0", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_99 ", + "result": "./query_res1.txt" + + }] + }, + "super_table_query": { + "stblname": "stb1", + "query_interval":0, + "threads": 1, + "sqls": [ + { + "sql": "select last_row(ts) from xxxx", + "result": "./query_res2.txt" + } + ] + } + } + \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/queryTimesless0.json b/tests/pytest/tools/taosdemoAllTest/queryTimesless0.json new file mode 100644 index 0000000000000000000000000000000000000000..039f7e10603cd2d06608cb24a2cb72356bd50728 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/queryTimesless0.json @@ -0,0 +1,37 @@ +{ + "filetype": "query", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "confirm_parameter_prompt": "no", + "databases": "db", + "query_times": -1, + "specified_table_query": { + "query_interval": 0, + "concurrent": 1, + "sqls": [ + { + "sql": "select last_row(*) from stb00_0", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_99 ", + "result": "./query_res1.txt" + + }] + }, + "super_table_query": { + "stblname": "stb1", + "query_interval":0, + "threads": 1, + "sqls": [ + { + "sql": "select last_row(ts) from xxxx", + "result": "./query_res2.txt" + } + ] + } + } + \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/queryall.json b/tests/pytest/tools/taosdemoAllTest/queryall.json new file mode 100644 index 0000000000000000000000000000000000000000..bbc3b9717c6afa8d54d5f48726afe6d4f87be528 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/queryall.json @@ -0,0 +1,14 @@ +{ + "filetype":"query", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "confirm_parameter_prompt": "no", + "databases": "db", + "specified_table_query": + {"query_interval":1, "concurrent":1, + "sqls": [{"sql": "select * from stb0", "result": ""}] + } +} \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/sample.csv b/tests/pytest/tools/taosdemoAllTest/sample.csv new file mode 100644 index 0000000000000000000000000000000000000000..471118a2ce9466bdb629434a32407c9616de9e3e --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/sample.csv @@ -0,0 +1,3 @@ +1,-1,2147483647,0,2247483647.1,-12.2,'12ac,;\[uer]','23ac,;\[uer23423]123123','true' +0,-1,2147483647,0,2247483647.1,-12.2,'12ac,;\[uer]','23ac,;\[uer23423]123123','true' +0,-1,2147483647,0,2247483647.1,-12.2,'12ac,;\[uer]','23ac,;\[uer23423]123123','false' \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-1s1tnt1r-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-1s1tnt1r-stmt.json new file mode 100644 index 0000000000000000000000000000000000000000..adb8764b2f6f3f89f0c3e2024ef0098ffb45b2c4 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-1s1tnt1r-stmt.json @@ -0,0 +1,88 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10, + "num_of_records_per_req": 1, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 1000, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 1, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 100, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1}, {"type": "BINARY", "len": 16, "count":1}, {"type": "BINARY", "len": 32, "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":1}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 1000, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 200, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1}, {"type": "BINARY", "len": 16, "count":1}, {"type": "BINARY", "len": 32, "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":1}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-1s1tntmr-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-1s1tntmr-stmt.json new file mode 100644 index 0000000000000000000000000000000000000000..b21154f1c578dedfbb880ac6aa8c9a1d101574ef --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-1s1tntmr-stmt.json @@ -0,0 +1,88 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 10, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 10000, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1}, {"type": "BINARY", "len": 16, "count":1}, {"type": "BINARY", "len": 32, "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":1}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 20, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 20000, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1}, {"type": "BINARY", "len": 16, "count":1}, {"type": "BINARY", "len": 32, "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":1}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-disorder-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-disorder-stmt.json new file mode 100644 index 0000000000000000000000000000000000000000..e7501804211c60767e073f98865a6ee9d719901f --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-disorder-stmt.json @@ -0,0 +1,88 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file":"./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 1, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 10, + "childtable_limit": -1, + "childtable_offset": 0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 1, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 10, + "disorder_range": 100, + "timestamp_step": 1000, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count":1, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 1, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 10, + "childtable_limit": -1, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 100, + "disorder_range": 1, + "timestamp_step": 1000, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":10}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-drop-exist-auto-N00-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-drop-exist-auto-N00-stmt.json new file mode 100644 index 0000000000000000000000000000000000000000..e541d663fc9f884a7206592271d5124da7746793 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-drop-exist-auto-N00-stmt.json @@ -0,0 +1,181 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 100, + "num_of_records_per_req": 100, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "no", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 3650, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb", + "child_table_exists":"no", + "auto_create_table": "123", + "childtable_count": 20, + "childtable_prefix": "NN123_", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 5, + "childtable_limit": 40, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "now", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "TINYINT"}] + },{ + "name": "stb", + "child_table_exists":"no", + "auto_create_table": "no", + "childtable_count": 20, + "childtable_prefix": "NNN_", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 5, + "childtable_limit": 40, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "now", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "TINYINT"}] + },{ + "name": "stb", + "child_table_exists":"no", + "auto_create_table": "yes", + "childtable_count": 20, + "childtable_prefix": "NNY_", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 5, + "childtable_limit": 40, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "now", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "TINYINT"}] + },{ + "name": "stb", + "child_table_exists":"yes", + "auto_create_table": "123", + "childtable_count": 20, + "childtable_prefix": "NY123_", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 5, + "childtable_limit": 40, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "now", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "TINYINT"}] + },{ + "name": "stb", + "child_table_exists":"yes", + "auto_create_table": "no", + "childtable_count": 20, + "childtable_prefix": "NYN_", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 5, + "childtable_limit": 40, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "now", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "TINYINT"}] + },{ + "name": "stb", + "child_table_exists":"yes", + "auto_create_table": "yes", + "childtable_count": 20, + "childtable_prefix": "NYY_", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 5, + "childtable_limit": 40, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "now", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "TINYINT"}] + } + ] + }] +} \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-drop-exist-auto-Y00-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-drop-exist-auto-Y00-stmt.json new file mode 100644 index 0000000000000000000000000000000000000000..f32d44240d7f5b717013878358e5d4db378ba354 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-drop-exist-auto-Y00-stmt.json @@ -0,0 +1,181 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 100, + "num_of_records_per_req": 100, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 3650, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb", + "child_table_exists":"no", + "auto_create_table": "123", + "childtable_count": 20, + "childtable_prefix": "YN123_", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 5, + "childtable_limit": 40, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "now", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "TINYINT"}] + },{ + "name": "stb", + "child_table_exists":"no", + "auto_create_table": "no", + "childtable_count": 20, + "childtable_prefix": "YNN_", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 5, + "childtable_limit": 40, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "now", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "TINYINT"}] + },{ + "name": "stb", + "child_table_exists":"no", + "auto_create_table": "yes", + "childtable_count": 20, + "childtable_prefix": "YNY_", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 5, + "childtable_limit": 40, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "now", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "TINYINT"}] + },{ + "name": "stb", + "child_table_exists":"yes", + "auto_create_table": "123", + "childtable_count": 20, + "childtable_prefix": "YY123_", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 5, + "childtable_limit": 40, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "now", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "TINYINT"}] + },{ + "name": "stb", + "child_table_exists":"yes", + "auto_create_table": "no", + "childtable_count": 20, + "childtable_prefix": "YYN_", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 5, + "childtable_limit": 40, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "now", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "TINYINT"}] + },{ + "name": "stb", + "child_table_exists":"yes", + "auto_create_table": "yes", + "childtable_count": 20, + "childtable_prefix": "YYY_", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 5, + "childtable_limit": 40, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "now", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "TINYINT"}] + } + ] + }] +} \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-interlace-row-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-interlace-row-stmt.json new file mode 100644 index 0000000000000000000000000000000000000000..45eb612e6f2efcedfe9de8d5f6cb4aeb3a464353 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-interlace-row-stmt.json @@ -0,0 +1,62 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 100, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 150, + "childtable_limit": -1, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 151, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":10}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-interval-speed-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-interval-speed-stmt.json new file mode 100644 index 0000000000000000000000000000000000000000..4e6edb2199b4cadffcc4bbc7ac74d00cfb1f1a69 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-interval-speed-stmt.json @@ -0,0 +1,88 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 100, + "interlace_rows": 0, + "num_of_records_per_req": 2000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 20000, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 1000, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1}, {"type": "BINARY", "len": 16, "count":1}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 20000, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 1000, + "insert_interval": 200, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1}, {"type": "BINARY", "len": 16, "count":1}, {"type": "BINARY", "len": 32, "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":1}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-newdb-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-newdb-stmt.json new file mode 100644 index 0000000000000000000000000000000000000000..622b2554ec37b223226fcab3ad3e01568937fc0f --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-newdb-stmt.json @@ -0,0 +1,166 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 0, + "num_of_records_per_req": 3000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 1 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"yes", + "childtable_count": 5, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 10, + "childtable_limit": -1, + "childtable_offset": 0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1}, {"type": "BINARY", "len": 16, "count":1}, {"type": "BINARY", "len": 32, "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 6, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 20, + "childtable_limit": -1, + "childtable_offset": 0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb2", + "child_table_exists":"no", + "childtable_count": 7, + "childtable_prefix": "stb02_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 20, + "childtable_limit": 4, + "childtable_offset": 0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb3", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb03_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 20, + "childtable_limit": 2, + "childtable_offset": 7, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb4", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb04_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 20, + "childtable_limit": 0, + "childtable_offset": 7, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-newtable-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-newtable-stmt.json new file mode 100644 index 0000000000000000000000000000000000000000..31985c85460cf39cc926afdc3c614fb84a45bd4b --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-newtable-stmt.json @@ -0,0 +1,166 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 0, + "num_of_records_per_req": 3000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "no", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 1 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"yes", + "childtable_count": 5, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 20, + "childtable_limit": -1, + "childtable_offset": 0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-12-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 6, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 20, + "childtable_limit": -1, + "childtable_offset": 0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-12-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb2", + "child_table_exists":"no", + "childtable_count": 7, + "childtable_prefix": "stb02_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 20, + "childtable_limit": 4, + "childtable_offset": 0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-12-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb3", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb03_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 20, + "childtable_limit": 2, + "childtable_offset": 7, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-12-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb4", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb04_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 30, + "childtable_limit": 0, + "childtable_offset": 7, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-12-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-nodbnodrop-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-nodbnodrop-stmt.json new file mode 100644 index 0000000000000000000000000000000000000000..3ebc377ca79d5cf472c102f23736960d757636e1 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-nodbnodrop-stmt.json @@ -0,0 +1,62 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 0, + "num_of_records_per_req": 3000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "dbno", + "drop": "no", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 1 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 5, + "childtable_prefix": "stb00_", + "auto_create_table": "yes", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 10, + "childtable_limit": -1, + "childtable_offset": 0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-offset-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-offset-stmt.json new file mode 100644 index 0000000000000000000000000000000000000000..adc6fa74bee9441999b83196726c2a133da7c24d --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-offset-stmt.json @@ -0,0 +1,166 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 0, + "num_of_records_per_req": 3000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "no", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"yes", + "childtable_count": 5, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 20, + "childtable_limit": 0, + "childtable_offset": 0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-11-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb1", + "child_table_exists":"yes", + "childtable_count": 6, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 20, + "childtable_limit": -1, + "childtable_offset": 0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-11-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb2", + "child_table_exists":"yes", + "childtable_count": 7, + "childtable_prefix": "stb02_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 20, + "childtable_limit": 4, + "childtable_offset": 0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-11-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb3", + "child_table_exists":"yes", + "childtable_count": 8, + "childtable_prefix": "stb03_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 20, + "childtable_limit": 2, + "childtable_offset":7, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-11-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb4", + "child_table_exists":"yes", + "childtable_count": 8, + "childtable_prefix": "stb04_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 20, + "childtable_limit": 0, + "childtable_offset": 7, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-11-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-renewdb-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-renewdb-stmt.json new file mode 100644 index 0000000000000000000000000000000000000000..715644f4f062d166e67f3038bacb903a26fbf93d --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-renewdb-stmt.json @@ -0,0 +1,166 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 0, + "num_of_records_per_req": 3000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 1 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"yes", + "childtable_count": 5, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 10, + "childtable_limit": -1, + "childtable_offset": 0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 6, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 20, + "childtable_limit": -1, + "childtable_offset": 0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb2", + "child_table_exists":"no", + "childtable_count": 7, + "childtable_prefix": "stb02_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 20, + "childtable_limit": 4, + "childtable_offset": 0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb3", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb03_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 20, + "childtable_limit": 2, + "childtable_offset": 7, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb4", + "child_table_exists":"no", + "childtable_count": 8, + "childtable_prefix": "stb04_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 20, + "childtable_limit": 0, + "childtable_offset": 7, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":6}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-sample-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-sample-stmt.json new file mode 100644 index 0000000000000000000000000000000000000000..e3d6ce850aeae242a5ac857cc02a9123845debb7 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-sample-stmt.json @@ -0,0 +1,88 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file":"./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "dbtest123", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 1, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "sample", + "insert_mode": "stmt", + "insert_rows": 10, + "childtable_limit": -1, + "childtable_offset": 0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./tools/taosdemoAllTest/sample.csv", + "tags_file": "", + "columns": [{"type": "INT", "count":3}, {"type": "DOUBLE", "count":3}, {"type": "BINARY", "len": 16, "count":1}, {"type": "BINARY", "len": 32, "count":1}, {"type": "BOOL"}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count":2, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 10, + "childtable_limit": -1, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "./tools/taosdemoAllTest/tags.csv", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":10}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":3}, {"type": "BINARY", "len": 16, "count":2}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-timestep-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-timestep-stmt.json new file mode 100644 index 0000000000000000000000000000000000000000..563dc86d0a1481e6b117766facf2122c75bd20f2 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-timestep-stmt.json @@ -0,0 +1,88 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file":"./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 10, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 20, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":10}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count":20, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 20, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "2020-11-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":10}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insertBinaryLenLarge16374AllcolLar49151-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insertBinaryLenLarge16374AllcolLar49151-stmt.json new file mode 100644 index 0000000000000000000000000000000000000000..5b7a7eda59831646a97318025b2b66979a17411a --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insertBinaryLenLarge16374AllcolLar49151-stmt.json @@ -0,0 +1,166 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10, + "num_of_records_per_req": 10240000000, + "max_sql_len": 10240000000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 1, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 1, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 16374, "count":1}], + "tags": [{"type": "TINYINT", "count":12}, {"type": "BINARY", "len": 16, "count":2}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 1, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 12, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 1, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 16370, "count":1},{"type": "INT"}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb3", + "child_table_exists":"no", + "childtable_count": 1, + "childtable_prefix": "stb03_", + "auto_create_table": "no", + "batch_create_tbl_num": 12, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 1, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 16371, "count":3},{"type": "INT","count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb2", + "child_table_exists":"no", + "childtable_count": 1, + "childtable_prefix": "stb02_", + "auto_create_table": "no", + "batch_create_tbl_num": 12, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 1, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 16375, "count":1},{"type": "INT"}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb4", + "child_table_exists":"no", + "childtable_count": 1, + "childtable_prefix": "stb04_", + "auto_create_table": "no", + "batch_create_tbl_num": 12, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 1, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 100, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 16371, "count":3},{"type": "INT","count":6},{"type": "TINYINT"}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insertChildTab0-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insertChildTab0-stmt.json new file mode 100644 index 0000000000000000000000000000000000000000..a27feee68a7700633197791567647875e6febee4 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insertChildTab0-stmt.json @@ -0,0 +1,88 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10, + "num_of_records_per_req": 10, + "max_sql_len": 10240000000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 0, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 1, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 1, "count":1}], + "tags": [{"type": "TINYINT", "count":1}, {"type": "BINARY", "len": 16, "count":2}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 10, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 12, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 2, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 1, "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insertChildTabLess0-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insertChildTabLess0-stmt.json new file mode 100644 index 0000000000000000000000000000000000000000..50e1a7173b0b708b454559c3a718e48900467c5a --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insertChildTabLess0-stmt.json @@ -0,0 +1,88 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10, + "num_of_records_per_req": 10, + "max_sql_len": 10240000000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": -1, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 1, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 1, "count":1}], + "tags": [{"type": "TINYINT", "count":1}, {"type": "BINARY", "len": 16, "count":2}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 10, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 12, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 2, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 1, "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insertColumnsAndTagNum4096-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insertColumnsAndTagNum4096-stmt.json new file mode 100644 index 0000000000000000000000000000000000000000..ca0d17f93ba503f3b532aa2cb9245282c540c507 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insertColumnsAndTagNum4096-stmt.json @@ -0,0 +1,62 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 0, + "num_of_records_per_req": 1000, + "max_sql_len": 10240000000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 10, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 1000, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1004}, {"type": "BINARY", "len": 5, "count":3075}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":7}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insertColumnsNum0-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insertColumnsNum0-stmt.json new file mode 100644 index 0000000000000000000000000000000000000000..c86e759db4377d05a2e4ec1b1b2bc4144f5689e4 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insertColumnsNum0-stmt.json @@ -0,0 +1,62 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10, + "num_of_records_per_req": 100, + "max_sql_len": 10240000000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 10, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 1000, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":0}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":7}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insertInterlaceRowsLarge1M-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insertInterlaceRowsLarge1M-stmt.json new file mode 100644 index 0000000000000000000000000000000000000000..ee36b62f903a2d27b24b55eba9a10146d45080ee --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insertInterlaceRowsLarge1M-stmt.json @@ -0,0 +1,62 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 0, + "num_of_records_per_req": 1000, + "max_sql_len": 10240000000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 10, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 1000, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 1000, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1004}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":7}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insertMaxNumPerReq-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insertMaxNumPerReq-stmt.json new file mode 100644 index 0000000000000000000000000000000000000000..00c346678f884a06a0611116ad13e47117bad59f --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insertMaxNumPerReq-stmt.json @@ -0,0 +1,86 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 50000, + "num_of_records_per_req": 50000, + "max_sql_len": 1025000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 3650, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows":50000, + "childtable_limit": -1, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1025000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2012-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "TINYINT", "count":1}], + "tags": [{"type": "TINYINT", "count":1}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows":50000, + "childtable_limit": -1, + "childtable_offset":0, + "interlace_rows": 32767, + "insert_interval":0, + "max_sql_len": 1025000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2012-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "TINYINT", "count":1}], + "tags": [{"type": "TINYINT", "count":1}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insertNumOfrecordPerReq0-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insertNumOfrecordPerReq0-stmt.json new file mode 100644 index 0000000000000000000000000000000000000000..4bd071ec15a56feb1ea2b119697f934620d6b8c2 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insertNumOfrecordPerReq0-stmt.json @@ -0,0 +1,88 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10, + "num_of_records_per_req": 0, + "max_sql_len": 10240000000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 1, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 1, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 1, "count":1}], + "tags": [{"type": "TINYINT", "count":1}, {"type": "BINARY", "len": 16, "count":2}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 2, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 12, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 2, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 1, "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insertNumOfrecordPerReqless0-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insertNumOfrecordPerReqless0-stmt.json new file mode 100644 index 0000000000000000000000000000000000000000..628c86045fa4a33f5d2e93882ca3b56dbfc91292 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insertNumOfrecordPerReqless0-stmt.json @@ -0,0 +1,88 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10, + "num_of_records_per_req": -1, + "max_sql_len": 10240000000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 1, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 1, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 1, "count":1}], + "tags": [{"type": "TINYINT", "count":1}, {"type": "BINARY", "len": 16, "count":2}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 2, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 12, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 2, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 1, "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insertSigcolumnsNum4096-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insertSigcolumnsNum4096-stmt.json new file mode 100644 index 0000000000000000000000000000000000000000..7abab6a0cf00d3161bb85114cb07eb39d7f7a747 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insertSigcolumnsNum4096-stmt.json @@ -0,0 +1,62 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10, + "num_of_records_per_req": 100, + "max_sql_len": 10240000000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 10, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 1000, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "DOUBLE", "count":4096}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":7}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insertTagsNumLarge128-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insertTagsNumLarge128-stmt.json new file mode 100644 index 0000000000000000000000000000000000000000..8f8539be2117f8706f894f92b2075848b0203216 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insertTagsNumLarge128-stmt.json @@ -0,0 +1,62 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10, + "num_of_records_per_req": 1000000, + "max_sql_len": 1024000000, + "databases": [{ + "dbinfo": { + "name": "db1", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 10, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 1000, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 10000, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1}, {"type": "BIGINT", "count":1}, {"type": "float", "count":1}, {"type": "double", "count":1}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":127}, {"type": "BINARY", "len": 16, "count":2}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insertTimestepMulRowsLargeint16-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insertTimestepMulRowsLargeint16-stmt.json new file mode 100644 index 0000000000000000000000000000000000000000..ed3eb280f6869bed76de72bdf50b646bca4a245a --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/stmt/insertTimestepMulRowsLargeint16-stmt.json @@ -0,0 +1,65 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "localhost", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "databases": [ + { + "dbinfo": { + "name": "blf", + "drop": "yes" + }, + "super_tables": [ + { + "name": "p_0_topics", + "child_table_exists": "no", + "childtable_count": 10, + "childtable_prefix": "p_0_topics_", + "auto_create_table": "no", + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 525600, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 1000, + "max_sql_len": 1048576, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 60000, + "start_timestamp": "2019-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [ + { + "type": "INT", + "count": 1 + }, + { + "type": "FLOAT", + "count": 1 + }, + { + "type": "BINARY", + "len": 12, + "count": 1 + } + ], + "tags": [ + { + "type": "BINARY", + "len": 12, + "count": 10 + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/nsertColumnsAndTagNumLarge4096-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/nsertColumnsAndTagNumLarge4096-stmt.json new file mode 100644 index 0000000000000000000000000000000000000000..c5a3a5f76de18589f3271287a78510e39acfb27f --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/stmt/nsertColumnsAndTagNumLarge4096-stmt.json @@ -0,0 +1,62 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10000, + "num_of_records_per_req": 10000, + "max_sql_len": 10240000000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 10, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "stmt", + "insert_rows": 1000, + "childtable_limit": 0, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1005}, {"type": "BINARY", "len": 16, "count":3075}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":7}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/subAsync.json b/tests/pytest/tools/taosdemoAllTest/subAsync.json new file mode 100644 index 0000000000000000000000000000000000000000..67a3bf5aab85bc540b4b891039ba59960ff3f4b1 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/subAsync.json @@ -0,0 +1,45 @@ +{ + "filetype":"subscribe", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "databases": "db", + "confirm_parameter_prompt": "no", + "specified_table_query": + { + "concurrent":2, + "mode":"async", + "interval":0, + "restart":"yes", + "keepProgress":"yes", + "sqls": [ + { + "sql": "select * from stb00_0", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select ts from stb00_1", + "result": "./subscribe_res1.txt" + }] + }, + "super_table_query": + { + "stblname": "stb0", + "threads":2, + "mode":"async", + "interval":0, + "restart":"yes", + "keepProgress":"yes", + "sqls": [ + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:01.000' ", + "result": "./subscribe_res2.txt" + }, + { + "sql": "select * from xxxx where ts > '2021-02-25 10:00:04.000' ", + "result": "./subscribe_res3.txt" + }] + } + } \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/subInsertdata.json b/tests/pytest/tools/taosdemoAllTest/subInsertdata.json new file mode 100644 index 0000000000000000000000000000000000000000..168b3753a13e6bfa2e884f5b8be4a03bb1675b2a --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/subInsertdata.json @@ -0,0 +1,61 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 0, + "num_of_records_per_req": 3000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 2, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 10, + "childtable_limit": 0, + "childtable_offset": 0, + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1000, + "start_timestamp": "2021-02-25 10:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 1, "count":1}, {"type": "BINARY", "len": 3, "count":1}, {"type": "INT"}, {"type": "DOUBLE", "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/subInsertdataMaxsql100.json b/tests/pytest/tools/taosdemoAllTest/subInsertdataMaxsql100.json new file mode 100644 index 0000000000000000000000000000000000000000..4fb7241012563143cf289f510a8b58f39841b9d0 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/subInsertdataMaxsql100.json @@ -0,0 +1,86 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 0, + "num_of_records_per_req": 3000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 200, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 1000, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 10, + "childtable_limit": 0, + "childtable_offset": 0, + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1000, + "start_timestamp": "2021-02-25 10:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 1, "count":1}, {"type": "BINARY", "len": 3, "count":1}, {"type": "INT"}, {"type": "DOUBLE", "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 20, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 1000, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 10, + "childtable_limit": 0, + "childtable_offset": 0, + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1000, + "start_timestamp": "2021-02-25 10:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "BINARY", "len": 1, "count":1}, {"type": "BINARY", "len": 3, "count":1}, {"type": "INT"}, {"type": "DOUBLE", "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/subSync.json b/tests/pytest/tools/taosdemoAllTest/subSync.json new file mode 100644 index 0000000000000000000000000000000000000000..aa0b2cd7a4b454fd3332d72a521d244b5e567869 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/subSync.json @@ -0,0 +1,45 @@ +{ + "filetype":"subscribe", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "databases": "db", + "confirm_parameter_prompt": "no", + "specified_table_query": + { + "concurrent":2, + "mode":"sync", + "interval":0, + "restart":"no", + "keepProgress":"no", + "sqls": [ + { + "sql": "select * from stb00_0", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select ts from stb00_1", + "result": "./subscribe_res1.txt" + }] + }, + "super_table_query": + { + "stblname": "stb0", + "threads":2, + "mode":"sync", + "interval":10000, + "restart":"no", + "keepProgress":"no", + "sqls": [ + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:01.000' ", + "result": "./subscribe_res2.txt" + }, + { + "sql": "select * from xxxx where ts > '2021-02-25 10:00:04.000' ", + "result": "./subscribe_res3.txt" + }] + } + } \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/subSyncResFileNull.json b/tests/pytest/tools/taosdemoAllTest/subSyncResFileNull.json new file mode 100644 index 0000000000000000000000000000000000000000..625e4792cfa113166e0ba5b0ef068bb2109bf027 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/subSyncResFileNull.json @@ -0,0 +1,49 @@ +{ + "filetype":"subscribe", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "databases": "db", + "confirm_parameter_prompt": "no", + "specified_table_query": + { + "concurrent":2, + "mode":"sync", + "interval":0, + "restart":"no", + "keepProgress":"no", + "resubAfterConsume":-1, + "endAfterConsume":1, + "sqls": [ + { + "sql": "select * from stb00_0", + "result": "" + }, + { + "sql": "select ts from stb00_1", + "result": "" + }] + }, + "super_table_query": + { + "stblname": "stb0", + "threads":2, + "mode":"sync", + "interval":10000, + "restart":"no", + "keepProgress":"no", + "resubAfterConsume":-1, + "endAfterConsume":1, + "sqls": [ + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:01.000' ", + "result": "" + }, + { + "sql": "select * from xxxx where ts > '2021-02-25 10:00:04.000' ", + "result": "" + }] + } + } \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/subSyncSpecMaxsql100.json b/tests/pytest/tools/taosdemoAllTest/subSyncSpecMaxsql100.json new file mode 100644 index 0000000000000000000000000000000000000000..6b2828822e4a35989ff9c0d69a469bb34a0e7a84 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/subSyncSpecMaxsql100.json @@ -0,0 +1,439 @@ +{ + "filetype":"subscribe", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "databases": "db", + "confirm_parameter_prompt": "no", + "specified_table_query": + { + "concurrent":1, + "mode":"sync", + "interval":0, + "restart":"no", + "keepProgress":"no", + "sqls": [ + { + "sql": "select * from stb00_0", + "result": "./subscribe_res1.txt" + }, + { + "sql": "select * from stb00_1", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_2", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_3", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_4", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_5", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_6", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_7", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_8", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_9", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_10 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_11 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_12 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_13 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_14 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_15 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_16 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_17 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_18 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_19 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_20 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_21 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_22 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_23 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_24 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_25 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_26 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_27 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_28 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_29 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_30 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_31 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_32 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_33 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_34 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_35 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_36 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_37 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_38 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_39 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_40 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_41 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_42 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_43 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_44 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_45 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_46 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_47 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_48 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_49 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_50 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_51 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_52 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_53 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_54 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_55 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_56 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_57 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_58 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_59 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_60", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_61", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_62", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_63", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_64", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_65", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_66", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_67", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_68", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_69", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_70 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_71 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_72 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_73 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_74 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_75 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_76 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_77 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_78 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_79 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_80 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_81 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_82 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_83 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_84 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_85 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_86 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_87 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_88 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_89 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_90 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_91 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_92 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_93 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_94 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_95 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_96 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_97 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_98 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_99 ", + "result": "./subscribe_res0.txt" + + }, + { + "sql": "select * from stb00_99 ", + "result": "./subscribe_res0.txt" + + }] + }, + "super_table_query": + { + "stblname": "stb0", + "threads":2, + "mode":"sync", + "interval":0, + "restart":"no", + "keepProgress":"no", + "sqls": [ + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:01.000' ", + "result": "./subscribe_res2.txt" + }] + } +} \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/subSyncSpecMaxsql100Async.json b/tests/pytest/tools/taosdemoAllTest/subSyncSpecMaxsql100Async.json new file mode 100644 index 0000000000000000000000000000000000000000..c45a9ea48a147ae96256de60ab6d1f9c579f1431 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/subSyncSpecMaxsql100Async.json @@ -0,0 +1,439 @@ +{ + "filetype":"subscribe", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "databases": "db", + "confirm_parameter_prompt": "no", + "specified_table_query": + { + "concurrent":1, + "mode":"async", + "interval":0, + "restart":"no", + "keepProgress":"no", + "sqls": [ + { + "sql": "select * from stb00_0", + "result": "./subscribe_res1.txt" + }, + { + "sql": "select * from stb00_1", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_2", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_3", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_4", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_5", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_6", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_7", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_8", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_9", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_10 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_11 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_12 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_13 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_14 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_15 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_16 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_17 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_18 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_19 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_20 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_21 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_22 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_23 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_24 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_25 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_26 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_27 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_28 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_29 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_30 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_31 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_32 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_33 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_34 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_35 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_36 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_37 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_38 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_39 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_40 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_41 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_42 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_43 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_44 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_45 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_46 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_47 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_48 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_49 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_50 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_51 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_52 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_53 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_54 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_55 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_56 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_57 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_58 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_59 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_60", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_61", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_62", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_63", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_64", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_65", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_66", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_67", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_68", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_69", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_70 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_71 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_72 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_73 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_74 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_75 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_76 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_77 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_78 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_79 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_80 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_81 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_82 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_83 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_84 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_85 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_86 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_87 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_88 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_89 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_90 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_91 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_92 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_93 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_94 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_95 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_96 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_97 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_98 ", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb00_99 ", + "result": "./subscribe_res0.txt" + + }, + { + "sql": "select * from stb00_99 ", + "result": "./subscribe_res0.txt" + + }] + }, + "super_table_query": + { + "stblname": "stb0", + "threads":2, + "mode":"sync", + "interval":0, + "restart":"no", + "keepProgress":"no", + "sqls": [ + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:01.000' ", + "result": "./subscribe_res2.txt" + }] + } +} \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/subSyncSuperMaxsql100.json b/tests/pytest/tools/taosdemoAllTest/subSyncSuperMaxsql100.json new file mode 100644 index 0000000000000000000000000000000000000000..3214d35bf04aa3b66b336734469539f42ea50c4c --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/subSyncSuperMaxsql100.json @@ -0,0 +1,426 @@ +{ + "filetype":"subscribe", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "databases": "db", + "confirm_parameter_prompt": "no", + "super_table_query": + { + "stblname": "stb1", + "threads":4, + "mode":"sync", + "interval":0, + "restart":"no", + "resubAfterConsume":-1, + "endAfterConsume":1, + "keepProgress":"no", + "sqls": [ + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res2.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }] + } +} \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/subSyncSuperMaxsql100Async.json b/tests/pytest/tools/taosdemoAllTest/subSyncSuperMaxsql100Async.json new file mode 100644 index 0000000000000000000000000000000000000000..075ec9cf5dc5fc75da2da4cde8a9358799af7cb9 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/subSyncSuperMaxsql100Async.json @@ -0,0 +1,426 @@ +{ + "filetype":"subscribe", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "databases": "db", + "confirm_parameter_prompt": "no", + "super_table_query": + { + "stblname": "stb1", + "threads":4, + "mode":"async", + "interval":0, + "restart":"no", + "resubAfterConsume":-1, + "endAfterConsume":1, + "keepProgress":"no", + "sqls": [ + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res2.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }, + { + "sql": "select * from xxxx where ts >= '2021-02-25 10:00:00.000' ", + "result": "./subscribe_res3.txt" + }] + } +} \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/sub_no_result.json b/tests/pytest/tools/taosdemoAllTest/sub_no_result.json new file mode 100644 index 0000000000000000000000000000000000000000..cdf7c2314ede28e9c3ccaa9d53864737ff3fac96 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/sub_no_result.json @@ -0,0 +1,25 @@ +{ + "filetype": "subscribe", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "databases": "db", + "confirm_parameter_prompt": "no", + "specified_table_query": + { + "concurrent":1, + "mode":"sync", + "interval": 0, + "restart":"yes", + "keepProgress":"no", + "endAfterConsume": 1100000, + "sqls": [ + { + "sql": "select * from st;", + "result": "" + }] + } + } + \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/subscribeNoResult.py b/tests/pytest/tools/taosdemoAllTest/subscribeNoResult.py new file mode 100644 index 0000000000000000000000000000000000000000..270eea17cb6c913719fb67c4b8f33065b0a0445d --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/subscribeNoResult.py @@ -0,0 +1,82 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +import time +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import _thread + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.ts = 1601481600000 + self.numberOfRecords = 1100000 + + def execCmdAndGetOutput(self, cmd): + r = os.popen(cmd) + text = r.read() + r.close() + return text + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def run(self): + buildPath = self.getBuildPath() + tdSql.prepare() + tdSql.execute("create table st(ts timestamp, c1 timestamp, c2 int, c3 bigint, c4 float, c5 double, c6 binary(8), c7 smallint, c8 tinyint, c9 bool, c10 nchar(8)) tags(t1 int)") + tdSql.execute("create table t1 using st tags(0)") + currts = self.ts + finish = 0 + while(finish < self.numberOfRecords): + sql = "insert into t1 values" + for i in range(finish, self.numberOfRecords): + sql += "(%d, 1019774612, 29931, 1442173978, 165092.468750, 1128.643179, 'MOCq1pTu', 18405, 82, 0, 'g0A6S0Fu')" % (currts + i) + finish = i + 1 + if (1048576 - len(sql)) < 16384: + break + tdSql.execute(sql) + + binPath = buildPath+ "/build/bin/" + + os.system("%staosdemo -f tools/taosdemoAllTest/sub_no_result.json -g 2>&1 | tee sub_no_result.log" % binPath) + test_line = int(self.execCmdAndGetOutput("cat sub_no_result.log | wc -l")) + if(test_line < 1100024): + tdLog.exit("failed test subscribeNoResult: %d != expected(1100024)" % test_line) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/tags.csv b/tests/pytest/tools/taosdemoAllTest/tags.csv new file mode 100644 index 0000000000000000000000000000000000000000..89bf8e3fb34a9498601a72bfc2779d93d9ab7a91 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/tags.csv @@ -0,0 +1,2 @@ +1,-127,127,'23ac,;\[uer]3','true' +1,-127,126,'23ac,;\[uer]3','true' diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoInsertMSDB.json b/tests/pytest/tools/taosdemoAllTest/taosdemoInsertMSDB.json new file mode 100644 index 0000000000000000000000000000000000000000..49ab6f3a4367b4cebd840bb24b43a5d190c0d464 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/taosdemoInsertMSDB.json @@ -0,0 +1,63 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 10, + "thread_count_create_tbl": 10, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 100, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "testdb3", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "tb0_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 100, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1000, + "start_timestamp": "2021-07-01 00:00:00.000", + "sample_format": "", + "sample_file": "", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":3}, {"type": "BINARY", "len": 16, "count":2}, {"type": "BINARY", "len": 32, "count":2}, + {"type": "TIMESTAMP"}, {"type": "BIGINT", "count":3},{"type": "FLOAT", "count":1},{"type": "SMALLINT", "count":1},{"type": "TINYINT", "count":1}, + {"type": "BOOL"},{"type": "NCHAR","len":16}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5},{"type": "NCHAR","len":16, "count":1}] + }] + }] +} + diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoInsertNanoDB.json b/tests/pytest/tools/taosdemoAllTest/taosdemoInsertNanoDB.json new file mode 100644 index 0000000000000000000000000000000000000000..9a35df917dcbb2600852e8172da0be3ffacb0d15 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/taosdemoInsertNanoDB.json @@ -0,0 +1,63 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 10, + "thread_count_create_tbl": 10, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 100, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "testdb1", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ns", + "keep": 36, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "tb0_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 100, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1000, + "start_timestamp": "2021-07-01 00:00:00.000", + "sample_format": "", + "sample_file": "", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":3}, {"type": "BINARY", "len": 16, "count":2}, {"type": "BINARY", "len": 32, "count":2}, + {"type": "TIMESTAMP"}, {"type": "BIGINT", "count":3},{"type": "FLOAT", "count":1},{"type": "SMALLINT", "count":1},{"type": "TINYINT", "count":1}, + {"type": "BOOL"},{"type": "NCHAR","len":16}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5},{"type": "NCHAR","len":16, "count":1}] + }] + }] +} + diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoInsertUSDB.json b/tests/pytest/tools/taosdemoAllTest/taosdemoInsertUSDB.json new file mode 100644 index 0000000000000000000000000000000000000000..631179dbaebfff29de6b38831b78fede989369d4 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/taosdemoInsertUSDB.json @@ -0,0 +1,63 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 10, + "thread_count_create_tbl": 10, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 100, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "testdb2", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "us", + "keep": 36, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "tb0_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 100, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1000, + "start_timestamp": "2021-07-01 00:00:00.000", + "sample_format": "", + "sample_file": "", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":3}, {"type": "BINARY", "len": 16, "count":2}, {"type": "BINARY", "len": 32, "count":2}, + {"type": "TIMESTAMP"}, {"type": "BIGINT", "count":3},{"type": "FLOAT", "count":1},{"type": "SMALLINT", "count":1},{"type": "TINYINT", "count":1}, + {"type": "BOOL"},{"type": "NCHAR","len":16}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5},{"type": "NCHAR","len":16, "count":1}] + }] + }] +} + diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertTime_step.py b/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertTime_step.py new file mode 100644 index 0000000000000000000000000000000000000000..7b3b865df91f87622737eede640ec79e880e433b --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertTime_step.py @@ -0,0 +1,115 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def run(self): + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + + # insert: create one or mutiple tables per sql and insert multiple rows per sql + + # check the params of taosdemo about time_step is nano + os.system("%staosdemo -f tools/taosdemoAllTest/taosdemoInsertNanoDB.json -y " % binPath) + tdSql.execute("use testdb1") + tdSql.query("show stables") + tdSql.checkData(0, 4, 100) + tdSql.query("select count (tbname) from stb0") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from tb0_0") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 10000) + tdSql.query("describe stb0") + tdSql.getData(9, 1) + tdSql.checkDataType(9, 1,"TIMESTAMP") + tdSql.query("select last(ts) from stb0") + tdSql.checkData(0, 0,"2021-07-01 00:00:00.000099000") + + # check the params of taosdemo about time_step is us + os.system("%staosdemo -f tools/taosdemoAllTest/taosdemoInsertUSDB.json -y " % binPath) + tdSql.execute("use testdb2") + tdSql.query("show stables") + tdSql.checkData(0, 4, 100) + tdSql.query("select count (tbname) from stb0") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from tb0_0") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 10000) + tdSql.query("describe stb0") + tdSql.getData(9, 1) + tdSql.checkDataType(9, 1,"TIMESTAMP") + tdSql.query("select last(ts) from stb0") + tdSql.checkData(0, 0,"2021-07-01 00:00:00.099000") + + # check the params of taosdemo about time_step is ms + os.system("%staosdemo -f tools/taosdemoAllTest/taosdemoInsertMSDB.json -y " % binPath) + tdSql.execute("use testdb3") + tdSql.query("show stables") + tdSql.checkData(0, 4, 100) + tdSql.query("select count (tbname) from stb0") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from tb0_0") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 10000) + tdSql.query("describe stb0") + tdSql.checkDataType(9, 1,"TIMESTAMP") + tdSql.query("select last(ts) from stb0") + tdSql.checkData(0, 0,"2021-07-01 00:01:39.000") + + + os.system("rm -rf ./res.txt") + os.system("rm -rf ./*.py.sql") + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertWithJson.py b/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertWithJson.py new file mode 100644 index 0000000000000000000000000000000000000000..a0b669d5f12e9ba8e2052f82c2d6d8ac349bd017 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertWithJson.py @@ -0,0 +1,335 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def run(self): + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + + # insert: create one or mutiple tables per sql and insert multiple rows per sql + os.system("%staosdemo -f tools/taosdemoAllTest/insert-1s1tnt1r.json -y " % binPath) + tdSql.execute("use db") + tdSql.query("select count (tbname) from stb0") + tdSql.checkData(0, 0, 1000) + tdSql.query("select count (tbname) from stb1") + tdSql.checkData(0, 0, 1000) + tdSql.query("select count(*) from stb00_0") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 100000) + tdSql.query("select count(*) from stb01_1") + tdSql.checkData(0, 0, 200) + tdSql.query("select count(*) from stb1") + tdSql.checkData(0, 0, 200000) + + # restful connector insert data + os.system("%staosdemo -f tools/taosdemoAllTest/insertRestful.json -y " % binPath) + tdSql.execute("use db") + tdSql.query("select count (tbname) from stb0") + tdSql.checkData(0, 0, 10) + tdSql.query("select count (tbname) from stb1") + tdSql.checkData(0, 0, 10) + tdSql.query("select count(*) from stb00_0") + tdSql.checkData(0, 0, 10) + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from stb01_1") + tdSql.checkData(0, 0, 20) + tdSql.query("select count(*) from stb1") + tdSql.checkData(0, 0, 200) + + + # insert: create mutiple tables per sql and insert one rows per sql . + os.system("%staosdemo -f tools/taosdemoAllTest/insert-1s1tntmr.json -y " % binPath) + tdSql.execute("use db") + tdSql.query("select count (tbname) from stb0") + tdSql.checkData(0, 0, 10) + tdSql.query("select count (tbname) from stb1") + tdSql.checkData(0, 0, 20) + tdSql.query("select count(*) from stb00_0") + tdSql.checkData(0, 0, 10000) + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 100000) + tdSql.query("select count(*) from stb01_0") + tdSql.checkData(0, 0, 20000) + tdSql.query("select count(*) from stb1") + tdSql.checkData(0, 0, 400000) + + # insert: using parament "insert_interval to controls spped of insert. + # but We need to have accurate methods to control the speed, such as getting the speed value, checking the count and so on。 + os.system("%staosdemo -f tools/taosdemoAllTest/insert-interval-speed.json -y" % binPath) + tdSql.execute("use db") + tdSql.query("show stables") + tdSql.checkData(0, 4, 100) + tdSql.query("select count(*) from stb00_0") + tdSql.checkData(0, 0, 20000) + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 2000000) + tdSql.query("show stables") + tdSql.checkData(1, 4, 100) + tdSql.query("select count(*) from stb01_0") + tdSql.checkData(0, 0, 20000) + tdSql.query("select count(*) from stb1") + tdSql.checkData(0, 0, 2000000) + + # spend 2min30s for 3 testcases. + # insert: drop and child_table_exists combination test + # insert: using parament "childtable_offset and childtable_limit" to control table'offset point and offset + os.system("%staosdemo -f tools/taosdemoAllTest/insert-nodbnodrop.json -y" % binPath) + tdSql.error("show dbno.stables") + os.system("%staosdemo -f tools/taosdemoAllTest/insert-newdb.json -y" % binPath) + tdSql.execute("use db") + tdSql.query("select count (tbname) from stb0") + tdSql.checkData(0, 0, 5) + tdSql.query("select count (tbname) from stb1") + tdSql.checkData(0, 0, 6) + tdSql.query("select count (tbname) from stb2") + tdSql.checkData(0, 0, 7) + tdSql.query("select count (tbname) from stb3") + tdSql.checkData(0, 0, 8) + tdSql.query("select count (tbname) from stb4") + tdSql.checkData(0, 0, 8) + os.system("%staosdemo -f tools/taosdemoAllTest/insert-offset.json -y" % binPath) + tdSql.execute("use db") + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 50) + tdSql.query("select count(*) from stb1") + tdSql.checkData(0, 0, 240) + tdSql.query("select count(*) from stb2") + tdSql.checkData(0, 0, 220) + tdSql.query("select count(*) from stb3") + tdSql.checkData(0, 0, 180) + tdSql.query("select count(*) from stb4") + tdSql.checkData(0, 0, 160) + os.system("%staosdemo -f tools/taosdemoAllTest/insert-newtable.json -y" % binPath) + tdSql.execute("use db") + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 150) + tdSql.query("select count(*) from stb1") + tdSql.checkData(0, 0, 360) + tdSql.query("select count(*) from stb2") + tdSql.checkData(0, 0, 360) + tdSql.query("select count(*) from stb3") + tdSql.checkData(0, 0, 340) + tdSql.query("select count(*) from stb4") + tdSql.checkData(0, 0, 400) + os.system("%staosdemo -f tools/taosdemoAllTest/insert-renewdb.json -y" % binPath) + tdSql.execute("use db") + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 50) + tdSql.query("select count(*) from stb1") + tdSql.checkData(0, 0, 120) + tdSql.query("select count(*) from stb2") + tdSql.checkData(0, 0, 140) + tdSql.query("select count(*) from stb3") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from stb4") + tdSql.checkData(0, 0, 160) + + + # insert: let parament in json file is illegal, it'll expect error. + tdSql.execute("drop database if exists db") + os.system("%staosdemo -f tools/taosdemoAllTest/insertColumnsAndTagNumLarge4096.json -y " % binPath) + tdSql.error("use db") + tdSql.execute("drop database if exists db") + os.system("%staosdemo -f tools/taosdemoAllTest/insertSigcolumnsNum4096.json -y " % binPath) + tdSql.error("select * from db.stb0") + tdSql.execute("drop database if exists db") + os.system("%staosdemo -f tools/taosdemoAllTest/insertColumnsAndTagNum4096.json -y " % binPath) + tdSql.query("select count(*) from db.stb0") + tdSql.checkData(0, 0, 10000) + + tdSql.execute("drop database if exists db") + os.system("%staosdemo -f tools/taosdemoAllTest/insertInterlaceRowsLarge1M.json -y " % binPath) + tdSql.query("select count(*) from db.stb0") + tdSql.checkRows(0) + tdSql.execute("drop database if exists db") + os.system("%staosdemo -f tools/taosdemoAllTest/insertColumnsNum0.json -y " % binPath) + tdSql.execute("use db") + tdSql.query("show stables like 'stb0%' ") + tdSql.checkData(0, 2, 11) + tdSql.execute("drop database if exists db") + os.system("%staosdemo -f tools/taosdemoAllTest/insertTagsNumLarge128.json -y " % binPath) + tdSql.error("use db1") + tdSql.execute("drop database if exists db") + os.system("%staosdemo -f tools/taosdemoAllTest/insertBinaryLenLarge16374AllcolLar49151.json -y " % binPath) + tdSql.query("select count(*) from db.stb0") + tdSql.checkRows(1) + tdSql.query("select count(*) from db.stb1") + tdSql.checkRows(1) + tdSql.error("select * from db.stb4") + tdSql.error("select * from db.stb2") + tdSql.query("select count(*) from db.stb3") + tdSql.checkRows(1) + tdSql.execute("drop database if exists db") + os.system("%staosdemo -f tools/taosdemoAllTest/insertNumOfrecordPerReq0.json -y " % binPath) + tdSql.error("select count(*) from db.stb0") + tdSql.execute("drop database if exists db") + os.system("%staosdemo -f tools/taosdemoAllTest/insertNumOfrecordPerReqless0.json -y " % binPath) + tdSql.error("use db") + tdSql.execute("drop database if exists db") + os.system("%staosdemo -f tools/taosdemoAllTest/insertChildTab0.json -y " % binPath) + tdSql.error("use db") + tdSql.execute("drop database if exists db") + os.system("%staosdemo -f tools/taosdemoAllTest/insertChildTabLess0.json -y " % binPath) + tdSql.error("use db") + tdSql.execute("drop database if exists blf") + os.system("%staosdemo -f tools/taosdemoAllTest/insertTimestepMulRowsLargeint16.json -y " % binPath) + tdSql.execute("use blf") + tdSql.query("select ts from blf.p_0_topics_7 limit 262800,1") + tdSql.checkData(0, 0, "2020-03-31 12:00:00.000") + tdSql.query("select first(ts) from blf.p_0_topics_2") + tdSql.checkData(0, 0, "2019-10-01 00:00:00") + tdSql.query("select last(ts) from blf.p_0_topics_6 ") + tdSql.checkData(0, 0, "2020-09-29 23:59:00") + os.system("%staosdemo -f tools/taosdemoAllTest/insertMaxNumPerReq.json -y " % binPath) + tdSql.execute("use db") + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 5000000) + tdSql.query("select count(*) from stb1") + tdSql.checkData(0, 0, 5000000) + + + + # insert: timestamp and step + os.system("%staosdemo -f tools/taosdemoAllTest/insert-timestep.json -y " % binPath) + tdSql.execute("use db") + tdSql.query("show stables") + tdSql.query("select count (tbname) from stb0") + tdSql.checkData(0, 0, 10) + tdSql.query("select count (tbname) from stb1") + tdSql.checkData(0, 0, 20) + tdSql.query("select last(ts) from db.stb00_0") + tdSql.checkData(0, 0, "2020-10-01 00:00:00.019000") + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 200) + tdSql.query("select last(ts) from db.stb01_0") + tdSql.checkData(0, 0, "2020-11-01 00:00:00.190000") + tdSql.query("select count(*) from stb1") + tdSql.checkData(0, 0, 400) + + # # insert: disorder_ratio + os.system("%staosdemo -f tools/taosdemoAllTest/insert-disorder.json -g 2>&1 -y " % binPath) + tdSql.execute("use db") + tdSql.query("select count (tbname) from stb0") + tdSql.checkData(0, 0, 1) + tdSql.query("select count (tbname) from stb1") + tdSql.checkData(0, 0, 1) + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 10) + tdSql.query("select count(*) from stb1") + tdSql.checkData(0, 0, 10) + + # insert: sample json + os.system("%staosdemo -f tools/taosdemoAllTest/insert-sample.json -y " % binPath) + tdSql.execute("use dbtest123") + tdSql.query("select c2 from stb0") + tdSql.checkData(0, 0, 2147483647) + tdSql.query("select * from stb1 where t1=-127") + tdSql.checkRows(20) + tdSql.query("select * from stb1 where t2=127") + tdSql.checkRows(10) + tdSql.query("select * from stb1 where t2=126") + tdSql.checkRows(10) + + # insert: test interlace parament + os.system("%staosdemo -f tools/taosdemoAllTest/insert-interlace-row.json -y " % binPath) + tdSql.execute("use db") + tdSql.query("select count (tbname) from stb0") + tdSql.checkData(0, 0, 100) + tdSql.query("select count (*) from stb0") + tdSql.checkData(0, 0, 15000) + + + # # insert: auto_create + + tdSql.execute('drop database if exists db') + tdSql.execute('create database db') + tdSql.execute('use db') + os.system("%staosdemo -y -f tools/taosdemoAllTest/insert-drop-exist-auto-N00.json " % binPath) # drop = no, child_table_exists, auto_create_table varies + tdSql.execute('use db') + tdSql.query('show tables like \'NN123%\'') #child_table_exists = no, auto_create_table varies = 123 + tdSql.checkRows(20) + tdSql.query('show tables like \'NNN%\'') #child_table_exists = no, auto_create_table varies = no + tdSql.checkRows(20) + tdSql.query('show tables like \'NNY%\'') #child_table_exists = no, auto_create_table varies = yes + tdSql.checkRows(20) + tdSql.query('show tables like \'NYN%\'') #child_table_exists = yes, auto_create_table varies = no + tdSql.checkRows(0) + tdSql.query('show tables like \'NY123%\'') #child_table_exists = yes, auto_create_table varies = 123 + tdSql.checkRows(0) + tdSql.query('show tables like \'NYY%\'') #child_table_exists = yes, auto_create_table varies = yes + tdSql.checkRows(0) + + tdSql.execute('drop database if exists db') + os.system("%staosdemo -y -f tools/taosdemoAllTest/insert-drop-exist-auto-Y00.json " % binPath) # drop = yes, child_table_exists, auto_create_table varies + tdSql.execute('use db') + tdSql.query('show tables like \'YN123%\'') #child_table_exists = no, auto_create_table varies = 123 + tdSql.checkRows(20) + tdSql.query('show tables like \'YNN%\'') #child_table_exists = no, auto_create_table varies = no + tdSql.checkRows(20) + tdSql.query('show tables like \'YNY%\'') #child_table_exists = no, auto_create_table varies = yes + tdSql.checkRows(20) + tdSql.query('show tables like \'YYN%\'') #child_table_exists = yes, auto_create_table varies = no + tdSql.checkRows(20) + tdSql.query('show tables like \'YY123%\'') #child_table_exists = yes, auto_create_table varies = 123 + tdSql.checkRows(20) + tdSql.query('show tables like \'YYY%\'') #child_table_exists = yes, auto_create_table varies = yes + tdSql.checkRows(20) + + testcaseFilename = os.path.split(__file__)[-1] + os.system("rm -rf ./insert_res.txt") + os.system("rm -rf tools/taosdemoAllTest/%s.sql" % testcaseFilename ) + + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertWithJsonStmt.py b/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertWithJsonStmt.py new file mode 100644 index 0000000000000000000000000000000000000000..0aade4318390b43d8781cdac3deff3f1d7623b10 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertWithJsonStmt.py @@ -0,0 +1,316 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def run(self): + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + + # insert: create one or mutiple tables per sql and insert multiple rows per sql + os.system("%staosdemo -f tools/taosdemoAllTest/stmt/insert-1s1tnt1r-stmt.json -y " % binPath) + tdSql.execute("use db") + tdSql.query("select count (tbname) from stb0") + tdSql.checkData(0, 0, 1000) + tdSql.query("select count (tbname) from stb1") + tdSql.checkData(0, 0, 1000) + tdSql.query("select count(*) from stb00_0") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 100000) + tdSql.query("select count(*) from stb01_1") + tdSql.checkData(0, 0, 200) + tdSql.query("select count(*) from stb1") + tdSql.checkData(0, 0, 200000) + + + # insert: create mutiple tables per sql and insert one rows per sql . + os.system("%staosdemo -f tools/taosdemoAllTest/stmt/insert-1s1tntmr-stmt.json -y " % binPath) + tdSql.execute("use db") + tdSql.query("select count (tbname) from stb0") + tdSql.checkData(0, 0, 10) + tdSql.query("select count (tbname) from stb1") + tdSql.checkData(0, 0, 20) + tdSql.query("select count(*) from stb00_0") + tdSql.checkData(0, 0, 10000) + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 100000) + tdSql.query("select count(*) from stb01_0") + tdSql.checkData(0, 0, 20000) + tdSql.query("select count(*) from stb1") + tdSql.checkData(0, 0, 400000) + + # insert: using parament "insert_interval to controls spped of insert. + # but We need to have accurate methods to control the speed, such as getting the speed value, checking the count and so on。 + os.system("%staosdemo -f tools/taosdemoAllTest/stmt/insert-interval-speed-stmt.json -y" % binPath) + tdSql.execute("use db") + tdSql.query("show stables") + tdSql.checkData(0, 4, 100) + tdSql.query("select count(*) from stb00_0") + tdSql.checkData(0, 0, 20000) + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 2000000) + tdSql.query("show stables") + tdSql.checkData(1, 4, 100) + tdSql.query("select count(*) from stb01_0") + tdSql.checkData(0, 0, 20000) + tdSql.query("select count(*) from stb1") + tdSql.checkData(0, 0, 2000000) + + # spend 2min30s for 3 testcases. + # insert: drop and child_table_exists combination test + # insert: using parament "childtable_offset and childtable_limit" to control table'offset point and offset + os.system("%staosdemo -f tools/taosdemoAllTest/stmt/insert-nodbnodrop-stmt.json -y" % binPath) + tdSql.error("show dbno.stables") + os.system("%staosdemo -f tools/taosdemoAllTest/stmt/insert-newdb-stmt.json -y" % binPath) + tdSql.execute("use db") + tdSql.query("select count (tbname) from stb0") + tdSql.checkData(0, 0, 5) + tdSql.query("select count (tbname) from stb1") + tdSql.checkData(0, 0, 6) + tdSql.query("select count (tbname) from stb2") + tdSql.checkData(0, 0, 7) + tdSql.query("select count (tbname) from stb3") + tdSql.checkData(0, 0, 8) + tdSql.query("select count (tbname) from stb4") + tdSql.checkData(0, 0, 8) + os.system("%staosdemo -f tools/taosdemoAllTest/stmt/insert-offset-stmt.json -y" % binPath) + tdSql.execute("use db") + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 50) + tdSql.query("select count(*) from stb1") + tdSql.checkData(0, 0, 240) + tdSql.query("select count(*) from stb2") + tdSql.checkData(0, 0, 220) + tdSql.query("select count(*) from stb3") + tdSql.checkData(0, 0, 180) + tdSql.query("select count(*) from stb4") + tdSql.checkData(0, 0, 160) + os.system("%staosdemo -f tools/taosdemoAllTest/stmt/insert-newtable-stmt.json -y" % binPath) + tdSql.execute("use db") + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 150) + tdSql.query("select count(*) from stb1") + tdSql.checkData(0, 0, 360) + tdSql.query("select count(*) from stb2") + tdSql.checkData(0, 0, 360) + tdSql.query("select count(*) from stb3") + tdSql.checkData(0, 0, 340) + tdSql.query("select count(*) from stb4") + tdSql.checkData(0, 0, 400) + os.system("%staosdemo -f tools/taosdemoAllTest/stmt/insert-renewdb-stmt.json -y" % binPath) + tdSql.execute("use db") + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 50) + tdSql.query("select count(*) from stb1") + tdSql.checkData(0, 0, 120) + tdSql.query("select count(*) from stb2") + tdSql.checkData(0, 0, 140) + tdSql.query("select count(*) from stb3") + tdSql.checkData(0, 0, 160) + tdSql.query("select count(*) from stb4") + tdSql.checkData(0, 0, 160) + + + # insert: let parament in json file is illegal, it'll expect error. + tdSql.execute("drop database if exists db") + os.system("%staosdemo -f tools/taosdemoAllTest/stmt/insertColumnsAndTagNumLarge4096-stmt.json -y " % binPath) + tdSql.error("use db") + tdSql.execute("drop database if exists db") + os.system("%staosdemo -f tools/taosdemoAllTest/stmt/insertSigcolumnsNum4096-stmt.json -y " % binPath) + tdSql.error("select * from db.stb0") + # tdSql.execute("drop database if exists db") + # os.system("%staosdemo -f tools/taosdemoAllTest/stmt/insertColumnsAndTagNum4096-stmt.json -y " % binPath) + # tdSql.query("select count(*) from db.stb0") + # tdSql.checkData(0, 0, 10000) + tdSql.execute("drop database if exists db") + os.system("%staosdemo -f tools/taosdemoAllTest/stmt/insertInterlaceRowsLarge1M-stmt.json -y " % binPath) + tdSql.query("select count(*) from db.stb0") + tdSql.checkRows(0) + tdSql.execute("drop database if exists db") + os.system("%staosdemo -f tools/taosdemoAllTest/stmt/insertColumnsNum0-stmt.json -y " % binPath) + tdSql.execute("use db") + tdSql.query("show stables like 'stb0%' ") + tdSql.checkData(0, 2, 11) + tdSql.execute("drop database if exists db") + os.system("%staosdemo -f tools/taosdemoAllTest/stmt/insertTagsNumLarge128-stmt.json -y " % binPath) + tdSql.error("use db1") + tdSql.execute("drop database if exists db") + os.system("%staosdemo -f tools/taosdemoAllTest/stmt/insertBinaryLenLarge16374AllcolLar49151-stmt.json -y " % binPath) + tdSql.query("select count(*) from db.stb0") + tdSql.checkRows(1) + tdSql.query("select count(*) from db.stb1") + tdSql.checkRows(1) + tdSql.error("select * from db.stb4") + tdSql.error("select * from db.stb2") + tdSql.query("select count(*) from db.stb3") + tdSql.checkRows(1) + tdSql.execute("drop database if exists db") + os.system("%staosdemo -f tools/taosdemoAllTest/stmt/insertNumOfrecordPerReq0-stmt.json -y " % binPath) + tdSql.error("select count(*) from db.stb0") + tdSql.execute("drop database if exists db") + os.system("%staosdemo -f tools/taosdemoAllTest/stmt/insertNumOfrecordPerReqless0-stmt.json -y " % binPath) + tdSql.error("use db") + tdSql.execute("drop database if exists db") + os.system("%staosdemo -f tools/taosdemoAllTest/stmt/insertChildTab0-stmt.json -y " % binPath) + tdSql.error("use db") + tdSql.execute("drop database if exists db") + os.system("%staosdemo -f tools/taosdemoAllTest/stmt/insertChildTabLess0-stmt.json -y " % binPath) + tdSql.error("use db") + tdSql.execute("drop database if exists blf") + os.system("%staosdemo -f tools/taosdemoAllTest/stmt/insertTimestepMulRowsLargeint16-stmt.json -y " % binPath) + tdSql.execute("use blf") + tdSql.query("select ts from blf.p_0_topics_7 limit 262800,1") + tdSql.checkData(0, 0, "2020-03-31 12:00:00.000") + tdSql.query("select first(ts) from blf.p_0_topics_2") + tdSql.checkData(0, 0, "2019-10-01 00:00:00") + tdSql.query("select last(ts) from blf.p_0_topics_6 ") + tdSql.checkData(0, 0, "2020-09-29 23:59:00") + os.system("%staosdemo -f tools/taosdemoAllTest/stmt/insertMaxNumPerReq-stmt.json -y " % binPath) + tdSql.execute("use db") + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 5000000) + tdSql.query("select count(*) from stb1") + tdSql.checkData(0, 0, 5000000) + + + # insert: timestamp and step + os.system("%staosdemo -f tools/taosdemoAllTest/stmt/insert-timestep-stmt.json -y " % binPath) + tdSql.execute("use db") + tdSql.query("show stables") + tdSql.query("select count (tbname) from stb0") + tdSql.checkData(0, 0, 10) + tdSql.query("select count (tbname) from stb1") + tdSql.checkData(0, 0, 20) + tdSql.query("select last(ts) from db.stb00_0") + tdSql.checkData(0, 0, "2020-10-01 00:00:00.019000") + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 200) + tdSql.query("select last(ts) from db.stb01_0") + tdSql.checkData(0, 0, "2020-11-01 00:00:00.190000") + tdSql.query("select count(*) from stb1") + tdSql.checkData(0, 0, 400) + + # # insert: disorder_ratio + os.system("%staosdemo -f tools/taosdemoAllTest/stmt/insert-disorder-stmt.json 2>&1 -y " % binPath) + tdSql.execute("use db") + tdSql.query("select count (tbname) from stb0") + tdSql.checkData(0, 0, 1) + tdSql.query("select count (tbname) from stb1") + tdSql.checkData(0, 0, 1) + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 10) + tdSql.query("select count(*) from stb1") + tdSql.checkData(0, 0, 10) + + # insert: sample json + os.system("%staosdemo -f tools/taosdemoAllTest/stmt/insert-sample-stmt.json -y " % binPath) + tdSql.execute("use dbtest123") + tdSql.query("select c2 from stb0") + tdSql.checkData(0, 0, 2147483647) + tdSql.query("select * from stb1 where t1=-127") + tdSql.checkRows(20) + tdSql.query("select * from stb1 where t2=127") + tdSql.checkRows(10) + tdSql.query("select * from stb1 where t2=126") + tdSql.checkRows(10) + + # insert: test interlace parament + os.system("%staosdemo -f tools/taosdemoAllTest/stmt/insert-interlace-row-stmt.json -y " % binPath) + tdSql.execute("use db") + tdSql.query("select count (tbname) from stb0") + tdSql.checkData(0, 0, 100) + tdSql.query("select count (*) from stb0") + tdSql.checkData(0, 0, 15000) + + + # insert: auto_create + + tdSql.execute('drop database if exists db') + tdSql.execute('create database db') + tdSql.execute('use db') + os.system("%staosdemo -y -f tools/taosdemoAllTest/stmt/insert-drop-exist-auto-N00-stmt.json " % binPath) # drop = no, child_table_exists, auto_create_table varies + tdSql.execute('use db') + tdSql.query('show tables like \'NN123%\'') #child_table_exists = no, auto_create_table varies = 123 + tdSql.checkRows(20) + tdSql.query('show tables like \'NNN%\'') #child_table_exists = no, auto_create_table varies = no + tdSql.checkRows(20) + tdSql.query('show tables like \'NNY%\'') #child_table_exists = no, auto_create_table varies = yes + tdSql.checkRows(20) + tdSql.query('show tables like \'NYN%\'') #child_table_exists = yes, auto_create_table varies = no + tdSql.checkRows(0) + tdSql.query('show tables like \'NY123%\'') #child_table_exists = yes, auto_create_table varies = 123 + tdSql.checkRows(0) + tdSql.query('show tables like \'NYY%\'') #child_table_exists = yes, auto_create_table varies = yes + tdSql.checkRows(0) + + tdSql.execute('drop database if exists db') + os.system("%staosdemo -y -f tools/taosdemoAllTest/stmt/insert-drop-exist-auto-Y00-stmt.json " % binPath) # drop = yes, child_table_exists, auto_create_table varies + tdSql.execute('use db') + tdSql.query('show tables like \'YN123%\'') #child_table_exists = no, auto_create_table varies = 123 + tdSql.checkRows(20) + tdSql.query('show tables like \'YNN%\'') #child_table_exists = no, auto_create_table varies = no + tdSql.checkRows(20) + tdSql.query('show tables like \'YNY%\'') #child_table_exists = no, auto_create_table varies = yes + tdSql.checkRows(20) + tdSql.query('show tables like \'YYN%\'') #child_table_exists = yes, auto_create_table varies = no + tdSql.checkRows(20) + tdSql.query('show tables like \'YY123%\'') #child_table_exists = yes, auto_create_table varies = 123 + tdSql.checkRows(20) + tdSql.query('show tables like \'YYY%\'') #child_table_exists = yes, auto_create_table varies = yes + tdSql.checkRows(20) + + testcaseFilename = os.path.split(__file__)[-1] + os.system("rm -rf ./insert_res.txt") + os.system("rm -rf tools/taosdemoAllTest/%s.sql" % testcaseFilename ) + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabase.json b/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabase.json new file mode 100644 index 0000000000000000000000000000000000000000..246f1c35f29973fc20602284b37ae68de23f70c1 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabase.json @@ -0,0 +1,88 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 10, + "thread_count_create_tbl": 10, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 100, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "nsdb", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ns", + "keep": 36, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "tb0_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 100, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10000000, + "start_timestamp": "2021-07-01 00:00:00.000", + "sample_format": "", + "sample_file": "", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":3}, {"type": "BINARY", "len": 16, "count":2}, {"type": "BINARY", "len": 32, "count":2}, + {"type": "TIMESTAMP"}, {"type": "BIGINT", "count":3},{"type": "FLOAT", "count":1},{"type": "SMALLINT", "count":1},{"type": "TINYINT", "count":1}, + {"type": "BOOL"},{"type": "NCHAR","len":16}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5},{"type": "NCHAR","len":16, "count":1}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "tb1_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 100, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 10, + "disorder_range": 1000, + "timestamp_step": 10000000, + "start_timestamp": "2021-07-01 00:00:00.000", + "sample_format": "", + "sample_file": "", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":3}, {"type": "BINARY", "len": 16, "count":2}, {"type": "BINARY", "len": 32, "count":2}, + {"type": "TIMESTAMP"}, {"type": "BIGINT", "count":3},{"type": "FLOAT", "count":1},{"type": "SMALLINT", "count":1},{"type": "TINYINT", "count":1}, + {"type": "BOOL"},{"type": "NCHAR","len":16}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5},{"type": "NCHAR","len":16, "count":1}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabaseInsertForSub.json b/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabaseInsertForSub.json new file mode 100644 index 0000000000000000000000000000000000000000..0726f3905de2b254b49be51a7973d34b5eb6757e --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabaseInsertForSub.json @@ -0,0 +1,84 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 10, + "thread_count_create_tbl": 10, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 100, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "subnsdb", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ns", + "keep": 36, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 10, + "childtable_prefix": "tb0_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "samples", + "insert_mode": "taosc", + "insert_rows": 10, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10000000, + "start_timestamp": "2021-07-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./tools/taosdemoAllTest/nano_samples.csv", + "tags_file": "./tools/taosdemoAllTest/nano_sampletags.csv", + "columns": [{"type": "DOUBLE"}, {"type": "BINARY", "len": 64, "count":1}, {"type": "TIMESTAMP", "count":1}], + "tags": [{"type": "BINARY", "len": 16, "count":1},{"type": "INT"},{"type": "DOUBLE"}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 10, + "childtable_prefix": "tb1_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "samples", + "insert_mode": "taosc", + "insert_rows": 10, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 10, + "disorder_range": 1000, + "timestamp_step": 10000000, + "start_timestamp": "2021-07-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./tools/taosdemoAllTest/nano_samples.csv", + "tags_file": "./tools/taosdemoAllTest/nano_sampletags.csv", + "columns": [{"type": "DOUBLE"}, {"type": "BINARY", "len": 64, "count":1}, {"type": "TIMESTAMP", "count":1}], + "tags": [{"type": "BINARY", "len": 16, "count":1},{"type": "INT"},{"type": "DOUBLE"}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabaseNow.json b/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabaseNow.json new file mode 100644 index 0000000000000000000000000000000000000000..f36b1f9b4c1b83707b9482428d4303a5418ad2c3 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabaseNow.json @@ -0,0 +1,62 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 10, + "thread_count_create_tbl": 10, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 100, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "nsdb2", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ns", + "keep": 36, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "tb0_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 100, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10, + "start_timestamp": "now", + "sample_format": "", + "sample_file": "", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":3}, {"type": "BINARY", "len": 16, "count":2}, {"type": "BINARY", "len": 32, "count":2}, + {"type": "TIMESTAMP"}, {"type": "BIGINT", "count":3},{"type": "FLOAT", "count":1},{"type": "SMALLINT", "count":1},{"type": "TINYINT", "count":1}, + {"type": "BOOL"},{"type": "NCHAR","len":16}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5},{"type": "NCHAR","len":16, "count":1}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabasecsv.json b/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabasecsv.json new file mode 100644 index 0000000000000000000000000000000000000000..867619ed8c1497e76077f96d257dd09a489d9eb7 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabasecsv.json @@ -0,0 +1,84 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 10, + "thread_count_create_tbl": 10, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 100, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "nsdbcsv", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ns", + "keep": 36, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "tb0_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "samples", + "insert_mode": "taosc", + "insert_rows": 100, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 10000000, + "start_timestamp": "2021-07-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./tools/taosdemoAllTest/nano_samples.csv", + "tags_file": "./tools/taosdemoAllTest/nano_sampletags.csv", + "columns": [{"type": "DOUBLE"}, {"type": "BINARY", "len": 64, "count":1}, {"type": "TIMESTAMP", "count":1}], + "tags": [{"type": "BINARY", "len": 16, "count":1},{"type": "INT"},{"type": "DOUBLE"}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "tb1_", + "auto_create_table": "no", + "batch_create_tbl_num": 20, + "data_source": "samples", + "insert_mode": "taosc", + "insert_rows": 100, + "childtable_offset":0, + "multi_thread_write_one_tbl": "no", + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 10, + "disorder_range": 1000, + "timestamp_step": 10000000, + "start_timestamp": "2021-07-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./tools/taosdemoAllTest/nano_samples.csv", + "tags_file": "./tools/taosdemoAllTest/nano_sampletags.csv", + "columns": [{"type": "DOUBLE"}, {"type": "BINARY", "len": 64, "count":1}, {"type": "TIMESTAMP", "count":1}], + "tags": [{"type": "BINARY", "len": 16, "count":1},{"type": "INT"},{"type": "DOUBLE"}] + }] + }] +} diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestQueryWithJson.py b/tests/pytest/tools/taosdemoAllTest/taosdemoTestQueryWithJson.py new file mode 100644 index 0000000000000000000000000000000000000000..fa25629bb3633a1c5280e20662ee2c13c7ee76e0 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/taosdemoTestQueryWithJson.py @@ -0,0 +1,240 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import time +from datetime import datetime +import ast +import re +# from assertpy import assert_that +import subprocess + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + # 获取taosc接口查询的结果文件中的内容,返回每行数据,并断言数据的第一列内容。 + def assertfileDataTaosc(self, filename, expectResult): + self.filename = filename + self.expectResult = expectResult + with open("%s" % filename, 'r+') as f1: + for line in f1.readlines(): + queryResult = line.strip().split()[0] + self.assertCheck(filename, queryResult, expectResult) + + # 获取restful接口查询的结果文件中的关键内容,目前的关键内容找到第一个key就跳出循,所以就只有一个数据。后续再修改多个结果文件。 + def getfileDataRestful(self, filename): + self.filename = filename + with open("%s" % filename, 'r+') as f1: + for line in f1.readlines(): + contents = line.strip() + if contents.find("data") != -1: + pattern = re.compile("{.*}") + contents = pattern.search(contents).group() + contentsDict = ast.literal_eval(contents) # 字符串转换为字典 + queryResult = contentsDict['data'][0][0] + break + return queryResult + + # 获取taosc接口查询次数 + def queryTimesTaosc(self, filename): + self.filename = filename + command = 'cat %s |wc -l' % filename + times = int(subprocess.getstatusoutput(command)[1]) + return times + + # 获取restful接口查询次数 + def queryTimesRestful(self, filename): + self.filename = filename + command = 'cat %s |grep "200 OK" |wc -l' % filename + times = int(subprocess.getstatusoutput(command)[1]) + return times + + # 定义断言结果是否正确。不正确返回错误结果,正确即通过。 + def assertCheck(self, filename, queryResult, expectResult): + self.filename = filename + self.queryResult = queryResult + self.expectResult = expectResult + args0 = (filename, queryResult, expectResult) + assert queryResult == expectResult, "Queryfile:%s ,result is %s != expect: %s" % args0 + + def run(self): + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath + "/build/bin/" + + # delete useless files + os.system("rm -rf ./query_res*") + os.system("rm -rf ./all_query*") + + # taosc query: query specified table and query super table + os.system( + "%staosdemo -f tools/taosdemoAllTest/queryInsertdata.json" % + binPath) + os.system( + "%staosdemo -f tools/taosdemoAllTest/queryTaosc.json" % + binPath) + os.system("cat query_res0.txt* > all_query_res0_taosc.txt") + os.system("cat query_res1.txt* > all_query_res1_taosc.txt") + os.system("cat query_res2.txt* > all_query_res2_taosc.txt") + + # correct Times testcases + queryTimes0Taosc = self.queryTimesTaosc("all_query_res0_taosc.txt") + self.assertCheck("all_query_res0_taosc.txt", queryTimes0Taosc, 6) + + queryTimes1Taosc = self.queryTimesTaosc("all_query_res1_taosc.txt") + self.assertCheck("all_query_res1_taosc.txt", queryTimes1Taosc, 6) + + queryTimes2Taosc = self.queryTimesTaosc("all_query_res2_taosc.txt") + self.assertCheck("all_query_res2_taosc.txt", queryTimes2Taosc, 20) + + # correct data testcase + self.assertfileDataTaosc("all_query_res0_taosc.txt", "1604160000099") + self.assertfileDataTaosc("all_query_res1_taosc.txt", "100") + self.assertfileDataTaosc("all_query_res2_taosc.txt", "1604160000199") + + # delete useless files + os.system("rm -rf ./query_res*") + os.system("rm -rf ./all_query*") + + # use restful api to query + os.system( + "%staosdemo -f tools/taosdemoAllTest/queryInsertrestdata.json" % + binPath) + os.system( + "%staosdemo -f tools/taosdemoAllTest/queryRestful.json" % + binPath) + os.system("cat query_res0.txt* > all_query_res0_rest.txt") + os.system("cat query_res1.txt* > all_query_res1_rest.txt") + os.system("cat query_res2.txt* > all_query_res2_rest.txt") + + # correct Times testcases + queryTimes0Restful = self.queryTimesRestful("all_query_res0_rest.txt") + self.assertCheck("all_query_res0_rest.txt", queryTimes0Restful, 6) + + queryTimes1Restful = self.queryTimesRestful("all_query_res1_rest.txt") + self.assertCheck("all_query_res1_rest.txt", queryTimes1Restful, 6) + + queryTimes2Restful = self.queryTimesRestful("all_query_res2_rest.txt") + self.assertCheck("all_query_res2_rest.txt", queryTimes2Restful, 4) + + # correct data testcase + data0 = self.getfileDataRestful("all_query_res0_rest.txt") + self.assertCheck( + 'all_query_res0_rest.txt', + data0, + "2020-11-01 00:00:00.009") + + data1 = self.getfileDataRestful("all_query_res1_rest.txt") + self.assertCheck('all_query_res1_rest.txt', data1, 10) + + data2 = self.getfileDataRestful("all_query_res2_rest.txt") + self.assertCheck( + 'all_query_res2_rest.txt', + data2, + "2020-11-01 00:00:00.004") + + # query times less than or equal to 100 + os.system( + "%staosdemo -f tools/taosdemoAllTest/queryInsertdata.json" % + binPath) + os.system( + "%staosdemo -f tools/taosdemoAllTest/querySpeciMutisql100.json" % + binPath) + os.system( + "%staosdemo -f tools/taosdemoAllTest/querySuperMutisql100.json" % + binPath) + + # query result print QPS + os.system( + "%staosdemo -f tools/taosdemoAllTest/queryInsertdata.json" % + binPath) + os.system( + "%staosdemo -f tools/taosdemoAllTest/queryQps.json" % + binPath) + + # use illegal or out of range parameters query json file + os.system( + "%staosdemo -f tools/taosdemoAllTest/queryInsertdata.json" % + binPath) + exceptcode = os.system( + "%staosdemo -f tools/taosdemoAllTest/queryTimes0.json" % + binPath) + assert exceptcode != 0 + + exceptcode0 = os.system( + "%staosdemo -f tools/taosdemoAllTest/queryTimesless0.json" % + binPath) + assert exceptcode0 != 0 + + exceptcode1 = os.system( + "%staosdemo -f tools/taosdemoAllTest/queryConcurrentless0.json" % + binPath) + assert exceptcode1 != 0 + + exceptcode2 = os.system( + "%staosdemo -f tools/taosdemoAllTest/queryConcurrent0.json" % + binPath) + assert exceptcode2 != 0 + + exceptcode3 = os.system( + "%staosdemo -f tools/taosdemoAllTest/querrThreadsless0.json" % + binPath) + assert exceptcode3 != 0 + + exceptcode4 = os.system( + "%staosdemo -f tools/taosdemoAllTest/querrThreads0.json" % + binPath) + assert exceptcode4 != 0 + + # delete useless files + os.system("rm -rf ./insert_res.txt") + os.system("rm -rf tools/taosdemoAllTest/*.py.sql") + os.system("rm -rf ./querySystemInfo*") + os.system("rm -rf ./query_res*") + os.system("rm -rf ./all_query*") + os.system("rm -rf ./test_query_res0.txt") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestSubWithJson.py b/tests/pytest/tools/taosdemoAllTest/taosdemoTestSubWithJson.py new file mode 100644 index 0000000000000000000000000000000000000000..3e967581a4491da4108b981ccd83949751406b82 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/taosdemoTestSubWithJson.py @@ -0,0 +1,204 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import time +from datetime import datetime +import subprocess + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + # get the number of subscriptions + def subTimes(self,filename): + self.filename = filename + command = 'cat %s |wc -l'% filename + times = int(subprocess.getstatusoutput(command)[1]) + return times + + # assert results + def assertCheck(self,filename,subResult,expectResult): + self.filename = filename + self.subResult = subResult + self.expectResult = expectResult + args0 = (filename, subResult, expectResult) + assert subResult == expectResult , "Queryfile:%s ,result is %s != expect: %s" % args0 + + def run(self): + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + + # clear env + os.system("ps -ef |grep 'taosdemoAllTest/subSync.json' |grep -v 'grep' |awk '{print $2}'|xargs kill -9") + os.system("ps -ef |grep 'taosdemoAllTest/subSyncKeepStart.json' |grep -v 'grep' |awk '{print $2}'|xargs kill -9") + sleep(1) + os.system("rm -rf ./subscribe_res*") + os.system("rm -rf ./all_subscribe_res*") + sleep(2) + # subscribe: sync + os.system("%staosdemo -f tools/taosdemoAllTest/subInsertdata.json" % binPath) + os.system("nohup %staosdemo -f tools/taosdemoAllTest/subSync.json &" % binPath) + query_pid = int(subprocess.getstatusoutput('ps aux|grep "taosdemoAllTest/subSync.json" |grep -v "grep"|awk \'{print $2}\'')[1]) + + # insert extral data + tdSql.execute("use db") + tdSql.execute("insert into stb00_0 values(1614218412000,'R','bf3',8637,98.861045)") + tdSql.execute("insert into stb00_1 values(1614218412000,'R','bf3',8637,78.861045)(1614218422000,'R','bf3',8637,98.861045)") + sleep(5) + + # merge result files + os.system("cat subscribe_res0.txt* > all_subscribe_res0.txt") + os.system("cat subscribe_res1.txt* > all_subscribe_res1.txt") + os.system("cat subscribe_res2.txt* > all_subscribe_res2.txt") + os.system("cat subscribe_res3.txt* > all_subscribe_res3.txt") + + + # correct subscribeTimes testcase + subTimes0 = self.subTimes("all_subscribe_res0.txt") + self.assertCheck("all_subscribe_res0.txt",subTimes0 ,22) + + subTimes1 = self.subTimes("all_subscribe_res1.txt") + self.assertCheck("all_subscribe_res1.txt",subTimes1 ,24) + + subTimes2 = self.subTimes("all_subscribe_res2.txt") + self.assertCheck("all_subscribe_res2.txt",subTimes2 ,21) + + subTimes3 = self.subTimes("all_subscribe_res3.txt") + self.assertCheck("all_subscribe_res3.txt",subTimes3 ,13) + + + # correct data testcase + os.system("kill -9 %d" % query_pid) + sleep(3) + os.system("rm -rf ./subscribe_res*") + os.system("rm -rf ./all_subscribe*") + + # # sql number lager 100 + os.system("%staosdemo -f tools/taosdemoAllTest/subInsertdataMaxsql100.json" % binPath) + assert os.system("%staosdemo -f tools/taosdemoAllTest/subSyncSpecMaxsql100.json" % binPath) != 0 + assert os.system("%staosdemo -f tools/taosdemoAllTest/subSyncSuperMaxsql100.json" % binPath) != 0 + + # # result files is null + # os.system("%staosdemo -f tools/taosdemoAllTest/subInsertdataMaxsql100.json" % binPath) + # os.system("%staosdemo -f tools/taosdemoAllTest/subSyncResFileNull.json" % binPath) + # # assert os.system("%staosdemo -f tools/taosdemoAllTest/subSyncResFileNull.json" % binPath) != 0 + + + + + # resubAfterConsume= -1 endAfter=-1 ; + os.system('kill -9 `ps aux|grep "subSyncResubACMinus1.json" |grep -v "grep"|awk \'{print $2}\'` ') + os.system("nohup %staosdemo -f tools/taosdemoAllTest/Resubjson/subSyncResubACMinus1.json & " % binPath) + sleep(2) + query_pid1 = int(subprocess.getstatusoutput('ps aux|grep "subSyncResubACMinus1.json" |grep -v "grep"|awk \'{print $2}\'')[1]) + print("get sub1 process'pid") + subres0Number1 =int(subprocess.getstatusoutput('grep "1614218412000" subscribe_res0* |wc -l' )[1]) + subres2Number1 =int(subprocess.getstatusoutput('grep "1614218412000" subscribe_res2* |wc -l' )[1]) + assert 0==subres0Number1 , "subres0Number1 error" + assert 0==subres2Number1 , "subres2Number1 error" + tdSql.execute("insert into db.stb00_0 values(1614218412000,'R','bf3',8637,78.861045)(1614218413000,'R','bf3',8637,98.861045)") + sleep(4) + subres2Number2 =int(subprocess.getstatusoutput('grep "1614218412000" subscribe_res0* |wc -l' )[1]) + subres0Number2 =int(subprocess.getstatusoutput('grep "1614218412000" subscribe_res0* |wc -l' )[1]) + assert 0!=subres2Number2 , "subres2Number2 error" + assert 0!=subres0Number2 , "subres0Number2 error" + os.system("kill -9 %d" % query_pid1) + os.system("rm -rf ./subscribe_res*") + + # # resubAfterConsume= -1 endAfter=0 ; + # os.system("%staosdemo -f tools/taosdemoAllTest/subInsertdataMaxsql100.json" % binPath) + # os.system('kill -9 `ps aux|grep "subSyncResubACMinus1endAfter0.json" |grep -v "grep"|awk \'{print $2}\'` ') + # os.system("nohup %staosdemo -f tools/taosdemoAllTest/Resubjson/subSyncResubACMinus1endAfter0.json & " % binPath) + # sleep(2) + # query_pid1 = int(subprocess.getstatusoutput('ps aux|grep "subSyncResubACMinus1endAfter0.json" |grep -v "grep"|awk \'{print $2}\'')[1]) + # print("get sub2 process'pid") + # subres0Number1 =int(subprocess.getstatusoutput('grep "1614218412000" subscribe_res0* |wc -l' )[1]) + # subres2Number1 =int(subprocess.getstatusoutput('grep "1614218412000" subscribe_res2* |wc -l' )[1]) + # assert 0==subres0Number1 , "subres0Number1 error" + # assert 0==subres2Number1 , "subres2Number1 error" + # tdSql.execute("insert into db.stb00_0 values(1614218412000,'R','bf3',8637,78.861045)(1614218413000,'R','bf3',8637,98.861045)") + # sleep(4) + # subres2Number2 =int(subprocess.getstatusoutput('grep "1614218412000" subscribe_res0* |wc -l' )[1]) + # subres0Number2 =int(subprocess.getstatusoutput('grep "1614218412000" subscribe_res0* |wc -l' )[1]) + # assert 0!=subres2Number2 , "subres2Number2 error" + # assert 0!=subres0Number2 , "subres0Number2 error" + # os.system("kill -9 %d" % query_pid1) + # os.system("rm -rf ./subscribe_res*") + + + + + # # # merge result files + # os.system("cat subscribe_res0.txt* > all_subscribe_res0.txt") + # os.system("cat subscribe_res1.txt* > all_subscribe_res1.txt") + # os.system("cat subscribe_res2.txt* > all_subscribe_res2.txt") + # # os.system("cat subscribe_res3.txt* > all_subscribe_res3.txt") + + # sleep(3) + + # # correct subscribeTimes testcase + # subTimes0 = self.subTimes("all_subscribe_res0.txt") + # self.assertCheck("all_subscribe_res0.txt",subTimes0 ,3960) + + # subTimes1 = self.subTimes("all_subscribe_res1.txt") + # self.assertCheck("all_subscribe_res1.txt",subTimes1 ,40) + + # subTimes2 = self.subTimes("all_subscribe_res2.txt") + # self.assertCheck("all_subscribe_res2.txt",subTimes2 ,1900) + + + # os.system("%staosdemo -f tools/taosdemoAllTest/subSupermaxsql100.json" % binPath) + # os.system("%staosdemo -f tools/taosdemoAllTest/subSupermaxsql100.json" % binPath) + + + + # delete useless files + os.system("rm -rf ./insert_res.txt") + os.system("rm -rf tools/taosdemoAllTest/*.py.sql") + os.system("rm -rf ./subscribe_res*") + os.system("rm -rf ./all_subscribe*") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestSubWithJsonAsync.py b/tests/pytest/tools/taosdemoAllTest/taosdemoTestSubWithJsonAsync.py new file mode 100644 index 0000000000000000000000000000000000000000..f2aa01e8703d9703d647507736130de2dd582bfb --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/taosdemoTestSubWithJsonAsync.py @@ -0,0 +1,124 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import time +from datetime import datetime +import subprocess + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + # 获取订阅次数 + def subTimes(self,filename): + self.filename = filename + command = 'cat %s |wc -l'% filename + times = int(subprocess.getstatusoutput(command)[1]) + return times + + def assertCheck(self,filename,queryResult,expectResult): + self.filename = filename + self.queryResult = queryResult + self.expectResult = expectResult + args0 = (filename, queryResult, expectResult) + assert queryResult == expectResult , "Queryfile:%s ,result is %s != expect: %s" % args0 + + def run(self): + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + + # clear env + os.system("ps -ef |grep 'taosdemoAllTest/subAsync.json' |grep -v 'grep' |awk '{print $2}'|xargs kill -9") + sleep(1) + os.system("rm -rf ./subscribe_res*") + os.system("rm -rf ./all_subscribe_res*") + + # subscribe: resultfile + os.system("%staosdemo -f tools/taosdemoAllTest/subInsertdata.json" % binPath) + os.system("nohup %staosdemo -f tools/taosdemoAllTest/subAsync.json &" % binPath) + query_pid = int(subprocess.getstatusoutput('ps aux|grep "taosdemoAllTest/subAsync.json" |grep -v "grep"|awk \'{print $2}\'')[1]) + + # insert extral data + tdSql.execute("use db") + tdSql.execute("insert into stb00_0 values(1614218412000,'R','bf3',8637,98.861045)") + tdSql.execute("insert into stb00_1 values(1614218412000,'R','bf3',8637,78.861045)(1614218422000,'R','bf3',8637,98.861045)") + sleep(5) + + # merge result files + os.system("cat subscribe_res0.txt* > all_subscribe_res0.txt") + os.system("cat subscribe_res1.txt* > all_subscribe_res1.txt") + os.system("cat subscribe_res2.txt* > all_subscribe_res2.txt") + os.system("cat subscribe_res3.txt* > all_subscribe_res3.txt") + + # correct subscribeTimes testcase + subTimes0 = self.subTimes("all_subscribe_res0.txt") + self.assertCheck("all_subscribe_res0.txt",subTimes0 ,22) + + subTimes1 = self.subTimes("all_subscribe_res1.txt") + self.assertCheck("all_subscribe_res1.txt",subTimes1 ,24) + + subTimes2 = self.subTimes("all_subscribe_res2.txt") + self.assertCheck("all_subscribe_res2.txt",subTimes2 ,21) + + subTimes3 = self.subTimes("all_subscribe_res3.txt") + self.assertCheck("all_subscribe_res3.txt",subTimes3 ,13) + + # correct data testcase + + os.system("kill -9 %d" % query_pid) + + # # query times less than or equal to 100 + os.system("%staosdemo -f tools/taosdemoAllTest/subInsertdataMaxsql100.json" % binPath) + assert os.system("%staosdemo -f tools/taosdemoAllTest/subSyncSpecMaxsql100.json" % binPath) != 0 + assert os.system("%staosdemo -f tools/taosdemoAllTest/subSyncSuperMaxsql100.json" % binPath) != 0 + + # delete useless files + os.system("rm -rf ./insert_res.txt") + os.system("rm -rf tools/taosdemoAllTest/*.py.sql") + os.system("rm -rf ./subscribe_res*") + os.system("rm -rf ./all_subscribe*") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestSupportNanoInsert.py b/tests/pytest/tools/taosdemoAllTest/taosdemoTestSupportNanoInsert.py new file mode 100644 index 0000000000000000000000000000000000000000..c3fdff00ec15fc1ca0d55f86d430c5cbf86ad168 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/taosdemoTestSupportNanoInsert.py @@ -0,0 +1,156 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def run(self): + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + + + # insert: create one or mutiple tables per sql and insert multiple rows per sql + # insert data from a special timestamp + # check stable stb0 + + os.system("%staosdemo -f tools/taosdemoAllTest/taosdemoTestNanoDatabase.json -y " % binPath) + tdSql.execute("use nsdb") + tdSql.query("show stables") + tdSql.checkData(0, 4, 100) + tdSql.query("select count (tbname) from stb0") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from tb0_0") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 10000) + tdSql.query("describe stb0") + tdSql.checkDataType(9, 1,"TIMESTAMP") + tdSql.query("select last(ts) from stb0") + tdSql.checkData(0, 0,"2021-07-01 00:00:00.990000000") + + # check stable stb1 which is insert with disord + + tdSql.query("select count (tbname) from stb1") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from tb1_0") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from stb1") + tdSql.checkData(0, 0, 10000) + # check c8 is an nano timestamp + tdSql.query("describe stb1") + tdSql.checkDataType(9, 1,"TIMESTAMP") + # check insert timestamp_step is nano_second + tdSql.query("select last(ts) from stb1") + tdSql.checkData(0, 0,"2021-07-01 00:00:00.990000000") + + # insert data from now time + + # check stable stb0 + os.system("%staosdemo -f tools/taosdemoAllTest/taosdemoTestNanoDatabaseNow.json -y " % binPath) + + tdSql.execute("use nsdb2") + tdSql.query("show stables") + tdSql.checkData(0, 4, 100) + tdSql.query("select count (tbname) from stb0") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from tb0_0") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 10000) + # check c8 is an nano timestamp + tdSql.query("describe stb0") + tdSql.checkDataType(9,1,"TIMESTAMP") + + # insert by csv files and timetamp is long int , strings in ts and cols + + os.system("%staosdemo -f tools/taosdemoAllTest/taosdemoTestNanoDatabasecsv.json -y " % binPath) + tdSql.execute("use nsdbcsv") + tdSql.query("show stables") + tdSql.checkData(0, 4, 100) + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 10000) + tdSql.query("describe stb0") + tdSql.checkDataType(3, 1, "TIMESTAMP") + tdSql.query("select count(*) from stb0 where ts > \"2021-07-01 00:00:00.490000000\"") + tdSql.checkData(0, 0, 5000) + tdSql.query("select count(*) from stb0 where ts < 1626918583000000000") + tdSql.checkData(0, 0, 10000) + + os.system("rm -rf ./insert_res.txt") + os.system("rm -rf tools/taosdemoAllTest/taosdemoTestSupportNano*.py.sql") + + # taosdemo test insert with command and parameter , detals show taosdemo --help + os.system("%staosdemo -u root -ptaosdata -P 6030 -a 1 -m pre -n 10 -T 20 -t 60 -o res.txt -y " % binPath) + tdSql.query("select count(*) from test.meters") + tdSql.checkData(0, 0, 600) + # check taosdemo -s + + sqls_ls = ['drop database if exists nsdbsql;','create database nsdbsql precision "ns" keep 36 days 6 update 1;', + 'use nsdbsql;','CREATE STABLE meters (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupdId int);', + 'CREATE TABLE d1001 USING meters TAGS ("Beijing.Chaoyang", 2);', + 'INSERT INTO d1001 USING METERS TAGS ("Beijng.Chaoyang", 2) VALUES (now, 10.2, 219, 0.32);', + 'INSERT INTO d1001 USING METERS TAGS ("Beijng.Chaoyang", 2) VALUES (now, 85, 32, 0.76);'] + + with open("./taosdemoTestNanoCreateDB.sql",mode ="a" ) as sql_files: + for sql in sqls_ls: + sql_files.write(sql+"\n") + sql_files.close() + + sleep(10) + + os.system("%staosdemo -s taosdemoTestNanoCreateDB.sql -y " % binPath) + tdSql.query("select count(*) from nsdbsql.meters") + tdSql.checkData(0, 0, 2) + + os.system("rm -rf ./res.txt") + os.system("rm -rf ./*.py.sql") + os.system("rm -rf ./taosdemoTestNanoCreateDB.sql") + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestSupportNanoQuery.json b/tests/pytest/tools/taosdemoAllTest/taosdemoTestSupportNanoQuery.json new file mode 100644 index 0000000000000000000000000000000000000000..fff1017588bb10f55a82aa2bd7bc6997df71abfd --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/taosdemoTestSupportNanoQuery.json @@ -0,0 +1,92 @@ +{ + "filetype": "query", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "confirm_parameter_prompt": "no", + "databases": "nsdb", + "query_times": 10, + "query_mode": "taosc", + "specified_table_query": { + "query_interval": 1, + "concurrent": 2, + "sqls": [ + { + "sql": "select count(*) from stb0 where ts>\"2021-07-01 00:01:00.000000000 \" ;", + "result": "./query_res0.txt" + }, + { + "sql": "select count(*) from stb0 where ts>\"2021-07-01 00:01:00.000000000\" and ts <=\"2021-07-01 00:01:10.000000000\" ;", + "result": "./query_res1.txt" + }, + { + "sql": "select count(*) from stb0 where ts>now-20d ;", + "result": "./query_res2.txt" + }, + { + "sql": "select max(c10) from stb0;", + "result": "./query_res3.txt" + }, + { + "sql": "select min(c1) from stb0;", + "result": "./query_res4.txt" + }, + { + "sql": "select avg(c1) from stb0;", + "result": "./query_res5.txt" + }, + { + "sql":"select count(*) from stb0 group by tbname;", + "result":"./query_res6.txt" + } + + ] + }, + "super_table_query": { + "stblname": "stb0", + "query_interval": 0, + "threads": 4, + "sqls": [ + { + "sql": "select count(*) from xxxx where ts>\"2021-07-01 00:01:00.000000000 \" ;", + "result": "./query_res_tb0.txt" + }, + { + "sql":"select count(*) from xxxx where ts>\"2021-07-01 00:01:00.000000000\" and ts <=\"2021-07-01 00:01:10.000000000\" ;", + "result": "./query_res_tb1.txt" + }, + { + "sql":"select first(*) from xxxx ;", + "result": "./query_res_tb2.txt" + }, + { + "sql":"select last(*) from xxxx;", + "result": "./query_res_tb3.txt" + + }, + { + "sql":"select last_row(*) from xxxx ;", + "result": "./query_res_tb4.txt" + + }, + { + "sql":"select max(c10) from xxxx ;", + "result": "./query_res_tb5.txt" + + }, + { + "sql":"select min(c1) from xxxx ;", + "result": "./query_res_tb6.txt" + + }, + { + "sql":"select avg(c10) from xxxx ;", + "result": "./query_res_tb7.txt" + + } + + ] + } + } \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestSupportNanoQuery.py b/tests/pytest/tools/taosdemoAllTest/taosdemoTestSupportNanoQuery.py new file mode 100644 index 0000000000000000000000000000000000000000..5a37cf9c7cf3153a7bcabb0bc9258063e5f05f09 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/taosdemoTestSupportNanoQuery.py @@ -0,0 +1,157 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def run(self): + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + + # query: query test for nanoSecond with where and max min groupby order + os.system("%staosdemo -f tools/taosdemoAllTest/taosdemoTestNanoDatabase.json -y " % binPath) + + tdSql.execute("use nsdb") + + # use where to filter + + tdSql.query("select count(*) from stb0 where ts>\"2021-07-01 00:00:00.590000000 \" ") + tdSql.checkData(0, 0, 4000) + tdSql.query("select count(*) from stb0 where ts>\"2021-07-01 00:00:00.000000000\" and ts <=\"2021-07-01 00:00:00.590000000\" ") + tdSql.checkData(0, 0, 5900) + + tdSql.query("select count(*) from tb0_0 where ts>\"2021-07-01 00:00:00.590000000 \" ;") + tdSql.checkData(0, 0, 40) + tdSql.query("select count(*) from tb0_0 where ts>\"2021-07-01 00:00:00.000000000\" and ts <=\"2021-07-01 00:00:00.590000000\" ") + tdSql.checkData(0, 0, 59) + + + # select max min avg from special col + tdSql.query("select max(c10) from stb0;") + print("select max(c10) from stb0 : " , tdSql.getData(0, 0)) + + tdSql.query("select max(c10) from tb0_0;") + print("select max(c10) from tb0_0 : " , tdSql.getData(0, 0)) + + + tdSql.query("select min(c1) from stb0;") + print( "select min(c1) from stb0 : " , tdSql.getData(0, 0)) + + tdSql.query("select min(c1) from tb0_0;") + print( "select min(c1) from tb0_0 : " , tdSql.getData(0, 0)) + + tdSql.query("select avg(c1) from stb0;") + print( "select avg(c1) from stb0 : " , tdSql.getData(0, 0)) + + tdSql.query("select avg(c1) from tb0_0;") + print( "select avg(c1) from tb0_0 : " , tdSql.getData(0, 0)) + + tdSql.query("select count(*) from stb0 group by tbname;") + tdSql.checkData(0, 0, 100) + tdSql.checkData(10, 0, 100) + + # query : query above sqls by taosdemo and continuously + + os.system("%staosdemo -f tools/taosdemoAllTest/taosdemoTestSupportNanoQuery.json -y " % binPath) + + + os.system("%staosdemo -f tools/taosdemoAllTest/taosdemoTestNanoDatabasecsv.json -y " % binPath) + tdSql.execute("use nsdbcsv") + tdSql.query("show stables") + tdSql.checkData(0, 4, 100) + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 10000) + tdSql.query("describe stb0") + tdSql.checkDataType(3, 1, "TIMESTAMP") + tdSql.query("select count(*) from stb0 where ts >\"2021-07-01 00:00:00.490000000\"") + tdSql.checkData(0, 0, 5000) + tdSql.query("select count(*) from stb0 where ts 162687012800000000') + tdSql.execute('select count(*) from stb0 where c2 < 162687012800000000') + tdSql.execute('select count(*) from stb0 where c2 = 162687012800000000') + tdSql.execute('select count(*) from stb0 where c2 != 162687012800000000') + tdSql.execute('select count(*) from stb0 where c2 <> 162687012800000000') + tdSql.execute('select count(*) from stb0 where c2 > "2021-07-21 20:22:08.248246976"') + tdSql.execute('select count(*) from stb0 where c2 < "2021-07-21 20:22:08.248246976"') + tdSql.execute('select count(*) from stb0 where c2 = "2021-07-21 20:22:08.248246976"') + tdSql.execute('select count(*) from stb0 where c2 != "2021-07-21 20:22:08.248246976"') + tdSql.execute('select count(*) from stb0 where c2 <> "2021-07-21 20:22:08.248246976"') + tdSql.execute('select count(*) from stb0 where ts between "2021-07-01 00:00:00.000000000" and "2021-07-01 00:00:00.990000000"') + tdSql.execute('select count(*) from stb0 where ts between 1625068800000000000 and 1625068801000000000') + tdSql.query('select avg(c0) from stb0 interval(5000000000b)') + tdSql.checkRows(1) + + tdSql.query('select avg(c0) from stb0 interval(100000000b)') + tdSql.checkRows(10) + + tdSql.error('select avg(c0) from stb0 interval(1b)') + tdSql.error('select avg(c0) from stb0 interval(999b)') + + tdSql.query('select avg(c0) from stb0 interval(1000b)') + tdSql.checkRows(100) + + tdSql.query('select avg(c0) from stb0 interval(1u)') + tdSql.checkRows(100) + + tdSql.query('select avg(c0) from stb0 interval(100000000b) sliding (100000000b)') + tdSql.checkRows(10) + + # query : query above sqls by taosdemo and continuously + os.system("%staosdemo -f tools/taosdemoAllTest/taosdemoTestSupportNanoQuerycsv.json -y " % binPath) + + os.system("rm -rf ./query_res*.txt*") + os.system("rm -rf tools/taosdemoAllTest/*.py.sql") + + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestSupportNanoQuerycsv.json b/tests/pytest/tools/taosdemoAllTest/taosdemoTestSupportNanoQuerycsv.json new file mode 100644 index 0000000000000000000000000000000000000000..a3b3c75efa6680aa0d1da0ca7986d863408ee515 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/taosdemoTestSupportNanoQuerycsv.json @@ -0,0 +1,110 @@ +{ + "filetype": "query", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "confirm_parameter_prompt": "no", + "databases": "nsdbcsv", + "query_times": 10, + "query_mode": "taosc", + "specified_table_query": { + "query_interval": 1, + "concurrent": 2, + "sqls": [ + { + "sql": "select count(*) from stb0 where ts> \"2021-07-01 00:00:00.490000000\" ;", + "result": "./query_res0.txt" + }, + { + "sql": "select count(*) from stb0 where ts < now -22d-1h-3s ;", + "result": "./query_res1.txt" + }, + { + "sql": "select count(*) from stb0 where ts < 1626918583000000000 ;", + "result": "./query_res2.txt" + }, + { + "sql": "select count(*) from stb0 where c2 <> 162687012800000000';", + "result": "./query_res3.txt" + }, + { + "sql": "select count(*) from stb0 where c2 != \"2021-07-21 20:22:08.248246976\";", + "result": "./query_res4.txt" + }, + { + "sql": "select count(*) from stb0 where ts between \"2021-07-01 00:00:00.000000000\" and \"2021-07-01 00:00:00.990000000\";", + "result": "./query_res5.txt" + }, + { + "sql":"select count(*) from stb0 group by tbname;", + "result":"./query_res6.txt" + }, + { + "sql":"select count(*) from stb0 where ts between 1625068800000000000 and 1625068801000000000;", + "result":"./query_res7.txt" + }, + { + "sql":"select avg(c0) from stb0 interval(5000000000b);", + "result":"./query_res8.txt" + }, + { + "sql":"select avg(c0) from stb0 interval(100000000b) sliding (100000000b);", + "result":"./query_res9.txt" + } + + ] + }, + "super_table_query": { + "stblname": "stb0", + "query_interval": 0, + "threads": 4, + "sqls": [ + { + "sql": "select count(*) from xxxx where ts > \"2021-07-01 00:00:00.490000000\" ;", + "result": "./query_res_tb0.txt" + }, + { + "sql":"select count(*) from xxxx where ts between \"2021-07-01 00:00:00.000000000\" and \"2021-07-01 00:00:00.990000000\" ;", + "result": "./query_res_tb1.txt" + }, + { + "sql":"select first(*) from xxxx ;", + "result": "./query_res_tb2.txt" + }, + { + "sql":"select last(*) from xxxx;", + "result": "./query_res_tb3.txt" + + }, + { + "sql":"select last_row(*) from xxxx ;", + "result": "./query_res_tb4.txt" + + }, + { + "sql":"select max(c0) from xxxx ;", + "result": "./query_res_tb5.txt" + + }, + { + "sql":"select min(c0) from xxxx ;", + "result": "./query_res_tb6.txt" + + }, + { + "sql":"select avg(c0) from xxxx ;", + "result": "./query_res_tb7.txt" + + }, + { + "sql":"select avg(c0) from xxxx interval(100000000b) sliding (100000000b) ;", + "result": "./query_res_tb8.txt" + + } + + + ] + } + } \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestSupportNanoSubscribe.json b/tests/pytest/tools/taosdemoAllTest/taosdemoTestSupportNanoSubscribe.json new file mode 100644 index 0000000000000000000000000000000000000000..1cc834164e7c966a9ce565f1ce481d823b1ed2d1 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/taosdemoTestSupportNanoSubscribe.json @@ -0,0 +1,32 @@ +{ + "filetype":"subscribe", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "databases": "subnsdb", + "confirm_parameter_prompt": "no", + "specified_table_query": + { + "concurrent":2, + "mode":"sync", + "interval":10000, + "restart":"yes", + "keepProgress":"yes", + "sqls": [ + { + "sql": "select * from stb0 where ts>= \"2021-07-01 00:00:00.000000000\" ;", + "result": "./subscribe_res0.txt" + }, + { + "sql": "select * from stb0 where ts < now -2d-1h-3s ;", + "result": "./subscribe_res1.txt" + }, + { + "sql": "select * from stb0 where ts < 1626918583000000000 ;", + "result": "./subscribe_res2.txt" + }] + + } +} diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestSupportNanosubscribe.py b/tests/pytest/tools/taosdemoAllTest/taosdemoTestSupportNanosubscribe.py new file mode 100644 index 0000000000000000000000000000000000000000..de38ea9a96b0eb3c2339aff6933a7383bb82e368 --- /dev/null +++ b/tests/pytest/tools/taosdemoAllTest/taosdemoTestSupportNanosubscribe.py @@ -0,0 +1,125 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import time +from datetime import datetime +import subprocess + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + # get the number of subscriptions + def subTimes(self,filename): + self.filename = filename + command = 'cat %s |wc -l'% filename + times = int(subprocess.getstatusoutput(command)[1]) + return times + + # assert results + def assertCheck(self,filename,subResult,expectResult): + self.filename = filename + self.subResult = subResult + self.expectResult = expectResult + args0 = (filename, subResult, expectResult) + assert subResult == expectResult , "Queryfile:%s ,result is %s != expect: %s" % args0 + + def run(self): + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + + # clear env + os.system("ps -ef |grep 'taosdemoAllTest/taosdemoTestSupportNanoSubscribe.json' |grep -v 'grep' |awk '{print $2}'|xargs kill -9") + os.system("rm -rf ./subscribe_res*") + os.system("rm -rf ./all_subscribe_res*") + + + # insert data + os.system("%staosdemo -f tools/taosdemoAllTest/taosdemoTestNanoDatabaseInsertForSub.json" % binPath) + os.system("nohup %staosdemo -f tools/taosdemoAllTest/taosdemoTestSupportNanoSubscribe.json &" % binPath) + query_pid = int(subprocess.getstatusoutput('ps aux|grep "taosdemoAllTest/taosdemoTestSupportNanoSubscribe.json" |grep -v "grep"|awk \'{print $2}\'')[1]) + + + # merge result files + sleep(5) + + os.system("cat subscribe_res0.txt* > all_subscribe_res0.txt") + os.system("cat subscribe_res1.txt* > all_subscribe_res1.txt") + os.system("cat subscribe_res2.txt* > all_subscribe_res2.txt") + + + # correct subscribeTimes testcase + subTimes0 = self.subTimes("all_subscribe_res0.txt") + self.assertCheck("all_subscribe_res0.txt",subTimes0 ,200) + + subTimes1 = self.subTimes("all_subscribe_res1.txt") + self.assertCheck("all_subscribe_res1.txt",subTimes1 ,200) + + subTimes2 = self.subTimes("all_subscribe_res2.txt") + self.assertCheck("all_subscribe_res2.txt",subTimes2 ,200) + + + # insert extral data + tdSql.execute("use subnsdb") + tdSql.execute("insert into tb0_0 values(now,100.1000,'subtest1',now-1s)") + sleep(15) + + os.system("cat subscribe_res0.txt* > all_subscribe_res0.txt") + subTimes0 = self.subTimes("all_subscribe_res0.txt") + self.assertCheck("all_subscribe_res0.txt",subTimes0 ,202) + + + + # correct data testcase + os.system("kill -9 %d" % query_pid) + sleep(3) + os.system("rm -rf ./subscribe_res*") + os.system("rm -rf ./all_subscribe*") + os.system("rm -rf ./*.py.sql") + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoPerformance.py b/tests/pytest/tools/taosdemoPerformance.py new file mode 100644 index 0000000000000000000000000000000000000000..82c57a656dfea12f80fe4eb2b530742c5bfb0916 --- /dev/null +++ b/tests/pytest/tools/taosdemoPerformance.py @@ -0,0 +1,250 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import taos +import pandas as pd +import argparse +import os.path +import json +import sys + +class taosdemoPerformace: + def __init__(self, commitID, dbName, branch, type, numOfTables, numOfRows, numOfInt, numOfDouble, numOfBinary): + self.commitID = commitID + self.dbName = dbName + self.branch = branch + self.type = type + self.numOfTables = numOfTables + self.numOfRows = numOfRows + self.numOfInt = numOfInt + self.numOfDouble = numOfDouble + self.numOfBinary = numOfBinary + self.host = "127.0.0.1" + self.user = "root" + self.password = "taosdata" + self.config = "/etc/perf" + self.conn = taos.connect( + self.host, + self.user, + self.password, + self.config) + self.insertDB = "insertDB" + self.host2 = "192.168.1.179" + self.conn2 = taos.connect( + host = self.host2, + user = self.user, + password = self.password, + config = self.config) + + def generateJson(self): + db = { + "name": "%s" % self.insertDB, + "drop": "yes" + } + + stb = { + "name": "meters", + "childtable_count": self.numOfTables, + "childtable_prefix": "stb_", + "batch_create_tbl_num": 10, + "insert_mode": "rand", + "insert_rows": self.numOfRows, + "batch_rows": 1000000, + "max_sql_len": 1048576, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [ + {"type": "INT", "count": self.numOfInt}, + {"type": "DOUBLE", "count": self.numOfDouble}, + {"type": "BINARY", "len": 128, "count": self.numOfBinary} + ], + "tags": [ + {"type": "INT", "count": 1}, + {"type": "BINARY", "len": 16} + ] + } + + + stables = [] + stables.append(stb) + + db = { + "dbinfo": db, + "super_tables": stables + } + + insert_data = { + "filetype": "insert", + "cfgdir": "/etc/perf", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 10, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "databases": [db] + } + + insert_json_file = f"/tmp/insert.json" + + with open(insert_json_file, 'w') as f: + json.dump(insert_data, f) + return insert_json_file + + def getCMDOutput(self, cmd): + cmd = os.popen(cmd) + output = cmd.read() + cmd.close() + return output + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def insertData(self): + buildPath = self.getBuildPath() + if (buildPath == ""): + print("taosdemo not found!") + sys.exit(1) + + binPath = buildPath + "/build/bin/" + + os.system( + "%sperfMonitor -f %s > /dev/null 2>&1" % + (binPath, self.generateJson())) + self.createTableTime = self.getCMDOutput( + "grep 'Spent' insert_res.txt | awk 'NR==1{print $2}'") + self.insertRecordsTime = self.getCMDOutput( + "grep 'Spent' insert_res.txt | awk 'NR==2{print $2}'") + self.recordsPerSecond = self.getCMDOutput( + "grep 'Spent' insert_res.txt | awk 'NR==2{print $16}'") + self.commitID = self.getCMDOutput("git rev-parse --short HEAD") + delay = self.getCMDOutput( + "grep 'delay' insert_res.txt | awk '{print $4}'") + self.avgDelay = delay[:-4] + delay = self.getCMDOutput( + "grep 'delay' insert_res.txt | awk '{print $6}'") + self.maxDelay = delay[:-4] + delay = self.getCMDOutput( + "grep 'delay' insert_res.txt | awk '{print $8}'") + self.minDelay = delay[:-3] + + os.system("[ -f insert_res.txt ] && rm insert_res.txt") + + def createTablesAndStoreData(self): + cursor = self.conn2.cursor() + + cursor.execute("create database if not exists %s" % self.dbName) + cursor.execute("use %s" % self.dbName) + cursor.execute("create table if not exists taosdemo_perf (ts timestamp, create_table_time float, insert_records_time float, records_per_second float, commit_id binary(50), avg_delay float, max_delay float, min_delay float, branch binary(50), type binary(20), numoftables int, numofrows int, numofint int, numofdouble int, numofbinary int)") + print("create tables time: %f" % float(self.createTableTime)) + print("insert records time: %f" % float(self.insertRecordsTime)) + print("records per second: %f" % float(self.recordsPerSecond)) + print("avg delay: %f" % float(self.avgDelay)) + print("max delay: %f" % float(self.maxDelay)) + print("min delay: %f" % float(self.minDelay)) + cursor.execute("insert into taosdemo_perf values(now, %f, %f, %f, '%s', %f, %f, %f, '%s', '%s', %d, %d, %d, %d, %d)" % + (float(self.createTableTime), float(self.insertRecordsTime), float(self.recordsPerSecond), + self.commitID, float(self.avgDelay), float(self.maxDelay), float(self.minDelay), self.branch, + self.type, self.numOfTables, self.numOfRows, self.numOfInt, self.numOfDouble, self.numOfBinary)) + cursor.close() + + cursor1 = self.conn.cursor() + cursor1.execute("drop database if exists %s" % self.insertDB) + cursor1.close() + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + parser.add_argument( + '-c', + '--commit-id', + action='store', + type=str, + help='git commit id (default: null)') + parser.add_argument( + '-d', + '--database-name', + action='store', + default='perf', + type=str, + help='Database name to be created (default: perf)') + parser.add_argument( + '-b', + '--git-branch', + action='store', + default='master', + type=str, + help='git branch (default: master)') + parser.add_argument( + '-T', + '--build-type', + action='store', + default='glibc', + type=str, + help='build type (default: glibc)') + parser.add_argument( + '-i', + '--num-of-int', + action='store', + default=4, + type=int, + help='num of int columns (default: 4)') + parser.add_argument( + '-D', + '--num-of-double', + action='store', + default=0, + type=int, + help='num of double columns (default: 4)') + parser.add_argument( + '-B', + '--num-of-binary', + action='store', + default=0, + type=int, + help='num of binary columns (default: 4)') + parser.add_argument( + '-t', + '--num-of-tables', + action='store', + default=10000, + type=int, + help='num of tables (default: 10000)') + parser.add_argument( + '-r', + '--num-of-rows', + action='store', + default=100000, + type=int, + help='num of rows (default: 100000)') + args = parser.parse_args() + + perftest = taosdemoPerformace(args.commit_id, args.database_name, args.git_branch, args.build_type, args.num_of_tables, args.num_of_rows, args.num_of_int, args.num_of_double, args.num_of_binary) + perftest.insertData() + perftest.createTablesAndStoreData() diff --git a/tests/pytest/tools/taosdemoTest.py b/tests/pytest/tools/taosdemoTest.py new file mode 100644 index 0000000000000000000000000000000000000000..3cdcdcef5afcb14c04204d2489571bdfed937080 --- /dev/null +++ b/tests/pytest/tools/taosdemoTest.py @@ -0,0 +1,77 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.numberOfTables = 1000 + self.numberOfRecords = 100 + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def run(self): + tdSql.prepare() + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosdemo not found!") + else: + tdLog.info("taosdemo found in %s" % buildPath) + binPath = buildPath + "/build/bin/" + os.system("%staosdemo -y -t %d -n %d -b INT,INT,INT,INT" % + (binPath, self.numberOfTables, self.numberOfRecords)) + + tdSql.execute("use test") + tdSql.query("select count(*) from meters") + tdSql.checkData(0, 0, self.numberOfTables * self.numberOfRecords) + + tdSql.query( + "select sum(c1) from test.meters interval(1h) sliding(30m)") + tdSql.checkRows(2) + + tdSql.query( + "select apercentile(c1, 1) from test.meters interval(100s)") + tdSql.checkRows(1) + + tdSql.error("select loc, count(loc) from test.meters") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoTestInterlace.py b/tests/pytest/tools/taosdemoTestInterlace.py new file mode 100644 index 0000000000000000000000000000000000000000..30c04729b7966660bdb4851ad1b971130d08f726 --- /dev/null +++ b/tests/pytest/tools/taosdemoTestInterlace.py @@ -0,0 +1,75 @@ +################################################################## +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import subprocess + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def run(self): + tdSql.prepare() + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath + "/build/bin/" + taosdemoCmd = "%staosdemo -f tools/insert-interlace.json -PP 2>&1 | grep sleep | wc -l" % binPath + sleepTimes = subprocess.check_output( + taosdemoCmd, shell=True).decode("utf-8") + print("sleep times: %d" % int(sleepTimes)) + + if (int(sleepTimes) != 16): + caller = inspect.getframeinfo(inspect.stack()[0][0]) + tdLog.exit( + "%s(%d) failed: expected sleep times 16, actual %d" % + (caller.filename, caller.lineno, int(sleepTimes))) + + tdSql.execute("use db") + tdSql.query("select count(tbname) from db.stb") + tdSql.checkData(0, 0, 9) + tdSql.query("select count(*) from db.stb") + tdSql.checkData(0, 0, 2250) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoTestLimitOffset.py b/tests/pytest/tools/taosdemoTestLimitOffset.py new file mode 100644 index 0000000000000000000000000000000000000000..dd8a1bee701da0ffd2f764cdbedcf12f9dbedb3c --- /dev/null +++ b/tests/pytest/tools/taosdemoTestLimitOffset.py @@ -0,0 +1,89 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.numberOfTables = 10000 + self.numberOfRecords = 100 + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def run(self): + tdSql.prepare() + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + os.system("%staosdemo -f tools/insert-tblimit-tboffset-createdb.json" % binPath) + os.system("%staosdemo -f tools/insert-tblimit-tboffset-insertrec.json" % binPath) + + tdSql.execute("use db") + tdSql.query("select count(tbname) from db.stb") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from db.stb") + tdSql.checkData(0, 0, 33000) + + os.system("%staosdemo -f tools/insert-tblimit-tboffset-createdb.json" % binPath) + os.system("%staosdemo -f tools/insert-tblimit-tboffset0.json" % binPath) + + tdSql.execute("reset query cache") + tdSql.execute("use db") + tdSql.query("select count(tbname) from db.stb") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from db.stb") + tdSql.checkData(0, 0, 20000) + + os.system("%staosdemo -f tools/insert-tblimit-tboffset-createdb.json" % binPath) + os.system("%staosdemo -f tools/insert-tblimit1-tboffset.json" % binPath) + + tdSql.execute("reset query cache") + tdSql.execute("use db") + tdSql.query("select count(tbname) from db.stb") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from db.stb") + tdSql.checkData(0, 0, 1000) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoTestQuery.py b/tests/pytest/tools/taosdemoTestQuery.py new file mode 100644 index 0000000000000000000000000000000000000000..bb2bb85052a9b21dc9181887622ec2019707256b --- /dev/null +++ b/tests/pytest/tools/taosdemoTestQuery.py @@ -0,0 +1,78 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +import time +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import subprocess + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.numberOfTables = 1000 + self.numberOfRecords = 100 + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def run(self): + tdSql.prepare() + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath + "/build/bin/" + os.system("%staosdemo -y -t %d -n %d" % + (binPath, self.numberOfTables, self.numberOfRecords)) + print("Sleep 2 seconds..") + time.sleep(2) + os.system('%staosdemo -f tools/query.json ' % binPath) +# taosdemoCmd = '%staosdemo -f tools/query.json ' % binPath +# threads = subprocess.check_output( +# taosdemoCmd, shell=True).decode("utf-8") +# print("threads: %d" % int(threads)) + +# if (int(threads) != 8): +# caller = inspect.getframeinfo(inspect.stack()[0][0]) +# tdLog.exit( +# "%s(%d) failed: expected threads 8, actual %d" % +# (caller.filename, caller.lineno, int(threads))) +# + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoTestSampleData.py b/tests/pytest/tools/taosdemoTestSampleData.py new file mode 100644 index 0000000000000000000000000000000000000000..a8710a9df36358199e567de2efeb90e88b675312 --- /dev/null +++ b/tests/pytest/tools/taosdemoTestSampleData.py @@ -0,0 +1,68 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.numberOfTables = 10000 + self.numberOfRecords = 100 + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def run(self): + tdSql.prepare() + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + os.system("%staosdemo -f tools/taosdemo-sampledata.json" % binPath) + + tdSql.execute("use db") + tdSql.query("select count(tbname) from db.stb") + tdSql.checkData(0, 0, 20) + tdSql.query("select count(*) from db.stb") + tdSql.checkData(0, 0, 400) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoTestTblAlt.py b/tests/pytest/tools/taosdemoTestTblAlt.py new file mode 100644 index 0000000000000000000000000000000000000000..89c1b92e140cb1e19b549d3248693153e116c52e --- /dev/null +++ b/tests/pytest/tools/taosdemoTestTblAlt.py @@ -0,0 +1,141 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import threading +import time + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.numberOfTables = 8 + self.numberOfRecords = 1000000 + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def insertDataAndAlterTable(self, threadID): + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath + "/build/bin/" + + if(threadID == 0): + print("%staosdemo -y -t %d -n %d -b INT,INT,INT,INT" % + (binPath, self.numberOfTables, self.numberOfRecords)) + os.system("%staosdemo -y -t %d -n %d -b INT,INT,INT,INT" % + (binPath, self.numberOfTables, self.numberOfRecords)) + if(threadID == 1): + time.sleep(2) + print("use test") + max_try = 100 + count = 0 + while (count < max_try): + try: + tdSql.execute("use test") + break + except Exception as e: + tdLog.info("use database test failed") + time.sleep(2) + count += 1 + print("try %d times" % count) + continue + + # check if all the tables have heen created + count = 0 + while (count < max_try): + try: + tdSql.query("show tables") + except Exception as e: + tdLog.info("show tables test failed") + time.sleep(2) + count += 1 + print("try %d times" % count) + continue + + rows = tdSql.queryRows + print("number of tables: %d" % rows) + if(rows == self.numberOfTables): + break + time.sleep(1) + # check if there are any records in the last created table + count = 0 + while (count < max_try): + print("query started") + print("try %d times" % count) + try: + tdSql.query("select * from test.d7") + except Exception as e: + tdLog.info("select * test failed") + time.sleep(2) + count += 1 + print("try %d times" % count) + continue + + rows = tdSql.queryRows + print("number of records: %d" % rows) + if(rows > 0): + break + time.sleep(1) + + print("alter table test.meters add column c10 int") + tdSql.execute("alter table test.meters add column c10 int") + print("insert into test.d7 values (now, 1, 2, 3, 4, 0)") + tdSql.execute("insert into test.d7 values (now, 1, 2, 3, 4, 0)") + + def run(self): + tdSql.prepare() + + t1 = threading.Thread(target=self.insertDataAndAlterTable, args=(0, )) + t2 = threading.Thread(target=self.insertDataAndAlterTable, args=(1, )) + + t1.start() + t2.start() + t1.join() + t2.join() + + time.sleep(3) + + tdSql.query("select count(*) from test.meters") + tdSql.checkData(0, 0, self.numberOfRecords * self.numberOfTables + 1) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoTestWithJson.py b/tests/pytest/tools/taosdemoTestWithJson.py new file mode 100644 index 0000000000000000000000000000000000000000..b2ecd5497620bf5a0f90dd2e8529890423fd82a1 --- /dev/null +++ b/tests/pytest/tools/taosdemoTestWithJson.py @@ -0,0 +1,63 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if "community" in selfPath: + projPath = selfPath[: selfPath.find("community")] + else: + projPath = selfPath[: selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if "taosd" in files: + rootRealPath = os.path.dirname(os.path.realpath(root)) + if "packaging" not in rootRealPath: + buildPath = root[: len(root) - len("/build/bin")] + break + return buildPath + + def run(self): + tdSql.prepare() + buildPath = self.getBuildPath() + if buildPath == "": + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath + "/build/bin/" + os.system("%staosdemo -f tools/insert.json -y" % binPath) + + tdSql.execute("use db01") + tdSql.query("select count(*) from stb01") + tdSql.checkData(0, 0, 60) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoTestWithoutMetric.py b/tests/pytest/tools/taosdemoTestWithoutMetric.py new file mode 100644 index 0000000000000000000000000000000000000000..01e19355d9dfde5c536ac1e28e1f190f33ab966e --- /dev/null +++ b/tests/pytest/tools/taosdemoTestWithoutMetric.py @@ -0,0 +1,72 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.numberOfTables = 100 + self.numberOfRecords = 1000 + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def run(self): + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath + "/build/bin/" + os.system("%staosdemo -N -y -t %d -n %d" % + (binPath, self.numberOfTables, self.numberOfRecords)) + + tdSql.query("show databases") + for i in range(18): + print(tdSql.getData(0, i) ) + tdSql.checkData(0, 2, self.numberOfTables) + + tdSql.execute("use test") + tdSql.query( + "select count(*) from test.d%d" % (self.numberOfTables -1)) + tdSql.checkData(0, 0, self.numberOfRecords) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdumpTest.py b/tests/pytest/tools/taosdumpTest.py new file mode 100644 index 0000000000000000000000000000000000000000..628617e27b4af8695b96961441c6b135bdb15416 --- /dev/null +++ b/tests/pytest/tools/taosdumpTest.py @@ -0,0 +1,188 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.ts = 1538548685000 + self.numberOfTables = 10000 + self.numberOfRecords = 100 + + def checkCommunity(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + if ("community" in selfPath): + return False + else: + return True + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosdump" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def run(self): + if not os.path.exists("./taosdumptest/tmp1"): + os.makedirs("./taosdumptest/tmp1") + else: + print("directory exists") + + if not os.path.exists("./taosdumptest/tmp2"): + os.makedirs("./taosdumptest/tmp2") + tdSql.execute("drop database if exists db") + tdSql.execute("create database db days 11 keep 3649 blocks 8 ") + tdSql.execute("create database db1 days 12 keep 3640 blocks 7 ") + tdSql.execute("use db") + tdSql.execute( + "create table st(ts timestamp, c1 int, c2 nchar(10)) tags(t1 int, t2 binary(10))") + tdSql.execute("create table t1 using st tags(1, 'beijing')") + sql = "insert into t1 values" + currts = self.ts + for i in range(100): + sql += "(%d, %d, 'nchar%d')" % (currts + i, i % 100, i % 100) + tdSql.execute(sql) + tdSql.execute("create table t2 using st tags(2, 'shanghai')") + sql = "insert into t2 values" + currts = self.ts + for i in range(100): + sql += "(%d, %d, 'nchar%d')" % (currts + i, i % 100, i % 100) + tdSql.execute(sql) + + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosdump not found!") + else: + tdLog.info("taosdump found in %s" % buildPath) + binPath = buildPath + "/build/bin/" + + os.system("%staosdump --databases db -o ./taosdumptest/tmp1" % binPath) + os.system( + "%staosdump --databases db1 -o ./taosdumptest/tmp2" % + binPath) + + tdSql.execute("drop database db") + tdSql.execute("drop database db1") + tdSql.query("show databases") + tdSql.checkRows(0) + + os.system("%staosdump -i ./taosdumptest/tmp1" % binPath) + os.system("%staosdump -i ./taosdumptest/tmp2" % binPath) + + tdSql.execute("use db") + tdSql.query("show databases") + tdSql.checkRows(2) + dbresult = tdSql.queryResult + # 6--days,7--keep0,keep1,keep, 12--block, + + isCommunity = self.checkCommunity() + print("iscommunity: %d" % isCommunity) + for i in range(len(dbresult)): + if dbresult[i][0] == 'db': + print(dbresult[i]) + print(type(dbresult[i][6])) + print(type(dbresult[i][7])) + print(type(dbresult[i][9])) + assert dbresult[i][6] == 11 + if isCommunity: + assert dbresult[i][7] == "3649" + else: + assert dbresult[i][7] == "3649,3649,3649" + assert dbresult[i][9] == 8 + if dbresult[i][0] == 'db1': + assert dbresult[i][6] == 12 + if isCommunity: + assert dbresult[i][7] == "3640" + else: + assert dbresult[i][7] == "3640,3640,3640" + assert dbresult[i][9] == 7 + + tdSql.query("show stables") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 'st') + + tdSql.query("show tables") + tdSql.checkRows(2) + tdSql.checkData(0, 0, 't2') + tdSql.checkData(1, 0, 't1') + + tdSql.query("select * from t1") + tdSql.checkRows(100) + for i in range(100): + tdSql.checkData(i, 1, i) + tdSql.checkData(i, 2, "nchar%d" % i) + + tdSql.query("select * from t2") + tdSql.checkRows(100) + for i in range(100): + tdSql.checkData(i, 1, i) + tdSql.checkData(i, 2, "nchar%d" % i) + + # drop all databases,boundary value testing. + # length(databasename)<=32;length(tablesname)<=192 + tdSql.execute("drop database db") + tdSql.execute("drop database db1") + os.system("rm -rf ./taosdumptest/tmp1") + os.system("rm -rf ./taosdumptest/tmp2") + os.makedirs("./taosdumptest/tmp1") + tdSql.execute("create database db12312313231231321312312312_323") + tdSql.error("create database db12312313231231321312312312_3231") + tdSql.execute("use db12312313231231321312312312_323") + tdSql.execute("create stable st12345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678_9(ts timestamp, c1 int, c2 nchar(10)) tags(t1 int, t2 binary(10))") + tdSql.error("create stable st_12345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678_9(ts timestamp, c1 int, c2 nchar(10)) tags(t1 int, t2 binary(10))") + tdSql.execute( + "create stable st(ts timestamp, c1 int, c2 nchar(10)) tags(t1 int, t2 binary(10))") + tdSql.error("create stable st1(ts timestamp, c1 int, col2_012345678901234567890123456789012345678901234567890123456789 nchar(10)) tags(t1 int, t2 binary(10))") + + tdSql.execute("select * from db12312313231231321312312312_323.st12345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678_9") + tdSql.error("create table t0_12345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678_9 using st tags(1, 'beijing')") + tdSql.query("show stables") + tdSql.checkRows(2) + os.system( + "%staosdump --databases db12312313231231321312312312_323 -o ./taosdumptest/tmp1" % binPath) + tdSql.execute("drop database db12312313231231321312312312_323") + os.system("%staosdump -i ./taosdumptest/tmp1" % binPath) + tdSql.execute("use db12312313231231321312312312_323") + tdSql.query("show stables") + tdSql.checkRows(2) + os.system("rm -rf ./taosdumptest/tmp1") + os.system("rm -rf ./taosdumptest/tmp2") + os.system("rm -rf ./dump_result.txt") + os.system("rm -rf ./db.csv") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdumpTest2.py b/tests/pytest/tools/taosdumpTest2.py new file mode 100644 index 0000000000000000000000000000000000000000..839988375b652b0cfad09d8a6de7697de19609ea --- /dev/null +++ b/tests/pytest/tools/taosdumpTest2.py @@ -0,0 +1,99 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.ts = 1601481600000 + self.numberOfTables = 1 + self.numberOfRecords = 15000 + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def run(self): + tdSql.prepare() + + tdSql.execute("create table st(ts timestamp, c1 timestamp, c2 int, c3 bigint, c4 float, c5 double, c6 binary(8), c7 smallint, c8 tinyint, c9 bool, c10 nchar(8)) tags(t1 int)") + tdSql.execute("create table t1 using st tags(0)") + currts = self.ts + finish = 0 + while(finish < self.numberOfRecords): + sql = "insert into t1 values" + for i in range(finish, self.numberOfRecords): + sql += "(%d, 1019774612, 29931, 1442173978, 165092.468750, 1128.643179, 'MOCq1pTu', 18405, 82, 0, 'g0A6S0Fu')" % (currts + i) + finish = i + 1 + if (1048576 - len(sql)) < 16384: + break + tdSql.execute(sql) + + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosdump not found!") + else: + tdLog.info("taosdump found in %s" % buildPath) + binPath = buildPath + "/build/bin/" + + os.system("rm /tmp/*.sql") + os.system( + "%staosdump --databases db -o /tmp -B 32766 -L 1048576" % + binPath) + + tdSql.execute("drop database db") + tdSql.query("show databases") + tdSql.checkRows(0) + + os.system("%staosdump -i /tmp" % binPath) + + tdSql.query("show databases") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 'db') + + tdSql.execute("use db") + tdSql.query("show stables") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 'st') + + tdSql.query("select count(*) from t1") + tdSql.checkData(0, 0, self.numberOfRecords) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdumpTestNanoSupport.py b/tests/pytest/tools/taosdumpTestNanoSupport.py new file mode 100644 index 0000000000000000000000000000000000000000..727690c6e629217997bd5ecbf085116be4a7e347 --- /dev/null +++ b/tests/pytest/tools/taosdumpTestNanoSupport.py @@ -0,0 +1,365 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.ts = 1625068800000000000 # this is timestamp "2021-07-01 00:00:00" + self.numberOfTables = 10 + self.numberOfRecords = 100 + + def checkCommunity(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + if ("community" in selfPath): + return False + else: + return True + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def createdb(self, precision="ns"): + tb_nums = self.numberOfTables + per_tb_rows = self.numberOfRecords + + def build_db(precision, start_time): + tdSql.execute("drop database if exists timedb1") + tdSql.execute( + "create database timedb1 days 10 keep 365 blocks 8 precision " + + "\"" + + precision + + "\"") + + tdSql.execute("use timedb1") + tdSql.execute( + "create stable st(ts timestamp, c1 int, c2 nchar(10),c3 timestamp) tags(t1 int, t2 binary(10))") + for tb in range(tb_nums): + tbname = "t" + str(tb) + tdSql.execute("create table " + tbname + + " using st tags(1, 'beijing')") + sql = "insert into " + tbname + " values" + currts = start_time + if precision == "ns": + ts_seed = 1000000000 + elif precision == "us": + ts_seed = 1000000 + else: + ts_seed = 1000 + + for i in range(per_tb_rows): + sql += "(%d, %d, 'nchar%d',%d)" % (currts + i * ts_seed, i % + 100, i % 100, currts + i * 100) # currts +1000ms (1000000000ns) + tdSql.execute(sql) + + if precision == "ns": + start_time = 1625068800000000000 + build_db(precision, start_time) + + elif precision == "us": + start_time = 1625068800000000 + build_db(precision, start_time) + + elif precision == "ms": + start_time = 1625068800000 + build_db(precision, start_time) + + else: + print("other time precision not valid , please check! ") + + def run(self): + + # clear envs + os.system("rm -rf ./taosdumptest/") + tdSql.execute("drop database if exists dumptmp1") + tdSql.execute("drop database if exists dumptmp2") + tdSql.execute("drop database if exists dumptmp3") + + if not os.path.exists("./taosdumptest/tmp1"): + os.makedirs("./taosdumptest/dumptmp1") + else: + print("path exist!") + + if not os.path.exists("./taosdumptest/dumptmp2"): + os.makedirs("./taosdumptest/dumptmp2") + + if not os.path.exists("./taosdumptest/dumptmp3"): + os.makedirs("./taosdumptest/dumptmp3") + + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosdump not found!") + else: + tdLog.info("taosdump found in %s" % buildPath) + binPath = buildPath + "/build/bin/" + + # create nano second database + + self.createdb(precision="ns") + + # dump all data + + os.system( + "%staosdump --databases timedb1 -o ./taosdumptest/dumptmp1" % + binPath) + + # dump part data with -S -E + os.system( + '%staosdump --databases timedb1 -S 1625068810000000000 -E 1625068860000000000 -o ./taosdumptest/dumptmp2 ' % + binPath) + os.system( + '%staosdump --databases timedb1 -S 1625068810000000000 -o ./taosdumptest/dumptmp3 ' % + binPath) + + # replace strings to dump in databases + os.system( + "sed -i \"s/timedb1/dumptmp1/g\" `grep timedb1 -rl ./taosdumptest/dumptmp1`") + os.system( + "sed -i \"s/timedb1/dumptmp2/g\" `grep timedb1 -rl ./taosdumptest/dumptmp2`") + os.system( + "sed -i \"s/timedb1/dumptmp3/g\" `grep timedb1 -rl ./taosdumptest/dumptmp3`") + + os.system("%staosdump -i ./taosdumptest/dumptmp1" % binPath) + os.system("%staosdump -i ./taosdumptest/dumptmp2" % binPath) + os.system("%staosdump -i ./taosdumptest/dumptmp3" % binPath) + + # dump data and check for taosdump + tdSql.query("select count(*) from dumptmp1.st") + tdSql.checkData(0, 0, 1000) + + tdSql.query("select count(*) from dumptmp2.st") + tdSql.checkData(0, 0, 510) + + tdSql.query("select count(*) from dumptmp3.st") + tdSql.checkData(0, 0, 900) + + # check data + origin_res = tdSql.getResult("select * from timedb1.st") + dump_res = tdSql.getResult("select * from dumptmp1.st") + if origin_res == dump_res: + tdLog.info("test nano second : dump check data pass for all data!") + else: + tdLog.info( + "test nano second : dump check data failed for all data!") + + origin_res = tdSql.getResult( + "select * from timedb1.st where ts >=1625068810000000000 and ts <= 1625068860000000000") + dump_res = tdSql.getResult("select * from dumptmp2.st") + if origin_res == dump_res: + tdLog.info(" test nano second : dump check data pass for data! ") + else: + tdLog.info(" test nano second : dump check data failed for data !") + + origin_res = tdSql.getResult( + "select * from timedb1.st where ts >=1625068810000000000 ") + dump_res = tdSql.getResult("select * from dumptmp3.st") + if origin_res == dump_res: + tdLog.info(" test nano second : dump check data pass for data! ") + else: + tdLog.info(" test nano second : dump check data failed for data !") + + # us second support test case + + os.system("rm -rf ./taosdumptest/") + tdSql.execute("drop database if exists dumptmp1") + tdSql.execute("drop database if exists dumptmp2") + tdSql.execute("drop database if exists dumptmp3") + + if not os.path.exists("./taosdumptest/tmp1"): + os.makedirs("./taosdumptest/dumptmp1") + else: + print("path exits!") + + if not os.path.exists("./taosdumptest/dumptmp2"): + os.makedirs("./taosdumptest/dumptmp2") + + if not os.path.exists("./taosdumptest/dumptmp3"): + os.makedirs("./taosdumptest/dumptmp3") + + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosdump not found!") + else: + tdLog.info("taosdump found in %s" % buildPath) + binPath = buildPath + "/build/bin/" + + self.createdb(precision="us") + + os.system( + "%staosdump --databases timedb1 -o ./taosdumptest/dumptmp1" % + binPath) + + os.system( + '%staosdump --databases timedb1 -S 1625068810000000 -E 1625068860000000 -o ./taosdumptest/dumptmp2 ' % + binPath) + os.system( + '%staosdump --databases timedb1 -S 1625068810000000 -o ./taosdumptest/dumptmp3 ' % + binPath) + + os.system( + "sed -i \"s/timedb1/dumptmp1/g\" `grep timedb1 -rl ./taosdumptest/dumptmp1`") + os.system( + "sed -i \"s/timedb1/dumptmp2/g\" `grep timedb1 -rl ./taosdumptest/dumptmp2`") + os.system( + "sed -i \"s/timedb1/dumptmp3/g\" `grep timedb1 -rl ./taosdumptest/dumptmp3`") + + os.system("%staosdump -i ./taosdumptest/dumptmp1" % binPath) + os.system("%staosdump -i ./taosdumptest/dumptmp2" % binPath) + os.system("%staosdump -i ./taosdumptest/dumptmp3" % binPath) + + tdSql.query("select count(*) from dumptmp1.st") + tdSql.checkData(0, 0, 1000) + + tdSql.query("select count(*) from dumptmp2.st") + tdSql.checkData(0, 0, 510) + + tdSql.query("select count(*) from dumptmp3.st") + tdSql.checkData(0, 0, 900) + + origin_res = tdSql.getResult("select * from timedb1.st") + dump_res = tdSql.getResult("select * from dumptmp1.st") + if origin_res == dump_res: + tdLog.info("test us second : dump check data pass for all data!") + else: + tdLog.info("test us second : dump check data failed for all data!") + + origin_res = tdSql.getResult( + "select * from timedb1.st where ts >=1625068810000000 and ts <= 1625068860000000") + dump_res = tdSql.getResult("select * from dumptmp2.st") + if origin_res == dump_res: + tdLog.info(" test us second : dump check data pass for data! ") + else: + tdLog.info(" test us second : dump check data failed for data!") + + origin_res = tdSql.getResult( + "select * from timedb1.st where ts >=1625068810000000 ") + dump_res = tdSql.getResult("select * from dumptmp3.st") + if origin_res == dump_res: + tdLog.info(" test us second : dump check data pass for data! ") + else: + tdLog.info(" test us second : dump check data failed for data! ") + + # ms second support test case + + os.system("rm -rf ./taosdumptest/") + tdSql.execute("drop database if exists dumptmp1") + tdSql.execute("drop database if exists dumptmp2") + tdSql.execute("drop database if exists dumptmp3") + + if not os.path.exists("./taosdumptest/tmp1"): + os.makedirs("./taosdumptest/dumptmp1") + else: + print("path exits!") + + if not os.path.exists("./taosdumptest/dumptmp2"): + os.makedirs("./taosdumptest/dumptmp2") + + if not os.path.exists("./taosdumptest/dumptmp3"): + os.makedirs("./taosdumptest/dumptmp3") + + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosdump not found!") + else: + tdLog.info("taosdump found in %s" % buildPath) + binPath = buildPath + "/build/bin/" + + self.createdb(precision="ms") + + os.system( + "%staosdump --databases timedb1 -o ./taosdumptest/dumptmp1" % + binPath) + + os.system( + '%staosdump --databases timedb1 -S 1625068810000 -E 1625068860000 -o ./taosdumptest/dumptmp2 ' % + binPath) + os.system( + '%staosdump --databases timedb1 -S 1625068810000 -o ./taosdumptest/dumptmp3 ' % + binPath) + + os.system( + "sed -i \"s/timedb1/dumptmp1/g\" `grep timedb1 -rl ./taosdumptest/dumptmp1`") + os.system( + "sed -i \"s/timedb1/dumptmp2/g\" `grep timedb1 -rl ./taosdumptest/dumptmp2`") + os.system( + "sed -i \"s/timedb1/dumptmp3/g\" `grep timedb1 -rl ./taosdumptest/dumptmp3`") + + os.system("%staosdump -i ./taosdumptest/dumptmp1" % binPath) + os.system("%staosdump -i ./taosdumptest/dumptmp2" % binPath) + os.system("%staosdump -i ./taosdumptest/dumptmp3" % binPath) + + tdSql.query("select count(*) from dumptmp1.st") + tdSql.checkData(0, 0, 1000) + + tdSql.query("select count(*) from dumptmp2.st") + tdSql.checkData(0, 0, 510) + + tdSql.query("select count(*) from dumptmp3.st") + tdSql.checkData(0, 0, 900) + + origin_res = tdSql.getResult("select * from timedb1.st") + dump_res = tdSql.getResult("select * from dumptmp1.st") + if origin_res == dump_res: + tdLog.info("test ms second : dump check data pass for all data!") + else: + tdLog.info("test ms second : dump check data failed for all data!") + + origin_res = tdSql.getResult( + "select * from timedb1.st where ts >=1625068810000 and ts <= 1625068860000") + dump_res = tdSql.getResult("select * from dumptmp2.st") + if origin_res == dump_res: + tdLog.info(" test ms second : dump check data pass for data! ") + else: + tdLog.info(" test ms second : dump check data failed for data!") + + origin_res = tdSql.getResult( + "select * from timedb1.st where ts >=1625068810000 ") + dump_res = tdSql.getResult("select * from dumptmp3.st") + if origin_res == dump_res: + tdLog.info(" test ms second : dump check data pass for data! ") + else: + tdLog.info(" test ms second : dump check data failed for data! ") + + os.system("rm -rf ./taosdumptest/") + os.system("rm -rf ./dump_result.txt") + os.system("rm -rf *.py.sql") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/windows_input.py b/tests/pytest/tools/windows_input.py new file mode 100644 index 0000000000000000000000000000000000000000..99e30fa311673903850149c1916c6466c6a29ee5 --- /dev/null +++ b/tests/pytest/tools/windows_input.py @@ -0,0 +1,86 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import os +from uiautomation import WindowControl +from util.cases import * +from util.sql import * +import clipboard + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self.host = conn._host + + def win_input_test(self): + os.system("start") + time.sleep(1) + + # 获取CMD窗口 + # window = DocumentControl(searchDepth=3, Name='Text Area') + window = WindowControl(searchDepth=1, AutomationId='Console Window') + # 切换英文输入法 + # window.SendKeys('\\') + # window.SendKeys('{Enter}') + # window.SendKeys('{Shift}') + # window.SendKeys('\\') + # window.SendKeys('{Enter}') + + # 切换目录 + window.SendKeys('c:') + window.SendKeys('{Enter}') + window.SendKeys('cd \\') + window.SendKeys('{Enter}') + window.SendKeys('cd c:\\TDengine') + window.SendKeys('{Enter}') + # 启动taos.exe + window.SendKeys('taos.exe -h %s || taos.exe' % (self.host)) + window.SendKeys('{Enter}') + # 输入 + + temp = '' + for i in range(300): + temp += 'a' + sql = "insert into db.tb values(now,'%s');" % temp + window.SendKeys(sql) + window.SendKeys('{Enter}') + window.SendKeys('{Ctrl}A') + window.SendKeys('{Ctrl}C') + # 获取剪切板里面的复制内容 + result = clipboard.paste() + window.SendKeys('{Ctrl}C') + window.SendKeys('exit') + window.SendKeys('{Enter}') + return result + + def run(self): + tdSql.prepare() + + ret = tdSql.execute('create table tb (ts timestamp, i binary(300))') + + result = self.win_input_test() + tdLog.info(result) + + tdSql.query("select * from tb") + tdSql.checkRows(1) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/topic/topicQuery.py b/tests/pytest/topic/topicQuery.py new file mode 100644 index 0000000000000000000000000000000000000000..1ee3c3a4274d67a76fdae442b2d26a4de29392a2 --- /dev/null +++ b/tests/pytest/topic/topicQuery.py @@ -0,0 +1,91 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.ts = 1538548685000 + + def run(self): + tdSql.prepare() + + # test case for https://jira.taosdata.com:18080/browse/TD-3679 + print("==============step1") + tdSql.execute( + "create topic tq_test partitions 10") + tdSql.execute( + "insert into tq_test.p1(off, ts, content) values(0, %d, 'aaaa')" % self.ts) + tdSql.execute( + "insert into tq_test.p1(off, ts, content) values(1, %d, 'aaaa')" % (self.ts + 1)) + tdSql.execute( + "insert into tq_test.p1(off, ts, content) values(2, %d, 'aaaa')" % (self.ts + 2)) + tdSql.execute( + "insert into tq_test.p1(off, ts, content) values(3, %d, 'aaaa')" % (self.ts + 3)) + + print("==============step2") + + tdSql.query("select * from tq_test.p1") + tdSql.checkRows(4) + + tdSql.query("select * from tq_test.p1 where ts >= %d" % self.ts) + tdSql.checkRows(4) + + tdSql.query("select * from tq_test.p1 where ts > %d" % self.ts) + tdSql.checkRows(3) + + tdSql.query("select * from tq_test.p1 where ts = %d" % self.ts) + tdSql.checkRows(1) + + + tdSql.execute("use db") + tdSql.execute("create table test(ts timestamp, start timestamp, value int)") + tdSql.execute("insert into test values(%d, %d, 1)" % (self.ts, self.ts)) + tdSql.execute("insert into test values(%d, %d, 1)" % (self.ts + 1, self.ts + 1)) + tdSql.execute("insert into test values(%d, %d, 1)" % (self.ts + 2, self.ts + 2)) + tdSql.execute("insert into test values(%d, %d, 1)" % (self.ts + 3, self.ts + 3)) + + tdSql.query("select * from test") + tdSql.checkRows(4) + + tdSql.query("select * from test where ts >= %d" % self.ts) + tdSql.checkRows(4) + + tdSql.query("select * from test where ts > %d" % self.ts) + tdSql.checkRows(3) + + tdSql.query("select * from test where ts = %d" % self.ts) + tdSql.checkRows(1) + + tdSql.query("select * from test where start >= %d" % self.ts) + tdSql.checkRows(4) + + tdSql.query("select * from test where start > %d" % self.ts) + tdSql.checkRows(3) + + tdSql.query("select * from test where start = %d" % self.ts) + tdSql.checkRows(1) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/tt.py b/tests/pytest/tt.py new file mode 100644 index 0000000000000000000000000000000000000000..313a48c96bcc4d4669c5a7236308777a9974f847 --- /dev/null +++ b/tests/pytest/tt.py @@ -0,0 +1,125 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- +import threading +import taos +import sys +import json +import time +import random +import requests +import argparse +import datetime +import string +from requests.auth import HTTPBasicAuth + +class CompressTest: + # def __init__(self,ts=1500000001000,host='127.0.0.1',user='root',password='taosdata',dbname='test', + # stb_prefix='st',subtb_prefix='t',n_Therads=10,r_Therads=10,probabilities=0.05,loop=5, + # stableNum = 2,subtableNum = 1000,insertRows = 100): + def __init__(self): + self.host = 'vm95' + self.ts = 1569859200000 + self.dbname = 'db' + self.user = 'root' + self.password = 'taosdata' + self.loop = 6 + + def rest_query(self,sql): #rest 接口 + host = self.host + user = self.user + password = self.password + port =6041 + url = "http://{}:{}/rest/sql".format(host, port ) + try: + r = requests.post(url, + data = 'use %s' % self.dbname, + auth = HTTPBasicAuth('root', 'taosdata')) + r = requests.post(url, + data = sql, + auth = HTTPBasicAuth('root', 'taosdata')) + except: + print("REST API Failure (TODO: more info here)") + raise + rj = r.json() + if ('status' not in rj): + raise RuntimeError("No status in REST response") + + if rj['status'] == 'error': # clearly reported error + if ('code' not in rj): # error without code + raise RuntimeError("REST error return without code") + errno = rj['code'] # May need to massage this in the future + # print("Raising programming error with REST return: {}".format(rj)) + raise taos.error.ProgrammingError( + rj['desc'], errno) # todo: check existance of 'desc' + + if rj['status'] != 'succ': # better be this + raise RuntimeError( + "Unexpected REST return status: {}".format( + rj['status'])) + + nRows = rj['rows'] if ('rows' in rj) else 0 + return nRows + + + def query_thread_n(self,threadID): #使用原生python接口查询 + tstart = time.time() + host = self.host + user = self.user + password = self.password + conn = taos.connect( + host, + user, + password, + ) + cl = conn.cursor() + cl.execute("use %s;" % self.dbname) + print("Thread %d: starting" % threadID) + loop = self.loop + for loop in range(7): + ts = 1569859200000+loop*86400000 + try: + # sql = 'select ts,c0 from stb_%d where ts >%d and ts <%d' % (threadID, ts, ts+86400000) + sql = 'select ts,c1 from stb_%d where ts >%d and ts <%d' % (threadID, ts, ts+86400000) + # print("sql is ",sql) + # start = time.time() + cl.execute(sql) + cl.fetchall() + # end = time.time() + # print("time cost :",end-start) + except Exception as e: + print('-'*40) + print( + "Failure thread%d, sql: %s \nexception: %s" % + (threadID, str(sql),str(e))) + err_uec='Unable to establish connection' + if err_uec in str(e) and loop >0: + exit(-1) + cl.close() + conn.close() + tstop = time.time() + print("Thread %d: finishing, time collaps:%d " % (threadID, tstop - tstart)) + + + def run(self): + threads = [] + for i in range(10): + thread = threading.Thread(target=self.query_thread_n, args=(i,)) + threads.append(thread) + thread.start() + # for i in range(1,11): + # thread = threading.Thread(target=self.query_thread_r, args=(i,)) + # threads.append(thread) + # thread.start() + +q = CompressTest() +q.run() diff --git a/tests/pytest/update/allow_update-0.py b/tests/pytest/update/allow_update-0.py new file mode 100644 index 0000000000000000000000000000000000000000..69e23883f347ed06a4a3c2375e1252f17336c467 --- /dev/null +++ b/tests/pytest/update/allow_update-0.py @@ -0,0 +1,170 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.numOfRecords = 10 + self.ts = 1604295582000 + + def restartTaosd(self): + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.execute("use udb") + + def run(self): + tdSql.prepare() + startTs = self.ts + + print("==============step1") + tdSql.execute("create database udb update 0") + tdSql.execute("use udb") + tdSql.execute("create table t (ts timestamp, a int)") + tdSql.execute("insert into t values (%d, 1)" % (startTs)) + tdSql.execute("insert into t values (%d, 1)" % (startTs - 3)) + tdSql.execute("insert into t values (%d, 1)" % (startTs + 3)) + + tdSql.query("select * from t") + tdSql.checkRows(3) + + tdSql.query("select a from t") + tdSql.checkData(0, 0, 1) + tdSql.checkData(1, 0, 1) + tdSql.checkData(2, 0, 1) + + print("==============step2") + tdSql.execute("insert into t values (%d, 2)" % (startTs)) + tdSql.execute("insert into t values (%d, 2)" % (startTs - 3)) + tdSql.execute("insert into t values (%d, 2)" % (startTs + 3)) + + tdSql.query("select * from t") + tdSql.checkRows(3) + + tdSql.query("select a from t") + tdSql.checkData(0, 0, 1) + tdSql.checkData(1, 0, 1) + tdSql.checkData(2, 0, 1) + + print("==============step3") + tdSql.execute("insert into t values (%d, 3)" % (startTs - 4)) + tdSql.execute("insert into t values (%d, 3)" % (startTs - 2)) + tdSql.execute("insert into t values (%d, 3)" % (startTs + 2)) + tdSql.execute("insert into t values (%d, 3)" % (startTs + 4)) + + tdSql.query("select * from t") + tdSql.checkRows(7) + + tdSql.query("select a from t") + tdSql.checkData(0, 0, 3) + tdSql.checkData(1, 0, 1) + tdSql.checkData(2, 0, 3) + tdSql.checkData(3, 0, 1) + tdSql.checkData(4, 0, 3) + tdSql.checkData(5, 0, 1) + tdSql.checkData(6, 0, 3) + + print("==============step4") + tdSql.execute("insert into t values (%d, 4)" % (startTs - 4)) + tdSql.execute("insert into t values (%d, 4)" % (startTs - 2)) + tdSql.execute("insert into t values (%d, 4)" % (startTs + 2)) + tdSql.execute("insert into t values (%d, 4)" % (startTs + 4)) + + tdSql.query("select * from t") + tdSql.checkRows(7) + + tdSql.query("select a from t") + tdSql.checkData(0, 0, 3) + tdSql.checkData(1, 0, 1) + tdSql.checkData(2, 0, 3) + tdSql.checkData(3, 0, 1) + tdSql.checkData(4, 0, 3) + tdSql.checkData(5, 0, 1) + tdSql.checkData(6, 0, 3) + + print("==============step5") + tdSql.execute("insert into t values (%d, 5)" % (startTs - 1)) + tdSql.execute("insert into t values (%d, 5)" % (startTs + 1)) + + tdSql.query("select * from t") + tdSql.checkRows(9) + + tdSql.query("select a from t") + tdSql.checkData(0, 0, 3) + tdSql.checkData(1, 0, 1) + tdSql.checkData(2, 0, 3) + tdSql.checkData(3, 0, 5) + tdSql.checkData(4, 0, 1) + tdSql.checkData(5, 0, 5) + tdSql.checkData(6, 0, 3) + tdSql.checkData(7, 0, 1) + tdSql.checkData(8, 0, 3) + + print("==============step6") + tdSql.execute("insert into t values (%d, 6)" % (startTs - 4)) + tdSql.execute("insert into t values (%d, 6)" % (startTs - 3)) + tdSql.execute("insert into t values (%d, 6)" % (startTs - 2)) + tdSql.execute("insert into t values (%d, 6)" % (startTs - 1)) + tdSql.execute("insert into t values (%d, 6)" % (startTs)) + tdSql.execute("insert into t values (%d, 6)" % (startTs + 1)) + tdSql.execute("insert into t values (%d, 6)" % (startTs + 2)) + tdSql.execute("insert into t values (%d, 6)" % (startTs + 3)) + tdSql.execute("insert into t values (%d, 6)" % (startTs + 4)) + + tdSql.query("select * from t") + tdSql.checkRows(9) + + tdSql.query("select a from t") + tdSql.checkData(0, 0, 3) + tdSql.checkData(1, 0, 1) + tdSql.checkData(2, 0, 3) + tdSql.checkData(3, 0, 5) + tdSql.checkData(4, 0, 1) + tdSql.checkData(5, 0, 5) + tdSql.checkData(6, 0, 3) + tdSql.checkData(7, 0, 1) + tdSql.checkData(8, 0, 3) + + # restart taosd to commit, and check + self.restartTaosd(); + + tdSql.query("select * from t") + tdSql.checkRows(9) + + tdSql.query("select a from t") + tdSql.checkData(0, 0, 3) + tdSql.checkData(1, 0, 1) + tdSql.checkData(2, 0, 3) + tdSql.checkData(3, 0, 5) + tdSql.checkData(4, 0, 1) + tdSql.checkData(5, 0, 5) + tdSql.checkData(6, 0, 3) + tdSql.checkData(7, 0, 1) + tdSql.checkData(8, 0, 3) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/update/allow_update.py b/tests/pytest/update/allow_update.py new file mode 100644 index 0000000000000000000000000000000000000000..fa122ff5cf778cca5c72525b9acb56d09c8b2314 --- /dev/null +++ b/tests/pytest/update/allow_update.py @@ -0,0 +1,266 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.numOfRecords = 10 + self.ts = 1604295582000 + + def restartTaosd(self): + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.execute("use udb") + + def run(self): + tdSql.prepare() + startTs = self.ts + + tdSql.execute("create database udb update 1") + tdSql.execute("use udb") + tdSql.execute("create table t (ts timestamp, a int)") + + print("==============step1") + tdSql.execute("insert into t values (%d, 1)" % (startTs)) + tdSql.execute("insert into t values (%d, 1)" % (startTs - 3)) + tdSql.execute("insert into t values (%d, 1)" % (startTs + 3)) + + tdSql.query("select * from t") + tdSql.checkRows(3) + + tdSql.query("select a from t") + tdSql.checkData(0, 0, 1) + tdSql.checkData(1, 0, 1) + tdSql.checkData(2, 0, 1) + + print("==============step2") + tdSql.execute("insert into t values (%d, 2)" % (startTs)) + tdSql.execute("insert into t values (%d, 2)" % (startTs - 3)) + tdSql.execute("insert into t values (%d, 2)" % (startTs + 3)) + + tdSql.query("select * from t") + tdSql.checkRows(3) + + tdSql.query("select a from t") + tdSql.checkData(0, 0, 2) + tdSql.checkData(1, 0, 2) + tdSql.checkData(2, 0, 2) + + print("==============step3") + tdSql.execute("insert into t values (%d, 3)" % (startTs - 4)) + tdSql.execute("insert into t values (%d, 3)" % (startTs - 2)) + tdSql.execute("insert into t values (%d, 3)" % (startTs + 2)) + tdSql.execute("insert into t values (%d, 3)" % (startTs + 4)) + + tdSql.query("select * from t") + tdSql.checkRows(7) + + tdSql.query("select a from t") + tdSql.checkData(0, 0, 3) + tdSql.checkData(1, 0, 2) + tdSql.checkData(2, 0, 3) + tdSql.checkData(3, 0, 2) + tdSql.checkData(4, 0, 3) + tdSql.checkData(5, 0, 2) + tdSql.checkData(6, 0, 3) + + print("==============step4") + tdSql.execute("insert into t values (%d, 4)" % (startTs - 4)) + tdSql.execute("insert into t values (%d, 4)" % (startTs - 2)) + tdSql.execute("insert into t values (%d, 4)" % (startTs + 2)) + tdSql.execute("insert into t values (%d, 4)" % (startTs + 4)) + + tdSql.query("select * from t") + tdSql.checkRows(7) + + tdSql.query("select a from t") + tdSql.checkData(0, 0, 4) + tdSql.checkData(1, 0, 2) + tdSql.checkData(2, 0, 4) + tdSql.checkData(3, 0, 2) + tdSql.checkData(4, 0, 4) + tdSql.checkData(5, 0, 2) + tdSql.checkData(6, 0, 4) + + print("==============step5") + tdSql.execute("insert into t values (%d, 5)" % (startTs - 1)) + tdSql.execute("insert into t values (%d, 5)" % (startTs + 1)) + + tdSql.query("select * from t") + tdSql.checkRows(9) + + tdSql.query("select a from t") + tdSql.checkData(0, 0, 4) + tdSql.checkData(1, 0, 2) + tdSql.checkData(2, 0, 4) + tdSql.checkData(3, 0, 5) + tdSql.checkData(4, 0, 2) + tdSql.checkData(5, 0, 5) + tdSql.checkData(6, 0, 4) + tdSql.checkData(7, 0, 2) + tdSql.checkData(8, 0, 4) + + print("==============step6") + tdSql.execute("insert into t values (%d, 6)" % (startTs - 4)) + tdSql.execute("insert into t values (%d, 6)" % (startTs - 3)) + tdSql.execute("insert into t values (%d, 6)" % (startTs - 2)) + tdSql.execute("insert into t values (%d, 6)" % (startTs - 1)) + tdSql.execute("insert into t values (%d, 6)" % (startTs)) + tdSql.execute("insert into t values (%d, 6)" % (startTs + 1)) + tdSql.execute("insert into t values (%d, 6)" % (startTs + 2)) + tdSql.execute("insert into t values (%d, 6)" % (startTs + 3)) + tdSql.execute("insert into t values (%d, 6)" % (startTs + 4)) + + tdSql.query("select * from t") + tdSql.checkRows(9) + + tdSql.query("select a from t") + tdSql.checkData(0, 0, 6) + tdSql.checkData(1, 0, 6) + tdSql.checkData(2, 0, 6) + tdSql.checkData(3, 0, 6) + tdSql.checkData(4, 0, 6) + tdSql.checkData(5, 0, 6) + tdSql.checkData(6, 0, 6) + tdSql.checkData(7, 0, 6) + tdSql.checkData(8, 0, 6) + + # restart taosd to commit, and check + self.restartTaosd(); + + tdSql.query("select * from t") + tdSql.checkRows(9) + + tdSql.query("select a from t") + tdSql.checkData(0, 0, 6) + tdSql.checkData(1, 0, 6) + tdSql.checkData(2, 0, 6) + tdSql.checkData(3, 0, 6) + tdSql.checkData(4, 0, 6) + tdSql.checkData(5, 0, 6) + tdSql.checkData(6, 0, 6) + tdSql.checkData(7, 0, 6) + tdSql.checkData(8, 0, 6) + + tdSql.execute("create table subt (ts timestamp, a int, b float, c binary(16), d bool)") + + print("==============step7") + tdSql.execute("insert into subt (ts, a, c) values (%d, 1, 'c+0')" % (startTs)) + tdSql.execute("insert into subt (ts, a, c) values (%d, 1, 'c-3')" % (startTs - 3)) + tdSql.execute("insert into subt (ts, a, c) values (%d, 1, 'c+3')" % (startTs + 3)) + + tdSql.query("select * from subt") + tdSql.checkRows(3) + + tdSql.query("select a,b,c,d from subt") + tdSql.checkData(0, 0, 1) + tdSql.checkData(1, 0, 1) + tdSql.checkData(2, 0, 1) + tdSql.checkData(0, 1, None) + tdSql.checkData(1, 1, None) + tdSql.checkData(2, 1, None) + tdSql.checkData(0, 2, 'c-3') + tdSql.checkData(1, 2, 'c+0') + tdSql.checkData(2, 2, 'c+3') + tdSql.checkData(0, 3, None) + tdSql.checkData(1, 3, None) + tdSql.checkData(2, 3, None) + + print("==============step8") + tdSql.execute("insert into subt (ts, b, d) values (%d, 2.0, true)" % (startTs)) + tdSql.execute("insert into subt (ts, b, d) values (%d, 2.0, true)" % (startTs - 3)) + tdSql.execute("insert into subt (ts, b, d) values (%d, 2.0, false)" % (startTs + 3)) + + tdSql.query("select * from subt") + tdSql.checkRows(3) + + tdSql.query("select a,b,c,d from subt") + tdSql.checkData(0, 0, None) + tdSql.checkData(1, 0, None) + tdSql.checkData(2, 0, None) + tdSql.checkData(0, 1, 2.0) + tdSql.checkData(1, 1, 2.0) + tdSql.checkData(2, 1, 2.0) + tdSql.checkData(0, 2, None) + tdSql.checkData(1, 2, None) + tdSql.checkData(2, 2, None) + tdSql.checkData(0, 3, 1) + tdSql.checkData(1, 3, 1) + tdSql.checkData(2, 3, 0) + + # restart taosd to commit, and check + self.restartTaosd(); + + tdSql.query("select * from subt") + tdSql.checkRows(3) + + tdSql.query("select a,b,c,d from subt") + tdSql.checkData(0, 0, None) + tdSql.checkData(1, 0, None) + tdSql.checkData(2, 0, None) + tdSql.checkData(0, 1, 2.0) + tdSql.checkData(1, 1, 2.0) + tdSql.checkData(2, 1, 2.0) + tdSql.checkData(0, 2, None) + tdSql.checkData(1, 2, None) + tdSql.checkData(2, 2, None) + tdSql.checkData(0, 3, 1) + tdSql.checkData(1, 3, 1) + tdSql.checkData(2, 3, 0) + + + + tdSql.execute("create table ct (ts timestamp, a int, b float, c binary(128))") + + print("==============step9") + insertRows = 20000 + for i in range(0, insertRows): + tdSql.execute("insert into ct values (%d , %d, %d, 'aabbccddeeffgghhiijjkkllmmoonn112233445566778899xxyyzz')" % (startTs + i, i, i)) + + tdSql.query("select * from ct") + tdSql.checkRows(insertRows) + + for i in range(0, insertRows): + tdSql.execute("insert into ct values (%d , %d, %d, 'aabbccddeeffgghhiijjkkllmmoonn112233445566778899xxyyzz')" % (startTs + i, i+insertRows, i+insertRows)) + + tdSql.query("select * from ct") + tdSql.checkRows(insertRows) + + tdSql.query("select a,b from ct limit 3") + tdSql.checkData(0, 0, insertRows+0) + tdSql.checkData(1, 0, insertRows+1) + tdSql.checkData(2, 0, insertRows+2) + + tdSql.checkData(0, 1, insertRows+0) + tdSql.checkData(1, 1, insertRows+1) + tdSql.checkData(2, 1, insertRows+2) + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/update/append_commit_data-0.py b/tests/pytest/update/append_commit_data-0.py new file mode 100644 index 0000000000000000000000000000000000000000..b844a50a086dc52d7edb5250801ee87cf68ee28f --- /dev/null +++ b/tests/pytest/update/append_commit_data-0.py @@ -0,0 +1,84 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + print("==========step1") + print("create table && insert data") + s = 'reset query cache' + tdSql.execute(s) + s = 'drop database if exists db' + tdSql.execute(s) + s = 'create database db' + tdSql.execute(s) + s = 'use db' + tdSql.execute(s) + ret = tdSql.execute('create table t1 (ts timestamp, a int)') + + insertRows = 200 + t0 = 1604298064000 + tdLog.info("insert %d rows" % (insertRows)) + for i in range(0, insertRows): + ret = tdSql.execute( + 'insert into t1 values (%d , 1)' % + (t0+i)) + print("==========step2") + print("restart to commit ") + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from db.t1") + tdSql.checkRows(insertRows) + for k in range(0,100): + tdLog.info("insert %d rows" % (insertRows)) + for i in range (0,insertRows): + ret = tdSql.execute( + 'insert into db.t1 values(%d,1)' % + (t0+k*200+i) + ) + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from db.t1") + tdSql.checkRows(insertRows+200*k) + print("==========step2") + print("insert into another table ") + s = 'use db' + tdSql.execute(s) + ret = tdSql.execute('create table t2 (ts timestamp, a int)') + insertRows = 20000 + for i in range(0, insertRows): + ret = tdSql.execute( + 'insert into t2 values (%d, 1)' % + (t0+i)) + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t2") + tdSql.checkRows(insertRows) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/update/append_commit_data.py b/tests/pytest/update/append_commit_data.py new file mode 100644 index 0000000000000000000000000000000000000000..524c66d06af6d0c5ba1564fd772da17d217066af --- /dev/null +++ b/tests/pytest/update/append_commit_data.py @@ -0,0 +1,109 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + print("==========step1") + print("create table && insert data") + s = 'reset query cache' + tdSql.execute(s) + s = 'drop database if exists db' + tdSql.execute(s) + s = 'create database db update 1' + tdSql.execute(s) + s = 'use db' + tdSql.execute(s) + ret = tdSql.execute('create table t1 (ts timestamp, a int)') + + insertRows = 200 + t0 = 1604298064000 + sql='insert into db.t1 values ' + temp='' + tdLog.info("insert %d rows" % (insertRows)) + for i in range(0, insertRows): + # ret = tdSql.execute( + # 'insert into t1 values (%d , 1)' % + # (t0+i)) + temp += '(%d,1)' %(t0+i) + if i % 100 == 0 or i == (insertRows - 1 ): + print(sql+temp) + ret = tdSql.execute( + sql+temp + ) + temp = '' + print("==========step2") + print("restart to commit ") + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from db.t1") + tdSql.checkRows(insertRows) + + for k in range(0,10): + tdLog.info("insert %d rows" % (insertRows)) + temp='' + for i in range (0,insertRows): + temp += '(%d,1)' %(t0+k*200+i) + if i % 100 == 0 or i == (insertRows - 1 ): + print(sql+temp) + ret = tdSql.execute( + sql+temp + ) + temp = '' + + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from db.t1") + tdSql.checkRows(insertRows+200*k) + insertRows = insertRows * 2 + print("==========step3") + print("insert into another table ") + s = 'use db' + tdSql.execute(s) + ret = tdSql.execute('create table t2 (ts timestamp, a int)') + insertRows = 20000 + sql = 'insert into t2 values ' + temp = '' + for i in range(0, insertRows): + # ret = tdSql.execute( + # 'insert into t2 values (%d, 1)' % + # (t0+i)) + temp += '(%d,1)' %(t0+i) + if i % 500 == 0 or i == (insertRows - 1 ): + print(sql+temp) + ret = tdSql.execute( + sql+temp + ) + temp = '' + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t2") + tdSql.checkRows(insertRows) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/update/append_commit_last-0.py b/tests/pytest/update/append_commit_last-0.py new file mode 100644 index 0000000000000000000000000000000000000000..c884207f2bba5dd0da09cf4aae501d27caef7aab --- /dev/null +++ b/tests/pytest/update/append_commit_last-0.py @@ -0,0 +1,90 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.ts = 1604298064000 + + def restartTaosd(self): + tdDnodes.stop(1) + tdDnodes.startWithoutSleep(1) + tdSql.execute("use db") + + def run(self): + tdSql.prepare() + + print("==============step1") + tdSql.execute("create table t1 (ts timestamp, a int)") + + for i in range(10): + tdSql.execute("insert into t1 values(%d, 1)" % (self.ts + i)) + self.restartTaosd() + tdSql.query("select * from t1") + tdSql.checkRows(i + 1) + tdSql.query("select sum(a) from t1") + tdSql.checkData(0, 0, i + 1) + + print("==============step2") + tdSql.execute("create table t2 (ts timestamp, a int)") + tdSql.execute("insert into t2 values(%d, 1)" % self.ts) + self.restartTaosd() + tdSql.query("select * from t2") + tdSql.checkRows(1) + tdSql.checkData(0, 1, 1) + + for i in range(1, 151): + tdSql.execute("insert into t2 values(%d, 1)" % (self.ts + i)) + + self.restartTaosd() + tdSql.query("select * from t2") + tdSql.checkRows(151) + tdSql.query("select sum(a) from t2") + tdSql.checkData(0, 0, 151) + + + print("==============step3") + tdSql.execute("create table t3 (ts timestamp, a int)") + tdSql.execute("insert into t3 values(%d, 1)" % self.ts) + self.restartTaosd() + tdSql.query("select * from t3") + tdSql.checkRows(1) + tdSql.checkData(0, 1, 1) + + for i in range(8): + for j in range(1, 11): + tdSql.execute("insert into t3 values(%d, 1)" % (self.ts + i * 10 + j)) + + self.restartTaosd() + tdSql.query("select * from t3") + tdSql.checkRows(81) + tdSql.query("select sum(a) from t3") + tdSql.checkData(0, 0, 81) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/update/append_commit_last.py b/tests/pytest/update/append_commit_last.py new file mode 100644 index 0000000000000000000000000000000000000000..013983f9402292d03d26bd998c96eaf39b26a8fd --- /dev/null +++ b/tests/pytest/update/append_commit_last.py @@ -0,0 +1,85 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.ts = 1604298064000 + + def restartTaosd(self): + tdDnodes.stop(1) + tdDnodes.startWithoutSleep(1) + tdSql.execute("use udb") + + def run(self): + tdSql.prepare() + + print("==============step1") + tdSql.execute("create database udb update 1") + tdSql.execute("use udb") + tdSql.execute("create table t1 (ts timestamp, a int)") + + for i in range(10): + tdSql.execute("insert into t1 values(%d, 1)" % (self.ts + i)) + self.restartTaosd() + tdSql.query("select * from t1") + tdSql.checkRows(i + 1) + + + print("==============step2") + tdSql.execute("create table t2 (ts timestamp, a int)") + tdSql.execute("insert into t2 values(%d, 1)" % self.ts) + self.restartTaosd() + tdSql.query("select * from t2") + tdSql.checkRows(1) + + for i in range(1, 151): + tdSql.execute("insert into t2 values(%d, 1)" % (self.ts + i)) + + self.restartTaosd() + tdSql.query("select * from t2") + tdSql.checkRows(151) + + + print("==============step3") + tdSql.execute("create table t3 (ts timestamp, a int)") + tdSql.execute("insert into t3 values(%d, 1)" % self.ts) + self.restartTaosd() + tdSql.query("select * from t3") + tdSql.checkRows(1) + + for i in range(8): + for j in range(1, 11): + tdSql.execute("insert into t3 values(%d, 1)" % (self.ts + i * 10 + j)) + + self.restartTaosd() + tdSql.query("select * from t3") + tdSql.checkRows(81) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/update/merge_commit_data-0.py b/tests/pytest/update/merge_commit_data-0.py new file mode 100644 index 0000000000000000000000000000000000000000..14d435f7f20d9e04565fdb7036da043d948b1dcf --- /dev/null +++ b/tests/pytest/update/merge_commit_data-0.py @@ -0,0 +1,351 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + print("==========step1") + print("UPDATE THE WHOLE DATA BLOCK REPEATEDLY") + s = 'reset query cache' + tdSql.execute(s) + s = 'drop database if exists db' + tdSql.execute(s) + s = 'create database db days 30' + tdSql.execute(s) + s = 'use db' + tdSql.execute(s) + ret = tdSql.execute('create table t1 (ts timestamp, a int)') + + insertRows = 200 + t0 = 1603152000000 + tdLog.info("insert %d rows" % (insertRows)) + for i in range(0, insertRows): + ret = tdSql.execute( + 'insert into t1 values (%d , 1)' % + (t0 + i)) + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t1") + tdSql.checkRows(insertRows) + + for k in range(0,10): + for i in range (0,insertRows): + ret = tdSql.execute( + 'insert into t1 values(%d,1)' % + (t0+i) + ) + tdSql.query("select * from t1") + tdSql.checkRows(insertRows) + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t1") + tdSql.checkRows(insertRows) + print("==========step2") + print("PREPEND DATA ") + ret = tdSql.execute('create table t2 (ts timestamp, a int)') + insertRows = 200 + for i in range(0, insertRows): + ret = tdSql.execute( + 'insert into t2 values (%d , 1)' % + (t0+i)) + tdSql.query("select * from t2") + tdSql.checkRows(insertRows) + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t2") + tdSql.checkRows(insertRows) + for i in range(-100,0): + ret = tdSql.execute( + 'insert into t2 values (%d , 1)' % + (t0+i)) + tdSql.query("select * from t2") + tdSql.checkRows(insertRows+100) + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t2") + tdSql.checkRows(insertRows+100) + print("==========step3") + print("PREPEND MASSIVE DATA ") + ret = tdSql.execute('create table t3 (ts timestamp, a int)') + insertRows = 200 + for i in range(0, insertRows): + ret = tdSql.execute( + 'insert into t3 values (%d , 1)' % + (t0+i)) + tdSql.query("select * from t3") + tdSql.checkRows(insertRows) + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t3") + tdSql.checkRows(insertRows) + for i in range(-6000,0): + ret = tdSql.execute( + 'insert into t3 values (%d , 1)' % + (t0+i)) + tdSql.query("select * from t3") + tdSql.checkRows(insertRows+6000) + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t3") + tdSql.checkRows(insertRows+6000) + print("==========step4") + print("APPEND DATA") + ret = tdSql.execute('create table t4 (ts timestamp, a int)') + insertRows = 200 + for i in range(0, insertRows): + ret = tdSql.execute( + 'insert into t4 values (%d , 1)' % + (t0+i)) + tdSql.query("select * from t4") + tdSql.checkRows(insertRows) + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t4") + tdSql.checkRows(insertRows) + for i in range(0,100): + ret = tdSql.execute( + 'insert into t4 values (%d , 1)' % + (t0+200+i)) + tdSql.query("select * from t4") + tdSql.checkRows(insertRows+100) + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t4") + tdSql.checkRows(insertRows+100) + print("==========step5") + print("APPEND DATA") + ret = tdSql.execute('create table t5 (ts timestamp, a int)') + insertRows = 200 + for i in range(0, insertRows): + ret = tdSql.execute( + 'insert into t5 values (%d , 1)' % + (t0+i)) + tdSql.query("select * from t5") + tdSql.checkRows(insertRows) + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t5") + tdSql.checkRows(insertRows) + for i in range(0,6000): + ret = tdSql.execute( + 'insert into t5 values (%d , 1)' % + (t0+200+i)) + tdSql.query("select * from t5") + tdSql.checkRows(insertRows+6000) + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t5") + tdSql.checkRows(insertRows+6000) + print("==========step6") + print("UPDATE BLOCK IN TWO STEP") + ret = tdSql.execute('create table t6 (ts timestamp, a int)') + insertRows = 200 + for i in range(0, insertRows): + ret = tdSql.execute( + 'insert into t6 values (%d , 1)' % + (t0+i)) + tdSql.query("select * from t6") + tdSql.checkRows(insertRows) + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t6") + tdSql.checkRows(insertRows) + for i in range(0,100): + ret = tdSql.execute( + 'insert into t6 values (%d , 2)' % + (t0+i)) + tdSql.query("select * from t6") + tdSql.checkRows(insertRows) + tdSql.query("select sum(a) from t6") + tdSql.checkData(0,0,'200') + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t6") + tdSql.checkRows(insertRows) + tdSql.query("select sum(a) from t6") + tdSql.checkData(0,0,'200') + for i in range(0,200): + ret = tdSql.execute( + 'insert into t6 values (%d , 2)' % + (t0+i)) + tdSql.query("select * from t6") + tdSql.checkRows(insertRows) + tdSql.query("select sum(a) from t6") + tdSql.checkData(0,0,'200') + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t6") + tdSql.checkRows(insertRows) + tdSql.query("select sum(a) from t6") + tdSql.checkData(0,0,'200') + print("==========step7") + print("UPDATE LAST HALF AND INSERT LITTLE DATA") + ret = tdSql.execute('create table t7 (ts timestamp, a int)') + insertRows = 200 + for i in range(0, insertRows): + ret = tdSql.execute( + 'insert into t7 values (%d , 1)' % + (t0+i)) + tdSql.query("select * from t7") + tdSql.checkRows(insertRows) + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t7") + tdSql.checkRows(insertRows) + for i in range(100,300): + ret = tdSql.execute( + 'insert into t7 values (%d , 2)' % + (t0+i)) + tdSql.query("select * from t7") + tdSql.checkRows(300) + tdSql.query("select sum(a) from t7") + tdSql.checkData(0,0,'400') + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t7") + tdSql.checkRows(300) + tdSql.query("select sum(a) from t7") + tdSql.checkData(0,0,'400') + print("==========step8") + print("UPDATE LAST HALF AND INSERT MASSIVE DATA") + ret = tdSql.execute('create table t8 (ts timestamp, a int)') + insertRows = 200 + for i in range(0, insertRows): + ret = tdSql.execute( + 'insert into t8 values (%d , 1)' % + (t0+i)) + tdSql.query("select * from t8") + tdSql.checkRows(insertRows) + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t8") + tdSql.checkRows(insertRows) + for i in range(6000): + ret = tdSql.execute( + 'insert into t8 values (%d , 2)' % + (t0+i)) + tdSql.query("select * from t8") + tdSql.checkRows(6000) + tdSql.query("select sum(a) from t8") + tdSql.checkData(0,0,'11800') + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t8") + tdSql.checkRows(6000) + tdSql.query("select sum(a) from t8") + tdSql.checkData(0,0,'11800') + print("==========step9") + print("UPDATE FIRST HALF AND PREPEND LITTLE DATA") + ret = tdSql.execute('create table t9 (ts timestamp, a int)') + insertRows = 200 + for i in range(0, insertRows): + ret = tdSql.execute( + 'insert into t9 values (%d , 1)' % + (t0+i)) + tdSql.query("select * from t9") + tdSql.checkRows(insertRows) + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t9") + tdSql.checkRows(insertRows) + for i in range(-100,100): + ret = tdSql.execute( + 'insert into t9 values (%d , 2)' % + (t0+i)) + tdSql.query("select * from t9") + tdSql.checkRows(300) + tdSql.query("select sum(a) from t9") + tdSql.checkData(0,0,'400') + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t9") + tdSql.checkRows(300) + tdSql.query("select sum(a) from t9") + tdSql.checkData(0,0,'400') + print("==========step10") + print("UPDATE FIRST HALF AND PREPEND MASSIVE DATA") + ret = tdSql.execute('create table t10 (ts timestamp, a int)') + insertRows = 200 + for i in range(0, insertRows): + ret = tdSql.execute( + 'insert into t10 values (%d , 1)' % + (t0+i)) + tdSql.query("select * from t10") + tdSql.checkRows(insertRows) + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t10") + tdSql.checkRows(insertRows) + for i in range(-6000,100): + ret = tdSql.execute( + 'insert into t10 values (%d , 2)' % + (t0+i)) + tdSql.query("select * from t10") + tdSql.checkRows(6200) + tdSql.query("select sum(a) from t10") + tdSql.checkData(0,0,'12200') + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t10") + tdSql.checkRows(6200) + tdSql.query("select sum(a) from t10") + tdSql.checkData(0,0,'12200') + print("==========step11") + print("UPDATE FIRST HALF AND APPEND MASSIVE DATA") + ret = tdSql.execute('create table t11 (ts timestamp, a int)') + insertRows = 200 + for i in range(0, insertRows): + ret = tdSql.execute( + 'insert into t11 values (%d , 1)' % + (t0+i)) + tdSql.query("select * from t11") + tdSql.checkRows(insertRows) + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t11") + tdSql.checkRows(insertRows) + for i in range(100): + ret = tdSql.execute( + 'insert into t11 values (%d , 2)' % + (t0+i)) + for i in range(200,6000): + ret = tdSql.execute( + 'insert into t11 values (%d , 2)' % + (t0+i)) + tdSql.query("select * from t11") + tdSql.checkRows(6000) + tdSql.query("select sum(a) from t11") + tdSql.checkData(0,0,'11800') + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t11") + tdSql.checkRows(6000) + tdSql.query("select sum(a) from t11") + tdSql.checkData(0,0,'11800') + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/update/merge_commit_data.py b/tests/pytest/update/merge_commit_data.py new file mode 100644 index 0000000000000000000000000000000000000000..4fb6765361e8099acb0f1f861623a88fd6b8e466 --- /dev/null +++ b/tests/pytest/update/merge_commit_data.py @@ -0,0 +1,351 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + print("==========step1") + print("UPDATE THE WHOLE DATA BLOCK REPEATEDLY") + s = 'reset query cache' + tdSql.execute(s) + s = 'drop database if exists db' + tdSql.execute(s) + s = 'create database db update 1 days 30' + tdSql.execute(s) + s = 'use db' + tdSql.execute(s) + ret = tdSql.execute('create table t1 (ts timestamp, a int)') + + insertRows = 200 + t0 = 1603152000000 + tdLog.info("insert %d rows" % (insertRows)) + for i in range(0, insertRows): + ret = tdSql.execute( + 'insert into t1 values (%d , 1)' % + (t0 + i)) + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t1") + tdSql.checkRows(insertRows) + + for k in range(0,10): + for i in range (0,insertRows): + ret = tdSql.execute( + 'insert into t1 values(%d,1)' % + (t0+i) + ) + tdSql.query("select * from t1") + tdSql.checkRows(insertRows) + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t1") + tdSql.checkRows(insertRows) + print("==========step2") + print("PREPEND DATA ") + ret = tdSql.execute('create table t2 (ts timestamp, a int)') + insertRows = 200 + for i in range(0, insertRows): + ret = tdSql.execute( + 'insert into t2 values (%d , 1)' % + (t0+i)) + tdSql.query("select * from t2") + tdSql.checkRows(insertRows) + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t2") + tdSql.checkRows(insertRows) + for i in range(-100,0): + ret = tdSql.execute( + 'insert into t2 values (%d , 1)' % + (t0+i)) + tdSql.query("select * from t2") + tdSql.checkRows(insertRows+100) + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t2") + tdSql.checkRows(insertRows+100) + print("==========step3") + print("PREPEND MASSIVE DATA ") + ret = tdSql.execute('create table t3 (ts timestamp, a int)') + insertRows = 200 + for i in range(0, insertRows): + ret = tdSql.execute( + 'insert into t3 values (%d , 1)' % + (t0+i)) + tdSql.query("select * from t3") + tdSql.checkRows(insertRows) + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t3") + tdSql.checkRows(insertRows) + for i in range(-6000,0): + ret = tdSql.execute( + 'insert into t3 values (%d , 1)' % + (t0+i)) + tdSql.query("select * from t3") + tdSql.checkRows(insertRows+6000) + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t3") + tdSql.checkRows(insertRows+6000) + print("==========step4") + print("APPEND DATA") + ret = tdSql.execute('create table t4 (ts timestamp, a int)') + insertRows = 200 + for i in range(0, insertRows): + ret = tdSql.execute( + 'insert into t4 values (%d , 1)' % + (t0+i)) + tdSql.query("select * from t4") + tdSql.checkRows(insertRows) + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t4") + tdSql.checkRows(insertRows) + for i in range(0,100): + ret = tdSql.execute( + 'insert into t4 values (%d , 1)' % + (t0+200+i)) + tdSql.query("select * from t4") + tdSql.checkRows(insertRows+100) + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t4") + tdSql.checkRows(insertRows+100) + print("==========step5") + print("APPEND DATA") + ret = tdSql.execute('create table t5 (ts timestamp, a int)') + insertRows = 200 + for i in range(0, insertRows): + ret = tdSql.execute( + 'insert into t5 values (%d , 1)' % + (t0+i)) + tdSql.query("select * from t5") + tdSql.checkRows(insertRows) + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t5") + tdSql.checkRows(insertRows) + for i in range(0,6000): + ret = tdSql.execute( + 'insert into t5 values (%d , 1)' % + (t0+200+i)) + tdSql.query("select * from t5") + tdSql.checkRows(insertRows+6000) + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t5") + tdSql.checkRows(insertRows+6000) + print("==========step6") + print("UPDATE BLOCK IN TWO STEP") + ret = tdSql.execute('create table t6 (ts timestamp, a int)') + insertRows = 200 + for i in range(0, insertRows): + ret = tdSql.execute( + 'insert into t6 values (%d , 1)' % + (t0+i)) + tdSql.query("select * from t6") + tdSql.checkRows(insertRows) + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t6") + tdSql.checkRows(insertRows) + for i in range(0,100): + ret = tdSql.execute( + 'insert into t6 values (%d , 2)' % + (t0+i)) + tdSql.query("select * from t6") + tdSql.checkRows(insertRows) + tdSql.query("select sum(a) from t6") + tdSql.checkData(0,0,'300') + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t6") + tdSql.checkRows(insertRows) + tdSql.query("select sum(a) from t6") + tdSql.checkData(0,0,'300') + for i in range(0,200): + ret = tdSql.execute( + 'insert into t6 values (%d , 2)' % + (t0+i)) + tdSql.query("select * from t6") + tdSql.checkRows(insertRows) + tdSql.query("select sum(a) from t6") + tdSql.checkData(0,0,'400') + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t6") + tdSql.checkRows(insertRows) + tdSql.query("select sum(a) from t6") + tdSql.checkData(0,0,'400') + print("==========step7") + print("UPDATE LAST HALF AND INSERT LITTLE DATA") + ret = tdSql.execute('create table t7 (ts timestamp, a int)') + insertRows = 200 + for i in range(0, insertRows): + ret = tdSql.execute( + 'insert into t7 values (%d , 1)' % + (t0+i)) + tdSql.query("select * from t7") + tdSql.checkRows(insertRows) + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t7") + tdSql.checkRows(insertRows) + for i in range(100,300): + ret = tdSql.execute( + 'insert into t7 values (%d , 2)' % + (t0+i)) + tdSql.query("select * from t7") + tdSql.checkRows(300) + tdSql.query("select sum(a) from t7") + tdSql.checkData(0,0,'500') + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t7") + tdSql.checkRows(300) + tdSql.query("select sum(a) from t7") + tdSql.checkData(0,0,'500') + print("==========step8") + print("UPDATE LAST HALF AND INSERT MASSIVE DATA") + ret = tdSql.execute('create table t8 (ts timestamp, a int)') + insertRows = 200 + for i in range(0, insertRows): + ret = tdSql.execute( + 'insert into t8 values (%d , 1)' % + (t0+i)) + tdSql.query("select * from t8") + tdSql.checkRows(insertRows) + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t8") + tdSql.checkRows(insertRows) + for i in range(6000): + ret = tdSql.execute( + 'insert into t8 values (%d , 2)' % + (t0+i)) + tdSql.query("select * from t8") + tdSql.checkRows(6000) + tdSql.query("select sum(a) from t8") + tdSql.checkData(0,0,'12000') + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t8") + tdSql.checkRows(6000) + tdSql.query("select sum(a) from t8") + tdSql.checkData(0,0,'12000') + print("==========step9") + print("UPDATE FIRST HALF AND PREPEND LITTLE DATA") + ret = tdSql.execute('create table t9 (ts timestamp, a int)') + insertRows = 200 + for i in range(0, insertRows): + ret = tdSql.execute( + 'insert into t9 values (%d , 1)' % + (t0+i)) + tdSql.query("select * from t9") + tdSql.checkRows(insertRows) + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t9") + tdSql.checkRows(insertRows) + for i in range(-100,100): + ret = tdSql.execute( + 'insert into t9 values (%d , 2)' % + (t0+i)) + tdSql.query("select * from t9") + tdSql.checkRows(300) + tdSql.query("select sum(a) from t9") + tdSql.checkData(0,0,'500') + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t9") + tdSql.checkRows(300) + tdSql.query("select sum(a) from t9") + tdSql.checkData(0,0,'500') + print("==========step10") + print("UPDATE FIRST HALF AND PREPEND MASSIVE DATA") + ret = tdSql.execute('create table t10 (ts timestamp, a int)') + insertRows = 200 + for i in range(0, insertRows): + ret = tdSql.execute( + 'insert into t10 values (%d , 1)' % + (t0+i)) + tdSql.query("select * from t10") + tdSql.checkRows(insertRows) + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t10") + tdSql.checkRows(insertRows) + for i in range(-6000,100): + ret = tdSql.execute( + 'insert into t10 values (%d , 2)' % + (t0+i)) + tdSql.query("select * from t10") + tdSql.checkRows(6200) + tdSql.query("select sum(a) from t10") + tdSql.checkData(0,0,'12300') + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t10") + tdSql.checkRows(6200) + tdSql.query("select sum(a) from t10") + tdSql.checkData(0,0,'12300') + print("==========step11") + print("UPDATE FIRST HALF AND APPEND MASSIVE DATA") + ret = tdSql.execute('create table t11 (ts timestamp, a int)') + insertRows = 200 + for i in range(0, insertRows): + ret = tdSql.execute( + 'insert into t11 values (%d , 1)' % + (t0+i)) + tdSql.query("select * from t11") + tdSql.checkRows(insertRows) + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t11") + tdSql.checkRows(insertRows) + for i in range(100): + ret = tdSql.execute( + 'insert into t11 values (%d , 2)' % + (t0+i)) + for i in range(200,6000): + ret = tdSql.execute( + 'insert into t11 values (%d , 2)' % + (t0+i)) + tdSql.query("select * from t11") + tdSql.checkRows(6000) + tdSql.query("select sum(a) from t11") + tdSql.checkData(0,0,'11900') + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from t11") + tdSql.checkRows(6000) + tdSql.query("select sum(a) from t11") + tdSql.checkData(0,0,'11900') + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/update/merge_commit_data2.py b/tests/pytest/update/merge_commit_data2.py new file mode 100644 index 0000000000000000000000000000000000000000..a334f39e867e80ca05a8de57016e4581ee5fb68c --- /dev/null +++ b/tests/pytest/update/merge_commit_data2.py @@ -0,0 +1,353 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import time + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + + def restart_taosd(self,db): + tdDnodes.stop(1) + tdDnodes.startWithoutSleep(1) + tdLog.sleep(2) + tdSql.execute("use %s;" % db) + + def date_to_timestamp_microseconds(self, date): + datetime_obj = datetime.strptime(date, "%Y-%m-%d %H:%M:%S.%f") + obj_stamp = int(time.mktime(datetime_obj.timetuple()) * 1000.0 + datetime_obj.microsecond / 1000.0) + return obj_stamp + + def timestamp_microseconds_to_date(self, timestamp): + d = datetime.datetime.fromtimestamp(timestamp/1000) + str1 = d.strftime("%Y-%m-%d %H:%M:%S.%f") + return str1 + + + + def run(self): + print("==========step1") + print("create table && insert data") + sql = 'reset query cache' + tdSql.execute(sql) + sql = 'drop database if exists db' + tdSql.execute(sql) + sql = 'create database db update 1 days 30;' + tdSql.execute(sql) + sql = 'use db;' + tdSql.execute(sql) + tdSql.execute('create table t1 (ts timestamp, a int)') + + + print("==================================1 start") + insert_rows = 200 + t0 = 1603152000000 + tdLog.info("insert %d rows" % insert_rows) + for i in range(insert_rows): + tdSql.execute('insert into t1 values (%d , 1)' %(t0+i)) + print("==========step2") + print("restart to commit ") + self.restart_taosd('db') + + print('check query result after restart') + tdSql.query('select * from db.t1;') + for i in range(insert_rows): + tdSql.checkData(i, 1, 1) + + print("==========step3") + print('insert data') + for i in range(insert_rows): + tdSql.execute('insert into t1 values (%d , 1)' %(t0+i+5000)) + print('check query result before restart') + tdSql.query('select * from db.t1;') + for i in range(insert_rows, insert_rows*2): + tdSql.checkData(i, 1, 1) + + self.restart_taosd('db') + print('check query result after restart') + tdSql.query('select * from db.t1;') + for i in range(insert_rows, insert_rows*2): + tdSql.checkData(i, 1, 1) + + print("==========step4") + print('insert data') + for i in range(insert_rows): + tdSql.execute('insert into t1 values (%d , 2)' %(t0+i)) + for i in range(insert_rows): + tdSql.execute('insert into t1 values (%d , 1)' %(t0+i+5000)) + + print('check query result before restart') + tdSql.query('select * from db.t1;') + print(tdSql.queryResult) + for i in range(insert_rows): + tdSql.checkData(i, 1, 2) + for i in range(insert_rows, insert_rows*2): + tdSql.checkData(i, 1, 1) + + print('check query result after restart') + self.restart_taosd('db') + tdSql.query('select * from db.t1;') + # print(tdSql.queryResult) + for i in range(insert_rows): + tdSql.checkData(i, 1, 2) + for i in range(insert_rows, insert_rows*2): + tdSql.checkData(i, 1, 1) + + print("==================================2 start") + print("==========step1") + print("create table && insert data") + tdSql.execute('create table t2 (ts timestamp, a int)') + insert_rows = 200 + t0 = 1603152000000 + tdLog.info("insert %d rows" % insert_rows) + for i in range(insert_rows): + tdSql.execute('insert into t2 values (%d , 1)' %(t0+i)) + print('restart to commit') + self.restart_taosd('db') + for i in range(insert_rows): + tdSql.execute('insert into t2 values (%d , 1)' %(t0+i+5000)) + print('restart to commit') + self.restart_taosd('db') + + for k in range(10): + for i in range(10): + tdSql.execute('insert into t2 values (%d , 1)' %(t0 + 200 + k * 10 + i)) + print('insert into t2 values (%d , 1)' %(t0 + 200 + k * 10 + i)) + + + print("==========step2") + print('check query result before restart') + tdSql.query('select * from db.t2;') + for i in range(insert_rows*2+100): + tdSql.checkData(i, 1, 1) + # print(tdSql.queryResult) + print('restart to commit') + self.restart_taosd('db') + print('check query result after restart') + tdSql.query('select * from db.t2;') + for i in range(insert_rows*2+100): + tdSql.checkData(i, 1, 1) + + + print("==================================3 start") + print("==========step1") + print("create table && insert data") + tdSql.execute('create table t3 (ts timestamp, a int)') + insert_rows = 200 + t0 = 1603152000000 + tdLog.info("insert %d rows" % insert_rows) + for i in range(insert_rows): + tdSql.execute('insert into t3 values (%d , 1)' %(t0+i)) + print('restart to commit') + self.restart_taosd('db') + + for i in range(insert_rows): + tdSql.execute('insert into t3 values (%d , 1)' %(t0+i+5000)) + print('restart to commit') + self.restart_taosd('db') + + for i in range(5200): + tdSql.execute('insert into t3 values (%d , 2)' %(t0+i)) + + print("==========step2") + print('check query result before restart') + tdSql.query('select * from db.t3;') + for i in range(5200): + tdSql.checkData(i, 1, 2) + # print(tdSql.queryResult) + print('restart to commit') + self.restart_taosd('db') + print('check query result after restart') + tdSql.query('select * from db.t3;') + for i in range(5200): + tdSql.checkData(i, 1, 2) + + print("==================================4 start") + print("==========step1") + print("create table && insert data") + tdSql.execute('create table t4 (ts timestamp, a int)') + insert_rows = 200 + t0 = 1603152000000 + tdLog.info("insert %d rows" % insert_rows) + for i in range(insert_rows): + tdSql.execute('insert into t4 values (%d , 1)' %(t0+i)) + print('restart to commit') + self.restart_taosd('db') + + for i in range(insert_rows): + tdSql.execute('insert into t4 values (%d , 1)' %(t0+i+5000)) + print('restart to commit') + self.restart_taosd('db') + + for i in range(100): + tdSql.execute('insert into t4 values (%d , 2)' %(t0+i)) + + for i in range(200, 5000): + tdSql.execute('insert into t4 values (%d , 2)' %(t0+i)) + + for i in range(100): + tdSql.execute('insert into t4 values (%d , 1)' %(t0+i+5000)) + + print('check query result before restart') + tdSql.query('select * from db.t4;') + for i in range(100): + tdSql.checkData(i, 1, 2) + for i in range(100, 200): + tdSql.checkData(i, 1, 1) + for i in range(200, 5000): + tdSql.checkData(i, 1, 2) + for i in range(5000, 5200): + tdSql.checkData(i, 1, 1) + + print('check query result after restart') + self.restart_taosd('db') + tdSql.query('select * from db.t4;') + for i in range(100): + tdSql.checkData(i, 1, 2) + for i in range(100, 200): + tdSql.checkData(i, 1, 1) + for i in range(200, 5000): + tdSql.checkData(i, 1, 2) + for i in range(5000, 5200): + tdSql.checkData(i, 1, 1) + + print("==================================5 start") + print("==========step1") + print("create table && insert data") + tdSql.execute('create table t5 (ts timestamp, a int)') + insert_rows = 200 + t0 = 1603152000000 + tdLog.info("insert %d rows" % insert_rows) + for i in range(insert_rows): + tdSql.execute('insert into t5 values (%d , 1)' %(t0+i)) + print('restart to commit') + self.restart_taosd('db') + + for i in range(insert_rows): + tdSql.execute('insert into t5 values (%d , 1)' %(t0+i+5000)) + print('restart to commit') + self.restart_taosd('db') + + for i in range(100, 200): + tdSql.execute('insert into t5 values (%d , 2)' %(t0+i)) + + for i in range(200, 5000): + tdSql.execute('insert into t5 values (%d , 2)' %(t0+i)) + + for i in range(100, 200): + tdSql.execute('insert into t5 values (%d , 2)' %(t0+i+5000)) + + print('check query result before restart') + tdSql.query('select * from db.t5;') + for i in range(100): + tdSql.checkData(i, 1, 1) + for i in range(100, 5000): + tdSql.checkData(i, 1, 2) + for i in range(5000, 5100): + tdSql.checkData(i, 1, 1) + for i in range(5100, 5200): + tdSql.checkData(i, 1, 2) + + print('check query result after restart') + self.restart_taosd('db') + tdSql.query('select * from db.t5;') + for i in range(100): + tdSql.checkData(i, 1, 1) + for i in range(100, 5000): + tdSql.checkData(i, 1, 2) + for i in range(5000, 5100): + tdSql.checkData(i, 1, 1) + for i in range(5100, 5200): + tdSql.checkData(i, 1, 2) + + print("==================================6 start") + print("==========step1") + print("create table && insert data") + tdSql.execute('create table t6 (ts timestamp, a int)') + insert_rows = 200 + t0 = 1603152000000 + tdLog.info("insert %d rows" % insert_rows) + for i in range(insert_rows): + tdSql.execute('insert into t6 values (%d , 1)' %(t0+i)) + print('restart to commit') + self.restart_taosd('db') + + for i in range(insert_rows): + tdSql.execute('insert into t6 values (%d , 1)' %(t0+i+5000)) + print('restart to commit') + self.restart_taosd('db') + + for i in range(-1000, 10000): + tdSql.execute('insert into t6 values (%d , 2)' %(t0+i)) + + print('check query result before restart') + tdSql.query('select * from db.t6;') + tdSql.checkRows(11000) + for i in range(11000): + tdSql.checkData(i, 1, 2) + + print('check query result after restart') + self.restart_taosd('db') + tdSql.query('select * from db.t6;') + tdSql.checkRows(11000) + for i in range(11000): + tdSql.checkData(i, 1, 2) + + + print("==================================7 start") + print("==========step1") + print("create table && insert data") + tdSql.execute('create table t7 (ts timestamp, a int)') + insert_rows = 200 + t0 = 1603152000000 + tdLog.info("insert %d rows" % insert_rows) + for i in range(insert_rows): + tdSql.execute('insert into t7 values (%d , 1)' %(t0+i)) + + for i in range(insert_rows): + tdSql.execute('insert into t7 values (%d , 1)' %(t0+i+5000)) + print('restart to commit') + self.restart_taosd('db') + + for i in range(-1000, 10000): + tdSql.execute('insert into t7 values (%d , 2)' %(t0+i)) + + print('check query result before restart') + tdSql.query('select * from db.t7;') + tdSql.checkRows(11000) + for i in range(11000): + tdSql.checkData(i, 1, 2) + + print('check query result after restart') + self.restart_taosd('db') + tdSql.query('select * from db.t7;') + tdSql.checkRows(11000) + for i in range(11000): + tdSql.checkData(i, 1, 2) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/update/merge_commit_data2_update0.py b/tests/pytest/update/merge_commit_data2_update0.py new file mode 100644 index 0000000000000000000000000000000000000000..7e3c65a0a2f2e3c0b01977b0b28cb0ec8a2530ea --- /dev/null +++ b/tests/pytest/update/merge_commit_data2_update0.py @@ -0,0 +1,384 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import time + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + + def restart_taosd(self,db): + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.execute("use %s;" % db) + + def date_to_timestamp_microseconds(self, date): + datetime_obj = datetime.strptime(date, "%Y-%m-%d %H:%M:%S.%f") + obj_stamp = int(time.mktime(datetime_obj.timetuple()) * 1000.0 + datetime_obj.microsecond / 1000.0) + return obj_stamp + + def timestamp_microseconds_to_date(self, timestamp): + d = datetime.datetime.fromtimestamp(timestamp/1000) + str1 = d.strftime("%Y-%m-%d %H:%M:%S.%f") + return str1 + + + + def run(self): + print("==========step1") + print("create table && insert data") + sql = 'reset query cache' + tdSql.execute(sql) + sql = 'drop database if exists db' + tdSql.execute(sql) + sql = 'create database db update 0 days 30;' + tdSql.execute(sql) + sql = 'use db;' + tdSql.execute(sql) + tdSql.execute('create table t1 (ts timestamp, a int)') + + + print("==================================1 start") + insert_rows = 200 + t0 = 1603152000000 + tdLog.info("insert %d rows" % insert_rows) + for i in range(insert_rows): + tdSql.execute('insert into t1 values (%d , 1)' %(t0+i)) + print("==========step2") + print("restart to commit ") + self.restart_taosd('db') + + print('check query result after restart') + tdSql.query('select * from db.t1;') + for i in range(insert_rows): + tdSql.checkData(i, 1, 1) + + print("==========step3") + print('insert data') + for i in range(insert_rows): + tdSql.execute('insert into t1 values (%d , 1)' %(t0+i+5000)) + print('check query result before restart') + tdSql.query('select * from db.t1;') + for i in range(insert_rows, insert_rows*2): + tdSql.checkData(i, 1, 1) + + self.restart_taosd('db') + print('check query result after restart') + tdSql.query('select * from db.t1;') + for i in range(insert_rows, insert_rows*2): + tdSql.checkData(i, 1, 1) + + print("==========step4") + print('insert data') + for i in range(insert_rows): + tdSql.execute('insert into t1 values (%d , 2)' %(t0+i)) + for i in range(insert_rows): + tdSql.execute('insert into t1 values (%d , 1)' %(t0+i+5000)) + + print('check query result before restart') + tdSql.query('select * from db.t1;') + print(tdSql.queryResult) + for i in range(insert_rows): + tdSql.checkData(i, 1, 1) + for i in range(insert_rows, insert_rows*2): + tdSql.checkData(i, 1, 1) + + print('check query result after restart') + self.restart_taosd('db') + tdSql.query('select * from db.t1;') + # print(tdSql.queryResult) + for i in range(insert_rows): + tdSql.checkData(i, 1, 1) + for i in range(insert_rows, insert_rows*2): + tdSql.checkData(i, 1, 1) + + print("==================================2 start") + print("==========step1") + print("create table && insert data") + tdSql.execute('create table t2 (ts timestamp, a int)') + insert_rows = 200 + t0 = 1603152000000 + tdLog.info("insert %d rows" % insert_rows) + for i in range(insert_rows): + tdSql.execute('insert into t2 values (%d , 1)' %(t0+i)) + print('restart to commit') + self.restart_taosd('db') + for i in range(insert_rows): + tdSql.execute('insert into t2 values (%d , 1)' %(t0+i+5000)) + print('restart to commit') + self.restart_taosd('db') + + for k in range(10): + for i in range(10): + tdSql.execute('insert into t2 values (%d , 1)' %(t0 + 200 + k * 10 + i)) + # print('insert into t2 values (%d , 1)' %(t0 + 200 + k * 10 + i)) + + + print("==========step2") + print('check query result before restart') + tdSql.query('select * from db.t2;') + for i in range(insert_rows*2+100): + tdSql.checkData(i, 1, 1) + # print(tdSql.queryResult) + print('restart to commit') + self.restart_taosd('db') + print('check query result after restart') + tdSql.query('select * from db.t2;') + for i in range(insert_rows*2+100): + tdSql.checkData(i, 1, 1) + + + print("==================================3 start") + print("==========step1") + print("create table && insert data") + tdSql.execute('create table t3 (ts timestamp, a int)') + insert_rows = 200 + t0 = 1603152000000 + tdLog.info("insert %d rows" % insert_rows) + for i in range(insert_rows): + tdSql.execute('insert into t3 values (%d , 1)' %(t0+i)) + print('restart to commit') + self.restart_taosd('db') + + for i in range(insert_rows): + tdSql.execute('insert into t3 values (%d , 1)' %(t0+i+5000)) + print('restart to commit') + self.restart_taosd('db') + + for i in range(5200): + tdSql.execute('insert into t3 values (%d , 2)' %(t0+i)) + + print("==========step2") + print('check query result before restart') + tdSql.query('select * from db.t3;') + for i in range(200): + tdSql.checkData(i, 1, 1) + for i in range(200, 5000): + tdSql.checkData(i, 1, 2) + for i in range(5000, 5200): + tdSql.checkData(i, 1, 1) + # print(tdSql.queryResult) + print('restart to commit') + self.restart_taosd('db') + print('check query result after restart') + tdSql.query('select * from db.t3;') + for i in range(200): + tdSql.checkData(i, 1, 1) + for i in range(200, 5000): + tdSql.checkData(i, 1, 2) + for i in range(5000, 5200): + tdSql.checkData(i, 1, 1) + + print("==================================4 start") + print("==========step1") + print("create table && insert data") + tdSql.execute('create table t4 (ts timestamp, a int)') + insert_rows = 200 + t0 = 1603152000000 + tdLog.info("insert %d rows" % insert_rows) + for i in range(insert_rows): + tdSql.execute('insert into t4 values (%d , 1)' %(t0+i)) + print('restart to commit') + self.restart_taosd('db') + + for i in range(insert_rows): + tdSql.execute('insert into t4 values (%d , 1)' %(t0+i+5000)) + print('restart to commit') + self.restart_taosd('db') + + for i in range(100): + tdSql.execute('insert into t4 values (%d , 2)' %(t0+i)) + + for i in range(200, 5000): + tdSql.execute('insert into t4 values (%d , 2)' %(t0+i)) + + for i in range(100): + tdSql.execute('insert into t4 values (%d , 1)' %(t0+i+5000)) + + print('check query result before restart') + tdSql.query('select * from db.t4;') + for i in range(200): + tdSql.checkData(i, 1, 1) + for i in range(200, 5000): + tdSql.checkData(i, 1, 2) + for i in range(5000, 5200): + tdSql.checkData(i, 1, 1) + + print('check query result after restart') + self.restart_taosd('db') + tdSql.query('select * from db.t4;') + for i in range(200): + tdSql.checkData(i, 1, 1) + for i in range(200, 5000): + tdSql.checkData(i, 1, 2) + for i in range(5000, 5200): + tdSql.checkData(i, 1, 1) + # + print("==================================5 start") + print("==========step1") + print("create table && insert data") + tdSql.execute('create table t5 (ts timestamp, a int)') + insert_rows = 200 + t0 = 1603152000000 + tdLog.info("insert %d rows" % insert_rows) + for i in range(insert_rows): + tdSql.execute('insert into t5 values (%d , 1)' %(t0+i)) + print('restart to commit') + self.restart_taosd('db') + + for i in range(insert_rows): + tdSql.execute('insert into t5 values (%d , 1)' %(t0+i+5000)) + print('restart to commit') + self.restart_taosd('db') + + for i in range(100, 200): + tdSql.execute('insert into t5 values (%d , 2)' %(t0+i)) + + for i in range(200, 5000): + tdSql.execute('insert into t5 values (%d , 2)' %(t0+i)) + + for i in range(100, 200): + tdSql.execute('insert into t5 values (%d , 2)' %(t0+i+5000)) + + print('check query result before restart') + tdSql.query('select * from db.t5;') + for i in range(200): + tdSql.checkData(i, 1, 1) + for i in range(200, 5000): + tdSql.checkData(i, 1, 2) + for i in range(5000, 5200): + tdSql.checkData(i, 1, 1) + + print('check query result after restart') + self.restart_taosd('db') + tdSql.query('select * from db.t5;') + for i in range(200): + tdSql.checkData(i, 1, 1) + for i in range(200, 5000): + tdSql.checkData(i, 1, 2) + for i in range(5000, 5200): + tdSql.checkData(i, 1, 1) + + print("==================================6 start") + print("==========step1") + print("create table && insert data") + tdSql.execute('create table t6 (ts timestamp, a int)') + insert_rows = 200 + t0 = 1603152000000 + tdLog.info("insert %d rows" % insert_rows) + for i in range(insert_rows): + tdSql.execute('insert into t6 values (%d , 1)' %(t0+i)) + print('restart to commit') + self.restart_taosd('db') + + for i in range(insert_rows): + tdSql.execute('insert into t6 values (%d , 1)' %(t0+i+5000)) + print('restart to commit') + self.restart_taosd('db') + + for i in range(-1000, 10000): + tdSql.execute('insert into t6 values (%d , 2)' %(t0+i)) + + print('check query result before restart') + tdSql.query('select * from db.t6;') + tdSql.checkRows(11000) + for i in range(1000): + tdSql.checkData(i, 1, 2) + for i in range(1000,1200): + tdSql.checkData(i, 1, 1) + for i in range(1200,6000): + tdSql.checkData(i, 1, 2) + for i in range(6000,6200): + tdSql.checkData(i, 1, 1) + for i in range(6200, 11000): + tdSql.checkData(i, 1, 2) + + print('check query result after restart') + self.restart_taosd('db') + tdSql.query('select * from db.t6;') + tdSql.checkRows(11000) + for i in range(1000): + tdSql.checkData(i, 1, 2) + for i in range(1000,1200): + tdSql.checkData(i, 1, 1) + for i in range(1200,6000): + tdSql.checkData(i, 1, 2) + for i in range(6000,6200): + tdSql.checkData(i, 1, 1) + for i in range(6200, 11000): + tdSql.checkData(i, 1, 2) + + + print("==================================7 start") + print("==========step1") + print("create table && insert data") + tdSql.execute('create table t7 (ts timestamp, a int)') + insert_rows = 200 + t0 = 1603152000000 + tdLog.info("insert %d rows" % insert_rows) + for i in range(insert_rows): + tdSql.execute('insert into t7 values (%d , 1)' %(t0+i)) + + for i in range(insert_rows): + tdSql.execute('insert into t7 values (%d , 1)' %(t0+i+5000)) + print('restart to commit') + self.restart_taosd('db') + + for i in range(-1000, 10000): + tdSql.execute('insert into t7 values (%d , 2)' %(t0+i)) + + print('check query result before restart') + tdSql.query('select * from db.t7;') + tdSql.checkRows(11000) + for i in range(1000): + tdSql.checkData(i, 1, 2) + for i in range(1000,1200): + tdSql.checkData(i, 1, 1) + for i in range(1200,6000): + tdSql.checkData(i, 1, 2) + for i in range(6000,6200): + tdSql.checkData(i, 1, 1) + for i in range(6200, 11000): + tdSql.checkData(i, 1, 2) + + print('check query result after restart') + self.restart_taosd('db') + tdSql.query('select * from db.t7;') + tdSql.checkRows(11000) + for i in range(1000): + tdSql.checkData(i, 1, 2) + for i in range(1000,1200): + tdSql.checkData(i, 1, 1) + for i in range(1200,6000): + tdSql.checkData(i, 1, 2) + for i in range(6000,6200): + tdSql.checkData(i, 1, 1) + for i in range(6200, 11000): + tdSql.checkData(i, 1, 2) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/update/merge_commit_last-0.py b/tests/pytest/update/merge_commit_last-0.py new file mode 100644 index 0000000000000000000000000000000000000000..8a247f38091467f69c74c57f00341adde0e15992 --- /dev/null +++ b/tests/pytest/update/merge_commit_last-0.py @@ -0,0 +1,309 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.ts = 1603152000000 + + def restartTaosd(self): + tdDnodes.stop(1) + tdDnodes.startWithoutSleep(1) + tdSql.execute("use db") + + def run(self): + tdSql.prepare() + + print("==============step 1: UPDATE THE LAST RECORD REPEATEDLY") + tdSql.execute("create table t1 (ts timestamp, a int)") + + for i in range(5): + tdSql.execute("insert into t1 values(%d, %d)" % (self.ts, i)) + self.restartTaosd() + tdSql.query("select * from t1") + tdSql.checkRows(1) + tdSql.checkData(0, 1, 0) + + print("==============step 2: UPDATE THE WHOLE LAST BLOCK") + tdSql.execute("create table t2 (ts timestamp, a int)") + + for i in range(50): + tdSql.execute("insert into t2 values(%d, 1)" % (self.ts + i)) + + self.restartTaosd() + tdSql.query("select * from t2") + tdSql.checkRows(50) + tdSql.query("select sum(a) from t2") + tdSql.checkData(0, 0, 50) + + for i in range(50): + tdSql.execute("insert into t2 values(%d, 2)" % (self.ts + i)) + tdSql.query("select * from t2") + tdSql.checkRows(50) + tdSql.query("select sum(a) from t2") + tdSql.checkData(0, 0, 50) + + self.restartTaosd() + tdSql.query("select * from t2") + tdSql.checkRows(50) + tdSql.query("select sum(a) from t2") + tdSql.checkData(0, 0, 50) + + print("==============step 3: UPDATE PART OF THE LAST BLOCK") + tdSql.execute("create table t3 (ts timestamp, a int)") + + for i in range(50): + tdSql.execute("insert into t3 values(%d, 1)" % (self.ts + i)) + self.restartTaosd() + tdSql.query("select * from t3") + tdSql.checkRows(50) + tdSql.query("select sum(a) from t3") + tdSql.checkData(0, 0, 50) + + for i in range(25): + tdSql.execute("insert into t3 values(%d, 2)" % (self.ts + i)) + + tdSql.query("select * from t3") + tdSql.checkRows(50) + tdSql.query("select sum(a) from t3") + tdSql.checkData(0, 0, 50) + + self.restartTaosd() + tdSql.query("select * from t3") + tdSql.checkRows(50) + tdSql.query("select sum(a) from t3") + tdSql.checkData(0, 0, 50) + + print("==============step 4: UPDATE AND INSERT APPEND AT END OF DATA") + tdSql.execute("create table t4 (ts timestamp, a int)") + + for i in range(50): + tdSql.execute("insert into t4 values(%d, 1)" % (self.ts + i)) + + self.restartTaosd() + tdSql.query("select * from t4") + tdSql.checkRows(50) + tdSql.query("select sum(a) from t4") + tdSql.checkData(0, 0, 50) + + for i in range(25): + tdSql.execute("insert into t4 values(%d, 2)" % (self.ts + i)) + + for i in range(50, 60): + tdSql.execute("insert into t4 values(%d, 2)" % (self.ts + i)) + + tdSql.query("select * from t4") + tdSql.checkRows(60) + tdSql.query("select sum(a) from t4") + tdSql.checkData(0, 0, 70) + + self.restartTaosd() + tdSql.query("select * from t4") + tdSql.checkRows(60) + tdSql.query("select sum(a) from t4") + tdSql.checkData(0, 0, 70) + + print("==============step 5: UPDATE AND INSERT PREPEND SOME DATA") + tdSql.execute("create table t5 (ts timestamp, a int)") + + for i in range(50): + tdSql.execute("insert into t5 values(%d, 1)" % (self.ts + i)) + + self.restartTaosd() + tdSql.query("select * from t5") + tdSql.checkRows(50) + tdSql.query("select sum(a) from t5") + tdSql.checkData(0, 0, 50) + + for i in range(-10, 0): + tdSql.execute("insert into t5 values(%d, 2)" % (self.ts + i)) + + for i in range(25): + tdSql.execute("insert into t5 values(%d, 2)" % (self.ts + i)) + + tdSql.query("select * from t5") + tdSql.checkRows(60) + tdSql.query("select sum(a) from t5") + tdSql.checkData(0, 0, 70) + + self.restartTaosd() + tdSql.query("select * from t5") + tdSql.checkRows(60) + tdSql.query("select sum(a) from t5") + tdSql.checkData(0, 0, 70) + + for i in range(-10, 0): + tdSql.execute("insert into t5 values(%d, 3)" % (self.ts + i)) + + for i in range(25, 50): + tdSql.execute("insert into t5 values(%d, 3)" % (self.ts + i)) + + tdSql.query("select * from t5") + tdSql.checkRows(60) + tdSql.query("select sum(a) from t5") + tdSql.checkData(0, 0, 70) + + self.restartTaosd() + tdSql.query("select * from t5") + tdSql.checkRows(60) + tdSql.query("select sum(a) from t5") + tdSql.checkData(0, 0, 70) + + + print("==============step 6: INSERT AHEAD A LOT OF DATA") + tdSql.execute("create table t6 (ts timestamp, a int)") + + for i in range(50): + tdSql.execute("insert into t6 values(%d, 1)" % (self.ts + i)) + + self.restartTaosd() + tdSql.query("select * from t6") + tdSql.checkRows(50) + tdSql.query("select sum(a) from t6") + tdSql.checkData(0, 0, 50) + + for i in range(-1000, 0): + tdSql.execute("insert into t6 values(%d, 2)" % (self.ts + i)) + + tdSql.query("select * from t6") + tdSql.checkRows(1050) + tdSql.query("select sum(a) from t6") + tdSql.checkData(0, 0, 2050) + + self.restartTaosd() + tdSql.query("select * from t6") + tdSql.checkRows(1050) + tdSql.query("select sum(a) from t6") + tdSql.checkData(0, 0, 2050) + + print("==============step 7: INSERT AHEAD A LOT AND UPDATE") + tdSql.execute("create table t7 (ts timestamp, a int)") + + for i in range(50): + tdSql.execute("insert into t7 values(%d, 1)" % (self.ts + i)) + + self.restartTaosd() + tdSql.query("select * from t7") + tdSql.checkRows(50) + tdSql.query("select sum(a) from t7") + tdSql.checkData(0, 0, 50) + + for i in range(-1000, 25): + tdSql.execute("insert into t7 values(%d, 2)" % (self.ts + i)) + + tdSql.query("select * from t7") + tdSql.checkRows(1050) + tdSql.query("select sum(a) from t7") + tdSql.checkData(0, 0, 2050) + + self.restartTaosd() + tdSql.query("select * from t7") + tdSql.checkRows(1050) + tdSql.query("select sum(a) from t7") + tdSql.checkData(0, 0, 2050) + + print("==============step 8: INSERT AFTER A LOT AND UPDATE") + tdSql.execute("create table t8 (ts timestamp, a int)") + + for i in range(50): + tdSql.execute("insert into t8 values(%d, 1)" % (self.ts + i)) + + self.restartTaosd() + tdSql.query("select * from t8") + tdSql.checkRows(50) + tdSql.query("select sum(a) from t8") + tdSql.checkData(0, 0, 50) + + for i in range(25, 6000): + tdSql.execute("insert into t8 values(%d, 2)" % (self.ts + i)) + + tdSql.query("select * from t8") + tdSql.checkRows(6000) + tdSql.query("select sum(a) from t8") + tdSql.checkData(0, 0, 11950) + + self.restartTaosd() + tdSql.query("select * from t8") + tdSql.checkRows(6000) + tdSql.query("select sum(a) from t8") + tdSql.checkData(0, 0, 11950) + + print("==============step 9: UPDATE ONLY MIDDLE") + tdSql.execute("create table t9 (ts timestamp, a int)") + + for i in range(50): + tdSql.execute("insert into t9 values(%d, 1)" % (self.ts + i)) + + self.restartTaosd() + tdSql.query("select * from t9") + tdSql.checkRows(50) + tdSql.query("select sum(a) from t9") + tdSql.checkData(0, 0, 50) + + for i in range(20, 30): + tdSql.execute("insert into t9 values(%d, 2)" % (self.ts + i)) + + tdSql.query("select * from t9") + tdSql.checkRows(50) + tdSql.query("select sum(a) from t9") + tdSql.checkData(0, 0, 50) + + self.restartTaosd() + tdSql.query("select * from t9") + tdSql.checkRows(50) + tdSql.query("select sum(a) from t9") + tdSql.checkData(0, 0, 50) + + print("==============step 10: A LOT OF DATA COVER THE WHOLE BLOCK") + tdSql.execute("create table t10 (ts timestamp, a int)") + + for i in range(50): + tdSql.execute("insert into t10 values(%d, 1)" % (self.ts + i)) + + self.restartTaosd() + tdSql.query("select * from t10") + tdSql.checkRows(50) + tdSql.query("select sum(a) from t10") + tdSql.checkData(0, 0, 50) + + for i in range(-4000, 4000): + tdSql.execute("insert into t10 values(%d, 2)" % (self.ts + i)) + + tdSql.query("select * from t10") + tdSql.checkRows(8000) + tdSql.query("select sum(a) from t10") + tdSql.checkData(0, 0, 15950) + + self.restartTaosd() + tdSql.query("select * from t10") + tdSql.checkRows(8000) + tdSql.query("select sum(a) from t10") + tdSql.checkData(0, 0, 15950) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/update/merge_commit_last.py b/tests/pytest/update/merge_commit_last.py new file mode 100644 index 0000000000000000000000000000000000000000..183cca0a1e40fd995daaed0f271bb5083838a78f --- /dev/null +++ b/tests/pytest/update/merge_commit_last.py @@ -0,0 +1,321 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.ts = 1603152000000 + + def restartTaosd(self): + tdDnodes.stop(1) + tdDnodes.startWithoutSleep(1) + tdSql.execute("use udb") + + def run(self): + tdSql.prepare() + + tdSql.execute("create database udb update 1 days 30") + tdSql.execute("use udb") + + print("==============step 1: UPDATE THE LAST RECORD REPEATEDLY") + tdSql.execute("create table t1 (ts timestamp, a int)") + + for i in range(5): + tdSql.execute("insert into t1 values(%d, %d)" % (self.ts, i)) + self.restartTaosd() + tdSql.query("select * from t1") + tdSql.checkRows(1) + tdSql.checkData(0, 1, i) + + print("==============step 2: UPDATE THE WHOLE LAST BLOCK") + tdSql.execute("create table t2 (ts timestamp, a int)") + + for i in range(50): + tdSql.execute("insert into t2 values(%d, 1)" % (self.ts + i)) + self.restartTaosd() + tdSql.query("select * from t2") + tdSql.checkRows(50) + for i in range(50): + tdSql.checkData(i, 1, 1) + + for i in range(50): + tdSql.execute("insert into t2 values(%d, 2)" % (self.ts + i)) + tdSql.query("select * from t2") + for i in range(50): + tdSql.checkData(i, 1, 2) + + self.restartTaosd() + tdSql.query("select * from t2") + tdSql.checkRows(50) + for i in range(50): + tdSql.checkData(i, 1, 2) + + print("==============step 3: UPDATE PART OF THE LAST BLOCK") + tdSql.execute("create table t3 (ts timestamp, a int)") + + for i in range(50): + tdSql.execute("insert into t3 values(%d, 1)" % (self.ts + i)) + self.restartTaosd() + tdSql.query("select * from t3") + tdSql.checkRows(50) + for i in range(50): + tdSql.checkData(i, 1, 1) + + for i in range(25): + tdSql.execute("insert into t3 values(%d, 2)" % (self.ts + i)) + + tdSql.query("select * from t3") + for i in range(25): + tdSql.checkData(i, 1, 2) + for i in range(25, 50): + tdSql.checkData(i, 1, 1) + + self.restartTaosd() + tdSql.query("select * from t3") + tdSql.checkRows(50) + for i in range(25): + tdSql.checkData(i, 1, 2) + for i in range(25, 50): + tdSql.checkData(i, 1, 1) + + print("==============step 4: UPDATE AND INSERT APPEND AT END OF DATA") + tdSql.execute("create table t4 (ts timestamp, a int)") + + for i in range(50): + tdSql.execute("insert into t4 values(%d, 1)" % (self.ts + i)) + + self.restartTaosd() + tdSql.query("select * from t4") + tdSql.checkRows(50) + for i in range(50): + tdSql.checkData(i, 1, 1) + + for i in range(25): + tdSql.execute("insert into t4 values(%d, 2)" % (self.ts + i)) + + for i in range(50, 60): + tdSql.execute("insert into t4 values(%d, 2)" % (self.ts + i)) + + tdSql.query("select * from t4") + tdSql.checkRows(60) + for i in range(25): + tdSql.checkData(i, 1, 2) + for i in range(25, 50): + tdSql.checkData(i, 1, 1) + for i in range(50, 60): + tdSql.checkData(i, 1, 2) + + self.restartTaosd() + tdSql.query("select * from t4") + tdSql.checkRows(60) + for i in range(25): + tdSql.checkData(i, 1, 2) + for i in range(25, 50): + tdSql.checkData(i, 1, 1) + for i in range(50, 60): + tdSql.checkData(i, 1, 2) + + print("==============step 5: UPDATE AND INSERT PREPEND SOME DATA") + tdSql.execute("create table t5 (ts timestamp, a int)") + + for i in range(50): + tdSql.execute("insert into t5 values(%d, 1)" % (self.ts + i)) + + self.restartTaosd() + tdSql.query("select * from t5") + tdSql.checkRows(50) + for i in range(50): + tdSql.checkData(i, 1, 1) + + for i in range(-10, 0): + tdSql.execute("insert into t5 values(%d, 2)" % (self.ts + i)) + + for i in range(25): + tdSql.execute("insert into t5 values(%d, 2)" % (self.ts + i)) + + tdSql.query("select * from t5") + tdSql.checkRows(60) + tdSql.query("select sum(a) from t5") + tdSql.checkData(0, 0, 95) + + self.restartTaosd() + tdSql.query("select * from t5") + tdSql.checkRows(60) + tdSql.query("select sum(a) from t5") + tdSql.checkData(0, 0, 95) + + for i in range(-10, 0): + tdSql.execute("insert into t5 values(%d, 3)" % (self.ts + i)) + + for i in range(25, 50): + tdSql.execute("insert into t5 values(%d, 3)" % (self.ts + i)) + + tdSql.query("select * from t5") + tdSql.checkRows(60) + tdSql.query("select sum(a) from t5") + tdSql.checkData(0, 0, 155) + + self.restartTaosd() + tdSql.query("select * from t5") + tdSql.checkRows(60) + tdSql.query("select sum(a) from t5") + tdSql.checkData(0, 0, 155) + + + print("==============step 6: INSERT AHEAD A LOT OF DATA") + tdSql.execute("create table t6 (ts timestamp, a int)") + + for i in range(50): + tdSql.execute("insert into t6 values(%d, 1)" % (self.ts + i)) + + self.restartTaosd() + tdSql.query("select * from t6") + tdSql.checkRows(50) + tdSql.query("select sum(a) from t6") + tdSql.checkData(0, 0, 50) + + for i in range(-1000, 0): + tdSql.execute("insert into t6 values(%d, 2)" % (self.ts + i)) + + tdSql.query("select * from t6") + tdSql.checkRows(1050) + tdSql.query("select sum(a) from t6") + tdSql.checkData(0, 0, 2050) + + self.restartTaosd() + tdSql.query("select * from t6") + tdSql.checkRows(1050) + tdSql.query("select sum(a) from t6") + tdSql.checkData(0, 0, 2050) + + print("==============step 7: INSERT AHEAD A LOT AND UPDATE") + tdSql.execute("create table t7 (ts timestamp, a int)") + + for i in range(50): + tdSql.execute("insert into t7 values(%d, 1)" % (self.ts + i)) + + self.restartTaosd() + tdSql.query("select * from t7") + tdSql.checkRows(50) + tdSql.query("select sum(a) from t7") + tdSql.checkData(0, 0, 50) + + for i in range(-1000, 25): + tdSql.execute("insert into t7 values(%d, 2)" % (self.ts + i)) + + tdSql.query("select * from t7") + tdSql.checkRows(1050) + tdSql.query("select sum(a) from t7") + tdSql.checkData(0, 0, 2075) + + self.restartTaosd() + tdSql.query("select * from t7") + tdSql.checkRows(1050) + tdSql.query("select sum(a) from t7") + tdSql.checkData(0, 0, 2075) + + print("==============step 8: INSERT AFTER A LOT AND UPDATE") + tdSql.execute("create table t8 (ts timestamp, a int)") + + for i in range(50): + tdSql.execute("insert into t8 values(%d, 1)" % (self.ts + i)) + + self.restartTaosd() + tdSql.query("select * from t8") + tdSql.checkRows(50) + tdSql.query("select sum(a) from t8") + tdSql.checkData(0, 0, 50) + + for i in range(25, 6000): + tdSql.execute("insert into t8 values(%d, 2)" % (self.ts + i)) + + tdSql.query("select * from t8") + tdSql.checkRows(6000) + tdSql.query("select sum(a) from t8") + tdSql.checkData(0, 0, 11975) + + self.restartTaosd() + tdSql.query("select * from t8") + tdSql.checkRows(6000) + tdSql.query("select sum(a) from t8") + tdSql.checkData(0, 0, 11975) + + print("==============step 9: UPDATE ONLY MIDDLE") + tdSql.execute("create table t9 (ts timestamp, a int)") + + for i in range(50): + tdSql.execute("insert into t9 values(%d, 1)" % (self.ts + i)) + + self.restartTaosd() + tdSql.query("select * from t9") + tdSql.checkRows(50) + tdSql.query("select sum(a) from t9") + tdSql.checkData(0, 0, 50) + + for i in range(20, 30): + tdSql.execute("insert into t9 values(%d, 2)" % (self.ts + i)) + + tdSql.query("select * from t9") + tdSql.checkRows(50) + tdSql.query("select sum(a) from t9") + tdSql.checkData(0, 0, 60) + + self.restartTaosd() + tdSql.query("select * from t9") + tdSql.checkRows(50) + tdSql.query("select sum(a) from t9") + tdSql.checkData(0, 0, 60) + + print("==============step 10: A LOT OF DATA COVER THE WHOLE BLOCK") + tdSql.execute("create table t10 (ts timestamp, a int)") + + for i in range(50): + tdSql.execute("insert into t10 values(%d, 1)" % (self.ts + i)) + + self.restartTaosd() + tdSql.query("select * from t10") + tdSql.checkRows(50) + tdSql.query("select sum(a) from t10") + tdSql.checkData(0, 0, 50) + + for i in range(-4000, 4000): + tdSql.execute("insert into t10 values(%d, 2)" % (self.ts + i)) + + tdSql.query("select * from t10") + tdSql.checkRows(8000) + tdSql.query("select sum(a) from t10") + tdSql.checkData(0, 0, 16000) + + self.restartTaosd() + tdSql.query("select * from t10") + tdSql.checkRows(8000) + tdSql.query("select sum(a) from t10") + tdSql.checkData(0, 0, 16000) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/update/updateWithClientMerge.py b/tests/pytest/update/updateWithClientMerge.py new file mode 100644 index 0000000000000000000000000000000000000000..3632d7719387f7da824aadd1bbde5e2a244dd251 --- /dev/null +++ b/tests/pytest/update/updateWithClientMerge.py @@ -0,0 +1,50 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + + updatecfgDict={'clientMerge':1} + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.ts = 1606700000000 + + def run(self): + # TS-932 + tdSql.execute("create database db3 update 2") + tdSql.execute("use db3") + tdSql.execute("drop table if exists tb") + tdSql.execute("create table tb (ts timestamp, c1 int, c2 int, c3 int)") + tdSql.execute("insert into tb values(%d, 1, 2, 3)(%d, null, 4, 5)(%d, 6, null, null)" % (self.ts, self.ts, self.ts)) + + tdSql.query("select * from tb") + tdSql.checkData(0, 1, 6) + tdSql.checkData(0, 2, None) + tdSql.checkData(0, 3, None) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/update/update_options.py b/tests/pytest/update/update_options.py new file mode 100644 index 0000000000000000000000000000000000000000..e119eb619c2bff14c79c27fa91791c6ae13dde3c --- /dev/null +++ b/tests/pytest/update/update_options.py @@ -0,0 +1,119 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.ts = 1606700000000 + + def restartTaosd(self): + tdDnodes.stop(1) + tdDnodes.startWithoutSleep(1) + tdSql.execute("use db") + + def run(self): + tdSql.prepare() + + # test case for TD-2279 + print("==============step1") + tdSql.execute("create table t (ts timestamp, a int)") + + for i in range(3276): + tdSql.execute("insert into t values(%d, 0)" % (self.ts + i)) + + newTs = 1606700010000 + for i in range(3275): + tdSql.execute("insert into t values(%d, 0)" % (self.ts + i)) + tdSql.execute("insert into t values(%d, 0)" % 1606700013280) + + self.restartTaosd() + + for i in range(1606700003275, 1606700006609): + tdSql.execute("insert into t values(%d, 0)" % i) + tdSql.execute("insert into t values(%d, 0)" % 1606700006612) + + self.restartTaosd() + + tdSql.execute("insert into t values(%d, 0)" % 1606700006610) + tdSql.query("select * from t") + tdSql.checkRows(6612) + + tdDnodes.stop(1) + tdDnodes.startWithoutSleep(1) + tdLog.sleep(3) + + # test case for https://jira.taosdata.com:18080/browse/TS-402 + tdLog.info("test case for update option 1") + tdSql.execute("create database test update 1") + tdSql.execute("use test") + + tdSql.execute("create table tb (ts timestamp, c1 int, c2 int, c3 int)") + tdSql.execute("insert into tb values(%d, 1, 2, 3)(%d, null, null, 9)" % (self.ts, self.ts)) + + tdSql.query("select * from tb") + tdSql.checkRows(1) + tdSql.checkData(0, 1, None) + tdSql.checkData(0, 2, None) + tdSql.checkData(0, 3, 9) + + tdSql.execute("drop table if exists tb") + tdSql.execute("create table tb (ts timestamp, c1 int, c2 int, c3 int)") + tdSql.execute("insert into tb values(%d, 1, 2, 3)(%d, null, 4, 5)(%d, 6, null, 7)" % (self.ts, self.ts, self.ts)) + + tdSql.query("select * from tb") + tdSql.checkRows(1) + tdSql.checkData(0, 1, 6) + tdSql.checkData(0, 2, None) + tdSql.checkData(0, 3, 7) + + # https://jira.taosdata.com:18080/browse/TS-424 + tdLog.info("test case for update option 2") + tdSql.execute("create database db2 update 2") + tdSql.execute("use db2") + + tdSql.execute("create table tb (ts timestamp, c1 int, c2 int, c3 int)") + tdSql.execute("insert into tb values(%d, 1, 2, 3)(%d, null, null, 9)" % (self.ts, self.ts)) + + tdSql.query("select * from tb") + tdSql.checkRows(1) + tdSql.checkData(0, 1, 1) + tdSql.checkData(0, 2, 2) + tdSql.checkData(0, 3, 9) + + tdSql.execute("drop table if exists tb") + tdSql.execute("create table tb (ts timestamp, c1 int, c2 int, c3 int)") + tdSql.execute("insert into tb values(%d, 1, 2, 3)(%d, null, 4, 5)(%d, 6, null, 7)" % (self.ts, self.ts, self.ts)) + + tdSql.query("select * from tb") + tdSql.checkRows(1) + tdSql.checkData(0, 1, 6) + tdSql.checkData(0, 2, 4) + tdSql.checkData(0, 3, 7) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/user/__init__.py b/tests/pytest/user/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/pytest/user/pass_len.py b/tests/pytest/user/pass_len.py new file mode 100644 index 0000000000000000000000000000000000000000..346b8424fe325a214b798c58b06c3e3cfb0e4d39 --- /dev/null +++ b/tests/pytest/user/pass_len.py @@ -0,0 +1,63 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + print("==============step1") + try: + tdSql.execute("create user abc pass '123456'") + except Exception as e: + tdLog.exit(e) + print("create user abc pass '123456'") + + print("==============step2") + try: + tdSql.execute("alter user abc pass 'taosdata'") + except Exception as e: + tdLog.exit(e) + print("alter user abc pass 'taosdata'") + + print("==============step3") + try: + tdSql.execute("alter user abc pass ''") + except Exception as e: + print("alter user abc pass ''") + else: + tdLog.exit("Error: alert user abc pass''") + + print("==============step4") + try: + tdSql.execute("alter user abc pass null") + except Exception as e: + print("alter user abc pass null") + else: + tdLog.exit("Error: alter user abc pass null") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/user/user_create.py b/tests/pytest/user/user_create.py new file mode 100644 index 0000000000000000000000000000000000000000..a00f670a36778e5ea2191ac4e7b43930efe64b01 --- /dev/null +++ b/tests/pytest/user/user_create.py @@ -0,0 +1,54 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + print("==============step1") + try: + tdSql.execute("create user &abc PASS 'pass123'") + except Exception as e: + print(e) + + print("==============step2") + try: + tdSql.execute("create user a&bc PASS 'pass123'") + except Exception as e: + print(e) + + print("==============step3") + try: + tdSql.execute("create user '涛思' PASS 'pass123'") + except Exception as e: + print(e) + return + + tdLog.exit("create user with special character.") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/util/__init__.py b/tests/pytest/util/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/pytest/util/cases.py b/tests/pytest/util/cases.py new file mode 100644 index 0000000000000000000000000000000000000000..fd3926a6f1bc79fee81c7d438dceb8eedcb7803d --- /dev/null +++ b/tests/pytest/util/cases.py @@ -0,0 +1,149 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +import time +import datetime +import inspect +import importlib +from util.log import * + + +class TDCase: + def __init__(self, name, case): + self.name = name + self.case = case + self._logSql = True + + +class TDCases: + def __init__(self): + self.linuxCases = [] + self.windowsCases = [] + self.clusterCases = [] + + def __dynamicLoadModule(self, fileName): + moduleName = fileName.replace(".py", "").replace(os.sep, ".") + return importlib.import_module(moduleName, package='..') + + def logSql(self, logSql): + self._logSql = logSql + + def addWindows(self, name, case): + self.windowsCases.append(TDCase(name, case)) + + def addLinux(self, name, case): + self.linuxCases.append(TDCase(name, case)) + + def addCluster(self, name, case): + self.clusterCases.append(TDCase(name, case)) + + def runAllLinux(self, conn): + # TODO: load all Linux cases here + runNum = 0 + for tmp in self.linuxCases: + if tmp.name.find(fileName) != -1: + case = testModule.TDTestCase() + case.init(conn) + case.run() + case.stop() + runNum += 1 + continue + + tdLog.info("total %d Linux test case(s) executed" % (runNum)) + + def runOneLinux(self, conn, fileName): + testModule = self.__dynamicLoadModule(fileName) + + runNum = 0 + for tmp in self.linuxCases: + if tmp.name.find(fileName) != -1: + case = testModule.TDTestCase() + case.init(conn, self._logSql) + try: + case.run() + except Exception as e: + tdLog.notice(repr(e)) + tdLog.exit("%s failed" % (fileName)) + case.stop() + runNum += 1 + continue + + def runAllWindows(self, conn, fileName): + # TODO: load all Windows cases here + runNum = 0 + for tmp in self.windowsCases: + if tmp.name.find(fileName) != -1: + case = testModule.TDTestCase() + case.init(conn) + case.run() + case.stop() + runNum += 1 + continue + + tdLog.notice("total %d Windows test case(s) executed" % (runNum)) + + def runOneWindows(self, conn, fileName): + testModule = self.__dynamicLoadModule(fileName) + + runNum = 0 + for tmp in self.windowsCases: + if tmp.name.find(fileName) != -1: + case = testModule.TDTestCase() + case.init(conn, self._logSql) + try: + case.run() + except Exception as e: + tdLog.notice(repr(e)) + tdLog.exit("%s failed" % (fileName)) + case.stop() + runNum += 1 + continue + tdLog.notice("total %d Windows case(s) executed" % (runNum)) + + + def runAllCluster(self): + # TODO: load all cluster case module here + + runNum = 0 + for tmp in self.clusterCases: + if tmp.name.find(fileName) != -1: + tdLog.notice("run cases like %s" % (fileName)) + case = testModule.TDTestCase() + case.init() + case.run() + case.stop() + runNum += 1 + continue + + tdLog.notice("total %d Cluster test case(s) executed" % (runNum)) + + def runOneCluster(self, fileName): + testModule = self.__dynamicLoadModule(fileName) + + runNum = 0 + for tmp in self.clusterCases: + if tmp.name.find(fileName) != -1: + tdLog.notice("run cases like %s" % (fileName)) + case = testModule.TDTestCase() + case.init() + case.run() + case.stop() + runNum += 1 + continue + + tdLog.notice("total %d Cluster test case(s) executed" % (runNum)) + + +tdCases = TDCases() diff --git a/tests/pytest/util/common.py b/tests/pytest/util/common.py new file mode 100644 index 0000000000000000000000000000000000000000..6d387ac674ad04b8346d1d0f7aba358ac48e458d --- /dev/null +++ b/tests/pytest/util/common.py @@ -0,0 +1,59 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import random +import string +from util.sql import tdSql +from util.dnodes import tdDnodes + +class TDCom: + def init(self, conn, logSql): + tdSql.init(conn.cursor(), logSql) + + def cleanTb(self): + query_sql = "show stables" + res_row_list = tdSql.query(query_sql, True) + stb_list = map(lambda x: x[0], res_row_list) + for stb in stb_list: + tdSql.execute(f'drop table if exists {stb}') + + query_sql = "show tables" + res_row_list = tdSql.query(query_sql, True) + tb_list = map(lambda x: x[0], res_row_list) + for tb in tb_list: + tdSql.execute(f'drop table if exists {tb}') + + def getLongName(self, len, mode = "mixed"): + """ + generate long name + mode could be numbers/letters/letters_mixed/mixed + """ + if mode == "numbers": + chars = ''.join(random.choice(string.digits) for i in range(len)) + elif mode == "letters": + chars = ''.join(random.choice(string.ascii_letters.lower()) for i in range(len)) + elif mode == "letters_mixed": + chars = ''.join(random.choice(string.ascii_letters.upper() + string.ascii_letters.lower()) for i in range(len)) + else: + chars = ''.join(random.choice(string.ascii_letters.lower() + string.digits) for i in range(len)) + return chars + + def restartTaosd(self, index=1, db_name="db"): + tdDnodes.stop(index) + tdDnodes.startWithoutSleep(index) + tdSql.execute(f"use {db_name}") + + def close(self): + self.cursor.close() + +tdCom = TDCom() diff --git a/tests/pytest/util/dnodes-default.py b/tests/pytest/util/dnodes-default.py new file mode 100644 index 0000000000000000000000000000000000000000..085e08314907d6d48d02a2512d2caff87cd617e4 --- /dev/null +++ b/tests/pytest/util/dnodes-default.py @@ -0,0 +1,503 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +import os.path +import subprocess +from util.log import * + + +class TDSimClient: + def __init__(self): + self.testCluster = False + + self.cfgDict = { + "numOfLogLines": "100000000", + "numOfThreadsPerCore": "2.0", + "locale": "en_US.UTF-8", + "charset": "UTF-8", + "asyncLog": "0", + "minTablesPerVnode": "4", + "maxTablesPerVnode": "1000", + "tableIncStepPerVnode": "10000", + "maxVgroupsPerDb": "1000", + "sdbDebugFlag": "143", + "rpcDebugFlag": "135", + "tmrDebugFlag": "131", + "cDebugFlag": "135", + "udebugFlag": "135", + "jnidebugFlag": "135", + "qdebugFlag": "135", + "telemetryReporting": "0", + } + def init(self, path): + self.__init__() + self.path = path + + def getLogDir(self): + self.logDir = "%s/sim/psim/log" % (self.path) + return self.logDir + + def getCfgDir(self): + self.cfgDir = "%s/sim/psim/cfg" % (self.path) + return self.cfgDir + + def setTestCluster(self, value): + self.testCluster = value + + def addExtraCfg(self, option, value): + self.cfgDict.update({option: value}) + + def cfg(self, option, value): + cmd = "echo '%s %s' >> %s" % (option, value, self.cfgPath) + if os.system(cmd) != 0: + tdLog.exit(cmd) + + def deploy(self): + self.logDir = "%s/sim/psim/log" % (self.path) + self.cfgDir = "%s/sim/psim/cfg" % (self.path) + self.cfgPath = "%s/sim/psim/cfg/taos.cfg" % (self.path) + + cmd = "rm -rf " + self.logDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "mkdir -p " + self.logDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "rm -rf " + self.cfgDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "mkdir -p " + self.cfgDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "touch " + self.cfgPath + if os.system(cmd) != 0: + tdLog.exit(cmd) + + if self.testCluster: + self.cfg("masterIp", "192.168.0.1") + self.cfg("secondIp", "192.168.0.2") + self.cfg("logDir", self.logDir) + + for key, value in self.cfgDict.items(): + self.cfg(key, value) + + tdLog.debug("psim is deployed and configured by %s" % (self.cfgPath)) + + +class TDDnode: + def __init__(self, index): + self.index = index + self.running = 0 + self.deployed = 0 + self.testCluster = False + self.valgrind = 0 + + def init(self, path): + self.path = path + + def setTestCluster(self, value): + self.testCluster = value + + def setValgrind(self, value): + self.valgrind = value + + def getDataSize(self): + totalSize = 0 + + if (self.deployed == 1): + for dirpath, dirnames, filenames in os.walk(self.dataDir): + for f in filenames: + fp = os.path.join(dirpath, f) + + if not os.path.islink(fp): + totalSize = totalSize + os.path.getsize(fp) + + return totalSize + + def deploy(self): + self.logDir = "%s/sim/dnode%d/log" % (self.path, self.index) + self.dataDir = "%s/sim/dnode%d/data" % (self.path, self.index) + self.cfgDir = "%s/sim/dnode%d/cfg" % (self.path, self.index) + self.cfgPath = "%s/sim/dnode%d/cfg/taos.cfg" % ( + self.path, self.index) + + cmd = "rm -rf " + self.dataDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "rm -rf " + self.logDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "rm -rf " + self.cfgDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "mkdir -p " + self.dataDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "mkdir -p " + self.logDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "mkdir -p " + self.cfgDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "touch " + self.cfgPath + if os.system(cmd) != 0: + tdLog.exit(cmd) + + if self.testCluster: + self.startIP() + + if self.testCluster: + self.cfg("masterIp", "192.168.0.1") + self.cfg("secondIp", "192.168.0.2") + self.cfg("publicIp", "192.168.0.%d" % (self.index)) + self.cfg("internalIp", "192.168.0.%d" % (self.index)) + self.cfg("privateIp", "192.168.0.%d" % (self.index)) + self.cfg("dataDir", self.dataDir) + self.cfg("logDir", self.logDir) + self.cfg("numOfLogLines", "100000000") + self.cfg("mnodeEqualVnodeNum", "0") + self.cfg("walLevel", "2") + self.cfg("fsync", "1000") + self.cfg("statusInterval", "1") + self.cfg("numOfMnodes", "3") + self.cfg("numOfThreadsPerCore", "2.0") + self.cfg("monitor", "0") + self.cfg("maxVnodeConnections", "30000") + self.cfg("maxMgmtConnections", "30000") + self.cfg("maxMeterConnections", "30000") + self.cfg("maxShellConns", "30000") + self.cfg("locale", "en_US.UTF-8") + self.cfg("charset", "UTF-8") + self.cfg("asyncLog", "0") + self.cfg("anyIp", "0") + self.cfg("dDebugFlag", "135") + self.cfg("mDebugFlag", "135") + self.cfg("sdbDebugFlag", "135") + self.cfg("rpcDebugFlag", "135") + self.cfg("tmrDebugFlag", "131") + self.cfg("cDebugFlag", "135") + self.cfg("httpDebugFlag", "135") + self.cfg("monitorDebugFlag", "135") + self.cfg("udebugFlag", "135") + self.cfg("jnidebugFlag", "135") + self.cfg("qdebugFlag", "135") + self.deployed = 1 + tdLog.debug( + "dnode:%d is deployed and configured by %s" % + (self.index, self.cfgPath)) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def start(self): + buildPath = self.getBuildPath() + + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + + binPath = buildPath + "/build/bin/taosd" + + if self.deployed == 0: + tdLog.exit("dnode:%d is not deployed" % (self.index)) + + if self.valgrind == 0: + cmd = "nohup %s -c %s > /dev/null 2>&1 & " % ( + binPath, self.cfgDir) + else: + valgrindCmdline = "valgrind --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes" + + cmd = "nohup %s %s -c %s 2>&1 & " % ( + valgrindCmdline, binPath, self.cfgDir) + + print(cmd) + + if os.system(cmd) != 0: + tdLog.exit(cmd) + self.running = 1 + tdLog.debug("dnode:%d is running with %s " % (self.index, cmd)) + + tdLog.debug("wait 5 seconds for the dnode:%d to start." % (self.index)) + time.sleep(5) + + def stop(self): + if self.valgrind == 0: + toBeKilled = "taosd" + else: + toBeKilled = "valgrind.bin" + + if self.running != 0: + psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + while(processID): + killCmd = "kill -INT %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + for port in range(6030, 6041): + fuserCmd = "fuser -k -n tcp %d" % port + os.system(fuserCmd) + if self.valgrind: + time.sleep(2) + + self.running = 0 + tdLog.debug("dnode:%d is stopped by kill -INT" % (self.index)) + + def forcestop(self): + if self.valgrind == 0: + toBeKilled = "taosd" + else: + toBeKilled = "valgrind.bin" + + if self.running != 0: + psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + while(processID): + killCmd = "kill -KILL %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + for port in range(6030, 6041): + fuserCmd = "fuser -k -n tcp %d" % port + os.system(fuserCmd) + if self.valgrind: + time.sleep(2) + + self.running = 0 + tdLog.debug("dnode:%d is stopped by kill -KILL" % (self.index)) + + def startIP(self): + cmd = "sudo ifconfig lo:%d 192.168.0.%d up" % (self.index, self.index) + if os.system(cmd) != 0: + tdLog.exit(cmd) + + def stopIP(self): + cmd = "sudo ifconfig lo:%d 192.168.0.%d down" % ( + self.index, self.index) + if os.system(cmd) != 0: + tdLog.exit(cmd) + + def cfg(self, option, value): + cmd = "echo '%s %s' >> %s" % (option, value, self.cfgPath) + if os.system(cmd) != 0: + tdLog.exit(cmd) + + def getDnodeRootDir(self, index): + dnodeRootDir = "%s/sim/psim/dnode%d" % (self.path, index) + return dnodeRootDir + + def getDnodesRootDir(self): + dnodesRootDir = "%s/sim/psim" % (self.path) + return dnodesRootDir + + +class TDDnodes: + def __init__(self): + self.dnodes = [] + self.dnodes.append(TDDnode(1)) + self.dnodes.append(TDDnode(2)) + self.dnodes.append(TDDnode(3)) + self.dnodes.append(TDDnode(4)) + self.dnodes.append(TDDnode(5)) + self.dnodes.append(TDDnode(6)) + self.dnodes.append(TDDnode(7)) + self.dnodes.append(TDDnode(8)) + self.dnodes.append(TDDnode(9)) + self.dnodes.append(TDDnode(10)) + self.simDeployed = False + + def init(self, path): + psCmd = "ps -ef|grep -w taosd| grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + while(processID): + killCmd = "kill -TERM %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + while(processID): + killCmd = "kill -TERM %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + binPath = os.path.dirname(os.path.realpath(__file__)) + binPath = binPath + "/../../../debug/" + tdLog.debug("binPath %s" % (binPath)) + binPath = os.path.realpath(binPath) + tdLog.debug("binPath real path %s" % (binPath)) + + # cmd = "sudo cp %s/build/lib/libtaos.so /usr/local/lib/taos/" % (binPath) + # tdLog.debug(cmd) + # os.system(cmd) + + # cmd = "sudo cp %s/build/bin/taos /usr/local/bin/taos/" % (binPath) + # if os.system(cmd) != 0 : + # tdLog.exit(cmd) + # tdLog.debug("execute %s" % (cmd)) + + # cmd = "sudo cp %s/build/bin/taosd /usr/local/bin/taos/" % (binPath) + # if os.system(cmd) != 0 : + # tdLog.exit(cmd) + # tdLog.debug("execute %s" % (cmd)) + + if path == "": + # self.path = os.path.expanduser('~') + self.path = os.path.abspath(binPath + "../../") + else: + self.path = os.path.realpath(path) + + for i in range(len(self.dnodes)): + self.dnodes[i].init(self.path) + + self.sim = TDSimClient() + self.sim.init(self.path) + + def setTestCluster(self, value): + self.testCluster = value + + def setValgrind(self, value): + self.valgrind = value + + def deploy(self, index): + self.sim.setTestCluster(self.testCluster) + + if (self.simDeployed == False): + self.sim.deploy() + self.simDeployed = True + + self.check(index) + self.dnodes[index - 1].setTestCluster(self.testCluster) + self.dnodes[index - 1].setValgrind(self.valgrind) + self.dnodes[index - 1].deploy() + + def cfg(self, index, option, value): + self.check(index) + self.dnodes[index - 1].cfg(option, value) + + def start(self, index): + self.check(index) + self.dnodes[index - 1].start() + + def stop(self, index): + self.check(index) + self.dnodes[index - 1].stop() + + def getDataSize(self, index): + self.check(index) + return self.dnodes[index - 1].getDataSize() + + def forcestop(self, index): + self.check(index) + self.dnodes[index - 1].forcestop() + + def startIP(self, index): + self.check(index) + + if self.testCluster: + self.dnodes[index - 1].startIP() + + def stopIP(self, index): + self.check(index) + + if self.dnodes[index - 1].testCluster: + self.dnodes[index - 1].stopIP() + + def check(self, index): + if index < 1 or index > 10: + tdLog.exit("index:%d should on a scale of [1, 10]" % (index)) + + def stopAll(self): + tdLog.info("stop all dnodes") + for i in range(len(self.dnodes)): + self.dnodes[i].stop() + + psCmd = "ps -ef | grep -w taosd | grep 'root' | grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + if processID: + cmd = "sudo systemctl stop taosd" + os.system(cmd) + # if os.system(cmd) != 0 : + # tdLog.exit(cmd) + psCmd = "ps -ef|grep -w taosd| grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + while(processID): + killCmd = "kill -TERM %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + while(processID): + killCmd = "kill -TERM %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + # if os.system(cmd) != 0 : + # tdLog.exit(cmd) + + def getDnodesRootDir(self): + dnodesRootDir = "%s/sim" % (self.path) + return dnodesRootDir + + def getSimCfgPath(self): + return self.sim.getCfgDir() + + def getSimLogPath(self): + return self.sim.getLogDir() + + def addSimExtraCfg(self, option, value): + self.sim.addExtraCfg(option, value) + + +tdDnodes = TDDnodes() diff --git a/tests/pytest/util/dnodes-no-random-fail.py b/tests/pytest/util/dnodes-no-random-fail.py new file mode 100644 index 0000000000000000000000000000000000000000..2627575e615c306afa60c512b4bf8c87f5ee00df --- /dev/null +++ b/tests/pytest/util/dnodes-no-random-fail.py @@ -0,0 +1,501 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +import os.path +import subprocess +from util.log import * + + +class TDSimClient: + def __init__(self): + self.testCluster = False + + self.cfgDict = { + "numOfLogLines": "100000000", + "numOfThreadsPerCore": "2.0", + "locale": "en_US.UTF-8", + "charset": "UTF-8", + "asyncLog": "0", + "anyIp": "0", + "sdbDebugFlag": "135", + "rpcDebugFlag": "135", + "tmrDebugFlag": "131", + "cDebugFlag": "135", + "udebugFlag": "135", + "jnidebugFlag": "135", + "qdebugFlag": "135", + "telemetryReporting": "0", + } + + def init(self, path): + self.__init__() + self.path = path + + def getLogDir(self): + self.logDir = "%s/sim/psim/log" % (self.path) + return self.logDir + + def getCfgDir(self): + self.cfgDir = "%s/sim/psim/cfg" % (self.path) + return self.cfgDir + + def setTestCluster(self, value): + self.testCluster = value + + def addExtraCfg(self, option, value): + self.cfgDict.update({option: value}) + + def cfg(self, option, value): + cmd = "echo '%s %s' >> %s" % (option, value, self.cfgPath) + if os.system(cmd) != 0: + tdLog.exit(cmd) + + def deploy(self): + self.logDir = "%s/sim/psim/log" % (self.path) + self.cfgDir = "%s/sim/psim/cfg" % (self.path) + self.cfgPath = "%s/sim/psim/cfg/taos.cfg" % (self.path) + + cmd = "rm -rf " + self.logDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "mkdir -p " + self.logDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "rm -rf " + self.cfgDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "mkdir -p " + self.cfgDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "touch " + self.cfgPath + if os.system(cmd) != 0: + tdLog.exit(cmd) + + if self.testCluster: + self.cfg("masterIp", "192.168.0.1") + self.cfg("secondIp", "192.168.0.2") + self.cfg("logDir", self.logDir) + + for key, value in self.cfgDict.items(): + self.cfg(key, value) + + tdLog.debug("psim is deployed and configured by %s" % (self.cfgPath)) + + +class TDDnode: + def __init__(self, index): + self.index = index + self.running = 0 + self.deployed = 0 + self.testCluster = False + self.valgrind = 0 + + def init(self, path): + self.path = path + + def setTestCluster(self, value): + self.testCluster = value + + def setValgrind(self, value): + self.valgrind = value + + def getDataSize(self): + totalSize = 0 + + if (self.deployed == 1): + for dirpath, dirnames, filenames in os.walk(self.dataDir): + for f in filenames: + fp = os.path.join(dirpath, f) + + if not os.path.islink(fp): + totalSize = totalSize + os.path.getsize(fp) + + return totalSize + + def deploy(self): + self.logDir = "%s/sim/dnode%d/log" % (self.path, self.index) + self.dataDir = "%s/sim/dnode%d/data" % (self.path, self.index) + self.cfgDir = "%s/sim/dnode%d/cfg" % (self.path, self.index) + self.cfgPath = "%s/sim/dnode%d/cfg/taos.cfg" % ( + self.path, self.index) + + cmd = "rm -rf " + self.dataDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "rm -rf " + self.logDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "rm -rf " + self.cfgDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "mkdir -p " + self.dataDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "mkdir -p " + self.logDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "mkdir -p " + self.cfgDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "touch " + self.cfgPath + if os.system(cmd) != 0: + tdLog.exit(cmd) + + if self.testCluster: + self.startIP() + + if self.testCluster: + self.cfg("masterIp", "192.168.0.1") + self.cfg("secondIp", "192.168.0.2") + self.cfg("publicIp", "192.168.0.%d" % (self.index)) + self.cfg("internalIp", "192.168.0.%d" % (self.index)) + self.cfg("privateIp", "192.168.0.%d" % (self.index)) + self.cfg("dataDir", self.dataDir) + self.cfg("logDir", self.logDir) + self.cfg("numOfLogLines", "100000000") + self.cfg("mnodeEqualVnodeNum", "0") + self.cfg("walLevel", "2") + self.cfg("fsync", "1000") + self.cfg("statusInterval", "1") + self.cfg("numOfMnodes", "3") + self.cfg("numOfThreadsPerCore", "2.0") + self.cfg("monitor", "0") + self.cfg("maxVnodeConnections", "30000") + self.cfg("maxMgmtConnections", "30000") + self.cfg("maxMeterConnections", "30000") + self.cfg("maxShellConns", "30000") + self.cfg("locale", "en_US.UTF-8") + self.cfg("charset", "UTF-8") + self.cfg("asyncLog", "0") + self.cfg("anyIp", "0") + self.cfg("dDebugFlag", "135") + self.cfg("mDebugFlag", "135") + self.cfg("sdbDebugFlag", "135") + self.cfg("rpcDebugFlag", "135") + self.cfg("tmrDebugFlag", "131") + self.cfg("cDebugFlag", "135") + self.cfg("httpDebugFlag", "135") + self.cfg("monitorDebugFlag", "135") + self.cfg("udebugFlag", "135") + self.cfg("jnidebugFlag", "135") + self.cfg("qdebugFlag", "135") + self.deployed = 1 + tdLog.debug( + "dnode:%d is deployed and configured by %s" % + (self.index, self.cfgPath)) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def start(self): + buildPath = self.getBuildPath() + + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + + binPath = buildPath + "/build/bin/taosd" + + if self.deployed == 0: + tdLog.exit("dnode:%d is not deployed" % (self.index)) + + if self.valgrind == 0: + cmd = "nohup %s -c %s --random-file-fail-factor 0 > /dev/null 2>&1 & " % ( + binPath, self.cfgDir) + else: + valgrindCmdline = "valgrind --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes" + + cmd = "nohup %s %s -c %s 2>&1 & " % ( + valgrindCmdline, binPath, self.cfgDir) + + print(cmd) + + if os.system(cmd) != 0: + tdLog.exit(cmd) + self.running = 1 + tdLog.debug("dnode:%d is running with %s " % (self.index, cmd)) + + tdLog.debug("wait 5 seconds for the dnode:%d to start." % (self.index)) + time.sleep(5) + + def stop(self): + if self.valgrind == 0: + toBeKilled = "taosd" + else: + toBeKilled = "valgrind.bin" + + if self.running != 0: + psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + while(processID): + killCmd = "kill -INT %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + for port in range(6030, 6041): + fuserCmd = "fuser -k -n tcp %d" % port + os.system(fuserCmd) + if self.valgrind: + time.sleep(2) + + self.running = 0 + tdLog.debug("dnode:%d is stopped by kill -INT" % (self.index)) + + def forcestop(self): + if self.valgrind == 0: + toBeKilled = "taosd" + else: + toBeKilled = "valgrind.bin" + + if self.running != 0: + psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + while(processID): + killCmd = "kill -KILL %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + for port in range(6030, 6041): + fuserCmd = "fuser -k -n tcp %d" % port + os.system(fuserCmd) + if self.valgrind: + time.sleep(2) + + self.running = 0 + tdLog.debug("dnode:%d is stopped by kill -KILL" % (self.index)) + + def startIP(self): + cmd = "sudo ifconfig lo:%d 192.168.0.%d up" % (self.index, self.index) + if os.system(cmd) != 0: + tdLog.exit(cmd) + + def stopIP(self): + cmd = "sudo ifconfig lo:%d 192.168.0.%d down" % ( + self.index, self.index) + if os.system(cmd) != 0: + tdLog.exit(cmd) + + def cfg(self, option, value): + cmd = "echo '%s %s' >> %s" % (option, value, self.cfgPath) + if os.system(cmd) != 0: + tdLog.exit(cmd) + + def getDnodeRootDir(self, index): + dnodeRootDir = "%s/sim/psim/dnode%d" % (self.path, index) + return dnodeRootDir + + def getDnodesRootDir(self): + dnodesRootDir = "%s/sim/psim" % (self.path) + return dnodesRootDir + + +class TDDnodes: + def __init__(self): + self.dnodes = [] + self.dnodes.append(TDDnode(1)) + self.dnodes.append(TDDnode(2)) + self.dnodes.append(TDDnode(3)) + self.dnodes.append(TDDnode(4)) + self.dnodes.append(TDDnode(5)) + self.dnodes.append(TDDnode(6)) + self.dnodes.append(TDDnode(7)) + self.dnodes.append(TDDnode(8)) + self.dnodes.append(TDDnode(9)) + self.dnodes.append(TDDnode(10)) + self.simDeployed = False + + def init(self, path): + psCmd = "ps -ef|grep -w taosd| grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + while(processID): + killCmd = "kill -TERM %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + while(processID): + killCmd = "kill -TERM %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + binPath = os.path.dirname(os.path.realpath(__file__)) + binPath = binPath + "/../../../debug/" + tdLog.debug("binPath %s" % (binPath)) + binPath = os.path.realpath(binPath) + tdLog.debug("binPath real path %s" % (binPath)) + + # cmd = "sudo cp %s/build/lib/libtaos.so /usr/local/lib/taos/" % (binPath) + # tdLog.debug(cmd) + # os.system(cmd) + + # cmd = "sudo cp %s/build/bin/taos /usr/local/bin/taos/" % (binPath) + # if os.system(cmd) != 0 : + # tdLog.exit(cmd) + # tdLog.debug("execute %s" % (cmd)) + + # cmd = "sudo cp %s/build/bin/taosd /usr/local/bin/taos/" % (binPath) + # if os.system(cmd) != 0 : + # tdLog.exit(cmd) + # tdLog.debug("execute %s" % (cmd)) + + if path == "": + # self.path = os.path.expanduser('~') + self.path = os.path.abspath(binPath + "../../") + else: + self.path = os.path.realpath(path) + + for i in range(len(self.dnodes)): + self.dnodes[i].init(self.path) + + self.sim = TDSimClient() + self.sim.init(self.path) + + def setTestCluster(self, value): + self.testCluster = value + + def setValgrind(self, value): + self.valgrind = value + + def deploy(self, index): + self.sim.setTestCluster(self.testCluster) + + if (self.simDeployed == False): + self.sim.deploy() + self.simDeployed = True + + self.check(index) + self.dnodes[index - 1].setTestCluster(self.testCluster) + self.dnodes[index - 1].setValgrind(self.valgrind) + self.dnodes[index - 1].deploy() + + def cfg(self, index, option, value): + self.check(index) + self.dnodes[index - 1].cfg(option, value) + + def start(self, index): + self.check(index) + self.dnodes[index - 1].start() + + def stop(self, index): + self.check(index) + self.dnodes[index - 1].stop() + + def getDataSize(self, index): + self.check(index) + return self.dnodes[index - 1].getDataSize() + + def forcestop(self, index): + self.check(index) + self.dnodes[index - 1].forcestop() + + def startIP(self, index): + self.check(index) + + if self.testCluster: + self.dnodes[index - 1].startIP() + + def stopIP(self, index): + self.check(index) + + if self.dnodes[index - 1].testCluster: + self.dnodes[index - 1].stopIP() + + def check(self, index): + if index < 1 or index > 10: + tdLog.exit("index:%d should on a scale of [1, 10]" % (index)) + + def stopAll(self): + tdLog.info("stop all dnodes") + for i in range(len(self.dnodes)): + self.dnodes[i].stop() + + psCmd = "ps -ef | grep -w taosd | grep 'root' | grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + if processID: + cmd = "sudo systemctl stop taosd" + os.system(cmd) + # if os.system(cmd) != 0 : + # tdLog.exit(cmd) + psCmd = "ps -ef|grep -w taosd| grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + while(processID): + killCmd = "kill -TERM %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + while(processID): + killCmd = "kill -TERM %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + # if os.system(cmd) != 0 : + # tdLog.exit(cmd) + + def getDnodesRootDir(self): + dnodesRootDir = "%s/sim" % (self.path) + return dnodesRootDir + + def getSimCfgPath(self): + return self.sim.getCfgDir() + + def getSimLogPath(self): + return self.sim.getLogDir() + + def addSimExtraCfg(self, option, value): + self.sim.addExtraCfg(option, value) + + +tdDnodes = TDDnodes() diff --git a/tests/pytest/util/dnodes-random-fail.py b/tests/pytest/util/dnodes-random-fail.py new file mode 100644 index 0000000000000000000000000000000000000000..4f4cdcc0d096652dbd0197236cbde95109c4a76b --- /dev/null +++ b/tests/pytest/util/dnodes-random-fail.py @@ -0,0 +1,501 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +import os.path +import subprocess +from util.log import * + + +class TDSimClient: + def __init__(self): + self.testCluster = False + + self.cfgDict = { + "numOfLogLines": "100000000", + "numOfThreadsPerCore": "2.0", + "locale": "en_US.UTF-8", + "charset": "UTF-8", + "asyncLog": "0", + "anyIp": "0", + "sdbDebugFlag": "135", + "rpcDebugFlag": "135", + "tmrDebugFlag": "131", + "cDebugFlag": "135", + "udebugFlag": "135", + "jnidebugFlag": "135", + "qdebugFlag": "135", + "telemetryReporting": "0", + } + + def init(self, path): + self.__init__() + self.path = path + + def getLogDir(self): + self.logDir = "%s/sim/psim/log" % (self.path) + return self.logDir + + def getCfgDir(self): + self.cfgDir = "%s/sim/psim/cfg" % (self.path) + return self.cfgDir + + def setTestCluster(self, value): + self.testCluster = value + + def addExtraCfg(self, option, value): + self.cfgDict.update({option: value}) + + def cfg(self, option, value): + cmd = "echo '%s %s' >> %s" % (option, value, self.cfgPath) + if os.system(cmd) != 0: + tdLog.exit(cmd) + + def deploy(self): + self.logDir = "%s/sim/psim/log" % (self.path) + self.cfgDir = "%s/sim/psim/cfg" % (self.path) + self.cfgPath = "%s/sim/psim/cfg/taos.cfg" % (self.path) + + cmd = "rm -rf " + self.logDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "mkdir -p " + self.logDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "rm -rf " + self.cfgDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "mkdir -p " + self.cfgDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "touch " + self.cfgPath + if os.system(cmd) != 0: + tdLog.exit(cmd) + + if self.testCluster: + self.cfg("masterIp", "192.168.0.1") + self.cfg("secondIp", "192.168.0.2") + self.cfg("logDir", self.logDir) + + for key, value in self.cfgDict.items(): + self.cfg(key, value) + + tdLog.debug("psim is deployed and configured by %s" % (self.cfgPath)) + + +class TDDnode: + def __init__(self, index): + self.index = index + self.running = 0 + self.deployed = 0 + self.testCluster = False + self.valgrind = 0 + + def init(self, path): + self.path = path + + def setTestCluster(self, value): + self.testCluster = value + + def setValgrind(self, value): + self.valgrind = value + + def getDataSize(self): + totalSize = 0 + + if (self.deployed == 1): + for dirpath, dirnames, filenames in os.walk(self.dataDir): + for f in filenames: + fp = os.path.join(dirpath, f) + + if not os.path.islink(fp): + totalSize = totalSize + os.path.getsize(fp) + + return totalSize + + def deploy(self): + self.logDir = "%s/sim/dnode%d/log" % (self.path, self.index) + self.dataDir = "%s/sim/dnode%d/data" % (self.path, self.index) + self.cfgDir = "%s/sim/dnode%d/cfg" % (self.path, self.index) + self.cfgPath = "%s/sim/dnode%d/cfg/taos.cfg" % ( + self.path, self.index) + + cmd = "rm -rf " + self.dataDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "rm -rf " + self.logDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "rm -rf " + self.cfgDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "mkdir -p " + self.dataDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "mkdir -p " + self.logDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "mkdir -p " + self.cfgDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "touch " + self.cfgPath + if os.system(cmd) != 0: + tdLog.exit(cmd) + + if self.testCluster: + self.startIP() + + if self.testCluster: + self.cfg("masterIp", "192.168.0.1") + self.cfg("secondIp", "192.168.0.2") + self.cfg("publicIp", "192.168.0.%d" % (self.index)) + self.cfg("internalIp", "192.168.0.%d" % (self.index)) + self.cfg("privateIp", "192.168.0.%d" % (self.index)) + self.cfg("dataDir", self.dataDir) + self.cfg("logDir", self.logDir) + self.cfg("numOfLogLines", "100000000") + self.cfg("mnodeEqualVnodeNum", "0") + self.cfg("walLevel", "2") + self.cfg("fsync", "1000") + self.cfg("statusInterval", "1") + self.cfg("numOfMnodes", "3") + self.cfg("numOfThreadsPerCore", "2.0") + self.cfg("monitor", "0") + self.cfg("maxVnodeConnections", "30000") + self.cfg("maxMgmtConnections", "30000") + self.cfg("maxMeterConnections", "30000") + self.cfg("maxShellConns", "30000") + self.cfg("locale", "en_US.UTF-8") + self.cfg("charset", "UTF-8") + self.cfg("asyncLog", "0") + self.cfg("anyIp", "0") + self.cfg("dDebugFlag", "135") + self.cfg("mDebugFlag", "135") + self.cfg("sdbDebugFlag", "135") + self.cfg("rpcDebugFlag", "135") + self.cfg("tmrDebugFlag", "131") + self.cfg("cDebugFlag", "135") + self.cfg("httpDebugFlag", "135") + self.cfg("monitorDebugFlag", "135") + self.cfg("udebugFlag", "135") + self.cfg("jnidebugFlag", "135") + self.cfg("qdebugFlag", "135") + self.deployed = 1 + tdLog.debug( + "dnode:%d is deployed and configured by %s" % + (self.index, self.cfgPath)) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def start(self): + buildPath = self.getBuildPath() + + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + + binPath = buildPath + "/build/bin/taosd" + + if self.deployed == 0: + tdLog.exit("dnode:%d is not deployed" % (self.index)) + + if self.valgrind == 0: + cmd = "nohup %s -c %s --alloc-random-fail --random-file-fail-factor 5 > /dev/null 2>&1 & " % ( + binPath, self.cfgDir) + else: + valgrindCmdline = "valgrind --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes" + + cmd = "nohup %s %s -c %s 2>&1 & " % ( + valgrindCmdline, binPath, self.cfgDir) + + print(cmd) + + if os.system(cmd) != 0: + tdLog.exit(cmd) + self.running = 1 + tdLog.debug("dnode:%d is running with %s " % (self.index, cmd)) + + tdLog.debug("wait 5 seconds for the dnode:%d to start." % (self.index)) + time.sleep(5) + + def stop(self): + if self.valgrind == 0: + toBeKilled = "taosd" + else: + toBeKilled = "valgrind.bin" + + if self.running != 0: + psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + while(processID): + killCmd = "kill -INT %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + for port in range(6030, 6041): + fuserCmd = "fuser -k -n tcp %d" % port + os.system(fuserCmd) + if self.valgrind: + time.sleep(2) + + self.running = 0 + tdLog.debug("dnode:%d is stopped by kill -INT" % (self.index)) + + def forcestop(self): + if self.valgrind == 0: + toBeKilled = "taosd" + else: + toBeKilled = "valgrind.bin" + + if self.running != 0: + psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + while(processID): + killCmd = "kill -KILL %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + for port in range(6030, 6041): + fuserCmd = "fuser -k -n tcp %d" % port + os.system(fuserCmd) + if self.valgrind: + time.sleep(2) + + self.running = 0 + tdLog.debug("dnode:%d is stopped by kill -KILL" % (self.index)) + + def startIP(self): + cmd = "sudo ifconfig lo:%d 192.168.0.%d up" % (self.index, self.index) + if os.system(cmd) != 0: + tdLog.exit(cmd) + + def stopIP(self): + cmd = "sudo ifconfig lo:%d 192.168.0.%d down" % ( + self.index, self.index) + if os.system(cmd) != 0: + tdLog.exit(cmd) + + def cfg(self, option, value): + cmd = "echo '%s %s' >> %s" % (option, value, self.cfgPath) + if os.system(cmd) != 0: + tdLog.exit(cmd) + + def getDnodeRootDir(self, index): + dnodeRootDir = "%s/sim/psim/dnode%d" % (self.path, index) + return dnodeRootDir + + def getDnodesRootDir(self): + dnodesRootDir = "%s/sim/psim" % (self.path) + return dnodesRootDir + + +class TDDnodes: + def __init__(self): + self.dnodes = [] + self.dnodes.append(TDDnode(1)) + self.dnodes.append(TDDnode(2)) + self.dnodes.append(TDDnode(3)) + self.dnodes.append(TDDnode(4)) + self.dnodes.append(TDDnode(5)) + self.dnodes.append(TDDnode(6)) + self.dnodes.append(TDDnode(7)) + self.dnodes.append(TDDnode(8)) + self.dnodes.append(TDDnode(9)) + self.dnodes.append(TDDnode(10)) + self.simDeployed = False + + def init(self, path): + psCmd = "ps -ef|grep -w taosd| grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + while(processID): + killCmd = "kill -TERM %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + while(processID): + killCmd = "kill -TERM %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + binPath = os.path.dirname(os.path.realpath(__file__)) + binPath = binPath + "/../../../debug/" + tdLog.debug("binPath %s" % (binPath)) + binPath = os.path.realpath(binPath) + tdLog.debug("binPath real path %s" % (binPath)) + + # cmd = "sudo cp %s/build/lib/libtaos.so /usr/local/lib/taos/" % (binPath) + # tdLog.debug(cmd) + # os.system(cmd) + + # cmd = "sudo cp %s/build/bin/taos /usr/local/bin/taos/" % (binPath) + # if os.system(cmd) != 0 : + # tdLog.exit(cmd) + # tdLog.debug("execute %s" % (cmd)) + + # cmd = "sudo cp %s/build/bin/taosd /usr/local/bin/taos/" % (binPath) + # if os.system(cmd) != 0 : + # tdLog.exit(cmd) + # tdLog.debug("execute %s" % (cmd)) + + if path == "": + # self.path = os.path.expanduser('~') + self.path = os.path.abspath(binPath + "../../") + else: + self.path = os.path.realpath(path) + + for i in range(len(self.dnodes)): + self.dnodes[i].init(self.path) + + self.sim = TDSimClient() + self.sim.init(self.path) + + def setTestCluster(self, value): + self.testCluster = value + + def setValgrind(self, value): + self.valgrind = value + + def deploy(self, index): + self.sim.setTestCluster(self.testCluster) + + if (self.simDeployed == False): + self.sim.deploy() + self.simDeployed = True + + self.check(index) + self.dnodes[index - 1].setTestCluster(self.testCluster) + self.dnodes[index - 1].setValgrind(self.valgrind) + self.dnodes[index - 1].deploy() + + def cfg(self, index, option, value): + self.check(index) + self.dnodes[index - 1].cfg(option, value) + + def start(self, index): + self.check(index) + self.dnodes[index - 1].start() + + def stop(self, index): + self.check(index) + self.dnodes[index - 1].stop() + + def getDataSize(self, index): + self.check(index) + return self.dnodes[index - 1].getDataSize() + + def forcestop(self, index): + self.check(index) + self.dnodes[index - 1].forcestop() + + def startIP(self, index): + self.check(index) + + if self.testCluster: + self.dnodes[index - 1].startIP() + + def stopIP(self, index): + self.check(index) + + if self.dnodes[index - 1].testCluster: + self.dnodes[index - 1].stopIP() + + def check(self, index): + if index < 1 or index > 10: + tdLog.exit("index:%d should on a scale of [1, 10]" % (index)) + + def stopAll(self): + tdLog.info("stop all dnodes") + for i in range(len(self.dnodes)): + self.dnodes[i].stop() + + psCmd = "ps -ef | grep -w taosd | grep 'root' | grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + if processID: + cmd = "sudo systemctl stop taosd" + os.system(cmd) + # if os.system(cmd) != 0 : + # tdLog.exit(cmd) + psCmd = "ps -ef|grep -w taosd| grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + while(processID): + killCmd = "kill -TERM %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + while(processID): + killCmd = "kill -TERM %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + # if os.system(cmd) != 0 : + # tdLog.exit(cmd) + + def getDnodesRootDir(self): + dnodesRootDir = "%s/sim" % (self.path) + return dnodesRootDir + + def getSimCfgPath(self): + return self.sim.getCfgDir() + + def getSimLogPath(self): + return self.sim.getLogDir() + + def addSimExtraCfg(self, option, value): + self.sim.addExtraCfg(option, value) + + +tdDnodes = TDDnodes() diff --git a/tests/pytest/util/dnodes.py b/tests/pytest/util/dnodes.py new file mode 100644 index 0000000000000000000000000000000000000000..397c56acd25f163728c76e3662c21a2e22699537 --- /dev/null +++ b/tests/pytest/util/dnodes.py @@ -0,0 +1,612 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +import os.path +import platform +import pathlib +import shutil +import subprocess +from time import sleep +from util.log import * + + +class TDSimClient: + def __init__(self, path): + self.testCluster = False + self.path = path + self.cfgDict = { + "numOfLogLines": "100000000", + "numOfThreadsPerCore": "2.0", + "locale": "en_US.UTF-8", + "charset": "UTF-8", + "asyncLog": "0", + "minTablesPerVnode": "4", + "maxTablesPerVnode": "1000", + "tableIncStepPerVnode": "10000", + "maxVgroupsPerDb": "1000", + "sdbDebugFlag": "143", + "rpcDebugFlag": "135", + "tmrDebugFlag": "131", + "cDebugFlag": "135", + "udebugFlag": "135", + "jnidebugFlag": "135", + "qdebugFlag": "135", + "telemetryReporting": "0", + } + + def getLogDir(self): + self.logDir = "%s/sim/psim/log" % (self.path) + return self.logDir + + def getCfgDir(self): + self.cfgDir = "%s/sim/psim/cfg" % (self.path) + return self.cfgDir + + def setTestCluster(self, value): + self.testCluster = value + + def addExtraCfg(self, option, value): + self.cfgDict.update({option: value}) + + def cfg(self, option, value): + cmd = "echo %s %s >> %s" % (option, value, self.cfgPath) + if os.system(cmd) != 0: + tdLog.exit(cmd) + + def os_string(self,path): + os_path = path.replace("/",os.sep) + return os_path + + def deploy(self, *updatecfgDict): + self.logDir = self.os_string("%s/sim/psim/log" % (self.path)) + self.cfgDir = self.os_string("%s/sim/psim/cfg" % (self.path)) + self.cfgPath = self.os_string("%s/sim/psim/cfg/taos.cfg" % (self.path)) + + # cmd = "rm -rf " + self.logDir + # if os.system(cmd) != 0: + # tdLog.exit(cmd) + if os.path.exists(self.logDir): + try: + shutil.rmtree(self.logDir) + except: + tdLog.exit("del %s failed"%self.logDir) + # cmd = "mkdir -p " + self.logDir + # if os.system(cmd) != 0: + # tdLog.exit(cmd) + os.makedirs(self.logDir) + # cmd = "rm -rf " + self.cfgDir + # if os.system(cmd) != 0: + # tdLog.exit(cmd) + if os.path.exists(self.cfgDir): + try: + shutil.rmtree(self.cfgDir) + except: + tdLog.exit("del %s failed"%self.cfgDir) + # cmd = "mkdir -p " + self.cfgDir + # if os.system(cmd) != 0: + # tdLog.exit(cmd) + os.makedirs(self.cfgDir) + # cmd = "touch " + self.cfgPath + # if os.system(cmd) != 0: + # tdLog.exit(cmd) + try: + pathlib.Path(self.cfgPath).touch() + except: + tdLog.exit("create %s failed"%self.cfgPath) + if self.testCluster: + self.cfg("masterIp", "192.168.0.1") + self.cfg("secondIp", "192.168.0.2") + self.cfg("logDir", self.logDir) + + # update extra client config + clientCfgkeys = ["clientMerge"] + if bool(updatecfgDict) and updatecfgDict[0] and updatecfgDict[0][0]: + for key, value in updatecfgDict[0][0].items(): + if key in clientCfgkeys: + self.cfg(key, value) + + for key, value in self.cfgDict.items(): + self.cfg(key, value) + + tdLog.debug("psim is deployed and configured by %s" % (self.cfgPath)) + + +class TDDnode: + def __init__(self, index): + self.index = index + self.running = 0 + self.deployed = 0 + self.testCluster = False + self.valgrind = 0 + self.cfgDict = { + "numOfLogLines":"100000000", + "mnodeEqualVnodeNum":"0", + "walLevel":"2", + "fsync":"1000", + "statusInterval":"1", + "numOfMnodes":"3", + "numOfThreadsPerCore":"2.0", + "monitor":"0", + "maxVnodeConnections":"30000", + "maxMgmtConnections":"30000", + "maxMeterConnections":"30000", + "maxShellConns":"30000", + "locale":"en_US.UTF-8", + "charset":"UTF-8", + "asyncLog":"0", + "anyIp":"0", + "telemetryReporting":"0", + "dDebugFlag":"135", + "tsdbDebugFlag":"135", + "mDebugFlag":"135", + "sdbDebugFlag":"135", + "rpcDebugFlag":"135", + "tmrDebugFlag":"131", + "cDebugFlag":"135", + "httpDebugFlag":"135", + "monitorDebugFlag":"135", + "udebugFlag":"135", + "jnidebugFlag":"135", + "qdebugFlag":"135", + "maxSQLLength":"1048576" + } + + def init(self, path): + self.path = path + + def setTestCluster(self, value): + self.testCluster = value + + def setValgrind(self, value): + self.valgrind = value + + def getDataSize(self): + totalSize = 0 + + if (self.deployed == 1): + for dirpath, dirnames, filenames in os.walk(self.dataDir): + for f in filenames: + fp = os.path.join(dirpath, f) + + if not os.path.islink(fp): + totalSize = totalSize + os.path.getsize(fp) + + return totalSize + + def addExtraCfg(self, option, value): + self.cfgDict.update({option: value}) + + def deploy(self, *updatecfgDict): + self.logDir = "%s/sim/dnode%d/log" % (self.path, self.index) + self.dataDir = "%s/sim/dnode%d/data" % (self.path, self.index) + self.cfgDir = "%s/sim/dnode%d/cfg" % (self.path, self.index) + self.cfgPath = "%s/sim/dnode%d/cfg/taos.cfg" % ( + self.path, self.index) + + cmd = "rm -rf " + self.dataDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "rm -rf " + self.logDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "rm -rf " + self.cfgDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "mkdir -p " + self.dataDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "mkdir -p " + self.logDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "mkdir -p " + self.cfgDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "touch " + self.cfgPath + if os.system(cmd) != 0: + tdLog.exit(cmd) + + if self.testCluster: + self.startIP() + + if self.testCluster: + self.cfg("masterIp", "192.168.0.1") + self.cfg("secondIp", "192.168.0.2") + self.cfg("publicIp", "192.168.0.%d" % (self.index)) + self.cfg("internalIp", "192.168.0.%d" % (self.index)) + self.cfg("privateIp", "192.168.0.%d" % (self.index)) + self.cfgDict["dataDir"] = self.dataDir + self.cfgDict["logDir"] = self.logDir + # self.cfg("dataDir",self.dataDir) + # self.cfg("logDir",self.logDir) + # print(updatecfgDict) + isFirstDir = 1 + if updatecfgDict[0] and updatecfgDict[0][0]: + print(updatecfgDict[0][0]) + for key,value in updatecfgDict[0][0].items(): + if value == 'dataDir' : + if isFirstDir: + self.cfgDict.pop('dataDir') + self.cfg(value,key) + isFirstDir = 0 + else: + self.cfg(value,key) + else: + self.addExtraCfg(key,value) + for key, value in self.cfgDict.items(): + self.cfg(key, value) + + self.deployed = 1 + tdLog.debug( + "dnode:%d is deployed and configured by %s" % + (self.index, self.cfgPath)) + + def getBuildPath(self): + buildPath = "" + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if (("taosd") in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def start(self): + buildPath = self.getBuildPath() + + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + + binPath = buildPath + "/build/bin/taosd" + + if self.deployed == 0: + tdLog.exit("dnode:%d is not deployed" % (self.index)) + + if self.valgrind == 0: + cmd = "nohup %s -c %s > /dev/null 2>&1 & " % ( + binPath, self.cfgDir) + else: + valgrindCmdline = "valgrind --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes" + + cmd = "nohup %s %s -c %s 2>&1 & " % ( + valgrindCmdline, binPath, self.cfgDir) + + print(cmd) + + if os.system(cmd) != 0: + tdLog.exit(cmd) + self.running = 1 + tdLog.debug("dnode:%d is running with %s " % (self.index, cmd)) + if self.valgrind == 0: + time.sleep(0.1) + key = 'from offline to online' + bkey = bytes(key,encoding="utf8") + logFile = self.logDir + "/taosdlog.0" + i = 0 + while not os.path.exists(logFile): + sleep(0.1) + i += 1 + if i>50: + break + popen = subprocess.Popen('tail -f ' + logFile, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) + pid = popen.pid + # print('Popen.pid:' + str(pid)) + timeout = time.time() + 60*2 + while True: + line = popen.stdout.readline().strip() + if bkey in line: + popen.kill() + break + if time.time() > timeout: + tdLog.exit('wait too long for taosd start') + tdLog.debug("the dnode:%d has been started." % (self.index)) + else: + tdLog.debug("wait 10 seconds for the dnode:%d to start." % (self.index)) + time.sleep(10) + + + # time.sleep(5) + + def startWithoutSleep(self): + buildPath = self.getBuildPath() + + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + + binPath = buildPath + "/build/bin/taosd" + + if self.deployed == 0: + tdLog.exit("dnode:%d is not deployed" % (self.index)) + + if self.valgrind == 0: + cmd = "nohup %s -c %s > /dev/null 2>&1 & " % ( + binPath, self.cfgDir) + else: + valgrindCmdline = "valgrind --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes" + + cmd = "nohup %s %s -c %s 2>&1 & " % ( + valgrindCmdline, binPath, self.cfgDir) + + print(cmd) + + if os.system(cmd) != 0: + tdLog.exit(cmd) + self.running = 1 + tdLog.debug("dnode:%d is running with %s " % (self.index, cmd)) + + def stop(self): + if self.valgrind == 0: + toBeKilled = "taosd" + else: + toBeKilled = "valgrind.bin" + + if self.running != 0: + psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + while(processID): + killCmd = "kill -INT %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + for port in range(6030, 6041): + fuserCmd = "fuser -k -n tcp %d" % port + os.system(fuserCmd) + if self.valgrind: + time.sleep(2) + + self.running = 0 + tdLog.debug("dnode:%d is stopped by kill -INT" % (self.index)) + + def forcestop(self): + if self.valgrind == 0: + toBeKilled = "taosd" + else: + toBeKilled = "valgrind.bin" + + if self.running != 0: + psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + while(processID): + killCmd = "kill -KILL %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + for port in range(6030, 6041): + fuserCmd = "fuser -k -n tcp %d" % port + os.system(fuserCmd) + if self.valgrind: + time.sleep(2) + + self.running = 0 + tdLog.debug("dnode:%d is stopped by kill -KILL" % (self.index)) + + def startIP(self): + cmd = "sudo ifconfig lo:%d 192.168.0.%d up" % (self.index, self.index) + if os.system(cmd) != 0: + tdLog.exit(cmd) + + def stopIP(self): + cmd = "sudo ifconfig lo:%d 192.168.0.%d down" % ( + self.index, self.index) + if os.system(cmd) != 0: + tdLog.exit(cmd) + + def cfg(self, option, value): + cmd = "echo %s %s >> %s" % (option, value, self.cfgPath) + if os.system(cmd) != 0: + tdLog.exit(cmd) + + def getDnodeRootDir(self, index): + dnodeRootDir = "%s/sim/psim/dnode%d" % (self.path, index) + return dnodeRootDir + + def getDnodesRootDir(self): + dnodesRootDir = "%s/sim/psim" % (self.path) + return dnodesRootDir + + +class TDDnodes: + def __init__(self): + self.dnodes = [] + self.dnodes.append(TDDnode(1)) + self.dnodes.append(TDDnode(2)) + self.dnodes.append(TDDnode(3)) + self.dnodes.append(TDDnode(4)) + self.dnodes.append(TDDnode(5)) + self.dnodes.append(TDDnode(6)) + self.dnodes.append(TDDnode(7)) + self.dnodes.append(TDDnode(8)) + self.dnodes.append(TDDnode(9)) + self.dnodes.append(TDDnode(10)) + self.simDeployed = False + + def init(self, path): + psCmd = "ps -ef|grep -w taosd| grep -v grep| grep -v defunct | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + while(processID): + killCmd = "kill -9 %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + while(processID): + killCmd = "kill -9 %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + binPath = os.path.dirname(os.path.realpath(__file__)) + binPath = binPath + "/../../../debug/" + tdLog.debug("binPath %s" % (binPath)) + binPath = os.path.realpath(binPath) + tdLog.debug("binPath real path %s" % (binPath)) + + # cmd = "sudo cp %s/build/lib/libtaos.so /usr/local/lib/taos/" % (binPath) + # tdLog.debug(cmd) + # os.system(cmd) + + # cmd = "sudo cp %s/build/bin/taos /usr/local/bin/taos/" % (binPath) + # if os.system(cmd) != 0 : + # tdLog.exit(cmd) + # tdLog.debug("execute %s" % (cmd)) + + # cmd = "sudo cp %s/build/bin/taosd /usr/local/bin/taos/" % (binPath) + # if os.system(cmd) != 0 : + # tdLog.exit(cmd) + # tdLog.debug("execute %s" % (cmd)) + + if path == "": + # self.path = os.path.expanduser('~') + self.path = os.path.abspath(binPath + "../../") + else: + self.path = os.path.realpath(path) + + for i in range(len(self.dnodes)): + self.dnodes[i].init(self.path) + + self.sim = TDSimClient(self.path) + + def setTestCluster(self, value): + self.testCluster = value + + def setValgrind(self, value): + self.valgrind = value + + def deploy(self, index, *updatecfgDict): + self.sim.setTestCluster(self.testCluster) + + if (self.simDeployed == False): + self.sim.deploy(updatecfgDict) + self.simDeployed = True + + self.check(index) + self.dnodes[index - 1].setTestCluster(self.testCluster) + self.dnodes[index - 1].setValgrind(self.valgrind) + self.dnodes[index - 1].deploy(updatecfgDict) + + def cfg(self, index, option, value): + self.check(index) + self.dnodes[index - 1].cfg(option, value) + + def start(self, index): + self.check(index) + self.dnodes[index - 1].start() + + def startWithoutSleep(self, index): + self.check(index) + self.dnodes[index - 1].startWithoutSleep() + + def stop(self, index): + self.check(index) + self.dnodes[index - 1].stop() + + def getDataSize(self, index): + self.check(index) + return self.dnodes[index - 1].getDataSize() + + def forcestop(self, index): + self.check(index) + self.dnodes[index - 1].forcestop() + + def startIP(self, index): + self.check(index) + + if self.testCluster: + self.dnodes[index - 1].startIP() + + def stopIP(self, index): + self.check(index) + + if self.dnodes[index - 1].testCluster: + self.dnodes[index - 1].stopIP() + + def check(self, index): + if index < 1 or index > 10: + tdLog.exit("index:%d should on a scale of [1, 10]" % (index)) + + def stopAll(self): + tdLog.info("stop all dnodes") + for i in range(len(self.dnodes)): + self.dnodes[i].stop() + + psCmd = "ps -ef | grep -w taosd | grep 'root' | grep -v grep| grep -v defunct | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + if processID: + cmd = "sudo systemctl stop taosd" + os.system(cmd) + # if os.system(cmd) != 0 : + # tdLog.exit(cmd) + psCmd = "ps -ef|grep -w taosd| grep -v grep| grep -v defunct | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + while(processID): + killCmd = "kill -9 %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + while(processID): + killCmd = "kill -TERM %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + # if os.system(cmd) != 0 : + # tdLog.exit(cmd) + + def getDnodesRootDir(self): + dnodesRootDir = "%s/sim" % (self.path) + return dnodesRootDir + + def getSimCfgPath(self): + return self.sim.getCfgDir() + + def getSimLogPath(self): + return self.sim.getLogDir() + + def addSimExtraCfg(self, option, value): + self.sim.addExtraCfg(option, value) + + +tdDnodes = TDDnodes() diff --git a/tests/pytest/util/log.py b/tests/pytest/util/log.py new file mode 100644 index 0000000000000000000000000000000000000000..55cd42a6eb5059b931dc892bdd4eb6101031b730 --- /dev/null +++ b/tests/pytest/util/log.py @@ -0,0 +1,49 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +import time +import datetime +from distutils.log import warn as printf + + +class TDLog: + def __init__(self): + self.path = "" + + def info(self, info): + print("%s %s\n" % (datetime.datetime.now(), info)) + + def sleep(self, sec): + print("%s sleep %d seconds" % (datetime.datetime.now(), sec)) + time.sleep(sec) + + def debug(self, err): + print("\033[1;36m%s %s\033[0m" % (datetime.datetime.now(), err)) + + def success(self, info): + printf("\033[1;32m%s %s\033[0m" % (datetime.datetime.now(), info)) + + def notice(self, err): + printf("\033[1;33m%s %s\033[0m" % (datetime.datetime.now(), err)) + + def exit(self, err): + printf("\033[1;31m%s %s\033[0m" % (datetime.datetime.now(), err)) + sys.exit(1) + + def printNoPrefix(self, info): + print("\033[1;36m%s\033[0m" % (info)) + + +tdLog = TDLog() diff --git a/tests/pytest/util/pathFinding.py b/tests/pytest/util/pathFinding.py new file mode 100644 index 0000000000000000000000000000000000000000..9dee5142ce3539c7cd145c3d8364e01c4af25164 --- /dev/null +++ b/tests/pytest/util/pathFinding.py @@ -0,0 +1,83 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + + +import os +from util.log import * + + + +class TDFindPath: + """This class is for finding path within TDengine + """ + def __init__(self): + self.file = "" + + + def init(self, file): + """[summary] + + Args: + file (str): the file location you want to start the query. Generally using __file__ + """ + self.file = file + + def getTaosdemoPath(self): + """for finding the path of directory containing taosdemo + + Returns: + str: the path to directory containing taosdemo + """ + selfPath = os.path.dirname(os.path.realpath(self.file)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info(f"taosd found in {buildPath}") + return buildPath + "/build/bin/" + + def getTDenginePath(self): + """for finding the root path of TDengine + + Returns: + str: the root path of TDengine + """ + selfPath = os.path.dirname(os.path.realpath(self.file)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + print(projPath) + for root, dirs, files in os.walk(projPath): + if ("sim" in dirs): + print(root) + rootRealPath = os.path.realpath(root) + if (rootRealPath == ""): + tdLog.exit("TDengine not found!") + else: + tdLog.info(f"TDengine found in {rootRealPath}") + return rootRealPath + +tdFindPath = TDFindPath() \ No newline at end of file diff --git a/tests/pytest/util/sql.py b/tests/pytest/util/sql.py new file mode 100644 index 0000000000000000000000000000000000000000..2b654a379369c67cf906be0dde2f0cc4a309e1ea --- /dev/null +++ b/tests/pytest/util/sql.py @@ -0,0 +1,344 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +import time +import datetime +import inspect +import psutil +import shutil +import pandas as pd +from util.log import * + +def _parse_datetime(timestr): + try: + return datetime.datetime.strptime(timestr, '%Y-%m-%d %H:%M:%S.%f') + except ValueError: + pass + try: + return datetime.datetime.strptime(timestr, '%Y-%m-%d %H:%M:%S') + except ValueError: + pass + +class TDSql: + def __init__(self): + self.queryRows = 0 + self.queryCols = 0 + self.affectedRows = 0 + + def init(self, cursor, log=False): + self.cursor = cursor + + if (log): + caller = inspect.getframeinfo(inspect.stack()[1][0]) + self.cursor.log(caller.filename + ".sql") + + def close(self): + self.cursor.close() + + def prepare(self): + tdLog.info("prepare database:db") + s = 'reset query cache' + self.cursor.execute(s) + s = 'drop database if exists db' + self.cursor.execute(s) + s = 'create database db' + self.cursor.execute(s) + s = 'use db' + self.cursor.execute(s) + + def error(self, sql): + expectErrNotOccured = True + try: + self.cursor.execute(sql) + except BaseException: + expectErrNotOccured = False + if expectErrNotOccured: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + tdLog.exit("%s(%d) failed: sql:%s, expect error not occured" % (caller.filename, caller.lineno, sql)) + else: + self.queryRows = 0 + self.queryCols = 0 + self.queryResult = None + tdLog.info("sql:%s, expect error occured" % (sql)) + + def query(self, sql, row_tag=None): + self.sql = sql + try: + self.cursor.execute(sql) + self.queryResult = self.cursor.fetchall() + self.queryRows = len(self.queryResult) + self.queryCols = len(self.cursor.description) + except Exception as e: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, sql, repr(e)) + tdLog.notice("%s(%d) failed: sql:%s, %s" % args) + raise Exception(repr(e)) + if row_tag: + return self.queryResult + return self.queryRows + + def getVariable(self, search_attr): + ''' + get variable of search_attr access "show variables" + ''' + try: + sql = 'show variables' + param_list = self.query(sql, row_tag=True) + for param in param_list: + if param[0] == search_attr: + return param[1], param_list + except Exception as e: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, sql, repr(e)) + tdLog.notice("%s(%d) failed: sql:%s, %s" % args) + raise Exception(repr(e)) + + def getColNameList(self, sql, col_tag=None): + self.sql = sql + try: + col_name_list = [] + col_type_list = [] + self.cursor.execute(sql) + self.queryCols = self.cursor.description + for query_col in self.queryCols: + col_name_list.append(query_col[0]) + col_type_list.append(query_col[1]) + except Exception as e: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, sql, repr(e)) + tdLog.notice("%s(%d) failed: sql:%s, %s" % args) + raise Exception(repr(e)) + if col_tag: + return col_name_list, col_type_list + return col_name_list + + def waitedQuery(self, sql, expectRows, timeout): + tdLog.info("sql: %s, try to retrieve %d rows in %d seconds" % (sql, expectRows, timeout)) + self.sql = sql + try: + for i in range(timeout): + self.cursor.execute(sql) + self.queryResult = self.cursor.fetchall() + self.queryRows = len(self.queryResult) + self.queryCols = len(self.cursor.description) + tdLog.info("sql: %s, try to retrieve %d rows,get %d rows" % (sql, expectRows, self.queryRows)) + if self.queryRows >= expectRows: + return (self.queryRows, i) + time.sleep(1) + except Exception as e: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, sql, repr(e)) + tdLog.notice("%s(%d) failed: sql:%s, %s" % args) + raise Exception(repr(e)) + return (self.queryRows, timeout) + + def checkRows(self, expectRows): + if self.queryRows == expectRows: + tdLog.info("sql:%s, queryRows:%d == expect:%d" % (self.sql, self.queryRows, expectRows)) + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, self.sql, self.queryRows, expectRows) + tdLog.exit("%s(%d) failed: sql:%s, queryRows:%d != expect:%d" % args) + + def checkCols(self, expectCols): + if self.queryCols == expectCols: + tdLog.info("sql:%s, queryCols:%d == expect:%d" % (self.sql, self.queryCols, expectCols)) + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, self.sql, self.queryCols, expectCols) + tdLog.exit("%s(%d) failed: sql:%s, queryCols:%d != expect:%d" % args) + + def checkRowCol(self, row, col): + caller = inspect.getframeinfo(inspect.stack()[2][0]) + if row < 0: + args = (caller.filename, caller.lineno, self.sql, row) + tdLog.exit("%s(%d) failed: sql:%s, row:%d is smaller than zero" % args) + if col < 0: + args = (caller.filename, caller.lineno, self.sql, row) + tdLog.exit("%s(%d) failed: sql:%s, col:%d is smaller than zero" % args) + if row > self.queryRows: + args = (caller.filename, caller.lineno, self.sql, row, self.queryRows) + tdLog.exit("%s(%d) failed: sql:%s, row:%d is larger than queryRows:%d" % args) + if col > self.queryCols: + args = (caller.filename, caller.lineno, self.sql, col, self.queryCols) + tdLog.exit("%s(%d) failed: sql:%s, col:%d is larger than queryCols:%d" % args) + + def checkDataType(self, row, col, dataType): + self.checkRowCol(row, col) + return self.cursor.istype(col, dataType) + + def checkData(self, row, col, data): + self.checkRowCol(row, col) + if self.queryResult[row][col] != data: + if self.cursor.istype(col, "TIMESTAMP"): + # suppose user want to check nanosecond timestamp if a longer data passed + if (len(data) >= 28): + if pd.to_datetime(self.queryResult[row][col]) == pd.to_datetime(data): + tdLog.info("sql:%s, row:%d col:%d data:%d == expect:%s" % + (self.sql, row, col, self.queryResult[row][col], data)) + else: + if self.queryResult[row][col] == _parse_datetime(data): + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (self.sql, row, col, self.queryResult[row][col], data)) + return + + if str(self.queryResult[row][col]) == str(data): + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (self.sql, row, col, self.queryResult[row][col], data)) + return + elif isinstance(data, float) and abs(self.queryResult[row][col] - data) <= 0.000001: + tdLog.info("sql:%s, row:%d col:%d data:%f == expect:%f" % + (self.sql, row, col, self.queryResult[row][col], data)) + return + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, self.sql, row, col, self.queryResult[row][col], data) + tdLog.exit("%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s" % args) + + if data is None: + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (self.sql, row, col, self.queryResult[row][col], data)) + elif isinstance(data, str): + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (self.sql, row, col, self.queryResult[row][col], data)) + elif isinstance(data, datetime.date): + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (self.sql, row, col, self.queryResult[row][col], data)) + elif isinstance(data, float): + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (self.sql, row, col, self.queryResult[row][col], data)) + else: + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%d" % + (self.sql, row, col, self.queryResult[row][col], data)) + + def getData(self, row, col): + self.checkRowCol(row, col) + return self.queryResult[row][col] + + def getResult(self, sql): + self.sql = sql + try: + self.cursor.execute(sql) + self.queryResult = self.cursor.fetchall() + except Exception as e: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, sql, repr(e)) + tdLog.notice("%s(%d) failed: sql:%s, %s" % args) + raise Exception(repr(e)) + return self.queryResult + + + def executeTimes(self, sql, times): + for i in range(times): + try: + return self.cursor.execute(sql) + except BaseException: + time.sleep(1) + continue + + def execute(self, sql): + self.sql = sql + try: + self.affectedRows = self.cursor.execute(sql) + except Exception as e: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, sql, repr(e)) + tdLog.notice("%s(%d) failed: sql:%s, %s" % args) + raise Exception(repr(e)) + return self.affectedRows + + def checkAffectedRows(self, expectAffectedRows): + if self.affectedRows != expectAffectedRows: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, self.sql, self.affectedRows, expectAffectedRows) + tdLog.exit("%s(%d) failed: sql:%s, affectedRows:%d != expect:%d" % args) + + tdLog.info("sql:%s, affectedRows:%d == expect:%d" % (self.sql, self.affectedRows, expectAffectedRows)) + + def checkColNameList(self, col_name_list, expect_col_name_list): + if col_name_list == expect_col_name_list: + tdLog.info("sql:%s, col_name_list:%s == expect_col_name_list:%s" % (self.sql, col_name_list, expect_col_name_list)) + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, self.sql, col_name_list, expect_col_name_list) + tdLog.exit("%s(%d) failed: sql:%s, col_name_list:%s != expect_col_name_list:%s" % args) + + def checkEqual(self, elm, expect_elm): + if elm == expect_elm: + tdLog.info("sql:%s, elm:%s == expect_elm:%s" % (self.sql, elm, expect_elm)) + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, self.sql, elm, expect_elm) + tdLog.exit("%s(%d) failed: sql:%s, elm:%s != expect_elm:%s" % args) + + def checkNotEqual(self, elm, expect_elm): + if elm != expect_elm: + tdLog.info("sql:%s, elm:%s != expect_elm:%s" % (self.sql, elm, expect_elm)) + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, self.sql, elm, expect_elm) + tdLog.exit("%s(%d) failed: sql:%s, elm:%s == expect_elm:%s" % args) + + def taosdStatus(self, state): + tdLog.sleep(5) + pstate = 0 + for i in range(30): + pstate = 0 + pl = psutil.pids() + for pid in pl: + try: + if psutil.Process(pid).name() == 'taosd': + print('have already started') + pstate = 1 + break + except psutil.NoSuchProcess: + pass + if pstate == state :break + if state or pstate: + tdLog.sleep(1) + continue + pstate = 0 + break + + args=(pstate,state) + if pstate == state: + tdLog.info("taosd state is %d == expect:%d" %args) + else: + tdLog.exit("taosd state is %d != expect:%d" %args) + pass + + def haveFile(self, dir, state): + if os.path.exists(dir) and os.path.isdir(dir): + if not os.listdir(dir): + if state : + tdLog.exit("dir: %s is empty, expect: not empty" %dir) + else: + tdLog.info("dir: %s is empty, expect: empty" %dir) + else: + if state : + tdLog.info("dir: %s is not empty, expect: not empty" %dir) + else: + tdLog.exit("dir: %s is not empty, expect: empty" %dir) + else: + tdLog.exit("dir: %s doesn't exist" %dir) + def createDir(self, dir): + if os.path.exists(dir): + shutil.rmtree(dir) + tdLog.info("dir: %s is removed" %dir) + os.makedirs( dir, 755 ) + tdLog.info("dir: %s is created" %dir) + pass + +tdSql = TDSql() \ No newline at end of file diff --git a/tests/pytest/util/sub.py b/tests/pytest/util/sub.py new file mode 100644 index 0000000000000000000000000000000000000000..664d830b86290e81e8ac1726f92193380d8c7715 --- /dev/null +++ b/tests/pytest/util/sub.py @@ -0,0 +1,44 @@ +################################################################### + # Copyright (c) 2020 by TAOS Technologies, Inc. + # All rights reserved. + # + # This file is proprietary and confidential to TAOS Technologies. + # No part of this file may be reproduced, stored, transmitted, + # disclosed or used in any form or by any means other than as + # expressly provided by the written permission from Jianhui Tao + # +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +import time +import datetime +from util.log import * + +class TDSub: + def __init__(self): + self.consumedRows = 0 + self.consumedCols = 0 + + def init(self, sub): + self.sub = sub + + def close(self, keepProgress): + self.sub.close(keepProgress) + + def consume(self): + self.result = self.sub.consume() + self.result.fetch_all() + self.consumedRows = self.result.row_count + self.consumedCols = self.result.field_count + return self.consumedRows + + def checkRows(self, expectRows): + if self.consumedRows != expectRows: + tdLog.exit("consumed rows:%d != expect:%d" % (self.consumedRows, expectRows)) + tdLog.info("consumed rows:%d == expect:%d" % (self.consumedRows, expectRows)) + + +tdSub = TDSub() diff --git a/tests/pytest/util/taosdemoCfg.py b/tests/pytest/util/taosdemoCfg.py new file mode 100644 index 0000000000000000000000000000000000000000..d211f86b81d0b41237c645c7955a3d5a3099cf11 --- /dev/null +++ b/tests/pytest/util/taosdemoCfg.py @@ -0,0 +1,465 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +import time +import datetime +import inspect +import psutil +import shutil +import json +from util.log import * +from multiprocessing import cpu_count + + +# TODO: fully test the function. Handle exceptions. +# Handle json format not accepted by taosdemo + +### How to use TaosdemoCfg: +# Before you start: +# Make sure you understand how is taosdemo's JSON file structured. Because the python used does +# not support directory in directory for self objects, the config is being tear to different parts. +# Please make sure you understand which directory represent which part of which type of the file +# This module will reassemble the parts when creating the JSON file. +# +# Basic use example +# step 1:use self.append_sql_stb() to append the insert/query/subscribe directory into the module +# you can append many insert/query/subscribe directory, but pay attention about taosdemo's limit +# step 2:use alter function to alter the specific config +# step 3:use the generation function to generate the files +# +# step 1 and step 2 can be replaced with using import functions +class TDTaosdemoCfg: + def __init__(self): + self.insert_cfg = { + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": cpu_count(), + "thread_count_create_tbl": cpu_count(), + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "num_of_records_per_req": 32766, + "max_sql_len": 32766, + "databases": None + } + + self.db = { + "name": 'db', + "drop": 'yes', + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 6, + "precision": "ms", + "keep": 3650, + "minRows": 100, + "maxRows": 4096, + "comp": 2, + "walLevel": 1, + "cachelast": 0, + "quorum": 1, + "fsync": 3000, + "update": 0 + } + + self.query_cfg = { + "filetype": "query", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "confirm_parameter_prompt": "no", + "databases": "db", + "query_times": 2, + "query_mode": "taosc", + "specified_table_query": None, + "super_table_query": None + } + + self.table_query = { + "query_interval": 1, + "concurrent": 3, + "sqls": None + } + + self.stable_query = { + "stblname": "stb", + "query_interval": 1, + "threads": 3, + "sqls": None + } + + self.sub_cfg = { + "filetype": "subscribe", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "databases": "db", + "confirm_parameter_prompt": "no", + "specified_table_query": None, + "super_table_query": None + } + + self.table_sub = { + "concurrent": 1, + "mode": "sync", + "interval": 10000, + "restart": "yes", + "keepProgress": "yes", + "sqls": None + } + + self.stable_sub = { + "stblname": "stb", + "threads": 1, + "mode": "sync", + "interval": 10000, + "restart": "yes", + "keepProgress": "yes", + "sqls": None + } + + self.stbs = [] + self.stb_template = { + "name": "stb", + "child_table_exists": "no", + "childtable_count": 100, + "childtable_prefix": "stb_", + "auto_create_table": "no", + "batch_create_tbl_num": 5, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 100, + "childtable_limit": 10, + "childtable_offset": 0, + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 32766, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT", "count": 1}], + "tags": [{"type": "BIGINT", "count": 1}] + } + + self.tb_query_sql = [] + self.tb_query_sql_template = { + "sql": "select last_row(*) from stb_0 ", + "result": "temp/query_res0.txt" + } + + self.stb_query_sql = [] + self.stb_query_sql_template = { + "sql": "select last_row(ts) from xxxx", + "result": "temp/query_res2.txt" + } + + self.tb_sub_sql = [] + self.tb_sub_sql_template = { + "sql": "select * from stb_0 ;", + "result": "temp/subscribe_res0.txt" + } + + self.stb_sub_sql = [] + self.stb_sub_sql_template = { + "sql": "select * from xxxx where ts > '2021-02-25 11:35:00.000' ;", + "result": "temp/subscribe_res1.txt" + } + + # The following functions are import functions for different dicts and lists + # except import_sql, all other import functions will a dict and overwrite the origional dict + # dict_in: the dict used to overwrite the target + def import_insert_cfg(self, dict_in): + self.insert_cfg = dict_in + + def import_db(self, dict_in): + self.db = dict_in + + def import_stbs(self, dict_in): + self.stbs = dict_in + + def import_query_cfg(self, dict_in): + self.query_cfg = dict_in + + def import_table_query(self, dict_in): + self.table_query = dict_in + + def import_stable_query(self, dict_in): + self.stable_query = dict_in + + def import_sub_cfg(self, dict_in): + self.sub_cfg = dict_in + + def import_table_sub(self, dict_in): + self.table_sub = dict_in + + def import_stable_sub(self, dict_in): + self.stable_sub = dict_in + + def import_sql(self, Sql_in, mode): + """used for importing the sql later used + + Args: + Sql_in (dict): the imported sql dict + mode (str): the sql storing location within TDTaosdemoCfg + format: 'fileType_tableType' + fileType: query, sub + tableType: table, stable + """ + if mode == 'query_table': + self.tb_query_sql = Sql_in + elif mode == 'query_stable': + self.stb_query_sql = Sql_in + elif mode == 'sub_table': + self.tb_sub_sql = Sql_in + elif mode == 'sub_stable': + self.stb_sub_sql = Sql_in + # import functions end + + # The following functions are alter functions for different dicts + # Args: + # key: the key that is going to be modified + # value: the value of the key that is going to be modified + # if key = 'databases' | "specified_table_query" | "super_table_query"|"sqls" + # value will not be used + + def alter_insert_cfg(self, key, value): + + if key == 'databases': + self.insert_cfg[key] = [ + { + 'dbinfo': self.db, + 'super_tables': self.stbs + } + ] + else: + self.insert_cfg[key] = value + + def alter_db(self, key, value): + self.db[key] = value + + def alter_query_tb(self, key, value): + if key == "sqls": + self.table_query[key] = self.tb_query_sql + else: + self.table_query[key] = value + + def alter_query_stb(self, key, value): + if key == "sqls": + self.stable_query[key] = self.stb_query_sql + else: + self.stable_query[key] = value + + def alter_query_cfg(self, key, value): + if key == "specified_table_query": + self.query_cfg["specified_table_query"] = self.table_query + elif key == "super_table_query": + self.query_cfg["super_table_query"] = self.stable_query + else: + self.query_cfg[key] = value + + def alter_sub_cfg(self, key, value): + if key == "specified_table_query": + self.sub_cfg["specified_table_query"] = self.table_sub + elif key == "super_table_query": + self.sub_cfg["super_table_query"] = self.stable_sub + else: + self.sub_cfg[key] = value + + def alter_sub_stb(self, key, value): + if key == "sqls": + self.stable_sub[key] = self.stb_sub_sql + else: + self.stable_sub[key] = value + + def alter_sub_tb(self, key, value): + if key == "sqls": + self.table_sub[key] = self.tb_sub_sql + else: + self.table_sub[key] = value + # alter function ends + + # the following functions are for handling the sql lists + def append_sql_stb(self, target, value): + """for appending sql dict into specific sql list + + Args: + target (str): the target append list + format: 'fileType_tableType' + fileType: query, sub + tableType: table, stable + unique: 'insert_stbs' + value (dict): the sql dict going to be appended + """ + if target == 'insert_stbs': + self.stbs.append(value) + elif target == 'query_table': + self.tb_query_sql.append(value) + elif target == 'query_stable': + self.stb_query_sql.append(value) + elif target == 'sub_table': + self.tb_sub_sql.append(value) + elif target == 'sub_stable': + self.stb_sub_sql.append(value) + + def pop_sql_stb(self, target, index): + """for poping a sql dict from specific sql list + + Args: + target (str): the target append list + format: 'fileType_tableType' + fileType: query, sub + tableType: table, stable + unique: 'insert_stbs' + index (int): the sql dict that is going to be popped + """ + if target == 'insert_stbs': + self.stbs.pop(index) + elif target == 'query_table': + self.tb_query_sql.pop(index) + elif target == 'query_stable': + self.stb_query_sql.pop(index) + elif target == 'sub_table': + self.tb_sub_sql.pop(index) + elif target == 'sub_stable': + self.stb_sub_sql.pop(index) + # sql list modification function end + + # The following functions are get functions for different dicts + def get_db(self): + return self.db + + def get_stb(self): + return self.stbs + + def get_insert_cfg(self): + return self.insert_cfg + + def get_query_cfg(self): + return self.query_cfg + + def get_tb_query(self): + return self.table_query + + def get_stb_query(self): + return self.stable_query + + def get_sub_cfg(self): + return self.sub_cfg + + def get_tb_sub(self): + return self.table_sub + + def get_stb_sub(self): + return self.stable_sub + + def get_sql(self, target): + """general get function for all sql lists + + Args: + target (str): the sql list want to get + format: 'fileType_tableType' + fileType: query, sub + tableType: table, stable + unique: 'insert_stbs' + """ + if target == 'query_table': + return self.tb_query_sql + elif target == 'query_stable': + return self.stb_query_sql + elif target == 'sub_table': + return self.tb_sub_sql + elif target == 'sub_stable': + return self.stb_sub_sql + + def get_template(self, target): + """general get function for the default sql template + + Args: + target (str): the sql list want to get + format: 'fileType_tableType' + fileType: query, sub + tableType: table, stable + unique: 'insert_stbs' + """ + if target == 'insert_stbs': + return self.stb_template + elif target == 'query_table': + return self.tb_query_sql_template + elif target == 'query_stable': + return self.stb_query_sql_template + elif target == 'sub_table': + return self.tb_sub_sql_template + elif target == 'sub_stable': + return self.stb_sub_sql_template + else: + print(f'did not find {target}') + + # the folloing are the file generation functions + """defalut document: + generator functio for generating taosdemo json file + will assemble the dicts and dump the final json + + Args: + pathName (str): the directory wanting the json file to be + fileName (str): the name suffix of the json file + Returns: + str: [pathName]/[filetype]_[filName].json + """ + + def generate_insert_cfg(self, pathName, fileName): + cfgFileName = f'{pathName}/insert_{fileName}.json' + self.alter_insert_cfg('databases', None) + with open(cfgFileName, 'w') as file: + json.dump(self.insert_cfg, file) + return cfgFileName + + def generate_query_cfg(self, pathName, fileName): + cfgFileName = f'{pathName}/query_{fileName}.json' + self.alter_query_tb('sqls', None) + self.alter_query_stb('sqls', None) + self.alter_query_cfg('specified_table_query', None) + self.alter_query_cfg('super_table_query', None) + with open(cfgFileName, 'w') as file: + json.dump(self.query_cfg, file) + return cfgFileName + + def generate_subscribe_cfg(self, pathName, fileName): + cfgFileName = f'{pathName}/subscribe_{fileName}.json' + self.alter_sub_tb('sqls', None) + self.alter_sub_stb('sqls', None) + self.alter_sub_cfg('specified_table_query', None) + self.alter_sub_cfg('super_table_query', None) + with open(cfgFileName, 'w') as file: + json.dump(self.sub_cfg, file) + return cfgFileName + # file generation functions ends + + def drop_cfg_file(self, fileName): + os.remove(f'{fileName}') + + +taosdemoCfg = TDTaosdemoCfg() diff --git a/tests/pytest/valgrind-test.sh b/tests/pytest/valgrind-test.sh new file mode 100755 index 0000000000000000000000000000000000000000..468974d0983884a5df0ee4fcc06aaf1ce0a36a90 --- /dev/null +++ b/tests/pytest/valgrind-test.sh @@ -0,0 +1,68 @@ +#!/bin/bash +IN_TDINTERNAL="community" +TDIR=`pwd` +if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then + cd ../.. +else + cd ../../.. +fi + +TOP_DIR=`pwd` +TAOSLIB_DIR=`find . -name "libtaos.so"|grep -w lib|head -n1` +if [[ "$TAOSLIB_DIR" == *"$IN_TDINTERNAL"* ]]; then + LIB_DIR=`find . -name "libtaos.so"|grep -w lib|head -n1|cut -d '/' --fields=2,3,4,5` +else + LIB_DIR=`find . -name "libtaos.so"|grep -w lib|head -n1|cut -d '/' --fields=2,3,4` +fi +if [ ! $LD_LIBRARY_PATH ]; then + export LD_LIBRARY_PATH=$TOP_DIR/$LIB_DIR +else + export LD_LIBRARY_PATH=$TOP_DIR/$LIB_DIR:$LD_LIBRARY_PATH +fi + +cd $TDIR +# client +PYTHONMALLOC=malloc python3 ./test.py -g -f client/client.py +PYTHONMALLOC=malloc python3 ./test.py -g -s && sleep 1 + +# insert +PYTHONMALLOC=malloc python3 ./test.py -g -f insert/basic.py +PYTHONMALLOC=malloc python3 ./test.py -g -s && sleep 1 +PYTHONMALLOC=malloc python3 ./test.py -g -f insert/int.py +PYTHONMALLOC=malloc python3 ./test.py -g -s && sleep 1 +PYTHONMALLOC=malloc python3 ./test.py -g -f insert/float.py +PYTHONMALLOC=malloc python3 ./test.py -g -s && sleep 1 +PYTHONMALLOC=malloc python3 ./test.py -g -f insert/bigint.py +PYTHONMALLOC=malloc python3 ./test.py -g -s && sleep 1 +PYTHONMALLOC=malloc python3 ./test.py -g -f insert/bool.py +PYTHONMALLOC=malloc python3 ./test.py -g -s && sleep 1 +PYTHONMALLOC=malloc python3 ./test.py -g -f insert/double.py +PYTHONMALLOC=malloc python3 ./test.py -g -s && sleep 1 +PYTHONMALLOC=malloc python3 ./test.py -g -f insert/smallint.py +PYTHONMALLOC=malloc python3 ./test.py -g -s && sleep 1 +PYTHONMALLOC=malloc python3 ./test.py -g -f insert/tinyint.py +PYTHONMALLOC=malloc python3 ./test.py -g -s && sleep 1 +PYTHONMALLOC=malloc python3 ./test.py -g -f insert/binary.py +PYTHONMALLOC=malloc python3 ./test.py -g -s && sleep 1 +PYTHONMALLOC=malloc python3 ./test.py -g -f insert/date.py +PYTHONMALLOC=malloc python3 ./test.py -g -s && sleep 1 +PYTHONMALLOC=malloc python3 ./test.py -g -f insert/nchar.py +PYTHONMALLOC=malloc python3 ./test.py -g -s && sleep 1 +PYTHONMALLOC=malloc python3 ./test.py -g -f insert/multi.py +PYTHONMALLOC=malloc python3 ./test.py -g -s && sleep 1 + +# table +PYTHONMALLOC=malloc python3 ./test.py -g -f table/column_name.py +PYTHONMALLOC=malloc python3 ./test.py -g -s && sleep 1 +PYTHONMALLOC=malloc python3 ./test.py -g -f table/column_num.py +PYTHONMALLOC=malloc python3 ./test.py -g -s && sleep 1 +PYTHONMALLOC=malloc python3 ./test.py -g -f table/db_table.py +PYTHONMALLOC=malloc python3 ./test.py -g -s && sleep 1 + +# import +PYTHONMALLOC=malloc python3 ./test.py -g -f import_merge/importDataLastSub.py +PYTHONMALLOC=malloc python3 ./test.py -g -s && sleep 1 + +#tag +PYTHONMALLOC=malloc python3 ./test.py $1 -f tag_lite/filter.py +PYTHONMALLOC=malloc python3 ./test.py $1 -s && sleep 1 diff --git a/tests/pytest/wal/addOldWalTest.py b/tests/pytest/wal/addOldWalTest.py new file mode 100644 index 0000000000000000000000000000000000000000..2f4dcd5ce807cf7bbadfa480af6ed6342058a78a --- /dev/null +++ b/tests/pytest/wal/addOldWalTest.py @@ -0,0 +1,70 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + def createOldDir(self): + oldDir = tdDnodes.getDnodesRootDir() + "dnode1/data/vnode/vnode2/wal/old" + os.system("sudo mkdir -p %s" % oldDir) + + def createOldDirAndAddWal(self): + oldDir = tdDnodes.getDnodesRootDir() + "dnode1/data/vnode/vnode2/wal/old" + os.system("sudo echo 'test' >> %s/wal" % oldDir) + + + def run(self): + tdSql.prepare() + + tdSql.execute("create table t1(ts timestamp, a int)") + tdSql.execute("insert into t1 values(now, 1)") + + # create old dir only + self.createOldDir() + os.system("sudo kill -9 $(pgrep taosd)") + tdDnodes.start(1) + + tdSql.execute("use db") + tdSql.query("select * from t1") + tdSql.checkRows(1) + tdSql.checkData(0, 1, 1) + + # create old dir and add wal under old dir + self.createOldDir() + self.createOldDirAndAddWal() + os.system("sudo kill -9 $(pgrep taosd)") + tdDnodes.start(1) + + tdSql.query("select * from t1") + tdSql.checkRows(1) + tdSql.checkData(0, 1, 1) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/wal/insertDataDb1.json b/tests/pytest/wal/insertDataDb1.json new file mode 100644 index 0000000000000000000000000000000000000000..1b7f757387afb8da99e7bfd7934a68ad90a6a8dd --- /dev/null +++ b/tests/pytest/wal/insertDataDb1.json @@ -0,0 +1,87 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db1", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 1000, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 100, + "childtable_limit": 0, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1}, {"type": "BINARY", "len": 16, "count":1}, {"type": "BINARY", "len": 32, "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":1}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 1000, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 200, + "childtable_limit": 0, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1}, {"type": "BINARY", "len": 16, "count":1}, {"type": "BINARY", "len": 32, "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":1}] + }] + }] +} + diff --git a/tests/pytest/wal/insertDataDb1Replica2.json b/tests/pytest/wal/insertDataDb1Replica2.json new file mode 100644 index 0000000000000000000000000000000000000000..20ea68cc06d1f3fd8ade8b0cfc95a976f339508e --- /dev/null +++ b/tests/pytest/wal/insertDataDb1Replica2.json @@ -0,0 +1,87 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 10, + "num_of_records_per_req": 1000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db1", + "drop": "yes", + "replica": 2, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 1000, + "childtable_prefix": "stb00_", + "auto_create_table": "no", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 100, + "childtable_limit": 0, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1}, {"type": "BINARY", "len": 16, "count":1}, {"type": "BINARY", "len": 32, "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":1}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 1000, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 200, + "childtable_limit": 0, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1}, {"type": "BINARY", "len": 16, "count":1}, {"type": "BINARY", "len": 32, "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":1}] + }] + }] +} + diff --git a/tests/pytest/wal/insertDataDb2.json b/tests/pytest/wal/insertDataDb2.json new file mode 100644 index 0000000000000000000000000000000000000000..15df1350c873a4569187fe8a7cac2f6e2b474eeb --- /dev/null +++ b/tests/pytest/wal/insertDataDb2.json @@ -0,0 +1,86 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 0, + "num_of_records_per_req": 3000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db2", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 2000, + "childtable_prefix": "stb0_", + "auto_create_table": "no", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 2000, + "childtable_limit": 0, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1}, {"type": "BINARY", "len": 16, "count":1}, {"type": "BINARY", "len": 32, "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":1}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 2, + "childtable_prefix": "stb1_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 5, + "childtable_limit": 0, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1}, {"type": "BINARY", "len": 16, "count":1}, {"type": "BINARY", "len": 32, "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":1}] + }] + }] +} diff --git a/tests/pytest/wal/insertDataDb2Newstab.json b/tests/pytest/wal/insertDataDb2Newstab.json new file mode 100644 index 0000000000000000000000000000000000000000..0558c8c33d1af477ae3b0cafe9416534db44dfb0 --- /dev/null +++ b/tests/pytest/wal/insertDataDb2Newstab.json @@ -0,0 +1,86 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 0, + "num_of_records_per_req": 3000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db2", + "drop": "no", + "replica": 1, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 1, + "childtable_prefix": "stb0_", + "auto_create_table": "no", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 0, + "childtable_limit": -1, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1}, {"type": "BINARY", "len": 16, "count":1}, {"type": "BINARY", "len": 32, "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":1}] + }, + { + "name": "stb1", + "child_table_exists":"yes", + "childtable_count": 1, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 10, + "childtable_limit": -1, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-11-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1}, {"type": "BINARY", "len": 16, "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":1}] + }] + }] +} diff --git a/tests/pytest/wal/insertDataDb2NewstabReplica2.json b/tests/pytest/wal/insertDataDb2NewstabReplica2.json new file mode 100644 index 0000000000000000000000000000000000000000..5bc145994d778105e10ae2631494cddfe8377cf7 --- /dev/null +++ b/tests/pytest/wal/insertDataDb2NewstabReplica2.json @@ -0,0 +1,86 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 0, + "num_of_records_per_req": 3000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db2", + "drop": "no", + "replica": 2, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 1, + "childtable_prefix": "stb0_", + "auto_create_table": "no", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 0, + "childtable_limit": -1, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1}, {"type": "BINARY", "len": 16, "count":1}, {"type": "BINARY", "len": 32, "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":1}] + }, + { + "name": "stb1", + "child_table_exists":"yes", + "childtable_count": 1, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 10, + "childtable_limit": -1, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-11-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1}, {"type": "BINARY", "len": 16, "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":1}] + }] + }] +} diff --git a/tests/pytest/wal/insertDataDb2Replica2.json b/tests/pytest/wal/insertDataDb2Replica2.json new file mode 100644 index 0000000000000000000000000000000000000000..07bbeaa632ce174aa6f1388689f15cc1c1a77b64 --- /dev/null +++ b/tests/pytest/wal/insertDataDb2Replica2.json @@ -0,0 +1,86 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "interlace_rows": 0, + "num_of_records_per_req": 3000, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db2", + "drop": "yes", + "replica": 2, + "days": 10, + "cache": 50, + "blocks": 8, + "precision": "ms", + "keep": 36500, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb0", + "child_table_exists":"no", + "childtable_count": 2000, + "childtable_prefix": "stb0_", + "auto_create_table": "no", + "batch_create_tbl_num": 100, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 2000, + "childtable_limit": 0, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1}, {"type": "BINARY", "len": 16, "count":1}, {"type": "BINARY", "len": 32, "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":1}] + }, + { + "name": "stb1", + "child_table_exists":"no", + "childtable_count": 2, + "childtable_prefix": "stb1_", + "auto_create_table": "no", + "batch_create_tbl_num": 10, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 5, + "childtable_limit": 0, + "childtable_offset":0, + "interlace_rows": 0, + "insert_interval":0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":1}, {"type": "BINARY", "len": 16, "count":1}, {"type": "BINARY", "len": 32, "count":1}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":1}] + }] + }] +} diff --git a/tests/pytest/wal/sdbComp.py b/tests/pytest/wal/sdbComp.py new file mode 100644 index 0000000000000000000000000000000000000000..428fbc9a145c0c3bae4507e33242ff3670c85024 --- /dev/null +++ b/tests/pytest/wal/sdbComp.py @@ -0,0 +1,125 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +from distutils.log import debug +import sys +import os +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import subprocess + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getBuildPath(self): + global selfPath + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def run(self): + + # set path para + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + + binPath = buildPath+ "/build/bin/" + testPath = selfPath+ "/../../../" + walFilePath = testPath + "/sim/dnode1/data/mnode_bak/wal/" + + #new db and insert data + os.system("rm -rf %s/sim/dnode1/data/mnode_tmp/" % testPath) + os.system("rm -rf %s/sim/dnode1/data/mnode_bak/" % testPath) + tdSql.execute("drop database if exists db2") + os.system("%staosdemo -f wal/insertDataDb1.json -y " % binPath) + tdSql.execute("drop database if exists db1") + os.system("%staosdemo -f wal/insertDataDb2.json -y " % binPath) + tdSql.execute("drop table if exists db2.stb0") + os.system("%staosdemo -f wal/insertDataDb2Newstab.json -y " % binPath) + query_pid1 = int(subprocess.getstatusoutput('ps aux|grep taosd |grep -v "grep"|awk \'{print $2}\'')[1]) + print(query_pid1) + tdSql.execute("use db2") + tdSql.execute("drop table if exists stb1_0") + tdSql.execute("drop table if exists stb1_1") + tdSql.execute("insert into stb0_0 values(1614218412000,8637,78.861045,'R','bf3')(1614218422000,8637,98.861045,'R','bf3')") + tdSql.execute("alter table db2.stb0 add column c4 int") + tdSql.execute("alter table db2.stb0 drop column c2") + tdSql.execute("alter table db2.stb0 add tag t3 int;") + tdSql.execute("alter table db2.stb0 drop tag t1") + tdSql.execute("create table if not exists stb2_0 (ts timestamp, c0 int, c1 float) ") + tdSql.execute("insert into stb2_0 values(1614218412000,8637,78.861045)") + tdSql.execute("alter table stb2_0 add column c2 binary(4)") + tdSql.execute("alter table stb2_0 drop column c1") + tdSql.execute("insert into stb2_0 values(1614218422000,8638,'R')") + + # stop taosd and compact wal file + tdDnodes.stop(1) + sleep(10) + os.system("nohup %s/taosd --compact-mnode-wal -c %s/sim/dnode1/cfg/ & " %(binPath,testPath) ) + sleep(5) + assert os.path.exists(walFilePath) , "%s is not generated, compact didn't take effect " % walFilePath + + # use new wal file to start taosd + tdDnodes.start(1) + sleep(5) + tdSql.execute("reset query cache") + query_pid2 = int(subprocess.getstatusoutput('ps aux|grep taosd |grep -v "grep"|awk \'{print $2}\'')[1]) + print(query_pid2) + + # verify that the data is correct + tdSql.execute("use db2") + tdSql.query("select count (tbname) from stb0") + tdSql.checkData(0, 0, 1) + tdSql.query("select count (tbname) from stb1") + tdSql.checkRows(0) + tdSql.query("select count(*) from stb0_0") + tdSql.checkData(0, 0, 2) + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 2) + tdSql.query("select count(*) from stb2_0") + tdSql.checkData(0, 0, 2) + + # delete useless file + testcaseFilename = os.path.split(__file__)[-1] + os.system("rm -rf ./insert_res.txt") + os.system("rm -rf wal/%s.sql" % testcaseFilename) + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/wal/sdbCompCluster.py b/tests/pytest/wal/sdbCompCluster.py new file mode 100644 index 0000000000000000000000000000000000000000..4fa84817ec01c9e5adfdb4a76bc29a4a6c49abfc --- /dev/null +++ b/tests/pytest/wal/sdbCompCluster.py @@ -0,0 +1,135 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import os +import sys +sys.path.insert(0, os.getcwd()) +from util.log import * +from util.sql import * +from util.dnodes import * +import taos +import threading + + +class TwoClients: + def initConnection(self): + self.host = "chenhaoran02" + self.user = "root" + self.password = "taosdata" + self.config = "/etc/taos/" + self.port =6030 + self.rowNum = 10 + self.ts = 1537146000000 + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def run(self): + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + walFilePath = "/var/lib/taos/mnode_bak/wal/" + + # new taos client + conn1 = taos.connect(host=self.host, user=self.user, password=self.password, config=self.config ) + print(conn1) + cur1 = conn1.cursor() + tdSql.init(cur1, True) + + # new db and insert data + os.system("rm -rf /var/lib/taos/mnode_bak/") + os.system("rm -rf /var/lib/taos/mnode_temp/") + tdSql.execute("drop database if exists db2") + os.system("%staosdemo -f wal/insertDataDb1.json -y " % binPath) + tdSql.execute("drop database if exists db1") + os.system("%staosdemo -f wal/insertDataDb2.json -y " % binPath) + tdSql.execute("drop table if exists db2.stb0") + os.system("%staosdemo -f wal/insertDataDb2Newstab.json -y " % binPath) + query_pid1 = int(subprocess.getstatusoutput('ps aux|grep taosd |grep -v "grep"|awk \'{print $2}\'')[1]) + print(query_pid1) + tdSql.execute("use db2") + tdSql.execute("drop table if exists stb1_0") + tdSql.execute("drop table if exists stb1_1") + tdSql.execute("insert into stb0_0 values(1614218412000,8637,78.861045,'R','bf3')(1614218422000,8637,98.861045,'R','bf3')") + tdSql.execute("alter table db2.stb0 add column col4 int") + tdSql.execute("alter table db2.stb0 drop column col2") + tdSql.execute("alter table db2.stb0 add tag t3 int") + tdSql.execute("alter table db2.stb0 drop tag t1") + tdSql.execute("create table if not exists stb2_0 (ts timestamp, col0 int, col1 float) ") + tdSql.execute("insert into stb2_0 values(1614218412000,8637,78.861045)") + tdSql.execute("alter table stb2_0 add column col2 binary(4)") + tdSql.execute("alter table stb2_0 drop column col1") + tdSql.execute("insert into stb2_0 values(1614218422000,8638,'R')") + + # stop taosd and compact wal file + os.system("ps -ef |grep taosd |grep -v 'grep' |awk '{print $2}'|xargs kill -2") + sleep(10) + os.system("nohup taosd --compact-mnode-wal -c /etc/taos & ") + sleep(10) + os.system("nohup /usr/bin/taosd > /dev/null 2>&1 &") + sleep(4) + tdSql.execute("reset query cache") + query_pid2 = int(subprocess.getstatusoutput('ps aux|grep taosd |grep -v "grep"|awk \'{print $2}\'')[1]) + print(query_pid2) + assert os.path.exists(walFilePath) , "%s is not generated " % walFilePath + + # new taos connecting to server + conn2 = taos.connect(host=self.host, user=self.user, password=self.password, config=self.config ) + print(conn2) + cur2 = conn2.cursor() + tdSql.init(cur2, True) + + # use new wal file to start up tasod + tdSql.query("show databases") + for i in range(tdSql.queryRows): + if tdSql.queryResult[i][0]=="db2": + assert tdSql.queryResult[i][4]==1 , "replica is wrong" + tdSql.execute("use db2") + tdSql.query("select count (tbname) from stb0") + tdSql.checkData(0, 0, 1) + tdSql.query("select count (tbname) from stb1") + tdSql.checkRows(0) + tdSql.query("select count(*) from stb0_0") + tdSql.checkData(0, 0, 2) + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 2) + tdSql.query("select count(*) from stb2_0") + tdSql.checkData(0, 0, 2) + tdSql.query("select * from stb2_0") + tdSql.checkData(1, 2, 'R') + + # delete useless file + testcaseFilename = os.path.split(__file__)[-1] + os.system("rm -rf ./insert_res.txt") + os.system("rm -rf wal/%s.sql" % testcaseFilename ) + +clients = TwoClients() +clients.initConnection() +# clients.getBuildPath() +clients.run() \ No newline at end of file diff --git a/tests/pytest/wal/sdbCompClusterReplica2.py b/tests/pytest/wal/sdbCompClusterReplica2.py new file mode 100644 index 0000000000000000000000000000000000000000..ba80e3864aed27c091dd5ec72ca9f09ea2c36126 --- /dev/null +++ b/tests/pytest/wal/sdbCompClusterReplica2.py @@ -0,0 +1,145 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import os +import sys +sys.path.insert(0, os.getcwd()) +from util.log import * +from util.sql import * +from util.dnodes import * +import taos +import threading + + +class TwoClients: + def initConnection(self): + self.host = "chenhaoran02" + self.user = "root" + self.password = "taosdata" + self.config = "/etc/taos/" + self.port =6030 + self.rowNum = 10 + self.ts = 1537146000000 + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def run(self): + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + walFilePath = "/var/lib/taos/mnode_bak/wal/" + + # new taos client + conn1 = taos.connect(host=self.host, user=self.user, password=self.password, config=self.config ) + print(conn1) + cur1 = conn1.cursor() + tdSql.init(cur1, True) + + # new db and insert data + os.system("rm -rf /var/lib/taos/mnode_bak/") + os.system("rm -rf /var/lib/taos/mnode_temp/") + tdSql.execute("drop database if exists db2") + os.system("%staosdemo -f wal/insertDataDb1Replica2.json -y " % binPath) + tdSql.execute("drop database if exists db1") + os.system("%staosdemo -f wal/insertDataDb2Replica2.json -y " % binPath) + tdSql.execute("drop table if exists db2.stb0") + os.system("%staosdemo -f wal/insertDataDb2NewstabReplica2.json -y " % binPath) + query_pid1 = int(subprocess.getstatusoutput('ps aux|grep taosd |grep -v "grep"|awk \'{print $2}\'')[1]) + print(query_pid1) + tdSql.execute("use db2") + tdSql.execute("drop table if exists stb1_0") + tdSql.execute("drop table if exists stb1_1") + tdSql.execute("insert into stb0_0 values(1614218412000,8637,78.861045,'R','bf3')(1614218422000,8637,98.861045,'R','bf3')") + tdSql.execute("alter table db2.stb0 add column col4 int") + tdSql.execute("alter table db2.stb0 drop column col2") + tdSql.execute("alter table db2.stb0 add tag t3 int") + tdSql.execute("alter table db2.stb0 drop tag t1") + tdSql.execute("create table if not exists stb2_0 (ts timestamp, col0 int, col1 float) ") + tdSql.execute("insert into stb2_0 values(1614218412000,8637,78.861045)") + tdSql.execute("alter table stb2_0 add column col2 binary(4)") + tdSql.execute("alter table stb2_0 drop column col1") + tdSql.execute("insert into stb2_0 values(1614218422000,8638,'R')") + tdSql.execute("drop dnode chenhaoran02") + sleep(10) + os.system("rm -rf /var/lib/taos/*") + print("clear dnode chenhaoran02'data files") + os.system("nohup /usr/bin/taosd > /dev/null 2>&1 &") + print("start taosd") + sleep(10) + tdSql.execute("reset query cache ;") + tdSql.execute("create dnode chenhaoran02 ;") + + + # stop taosd and compact wal file + os.system("ps -ef |grep taosd |grep -v 'grep' |awk '{print $2}'|xargs kill -2") + sleep(10) + os.system("nohup taosd --compact-mnode-wal -c /etc/taos & ") + sleep(10) + os.system("nohup /usr/bin/taosd > /dev/null 2>&1 &") + sleep(4) + tdSql.execute("reset query cache") + query_pid2 = int(subprocess.getstatusoutput('ps aux|grep taosd |grep -v "grep"|awk \'{print $2}\'')[1]) + print(query_pid2) + assert os.path.exists(walFilePath) , "%s is not generated " % walFilePath + + # new taos connecting to server + conn2 = taos.connect(host=self.host, user=self.user, password=self.password, config=self.config ) + print(conn2) + cur2 = conn2.cursor() + tdSql.init(cur2, True) + + # use new wal file to start up tasod + tdSql.query("show databases") + for i in range(tdSql.queryRows): + if tdSql.queryResult[i][0]=="db2": + assert tdSql.queryResult[i][4]==2 , "replica is wrong" + tdSql.execute("use db2") + tdSql.query("select count (tbname) from stb0") + tdSql.checkData(0, 0, 1) + tdSql.query("select count (tbname) from stb1") + tdSql.checkRows(0) + tdSql.query("select count(*) from stb0_0") + tdSql.checkData(0, 0, 2) + tdSql.query("select count(*) from stb0") + tdSql.checkData(0, 0, 2) + tdSql.query("select count(*) from stb2_0") + tdSql.checkData(0, 0, 2) + tdSql.query("select * from stb2_0") + tdSql.checkData(1, 2, 'R') + + # delete useless file + testcaseFilename = os.path.split(__file__)[-1] + os.system("rm -rf ./insert_res.txt") + os.system("rm -rf wal/%s.sql" % testcaseFilename ) + +clients = TwoClients() +clients.initConnection() +# clients.getBuildPath() +clients.run() diff --git a/tests/robust/cluster.sh b/tests/robust/cluster.sh new file mode 100755 index 0000000000000000000000000000000000000000..b291fb4d9ea229c4620004a0305b06a08994a99e --- /dev/null +++ b/tests/robust/cluster.sh @@ -0,0 +1,334 @@ +#!/bin/bash +stty erase '^H' +stty erase '^?' + +# 运行前需要安装expect; apt install expect +# 运行方式: +# ./cluster.sh -c xxx.cfg +# cfg文件内格式: 每行代表一个节点 第一列为external ip、第二列为密码、第三列为用户名、第四列为hostname、第五列为interal ip +# 注意:列与列直接用空格隔开 +# 例子: +# 51.143.97.155 tbase125! root node5 10.2.0.10 +# 20.94.253.116 tbase125! root node2 10.2.0.12 +# 20.94.250.236 tbase125! root node3 10.2.0.13 +# 20.98.72.51 tbase125! root node4 10.2.0.14 + +menu(){ + echo "==============================" + echo "-------------Target-----------" + echo "==============================" + echo "1 cluster" + echo "==============================" + echo "2 dnode" + echo "==============================" + echo "3 arbitrator" + echo "==============================" + echo "4 alter replica" + echo "==============================" + echo "5 exit" + echo "==============================" +} + +cluster_menu(){ + echo "==============================" + echo "----------Operation-----------" + echo "==============================" + echo "1 start cluster" + echo "==============================" + echo "2 stop cluster" + echo "==============================" + echo "3 exit" + echo "==============================" +} + +dnode_menu(){ + echo "==============================" + echo "----------Operation-----------" + echo "==============================" + echo "1 start dnode" + echo "==============================" + echo "2 stop dnode" + echo "==============================" + echo "3 add dnode" + echo "==============================" + echo "4 drop dnode" + echo "==============================" + echo "5 exit" + echo "==============================" +} + +arbitrator_menu(){ + echo "==============================" + echo "----------Operation-----------" + echo "==============================" + echo "1 start arbitrator" + echo "==============================" + echo "2 stop arbitrator" + echo "==============================" + echo "3 exit" + echo "==============================" +} + +print_cfg() { + echo "==============================" + echo "-------Configure file---------" + echo "==============================" + echo "Id | IP address | hostname" + i=1 + while read line || [[ -n ${line} ]] + do + arr=($line) + echo " $i | ${arr[0]} | ${arr[3]}" + i=`expr $i + 1`; + done < $1 + echo "==============================" +} + +update(){ + expect -c " + set timeout -1; + spawn ssh $3@$1; + expect { + *yes/no* { send \"yes\r\"; exp_continue } + *assword:* { send \"$2\r\" } + } + expect { + *#* { send \"systemctl $4 taosd\r\" } + } + expect { + *#* { send \"exit\r\" } + } + expect eof; + " + echo -e "\033[32mdnode successfully $4 \033[0m" +} + +update_dnode(){ + i=1 + while read line || [[ -n ${line} ]] + do + if [[ $1 -eq $i ]]; then + arr=($line) + update ${arr[0]} ${arr[1]} ${arr[2]} $2 + break; + fi + i=`expr $i + 1`; + done < $3 +} + +add_hosts() { + expect -c " + set timeout -1; + spawn ssh $3@$1; + expect { + *yes/no* { send \"yes\r\"; exp_continue } + *assword:* { send \"$2\r\" } + } + expect { + *#* { send \"echo $4 $5 >> /etc/hosts\r\" } + } + expect { + *#* { send \"exit\r\" } + } + expect eof; + " + echo -e "\033[32mSuccessfully add to /etc/hosts in $1\033[0m" +} + +remove_hosts() { + expect -c " + set timeout -1; + spawn ssh $3@$1; + expect { + *yes/no* { send \"yes\r\"; exp_continue } + *assword:* { send \"$2\r\" } + } + expect { + *#* { send \"sed -i '/$4/d\' /etc/hosts\r\" } + } + expect { + *#* { send \"exit\r\" } + } + expect eof; + " + echo -e "\033[32mSuccessfully remove from /etc/hosts in $1\033[0m" +} + +remove_varlibtaos() { + expect -c " + set timeout -1; + spawn ssh $3@$1; + expect { + *yes/no* { send \"yes\r\"; exp_continue } + *assword:* { send \"$2\r\" } + } + expect { + *#* { send \"rm -rf /var/lib/taos/*\r\" } + } + expect { + *#* { send \"exit\r\" } + } + expect eof; + " + echo -e "\033[32mSuccessfully remove /var/lib/taos/* in $1\033[0m" +} + +scp_cfg() { + expect -c " + set timeout -1; + spawn scp /etc/taos/taos.cfg $3@$1:/etc/taos; + expect { + *yes/no* { send \"yes\r\"; exp_continue } + *assword:* { send \"$2\r\" } + } + expect eof; + " + echo -e "\033[32mSuccessfully scp /etc/taos/taos.cfg to $1\033[0m" +} + +manage_dnode(){ + i=1 + while read line || [[ -n ${line} ]] + do + if [[ $1 -eq $i ]]; then + arr=($line) + scp_cfg ${arr[0]} ${arr[1]} ${arr[2]} + ip=${arr[0]} + pd=${arr[1]} + user=${arr[2]} + j=1 + while read line2 || [[ -n ${line2} ]] + do + arr2=($line2) + if [[ $1 -ne $j ]]; then + if [ $3 == "create" ];then + echo "$3" + add_hosts $ip $pd $user ${arr2[4]} ${arr2[3]} + else + remove_hosts $ip $pd $user ${arr2[4]} ${arr2[3]} + fi + fi + j=`expr $j + 1`; + done < $2 + remove_varlibtaos $ip $pd $user + if [ $3 == "create" ];then + update $ip $pd $user "start" + else + update $ip $pd $user "stop" + fi + taos -s "$3 dnode \"${arr[3]}:6030\"" + break; + fi + i=`expr $i + 1`; + done < $2 + echo -e "\033[32mSuccessfully $3 dnode id $1\033[0m" +} + +update_cluster() { + while read line || [[ -n ${line} ]] + do + arr=($line) + if [ $1 == "start" ]; then + scp_cfg ${arr[0]} ${arr[1]} ${arr[2]} + fi + update ${arr[0]} ${arr[1]} ${arr[2]} $1 + done < $2 +} + +while : +do + clear + menu + read -p "select mode: " n + case $n in + 1) + clear + print_cfg $2 + cluster_menu + read -p "select operation: " c + case $c in + 1) + update_cluster "start" $2 + break + ;; + 2) + update_cluster "stop" $2 + break + ;; + 3) + break + ;; + esac + ;; + 2) + clear + print_cfg $2 + dnode_menu + read -p "select operation: " d + case $d in + 1) + clear + print_cfg $2 + read -p "select dnode: " id + update_dnode $id "start" $2 + break + ;; + 2) + clear + print_cfg $2 + read -p "select dnode: " id + update_dnode $id "stop" $2 + break + ;; + 3) + clear + print_cfg $2 + read -p "select dnode: " id + manage_dnode $id $2 "create" + break + ;; + 4) + clear + print_cfg $2 + read -p "select dnode: " id + manage_dnode $id $2 "drop" + break + ;; + 5) + break + ;; + esac + ;; + 3) + clear + arbitrator_menu + read -p "select operation: " m + case $m in + 1) + nohup /usr/local/taos/bin/tarbitrator >/dev/null 2>&1 & + echo -e "\033[32mSuccessfully start arbitrator $3 \033[0m" + break + ;; + 2) + var=`ps -ef | grep tarbitrator | awk '{print $2}' | head -n 1` + kill -9 $var + echo -e "\033[32mSuccessfully stop arbitrator $3 \033[0m" + break + ;; + 3) + break + ;; + esac + ;; + 4) + read -p "Enter replica number: " rep + read -p "Enter database name: " db + taos -s "alter database $db replica $rep" + echo -e "\033[32mSuccessfully change $db's replica to $rep \033[0m" + break + ;; + 5) + break + ;; + esac +done diff --git a/tests/robust/makefile b/tests/robust/makefile new file mode 100644 index 0000000000000000000000000000000000000000..c98469498f9de31f423e5d8cf19462f92d3e0b8f --- /dev/null +++ b/tests/robust/makefile @@ -0,0 +1,8 @@ +NAME=robust +CFLAGS = -O3 -g -Wall -Wno-deprecated -fPIC -Wno-unused-result -Wconversion -Wno-char-subscripts -D_REENTRANT -Wno-format -DLINUX -msse4.2 -Wno-unused-function -D_M_X64 -std=gnu99 + +all: + gcc $(CFLAGS) ./$(NAME).c -o $(NAME) -ltaos -lpthread + +clean: + rm $(NAME) \ No newline at end of file diff --git a/tests/robust/monitor.sh b/tests/robust/monitor.sh new file mode 100755 index 0000000000000000000000000000000000000000..4fc1fed75275f87eb184ed34234fdb04a7a5e312 --- /dev/null +++ b/tests/robust/monitor.sh @@ -0,0 +1,8 @@ +while : +do + dlog=`taos -s "show dnodes"` + mlog=`taos -s "show mnodes"` + echo "$dlog" | tee -a dnode.log + echo "$mlog" | tee -a mnode.log + sleep 1s +done \ No newline at end of file diff --git a/tests/robust/robust.c b/tests/robust/robust.c new file mode 100644 index 0000000000000000000000000000000000000000..20abef6b306041f94b3474cbe6c201783bf81a87 --- /dev/null +++ b/tests/robust/robust.c @@ -0,0 +1,260 @@ +#include +#include +#include +#include +#include +#include +#include + +typedef struct { + char querySQL[256]; + int client; + int stable; + int table; + unsigned interval; + int insert; + int create; + int query; +} ProArgs; + +typedef struct { + pthread_t pid; + int threadId; + void* taos; +} ThreadObj; + +static ProArgs arguments; +void parseArg(int argc, char *argv[]); +void create(); +void createImp(void *param); +void start(); +void insertImp(void *param); +void queryImp(void *param); + +int64_t getTimeStampMs() { + struct timeval systemTime; + gettimeofday(&systemTime, NULL); + return (int64_t)systemTime.tv_sec * 1000L + (int64_t)systemTime.tv_usec / 1000; +} + +void parseArg(int argc, char *argv[]) { + arguments.stable = 100000; + arguments.table = 50; + arguments.client = 16; + arguments.interval = 1; + sprintf(arguments.querySQL, "select count(*) from"); + for (int i = 1; i < argc; ++i) { + if (strcmp(argv[i], "-stable") == 0) { + if (i < argc - 1) { + arguments.stable = atoi(argv[++i]); + } else { + fprintf(stderr, "'-stable' requires a parameter, default:%d\n", arguments.stable); + } + } else if (strcmp(argv[i], "-table") == 0) { + if (i < argc - 1) { + arguments.table = atoi(argv[++i]); + } else { + fprintf(stderr, "'-table' requires a parameter, default:%d\n", arguments.table); + } + } else if (strcmp(argv[i], "-client") == 0) { + if (i < argc - 1) { + arguments.client = atoi(argv[++i]); + } else { + fprintf(stderr, "'-client' requires a parameter, default:%d\n", arguments.client); + } + } else if (strcmp(argv[i], "-sql") == 0) { + if (i < argc - 1) { + strcpy(arguments.querySQL,argv[++i]); + } else { + fprintf(stderr, "'-sql' requires a parameter, default:%d\n", arguments.querySQL); + } + } else if (strcmp(argv[i], "-insert") == 0) { + arguments.insert = 1; + } else if (strcmp(argv[i], "-create") == 0) { + arguments.create = 1; + } else if (strcmp(argv[i], "-query") == 0) { + arguments.query = 1; + } + } +} + +void create() { + int64_t st = getTimeStampMs(); + void *taos = taos_connect("127.0.0.1", "root", "taosdata", NULL, 0); + if (taos == NULL) { + printf("TDengine error: failed to connect\n"); + exit(EXIT_FAILURE); + } + TAOS_RES *result = taos_query(taos, "drop database if exists db"); + if (result == NULL || taos_errno(result) != 0) { + printf("In line:%d, failed to execute sql, reason:%s\n", __LINE__, taos_errstr(result)); + taos_free_result(result); + exit(EXIT_FAILURE); + } + taos_free_result(result); + int64_t elapsed = getTimeStampMs() - st; + printf("--- spend %ld ms to drop database db\n", elapsed); + st = getTimeStampMs(); + result = taos_query(taos, "create database if not exists db"); + if (result == NULL || taos_errno(result) != 0) { + printf("In line:%d, failed to execute sql, reason:%s\n", __LINE__, taos_errstr(result)); + taos_free_result(result); + exit(EXIT_FAILURE); + } + taos_free_result(result); + elapsed = getTimeStampMs() - st; + printf("--- spend %ld ms to create database db\n", elapsed); + st = getTimeStampMs(); + start(); + printf("--- Spend %ld ms to create %d super tables and each %d tables\n", elapsed, arguments.stable, arguments.table); +} + +void createImp(void *param) { + char command[256] = "\0"; + int sqlLen = 0; + int count = 0; + char *sql = calloc(1, 1024*1024); + ThreadObj *pThread = (ThreadObj *)param; + printf("Thread %d start create super table s%d to s%d\n", pThread->threadId, (pThread->threadId - 1) * arguments.stable / arguments.client, pThread->threadId * arguments.stable / arguments.client - 1); + for (int i = (pThread->threadId - 1) * arguments.stable / arguments.client; i < pThread->threadId * arguments.stable / arguments.client; i++) { + sprintf(command, "create table if not exists db.s%d(ts timestamp, c1 int, c2 int, c3 int) TAGS (id int)", i); + TAOS_RES *result = taos_query(pThread->taos, command); + if (result == NULL || taos_errno(result) != 0) { + printf("In line:%d, failed to execute sql:%s, reason:%s\n", __LINE__, command, taos_errstr(result)); + taos_free_result(result); + return; + } + taos_free_result(result); + result = taos_query(pThread->taos, "use db"); + if (result == NULL || taos_errno(result) != 0) { + printf("In line:%d, failed to execute sql, reason:%s\n", __LINE__, taos_errstr(result)); + taos_free_result(result); + return; + } + taos_free_result(result); + sqlLen = sprintf(sql, "create table if not exists "); + count = 0; + for (int j = 0; j < arguments.table; j++) { + sqlLen += sprintf(sql + sqlLen, " s%d_%d USING s%d TAGS (%d)", i, j, i, j); + if ((j + 1) % arguments.table == 0) { + result = taos_query(pThread->taos, sql); + if (result == NULL || taos_errno(result) != 0) { + printf("In line:%d, failed to execute sql, reason:%s\n", __LINE__, taos_errstr(result)); + taos_free_result(result); + return; + } + taos_free_result(result); + printf("Thread %d created table s%d_%d to s%d_%d\n", pThread->threadId, i, count, i, j); + count = j; + sqlLen = sprintf(sql, "create table if not exists "); + } + } + } +} + +void start() { + ThreadObj *threads = calloc((size_t)arguments.client, sizeof(ThreadObj)); + for (int i = 0; i < arguments.client; i++) { + ThreadObj *pthread = threads + i; + pthread_attr_t thattr; + pthread->threadId = i + 1; + pthread->taos = taos_connect("127.0.0.1", "root", "taosdata", NULL, 0); + pthread_attr_init(&thattr); + pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_JOINABLE); + if (arguments.create) { + pthread_create(&pthread->pid, &thattr, (void *(*)(void *))createImp, pthread); + } else if (arguments.insert) { + pthread_create(&pthread->pid, &thattr, (void *(*)(void *))insertImp, pthread); + } else if (arguments.query) { + pthread_create(&pthread->pid, &thattr, (void *(*)(void *))queryImp, pthread); + } + } + for (int i = 0; i < arguments.client; i++) { + pthread_join(threads[i].pid, NULL); + } + free(threads); +} + +void insertImp(void *param) { + int count = 0; + ThreadObj *pThread = (ThreadObj *)param; + printf("Thread %d start insert data\n", pThread->threadId); + int sqlLen = 0; + char *sql = calloc(1, 1024*1024); + TAOS_RES *result = taos_query(pThread->taos, "use db"); + if (result == NULL || taos_errno(result) != 0) { + printf("In line:%d, failed to execute sql, reason:%s\n", __LINE__, taos_errstr(result)); + taos_free_result(result); + return; + } + taos_free_result(result); + int64_t test_time = getTimeStampMs(); + while (true) { + sqlLen = sprintf(sql, "insert into"); + for (int i = (pThread->threadId - 1) * arguments.stable / arguments.client; i < pThread->threadId * arguments.stable / arguments.client; i++) { + for (int j = 0; j < arguments.table; j++) { + sqlLen += sprintf(sql + sqlLen, " s%d_%d values (%ld, %d, %d, %d)", i, j, test_time, rand(), rand(), rand()); + count++; + if ( (1048576 - sqlLen) < 49151 || i == (pThread->threadId * arguments.stable / arguments.client - 1)) { + result = taos_query(pThread->taos, sql); + printf("Thread %d already insert %d rows\n", pThread->threadId, count); + if (result == NULL || taos_errno(result) != 0) { + printf("In line:%d, failed to execute sql, reason:%s\n", __LINE__, taos_errstr(result)); + taos_free_result(result); + return; + } + taos_free_result(result); + sqlLen = sprintf(sql, "insert into"); + } + } + } + test_time += 1000*arguments.interval; + } +} + +void queryImp(void *param) { + ThreadObj *pThread = (ThreadObj *)param; + printf("Thread %d start query\n", pThread->threadId); + int sqlLen = 0; + char *sql = calloc(1, 1024*1024); + TAOS_RES *result = taos_query(pThread->taos, "use db"); + if (result == NULL || taos_errno(result) != 0) { + printf("In line:%d, failed to execute sql, reason:%s\n", __LINE__, taos_errstr(result)); + taos_free_result(result); + return; + } + taos_free_result(result); + while (true) { + for (int i = (pThread->threadId - 1) * arguments.stable / arguments.client; i < pThread->threadId * arguments.stable / arguments.client; i++) { + sqlLen = sprintf(sql, arguments.querySQL); + sqlLen += sprintf(sql + sqlLen, " s%d", i); + result = taos_query(pThread->taos, sql); + if (result == NULL || taos_errno(result) != 0) { + printf("In line:%d, failed to execute sql: %s, reason:%s\n", __LINE__, sql, taos_errstr(result)); + taos_free_result(result); + return; + } + int num_fields = taos_field_count(result); + TAOS_FIELD *fields = taos_fetch_fields(result); + TAOS_ROW row = NULL; + while ((row = taos_fetch_row(result))) { + char temp[16000] = {0}; + int len = taos_print_row(temp, row, fields, num_fields); + len += sprintf(temp + len, "\n"); + printf("Thread %d query result: %s\n", pThread->threadId, temp); + } + taos_free_result(result); + sleep(arguments.interval); + } + } + +} + +int main(int argc, char *argv[]) { + parseArg(argc, argv); + if (arguments.insert || arguments.query || arguments.create) { + start(); + } else { + printf("choose one argument: \n1) -create\n2) -insert\n3) -query\n"); + } +} \ No newline at end of file diff --git a/tests/script/api/batchprepare.c b/tests/script/api/batchprepare.c new file mode 100644 index 0000000000000000000000000000000000000000..0281c4e9ee1554462dab9875c624beefa3ce8ad9 --- /dev/null +++ b/tests/script/api/batchprepare.c @@ -0,0 +1,5214 @@ +// TAOS standard API example. The same syntax as MySQL, but only a subet +// to compile: gcc -o prepare prepare.c -ltaos + +#include +#include +#include +#include "taos.h" +#include +#include +#include + +typedef struct { + TAOS *taos; + int idx; +}T_par; + +void taosMsleep(int mseconds); + +unsigned long long getCurrentTime(){ + struct timeval tv; + if (gettimeofday(&tv, NULL) != 0) { + perror("Failed to get current time in ms"); + exit(EXIT_FAILURE); + } + + return (uint64_t)tv.tv_sec * 1000000ULL + (uint64_t)tv.tv_usec; +} + + + + + +int stmt_scol_func1(TAOS_STMT *stmt) { + struct { + int64_t ts; + int8_t b; + int8_t v1; + int16_t v2; + int32_t v4; + int64_t v8; + float f4; + double f8; + char bin[40]; + char blob[80]; + } v = {0}; + + TAOS_BIND params[10]; + params[0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[0].buffer_length = sizeof(v.ts); + params[0].buffer = &v.ts; + params[0].length = ¶ms[0].buffer_length; + params[0].is_null = NULL; + + params[1].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[1].buffer_length = sizeof(v.v1); + params[1].buffer = &v.v1; + params[1].length = ¶ms[1].buffer_length; + params[1].is_null = NULL; + + params[2].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[2].buffer_length = sizeof(v.v2); + params[2].buffer = &v.v2; + params[2].length = ¶ms[2].buffer_length; + params[2].is_null = NULL; + + params[3].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[3].buffer_length = sizeof(v.f4); + params[3].buffer = &v.f4; + params[3].length = ¶ms[3].buffer_length; + params[3].is_null = NULL; + + params[4].buffer_type = TSDB_DATA_TYPE_BINARY; + params[4].buffer_length = sizeof(v.bin); + params[4].buffer = v.bin; + params[4].length = ¶ms[4].buffer_length; + params[4].is_null = NULL; + + params[5].buffer_type = TSDB_DATA_TYPE_BINARY; + params[5].buffer_length = sizeof(v.bin); + params[5].buffer = v.bin; + params[5].length = ¶ms[5].buffer_length; + params[5].is_null = NULL; + + char *sql = "insert into ? (ts, v1,v2,f4,bin,bin2) values(?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + } + + for (int zz = 0; zz < 10; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code); + exit(1); + } + v.ts = 1591060628000 + zz * 10; + for (int i = 0; i < 10; ++i) { + v.ts += 1; + + v.b = (int8_t)(i+zz*10) % 2; + v.v1 = (int8_t)(i+zz*10); + v.v2 = (int16_t)((i+zz*10) * 2); + v.v4 = (int32_t)((i+zz*10) * 4); + v.v8 = (int64_t)((i+zz*10) * 8); + v.f4 = (float)((i+zz*10) * 40); + v.f8 = (double)((i+zz*10) * 80); + for (int j = 0; j < sizeof(v.bin) - 1; ++j) { + v.bin[j] = (char)((i)%10 + '0'); + } + + taos_stmt_bind_param(stmt, params); + taos_stmt_add_batch(stmt); + } + } + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + + return 0; +} + + + +int stmt_scol_func2(TAOS_STMT *stmt) { + struct { + int64_t ts; + int8_t b; + int8_t v1; + int16_t v2; + int32_t v4; + int64_t v8; + float f4; + double f8; + char bin[40]; + char blob[80]; + } v = {0}; + + TAOS_BIND params[10]; + params[0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[0].buffer_length = sizeof(v.ts); + params[0].buffer = &v.ts; + params[0].length = ¶ms[0].buffer_length; + params[0].is_null = NULL; + + params[1].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[1].buffer_length = sizeof(v.v1); + params[1].buffer = &v.v1; + params[1].length = ¶ms[1].buffer_length; + params[1].is_null = NULL; + + params[2].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[2].buffer_length = sizeof(v.v2); + params[2].buffer = &v.v2; + params[2].length = ¶ms[2].buffer_length; + params[2].is_null = NULL; + + params[3].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[3].buffer_length = sizeof(v.f4); + params[3].buffer = &v.f4; + params[3].length = ¶ms[3].buffer_length; + params[3].is_null = NULL; + + params[4].buffer_type = TSDB_DATA_TYPE_BINARY; + params[4].buffer_length = sizeof(v.bin); + params[4].buffer = v.bin; + params[4].length = ¶ms[4].buffer_length; + params[4].is_null = NULL; + + params[5].buffer_type = TSDB_DATA_TYPE_BINARY; + params[5].buffer_length = sizeof(v.bin); + params[5].buffer = v.bin; + params[5].length = ¶ms[5].buffer_length; + params[5].is_null = NULL; + + char *sql = "insert into m0 (ts, v1,v2,f4,bin,bin2) values(?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + } + + for (int zz = 0; zz < 10; zz++) { + v.ts = 1591060628000 + zz * 10; + for (int i = 0; i < 10; ++i) { + v.ts += 1; + + v.b = (int8_t)(i+zz*10) % 2; + v.v1 = (int8_t)(i+zz*10); + v.v2 = (int16_t)((i+zz*10) * 2); + v.v4 = (int32_t)((i+zz*10) * 4); + v.v8 = (int64_t)((i+zz*10) * 8); + v.f4 = (float)((i+zz*10) * 40); + v.f8 = (double)((i+zz*10) * 80); + for (int j = 0; j < sizeof(v.bin) - 1; ++j) { + v.bin[j] = (char)((i)%10 + '0'); + } + + taos_stmt_bind_param(stmt, params); + taos_stmt_add_batch(stmt); + } + } + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + + return 0; +} + + + + +//300 tables 60 records +int stmt_scol_func3(TAOS_STMT *stmt) { + struct { + int64_t *ts; + int8_t b[60]; + int8_t v1[60]; + int16_t v2[60]; + int32_t v4[60]; + int64_t v8[60]; + float f4[60]; + double f8[60]; + char bin[60][40]; + } v = {0}; + + v.ts = malloc(sizeof(int64_t) * 900000 * 60); + + int *lb = malloc(60 * sizeof(int)); + + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * 900000*10); + char* is_null = malloc(sizeof(char) * 60); + char* no_null = malloc(sizeof(char) * 60); + + for (int i = 0; i < 60; ++i) { + lb[i] = 40; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v.b[i] = (int8_t)(i % 2); + v.v1[i] = (int8_t)((i+1) % 2); + v.v2[i] = (int16_t)i; + v.v4[i] = (int32_t)(i+1); + v.v8[i] = (int64_t)(i+2); + v.f4[i] = (float)(i+3); + v.f8[i] = (double)(i+4); + memset(v.bin[i], '0'+i%10, 40); + } + + for (int i = 0; i < 9000000; i+=10) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v.ts[10*i/10]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = 10; + + params[i+1].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v.v1; + params[i+1].length = NULL; + params[i+1].is_null = no_null; + params[i+1].num = 10; + + params[i+2].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[i+2].buffer_length = sizeof(int16_t); + params[i+2].buffer = v.v2; + params[i+2].length = NULL; + params[i+2].is_null = no_null; + params[i+2].num = 10; + + params[i+3].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+3].buffer_length = sizeof(float); + params[i+3].buffer = v.f4; + params[i+3].length = NULL; + params[i+3].is_null = no_null; + params[i+3].num = 10; + + params[i+4].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+4].buffer_length = 40; + params[i+4].buffer = v.bin; + params[i+4].length = lb; + params[i+4].is_null = no_null; + params[i+4].num = 10; + + params[i+5].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+5].buffer_length = 40; + params[i+5].buffer = v.bin; + params[i+5].length = lb; + params[i+5].is_null = no_null; + params[i+5].num = 10; + + } + + int64_t tts = 1591060628000; + for (int i = 0; i < 54000000; ++i) { + v.ts[i] = tts + i; + } + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? (ts, v1,v2,f4,bin,bin2) values(?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + } + + int id = 0; + for (int l = 0; l < 2; l++) { + for (int zz = 0; zz < 300; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code); + } + + taos_stmt_bind_param_batch(stmt, params + id * 10); + taos_stmt_add_batch(stmt); + } + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + + ++id; + } + + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60)); + + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + + return 0; +} + + + +//10 tables 10 records single column bind +int stmt_scol_func4(TAOS_STMT *stmt) { + struct { + int64_t *ts; + int8_t b[60]; + int8_t v1[60]; + int16_t v2[60]; + int32_t v4[60]; + int64_t v8[60]; + float f4[60]; + double f8[60]; + char bin[60][40]; + } v = {0}; + + v.ts = malloc(sizeof(int64_t) * 1000 * 60); + + int *lb = malloc(60 * sizeof(int)); + + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * 1000*10); + char* is_null = malloc(sizeof(char) * 60); + char* no_null = malloc(sizeof(char) * 60); + + for (int i = 0; i < 60; ++i) { + lb[i] = 40; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v.b[i] = (int8_t)(i % 2); + v.v1[i] = (int8_t)((i+1) % 2); + v.v2[i] = (int16_t)i; + v.v4[i] = (int32_t)(i+1); + v.v8[i] = (int64_t)(i+2); + v.f4[i] = (float)(i+3); + v.f8[i] = (double)(i+4); + memset(v.bin[i], '0'+i%10, 40); + } + + for (int i = 0; i < 10000; i+=10) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v.ts[10*i/10]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = 2; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v.b; + params[i+1].length = NULL; + params[i+1].is_null = no_null; + params[i+1].num = 2; + + params[i+2].buffer_type = TSDB_DATA_TYPE_INT; + params[i+2].buffer_length = sizeof(int32_t); + params[i+2].buffer = v.v4; + params[i+2].length = NULL; + params[i+2].is_null = no_null; + params[i+2].num = 2; + + params[i+3].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[i+3].buffer_length = sizeof(int64_t); + params[i+3].buffer = v.v8; + params[i+3].length = NULL; + params[i+3].is_null = no_null; + params[i+3].num = 2; + + params[i+4].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[i+4].buffer_length = sizeof(double); + params[i+4].buffer = v.f8; + params[i+4].length = NULL; + params[i+4].is_null = no_null; + params[i+4].num = 2; + } + + int64_t tts = 1591060628000; + for (int i = 0; i < 60000; ++i) { + v.ts[i] = tts + i; + } + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? (ts,b,v4,v8,f8) values(?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + } + + int id = 0; + for (int l = 0; l < 10; l++) { + for (int zz = 0; zz < 10; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code); + } + + for (int col=0; col < 10; ++col) { + taos_stmt_bind_single_param_batch(stmt, params + id++, col); + } + + taos_stmt_add_batch(stmt); + } + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + } + + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60)); + + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + + return 0; +} + + + +int stmt_func1(TAOS_STMT *stmt) { + struct { + int64_t ts; + int8_t b; + int8_t v1; + int16_t v2; + int32_t v4; + int64_t v8; + float f4; + double f8; + char bin[40]; + char blob[80]; + } v = {0}; + + TAOS_BIND params[10]; + params[0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[0].buffer_length = sizeof(v.ts); + params[0].buffer = &v.ts; + params[0].length = ¶ms[0].buffer_length; + params[0].is_null = NULL; + + params[1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[1].buffer_length = sizeof(v.b); + params[1].buffer = &v.b; + params[1].length = ¶ms[1].buffer_length; + params[1].is_null = NULL; + + params[2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[2].buffer_length = sizeof(v.v1); + params[2].buffer = &v.v1; + params[2].length = ¶ms[2].buffer_length; + params[2].is_null = NULL; + + params[3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[3].buffer_length = sizeof(v.v2); + params[3].buffer = &v.v2; + params[3].length = ¶ms[3].buffer_length; + params[3].is_null = NULL; + + params[4].buffer_type = TSDB_DATA_TYPE_INT; + params[4].buffer_length = sizeof(v.v4); + params[4].buffer = &v.v4; + params[4].length = ¶ms[4].buffer_length; + params[4].is_null = NULL; + + params[5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[5].buffer_length = sizeof(v.v8); + params[5].buffer = &v.v8; + params[5].length = ¶ms[5].buffer_length; + params[5].is_null = NULL; + + params[6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[6].buffer_length = sizeof(v.f4); + params[6].buffer = &v.f4; + params[6].length = ¶ms[6].buffer_length; + params[6].is_null = NULL; + + params[7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[7].buffer_length = sizeof(v.f8); + params[7].buffer = &v.f8; + params[7].length = ¶ms[7].buffer_length; + params[7].is_null = NULL; + + params[8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[8].buffer_length = sizeof(v.bin); + params[8].buffer = v.bin; + params[8].length = ¶ms[8].buffer_length; + params[8].is_null = NULL; + + params[9].buffer_type = TSDB_DATA_TYPE_BINARY; + params[9].buffer_length = sizeof(v.bin); + params[9].buffer = v.bin; + params[9].length = ¶ms[9].buffer_length; + params[9].is_null = NULL; + + int is_null = 1; + + char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + } + + for (int zz = 0; zz < 10; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code); + } + v.ts = 1591060628000 + zz * 10; + for (int i = 0; i < 10; ++i) { + v.ts += 1; + for (int j = 1; j < 10; ++j) { + params[j].is_null = ((i == j) ? &is_null : 0); + } + v.b = (int8_t)(i+zz*10) % 2; + v.v1 = (int8_t)(i+zz*10); + v.v2 = (int16_t)((i+zz*10) * 2); + v.v4 = (int32_t)((i+zz*10) * 4); + v.v8 = (int64_t)((i+zz*10) * 8); + v.f4 = (float)((i+zz*10) * 40); + v.f8 = (double)((i+zz*10) * 80); + for (int j = 0; j < sizeof(v.bin) - 1; ++j) { + v.bin[j] = (char)((i+zz)%10 + '0'); + } + + taos_stmt_bind_param(stmt, params); + taos_stmt_add_batch(stmt); + } + } + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + + return 0; +} + + +int stmt_func2(TAOS_STMT *stmt) { + struct { + int64_t ts; + int8_t b; + int8_t v1; + int16_t v2; + int32_t v4; + int64_t v8; + float f4; + double f8; + char bin[40]; + char blob[80]; + } v = {0}; + + TAOS_BIND params[10]; + params[0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[0].buffer_length = sizeof(v.ts); + params[0].buffer = &v.ts; + params[0].length = ¶ms[0].buffer_length; + params[0].is_null = NULL; + + params[1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[1].buffer_length = sizeof(v.b); + params[1].buffer = &v.b; + params[1].length = ¶ms[1].buffer_length; + params[1].is_null = NULL; + + params[2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[2].buffer_length = sizeof(v.v1); + params[2].buffer = &v.v1; + params[2].length = ¶ms[2].buffer_length; + params[2].is_null = NULL; + + params[3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[3].buffer_length = sizeof(v.v2); + params[3].buffer = &v.v2; + params[3].length = ¶ms[3].buffer_length; + params[3].is_null = NULL; + + params[4].buffer_type = TSDB_DATA_TYPE_INT; + params[4].buffer_length = sizeof(v.v4); + params[4].buffer = &v.v4; + params[4].length = ¶ms[4].buffer_length; + params[4].is_null = NULL; + + params[5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[5].buffer_length = sizeof(v.v8); + params[5].buffer = &v.v8; + params[5].length = ¶ms[5].buffer_length; + params[5].is_null = NULL; + + params[6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[6].buffer_length = sizeof(v.f4); + params[6].buffer = &v.f4; + params[6].length = ¶ms[6].buffer_length; + params[6].is_null = NULL; + + params[7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[7].buffer_length = sizeof(v.f8); + params[7].buffer = &v.f8; + params[7].length = ¶ms[7].buffer_length; + params[7].is_null = NULL; + + params[8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[8].buffer_length = sizeof(v.bin); + params[8].buffer = v.bin; + params[8].length = ¶ms[8].buffer_length; + params[8].is_null = NULL; + + params[9].buffer_type = TSDB_DATA_TYPE_BINARY; + params[9].buffer_length = sizeof(v.bin); + params[9].buffer = v.bin; + params[9].length = ¶ms[9].buffer_length; + params[9].is_null = NULL; + + int is_null = 1; + + char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + } + + for (int l = 0; l < 100; l++) { + for (int zz = 0; zz < 10; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code); + } + v.ts = 1591060628000 + zz * 100 * l; + for (int i = 0; i < zz; ++i) { + v.ts += 1; + for (int j = 1; j < 10; ++j) { + params[j].is_null = ((i == j) ? &is_null : 0); + } + v.b = (int8_t)(i+zz*10) % 2; + v.v1 = (int8_t)(i+zz*10); + v.v2 = (int16_t)((i+zz*10) * 2); + v.v4 = (int32_t)((i+zz*10) * 4); + v.v8 = (int64_t)((i+zz*10) * 8); + v.f4 = (float)((i+zz*10) * 40); + v.f8 = (double)((i+zz*10) * 80); + for (int j = 0; j < sizeof(v.bin) - 1; ++j) { + v.bin[j] = (char)((i+zz)%10 + '0'); + } + + taos_stmt_bind_param(stmt, params); + taos_stmt_add_batch(stmt); + } + } + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + + } + + + return 0; +} + + + + +int stmt_func3(TAOS_STMT *stmt) { + struct { + int64_t ts; + int8_t b; + int8_t v1; + int16_t v2; + int32_t v4; + int64_t v8; + float f4; + double f8; + char bin[40]; + char blob[80]; + } v = {0}; + + TAOS_BIND params[10]; + params[0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[0].buffer_length = sizeof(v.ts); + params[0].buffer = &v.ts; + params[0].length = ¶ms[0].buffer_length; + params[0].is_null = NULL; + + params[1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[1].buffer_length = sizeof(v.b); + params[1].buffer = &v.b; + params[1].length = ¶ms[1].buffer_length; + params[1].is_null = NULL; + + params[2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[2].buffer_length = sizeof(v.v1); + params[2].buffer = &v.v1; + params[2].length = ¶ms[2].buffer_length; + params[2].is_null = NULL; + + params[3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[3].buffer_length = sizeof(v.v2); + params[3].buffer = &v.v2; + params[3].length = ¶ms[3].buffer_length; + params[3].is_null = NULL; + + params[4].buffer_type = TSDB_DATA_TYPE_INT; + params[4].buffer_length = sizeof(v.v4); + params[4].buffer = &v.v4; + params[4].length = ¶ms[4].buffer_length; + params[4].is_null = NULL; + + params[5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[5].buffer_length = sizeof(v.v8); + params[5].buffer = &v.v8; + params[5].length = ¶ms[5].buffer_length; + params[5].is_null = NULL; + + params[6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[6].buffer_length = sizeof(v.f4); + params[6].buffer = &v.f4; + params[6].length = ¶ms[6].buffer_length; + params[6].is_null = NULL; + + params[7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[7].buffer_length = sizeof(v.f8); + params[7].buffer = &v.f8; + params[7].length = ¶ms[7].buffer_length; + params[7].is_null = NULL; + + params[8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[8].buffer_length = sizeof(v.bin); + params[8].buffer = v.bin; + params[8].length = ¶ms[8].buffer_length; + params[8].is_null = NULL; + + params[9].buffer_type = TSDB_DATA_TYPE_BINARY; + params[9].buffer_length = sizeof(v.bin); + params[9].buffer = v.bin; + params[9].length = ¶ms[9].buffer_length; + params[9].is_null = NULL; + + int is_null = 1; + + char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + } + + for (int l = 0; l < 100; l++) { + for (int zz = 0; zz < 10; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code); + } + v.ts = 1591060628000 + zz * 100 * l; + for (int i = 0; i < zz; ++i) { + v.ts += 1; + for (int j = 1; j < 10; ++j) { + params[j].is_null = ((i == j) ? &is_null : 0); + } + v.b = (int8_t)(i+zz*10) % 2; + v.v1 = (int8_t)(i+zz*10); + v.v2 = (int16_t)((i+zz*10) * 2); + v.v4 = (int32_t)((i+zz*10) * 4); + v.v8 = (int64_t)((i+zz*10) * 8); + v.f4 = (float)((i+zz*10) * 40); + v.f8 = (double)((i+zz*10) * 80); + for (int j = 0; j < sizeof(v.bin) - 1; ++j) { + v.bin[j] = (char)((i+zz)%10 + '0'); + } + + taos_stmt_bind_param(stmt, params); + taos_stmt_add_batch(stmt); + } + } + } + + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + + + return 0; +} + + + +//1 tables 10 records +int stmt_funcb_autoctb1(TAOS_STMT *stmt) { + struct { + int64_t *ts; + int8_t b[10]; + int8_t v1[10]; + int16_t v2[10]; + int32_t v4[10]; + int64_t v8[10]; + float f4[10]; + double f8[10]; + char bin[10][40]; + } v = {0}; + + v.ts = malloc(sizeof(int64_t) * 1 * 10); + + int *lb = malloc(10 * sizeof(int)); + + TAOS_BIND *tags = calloc(1, sizeof(TAOS_BIND) * 9 * 1); + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * 1*10); + +// int one_null = 1; + int one_not_null = 0; + + char* is_null = malloc(sizeof(char) * 10); + char* no_null = malloc(sizeof(char) * 10); + + for (int i = 0; i < 10; ++i) { + lb[i] = 40; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v.b[i] = (int8_t)(i % 2); + v.v1[i] = (int8_t)((i+1) % 2); + v.v2[i] = (int16_t)i; + v.v4[i] = (int32_t)(i+1); + v.v8[i] = (int64_t)(i+2); + v.f4[i] = (float)(i+3); + v.f8[i] = (double)(i+4); + memset(v.bin[i], '0'+i%10, 40); + } + + for (int i = 0; i < 10; i+=10) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v.ts[10*i/10]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = 10; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v.b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = 10; + + params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[i+2].buffer_length = sizeof(int8_t); + params[i+2].buffer = v.v1; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = 10; + + params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[i+3].buffer_length = sizeof(int16_t); + params[i+3].buffer = v.v2; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = 10; + + params[i+4].buffer_type = TSDB_DATA_TYPE_INT; + params[i+4].buffer_length = sizeof(int32_t); + params[i+4].buffer = v.v4; + params[i+4].length = NULL; + params[i+4].is_null = is_null; + params[i+4].num = 10; + + params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[i+5].buffer_length = sizeof(int64_t); + params[i+5].buffer = v.v8; + params[i+5].length = NULL; + params[i+5].is_null = is_null; + params[i+5].num = 10; + + params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+6].buffer_length = sizeof(float); + params[i+6].buffer = v.f4; + params[i+6].length = NULL; + params[i+6].is_null = is_null; + params[i+6].num = 10; + + params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[i+7].buffer_length = sizeof(double); + params[i+7].buffer = v.f8; + params[i+7].length = NULL; + params[i+7].is_null = is_null; + params[i+7].num = 10; + + params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+8].buffer_length = 40; + params[i+8].buffer = v.bin; + params[i+8].length = lb; + params[i+8].is_null = is_null; + params[i+8].num = 10; + + params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+9].buffer_length = 40; + params[i+9].buffer = v.bin; + params[i+9].length = lb; + params[i+9].is_null = is_null; + params[i+9].num = 10; + + } + + int64_t tts = 1591060628000; + for (int i = 0; i < 10; ++i) { + v.ts[i] = tts + i; + } + + + for (int i = 0; i < 1; ++i) { + tags[i+0].buffer_type = TSDB_DATA_TYPE_INT; + tags[i+0].buffer = v.v4; + tags[i+0].is_null = &one_not_null; + tags[i+0].length = NULL; + + tags[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + tags[i+1].buffer = v.b; + tags[i+1].is_null = &one_not_null; + tags[i+1].length = NULL; + + tags[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + tags[i+2].buffer = v.v1; + tags[i+2].is_null = &one_not_null; + tags[i+2].length = NULL; + + tags[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + tags[i+3].buffer = v.v2; + tags[i+3].is_null = &one_not_null; + tags[i+3].length = NULL; + + tags[i+4].buffer_type = TSDB_DATA_TYPE_BIGINT; + tags[i+4].buffer = v.v8; + tags[i+4].is_null = &one_not_null; + tags[i+4].length = NULL; + + tags[i+5].buffer_type = TSDB_DATA_TYPE_FLOAT; + tags[i+5].buffer = v.f4; + tags[i+5].is_null = &one_not_null; + tags[i+5].length = NULL; + + tags[i+6].buffer_type = TSDB_DATA_TYPE_DOUBLE; + tags[i+6].buffer = v.f8; + tags[i+6].is_null = &one_not_null; + tags[i+6].length = NULL; + + tags[i+7].buffer_type = TSDB_DATA_TYPE_BINARY; + tags[i+7].buffer = v.bin; + tags[i+7].is_null = &one_not_null; + tags[i+7].length = (uintptr_t *)lb; + + tags[i+8].buffer_type = TSDB_DATA_TYPE_NCHAR; + tags[i+8].buffer = v.bin; + tags[i+8].is_null = &one_not_null; + tags[i+8].length = (uintptr_t *)lb; + } + + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? using stb1 tags(?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + exit(1); + } + + int id = 0; + for (int zz = 0; zz < 1; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname_tags(stmt, buf, tags); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname_tags. code:0x%x\n", code); + } + + taos_stmt_bind_param_batch(stmt, params + id * 10); + taos_stmt_add_batch(stmt); + } + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + + ++id; + + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%u useconds\n", 10, (endtime-starttime)/1000000UL, (endtime-starttime)/(10)); + + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + free(tags); + + return 0; +} + + + + +//1 tables 10 records +int stmt_funcb_autoctb2(TAOS_STMT *stmt) { + struct { + int64_t *ts; + int8_t b[10]; + int8_t v1[10]; + int16_t v2[10]; + int32_t v4[10]; + int64_t v8[10]; + float f4[10]; + double f8[10]; + char bin[10][40]; + } v = {0}; + + v.ts = malloc(sizeof(int64_t) * 1 * 10); + + int *lb = malloc(10 * sizeof(int)); + + TAOS_BIND *tags = calloc(1, sizeof(TAOS_BIND) * 9 * 1); + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * 1*10); + +// int one_null = 1; + int one_not_null = 0; + + char* is_null = malloc(sizeof(char) * 10); + char* no_null = malloc(sizeof(char) * 10); + + for (int i = 0; i < 10; ++i) { + lb[i] = 40; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v.b[i] = (int8_t)(i % 2); + v.v1[i] = (int8_t)((i+1) % 2); + v.v2[i] = (int16_t)i; + v.v4[i] = (int32_t)(i+1); + v.v8[i] = (int64_t)(i+2); + v.f4[i] = (float)(i+3); + v.f8[i] = (double)(i+4); + memset(v.bin[i], '0'+i%10, 40); + } + + for (int i = 0; i < 10; i+=10) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v.ts[10*i/10]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = 10; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v.b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = 10; + + params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[i+2].buffer_length = sizeof(int8_t); + params[i+2].buffer = v.v1; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = 10; + + params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[i+3].buffer_length = sizeof(int16_t); + params[i+3].buffer = v.v2; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = 10; + + params[i+4].buffer_type = TSDB_DATA_TYPE_INT; + params[i+4].buffer_length = sizeof(int32_t); + params[i+4].buffer = v.v4; + params[i+4].length = NULL; + params[i+4].is_null = is_null; + params[i+4].num = 10; + + params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[i+5].buffer_length = sizeof(int64_t); + params[i+5].buffer = v.v8; + params[i+5].length = NULL; + params[i+5].is_null = is_null; + params[i+5].num = 10; + + params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+6].buffer_length = sizeof(float); + params[i+6].buffer = v.f4; + params[i+6].length = NULL; + params[i+6].is_null = is_null; + params[i+6].num = 10; + + params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[i+7].buffer_length = sizeof(double); + params[i+7].buffer = v.f8; + params[i+7].length = NULL; + params[i+7].is_null = is_null; + params[i+7].num = 10; + + params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+8].buffer_length = 40; + params[i+8].buffer = v.bin; + params[i+8].length = lb; + params[i+8].is_null = is_null; + params[i+8].num = 10; + + params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+9].buffer_length = 40; + params[i+9].buffer = v.bin; + params[i+9].length = lb; + params[i+9].is_null = is_null; + params[i+9].num = 10; + + } + + int64_t tts = 1591060628000; + for (int i = 0; i < 10; ++i) { + v.ts[i] = tts + i; + } + + + for (int i = 0; i < 1; ++i) { + tags[i+0].buffer_type = TSDB_DATA_TYPE_INT; + tags[i+0].buffer = v.v4; + tags[i+0].is_null = &one_not_null; + tags[i+0].length = NULL; + + tags[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + tags[i+1].buffer = v.b; + tags[i+1].is_null = &one_not_null; + tags[i+1].length = NULL; + + tags[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + tags[i+2].buffer = v.v1; + tags[i+2].is_null = &one_not_null; + tags[i+2].length = NULL; + + tags[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + tags[i+3].buffer = v.v2; + tags[i+3].is_null = &one_not_null; + tags[i+3].length = NULL; + + tags[i+4].buffer_type = TSDB_DATA_TYPE_BIGINT; + tags[i+4].buffer = v.v8; + tags[i+4].is_null = &one_not_null; + tags[i+4].length = NULL; + + tags[i+5].buffer_type = TSDB_DATA_TYPE_FLOAT; + tags[i+5].buffer = v.f4; + tags[i+5].is_null = &one_not_null; + tags[i+5].length = NULL; + + tags[i+6].buffer_type = TSDB_DATA_TYPE_DOUBLE; + tags[i+6].buffer = v.f8; + tags[i+6].is_null = &one_not_null; + tags[i+6].length = NULL; + + tags[i+7].buffer_type = TSDB_DATA_TYPE_BINARY; + tags[i+7].buffer = v.bin; + tags[i+7].is_null = &one_not_null; + tags[i+7].length = (uintptr_t *)lb; + + tags[i+8].buffer_type = TSDB_DATA_TYPE_NCHAR; + tags[i+8].buffer = v.bin; + tags[i+8].is_null = &one_not_null; + tags[i+8].length = (uintptr_t *)lb; + } + + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? using stb1 tags(1,true,2,3,4,5.0,6.0,'a','b') values(?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + exit(1); + } + + int id = 0; + for (int zz = 0; zz < 1; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname_tags(stmt, buf, tags); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname_tags. code:0x%x\n", code); + } + + taos_stmt_bind_param_batch(stmt, params + id * 10); + taos_stmt_add_batch(stmt); + } + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + + ++id; + + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%u useconds\n", 10, (endtime-starttime)/1000000UL, (endtime-starttime)/(10)); + + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + free(tags); + + return 0; +} + + + + + +//1 tables 10 records +int stmt_funcb_autoctb3(TAOS_STMT *stmt) { + struct { + int64_t *ts; + int8_t b[10]; + int8_t v1[10]; + int16_t v2[10]; + int32_t v4[10]; + int64_t v8[10]; + float f4[10]; + double f8[10]; + char bin[10][40]; + } v = {0}; + + v.ts = malloc(sizeof(int64_t) * 1 * 10); + + int *lb = malloc(10 * sizeof(int)); + + TAOS_BIND *tags = calloc(1, sizeof(TAOS_BIND) * 9 * 1); + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * 1*10); + +// int one_null = 1; + int one_not_null = 0; + + char* is_null = malloc(sizeof(char) * 10); + char* no_null = malloc(sizeof(char) * 10); + + for (int i = 0; i < 10; ++i) { + lb[i] = 40; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v.b[i] = (int8_t)(i % 2); + v.v1[i] = (int8_t)((i+1) % 2); + v.v2[i] = (int16_t)i; + v.v4[i] = (int32_t)(i+1); + v.v8[i] = (int64_t)(i+2); + v.f4[i] = (float)(i+3); + v.f8[i] = (double)(i+4); + memset(v.bin[i], '0'+i%10, 40); + } + + for (int i = 0; i < 10; i+=10) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v.ts[10*i/10]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = 10; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v.b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = 10; + + params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[i+2].buffer_length = sizeof(int8_t); + params[i+2].buffer = v.v1; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = 10; + + params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[i+3].buffer_length = sizeof(int16_t); + params[i+3].buffer = v.v2; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = 10; + + params[i+4].buffer_type = TSDB_DATA_TYPE_INT; + params[i+4].buffer_length = sizeof(int32_t); + params[i+4].buffer = v.v4; + params[i+4].length = NULL; + params[i+4].is_null = is_null; + params[i+4].num = 10; + + params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[i+5].buffer_length = sizeof(int64_t); + params[i+5].buffer = v.v8; + params[i+5].length = NULL; + params[i+5].is_null = is_null; + params[i+5].num = 10; + + params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+6].buffer_length = sizeof(float); + params[i+6].buffer = v.f4; + params[i+6].length = NULL; + params[i+6].is_null = is_null; + params[i+6].num = 10; + + params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[i+7].buffer_length = sizeof(double); + params[i+7].buffer = v.f8; + params[i+7].length = NULL; + params[i+7].is_null = is_null; + params[i+7].num = 10; + + params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+8].buffer_length = 40; + params[i+8].buffer = v.bin; + params[i+8].length = lb; + params[i+8].is_null = is_null; + params[i+8].num = 10; + + params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+9].buffer_length = 40; + params[i+9].buffer = v.bin; + params[i+9].length = lb; + params[i+9].is_null = is_null; + params[i+9].num = 10; + + } + + int64_t tts = 1591060628000; + for (int i = 0; i < 10; ++i) { + v.ts[i] = tts + i; + } + + + for (int i = 0; i < 1; ++i) { + tags[i+0].buffer_type = TSDB_DATA_TYPE_BOOL; + tags[i+0].buffer = v.b; + tags[i+0].is_null = &one_not_null; + tags[i+0].length = NULL; + + tags[i+1].buffer_type = TSDB_DATA_TYPE_SMALLINT; + tags[i+1].buffer = v.v2; + tags[i+1].is_null = &one_not_null; + tags[i+1].length = NULL; + + tags[i+2].buffer_type = TSDB_DATA_TYPE_FLOAT; + tags[i+2].buffer = v.f4; + tags[i+2].is_null = &one_not_null; + tags[i+2].length = NULL; + + tags[i+3].buffer_type = TSDB_DATA_TYPE_BINARY; + tags[i+3].buffer = v.bin; + tags[i+3].is_null = &one_not_null; + tags[i+3].length = (uintptr_t *)lb; + } + + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? using stb1 tags(1,?,2,?,4,?,6.0,?,'b') values(?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + exit(1); + } + + int id = 0; + for (int zz = 0; zz < 1; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname_tags(stmt, buf, tags); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname_tags. code:0x%x\n", code); + } + + taos_stmt_bind_param_batch(stmt, params + id * 10); + taos_stmt_add_batch(stmt); + } + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + + ++id; + + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%u useconds\n", 10, (endtime-starttime)/1000000UL, (endtime-starttime)/(10)); + + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + free(tags); + + return 0; +} + + + + + + + +//1 tables 10 records +int stmt_funcb_autoctb4(TAOS_STMT *stmt) { + struct { + int64_t *ts; + int8_t b[10]; + int8_t v1[10]; + int16_t v2[10]; + int32_t v4[10]; + int64_t v8[10]; + float f4[10]; + double f8[10]; + char bin[10][40]; + } v = {0}; + + v.ts = malloc(sizeof(int64_t) * 1 * 10); + + int *lb = malloc(10 * sizeof(int)); + + TAOS_BIND *tags = calloc(1, sizeof(TAOS_BIND) * 9 * 1); + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * 1*5); + +// int one_null = 1; + int one_not_null = 0; + + char* is_null = malloc(sizeof(char) * 10); + char* no_null = malloc(sizeof(char) * 10); + + for (int i = 0; i < 10; ++i) { + lb[i] = 40; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v.b[i] = (int8_t)(i % 2); + v.v1[i] = (int8_t)((i+1) % 2); + v.v2[i] = (int16_t)i; + v.v4[i] = (int32_t)(i+1); + v.v8[i] = (int64_t)(i+2); + v.f4[i] = (float)(i+3); + v.f8[i] = (double)(i+4); + memset(v.bin[i], '0'+i%10, 40); + } + + for (int i = 0; i < 5; i+=5) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v.ts[10*i/10]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = 10; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v.b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = 10; + + params[i+2].buffer_type = TSDB_DATA_TYPE_INT; + params[i+2].buffer_length = sizeof(int32_t); + params[i+2].buffer = v.v4; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = 10; + + params[i+3].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[i+3].buffer_length = sizeof(int64_t); + params[i+3].buffer = v.v8; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = 10; + + params[i+4].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[i+4].buffer_length = sizeof(double); + params[i+4].buffer = v.f8; + params[i+4].length = NULL; + params[i+4].is_null = is_null; + params[i+4].num = 10; + } + + int64_t tts = 1591060628000; + for (int i = 0; i < 10; ++i) { + v.ts[i] = tts + i; + } + + + for (int i = 0; i < 1; ++i) { + tags[i+0].buffer_type = TSDB_DATA_TYPE_BOOL; + tags[i+0].buffer = v.b; + tags[i+0].is_null = &one_not_null; + tags[i+0].length = NULL; + + tags[i+1].buffer_type = TSDB_DATA_TYPE_SMALLINT; + tags[i+1].buffer = v.v2; + tags[i+1].is_null = &one_not_null; + tags[i+1].length = NULL; + + tags[i+2].buffer_type = TSDB_DATA_TYPE_FLOAT; + tags[i+2].buffer = v.f4; + tags[i+2].is_null = &one_not_null; + tags[i+2].length = NULL; + + tags[i+3].buffer_type = TSDB_DATA_TYPE_BINARY; + tags[i+3].buffer = v.bin; + tags[i+3].is_null = &one_not_null; + tags[i+3].length = (uintptr_t *)lb; + } + + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? using stb1 tags(1,?,2,?,4,?,6.0,?,'b') (ts,b,v4,v8,f8) values(?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + exit(1); + } + + int id = 0; + for (int zz = 0; zz < 1; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname_tags(stmt, buf, tags); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname_tags. code:0x%x\n", code); + } + + taos_stmt_bind_param_batch(stmt, params + id * 5); + taos_stmt_add_batch(stmt); + } + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + + ++id; + + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%u useconds\n", 10, (endtime-starttime)/1000000UL, (endtime-starttime)/(10)); + + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + free(tags); + + return 0; +} + + + + + +//1 tables 10 records +int stmt_funcb_autoctb_e1(TAOS_STMT *stmt) { + struct { + int64_t *ts; + int8_t b[10]; + int8_t v1[10]; + int16_t v2[10]; + int32_t v4[10]; + int64_t v8[10]; + float f4[10]; + double f8[10]; + char bin[10][40]; + } v = {0}; + + v.ts = malloc(sizeof(int64_t) * 1 * 10); + + int *lb = malloc(10 * sizeof(int)); + + TAOS_BIND *tags = calloc(1, sizeof(TAOS_BIND) * 9 * 1); + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * 1*10); + +// int one_null = 1; + int one_not_null = 0; + + char* is_null = malloc(sizeof(char) * 10); + char* no_null = malloc(sizeof(char) * 10); + + for (int i = 0; i < 10; ++i) { + lb[i] = 40; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v.b[i] = (int8_t)(i % 2); + v.v1[i] = (int8_t)((i+1) % 2); + v.v2[i] = (int16_t)i; + v.v4[i] = (int32_t)(i+1); + v.v8[i] = (int64_t)(i+2); + v.f4[i] = (float)(i+3); + v.f8[i] = (double)(i+4); + memset(v.bin[i], '0'+i%10, 40); + } + + for (int i = 0; i < 10; i+=10) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v.ts[10*i/10]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = 10; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v.b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = 10; + + params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[i+2].buffer_length = sizeof(int8_t); + params[i+2].buffer = v.v1; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = 10; + + params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[i+3].buffer_length = sizeof(int16_t); + params[i+3].buffer = v.v2; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = 10; + + params[i+4].buffer_type = TSDB_DATA_TYPE_INT; + params[i+4].buffer_length = sizeof(int32_t); + params[i+4].buffer = v.v4; + params[i+4].length = NULL; + params[i+4].is_null = is_null; + params[i+4].num = 10; + + params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[i+5].buffer_length = sizeof(int64_t); + params[i+5].buffer = v.v8; + params[i+5].length = NULL; + params[i+5].is_null = is_null; + params[i+5].num = 10; + + params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+6].buffer_length = sizeof(float); + params[i+6].buffer = v.f4; + params[i+6].length = NULL; + params[i+6].is_null = is_null; + params[i+6].num = 10; + + params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[i+7].buffer_length = sizeof(double); + params[i+7].buffer = v.f8; + params[i+7].length = NULL; + params[i+7].is_null = is_null; + params[i+7].num = 10; + + params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+8].buffer_length = 40; + params[i+8].buffer = v.bin; + params[i+8].length = lb; + params[i+8].is_null = is_null; + params[i+8].num = 10; + + params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+9].buffer_length = 40; + params[i+9].buffer = v.bin; + params[i+9].length = lb; + params[i+9].is_null = is_null; + params[i+9].num = 10; + + } + + int64_t tts = 1591060628000; + for (int i = 0; i < 10; ++i) { + v.ts[i] = tts + i; + } + + + for (int i = 0; i < 1; ++i) { + tags[i+0].buffer_type = TSDB_DATA_TYPE_BOOL; + tags[i+0].buffer = v.b; + tags[i+0].is_null = &one_not_null; + tags[i+0].length = NULL; + + tags[i+1].buffer_type = TSDB_DATA_TYPE_SMALLINT; + tags[i+1].buffer = v.v2; + tags[i+1].is_null = &one_not_null; + tags[i+1].length = NULL; + + tags[i+2].buffer_type = TSDB_DATA_TYPE_FLOAT; + tags[i+2].buffer = v.f4; + tags[i+2].is_null = &one_not_null; + tags[i+2].length = NULL; + + tags[i+3].buffer_type = TSDB_DATA_TYPE_BINARY; + tags[i+3].buffer = v.bin; + tags[i+3].is_null = &one_not_null; + tags[i+3].length = (uintptr_t *)lb; + } + + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? using stb1 (id1,id2,id3,id4,id5,id6,id7,id8,id9) tags(1,?,2,?,4,?,6.0,?,'b') values(?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. error:%s\n", taos_stmt_errstr(stmt)); + exit(1); + } + + int id = 0; + for (int zz = 0; zz < 1; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname_tags(stmt, buf, tags); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname_tags. code:0x%x\n", code); + } + + taos_stmt_bind_param_batch(stmt, params + id * 10); + taos_stmt_add_batch(stmt); + } + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + + ++id; + + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%u useconds\n", 10, (endtime-starttime)/1000000UL, (endtime-starttime)/(10)); + + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + free(tags); + + return 0; +} + +int stmt_multi_insert_check(TAOS_STMT *stmt) { + char *sql; + + // The number of tag column list is not equal to the number of tag value list + sql = "insert into ? using stb1 (id1) tags(1,?) values(?,?,?,?,?,?,?,?,?,?)"; + if (0 == taos_stmt_prepare(stmt, sql, 0)) { + printf("failed to check taos_stmt_prepare. sql:%s\n", sql); + exit(1); + } + + // The number of column list is not equal to the number of value list + sql = "insert into ? using stb1 tags(1,?,2,?,4,?,6.0,?,'b') " + "(ts, b, v1, v2, v4, v8, f4, f8, bin) values(?,?,?,?,?,?,?,?,?,?)"; + if (0 == taos_stmt_prepare(stmt, sql, 0)) { + printf("failed to check taos_stmt_prepare. sql:%s\n", sql); + exit(1); + } + + sql = "insert into ? using stb1 () tags(1,?) values(?,?,?,?,?,?,?,?,?,?)"; + if (0 == taos_stmt_prepare(stmt, sql, 0)) { + printf("failed to check taos_stmt_prepare. sql:%s\n", sql); + exit(1); + } + + sql = "insert into ? using stb1 ( tags(1,?) values(?,?,?,?,?,?,?,?,?,?)"; + if (0 == taos_stmt_prepare(stmt, sql, 0)) { + printf("failed to check taos_stmt_prepare. sql:%s\n", sql); + exit(1); + } + + sql = "insert into ? using stb1 ) tags(1,?) values(?,?,?,?,?,?,?,?,?,?)"; + if (0 == taos_stmt_prepare(stmt, sql, 0)) { + printf("failed to check taos_stmt_prepare. sql:%s\n", sql); + exit(1); + } + + return 0; +} + +//1 tables 10 records +int stmt_funcb_autoctb_e2(TAOS_STMT *stmt) { + struct { + int64_t *ts; + int8_t b[10]; + int8_t v1[10]; + int16_t v2[10]; + int32_t v4[10]; + int64_t v8[10]; + float f4[10]; + double f8[10]; + char bin[10][40]; + } v = {0}; + + v.ts = malloc(sizeof(int64_t) * 1 * 10); + + int *lb = malloc(10 * sizeof(int)); + + TAOS_BIND *tags = calloc(1, sizeof(TAOS_BIND) * 9 * 1); + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * 1*10); + +// int one_null = 1; + int one_not_null = 0; + + char* is_null = malloc(sizeof(char) * 10); + char* no_null = malloc(sizeof(char) * 10); + + for (int i = 0; i < 10; ++i) { + lb[i] = 40; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v.b[i] = (int8_t)(i % 2); + v.v1[i] = (int8_t)((i+1) % 2); + v.v2[i] = (int16_t)i; + v.v4[i] = (int32_t)(i+1); + v.v8[i] = (int64_t)(i+2); + v.f4[i] = (float)(i+3); + v.f8[i] = (double)(i+4); + memset(v.bin[i], '0'+i%10, 40); + } + + for (int i = 0; i < 10; i+=10) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v.ts[10*i/10]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = 10; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v.b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = 10; + + params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[i+2].buffer_length = sizeof(int8_t); + params[i+2].buffer = v.v1; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = 10; + + params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[i+3].buffer_length = sizeof(int16_t); + params[i+3].buffer = v.v2; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = 10; + + params[i+4].buffer_type = TSDB_DATA_TYPE_INT; + params[i+4].buffer_length = sizeof(int32_t); + params[i+4].buffer = v.v4; + params[i+4].length = NULL; + params[i+4].is_null = is_null; + params[i+4].num = 10; + + params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[i+5].buffer_length = sizeof(int64_t); + params[i+5].buffer = v.v8; + params[i+5].length = NULL; + params[i+5].is_null = is_null; + params[i+5].num = 10; + + params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+6].buffer_length = sizeof(float); + params[i+6].buffer = v.f4; + params[i+6].length = NULL; + params[i+6].is_null = is_null; + params[i+6].num = 10; + + params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[i+7].buffer_length = sizeof(double); + params[i+7].buffer = v.f8; + params[i+7].length = NULL; + params[i+7].is_null = is_null; + params[i+7].num = 10; + + params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+8].buffer_length = 40; + params[i+8].buffer = v.bin; + params[i+8].length = lb; + params[i+8].is_null = is_null; + params[i+8].num = 10; + + params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+9].buffer_length = 40; + params[i+9].buffer = v.bin; + params[i+9].length = lb; + params[i+9].is_null = is_null; + params[i+9].num = 10; + + } + + int64_t tts = 1591060628000; + for (int i = 0; i < 10; ++i) { + v.ts[i] = tts + i; + } + + + for (int i = 0; i < 1; ++i) { + tags[i+0].buffer_type = TSDB_DATA_TYPE_INT; + tags[i+0].buffer = v.v4; + tags[i+0].is_null = &one_not_null; + tags[i+0].length = NULL; + + tags[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + tags[i+1].buffer = v.b; + tags[i+1].is_null = &one_not_null; + tags[i+1].length = NULL; + + tags[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + tags[i+2].buffer = v.v1; + tags[i+2].is_null = &one_not_null; + tags[i+2].length = NULL; + + tags[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + tags[i+3].buffer = v.v2; + tags[i+3].is_null = &one_not_null; + tags[i+3].length = NULL; + + tags[i+4].buffer_type = TSDB_DATA_TYPE_BIGINT; + tags[i+4].buffer = v.v8; + tags[i+4].is_null = &one_not_null; + tags[i+4].length = NULL; + + tags[i+5].buffer_type = TSDB_DATA_TYPE_FLOAT; + tags[i+5].buffer = v.f4; + tags[i+5].is_null = &one_not_null; + tags[i+5].length = NULL; + + tags[i+6].buffer_type = TSDB_DATA_TYPE_DOUBLE; + tags[i+6].buffer = v.f8; + tags[i+6].is_null = &one_not_null; + tags[i+6].length = NULL; + + tags[i+7].buffer_type = TSDB_DATA_TYPE_BINARY; + tags[i+7].buffer = v.bin; + tags[i+7].is_null = &one_not_null; + tags[i+7].length = (uintptr_t *)lb; + + tags[i+8].buffer_type = TSDB_DATA_TYPE_NCHAR; + tags[i+8].buffer = v.bin; + tags[i+8].is_null = &one_not_null; + tags[i+8].length = (uintptr_t *)lb; + } + + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? using stb1 tags(?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + exit(1); + } + + int id = 0; + for (int zz = 0; zz < 1; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname_tags(stmt, buf, NULL); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname_tags. code:%s\n", taos_stmt_errstr(stmt)); + goto exit; + } + + taos_stmt_bind_param_batch(stmt, params + id * 10); + taos_stmt_add_batch(stmt); + } + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + + ++id; + + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%u useconds\n", 10, (endtime-starttime)/1000000UL, (endtime-starttime)/(10)); + +exit: + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + free(tags); + + return 0; +} + + + + + + + +//1 tables 10 records +int stmt_funcb_autoctb_e3(TAOS_STMT *stmt) { + struct { + int64_t *ts; + int8_t b[10]; + int8_t v1[10]; + int16_t v2[10]; + int32_t v4[10]; + int64_t v8[10]; + float f4[10]; + double f8[10]; + char bin[10][40]; + } v = {0}; + + v.ts = malloc(sizeof(int64_t) * 1 * 10); + + int *lb = malloc(10 * sizeof(int)); + + TAOS_BIND *tags = calloc(1, sizeof(TAOS_BIND) * 9 * 1); + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * 1*10); + +// int one_null = 1; + int one_not_null = 0; + + char* is_null = malloc(sizeof(char) * 10); + char* no_null = malloc(sizeof(char) * 10); + + for (int i = 0; i < 10; ++i) { + lb[i] = 40; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v.b[i] = (int8_t)(i % 2); + v.v1[i] = (int8_t)((i+1) % 2); + v.v2[i] = (int16_t)i; + v.v4[i] = (int32_t)(i+1); + v.v8[i] = (int64_t)(i+2); + v.f4[i] = (float)(i+3); + v.f8[i] = (double)(i+4); + memset(v.bin[i], '0'+i%10, 40); + } + + for (int i = 0; i < 10; i+=10) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v.ts[10*i/10]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = 10; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v.b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = 10; + + params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[i+2].buffer_length = sizeof(int8_t); + params[i+2].buffer = v.v1; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = 10; + + params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[i+3].buffer_length = sizeof(int16_t); + params[i+3].buffer = v.v2; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = 10; + + params[i+4].buffer_type = TSDB_DATA_TYPE_INT; + params[i+4].buffer_length = sizeof(int32_t); + params[i+4].buffer = v.v4; + params[i+4].length = NULL; + params[i+4].is_null = is_null; + params[i+4].num = 10; + + params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[i+5].buffer_length = sizeof(int64_t); + params[i+5].buffer = v.v8; + params[i+5].length = NULL; + params[i+5].is_null = is_null; + params[i+5].num = 10; + + params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+6].buffer_length = sizeof(float); + params[i+6].buffer = v.f4; + params[i+6].length = NULL; + params[i+6].is_null = is_null; + params[i+6].num = 10; + + params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[i+7].buffer_length = sizeof(double); + params[i+7].buffer = v.f8; + params[i+7].length = NULL; + params[i+7].is_null = is_null; + params[i+7].num = 10; + + params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+8].buffer_length = 40; + params[i+8].buffer = v.bin; + params[i+8].length = lb; + params[i+8].is_null = is_null; + params[i+8].num = 10; + + params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+9].buffer_length = 40; + params[i+9].buffer = v.bin; + params[i+9].length = lb; + params[i+9].is_null = is_null; + params[i+9].num = 10; + + } + + int64_t tts = 1591060628000; + for (int i = 0; i < 10; ++i) { + v.ts[i] = tts + i; + } + + + for (int i = 0; i < 1; ++i) { + tags[i+0].buffer_type = TSDB_DATA_TYPE_INT; + tags[i+0].buffer = v.v4; + tags[i+0].is_null = &one_not_null; + tags[i+0].length = NULL; + + tags[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + tags[i+1].buffer = v.b; + tags[i+1].is_null = &one_not_null; + tags[i+1].length = NULL; + + tags[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + tags[i+2].buffer = v.v1; + tags[i+2].is_null = &one_not_null; + tags[i+2].length = NULL; + + tags[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + tags[i+3].buffer = v.v2; + tags[i+3].is_null = &one_not_null; + tags[i+3].length = NULL; + + tags[i+4].buffer_type = TSDB_DATA_TYPE_BIGINT; + tags[i+4].buffer = v.v8; + tags[i+4].is_null = &one_not_null; + tags[i+4].length = NULL; + + tags[i+5].buffer_type = TSDB_DATA_TYPE_FLOAT; + tags[i+5].buffer = v.f4; + tags[i+5].is_null = &one_not_null; + tags[i+5].length = NULL; + + tags[i+6].buffer_type = TSDB_DATA_TYPE_DOUBLE; + tags[i+6].buffer = v.f8; + tags[i+6].is_null = &one_not_null; + tags[i+6].length = NULL; + + tags[i+7].buffer_type = TSDB_DATA_TYPE_BINARY; + tags[i+7].buffer = v.bin; + tags[i+7].is_null = &one_not_null; + tags[i+7].length = (uintptr_t *)lb; + + tags[i+8].buffer_type = TSDB_DATA_TYPE_NCHAR; + tags[i+8].buffer = v.bin; + tags[i+8].is_null = &one_not_null; + tags[i+8].length = (uintptr_t *)lb; + } + + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? using stb1 (id1,id2,id3,id4,id5,id6,id7,id8,id9) tags(?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:%s\n", taos_stmt_errstr(stmt)); + goto exit; + //exit(1); + } + + int id = 0; + for (int zz = 0; zz < 1; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname_tags(stmt, buf, NULL); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname_tags. code:0x%x\n", code); + return -1; + } + + taos_stmt_bind_param_batch(stmt, params + id * 10); + taos_stmt_add_batch(stmt); + } + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + + ++id; + + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%u useconds\n", 10, (endtime-starttime)/1000000UL, (endtime-starttime)/(10)); + +exit: + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + free(tags); + + return 0; +} + + + + +//1 tables 10 records +int stmt_funcb_autoctb_e4(TAOS_STMT *stmt) { + struct { + int64_t *ts; + int8_t b[10]; + int8_t v1[10]; + int16_t v2[10]; + int32_t v4[10]; + int64_t v8[10]; + float f4[10]; + double f8[10]; + char bin[10][40]; + } v = {0}; + + v.ts = malloc(sizeof(int64_t) * 1 * 10); + + int *lb = malloc(10 * sizeof(int)); + + TAOS_BIND *tags = calloc(1, sizeof(TAOS_BIND) * 9 * 1); + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * 1*10); + +// int one_null = 1; + int one_not_null = 0; + + char* is_null = malloc(sizeof(char) * 10); + char* no_null = malloc(sizeof(char) * 10); + + for (int i = 0; i < 10; ++i) { + lb[i] = 40; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v.b[i] = (int8_t)(i % 2); + v.v1[i] = (int8_t)((i+1) % 2); + v.v2[i] = (int16_t)i; + v.v4[i] = (int32_t)(i+1); + v.v8[i] = (int64_t)(i+2); + v.f4[i] = (float)(i+3); + v.f8[i] = (double)(i+4); + memset(v.bin[i], '0'+i%10, 40); + } + + for (int i = 0; i < 10; i+=10) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v.ts[10*i/10]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = 10; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v.b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = 10; + + params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[i+2].buffer_length = sizeof(int8_t); + params[i+2].buffer = v.v1; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = 10; + + params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[i+3].buffer_length = sizeof(int16_t); + params[i+3].buffer = v.v2; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = 10; + + params[i+4].buffer_type = TSDB_DATA_TYPE_INT; + params[i+4].buffer_length = sizeof(int32_t); + params[i+4].buffer = v.v4; + params[i+4].length = NULL; + params[i+4].is_null = is_null; + params[i+4].num = 10; + + params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[i+5].buffer_length = sizeof(int64_t); + params[i+5].buffer = v.v8; + params[i+5].length = NULL; + params[i+5].is_null = is_null; + params[i+5].num = 10; + + params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+6].buffer_length = sizeof(float); + params[i+6].buffer = v.f4; + params[i+6].length = NULL; + params[i+6].is_null = is_null; + params[i+6].num = 10; + + params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[i+7].buffer_length = sizeof(double); + params[i+7].buffer = v.f8; + params[i+7].length = NULL; + params[i+7].is_null = is_null; + params[i+7].num = 10; + + params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+8].buffer_length = 40; + params[i+8].buffer = v.bin; + params[i+8].length = lb; + params[i+8].is_null = is_null; + params[i+8].num = 10; + + params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+9].buffer_length = 40; + params[i+9].buffer = v.bin; + params[i+9].length = lb; + params[i+9].is_null = is_null; + params[i+9].num = 10; + + } + + int64_t tts = 1591060628000; + for (int i = 0; i < 10; ++i) { + v.ts[i] = tts + i; + } + + + for (int i = 0; i < 1; ++i) { + tags[i+0].buffer_type = TSDB_DATA_TYPE_INT; + tags[i+0].buffer = v.v4; + tags[i+0].is_null = &one_not_null; + tags[i+0].length = NULL; + + tags[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + tags[i+1].buffer = v.b; + tags[i+1].is_null = &one_not_null; + tags[i+1].length = NULL; + + tags[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + tags[i+2].buffer = v.v1; + tags[i+2].is_null = &one_not_null; + tags[i+2].length = NULL; + + tags[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + tags[i+3].buffer = v.v2; + tags[i+3].is_null = &one_not_null; + tags[i+3].length = NULL; + + tags[i+4].buffer_type = TSDB_DATA_TYPE_BIGINT; + tags[i+4].buffer = v.v8; + tags[i+4].is_null = &one_not_null; + tags[i+4].length = NULL; + + tags[i+5].buffer_type = TSDB_DATA_TYPE_FLOAT; + tags[i+5].buffer = v.f4; + tags[i+5].is_null = &one_not_null; + tags[i+5].length = NULL; + + tags[i+6].buffer_type = TSDB_DATA_TYPE_DOUBLE; + tags[i+6].buffer = v.f8; + tags[i+6].is_null = &one_not_null; + tags[i+6].length = NULL; + + tags[i+7].buffer_type = TSDB_DATA_TYPE_BINARY; + tags[i+7].buffer = v.bin; + tags[i+7].is_null = &one_not_null; + tags[i+7].length = (uintptr_t *)lb; + + tags[i+8].buffer_type = TSDB_DATA_TYPE_NCHAR; + tags[i+8].buffer = v.bin; + tags[i+8].is_null = &one_not_null; + tags[i+8].length = (uintptr_t *)lb; + } + + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? using stb1 tags(?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:%s\n", taos_stmt_errstr(stmt)); + exit(1); + } + + int id = 0; + for (int zz = 0; zz < 1; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname_tags(stmt, buf, tags); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname_tags. error:%s\n", taos_stmt_errstr(stmt)); + exit(1); + } + + code = taos_stmt_bind_param_batch(stmt, params + id * 10); + if (code != 0) { + printf("failed to execute taos_stmt_bind_param_batch. error:%s\n", taos_stmt_errstr(stmt)); + exit(1); + } + + code = taos_stmt_bind_param_batch(stmt, params + id * 10); + if (code != 0) { + printf("failed to execute taos_stmt_bind_param_batch. error:%s\n", taos_stmt_errstr(stmt)); + goto exit; + } + + taos_stmt_add_batch(stmt); + } + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + + ++id; + + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%u useconds\n", 10, (endtime-starttime)/1000000UL, (endtime-starttime)/(10)); + +exit: + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + free(tags); + + return 0; +} + + + + + + +//1 tables 10 records +int stmt_funcb_autoctb_e5(TAOS_STMT *stmt) { + struct { + int64_t *ts; + int8_t b[10]; + int8_t v1[10]; + int16_t v2[10]; + int32_t v4[10]; + int64_t v8[10]; + float f4[10]; + double f8[10]; + char bin[10][40]; + } v = {0}; + + v.ts = malloc(sizeof(int64_t) * 1 * 10); + + int *lb = malloc(10 * sizeof(int)); + + TAOS_BIND *tags = calloc(1, sizeof(TAOS_BIND) * 9 * 1); + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * 1*10); + +// int one_null = 1; + int one_not_null = 0; + + char* is_null = malloc(sizeof(char) * 10); + char* no_null = malloc(sizeof(char) * 10); + + for (int i = 0; i < 10; ++i) { + lb[i] = 40; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v.b[i] = (int8_t)(i % 2); + v.v1[i] = (int8_t)((i+1) % 2); + v.v2[i] = (int16_t)i; + v.v4[i] = (int32_t)(i+1); + v.v8[i] = (int64_t)(i+2); + v.f4[i] = (float)(i+3); + v.f8[i] = (double)(i+4); + memset(v.bin[i], '0'+i%10, 40); + } + + for (int i = 0; i < 10; i+=10) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v.ts[10*i/10]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = 10; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v.b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = 10; + + params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[i+2].buffer_length = sizeof(int8_t); + params[i+2].buffer = v.v1; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = 10; + + params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[i+3].buffer_length = sizeof(int16_t); + params[i+3].buffer = v.v2; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = 10; + + params[i+4].buffer_type = TSDB_DATA_TYPE_INT; + params[i+4].buffer_length = sizeof(int32_t); + params[i+4].buffer = v.v4; + params[i+4].length = NULL; + params[i+4].is_null = is_null; + params[i+4].num = 10; + + params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[i+5].buffer_length = sizeof(int64_t); + params[i+5].buffer = v.v8; + params[i+5].length = NULL; + params[i+5].is_null = is_null; + params[i+5].num = 10; + + params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+6].buffer_length = sizeof(float); + params[i+6].buffer = v.f4; + params[i+6].length = NULL; + params[i+6].is_null = is_null; + params[i+6].num = 10; + + params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[i+7].buffer_length = sizeof(double); + params[i+7].buffer = v.f8; + params[i+7].length = NULL; + params[i+7].is_null = is_null; + params[i+7].num = 10; + + params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+8].buffer_length = 40; + params[i+8].buffer = v.bin; + params[i+8].length = lb; + params[i+8].is_null = is_null; + params[i+8].num = 10; + + params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+9].buffer_length = 40; + params[i+9].buffer = v.bin; + params[i+9].length = lb; + params[i+9].is_null = is_null; + params[i+9].num = 10; + + } + + int64_t tts = 1591060628000; + for (int i = 0; i < 10; ++i) { + v.ts[i] = tts + i; + } + + + for (int i = 0; i < 1; ++i) { + tags[i+0].buffer_type = TSDB_DATA_TYPE_INT; + tags[i+0].buffer = v.v4; + tags[i+0].is_null = &one_not_null; + tags[i+0].length = NULL; + + tags[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + tags[i+1].buffer = v.b; + tags[i+1].is_null = &one_not_null; + tags[i+1].length = NULL; + + tags[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + tags[i+2].buffer = v.v1; + tags[i+2].is_null = &one_not_null; + tags[i+2].length = NULL; + + tags[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + tags[i+3].buffer = v.v2; + tags[i+3].is_null = &one_not_null; + tags[i+3].length = NULL; + + tags[i+4].buffer_type = TSDB_DATA_TYPE_BIGINT; + tags[i+4].buffer = v.v8; + tags[i+4].is_null = &one_not_null; + tags[i+4].length = NULL; + + tags[i+5].buffer_type = TSDB_DATA_TYPE_FLOAT; + tags[i+5].buffer = v.f4; + tags[i+5].is_null = &one_not_null; + tags[i+5].length = NULL; + + tags[i+6].buffer_type = TSDB_DATA_TYPE_DOUBLE; + tags[i+6].buffer = v.f8; + tags[i+6].is_null = &one_not_null; + tags[i+6].length = NULL; + + tags[i+7].buffer_type = TSDB_DATA_TYPE_BINARY; + tags[i+7].buffer = v.bin; + tags[i+7].is_null = &one_not_null; + tags[i+7].length = (uintptr_t *)lb; + + tags[i+8].buffer_type = TSDB_DATA_TYPE_NCHAR; + tags[i+8].buffer = v.bin; + tags[i+8].is_null = &one_not_null; + tags[i+8].length = (uintptr_t *)lb; + } + + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? using stb1 tags(?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(NULL, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:%s\n", taos_stmt_errstr(NULL)); + return -1; + } + + int id = 0; + for (int zz = 0; zz < 1; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname_tags(stmt, buf, tags); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname_tags. error:%s\n", taos_stmt_errstr(stmt)); + exit(1); + } + + code = taos_stmt_bind_param_batch(stmt, params + id * 10); + if (code != 0) { + printf("failed to execute taos_stmt_bind_param_batch. error:%s\n", taos_stmt_errstr(stmt)); + exit(1); + } + + code = taos_stmt_bind_param_batch(stmt, params + id * 10); + if (code != 0) { + printf("failed to execute taos_stmt_bind_param_batch. error:%s\n", taos_stmt_errstr(stmt)); + goto exit; + } + + taos_stmt_add_batch(stmt); + } + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + + ++id; + + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%u useconds\n", 10, (endtime-starttime)/1000000UL, (endtime-starttime)/(10)); + + +exit: + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + free(tags); + + return 0; +} + + +int stmt_funcb_autoctb_e6(TAOS_STMT *stmt) { + char *sql = "insert into ? using stb1 tags(?,?,?,?,?,?,?,?,?) values(now,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("case success:failed to execute taos_stmt_prepare. code:%s\n", taos_stmt_errstr(stmt)); + } + + return 0; +} + + +int stmt_funcb_autoctb_e7(TAOS_STMT *stmt) { + char *sql = "insert into ? using stb1 tags(?,?,?,?,?,?,?,?,?) values(?,true,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("case success:failed to execute taos_stmt_prepare. code:%s\n", taos_stmt_errstr(stmt)); + } + + return 0; +} + + +int stmt_funcb_autoctb_e8(TAOS_STMT *stmt) { + char *sql = "insert into ? using stb1 tags(?,?,?,?,?,?,?,?,?) values(?,?,1,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("case success:failed to execute taos_stmt_prepare. code:%s\n", taos_stmt_errstr(stmt)); + } + + return 0; +} + + +//300 tables 60 records +int stmt_funcb1(TAOS_STMT *stmt) { + struct { + int64_t *ts; + int8_t b[60]; + int8_t v1[60]; + int16_t v2[60]; + int32_t v4[60]; + int64_t v8[60]; + float f4[60]; + double f8[60]; + char bin[60][40]; + } v = {0}; + + v.ts = malloc(sizeof(int64_t) * 900000 * 60); + + int *lb = malloc(60 * sizeof(int)); + + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * 900000*10); + char* is_null = malloc(sizeof(char) * 60); + char* no_null = malloc(sizeof(char) * 60); + + for (int i = 0; i < 60; ++i) { + lb[i] = 40; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v.b[i] = (int8_t)(i % 2); + v.v1[i] = (int8_t)((i+1) % 2); + v.v2[i] = (int16_t)i; + v.v4[i] = (int32_t)(i+1); + v.v8[i] = (int64_t)(i+2); + v.f4[i] = (float)(i+3); + v.f8[i] = (double)(i+4); + memset(v.bin[i], '0'+i%10, 40); + } + + for (int i = 0; i < 9000000; i+=10) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v.ts[60*i/10]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = 60; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v.b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = 60; + + params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[i+2].buffer_length = sizeof(int8_t); + params[i+2].buffer = v.v1; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = 60; + + params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[i+3].buffer_length = sizeof(int16_t); + params[i+3].buffer = v.v2; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = 60; + + params[i+4].buffer_type = TSDB_DATA_TYPE_INT; + params[i+4].buffer_length = sizeof(int32_t); + params[i+4].buffer = v.v4; + params[i+4].length = NULL; + params[i+4].is_null = is_null; + params[i+4].num = 60; + + params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[i+5].buffer_length = sizeof(int64_t); + params[i+5].buffer = v.v8; + params[i+5].length = NULL; + params[i+5].is_null = is_null; + params[i+5].num = 60; + + params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+6].buffer_length = sizeof(float); + params[i+6].buffer = v.f4; + params[i+6].length = NULL; + params[i+6].is_null = is_null; + params[i+6].num = 60; + + params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[i+7].buffer_length = sizeof(double); + params[i+7].buffer = v.f8; + params[i+7].length = NULL; + params[i+7].is_null = is_null; + params[i+7].num = 60; + + params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+8].buffer_length = 40; + params[i+8].buffer = v.bin; + params[i+8].length = lb; + params[i+8].is_null = is_null; + params[i+8].num = 60; + + params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+9].buffer_length = 40; + params[i+9].buffer = v.bin; + params[i+9].length = lb; + params[i+9].is_null = is_null; + params[i+9].num = 60; + + } + + int64_t tts = 1591060628000; + for (int i = 0; i < 54000000; ++i) { + v.ts[i] = tts + i; + } + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + } + + int id = 0; + for (int l = 0; l < 3000; l++) { + for (int zz = 0; zz < 300; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code); + } + + taos_stmt_bind_param_batch(stmt, params + id * 10); + taos_stmt_add_batch(stmt); + } + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + + ++id; + } + + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60)); + + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + + return 0; +} + + +//1table 18000 reocrds +int stmt_funcb2(TAOS_STMT *stmt) { + struct { + int64_t *ts; + int8_t b[18000]; + int8_t v1[18000]; + int16_t v2[18000]; + int32_t v4[18000]; + int64_t v8[18000]; + float f4[18000]; + double f8[18000]; + char bin[18000][40]; + } v = {0}; + + v.ts = malloc(sizeof(int64_t) * 900000 * 60); + + int *lb = malloc(18000 * sizeof(int)); + + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * 3000*10); + char* is_null = malloc(sizeof(char) * 18000); + char* no_null = malloc(sizeof(char) * 18000); + + for (int i = 0; i < 18000; ++i) { + lb[i] = 40; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v.b[i] = (int8_t)(i % 2); + v.v1[i] = (int8_t)((i+1) % 2); + v.v2[i] = (int16_t)i; + v.v4[i] = (int32_t)(i+1); + v.v8[i] = (int64_t)(i+2); + v.f4[i] = (float)(i+3); + v.f8[i] = (double)(i+4); + memset(v.bin[i], '0'+i%10, 40); + } + + for (int i = 0; i < 30000; i+=10) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v.ts[18000*i/10]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = 18000; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v.b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = 18000; + + params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[i+2].buffer_length = sizeof(int8_t); + params[i+2].buffer = v.v1; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = 18000; + + params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[i+3].buffer_length = sizeof(int16_t); + params[i+3].buffer = v.v2; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = 18000; + + params[i+4].buffer_type = TSDB_DATA_TYPE_INT; + params[i+4].buffer_length = sizeof(int32_t); + params[i+4].buffer = v.v4; + params[i+4].length = NULL; + params[i+4].is_null = is_null; + params[i+4].num = 18000; + + params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[i+5].buffer_length = sizeof(int64_t); + params[i+5].buffer = v.v8; + params[i+5].length = NULL; + params[i+5].is_null = is_null; + params[i+5].num = 18000; + + params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+6].buffer_length = sizeof(float); + params[i+6].buffer = v.f4; + params[i+6].length = NULL; + params[i+6].is_null = is_null; + params[i+6].num = 18000; + + params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[i+7].buffer_length = sizeof(double); + params[i+7].buffer = v.f8; + params[i+7].length = NULL; + params[i+7].is_null = is_null; + params[i+7].num = 18000; + + params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+8].buffer_length = 40; + params[i+8].buffer = v.bin; + params[i+8].length = lb; + params[i+8].is_null = is_null; + params[i+8].num = 18000; + + params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+9].buffer_length = 40; + params[i+9].buffer = v.bin; + params[i+9].length = lb; + params[i+9].is_null = is_null; + params[i+9].num = 18000; + + } + + int64_t tts = 1591060628000; + for (int i = 0; i < 54000000; ++i) { + v.ts[i] = tts + i; + } + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + } + + int id = 0; + for (int l = 0; l < 10; l++) { + for (int zz = 0; zz < 300; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code); + } + + taos_stmt_bind_param_batch(stmt, params + id * 10); + taos_stmt_add_batch(stmt); + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + ++id; + + } + + } + + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60)); + + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + + return 0; +} + + +//disorder +int stmt_funcb3(TAOS_STMT *stmt) { + struct { + int64_t *ts; + int8_t b[60]; + int8_t v1[60]; + int16_t v2[60]; + int32_t v4[60]; + int64_t v8[60]; + float f4[60]; + double f8[60]; + char bin[60][40]; + } v = {0}; + + v.ts = malloc(sizeof(int64_t) * 900000 * 60); + + int *lb = malloc(60 * sizeof(int)); + + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * 900000*10); + char* is_null = malloc(sizeof(char) * 60); + char* no_null = malloc(sizeof(char) * 60); + + for (int i = 0; i < 60; ++i) { + lb[i] = 40; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v.b[i] = (int8_t)(i % 2); + v.v1[i] = (int8_t)((i+1) % 2); + v.v2[i] = (int16_t)i; + v.v4[i] = (int32_t)(i+1); + v.v8[i] = (int64_t)(i+2); + v.f4[i] = (float)(i+3); + v.f8[i] = (double)(i+4); + memset(v.bin[i], '0'+i%10, 40); + } + + for (int i = 0; i < 9000000; i+=10) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v.ts[60*i/10]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = 60; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v.b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = 60; + + params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[i+2].buffer_length = sizeof(int8_t); + params[i+2].buffer = v.v1; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = 60; + + params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[i+3].buffer_length = sizeof(int16_t); + params[i+3].buffer = v.v2; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = 60; + + params[i+4].buffer_type = TSDB_DATA_TYPE_INT; + params[i+4].buffer_length = sizeof(int32_t); + params[i+4].buffer = v.v4; + params[i+4].length = NULL; + params[i+4].is_null = is_null; + params[i+4].num = 60; + + params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[i+5].buffer_length = sizeof(int64_t); + params[i+5].buffer = v.v8; + params[i+5].length = NULL; + params[i+5].is_null = is_null; + params[i+5].num = 60; + + params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+6].buffer_length = sizeof(float); + params[i+6].buffer = v.f4; + params[i+6].length = NULL; + params[i+6].is_null = is_null; + params[i+6].num = 60; + + params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[i+7].buffer_length = sizeof(double); + params[i+7].buffer = v.f8; + params[i+7].length = NULL; + params[i+7].is_null = is_null; + params[i+7].num = 60; + + params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+8].buffer_length = 40; + params[i+8].buffer = v.bin; + params[i+8].length = lb; + params[i+8].is_null = is_null; + params[i+8].num = 60; + + params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+9].buffer_length = 40; + params[i+9].buffer = v.bin; + params[i+9].length = lb; + params[i+9].is_null = is_null; + params[i+9].num = 60; + + } + + int64_t tts = 1591060628000; + int64_t ttt = 0; + for (int i = 0; i < 54000000; ++i) { + v.ts[i] = tts + i; + if (i > 0 && i%60 == 0) { + ttt = v.ts[i-1]; + v.ts[i-1] = v.ts[i-60]; + v.ts[i-60] = ttt; + } + } + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + } + + int id = 0; + for (int l = 0; l < 3000; l++) { + for (int zz = 0; zz < 300; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code); + } + + taos_stmt_bind_param_batch(stmt, params + id * 10); + taos_stmt_add_batch(stmt); + } + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + + ++id; + } + + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60)); + + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + + return 0; +} + + + + +//samets +int stmt_funcb4(TAOS_STMT *stmt) { + struct { + int64_t *ts; + int8_t b[60]; + int8_t v1[60]; + int16_t v2[60]; + int32_t v4[60]; + int64_t v8[60]; + float f4[60]; + double f8[60]; + char bin[60][40]; + } v = {0}; + + v.ts = malloc(sizeof(int64_t) * 900000 * 60); + + int *lb = malloc(60 * sizeof(int)); + + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * 900000*10); + char* is_null = malloc(sizeof(char) * 60); + char* no_null = malloc(sizeof(char) * 60); + + for (int i = 0; i < 60; ++i) { + lb[i] = 40; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v.b[i] = (int8_t)(i % 2); + v.v1[i] = (int8_t)((i+1) % 2); + v.v2[i] = (int16_t)i; + v.v4[i] = (int32_t)(i+1); + v.v8[i] = (int64_t)(i+2); + v.f4[i] = (float)(i+3); + v.f8[i] = (double)(i+4); + memset(v.bin[i], '0'+i%10, 40); + } + + for (int i = 0; i < 9000000; i+=10) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v.ts[60*i/10]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = 60; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v.b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = 60; + + params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[i+2].buffer_length = sizeof(int8_t); + params[i+2].buffer = v.v1; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = 60; + + params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[i+3].buffer_length = sizeof(int16_t); + params[i+3].buffer = v.v2; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = 60; + + params[i+4].buffer_type = TSDB_DATA_TYPE_INT; + params[i+4].buffer_length = sizeof(int32_t); + params[i+4].buffer = v.v4; + params[i+4].length = NULL; + params[i+4].is_null = is_null; + params[i+4].num = 60; + + params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[i+5].buffer_length = sizeof(int64_t); + params[i+5].buffer = v.v8; + params[i+5].length = NULL; + params[i+5].is_null = is_null; + params[i+5].num = 60; + + params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+6].buffer_length = sizeof(float); + params[i+6].buffer = v.f4; + params[i+6].length = NULL; + params[i+6].is_null = is_null; + params[i+6].num = 60; + + params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[i+7].buffer_length = sizeof(double); + params[i+7].buffer = v.f8; + params[i+7].length = NULL; + params[i+7].is_null = is_null; + params[i+7].num = 60; + + params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+8].buffer_length = 40; + params[i+8].buffer = v.bin; + params[i+8].length = lb; + params[i+8].is_null = is_null; + params[i+8].num = 60; + + params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+9].buffer_length = 40; + params[i+9].buffer = v.bin; + params[i+9].length = lb; + params[i+9].is_null = is_null; + params[i+9].num = 60; + + } + + int64_t tts = 1591060628000; + for (int i = 0; i < 54000000; ++i) { + v.ts[i] = tts; + } + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + } + + int id = 0; + for (int l = 0; l < 3000; l++) { + for (int zz = 0; zz < 300; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code); + } + + taos_stmt_bind_param_batch(stmt, params + id * 10); + taos_stmt_add_batch(stmt); + } + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + + ++id; + } + + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60)); + + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + + return 0; +} + + + + +//1table 18000 reocrds +int stmt_funcb5(TAOS_STMT *stmt) { + struct { + int64_t *ts; + int8_t b[18000]; + int8_t v1[18000]; + int16_t v2[18000]; + int32_t v4[18000]; + int64_t v8[18000]; + float f4[18000]; + double f8[18000]; + char bin[18000][40]; + } v = {0}; + + v.ts = malloc(sizeof(int64_t) * 900000 * 60); + + int *lb = malloc(18000 * sizeof(int)); + + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * 3000*10); + char* is_null = malloc(sizeof(char) * 18000); + char* no_null = malloc(sizeof(char) * 18000); + + for (int i = 0; i < 18000; ++i) { + lb[i] = 40; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v.b[i] = (int8_t)(i % 2); + v.v1[i] = (int8_t)((i+1) % 2); + v.v2[i] = (int16_t)i; + v.v4[i] = (int32_t)(i+1); + v.v8[i] = (int64_t)(i+2); + v.f4[i] = (float)(i+3); + v.f8[i] = (double)(i+4); + memset(v.bin[i], '0'+i%10, 40); + } + + for (int i = 0; i < 30000; i+=10) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v.ts[18000*i/10]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = 18000; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v.b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = 18000; + + params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[i+2].buffer_length = sizeof(int8_t); + params[i+2].buffer = v.v1; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = 18000; + + params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[i+3].buffer_length = sizeof(int16_t); + params[i+3].buffer = v.v2; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = 18000; + + params[i+4].buffer_type = TSDB_DATA_TYPE_INT; + params[i+4].buffer_length = sizeof(int32_t); + params[i+4].buffer = v.v4; + params[i+4].length = NULL; + params[i+4].is_null = is_null; + params[i+4].num = 18000; + + params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[i+5].buffer_length = sizeof(int64_t); + params[i+5].buffer = v.v8; + params[i+5].length = NULL; + params[i+5].is_null = is_null; + params[i+5].num = 18000; + + params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+6].buffer_length = sizeof(float); + params[i+6].buffer = v.f4; + params[i+6].length = NULL; + params[i+6].is_null = is_null; + params[i+6].num = 18000; + + params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[i+7].buffer_length = sizeof(double); + params[i+7].buffer = v.f8; + params[i+7].length = NULL; + params[i+7].is_null = is_null; + params[i+7].num = 18000; + + params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+8].buffer_length = 40; + params[i+8].buffer = v.bin; + params[i+8].length = lb; + params[i+8].is_null = is_null; + params[i+8].num = 18000; + + params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+9].buffer_length = 40; + params[i+9].buffer = v.bin; + params[i+9].length = lb; + params[i+9].is_null = is_null; + params[i+9].num = 18000; + + } + + int64_t tts = 1591060628000; + for (int i = 0; i < 54000000; ++i) { + v.ts[i] = tts + i; + } + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into m0 values(?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + } + + int id = 0; + for (int l = 0; l < 10; l++) { + for (int zz = 0; zz < 1; zz++) { + taos_stmt_bind_param_batch(stmt, params + id * 10); + taos_stmt_add_batch(stmt); + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + ++id; + + } + + } + + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60)); + + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + + return 0; +} + + +//1table 200000 reocrds +int stmt_funcb_ssz1(TAOS_STMT *stmt) { + struct { + int64_t *ts; + int b[30000]; + } v = {0}; + + v.ts = malloc(sizeof(int64_t) * 30000 * 3000); + + int *lb = malloc(30000 * sizeof(int)); + + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * 3000*10); + char* no_null = malloc(sizeof(int) * 200000); + + for (int i = 0; i < 30000; ++i) { + lb[i] = 40; + no_null[i] = 0; + v.b[i] = (int8_t)(i % 2); + } + + for (int i = 0; i < 30000; i+=10) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v.ts[30000*i/10]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = 30000; + + params[i+1].buffer_type = TSDB_DATA_TYPE_INT; + params[i+1].buffer_length = sizeof(int); + params[i+1].buffer = v.b; + params[i+1].length = NULL; + params[i+1].is_null = no_null; + params[i+1].num = 30000; + } + + int64_t tts = 0; + for (int64_t i = 0; i < 90000000LL; ++i) { + v.ts[i] = tts + i; + } + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? values(?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + } + + int id = 0; + for (int l = 0; l < 10; l++) { + for (int zz = 0; zz < 300; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code); + } + + taos_stmt_bind_param_batch(stmt, params + id * 10); + taos_stmt_add_batch(stmt); + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + ++id; + + } + + } + + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60)); + + free(v.ts); + free(lb); + free(params); + free(no_null); + + return 0; +} + + +//one table 60 records one time +int stmt_funcb_s1(TAOS_STMT *stmt) { + struct { + int64_t *ts; + int8_t b[60]; + int8_t v1[60]; + int16_t v2[60]; + int32_t v4[60]; + int64_t v8[60]; + float f4[60]; + double f8[60]; + char bin[60][40]; + } v = {0}; + + v.ts = malloc(sizeof(int64_t) * 900000 * 60); + + int *lb = malloc(60 * sizeof(int)); + + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * 900000*10); + char* is_null = malloc(sizeof(char) * 60); + char* no_null = malloc(sizeof(char) * 60); + + for (int i = 0; i < 60; ++i) { + lb[i] = 40; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v.b[i] = (int8_t)(i % 2); + v.v1[i] = (int8_t)((i+1) % 2); + v.v2[i] = (int16_t)i; + v.v4[i] = (int32_t)(i+1); + v.v8[i] = (int64_t)(i+2); + v.f4[i] = (float)(i+3); + v.f8[i] = (double)(i+4); + memset(v.bin[i], '0'+i%10, 40); + } + + for (int i = 0; i < 9000000; i+=10) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v.ts[60*i/10]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = 60; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v.b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = 60; + + params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[i+2].buffer_length = sizeof(int8_t); + params[i+2].buffer = v.v1; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = 60; + + params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[i+3].buffer_length = sizeof(int16_t); + params[i+3].buffer = v.v2; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = 60; + + params[i+4].buffer_type = TSDB_DATA_TYPE_INT; + params[i+4].buffer_length = sizeof(int32_t); + params[i+4].buffer = v.v4; + params[i+4].length = NULL; + params[i+4].is_null = is_null; + params[i+4].num = 60; + + params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[i+5].buffer_length = sizeof(int64_t); + params[i+5].buffer = v.v8; + params[i+5].length = NULL; + params[i+5].is_null = is_null; + params[i+5].num = 60; + + params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+6].buffer_length = sizeof(float); + params[i+6].buffer = v.f4; + params[i+6].length = NULL; + params[i+6].is_null = is_null; + params[i+6].num = 60; + + params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[i+7].buffer_length = sizeof(double); + params[i+7].buffer = v.f8; + params[i+7].length = NULL; + params[i+7].is_null = is_null; + params[i+7].num = 60; + + params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+8].buffer_length = 40; + params[i+8].buffer = v.bin; + params[i+8].length = lb; + params[i+8].is_null = is_null; + params[i+8].num = 60; + + params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+9].buffer_length = 40; + params[i+9].buffer = v.bin; + params[i+9].length = lb; + params[i+9].is_null = is_null; + params[i+9].num = 60; + + } + + int64_t tts = 1591060628000; + for (int i = 0; i < 54000000; ++i) { + v.ts[i] = tts + i; + } + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + } + + int id = 0; + for (int l = 0; l < 3000; l++) { + for (int zz = 0; zz < 300; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code); + } + + taos_stmt_bind_param_batch(stmt, params + id * 10); + taos_stmt_add_batch(stmt); + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + + ++id; + } + + } + + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60)); + + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + + return 0; +} + + + + + + +//300 tables 60 records single column bind +int stmt_funcb_sc1(TAOS_STMT *stmt) { + struct { + int64_t *ts; + int8_t b[60]; + int8_t v1[60]; + int16_t v2[60]; + int32_t v4[60]; + int64_t v8[60]; + float f4[60]; + double f8[60]; + char bin[60][40]; + } v = {0}; + + v.ts = malloc(sizeof(int64_t) * 900000 * 60); + + int *lb = malloc(60 * sizeof(int)); + + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * 900000*10); + char* is_null = malloc(sizeof(char) * 60); + char* no_null = malloc(sizeof(char) * 60); + + for (int i = 0; i < 60; ++i) { + lb[i] = 40; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v.b[i] = (int8_t)(i % 2); + v.v1[i] = (int8_t)((i+1) % 2); + v.v2[i] = (int16_t)i; + v.v4[i] = (int32_t)(i+1); + v.v8[i] = (int64_t)(i+2); + v.f4[i] = (float)(i+3); + v.f8[i] = (double)(i+4); + memset(v.bin[i], '0'+i%10, 40); + } + + for (int i = 0; i < 9000000; i+=10) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v.ts[60*i/10]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = 60; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v.b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = 60; + + params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[i+2].buffer_length = sizeof(int8_t); + params[i+2].buffer = v.v1; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = 60; + + params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[i+3].buffer_length = sizeof(int16_t); + params[i+3].buffer = v.v2; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = 60; + + params[i+4].buffer_type = TSDB_DATA_TYPE_INT; + params[i+4].buffer_length = sizeof(int32_t); + params[i+4].buffer = v.v4; + params[i+4].length = NULL; + params[i+4].is_null = is_null; + params[i+4].num = 60; + + params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[i+5].buffer_length = sizeof(int64_t); + params[i+5].buffer = v.v8; + params[i+5].length = NULL; + params[i+5].is_null = is_null; + params[i+5].num = 60; + + params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+6].buffer_length = sizeof(float); + params[i+6].buffer = v.f4; + params[i+6].length = NULL; + params[i+6].is_null = is_null; + params[i+6].num = 60; + + params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[i+7].buffer_length = sizeof(double); + params[i+7].buffer = v.f8; + params[i+7].length = NULL; + params[i+7].is_null = is_null; + params[i+7].num = 60; + + params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+8].buffer_length = 40; + params[i+8].buffer = v.bin; + params[i+8].length = lb; + params[i+8].is_null = is_null; + params[i+8].num = 60; + + params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+9].buffer_length = 40; + params[i+9].buffer = v.bin; + params[i+9].length = lb; + params[i+9].is_null = is_null; + params[i+9].num = 60; + + } + + int64_t tts = 1591060628000; + for (int i = 0; i < 54000000; ++i) { + v.ts[i] = tts + i; + } + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + } + + int id = 0; + for (int l = 0; l < 3000; l++) { + for (int zz = 0; zz < 300; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code); + } + + for (int col=0; col < 10; ++col) { + taos_stmt_bind_single_param_batch(stmt, params + id++, col); + } + + taos_stmt_add_batch(stmt); + } + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + } + + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60)); + + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + + return 0; +} + + +//1 tables 60 records single column bind +int stmt_funcb_sc2(TAOS_STMT *stmt) { + struct { + int64_t *ts; + int8_t b[60]; + int8_t v1[60]; + int16_t v2[60]; + int32_t v4[60]; + int64_t v8[60]; + float f4[60]; + double f8[60]; + char bin[60][40]; + } v = {0}; + + v.ts = malloc(sizeof(int64_t) * 900000 * 60); + + int *lb = malloc(60 * sizeof(int)); + + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * 900000*10); + char* is_null = malloc(sizeof(char) * 60); + char* no_null = malloc(sizeof(char) * 60); + + for (int i = 0; i < 60; ++i) { + lb[i] = 40; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v.b[i] = (int8_t)(i % 2); + v.v1[i] = (int8_t)((i+1) % 2); + v.v2[i] = (int16_t)i; + v.v4[i] = (int32_t)(i+1); + v.v8[i] = (int64_t)(i+2); + v.f4[i] = (float)(i+3); + v.f8[i] = (double)(i+4); + memset(v.bin[i], '0'+i%10, 40); + } + + for (int i = 0; i < 9000000; i+=10) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v.ts[60*i/10]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = 60; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v.b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = 60; + + params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[i+2].buffer_length = sizeof(int8_t); + params[i+2].buffer = v.v1; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = 60; + + params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[i+3].buffer_length = sizeof(int16_t); + params[i+3].buffer = v.v2; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = 60; + + params[i+4].buffer_type = TSDB_DATA_TYPE_INT; + params[i+4].buffer_length = sizeof(int32_t); + params[i+4].buffer = v.v4; + params[i+4].length = NULL; + params[i+4].is_null = is_null; + params[i+4].num = 60; + + params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[i+5].buffer_length = sizeof(int64_t); + params[i+5].buffer = v.v8; + params[i+5].length = NULL; + params[i+5].is_null = is_null; + params[i+5].num = 60; + + params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+6].buffer_length = sizeof(float); + params[i+6].buffer = v.f4; + params[i+6].length = NULL; + params[i+6].is_null = is_null; + params[i+6].num = 60; + + params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[i+7].buffer_length = sizeof(double); + params[i+7].buffer = v.f8; + params[i+7].length = NULL; + params[i+7].is_null = is_null; + params[i+7].num = 60; + + params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+8].buffer_length = 40; + params[i+8].buffer = v.bin; + params[i+8].length = lb; + params[i+8].is_null = is_null; + params[i+8].num = 60; + + params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+9].buffer_length = 40; + params[i+9].buffer = v.bin; + params[i+9].length = lb; + params[i+9].is_null = is_null; + params[i+9].num = 60; + + } + + int64_t tts = 1591060628000; + for (int i = 0; i < 54000000; ++i) { + v.ts[i] = tts + i; + } + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + } + + int id = 0; + for (int l = 0; l < 3000; l++) { + for (int zz = 0; zz < 300; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code); + } + + for (int col=0; col < 10; ++col) { + taos_stmt_bind_single_param_batch(stmt, params + id++, col); + } + + taos_stmt_add_batch(stmt); + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + + } + + } + + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60)); + + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + + return 0; +} + + +//10 tables [1...10] records single column bind +int stmt_funcb_sc3(TAOS_STMT *stmt) { + struct { + int64_t *ts; + int8_t b[60]; + int8_t v1[60]; + int16_t v2[60]; + int32_t v4[60]; + int64_t v8[60]; + float f4[60]; + double f8[60]; + char bin[60][40]; + } v = {0}; + + v.ts = malloc(sizeof(int64_t) * 60); + + int *lb = malloc(60 * sizeof(int)); + + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * 60*10); + char* is_null = malloc(sizeof(char) * 60); + char* no_null = malloc(sizeof(char) * 60); + + for (int i = 0; i < 60; ++i) { + lb[i] = 40; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v.b[i] = (int8_t)(i % 2); + v.v1[i] = (int8_t)((i+1) % 2); + v.v2[i] = (int16_t)i; + v.v4[i] = (int32_t)(i+1); + v.v8[i] = (int64_t)(i+2); + v.f4[i] = (float)(i+3); + v.f8[i] = (double)(i+4); + memset(v.bin[i], '0'+i%10, 40); + } + + int g = 0; + for (int i = 0; i < 600; i+=10) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v.ts[i/10]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = g%10+1; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v.b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = g%10+1; + + params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[i+2].buffer_length = sizeof(int8_t); + params[i+2].buffer = v.v1; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = g%10+1; + + params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[i+3].buffer_length = sizeof(int16_t); + params[i+3].buffer = v.v2; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = g%10+1; + + params[i+4].buffer_type = TSDB_DATA_TYPE_INT; + params[i+4].buffer_length = sizeof(int32_t); + params[i+4].buffer = v.v4; + params[i+4].length = NULL; + params[i+4].is_null = is_null; + params[i+4].num = g%10+1; + + params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[i+5].buffer_length = sizeof(int64_t); + params[i+5].buffer = v.v8; + params[i+5].length = NULL; + params[i+5].is_null = is_null; + params[i+5].num = g%10+1; + + params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+6].buffer_length = sizeof(float); + params[i+6].buffer = v.f4; + params[i+6].length = NULL; + params[i+6].is_null = is_null; + params[i+6].num = g%10+1; + + params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[i+7].buffer_length = sizeof(double); + params[i+7].buffer = v.f8; + params[i+7].length = NULL; + params[i+7].is_null = is_null; + params[i+7].num = g%10+1; + + params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+8].buffer_length = 40; + params[i+8].buffer = v.bin; + params[i+8].length = lb; + params[i+8].is_null = is_null; + params[i+8].num = g%10+1; + + params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+9].buffer_length = 40; + params[i+9].buffer = v.bin; + params[i+9].length = lb; + params[i+9].is_null = is_null; + params[i+9].num = g%10+1; + ++g; + } + + int64_t tts = 1591060628000; + for (int i = 0; i < 60; ++i) { + v.ts[i] = tts + i; + } + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + } + + int id = 0; + for (int zz = 0; zz < 10; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code); + } + + for (int col=0; col < 10; ++col) { + taos_stmt_bind_single_param_batch(stmt, params + id++, col); + } + + taos_stmt_add_batch(stmt); + } + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60)); + + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + + return 0; +} + + +void check_result(TAOS *taos, char *tname, int printr, int expected) { + char sql[255] = "SELECT * FROM "; + TAOS_RES *result; + + //FORCE NO PRINT + printr = 0; + + strcat(sql, tname); + + result = taos_query(taos, sql); + int code = taos_errno(result); + if (code != 0) { + printf("failed to query table, reason:%s\n", taos_errstr(result)); + taos_free_result(result); + exit(1); + } + + + TAOS_ROW row; + int rows = 0; + int num_fields = taos_num_fields(result); + TAOS_FIELD *fields = taos_fetch_fields(result); + char temp[256]; + + // fetch the records row by row + while ((row = taos_fetch_row(result))) { + rows++; + if (printr) { + memset(temp, 0, sizeof(temp)); + taos_print_row(temp, row, fields, num_fields); + printf("[%s]\n", temp); + } + } + + if (rows == expected) { + printf("%d rows are fetched as expectation\n", rows); + } else { + printf("!!!expect %d rows, but %d rows are fetched\n", expected, rows); + exit(1); + } + + taos_free_result(result); + +} + + + +//120table 60 record each table +int sql_perf1(TAOS *taos) { + char *sql[3000] = {0}; + TAOS_RES *result; + + for (int i = 0; i < 3000; i++) { + sql[i] = calloc(1, 1048576); + } + + int len = 0; + int tss = 0; + for (int l = 0; l < 3000; ++l) { + len = sprintf(sql[l], "insert into "); + for (int t = 0; t < 120; ++t) { + len += sprintf(sql[l] + len, "m%d values ", t); + for (int m = 0; m < 60; ++m) { + len += sprintf(sql[l] + len, "(%d, %d, %d, %d, %d, %d, %f, %f, \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") ", tss++, m, m, m, m, m, m+1.0, m+1.0); + } + } + } + + + unsigned long long starttime = getCurrentTime(); + for (int i = 0; i < 3000; ++i) { + result = taos_query(taos, sql[i]); + int code = taos_errno(result); + if (code != 0) { + printf("failed to query table, reason:%s\n", taos_errstr(result)); + taos_free_result(result); + exit(1); + } + + taos_free_result(result); + } + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%.1f useconds\n", 3000*120*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*120*60)); + + for (int i = 0; i < 3000; i++) { + free(sql[i]); + } + + return 0; +} + + + + + +//one table 60 records one time +int sql_perf_s1(TAOS *taos) { + char **sql = calloc(1, sizeof(char*) * 360000); + TAOS_RES *result; + + for (int i = 0; i < 360000; i++) { + sql[i] = calloc(1, 9000); + } + + int len = 0; + int tss = 0; + int id = 0; + for (int t = 0; t < 120; ++t) { + for (int l = 0; l < 3000; ++l) { + len = sprintf(sql[id], "insert into m%d values ", t); + for (int m = 0; m < 60; ++m) { + len += sprintf(sql[id] + len, "(%d, %d, %d, %d, %d, %d, %f, %f, \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") ", tss++, m, m, m, m, m, m+1.0, m+1.0); + } + if (len >= 9000) { + printf("sql:%s,len:%d\n", sql[id], len); + exit(1); + } + ++id; + } + } + + + unsigned long long starttime = getCurrentTime(); + for (int i = 0; i < 360000; ++i) { + result = taos_query(taos, sql[i]); + int code = taos_errno(result); + if (code != 0) { + printf("failed to query table, reason:%s\n", taos_errstr(result)); + taos_free_result(result); + exit(1); + } + + taos_free_result(result); + } + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%.1f useconds\n", 3000*120*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*120*60)); + + for (int i = 0; i < 360000; i++) { + free(sql[i]); + } + + free(sql); + + return 0; +} + + +//small record size +int sql_s_perf1(TAOS *taos) { + char *sql[3000] = {0}; + TAOS_RES *result; + + for (int i = 0; i < 3000; i++) { + sql[i] = calloc(1, 1048576); + } + + int len = 0; + int tss = 0; + for (int l = 0; l < 3000; ++l) { + len = sprintf(sql[l], "insert into "); + for (int t = 0; t < 120; ++t) { + len += sprintf(sql[l] + len, "m%d values ", t); + for (int m = 0; m < 60; ++m) { + len += sprintf(sql[l] + len, "(%d, %d) ", tss++, m%2); + } + } + } + + + unsigned long long starttime = getCurrentTime(); + for (int i = 0; i < 3000; ++i) { + result = taos_query(taos, sql[i]); + int code = taos_errno(result); + if (code != 0) { + printf("failed to query table, reason:%s\n", taos_errstr(result)); + taos_free_result(result); + exit(1); + } + + taos_free_result(result); + } + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%.1f useconds\n", 3000*120*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*120*60)); + + for (int i = 0; i < 3000; i++) { + free(sql[i]); + } + + return 0; +} + + +void prepare(TAOS *taos, int bigsize, int createChildTable) { + TAOS_RES *result; + int code; + + result = taos_query(taos, "drop database demo"); + taos_free_result(result); + + result = taos_query(taos, "create database demo keep 36500"); + code = taos_errno(result); + if (code != 0) { + printf("failed to create database, reason:%s\n", taos_errstr(result)); + taos_free_result(result); + exit(1); + } + taos_free_result(result); + + result = taos_query(taos, "use demo"); + taos_free_result(result); + + if (createChildTable) { + // create table + for (int i = 0 ; i < 300; i++) { + char buf[1024]; + if (bigsize) { + sprintf(buf, "create table m%d (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, bin binary(40), bin2 binary(40))", i) ; + } else { + sprintf(buf, "create table m%d (ts timestamp, b int)", i) ; + } + result = taos_query(taos, buf); + code = taos_errno(result); + if (code != 0) { + printf("failed to create table, reason:%s\n", taos_errstr(result)); + taos_free_result(result); + exit(1); + } + taos_free_result(result); + } + } else { + char buf[1024]; + if (bigsize) { + sprintf(buf, "create stable stb1 (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, bin binary(40), bin2 binary(40))" + " tags(id1 int, id2 bool, id3 tinyint, id4 smallint, id5 bigint, id6 float, id7 double, id8 binary(40), id9 nchar(40))") ; + } else { + sprintf(buf, "create stable stb1 (ts timestamp, b int) tags(id1 int, id2 bool, id3 tinyint, id4 smallint, id5 bigint, id6 float, id7 double, id8 binary(40), id9 nchar(40))") ; + } + + result = taos_query(taos, buf); + code = taos_errno(result); + if (code != 0) { + printf("failed to create table, reason:%s\n", taos_errstr(result)); + taos_free_result(result); + exit(1); + } + taos_free_result(result); + } + +} + + + +void preparem(TAOS *taos, int bigsize, int idx) { + TAOS_RES *result; + int code; + char dbname[32],sql[255]; + + sprintf(dbname, "demo%d", idx); + sprintf(sql, "drop database %s", dbname); + + + result = taos_query(taos, sql); + taos_free_result(result); + + sprintf(sql, "create database %s keep 36500", dbname); + result = taos_query(taos, sql); + code = taos_errno(result); + if (code != 0) { + printf("failed to create database, reason:%s\n", taos_errstr(result)); + taos_free_result(result); + exit(1); + } + taos_free_result(result); + + sprintf(sql, "use %s", dbname); + result = taos_query(taos, sql); + taos_free_result(result); + + // create table + for (int i = 0 ; i < 300; i++) { + char buf[1024]; + if (bigsize) { + sprintf(buf, "create table m%d (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, bin binary(40), bin2 binary(40))", i) ; + } else { + sprintf(buf, "create table m%d (ts timestamp, b int)", i) ; + } + result = taos_query(taos, buf); + code = taos_errno(result); + if (code != 0) { + printf("failed to create table, reason:%s\n", taos_errstr(result)); + taos_free_result(result); + exit(1); + } + taos_free_result(result); + } + +} + + + +//void runcase(TAOS *taos, int idx) { +void* runcase(void *par) { + T_par* tpar = (T_par *)par; + TAOS *taos = tpar->taos; + int idx = tpar->idx; + + TAOS_STMT *stmt; + + (void)idx; + +#if 1 + prepare(taos, 1, 1); + + stmt = taos_stmt_init(taos); + + printf("10t+10records+specifycol start\n"); + stmt_scol_func1(stmt); + printf("10t+10records+specifycol end\n"); + printf("check result start\n"); + check_result(taos, "m0", 1, 10); + check_result(taos, "m1", 1, 10); + check_result(taos, "m2", 1, 10); + check_result(taos, "m3", 1, 10); + check_result(taos, "m4", 1, 10); + check_result(taos, "m5", 1, 10); + check_result(taos, "m6", 1, 10); + check_result(taos, "m7", 1, 10); + check_result(taos, "m8", 1, 10); + check_result(taos, "m9", 1, 10); + printf("check result end\n"); + taos_stmt_close(stmt); +#endif + + +#if 1 + prepare(taos, 1, 1); + + stmt = taos_stmt_init(taos); + + printf("1t+100records+specifycol start\n"); + stmt_scol_func2(stmt); + printf("1t+100records+specifycol end\n"); + printf("check result start\n"); + check_result(taos, "m0", 1, 100); + printf("check result end\n"); + taos_stmt_close(stmt); +#endif + + +#if 1 + prepare(taos, 1, 1); + + stmt = taos_stmt_init(taos); + + printf("300t+10r+bm+specifycol start\n"); + stmt_scol_func3(stmt); + printf("300t+10r+bm+specifycol end\n"); + printf("check result start\n"); + check_result(taos, "m0", 1, 20); + check_result(taos, "m1", 1, 20); + check_result(taos, "m111", 1, 20); + check_result(taos, "m223", 1, 20); + check_result(taos, "m299", 1, 20); + printf("check result end\n"); + taos_stmt_close(stmt); + +#endif + +#if 1 + prepare(taos, 1, 1); + + stmt = taos_stmt_init(taos); + + printf("10t+2r+bm+specifycol start\n"); + stmt_scol_func4(stmt); + printf("10t+2r+bm+specifycol end\n"); + printf("check result start\n"); + check_result(taos, "m0", 1, 20); + check_result(taos, "m1", 1, 20); + check_result(taos, "m2", 1, 20); + check_result(taos, "m3", 1, 20); + check_result(taos, "m4", 1, 20); + check_result(taos, "m5", 1, 20); + check_result(taos, "m6", 1, 20); + check_result(taos, "m7", 1, 20); + check_result(taos, "m8", 1, 20); + check_result(taos, "m9", 1, 20); + printf("check result end\n"); + taos_stmt_close(stmt); + +#endif + + +#if 1 + prepare(taos, 1, 1); + + stmt = taos_stmt_init(taos); + + printf("10t+10records start\n"); + stmt_func1(stmt); + printf("10t+10records end\n"); + printf("check result start\n"); + check_result(taos, "m0", 1, 10); + check_result(taos, "m1", 1, 10); + check_result(taos, "m2", 1, 10); + check_result(taos, "m3", 1, 10); + check_result(taos, "m4", 1, 10); + check_result(taos, "m5", 1, 10); + check_result(taos, "m6", 1, 10); + check_result(taos, "m7", 1, 10); + check_result(taos, "m8", 1, 10); + check_result(taos, "m9", 1, 10); + printf("check result end\n"); + taos_stmt_close(stmt); + +#endif + +#if 1 + prepare(taos, 1, 1); + + stmt = taos_stmt_init(taos); + + printf("10t+[0,1,2...9]records start\n"); + stmt_func2(stmt); + printf("10t+[0,1,2...9]records end\n"); + printf("check result start\n"); + check_result(taos, "m0", 0, 0); + check_result(taos, "m1", 0, 100); + check_result(taos, "m2", 0, 200); + check_result(taos, "m3", 0, 300); + check_result(taos, "m4", 0, 400); + check_result(taos, "m5", 0, 500); + check_result(taos, "m6", 0, 600); + check_result(taos, "m7", 0, 700); + check_result(taos, "m8", 0, 800); + check_result(taos, "m9", 0, 900); + printf("check result end\n"); + taos_stmt_close(stmt); + +#endif + +#if 1 + prepare(taos, 1, 1); + + stmt = taos_stmt_init(taos); + + printf("10t+[0,100,200...900]records start\n"); + stmt_func3(stmt); + printf("10t+[0,100,200...900]records end\n"); + printf("check result start\n"); + check_result(taos, "m0", 0, 0); + check_result(taos, "m1", 0, 100); + check_result(taos, "m2", 0, 200); + check_result(taos, "m3", 0, 300); + check_result(taos, "m4", 0, 400); + check_result(taos, "m5", 0, 500); + check_result(taos, "m6", 0, 600); + check_result(taos, "m7", 0, 700); + check_result(taos, "m8", 0, 800); + check_result(taos, "m9", 0, 900); + printf("check result end\n"); + taos_stmt_close(stmt); + +#endif + + +#if 1 + prepare(taos, 1, 1); + + stmt = taos_stmt_init(taos); + + printf("300t+60r+bm start\n"); + stmt_funcb1(stmt); + printf("300t+60r+bm end\n"); + printf("check result start\n"); + check_result(taos, "m0", 0, 180000); + check_result(taos, "m1", 0, 180000); + check_result(taos, "m111", 0, 180000); + check_result(taos, "m223", 0, 180000); + check_result(taos, "m299", 0, 180000); + printf("check result end\n"); + taos_stmt_close(stmt); + +#endif + +#if 1 + prepare(taos, 1, 0); + + stmt = taos_stmt_init(taos); + + printf("1t+10r+bm+autoctb1 start\n"); + stmt_funcb_autoctb1(stmt); + printf("1t+10r+bm+autoctb1 end\n"); + printf("check result start\n"); + check_result(taos, "m0", 1, 10); + printf("check result end\n"); + taos_stmt_close(stmt); + +#endif + +#if 1 + prepare(taos, 1, 0); + + stmt = taos_stmt_init(taos); + + printf("1t+10r+bm+autoctb2 start\n"); + stmt_funcb_autoctb2(stmt); + printf("1t+10r+bm+autoctb2 end\n"); + printf("check result start\n"); + check_result(taos, "m0", 1, 10); + printf("check result end\n"); + taos_stmt_close(stmt); + +#endif + + +#if 1 + prepare(taos, 1, 0); + + stmt = taos_stmt_init(taos); + + printf("1t+10r+bm+autoctb3 start\n"); + stmt_funcb_autoctb3(stmt); + printf("1t+10r+bm+autoctb3 end\n"); + printf("check result start\n"); + check_result(taos, "m0", 1, 10); + printf("check result end\n"); + taos_stmt_close(stmt); + +#endif + + +#if 1 + prepare(taos, 1, 0); + + stmt = taos_stmt_init(taos); + + printf("1t+10r+bm+autoctb4 start\n"); + stmt_funcb_autoctb4(stmt); + printf("1t+10r+bm+autoctb4 end\n"); + printf("check result start\n"); + check_result(taos, "m0", 1, 10); + printf("check result end\n"); + taos_stmt_close(stmt); +#endif + + +#if 1 + prepare(taos, 1, 0); + + stmt = taos_stmt_init(taos); + + printf("1t+10r+bm+autoctb+e1 start\n"); + stmt_funcb_autoctb_e1(stmt); + printf("1t+10r+bm+autoctb+e1 end\n"); + printf("check result start\n"); + //check_result(taos, "m0", 1, 0); + printf("check result end\n"); + taos_stmt_close(stmt); + +#endif + +#if 1 + prepare(taos, 1, 0); + + stmt = taos_stmt_init(taos); + + printf("1t+10r+bm+autoctb+e2 start\n"); + stmt_funcb_autoctb_e2(stmt); + printf("1t+10r+bm+autoctb+e2 end\n"); + printf("check result start\n"); + //check_result(taos, "m0", 1, 0); + printf("check result end\n"); + taos_stmt_close(stmt); + +#endif + +#if 1 + prepare(taos, 1, 0); + + stmt = taos_stmt_init(taos); + + printf("1t+10r+bm+autoctb+e3 start\n"); + stmt_funcb_autoctb_e3(stmt); + printf("1t+10r+bm+autoctb+e3 end\n"); + printf("check result start\n"); + //check_result(taos, "m0", 1, 0); + printf("check result end\n"); + taos_stmt_close(stmt); + +#endif + + +#if 1 + prepare(taos, 1, 0); + + stmt = taos_stmt_init(taos); + + printf("1t+10r+bm+autoctb+e4 start\n"); + stmt_funcb_autoctb_e4(stmt); + printf("1t+10r+bm+autoctb+e4 end\n"); + printf("check result start\n"); + //check_result(taos, "m0", 1, 0); + printf("check result end\n"); + taos_stmt_close(stmt); + +#endif + +#if 1 + prepare(taos, 1, 0); + + stmt = taos_stmt_init(taos); + + printf("1t+10r+bm+autoctb+e5 start\n"); + stmt_funcb_autoctb_e5(stmt); + printf("1t+10r+bm+autoctb+e5 end\n"); + printf("check result start\n"); + //check_result(taos, "m0", 1, 0); + printf("check result end\n"); + taos_stmt_close(stmt); + +#endif + + +#if 1 + prepare(taos, 1, 0); + + stmt = taos_stmt_init(taos); + + printf("e6 start\n"); + stmt_funcb_autoctb_e6(stmt); + printf("e6 end\n"); + taos_stmt_close(stmt); + +#endif + +#if 1 + prepare(taos, 1, 0); + + stmt = taos_stmt_init(taos); + + printf("e7 start\n"); + stmt_funcb_autoctb_e7(stmt); + printf("e7 end\n"); + taos_stmt_close(stmt); + +#endif + +#if 1 + prepare(taos, 1, 0); + + stmt = taos_stmt_init(taos); + + printf("e8 start\n"); + stmt_funcb_autoctb_e8(stmt); + printf("e8 end\n"); + taos_stmt_close(stmt); + +#endif + + +#if 1 + prepare(taos, 1, 0); + + stmt = taos_stmt_init(taos); + + printf("stmt_multi_insert_check start\n"); + stmt_multi_insert_check(stmt); + printf("stmt_multi_insert_check end\n"); + taos_stmt_close(stmt); +#endif + +#if 1 + prepare(taos, 1, 1); + + stmt = taos_stmt_init(taos); + + printf("1t+18000r+bm start\n"); + stmt_funcb2(stmt); + printf("1t+18000r+bm end\n"); + printf("check result start\n"); + check_result(taos, "m0", 0, 180000); + check_result(taos, "m1", 0, 180000); + check_result(taos, "m111", 0, 180000); + check_result(taos, "m223", 0, 180000); + check_result(taos, "m299", 0, 180000); + printf("check result end\n"); + taos_stmt_close(stmt); + +#endif + +#if 1 + prepare(taos, 1, 1); + + stmt = taos_stmt_init(taos); + + printf("300t+60r+disorder+bm start\n"); + stmt_funcb3(stmt); + printf("300t+60r+disorder+bm end\n"); + printf("check result start\n"); + check_result(taos, "m0", 0, 180000); + check_result(taos, "m1", 0, 180000); + check_result(taos, "m111", 0, 180000); + check_result(taos, "m223", 0, 180000); + check_result(taos, "m299", 0, 180000); + printf("check result end\n"); + taos_stmt_close(stmt); + +#endif + + +#if 1 + prepare(taos, 1, 1); + + stmt = taos_stmt_init(taos); + + printf("300t+60r+samets+bm start\n"); + stmt_funcb4(stmt); + printf("300t+60r+samets+bm end\n"); + printf("check result start\n"); + check_result(taos, "m0", 0, 1); + check_result(taos, "m1", 0, 1); + check_result(taos, "m111", 0, 1); + check_result(taos, "m223", 0, 1); + check_result(taos, "m299", 0, 1); + printf("check result end\n"); + taos_stmt_close(stmt); +#endif + +#if 1 + prepare(taos, 1, 1); + + stmt = taos_stmt_init(taos); + + printf("1t+18000r+nodyntable+bm start\n"); + stmt_funcb5(stmt); + printf("1t+18000r+nodyntable+bm end\n"); + printf("check result start\n"); + check_result(taos, "m0", 0, 180000); + printf("check result end\n"); + taos_stmt_close(stmt); + +#endif + + +#if 1 + prepare(taos, 1, 1); + + stmt = taos_stmt_init(taos); + + printf("300t+60r+bm+sc start\n"); + stmt_funcb_sc1(stmt); + printf("300t+60r+bm+sc end\n"); + printf("check result start\n"); + check_result(taos, "m0", 0, 180000); + check_result(taos, "m1", 0, 180000); + check_result(taos, "m111", 0, 180000); + check_result(taos, "m223", 0, 180000); + check_result(taos, "m299", 0, 180000); + printf("check result end\n"); + taos_stmt_close(stmt); +#endif + +#if 1 + prepare(taos, 1, 1); + + stmt = taos_stmt_init(taos); + + printf("1t+60r+bm+sc start\n"); + stmt_funcb_sc2(stmt); + printf("1t+60r+bm+sc end\n"); + printf("check result start\n"); + check_result(taos, "m0", 0, 180000); + check_result(taos, "m1", 0, 180000); + check_result(taos, "m111", 0, 180000); + check_result(taos, "m223", 0, 180000); + check_result(taos, "m299", 0, 180000); + printf("check result end\n"); + taos_stmt_close(stmt); + +#endif + +#if 1 + prepare(taos, 1, 1); + + stmt = taos_stmt_init(taos); + + printf("10t+[1...10]r+bm+sc start\n"); + stmt_funcb_sc3(stmt); + printf("10t+[1...10]r+bm+sc end\n"); + printf("check result start\n"); + check_result(taos, "m0", 1, 1); + check_result(taos, "m1", 1, 2); + check_result(taos, "m2", 1, 3); + check_result(taos, "m3", 1, 4); + check_result(taos, "m4", 1, 5); + check_result(taos, "m5", 1, 6); + check_result(taos, "m6", 1, 7); + check_result(taos, "m7", 1, 8); + check_result(taos, "m8", 1, 9); + check_result(taos, "m9", 1, 10); + printf("check result end\n"); + taos_stmt_close(stmt); + +#endif + + +#if 1 + prepare(taos, 1, 1); + + stmt = taos_stmt_init(taos); + + printf("1t+60r+bm start\n"); + stmt_funcb_s1(stmt); + printf("1t+60r+bm end\n"); + printf("check result start\n"); + check_result(taos, "m0", 0, 180000); + check_result(taos, "m1", 0, 180000); + check_result(taos, "m111", 0, 180000); + check_result(taos, "m223", 0, 180000); + check_result(taos, "m299", 0, 180000); + printf("check result end\n"); + taos_stmt_close(stmt); + +#endif + + +#if 1 + prepare(taos, 1, 1); + + (void)stmt; + printf("120t+60r+sql start\n"); + sql_perf1(taos); + printf("120t+60r+sql end\n"); + printf("check result start\n"); + check_result(taos, "m0", 0, 180000); + check_result(taos, "m1", 0, 180000); + check_result(taos, "m34", 0, 180000); + check_result(taos, "m67", 0, 180000); + check_result(taos, "m99", 0, 180000); + printf("check result end\n"); +#endif + +#if 1 + prepare(taos, 1, 1); + + (void)stmt; + printf("1t+60r+sql start\n"); + sql_perf_s1(taos); + printf("1t+60r+sql end\n"); + printf("check result start\n"); + check_result(taos, "m0", 0, 180000); + check_result(taos, "m1", 0, 180000); + check_result(taos, "m34", 0, 180000); + check_result(taos, "m67", 0, 180000); + check_result(taos, "m99", 0, 180000); + printf("check result end\n"); +#endif + +#if 1 + preparem(taos, 0, idx); + + stmt = taos_stmt_init(taos); + + printf("1t+30000r+bm start\n"); + stmt_funcb_ssz1(stmt); + printf("1t+30000r+bm end\n"); + printf("check result start\n"); + check_result(taos, "m0", 0, 300000); + check_result(taos, "m1", 0, 300000); + check_result(taos, "m111", 0, 300000); + check_result(taos, "m223", 0, 300000); + check_result(taos, "m299", 0, 300000); + printf("check result end\n"); + taos_stmt_close(stmt); + +#endif + + printf("test end\n"); + + return NULL; + +} + +int main(int argc, char *argv[]) +{ + TAOS *taos[4]; + + // connect to server + if (argc < 2) { + printf("please input server ip \n"); + return 0; + } + + taos[0] = taos_connect(argv[1], "root", "taosdata", NULL, 0); + if (taos == NULL) { + printf("failed to connect to db, reason:%s\n", taos_errstr(taos)); + exit(1); + } + + taos[1] = taos_connect(argv[1], "root", "taosdata", NULL, 0); + if (taos == NULL) { + printf("failed to connect to db, reason:%s\n", taos_errstr(taos)); + exit(1); + } + + taos[2] = taos_connect(argv[1], "root", "taosdata", NULL, 0); + if (taos == NULL) { + printf("failed to connect to db, reason:%s\n", taos_errstr(taos)); + exit(1); + } + + taos[3] = taos_connect(argv[1], "root", "taosdata", NULL, 0); + if (taos == NULL) { + printf("failed to connect to db, reason:%s\n", taos_errstr(taos)); + exit(1); + } + + pthread_t *pThreadList = (pthread_t *) calloc(sizeof(pthread_t), 4); + + pthread_attr_t thattr; + pthread_attr_init(&thattr); + pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_JOINABLE); + T_par par[4]; + + par[0].taos = taos[0]; + par[0].idx = 0; + par[1].taos = taos[1]; + par[1].idx = 1; + par[2].taos = taos[2]; + par[2].idx = 2; + par[3].taos = taos[3]; + par[3].idx = 3; + + pthread_create(&(pThreadList[0]), &thattr, runcase, (void *)&par[0]); + //pthread_create(&(pThreadList[1]), &thattr, runcase, (void *)&par[1]); + //pthread_create(&(pThreadList[2]), &thattr, runcase, (void *)&par[2]); + //pthread_create(&(pThreadList[3]), &thattr, runcase, (void *)&par[3]); + + while(1) { + sleep(1); + } + return 0; +} + diff --git a/tests/script/api/makefile b/tests/script/api/makefile new file mode 100644 index 0000000000000000000000000000000000000000..0357b284549558e5ea27ff7c3296c37285d92cd5 --- /dev/null +++ b/tests/script/api/makefile @@ -0,0 +1,24 @@ +# Copyright (c) 2017 by TAOS Technologies, Inc. +# todo: library dependency, header file dependency + +ROOT=./ +TARGET=exe +LFLAGS = '-Wl,-rpath,/usr/local/taos/driver/' -ltaos -lpthread -lm -lrt +CFLAGS = -O0 -g -Wall -Wno-deprecated -fPIC -Wno-unused-result -Wconversion \ + -Wno-char-subscripts -D_REENTRANT -Wno-format -D_REENTRANT -DLINUX \ + -Wno-unused-function -D_M_X64 -I/usr/local/taos/include -std=gnu99 \ + -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment + +all: $(TARGET) + +exe: + gcc $(CFLAGS) ./batchprepare.c -o $(ROOT)batchprepare $(LFLAGS) + gcc $(CFLAGS) ./stmtBatchTest.c -o $(ROOT)stmtBatchTest $(LFLAGS) + gcc $(CFLAGS) ./stmtTest.c -o $(ROOT)stmtTest $(LFLAGS) + gcc $(CFLAGS) ./stmt.c -o $(ROOT)stmt $(LFLAGS) + +clean: + rm $(ROOT)batchprepare + rm $(ROOT)stmtBatchTest + rm $(ROOT)stmtTest + rm $(ROOT)stmt diff --git a/tests/script/api/stmt.c b/tests/script/api/stmt.c new file mode 100644 index 0000000000000000000000000000000000000000..ef62b22f9a52c226c0194173fd391ecb782c9e6b --- /dev/null +++ b/tests/script/api/stmt.c @@ -0,0 +1,545 @@ +#include +#include +#include +#include +#include +#include +#include +#include "taos.h" + +void execute_simple_sql(void *taos, char *sql) { + TAOS_RES *result = taos_query(taos, sql); + if (result == NULL || taos_errno(result) != 0) { + printf("failed to %s, Reason: %s\n", sql, taos_errstr(result)); + taos_free_result(result); + exit(EXIT_FAILURE); + } + taos_free_result(result); +} + +void print_result(TAOS_RES *res) { + if (res == NULL) { + exit(EXIT_FAILURE); + } + TAOS_ROW row = NULL; + int num_fields = taos_num_fields(res); + TAOS_FIELD *fields = taos_fetch_fields(res); + while ((row = taos_fetch_row(res))) { + char temp[256] = {0}; + taos_print_row(temp, row, fields, num_fields); + printf("get result: %s\n", temp); + } +} + +void taos_stmt_init_test() { + printf("start taos_stmt_init test \n"); + void * taos = NULL; + TAOS_STMT *stmt = NULL; + stmt = taos_stmt_init(taos); + assert(stmt == NULL); + // ASM ERROR + assert(taos_stmt_close(stmt) != 0); + taos = taos_connect("127.0.0.1", "root", "taosdata", NULL, 0); + if (taos == NULL) { + printf("Cannot connect to tdengine server\n"); + exit(EXIT_FAILURE); + } + stmt = taos_stmt_init(taos); + assert(stmt != NULL); + assert(taos_stmt_close(stmt) == 0); + printf("finish taos_stmt_init test\n"); +} +void taos_stmt_preprare_test() { + printf("start taos_stmt_prepare test\n"); + char * stmt_sql = calloc(1, 1048576); + TAOS_STMT *stmt = NULL; + assert(taos_stmt_prepare(stmt, stmt_sql, 0) != 0); + void *taos = NULL; + taos = taos_connect("127.0.0.1", "root", "taosdata", NULL, 0); + if (taos == NULL) { + printf("Cannot connect to tdengine server\n"); + exit(EXIT_FAILURE); + } + execute_simple_sql(taos, "drop database if exists stmt_test"); + execute_simple_sql(taos, "create database stmt_test"); + execute_simple_sql(taos, "use stmt_test"); + execute_simple_sql(taos, + "create table super(ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 binary(8), c6 " + "smallint, c7 tinyint, c8 bool, c9 nchar(8), c10 timestamp) tags (t1 int, t2 bigint, t3 float, t4 " + "double, t5 binary(8), t6 smallint, t7 tinyint, t8 bool, t9 nchar(8))"); + stmt = taos_stmt_init(taos); + assert(stmt != NULL); + // below will make client dead lock + assert(taos_stmt_prepare(stmt, stmt_sql, 0) == 0); + + assert(taos_stmt_close(stmt) == 0); + stmt = taos_stmt_init(taos); + assert(stmt != NULL); + sprintf(stmt_sql, "select from ?"); + assert(taos_stmt_prepare(stmt, stmt_sql, 0) == 0); + assert(taos_stmt_close(stmt) == 0); + + stmt = taos_stmt_init(taos); + assert(stmt != NULL); + sprintf(stmt_sql, "insert into ? values (?,?,?,?,?,?,?,?,?,?,?)"); + assert(taos_stmt_prepare(stmt, stmt_sql, 0) == 0); + assert(taos_stmt_close(stmt) == 0); + + stmt = taos_stmt_init(taos); + assert(stmt != NULL); + sprintf(stmt_sql, "insert into super values (?,?,?,?,?,?,?,?,?,?,?)"); + assert(taos_stmt_prepare(stmt, stmt_sql, 0) != 0); + assert(taos_stmt_close(stmt) == 0); + + stmt = taos_stmt_init(taos); + assert(stmt != NULL); + sprintf(stmt_sql, "insert into ? values (?,?,?,?,?,?,?,?,1,?,?,?)"); + assert(taos_stmt_prepare(stmt, stmt_sql, 0) == 0); + assert(taos_stmt_close(stmt) == 0); + + free(stmt_sql); + printf("finish taos_stmt_prepare test\n"); +} + +void taos_stmt_set_tbname_test() { + printf("start taos_stmt_set_tbname test\n"); + TAOS_STMT *stmt = NULL; + char * name = calloc(1, 200); + // ASM ERROR + assert(taos_stmt_set_tbname(stmt, name) != 0); + void *taos = taos_connect("127.0.0.1", "root", "taosdata", NULL, 0); + if (taos == NULL) { + printf("Cannot connect to tdengine server\n"); + exit(EXIT_FAILURE); + } + execute_simple_sql(taos, "drop database if exists stmt_test"); + execute_simple_sql(taos, "create database stmt_test"); + execute_simple_sql(taos, "use stmt_test"); + execute_simple_sql(taos, "create table super(ts timestamp, c1 int)"); + stmt = taos_stmt_init(taos); + assert(stmt != NULL); + assert(taos_stmt_set_tbname(stmt, name) != 0); + char *stmt_sql = calloc(1, 1000); + sprintf(stmt_sql, "insert into ? values (?,?)"); + assert(taos_stmt_prepare(stmt, stmt_sql, 0) == 0); + sprintf(name, "super"); + assert(stmt != NULL); + assert(taos_stmt_set_tbname(stmt, name) == 0); + free(name); + free(stmt_sql); + taos_stmt_close(stmt); + printf("finish taos_stmt_set_tbname test\n"); +} + +void taos_stmt_set_tbname_tags_test() { + printf("start taos_stmt_set_tbname_tags test\n"); + TAOS_STMT *stmt = NULL; + char * name = calloc(1, 20); + TAOS_BIND *tags = calloc(1, sizeof(TAOS_BIND)); + // ASM ERROR + assert(taos_stmt_set_tbname_tags(stmt, name, tags) != 0); + void *taos = taos_connect("127.0.0.1", "root", "taosdata", NULL, 0); + if (taos == NULL) { + printf("Cannot connect to tdengine server\n"); + exit(EXIT_FAILURE); + } + execute_simple_sql(taos, "drop database if exists stmt_test"); + execute_simple_sql(taos, "create database stmt_test"); + execute_simple_sql(taos, "use stmt_test"); + execute_simple_sql(taos, "create stable super(ts timestamp, c1 int) tags (id int)"); + execute_simple_sql(taos, "create table tb using super tags (1)"); + stmt = taos_stmt_init(taos); + assert(stmt != NULL); + char *stmt_sql = calloc(1, 1000); + sprintf(stmt_sql, "insert into ? using super tags (?) values (?,?)"); + assert(taos_stmt_prepare(stmt, stmt_sql, 0) == 0); + assert(taos_stmt_set_tbname_tags(stmt, name, tags) != 0); + sprintf(name, "tb"); + assert(taos_stmt_set_tbname_tags(stmt, name, tags) != 0); + int t = 1; + tags->buffer_length = TSDB_DATA_TYPE_INT; + tags->buffer_length = sizeof(uint32_t); + tags->buffer = &t; + tags->length = &tags->buffer_length; + tags->is_null = NULL; + assert(taos_stmt_set_tbname_tags(stmt, name, tags) == 0); + free(stmt_sql); + free(name); + free(tags); + taos_stmt_close(stmt); + printf("finish taos_stmt_set_tbname_tags test\n"); +} + +void taos_stmt_set_sub_tbname_test() { + printf("start taos_stmt_set_sub_tbname test\n"); + TAOS_STMT *stmt = NULL; + char * name = calloc(1, 200); + // ASM ERROR + assert(taos_stmt_set_sub_tbname(stmt, name) != 0); + void *taos = taos_connect("127.0.0.1", "root", "taosdata", NULL, 0); + if (taos == NULL) { + printf("Cannot connect to tdengine server\n"); + exit(EXIT_FAILURE); + } + execute_simple_sql(taos, "drop database if exists stmt_test"); + execute_simple_sql(taos, "create database stmt_test"); + execute_simple_sql(taos, "use stmt_test"); + execute_simple_sql(taos, "create stable super(ts timestamp, c1 int) tags (id int)"); + execute_simple_sql(taos, "create table tb using super tags (1)"); + stmt = taos_stmt_init(taos); + assert(stmt != NULL); + char *stmt_sql = calloc(1, 1000); + sprintf(stmt_sql, "insert into ? values (?,?)"); + assert(taos_stmt_prepare(stmt, stmt_sql, 0) == 0); + assert(taos_stmt_set_sub_tbname(stmt, name) != 0); + sprintf(name, "tb"); + assert(taos_stmt_set_sub_tbname(stmt, name) == 0); + assert(taos_load_table_info(taos, "super, tb") == 0); + assert(taos_stmt_set_sub_tbname(stmt, name) == 0); + free(name); + free(stmt_sql); + assert(taos_stmt_close(stmt) == 0); + printf("finish taos_stmt_set_sub_tbname test\n"); +} + +void taos_stmt_bind_param_test() { + printf("start taos_stmt_bind_param test\n"); + TAOS_STMT *stmt = NULL; + TAOS_BIND *binds = NULL; + assert(taos_stmt_bind_param(stmt, binds) != 0); + void *taos = taos_connect("127.0.0.1", "root", "taosdata", NULL, 0); + if (taos == NULL) { + printf("Cannot connect to tdengine server\n"); + exit(EXIT_FAILURE); + } + execute_simple_sql(taos, "drop database if exists stmt_test"); + execute_simple_sql(taos, "create database stmt_test"); + execute_simple_sql(taos, "use stmt_test"); + execute_simple_sql(taos, "create table super(ts timestamp, c1 int)"); + stmt = taos_stmt_init(taos); + char *stmt_sql = calloc(1, 1000); + sprintf(stmt_sql, "insert into ? values (?,?)"); + assert(taos_stmt_prepare(stmt, stmt_sql, 0) == 0); + assert(taos_stmt_bind_param(stmt, binds) != 0); + free(binds); + TAOS_BIND *params = calloc(2, sizeof(TAOS_BIND)); + int64_t ts = (int64_t)1591060628000; + params[0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[0].buffer_length = sizeof(uint64_t); + params[0].buffer = &ts; + params[0].length = ¶ms[0].buffer_length; + params[0].is_null = NULL; + int32_t i = (int32_t)21474; + params[1].buffer_type = TSDB_DATA_TYPE_INT; + params[1].buffer_length = sizeof(int32_t); + params[1].buffer = &i; + params[1].length = ¶ms[1].buffer_length; + params[1].is_null = NULL; + assert(taos_stmt_bind_param(stmt, params) != 0); + assert(taos_stmt_set_tbname(stmt, "super") == 0); + assert(taos_stmt_bind_param(stmt, params) == 0); + free(params); + free(stmt_sql); + taos_stmt_close(stmt); + printf("finish taos_stmt_bind_param test\n"); +} + +void taos_stmt_bind_single_param_batch_test() { + printf("start taos_stmt_bind_single_param_batch test\n"); + TAOS_STMT * stmt = NULL; + TAOS_MULTI_BIND *test_bind = NULL; + assert(taos_stmt_bind_single_param_batch(stmt, test_bind, 0) != 0); + printf("finish taos_stmt_bind_single_param_batch test\n"); +} + +void taos_stmt_bind_param_batch_test() { + printf("start taos_stmt_bind_param_batch test\n"); + TAOS_STMT * stmt = NULL; + TAOS_MULTI_BIND *test_bind = NULL; + assert(taos_stmt_bind_param_batch(stmt, test_bind) != 0); + printf("finish taos_stmt_bind_param_batch test\n"); +} + +void taos_stmt_add_batch_test() { + printf("start taos_stmt_add_batch test\n"); + TAOS_STMT *stmt = NULL; + assert(taos_stmt_add_batch(stmt) != 0); + void *taos = taos_connect("127.0.0.1", "root", "taosdata", NULL, 0); + if (taos == NULL) { + printf("Cannot connect to tdengine server\n"); + exit(EXIT_FAILURE); + } + execute_simple_sql(taos, "drop database if exists stmt_test"); + execute_simple_sql(taos, "create database stmt_test"); + execute_simple_sql(taos, "use stmt_test"); + execute_simple_sql(taos, "create table super(ts timestamp, c1 int)"); + stmt = taos_stmt_init(taos); + assert(stmt != NULL); + char *stmt_sql = calloc(1, 1000); + sprintf(stmt_sql, "insert into ? values (?,?)"); + assert(taos_stmt_prepare(stmt, stmt_sql, 0) == 0); + assert(taos_stmt_add_batch(stmt) != 0); + TAOS_BIND *params = calloc(2, sizeof(TAOS_BIND)); + int64_t ts = (int64_t)1591060628000; + params[0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[0].buffer_length = sizeof(uint64_t); + params[0].buffer = &ts; + params[0].length = ¶ms[0].buffer_length; + params[0].is_null = NULL; + int32_t i = (int32_t)21474; + params[1].buffer_type = TSDB_DATA_TYPE_INT; + params[1].buffer_length = sizeof(int32_t); + params[1].buffer = &i; + params[1].length = ¶ms[1].buffer_length; + params[1].is_null = NULL; + assert(taos_stmt_set_tbname(stmt, "super") == 0); + assert(taos_stmt_bind_param(stmt, params) == 0); + assert(taos_stmt_add_batch(stmt) == 0); + free(params); + free(stmt_sql); + assert(taos_stmt_close(stmt) == 0); + printf("finish taos_stmt_add_batch test\n"); +} + +void taos_stmt_execute_test() { + printf("start taos_stmt_execute test\n"); + TAOS_STMT *stmt = NULL; + assert(taos_stmt_execute(stmt) != 0); + void *taos = taos_connect("127.0.0.1", "root", "taosdata", NULL, 0); + if (taos == NULL) { + printf("Cannot connect to tdengine server\n"); + exit(EXIT_FAILURE); + } + execute_simple_sql(taos, "drop database if exists stmt_test"); + execute_simple_sql(taos, "create database stmt_test"); + execute_simple_sql(taos, "use stmt_test"); + execute_simple_sql(taos, "create table super(ts timestamp, c1 int)"); + stmt = taos_stmt_init(taos); + assert(stmt != NULL); + assert(taos_stmt_execute(stmt) != 0); + char *stmt_sql = calloc(1, 1000); + sprintf(stmt_sql, "insert into ? values (?,?)"); + assert(taos_stmt_prepare(stmt, stmt_sql, 0) == 0); + assert(taos_stmt_execute(stmt) != 0); + TAOS_BIND *params = calloc(2, sizeof(TAOS_BIND)); + int64_t ts = (int64_t)1591060628000; + params[0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[0].buffer_length = sizeof(uint64_t); + params[0].buffer = &ts; + params[0].length = ¶ms[0].buffer_length; + params[0].is_null = NULL; + int32_t i = (int32_t)21474; + params[1].buffer_type = TSDB_DATA_TYPE_INT; + params[1].buffer_length = sizeof(int32_t); + params[1].buffer = &i; + params[1].length = ¶ms[1].buffer_length; + params[1].is_null = NULL; + assert(taos_stmt_set_tbname(stmt, "super") == 0); + assert(taos_stmt_execute(stmt) != 0); + assert(taos_stmt_bind_param(stmt, params) == 0); + assert(taos_stmt_execute(stmt) != 0); + assert(taos_stmt_add_batch(stmt) == 0); + assert(taos_stmt_execute(stmt) == 0); + free(params); + free(stmt_sql); + assert(taos_stmt_close(stmt) == 0); + printf("finish taos_stmt_execute test\n"); +} + +void taos_stmt_use_result_query(void *taos, char *col, int type) { + TAOS_STMT *stmt = taos_stmt_init(taos); + assert(stmt != NULL); + char *stmt_sql = calloc(1, 1024); + struct { + int64_t long_value; + int64_t ts_value; + uint64_t ulong_value; + int32_t int_value; + uint32_t uint_value; + int16_t small_value; + uint16_t usmall_value; + int8_t tiny_value; + uint8_t utiny_value; + float float_value; + double double_value; + char binary_value[10]; + char nchar_value[32]; + } v = {0}; + v.ts_value = (int64_t)1591060628000; + v.long_value = (int64_t)1; + v.int_value = (int32_t)1; + v.small_value = (int16_t)1; + v.tiny_value = (int8_t)1; + v.ulong_value = (uint64_t)1; + v.uint_value = (uint32_t)1; + v.usmall_value = (uint16_t)1; + v.utiny_value = (uint8_t)1; + v.float_value = (float)1; + v.double_value = (double)1; + strcpy(v.binary_value, "abcdefgh"); + strcpy(v.nchar_value, "一二三四五六七八"); + uintptr_t nchar_value_len = strlen(v.nchar_value); + sprintf(stmt_sql, "select * from stmt_test.t1 where %s = ?", col); + printf("stmt_sql: %s\n", stmt_sql); + assert(taos_stmt_prepare(stmt, stmt_sql, 0) == 0); + TAOS_BIND *params = calloc(1, sizeof(TAOS_BIND)); + params->buffer_type = type; + params->is_null = NULL; + switch (type) { + case TSDB_DATA_TYPE_TIMESTAMP: + params->buffer_length = sizeof(v.ts_value); + params->buffer = &v.ts_value; + params->length = ¶ms->buffer_length; + break; + case TSDB_DATA_TYPE_INT: + params->buffer_length = sizeof(v.int_value); + params->buffer = &v.int_value; + params->length = ¶ms->buffer_length; + break; + case TSDB_DATA_TYPE_BIGINT: + params->buffer_length = sizeof(v.long_value); + params->buffer = &v.long_value; + params->length = ¶ms->buffer_length; + break; + case TSDB_DATA_TYPE_FLOAT: + params->buffer_length = sizeof(v.float_value); + params->buffer = &v.float_value; + params->length = ¶ms->buffer_length; + break; + case TSDB_DATA_TYPE_DOUBLE: + params->buffer_length = sizeof(v.double_value); + params->buffer = &v.double_value; + params->length = ¶ms->buffer_length; + break; + case TSDB_DATA_TYPE_BINARY: + params->buffer_length = sizeof(v.binary_value); + params->buffer = &v.binary_value; + params->length = ¶ms->buffer_length; + break; + case TSDB_DATA_TYPE_SMALLINT: + params->buffer_length = sizeof(v.small_value); + params->buffer = &v.small_value; + params->length = ¶ms->buffer_length; + break; + case TSDB_DATA_TYPE_TINYINT: + params->buffer_length = sizeof(v.tiny_value); + params->buffer = &v.tiny_value; + params->length = ¶ms->buffer_length; + break; + case TSDB_DATA_TYPE_BOOL: + params->buffer_length = sizeof(v.tiny_value); + params->buffer = &v.tiny_value; + params->length = ¶ms->buffer_length; + break; + case TSDB_DATA_TYPE_NCHAR: + params->buffer_length = sizeof(v.nchar_value); + params->buffer = &v.nchar_value; + params->length = &nchar_value_len; + break; + case TSDB_DATA_TYPE_UINT: + params->buffer_length = sizeof(v.uint_value); + params->buffer = &v.uint_value; + params->length = ¶ms->buffer_length; + break; + case TSDB_DATA_TYPE_UBIGINT: + params->buffer_length = sizeof(v.ulong_value); + params->buffer = &v.ulong_value; + params->length = ¶ms->buffer_length; + break; + case TSDB_DATA_TYPE_USMALLINT: + params->buffer_length = sizeof(v.usmall_value); + params->buffer = &v.usmall_value; + params->length = ¶ms->buffer_length; + break; + case TSDB_DATA_TYPE_UTINYINT: + params->buffer_length = sizeof(v.utiny_value); + params->buffer = &v.utiny_value; + params->length = ¶ms->buffer_length; + break; + default: + printf("Cannnot find type: %d\n", type); + break; + } + assert(taos_stmt_bind_param(stmt, params) == 0); + assert(taos_stmt_execute(stmt) == 0); + TAOS_RES *result = taos_stmt_use_result(stmt); + assert(result != NULL); + print_result(result); + taos_free_result(result); + assert(taos_stmt_close(stmt) == 0); + free(params); + free(stmt_sql); +} + +void taos_stmt_use_result_test() { + printf("start taos_stmt_use_result test\n"); + void *taos = taos_connect("127.0.0.1", "root", "taosdata", NULL, 0); + if (taos == NULL) { + printf("Cannot connect to tdengine server\n"); + exit(EXIT_FAILURE); + } + execute_simple_sql(taos, "drop database if exists stmt_test"); + execute_simple_sql(taos, "create database stmt_test"); + execute_simple_sql(taos, "use stmt_test"); + execute_simple_sql( + taos, + "create table super(ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 binary(8), c6 smallint, c7 tinyint, " + "c8 bool, c9 nchar(8), c10 timestamp, c11 int unsigned, c12 bigint unsigned, c13 smallint unsigned, c14 tinyint " + "unsigned) tags (t1 int, t2 bigint, t3 float, t4 double, t5 binary(8), t6 smallint, t7 tinyint, t8 bool, t9 " + "nchar(8), t10 int unsigned, t11 bigint unsigned, t12 smallint unsigned, t13 tinyint unsigned)"); + execute_simple_sql(taos, + "create table t1 using super tags (1, 1, 1, 1, 'abcdefgh',1,1,1,'一二三四五六七八', 1, 1, 1, 1)"); + execute_simple_sql( + taos, "insert into t1 values (1591060628000, 1, 1, 1, 1, 'abcdefgh',1,1,1,'一二三四五六七八', now, 1, 1, 1, 1)"); + execute_simple_sql( + taos, "insert into t1 values (1591060628001, 1, 1, 1, 1, 'abcdefgh',1,1,1,'一二三四五六七八', now, 1, 1, 1, 1)"); + + taos_stmt_use_result_query(taos, "ts", TSDB_DATA_TYPE_TIMESTAMP); + taos_stmt_use_result_query(taos, "c1", TSDB_DATA_TYPE_INT); + taos_stmt_use_result_query(taos, "c2", TSDB_DATA_TYPE_BIGINT); + taos_stmt_use_result_query(taos, "c3", TSDB_DATA_TYPE_FLOAT); + taos_stmt_use_result_query(taos, "c4", TSDB_DATA_TYPE_DOUBLE); + taos_stmt_use_result_query(taos, "c5", TSDB_DATA_TYPE_BINARY); + taos_stmt_use_result_query(taos, "c6", TSDB_DATA_TYPE_SMALLINT); + taos_stmt_use_result_query(taos, "c7", TSDB_DATA_TYPE_TINYINT); + taos_stmt_use_result_query(taos, "c8", TSDB_DATA_TYPE_BOOL); + taos_stmt_use_result_query(taos, "c9", TSDB_DATA_TYPE_NCHAR); + taos_stmt_use_result_query(taos, "c10", TSDB_DATA_TYPE_TIMESTAMP); + taos_stmt_use_result_query(taos, "c11", TSDB_DATA_TYPE_UINT); + taos_stmt_use_result_query(taos, "c12", TSDB_DATA_TYPE_UBIGINT); + taos_stmt_use_result_query(taos, "c13", TSDB_DATA_TYPE_USMALLINT); + taos_stmt_use_result_query(taos, "c14", TSDB_DATA_TYPE_UTINYINT); + + printf("finish taos_stmt_use_result test\n"); +} + +void taos_stmt_close_test() { + printf("start taos_stmt_close test\n"); + // ASM ERROR + TAOS_STMT *stmt = NULL; + assert(taos_stmt_close(stmt) != 0); + printf("finish taos_stmt_close test\n"); +} + +void test_api_reliability() { + // ASM catch memory leak + taos_stmt_init_test(); + taos_stmt_preprare_test(); + taos_stmt_set_tbname_test(); + taos_stmt_set_tbname_tags_test(); + taos_stmt_set_sub_tbname_test(); + taos_stmt_bind_param_test(); + taos_stmt_bind_single_param_batch_test(); + taos_stmt_bind_param_batch_test(); + taos_stmt_add_batch_test(); + taos_stmt_execute_test(); + taos_stmt_close_test(); +} + +void test_query() { taos_stmt_use_result_test(); } + +int main(int argc, char *argv[]) { + test_api_reliability(); + test_query(); + return 0; +} \ No newline at end of file diff --git a/tests/script/api/stmtBatchTest.c b/tests/script/api/stmtBatchTest.c new file mode 100644 index 0000000000000000000000000000000000000000..c488f2fa89714da3b20d9eafa4b7ff2c89580e0c --- /dev/null +++ b/tests/script/api/stmtBatchTest.c @@ -0,0 +1,5126 @@ +// TAOS standard API example. The same syntax as MySQL, but only a subet +// to compile: gcc -o prepare prepare.c -ltaos + +#include +#include +#include +#include "taos.h" +#include "taoserror.h" +#include +#include +#include + +#define MAX_ROWS_OF_PER_COLUMN 32770 +#define MAX_BINARY_DEF_LEN (1024*16) + +typedef struct { + int64_t *ts; + int8_t b[MAX_ROWS_OF_PER_COLUMN]; + int8_t v1[MAX_ROWS_OF_PER_COLUMN]; + int16_t v2[MAX_ROWS_OF_PER_COLUMN]; + int32_t v4[MAX_ROWS_OF_PER_COLUMN]; + int64_t v8[MAX_ROWS_OF_PER_COLUMN]; + float f4[MAX_ROWS_OF_PER_COLUMN]; + double f8[MAX_ROWS_OF_PER_COLUMN]; + //char br[MAX_ROWS_OF_PER_COLUMN][MAX_BINARY_DEF_LEN]; + //char nr[MAX_ROWS_OF_PER_COLUMN][MAX_BINARY_DEF_LEN]; + char *br; + char *nr; + int64_t ts2[MAX_ROWS_OF_PER_COLUMN]; +} sampleValue; + + +typedef struct { + TAOS *taos; + int idx; +} ThreadInfo; + +//void taosMsleep(int mseconds); + +int g_runTimes = 5; + + +unsigned long long getCurrentTime(){ + struct timeval tv; + if (gettimeofday(&tv, NULL) != 0) { + perror("Failed to get current time in ms"); + exit(EXIT_FAILURE); + } + + return (uint64_t)tv.tv_sec * 1000000ULL + (uint64_t)tv.tv_usec; +} + +static int stmt_bind_case_001(TAOS_STMT *stmt, int tableNum, int rowsOfPerColum, int bingNum, int lenOfBinaryDef, int lenOfBinaryAct, int columnNum) { + sampleValue* v = (sampleValue *)calloc(1, sizeof(sampleValue)); + + int totalRowsPerTbl = rowsOfPerColum * bingNum; + + v->ts = (int64_t *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * tableNum)); + v->br = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef)); + v->nr = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef)); + + int *lb = (int *)malloc(MAX_ROWS_OF_PER_COLUMN * sizeof(int)); + + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * (size_t)(bingNum * columnNum * (tableNum+1) * rowsOfPerColum)); + char* is_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN); + char* no_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN); + + int64_t tts = 1591060628000; + + for (int i = 0; i < rowsOfPerColum; ++i) { + lb[i] = lenOfBinaryAct; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v->b[i] = (int8_t)(i % 2); + v->v1[i] = (int8_t)((i+1) % 2); + v->v2[i] = (int16_t)i; + v->v4[i] = (int32_t)(i+1); + v->v8[i] = (int64_t)(i+2); + v->f4[i] = (float)(i+3); + v->f8[i] = (double)(i+4); + char tbuf[MAX_BINARY_DEF_LEN]; + memset(tbuf, 0, MAX_BINARY_DEF_LEN); + sprintf(tbuf, "binary-%d", i%10); + memcpy(v->br + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct); + memset(tbuf, 0, MAX_BINARY_DEF_LEN); + sprintf(tbuf, "nchar-%d", i%10); + memcpy(v->nr + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct); + v->ts2[i] = tts + i; + } + + int i = 0; + for (int j = 0; j < bingNum * tableNum; j++) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v->ts[j*rowsOfPerColum]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = rowsOfPerColum; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v->b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = rowsOfPerColum; + + params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[i+2].buffer_length = sizeof(int8_t); + params[i+2].buffer = v->v1; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = rowsOfPerColum; + + params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[i+3].buffer_length = sizeof(int16_t); + params[i+3].buffer = v->v2; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = rowsOfPerColum; + + params[i+4].buffer_type = TSDB_DATA_TYPE_INT; + params[i+4].buffer_length = sizeof(int32_t); + params[i+4].buffer = v->v4; + params[i+4].length = NULL; + params[i+4].is_null = is_null; + params[i+4].num = rowsOfPerColum; + + params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[i+5].buffer_length = sizeof(int64_t); + params[i+5].buffer = v->v8; + params[i+5].length = NULL; + params[i+5].is_null = is_null; + params[i+5].num = rowsOfPerColum; + + params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+6].buffer_length = sizeof(float); + params[i+6].buffer = v->f4; + params[i+6].length = NULL; + params[i+6].is_null = is_null; + params[i+6].num = rowsOfPerColum; + + params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[i+7].buffer_length = sizeof(double); + params[i+7].buffer = v->f8; + params[i+7].length = NULL; + params[i+7].is_null = is_null; + params[i+7].num = rowsOfPerColum; + + params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+8].buffer_length = (uintptr_t)lenOfBinaryDef; + params[i+8].buffer = v->br; + params[i+8].length = lb; + params[i+8].is_null = is_null; + params[i+8].num = rowsOfPerColum; + + params[i+9].buffer_type = TSDB_DATA_TYPE_NCHAR; + params[i+9].buffer_length = (uintptr_t)lenOfBinaryDef; + params[i+9].buffer = v->nr; + params[i+9].length = lb; + params[i+9].is_null = is_null; + params[i+9].num = rowsOfPerColum; + + params[i+10].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+10].buffer_length = sizeof(int64_t); + params[i+10].buffer = v->ts2; + params[i+10].length = NULL; + params[i+10].is_null = is_null; + params[i+10].num = rowsOfPerColum; + + i+=columnNum; + } + + //int64_t tts = 1591060628000; + for (int i = 0; i < totalRowsPerTbl * tableNum; ++i) { + v->ts[i] = tts + i; + } + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + + int id = 0; + for (int l = 0; l < bingNum; l++) { + for (int zz = 0; zz < tableNum; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + + for (int col=0; col < columnNum; ++col) { + code = taos_stmt_bind_single_param_batch(stmt, params + id, col); + if (code != 0){ + printf("failed to execute taos_stmt_bind_single_param_batch. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + id++; + } + + code = taos_stmt_add_batch(stmt); + if (code != 0) { + printf("failed to execute taos_stmt_add_batch. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + } + + code = taos_stmt_execute(stmt); + if (code != 0) { + printf("failed to execute taos_stmt_execute. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + } + + unsigned long long endtime = getCurrentTime(); + unsigned long long totalRows = (uint32_t)(totalRowsPerTbl * tableNum); + printf("insert total %d records, used %u seconds, avg:%u useconds per record\n", totalRows, (endtime-starttime)/1000000UL, (endtime-starttime)/totalRows); + + free(v->ts); + free(v->br); + free(v->nr); + free(v); + free(lb); + free(params); + free(is_null); + free(no_null); + + return 0; +} + + +static int stmt_bind_case_002(TAOS_STMT *stmt, int tableNum, int rowsOfPerColum, int bingNum, int lenOfBinaryDef, int lenOfBinaryAct, int columnNum) { + sampleValue* v = (sampleValue *)calloc(1, sizeof(sampleValue)); + + int totalRowsPerTbl = rowsOfPerColum * bingNum; + + v->ts = (int64_t *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * tableNum)); + v->br = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef)); + v->nr = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef)); + + int *lb = (int *)malloc(MAX_ROWS_OF_PER_COLUMN * sizeof(int)); + + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * (size_t)(bingNum * columnNum * (tableNum+1) * rowsOfPerColum)); + char* is_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN); + char* no_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN); + + int64_t tts = 1591060628000; + + for (int i = 0; i < rowsOfPerColum; ++i) { + lb[i] = lenOfBinaryAct; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v->b[i] = (int8_t)(i % 2); + v->v1[i] = (int8_t)((i+1) % 2); + v->v2[i] = (int16_t)i; + v->v4[i] = (int32_t)(i+1); + v->v8[i] = (int64_t)(i+2); + v->f4[i] = (float)(i+3); + v->f8[i] = (double)(i+4); + char tbuf[MAX_BINARY_DEF_LEN]; + memset(tbuf, 0, MAX_BINARY_DEF_LEN); + sprintf(tbuf, "binary-%d", i%10); + memcpy(v->br + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct); + memset(tbuf, 0, MAX_BINARY_DEF_LEN); + sprintf(tbuf, "nchar-%d", i%10); + memcpy(v->nr + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct); + v->ts2[i] = tts + i; + } + + int i = 0; + for (int j = 0; j < bingNum * tableNum; j++) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v->ts[j*rowsOfPerColum]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = rowsOfPerColum; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v->b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = rowsOfPerColum; + + params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[i+2].buffer_length = sizeof(int8_t); + params[i+2].buffer = v->v1; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = rowsOfPerColum; + + params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[i+3].buffer_length = sizeof(int16_t); + params[i+3].buffer = v->v2; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = rowsOfPerColum; + + params[i+4].buffer_type = TSDB_DATA_TYPE_INT; + params[i+4].buffer_length = sizeof(int32_t); + params[i+4].buffer = v->v4; + params[i+4].length = NULL; + params[i+4].is_null = is_null; + params[i+4].num = rowsOfPerColum; + + params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[i+5].buffer_length = sizeof(int64_t); + params[i+5].buffer = v->v8; + params[i+5].length = NULL; + params[i+5].is_null = is_null; + params[i+5].num = rowsOfPerColum; + + params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+6].buffer_length = sizeof(float); + params[i+6].buffer = v->f4; + params[i+6].length = NULL; + params[i+6].is_null = is_null; + params[i+6].num = rowsOfPerColum; + + params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[i+7].buffer_length = sizeof(double); + params[i+7].buffer = v->f8; + params[i+7].length = NULL; + params[i+7].is_null = is_null; + params[i+7].num = rowsOfPerColum; + + params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+8].buffer_length = (uintptr_t)lenOfBinaryDef; + params[i+8].buffer = v->br; + params[i+8].length = lb; + params[i+8].is_null = is_null; + params[i+8].num = rowsOfPerColum; + + params[i+9].buffer_type = TSDB_DATA_TYPE_NCHAR; + params[i+9].buffer_length = (uintptr_t)lenOfBinaryDef; + params[i+9].buffer = v->nr; + params[i+9].length = lb; + params[i+9].is_null = is_null; + params[i+9].num = rowsOfPerColum; + + params[i+10].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+10].buffer_length = sizeof(int64_t); + params[i+10].buffer = v->ts2; + params[i+10].length = NULL; + params[i+10].is_null = is_null; + params[i+10].num = rowsOfPerColum; + + i+=columnNum; + } + + //int64_t tts = 1591060628000; + for (int i = 0; i < totalRowsPerTbl * tableNum; ++i) { + v->ts[i] = tts + i; + } + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + + int id = 0; + for (int l = 0; l < bingNum; l++) { + for (int zz = 0; zz < tableNum; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + + for (int col=0; col < columnNum; ++col) { + code = taos_stmt_bind_single_param_batch(stmt, params + id, col); + if (code != 0){ + printf("failed to execute taos_stmt_bind_single_param_batch. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + id++; + } + + code = taos_stmt_add_batch(stmt); + if (code != 0) { + printf("failed to execute taos_stmt_add_batch. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + } + } + + code = taos_stmt_execute(stmt); + if (code != 0) { + printf("failed to execute taos_stmt_execute. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + + unsigned long long endtime = getCurrentTime(); + unsigned long long totalRows = (uint32_t)(totalRowsPerTbl * tableNum); + printf("insert total %d records, used %u seconds, avg:%u useconds per record\n", totalRows, (endtime-starttime)/1000000UL, (endtime-starttime)/totalRows); + + free(v->ts); + free(v->br); + free(v->nr); + free(v); + free(lb); + free(params); + free(is_null); + free(no_null); + + return 0; +} + + +static int stmt_bind_case_003(TAOS_STMT *stmt, int tableNum, int rowsOfPerColum, int bingNum, int lenOfBinaryDef, int lenOfBinaryAct, int columnNum) { + sampleValue* v = (sampleValue *)calloc(1, sizeof(sampleValue)); + + int totalRowsPerTbl = rowsOfPerColum * bingNum; + + v->ts = (int64_t *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * tableNum)); + v->br = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef)); + v->nr = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef)); + + int *lb = (int *)malloc(MAX_ROWS_OF_PER_COLUMN * sizeof(int)); + + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * (size_t)(bingNum * columnNum * (tableNum+1) * rowsOfPerColum)); + char* is_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN); + char* no_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN); + + int64_t tts = 1591060628000; + + for (int i = 0; i < rowsOfPerColum; ++i) { + lb[i] = lenOfBinaryAct; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v->b[i] = (int8_t)(i % 2); + v->v1[i] = (int8_t)((i+1) % 2); + v->v2[i] = (int16_t)i; + v->v4[i] = (int32_t)(i+1); + v->v8[i] = (int64_t)(i+2); + v->f4[i] = (float)(i+3); + v->f8[i] = (double)(i+4); + char tbuf[MAX_BINARY_DEF_LEN]; + memset(tbuf, 0, MAX_BINARY_DEF_LEN); + sprintf(tbuf, "binary-%d", i%10); + memcpy(v->br + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct); + memset(tbuf, 0, MAX_BINARY_DEF_LEN); + sprintf(tbuf, "nchar-%d", i%10); + memcpy(v->nr + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct); + v->ts2[i] = tts + i; + } + + int i = 0; + for (int j = 0; j < bingNum * tableNum; j++) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v->ts[j*rowsOfPerColum]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = rowsOfPerColum; + + params[i+1].buffer_type = TSDB_DATA_TYPE_INT; + params[i+1].buffer_length = sizeof(int32_t); + params[i+1].buffer = v->v4; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = rowsOfPerColum; + + i+=columnNum; + } + + //int64_t tts = 1591060628000; + for (int i = 0; i < totalRowsPerTbl * tableNum; ++i) { + v->ts[i] = tts + i; + } + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? values(?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + + int id = 0; + for (int l = 0; l < bingNum; l++) { + for (int zz = 0; zz < tableNum; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + + for (int col=0; col < columnNum; ++col) { + code = taos_stmt_bind_single_param_batch(stmt, params + id, col); + if (code != 0){ + printf("failed to execute taos_stmt_bind_single_param_batch. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + id++; + } + + code = taos_stmt_add_batch(stmt); + if (code != 0) { + printf("failed to execute taos_stmt_add_batch. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + } + + code = taos_stmt_execute(stmt); + if (code != 0) { + printf("failed to execute taos_stmt_execute. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + } + + unsigned long long endtime = getCurrentTime(); + unsigned long long totalRows = (uint32_t)(totalRowsPerTbl * tableNum); + printf("insert total %d records, used %u seconds, avg:%u useconds per record\n", totalRows, (endtime-starttime)/1000000UL, (endtime-starttime)/totalRows); + + free(v->ts); + free(v->br); + free(v->nr); + free(v); + free(lb); + free(params); + free(is_null); + free(no_null); + + return 0; +} + +static int stmt_bind_case_004(TAOS_STMT *stmt, int tableNum, int rowsOfPerColum, int bingNum, int lenOfBinaryDef, int lenOfBinaryAct, int columnNum) { + sampleValue* v = (sampleValue *)calloc(1, sizeof(sampleValue)); + + int totalRowsPerTbl = rowsOfPerColum * bingNum; + + v->ts = (int64_t *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * tableNum * 2)); + v->br = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef)); + v->nr = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef)); + + int *lb = (int *)malloc(MAX_ROWS_OF_PER_COLUMN * sizeof(int)); + + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * (size_t)(bingNum * columnNum * 2 * (tableNum+1) * rowsOfPerColum)); + char* is_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN); + char* no_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN); + + int64_t tts = 1591060628000; + + for (int i = 0; i < rowsOfPerColum; ++i) { + lb[i] = lenOfBinaryAct; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v->b[i] = (int8_t)(i % 2); + v->v1[i] = (int8_t)((i+1) % 2); + v->v2[i] = (int16_t)i; + v->v4[i] = (int32_t)(i+1); + v->v8[i] = (int64_t)(i+2); + v->f4[i] = (float)(i+3); + v->f8[i] = (double)(i+4); + char tbuf[MAX_BINARY_DEF_LEN]; + memset(tbuf, 0, MAX_BINARY_DEF_LEN); + sprintf(tbuf, "binary-%d", i%10); + memcpy(v->br + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct); + memset(tbuf, 0, MAX_BINARY_DEF_LEN); + sprintf(tbuf, "nchar-%d", i%10); + memcpy(v->nr + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct); + v->ts2[i] = tts + i; + } + + int i = 0; + for (int j = 0; j < bingNum * tableNum * 2; j++) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v->ts[j*rowsOfPerColum]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = rowsOfPerColum; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v->b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = rowsOfPerColum; + + params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[i+2].buffer_length = sizeof(int8_t); + params[i+2].buffer = v->v1; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = rowsOfPerColum; + + params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[i+3].buffer_length = sizeof(int16_t); + params[i+3].buffer = v->v2; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = rowsOfPerColum; + + params[i+4].buffer_type = TSDB_DATA_TYPE_INT; + params[i+4].buffer_length = sizeof(int32_t); + params[i+4].buffer = v->v4; + params[i+4].length = NULL; + params[i+4].is_null = is_null; + params[i+4].num = rowsOfPerColum; + + params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[i+5].buffer_length = sizeof(int64_t); + params[i+5].buffer = v->v8; + params[i+5].length = NULL; + params[i+5].is_null = is_null; + params[i+5].num = rowsOfPerColum; + + params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+6].buffer_length = sizeof(float); + params[i+6].buffer = v->f4; + params[i+6].length = NULL; + params[i+6].is_null = is_null; + params[i+6].num = rowsOfPerColum; + + params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[i+7].buffer_length = sizeof(double); + params[i+7].buffer = v->f8; + params[i+7].length = NULL; + params[i+7].is_null = is_null; + params[i+7].num = rowsOfPerColum; + + params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+8].buffer_length = (uintptr_t)lenOfBinaryDef; + params[i+8].buffer = v->br; + params[i+8].length = lb; + params[i+8].is_null = is_null; + params[i+8].num = rowsOfPerColum; + + params[i+9].buffer_type = TSDB_DATA_TYPE_NCHAR; + params[i+9].buffer_length = (uintptr_t)lenOfBinaryDef; + params[i+9].buffer = v->nr; + params[i+9].length = lb; + params[i+9].is_null = is_null; + params[i+9].num = rowsOfPerColum; + + params[i+10].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+10].buffer_length = sizeof(int64_t); + params[i+10].buffer = v->ts2; + params[i+10].length = NULL; + params[i+10].is_null = is_null; + params[i+10].num = rowsOfPerColum; + + i+=columnNum; + } + + //int64_t tts = 1591060628000; + for (int i = 0; i < totalRowsPerTbl * tableNum * 2; ++i) { + v->ts[i] = tts + i; + } + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + + int id = 0; + for (int l = 0; l < bingNum; l++) { + for (int zz = 0; zz < tableNum; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + + for (int col=0; col < columnNum; ++col) { + code = taos_stmt_bind_single_param_batch(stmt, params + id, col); + if (code != 0){ + printf("failed to execute taos_stmt_bind_single_param_batch. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + id++; + } + + code = taos_stmt_add_batch(stmt); + if (code != 0) { + printf("failed to execute taos_stmt_add_batch. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + + // ===================================start==============================================// + for (int col=0; col < columnNum; ++col) { + code = taos_stmt_bind_single_param_batch(stmt, params + id, col); + if (code != 0){ + printf("failed to execute taos_stmt_bind_single_param_batch. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + id++; + } + + code = taos_stmt_add_batch(stmt); + if (code != 0) { + printf("failed to execute taos_stmt_add_batch. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + // ===================================end==============================================// + + } + + code = taos_stmt_execute(stmt); + if (code != 0) { + printf("failed to execute taos_stmt_execute. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + } + + unsigned long long endtime = getCurrentTime(); + unsigned long long totalRows = (uint32_t)(totalRowsPerTbl * tableNum); + printf("insert total %d records, used %u seconds, avg:%u useconds per record\n", totalRows, (endtime-starttime)/1000000UL, (endtime-starttime)/totalRows); + + free(v->ts); + free(v->br); + free(v->nr); + free(v); + free(lb); + free(params); + free(is_null); + free(no_null); + + return 0; +} + +static int stmt_bind_error_case_001(TAOS_STMT *stmt, int tableNum, int rowsOfPerColum, int bingNum, int lenOfBinaryDef, int lenOfBinaryAct, int columnNum) { + sampleValue* v = (sampleValue *)calloc(1, sizeof(sampleValue)); + + int totalRowsPerTbl = rowsOfPerColum * bingNum; + + v->ts = (int64_t *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * tableNum * 2)); + v->br = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef)); + v->nr = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef)); + + int *lb = (int *)malloc(MAX_ROWS_OF_PER_COLUMN * sizeof(int)); + + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * (size_t)(bingNum * columnNum * 2 * (tableNum+1) * rowsOfPerColum)); + char* is_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN); + char* no_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN); + + int64_t tts = 1591060628000; + + for (int i = 0; i < rowsOfPerColum; ++i) { + lb[i] = lenOfBinaryAct; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v->b[i] = (int8_t)(i % 2); + v->v1[i] = (int8_t)((i+1) % 2); + v->v2[i] = (int16_t)i; + v->v4[i] = (int32_t)(i+1); + v->v8[i] = (int64_t)(i+2); + v->f4[i] = (float)(i+3); + v->f8[i] = (double)(i+4); + char tbuf[MAX_BINARY_DEF_LEN]; + memset(tbuf, 0, MAX_BINARY_DEF_LEN); + sprintf(tbuf, "binary-%d", i%10); + memcpy(v->br + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct); + memset(tbuf, 0, MAX_BINARY_DEF_LEN); + sprintf(tbuf, "nchar-%d", i%10); + memcpy(v->nr + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct); + v->ts2[i] = tts + i; + } + + int i = 0; + for (int j = 0; j < bingNum * tableNum * 2; j++) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v->ts[j*rowsOfPerColum]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = rowsOfPerColum; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v->b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = rowsOfPerColum; + + params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[i+2].buffer_length = sizeof(int8_t); + params[i+2].buffer = v->v1; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = rowsOfPerColum; + + params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[i+3].buffer_length = sizeof(int16_t); + params[i+3].buffer = v->v2; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = rowsOfPerColum; + + params[i+4].buffer_type = TSDB_DATA_TYPE_INT; + params[i+4].buffer_length = sizeof(int32_t); + params[i+4].buffer = v->v4; + params[i+4].length = NULL; + params[i+4].is_null = is_null; + params[i+4].num = rowsOfPerColum; + + params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[i+5].buffer_length = sizeof(int64_t); + params[i+5].buffer = v->v8; + params[i+5].length = NULL; + params[i+5].is_null = is_null; + params[i+5].num = rowsOfPerColum; + + params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+6].buffer_length = sizeof(float); + params[i+6].buffer = v->f4; + params[i+6].length = NULL; + params[i+6].is_null = is_null; + params[i+6].num = rowsOfPerColum; + + params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[i+7].buffer_length = sizeof(double); + params[i+7].buffer = v->f8; + params[i+7].length = NULL; + params[i+7].is_null = is_null; + params[i+7].num = rowsOfPerColum; + + params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+8].buffer_length = (uintptr_t)lenOfBinaryDef; + params[i+8].buffer = v->br; + params[i+8].length = lb; + params[i+8].is_null = is_null; + params[i+8].num = rowsOfPerColum; + + params[i+9].buffer_type = TSDB_DATA_TYPE_NCHAR; + params[i+9].buffer_length = (uintptr_t)lenOfBinaryDef; + params[i+9].buffer = v->nr; + params[i+9].length = lb; + params[i+9].is_null = is_null; + params[i+9].num = rowsOfPerColum; + + params[i+10].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+10].buffer_length = sizeof(int64_t); + params[i+10].buffer = v->ts2; + params[i+10].length = NULL; + params[i+10].is_null = is_null; + params[i+10].num = rowsOfPerColum; + + i+=columnNum; + } + + //int64_t tts = 1591060628000; + for (int i = 0; i < totalRowsPerTbl * tableNum * 2; ++i) { + v->ts[i] = tts + i; + } + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + + int id = 0; + for (int l = 0; l < bingNum; l++) { + for (int zz = 0; zz < tableNum; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + + for (int col=0; col < columnNum; ++col) { + code = taos_stmt_bind_single_param_batch(stmt, params + id, col); + if (code != 0){ + printf("failed to execute taos_stmt_bind_single_param_batch. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + id++; + } + + //------- add one batch ------// + for (int col=0; col < columnNum; ++col) { + code = taos_stmt_bind_single_param_batch(stmt, params + id, col); + if (code != 0){ + printf("failed to execute taos_stmt_bind_single_param_batch. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + id++; + } + //----------------------------// + + code = taos_stmt_add_batch(stmt); + if (code != 0) { + printf("failed to execute taos_stmt_add_batch. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + } + + code = taos_stmt_execute(stmt); + if (code != 0) { + printf("failed to execute taos_stmt_execute. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + } + + unsigned long long endtime = getCurrentTime(); + unsigned long long totalRows = (uint32_t)(totalRowsPerTbl * tableNum); + printf("insert total %d records, used %u seconds, avg:%u useconds per record\n", totalRows, (endtime-starttime)/1000000UL, (endtime-starttime)/totalRows); + + free(v->ts); + free(v->br); + free(v->nr); + free(v); + free(lb); + free(params); + free(is_null); + free(no_null); + + return 0; +} + + +static int stmt_bind_error_case_002(TAOS_STMT *stmt, int tableNum, int rowsOfPerColum, int bingNum, int lenOfBinaryDef, int lenOfBinaryAct, int columnNum) { + sampleValue* v = (sampleValue *)calloc(1, sizeof(sampleValue)); + + int totalRowsPerTbl = rowsOfPerColum * bingNum; + + v->ts = (int64_t *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * tableNum * 2)); + v->br = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef)); + v->nr = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef)); + + int *lb = (int *)malloc(MAX_ROWS_OF_PER_COLUMN * sizeof(int)); + + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * (size_t)(bingNum * columnNum * 2 * (tableNum+1) * rowsOfPerColum)); + char* is_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN); + char* no_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN); + + int64_t tts = 1591060628000; + + for (int i = 0; i < rowsOfPerColum; ++i) { + lb[i] = lenOfBinaryAct; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v->b[i] = (int8_t)(i % 2); + v->v1[i] = (int8_t)((i+1) % 2); + v->v2[i] = (int16_t)i; + v->v4[i] = (int32_t)(i+1); + v->v8[i] = (int64_t)(i+2); + v->f4[i] = (float)(i+3); + v->f8[i] = (double)(i+4); + char tbuf[MAX_BINARY_DEF_LEN]; + memset(tbuf, 0, MAX_BINARY_DEF_LEN); + sprintf(tbuf, "binary-%d", i%10); + memcpy(v->br + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct); + memset(tbuf, 0, MAX_BINARY_DEF_LEN); + sprintf(tbuf, "nchar-%d", i%10); + memcpy(v->nr + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct); + v->ts2[i] = tts + i; + } + + int i = 0; + for (int j = 0; j < bingNum * tableNum * 2; j++) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v->ts[j*rowsOfPerColum]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = rowsOfPerColum; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v->b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = rowsOfPerColum; + + params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[i+2].buffer_length = sizeof(int8_t); + params[i+2].buffer = v->v1; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = rowsOfPerColum; + + params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[i+3].buffer_length = sizeof(int16_t); + params[i+3].buffer = v->v2; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = rowsOfPerColum; + + params[i+4].buffer_type = TSDB_DATA_TYPE_INT; + params[i+4].buffer_length = sizeof(int32_t); + params[i+4].buffer = v->v4; + params[i+4].length = NULL; + params[i+4].is_null = is_null; + params[i+4].num = rowsOfPerColum; + + params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[i+5].buffer_length = sizeof(int64_t); + params[i+5].buffer = v->v8; + params[i+5].length = NULL; + params[i+5].is_null = is_null; + params[i+5].num = rowsOfPerColum; + + params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+6].buffer_length = sizeof(float); + params[i+6].buffer = v->f4; + params[i+6].length = NULL; + params[i+6].is_null = is_null; + params[i+6].num = rowsOfPerColum; + + params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[i+7].buffer_length = sizeof(double); + params[i+7].buffer = v->f8; + params[i+7].length = NULL; + params[i+7].is_null = is_null; + params[i+7].num = rowsOfPerColum; + + params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+8].buffer_length = (uintptr_t)lenOfBinaryDef; + params[i+8].buffer = v->br; + params[i+8].length = lb; + params[i+8].is_null = is_null; + params[i+8].num = rowsOfPerColum; + + params[i+9].buffer_type = TSDB_DATA_TYPE_NCHAR; + params[i+9].buffer_length = (uintptr_t)lenOfBinaryDef; + params[i+9].buffer = v->nr; + params[i+9].length = lb; + params[i+9].is_null = is_null; + params[i+9].num = rowsOfPerColum; + + params[i+10].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+10].buffer_length = sizeof(int64_t); + params[i+10].buffer = v->ts2; + params[i+10].length = NULL; + params[i+10].is_null = is_null; + params[i+10].num = rowsOfPerColum; + + i+=columnNum; + } + + //int64_t tts = 1591060628000; + for (int i = 0; i < totalRowsPerTbl * tableNum * 2; ++i) { + v->ts[i] = tts + i; + } + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + + int id = 0; + for (int l = 0; l < bingNum; l++) { + for (int zz = 0; zz < tableNum; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + + for (int col=0; col < columnNum; ++col) { + code = taos_stmt_bind_single_param_batch(stmt, params + id, col); + if (code != 0){ + printf("failed to execute taos_stmt_bind_single_param_batch. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + id++; + } + + //code = taos_stmt_add_batch(stmt); + //if (code != 0) { + // printf("failed to execute taos_stmt_add_batch. code:0x%x[%s]\n", code, tstrerror(code)); + // return -1; + //} + } + + code = taos_stmt_execute(stmt); + if (code != 0) { + printf("failed to execute taos_stmt_execute. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + } + + unsigned long long endtime = getCurrentTime(); + unsigned long long totalRows = (uint32_t)(totalRowsPerTbl * tableNum); + printf("insert total %d records, used %u seconds, avg:%u useconds per record\n", totalRows, (endtime-starttime)/1000000UL, (endtime-starttime)/totalRows); + + free(v->ts); + free(v->br); + free(v->nr); + free(v); + free(lb); + free(params); + free(is_null); + free(no_null); + + return 0; +} + +static int stmt_bind_error_case_003(TAOS_STMT *stmt, int tableNum, int rowsOfPerColum, int bingNum, int lenOfBinaryDef, int lenOfBinaryAct, int columnNum) { + sampleValue* v = (sampleValue *)calloc(1, sizeof(sampleValue)); + + int totalRowsPerTbl = rowsOfPerColum * bingNum; + + v->ts = (int64_t *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * tableNum * 2)); + v->br = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef)); + v->nr = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef)); + + int *lb = (int *)malloc(MAX_ROWS_OF_PER_COLUMN * sizeof(int)); + + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * (size_t)(bingNum * columnNum * 2 * (tableNum+1) * rowsOfPerColum)); + char* is_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN); + char* no_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN); + + int64_t tts = 1591060628000; + + for (int i = 0; i < rowsOfPerColum; ++i) { + lb[i] = lenOfBinaryAct; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v->b[i] = (int8_t)(i % 2); + v->v1[i] = (int8_t)((i+1) % 2); + v->v2[i] = (int16_t)i; + v->v4[i] = (int32_t)(i+1); + v->v8[i] = (int64_t)(i+2); + v->f4[i] = (float)(i+3); + v->f8[i] = (double)(i+4); + char tbuf[MAX_BINARY_DEF_LEN]; + memset(tbuf, 0, MAX_BINARY_DEF_LEN); + sprintf(tbuf, "binary-%d", i%10); + memcpy(v->br + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct); + memset(tbuf, 0, MAX_BINARY_DEF_LEN); + sprintf(tbuf, "nchar-%d", i%10); + memcpy(v->nr + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct); + v->ts2[i] = tts + i; + } + + int i = 0; + for (int j = 0; j < bingNum * tableNum * 2; j++) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v->ts[j*rowsOfPerColum]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = rowsOfPerColum; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v->b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = rowsOfPerColum; + + params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[i+2].buffer_length = sizeof(int8_t); + params[i+2].buffer = v->v1; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = rowsOfPerColum; + + params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[i+3].buffer_length = sizeof(int16_t); + params[i+3].buffer = v->v2; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = rowsOfPerColum; + + params[i+4].buffer_type = TSDB_DATA_TYPE_INT; + params[i+4].buffer_length = sizeof(int32_t); + params[i+4].buffer = v->v4; + params[i+4].length = NULL; + params[i+4].is_null = is_null; + params[i+4].num = rowsOfPerColum; + + params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[i+5].buffer_length = sizeof(int64_t); + params[i+5].buffer = v->v8; + params[i+5].length = NULL; + params[i+5].is_null = is_null; + params[i+5].num = rowsOfPerColum; + + params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+6].buffer_length = sizeof(float); + params[i+6].buffer = v->f4; + params[i+6].length = NULL; + params[i+6].is_null = is_null; + params[i+6].num = rowsOfPerColum; + + params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[i+7].buffer_length = sizeof(double); + params[i+7].buffer = v->f8; + params[i+7].length = NULL; + params[i+7].is_null = is_null; + params[i+7].num = rowsOfPerColum; + + params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+8].buffer_length = (uintptr_t)lenOfBinaryDef; + params[i+8].buffer = v->br; + params[i+8].length = lb; + params[i+8].is_null = is_null; + params[i+8].num = rowsOfPerColum; + + params[i+9].buffer_type = TSDB_DATA_TYPE_NCHAR; + params[i+9].buffer_length = (uintptr_t)lenOfBinaryDef; + params[i+9].buffer = v->nr; + params[i+9].length = lb; + params[i+9].is_null = is_null; + params[i+9].num = rowsOfPerColum; + + params[i+10].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+10].buffer_length = sizeof(int64_t); + params[i+10].buffer = v->ts2; + params[i+10].length = NULL; + params[i+10].is_null = is_null; + params[i+10].num = rowsOfPerColum; + + i+=columnNum; + } + + //int64_t tts = 1591060628000; + for (int i = 0; i < totalRowsPerTbl * tableNum * 2; ++i) { + v->ts[i] = tts + i; + } + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + + int id = 0; + for (int l = 0; l < bingNum; l++) { + for (int zz = 0; zz < tableNum; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + + //==================add one=================// + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + //==========================================// + + for (int col=0; col < columnNum; ++col) { + + //==================add one=================// + if (1==col) { + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + } + //==========================================// + + code = taos_stmt_bind_single_param_batch(stmt, params + id, col); + if (code != 0){ + printf("failed to execute taos_stmt_bind_single_param_batch. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + id++; + } + + code = taos_stmt_add_batch(stmt); + if (code != 0) { + printf("failed to execute taos_stmt_add_batch. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + } + + code = taos_stmt_execute(stmt); + if (code != 0) { + printf("failed to execute taos_stmt_execute. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + } + + unsigned long long endtime = getCurrentTime(); + unsigned long long totalRows = (uint32_t)(totalRowsPerTbl * tableNum); + printf("insert total %d records, used %u seconds, avg:%u useconds per record\n", totalRows, (endtime-starttime)/1000000UL, (endtime-starttime)/totalRows); + + free(v->ts); + free(v->br); + free(v->nr); + free(v); + free(lb); + free(params); + free(is_null); + free(no_null); + + return 0; +} + +static void checkResult(TAOS *taos, char *tname, int printr, int expected) { + char sql[255] = "SELECT * FROM "; + TAOS_RES *result; + + strcat(sql, tname); + + result = taos_query(taos, sql); + int code = taos_errno(result); + if (code != 0) { + printf("failed to query table: %s, reason:%s\n", tname, taos_errstr(result)); + taos_free_result(result); + return; + } + + TAOS_ROW row; + int rows = 0; + int num_fields = taos_num_fields(result); + TAOS_FIELD *fields = taos_fetch_fields(result); + char temp[256]; + + // fetch the records row by row + while ((row = taos_fetch_row(result))) { + rows++; + if (printr) { + memset(temp, 0, sizeof(temp)); + taos_print_row(temp, row, fields, num_fields); + printf("[%s]\n", temp); + } + } + + if (rows == expected) { + printf("%d rows are fetched as expectation from %s\n", rows, tname); + } else { + printf("!!!expect %d rows, but %d rows are fetched from %s\n", expected, rows, tname); + return; + } + + taos_free_result(result); + +} + + +static void prepareV(TAOS *taos, int schemaCase, int tableNum, int lenOfBinaryDef) { + TAOS_RES *result; + int code; + + result = taos_query(taos, "drop database if exists demo"); + taos_free_result(result); + + result = taos_query(taos, "create database demo"); + code = taos_errno(result); + if (code != 0) { + printf("failed to create database, reason:%s\n", taos_errstr(result)); + taos_free_result(result); + return; + } + taos_free_result(result); + + result = taos_query(taos, "use demo"); + taos_free_result(result); + + // create table + for (int i = 0 ; i < tableNum; i++) { + char buf[1024]; + if (schemaCase) { + sprintf(buf, "create table m%d (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, br binary(%d), nr nchar(%d), ts2 timestamp)", i, lenOfBinaryDef, lenOfBinaryDef) ; + } else { + sprintf(buf, "create table m%d (ts timestamp, b int)", i) ; + } + + result = taos_query(taos, buf); + code = taos_errno(result); + if (code != 0) { + printf("failed to create table, reason:%s\n", taos_errstr(result)); + taos_free_result(result); + return; + } + taos_free_result(result); + } + +} + +static void prepareV_long(TAOS *taos, int schemaCase, int tableNum, int lenOfBinaryDef) { + TAOS_RES *result; + int code; + + result = taos_query(taos, "drop database if exists demol"); + taos_free_result(result); + + result = taos_query(taos, "create database demol"); + code = taos_errno(result); + if (code != 0) { + printf("failed to create database, reason:%s\n", taos_errstr(result)); + taos_free_result(result); + return; + } + taos_free_result(result); + + result = taos_query(taos, "use demol"); + taos_free_result(result); + + // create table + for (int i = 0 ; i < tableNum; i++) { + char buf[1024]; + if (schemaCase) { + sprintf(buf, "create table m%d (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, br binary(%d), nr nchar(%d), ts2 timestamp)", i, lenOfBinaryDef, lenOfBinaryDef) ; + } else { + sprintf(buf, "create table m%d (ts timestamp, b int)", i) ; + } + + result = taos_query(taos, buf); + code = taos_errno(result); + if (code != 0) { + printf("failed to create table, reason:%s\n", taos_errstr(result)); + taos_free_result(result); + return; + } + taos_free_result(result); + } + +} + + +static void prepareVcolumn_autoCreateTbl(TAOS *taos, int schemaCase, int tableNum, int lenOfBinaryDef, char* dbName) { + TAOS_RES *result; + int code; + char sqlstr[1024] = {0}; + sprintf(sqlstr, "drop database if exists %s;", dbName); + result = taos_query(taos, sqlstr); + taos_free_result(result); + + sprintf(sqlstr, "create database %s;", dbName); + result = taos_query(taos, sqlstr); + code = taos_errno(result); + if (code != 0) { + printf("failed to create database, reason:%s\n", taos_errstr(result)); + taos_free_result(result); + return; + } + taos_free_result(result); + + sprintf(sqlstr, "use %s;", dbName); + result = taos_query(taos, sqlstr); + taos_free_result(result); + + // create table + char buf[1024] = {0}; + //if (bigsize) { + sprintf(buf, "create stable stb1 (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, br binary(%d), nr nchar(%d), ts2 timestamp)" + " tags(id1 int, id2 bool, id3 tinyint, id4 smallint, id5 bigint, id6 float, id7 double, id8 binary(%d), id9 nchar(%d))", lenOfBinaryDef, lenOfBinaryDef, lenOfBinaryDef, lenOfBinaryDef) ; + //} else { + // sprintf(buf, "create stable stb1 (ts timestamp, b int) tags(id1 int, id2 bool, id3 tinyint, id4 smallint, id5 bigint, id6 float, id7 double, id8 binary(40), id9 nchar(40))") ; + //} + + result = taos_query(taos, buf); + code = taos_errno(result); + if (code != 0) { + printf("failed to create table, reason:%s\n", taos_errstr(result)); + taos_free_result(result); + return; + } + taos_free_result(result); +} + + +static void prepareVcolumn(TAOS *taos, int schemaCase, int tableNum, int lenOfBinaryDef, char* dbName) { + TAOS_RES *result; + int code; + char sqlstr[1024] = {0}; + sprintf(sqlstr, "drop database if exists %s;", dbName); + result = taos_query(taos, sqlstr); + taos_free_result(result); + + sprintf(sqlstr, "create database %s;", dbName); + result = taos_query(taos, sqlstr); + code = taos_errno(result); + if (code != 0) { + printf("failed to create database, reason:%s\n", taos_errstr(result)); + taos_free_result(result); + return; + } + taos_free_result(result); + + sprintf(sqlstr, "use %s;", dbName); + result = taos_query(taos, sqlstr); + taos_free_result(result); + + // create table + for (int i = 0 ; i < tableNum; i++) { + char buf[1024]; + if (schemaCase) { + sprintf(buf, "create table m%d (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, br binary(%d), nr nchar(%d), ts2 timestamp)", i, lenOfBinaryDef, lenOfBinaryDef) ; + } else { + sprintf(buf, "create table m%d (ts timestamp, b int)", i) ; + } + + result = taos_query(taos, buf); + code = taos_errno(result); + if (code != 0) { + printf("failed to create table, reason:%s\n", taos_errstr(result)); + taos_free_result(result); + return; + } + taos_free_result(result); + } + +} + +//void runcase(TAOS *taos, int idx) { +static void runCase(TAOS *taos) { + TAOS_STMT *stmt = NULL; + + int tableNum; + int lenOfBinaryDef; + int rowsOfPerColum; + int bingNum; + int lenOfBinaryAct; + int columnNum; + + int totalRowsPerTbl; + +//=======================================================================// +//=============================== single table ==========================// +//========== case 1: ======================// +#if 1 +{ + stmt = taos_stmt_init(taos); + + tableNum = 1; + rowsOfPerColum = 1; + bingNum = 1; + lenOfBinaryDef = 40; + lenOfBinaryAct = 16; + columnNum = 11; + + prepareV(taos, 1, tableNum, lenOfBinaryDef); + stmt_bind_case_001(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 1 check result end\n\n"); +} +#endif + + //========== case 2: ======================// +#if 1 +{ + stmt = taos_stmt_init(taos); + + tableNum = 1; + rowsOfPerColum = 5; + bingNum = 1; + lenOfBinaryDef = 1000; + lenOfBinaryAct = 33; + columnNum = 11; + + prepareV(taos, 1, tableNum, lenOfBinaryDef); + stmt_bind_case_001(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + //checkResult(taos, "m1", 0, totalRowsPerTbl); + //checkResult(taos, "m2", 0, totalRowsPerTbl); + //checkResult(taos, "m3", 0, totalRowsPerTbl); + //checkResult(taos, "m4", 0, totalRowsPerTbl); + //checkResult(taos, "m5", 0, totalRowsPerTbl); + //checkResult(taos, "m6", 0, totalRowsPerTbl); + //checkResult(taos, "m7", 0, totalRowsPerTbl); + //checkResult(taos, "m8", 0, totalRowsPerTbl); + //checkResult(taos, "m9", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 2 check result end\n\n"); +} +#endif + + //========== case 3: ======================// +#if 1 + { + stmt = taos_stmt_init(taos); + + tableNum = 1; + rowsOfPerColum = 1; + bingNum = 5; + lenOfBinaryDef = 1000; + lenOfBinaryAct = 33; + columnNum = 11; + + prepareV(taos, 1, tableNum, lenOfBinaryDef); + stmt_bind_case_001(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + //checkResult(taos, "m1", 0, totalRowsPerTbl); + //checkResult(taos, "m2", 0, totalRowsPerTbl); + //checkResult(taos, "m3", 0, totalRowsPerTbl); + //checkResult(taos, "m4", 0, totalRowsPerTbl); + //checkResult(taos, "m5", 0, totalRowsPerTbl); + //checkResult(taos, "m6", 0, totalRowsPerTbl); + //checkResult(taos, "m7", 0, totalRowsPerTbl); + //checkResult(taos, "m8", 0, totalRowsPerTbl); + //checkResult(taos, "m9", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 3 check result end\n\n"); + } +#endif + + //========== case 4: ======================// +#if 1 + { + stmt = taos_stmt_init(taos); + + tableNum = 1; + rowsOfPerColum = 5; + bingNum = 5; + lenOfBinaryDef = 1000; + lenOfBinaryAct = 33; + columnNum = 11; + + prepareV(taos, 1, tableNum, lenOfBinaryDef); + stmt_bind_case_001(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + //checkResult(taos, "m1", 0, totalRowsPerTbl); + //checkResult(taos, "m2", 0, totalRowsPerTbl); + //checkResult(taos, "m3", 0, totalRowsPerTbl); + //checkResult(taos, "m4", 0, totalRowsPerTbl); + //checkResult(taos, "m5", 0, totalRowsPerTbl); + //checkResult(taos, "m6", 0, totalRowsPerTbl); + //checkResult(taos, "m7", 0, totalRowsPerTbl); + //checkResult(taos, "m8", 0, totalRowsPerTbl); + //checkResult(taos, "m9", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 4 check result end\n\n"); + } +#endif + +//=======================================================================// +//=============================== multi tables ==========================// + //========== case 5: ======================// +#if 1 + { + stmt = taos_stmt_init(taos); + + tableNum = 5; + rowsOfPerColum = 1; + bingNum = 1; + lenOfBinaryDef = 40; + lenOfBinaryAct = 16; + columnNum = 11; + + prepareV(taos, 1, tableNum, lenOfBinaryDef); + stmt_bind_case_001(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + checkResult(taos, "m1", 0, totalRowsPerTbl); + checkResult(taos, "m2", 0, totalRowsPerTbl); + checkResult(taos, "m3", 0, totalRowsPerTbl); + checkResult(taos, "m4", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 5 check result end\n\n"); + } +#endif + + //========== case 6: ======================// +#if 1 + { + stmt = taos_stmt_init(taos); + + tableNum = 5; + rowsOfPerColum = 5; + bingNum = 1; + lenOfBinaryDef = 1000; + lenOfBinaryAct = 33; + columnNum = 11; + + prepareV(taos, 1, tableNum, lenOfBinaryDef); + stmt_bind_case_001(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + checkResult(taos, "m1", 0, totalRowsPerTbl); + checkResult(taos, "m2", 0, totalRowsPerTbl); + checkResult(taos, "m3", 0, totalRowsPerTbl); + checkResult(taos, "m4", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 6 check result end\n\n"); + } +#endif + + //========== case 7: ======================// +#if 1 + { + stmt = taos_stmt_init(taos); + + tableNum = 5; + rowsOfPerColum = 1; + bingNum = 5; + lenOfBinaryDef = 1000; + lenOfBinaryAct = 33; + columnNum = 11; + + prepareV(taos, 1, tableNum, lenOfBinaryDef); + stmt_bind_case_001(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + checkResult(taos, "m1", 0, totalRowsPerTbl); + checkResult(taos, "m2", 0, totalRowsPerTbl); + checkResult(taos, "m3", 0, totalRowsPerTbl); + checkResult(taos, "m4", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 7 check result end\n\n"); + } +#endif + + //========== case 8: ======================// +#if 1 +{ + stmt = taos_stmt_init(taos); + + tableNum = 5; + rowsOfPerColum = 5; + bingNum = 5; + lenOfBinaryDef = 1000; + lenOfBinaryAct = 33; + columnNum = 11; + + prepareV(taos, 1, tableNum, lenOfBinaryDef); + stmt_bind_case_001(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + checkResult(taos, "m1", 0, totalRowsPerTbl); + checkResult(taos, "m2", 0, totalRowsPerTbl); + checkResult(taos, "m3", 0, totalRowsPerTbl); + checkResult(taos, "m4", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 8 check result end\n\n"); +} +#endif + + //=======================================================================// + //=============================== multi-rows to single table ==========================// + //========== case 9: ======================// +#if 1 + { + stmt = taos_stmt_init(taos); + + tableNum = 1; + rowsOfPerColum = 23740; + bingNum = 1; + lenOfBinaryDef = 40; + lenOfBinaryAct = 16; + columnNum = 11; + + prepareV(taos, 1, tableNum, lenOfBinaryDef); + stmt_bind_case_001(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 9 check result end\n\n"); + } +#endif + + //========== case 10: ======================// +#if 1 + { + printf("====case 10 error test start\n"); + stmt = taos_stmt_init(taos); + + tableNum = 1; + rowsOfPerColum = 23741; // WAL size exceeds limit + bingNum = 1; + lenOfBinaryDef = 40; + lenOfBinaryAct = 16; + columnNum = 11; + + prepareV(taos, 1, tableNum, lenOfBinaryDef); + stmt_bind_case_001(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("====case 10 check result end\n\n"); + } +#endif + + + //========== case 11: ======================// +#if 1 + { + stmt = taos_stmt_init(taos); + + tableNum = 1; + rowsOfPerColum = 32767; + bingNum = 1; + lenOfBinaryDef = 40; + lenOfBinaryAct = 16; + columnNum = 2; + + prepareV(taos, 0, tableNum, lenOfBinaryDef); + stmt_bind_case_003(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 11 check result end\n\n"); + } +#endif + + //========== case 12: ======================// +#if 1 + { + printf("====case 12 error test start\n"); + stmt = taos_stmt_init(taos); + + tableNum = 1; + rowsOfPerColum = 32768; // invalid parameter + bingNum = 1; + lenOfBinaryDef = 40; + lenOfBinaryAct = 16; + columnNum = 2; + + prepareV(taos, 0, tableNum, lenOfBinaryDef); + stmt_bind_case_003(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("====case 12 check result end\n\n"); + } +#endif + + //=======================================================================// + //=============================== multi tables, multi bind one same table ==========================// + //========== case 13: ======================// +#if 1 + { + stmt = taos_stmt_init(taos); + + tableNum = 5; + rowsOfPerColum = 1; + bingNum = 5; + lenOfBinaryDef = 40; + lenOfBinaryAct = 16; + columnNum = 11; + + prepareV(taos, 1, tableNum, lenOfBinaryDef); + stmt_bind_case_002(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + checkResult(taos, "m1", 0, totalRowsPerTbl); + checkResult(taos, "m2", 0, totalRowsPerTbl); + checkResult(taos, "m3", 0, totalRowsPerTbl); + checkResult(taos, "m4", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 13 check result end\n\n"); + } +#endif + + //========== case 14: ======================// +#if 1 + { + stmt = taos_stmt_init(taos); + + tableNum = 5; + rowsOfPerColum = 5; + bingNum = 5; + lenOfBinaryDef = 1000; + lenOfBinaryAct = 33; + columnNum = 11; + + prepareV(taos, 1, tableNum, lenOfBinaryDef); + stmt_bind_case_002(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + checkResult(taos, "m1", 0, totalRowsPerTbl); + checkResult(taos, "m2", 0, totalRowsPerTbl); + checkResult(taos, "m3", 0, totalRowsPerTbl); + checkResult(taos, "m4", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 14 check result end\n\n"); + } +#endif + + + //========== case 15: ======================// +#if 1 + { + stmt = taos_stmt_init(taos); + + tableNum = 1000; + rowsOfPerColum = 10; + bingNum = 5; + lenOfBinaryDef = 1000; + lenOfBinaryAct = 8; + columnNum = 11; + + prepareV(taos, 1, tableNum, lenOfBinaryDef); + stmt_bind_case_001(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + checkResult(taos, "m111", 0, totalRowsPerTbl); + checkResult(taos, "m222", 0, totalRowsPerTbl); + checkResult(taos, "m333", 0, totalRowsPerTbl); + checkResult(taos, "m999", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 15 check result end\n\n"); + } +#endif + + //========== case 16: ======================// +#if 1 + { + printf("====case 16 error test start\n"); + stmt = taos_stmt_init(taos); + + tableNum = 10; + rowsOfPerColum = 10; + bingNum = 1; + lenOfBinaryDef = 100; + lenOfBinaryAct = 8; + columnNum = 11; + + prepareV(taos, 1, tableNum, lenOfBinaryDef); + stmt_bind_error_case_001(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + //checkResult(taos, "m11", 0, totalRowsPerTbl); + //checkResult(taos, "m22", 0, totalRowsPerTbl); + //checkResult(taos, "m33", 0, totalRowsPerTbl); + //checkResult(taos, "m99", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("====case 16 check result end\n\n"); + } +#endif + + //========== case 17: ======================// +#if 1 + { + //printf("case 17 test start\n"); + stmt = taos_stmt_init(taos); + + tableNum = 10; + rowsOfPerColum = 10; + bingNum = 1; + lenOfBinaryDef = 100; + lenOfBinaryAct = 8; + columnNum = 11; + + prepareV(taos, 1, tableNum, lenOfBinaryDef); + stmt_bind_case_004(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum * 2; + checkResult(taos, "m0", 0, totalRowsPerTbl); + //checkResult(taos, "m11", 0, totalRowsPerTbl); + //checkResult(taos, "m22", 0, totalRowsPerTbl); + //checkResult(taos, "m33", 0, totalRowsPerTbl); + //checkResult(taos, "m99", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 17 check result end\n\n"); + } +#endif + + //========== case 18: ======================// +#if 1 + { + printf("====case 18 error test start\n"); + stmt = taos_stmt_init(taos); + + tableNum = 1; + rowsOfPerColum = 10; + bingNum = 1; + lenOfBinaryDef = 100; + lenOfBinaryAct = 8; + columnNum = 11; + + prepareV(taos, 1, tableNum, lenOfBinaryDef); + stmt_bind_error_case_002(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + //checkResult(taos, "m11", 0, totalRowsPerTbl); + //checkResult(taos, "m22", 0, totalRowsPerTbl); + //checkResult(taos, "m33", 0, totalRowsPerTbl); + //checkResult(taos, "m99", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("====case 18 check result end\n\n"); + } +#endif + + //========== case 19: ======================// +#if 1 + { + printf("====case 19 error test start\n"); + stmt = taos_stmt_init(taos); + + tableNum = 1; + rowsOfPerColum = 10; + bingNum = 1; + lenOfBinaryDef = 100; + lenOfBinaryAct = 8; + columnNum = 11; + + prepareV(taos, 1, tableNum, lenOfBinaryDef); + stmt_bind_error_case_003(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + //checkResult(taos, "m11", 0, totalRowsPerTbl); + //checkResult(taos, "m22", 0, totalRowsPerTbl); + //checkResult(taos, "m33", 0, totalRowsPerTbl); + //checkResult(taos, "m99", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("====case 19 check result end\n\n"); + } +#endif + + return ; + +} + + +static int stmt_bind_case_001_long(TAOS_STMT *stmt, int tableNum, int rowsOfPerColum, int bingNum, int lenOfBinaryDef, int lenOfBinaryAct, int columnNum, int64_t* startTs) { + sampleValue* v = (sampleValue *)calloc(1, sizeof(sampleValue)); + + int totalRowsPerTbl = rowsOfPerColum * bingNum; + + v->ts = (int64_t *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * tableNum)); + v->br = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef)); + v->nr = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef)); + + int *lb = (int *)malloc(MAX_ROWS_OF_PER_COLUMN * sizeof(int)); + + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * (size_t)(bingNum * columnNum * (tableNum+1) * rowsOfPerColum)); + char* is_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN); + char* no_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN); + + int64_t tts = *startTs; + + for (int i = 0; i < rowsOfPerColum; ++i) { + lb[i] = lenOfBinaryAct; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v->b[i] = (int8_t)(i % 2); + v->v1[i] = (int8_t)((i+1) % 2); + v->v2[i] = (int16_t)i; + v->v4[i] = (int32_t)(i+1); + v->v8[i] = (int64_t)(i+2); + v->f4[i] = (float)(i+3); + v->f8[i] = (double)(i+4); + char tbuf[MAX_BINARY_DEF_LEN]; + memset(tbuf, 0, MAX_BINARY_DEF_LEN); + sprintf(tbuf, "binary-%d", i%10); + memcpy(v->br + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct); + memset(tbuf, 0, MAX_BINARY_DEF_LEN); + sprintf(tbuf, "nchar-%d", i%10); + memcpy(v->nr + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct); + v->ts2[i] = tts + i; + } + + int i = 0; + for (int j = 0; j < bingNum * tableNum; j++) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v->ts[j*rowsOfPerColum]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = rowsOfPerColum; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v->b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = rowsOfPerColum; + + params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[i+2].buffer_length = sizeof(int8_t); + params[i+2].buffer = v->v1; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = rowsOfPerColum; + + params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[i+3].buffer_length = sizeof(int16_t); + params[i+3].buffer = v->v2; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = rowsOfPerColum; + + params[i+4].buffer_type = TSDB_DATA_TYPE_INT; + params[i+4].buffer_length = sizeof(int32_t); + params[i+4].buffer = v->v4; + params[i+4].length = NULL; + params[i+4].is_null = is_null; + params[i+4].num = rowsOfPerColum; + + params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[i+5].buffer_length = sizeof(int64_t); + params[i+5].buffer = v->v8; + params[i+5].length = NULL; + params[i+5].is_null = is_null; + params[i+5].num = rowsOfPerColum; + + params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+6].buffer_length = sizeof(float); + params[i+6].buffer = v->f4; + params[i+6].length = NULL; + params[i+6].is_null = is_null; + params[i+6].num = rowsOfPerColum; + + params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[i+7].buffer_length = sizeof(double); + params[i+7].buffer = v->f8; + params[i+7].length = NULL; + params[i+7].is_null = is_null; + params[i+7].num = rowsOfPerColum; + + params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+8].buffer_length = (uintptr_t)lenOfBinaryDef; + params[i+8].buffer = v->br; + params[i+8].length = lb; + params[i+8].is_null = is_null; + params[i+8].num = rowsOfPerColum; + + params[i+9].buffer_type = TSDB_DATA_TYPE_NCHAR; + params[i+9].buffer_length = (uintptr_t)lenOfBinaryDef; + params[i+9].buffer = v->nr; + params[i+9].length = lb; + params[i+9].is_null = is_null; + params[i+9].num = rowsOfPerColum; + + params[i+10].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+10].buffer_length = sizeof(int64_t); + params[i+10].buffer = v->ts2; + params[i+10].length = NULL; + params[i+10].is_null = is_null; + params[i+10].num = rowsOfPerColum; + + i+=columnNum; + } + + //int64_t tts = 1591060628000; + for (int i = 0; i < totalRowsPerTbl * tableNum; ++i) { + v->ts[i] = tts + i; + } + + *startTs = tts + totalRowsPerTbl * tableNum; // return to next + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + + int id = 0; + for (int l = 0; l < bingNum; l++) { + for (int zz = 0; zz < tableNum; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + + for (int col=0; col < columnNum; ++col) { + code = taos_stmt_bind_single_param_batch(stmt, params + id, col); + if (code != 0){ + printf("failed to execute taos_stmt_bind_single_param_batch. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + id++; + } + + code = taos_stmt_add_batch(stmt); + if (code != 0) { + printf("failed to execute taos_stmt_add_batch. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + } + + code = taos_stmt_execute(stmt); + if (code != 0) { + printf("failed to execute taos_stmt_execute. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + } + + unsigned long long endtime = getCurrentTime(); + unsigned long long totalRows = (uint32_t)(totalRowsPerTbl * tableNum); + printf("insert total %d records, used %u seconds, avg:%u useconds per record\n", totalRows, (endtime-starttime)/1000000UL, (endtime-starttime)/totalRows); + + free(v->ts); + free(v->br); + free(v->nr); + free(v); + free(lb); + free(params); + free(is_null); + free(no_null); + + return 0; +} + +static void runCase_long(TAOS *taos) { + TAOS_STMT *stmt = NULL; + + int tableNum; + int lenOfBinaryDef; + int rowsOfPerColum; + int bingNum; + int lenOfBinaryAct; + int columnNum; + + int totalRowsPerTbl; + +//=======================================================================// + //========== long case 14: ======================// +#if 0 + { + stmt = taos_stmt_init(taos); + + tableNum = 1000; + rowsOfPerColum = 10; + bingNum = 5000000; + lenOfBinaryDef = 1000; + lenOfBinaryAct = 33; + columnNum = 11; + + prepareV(taos, 1, tableNum, lenOfBinaryDef); + stmt_bind_case_002(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + checkResult(taos, "m1", 0, totalRowsPerTbl); + checkResult(taos, "m2", 0, totalRowsPerTbl); + checkResult(taos, "m3", 0, totalRowsPerTbl); + checkResult(taos, "m4", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("long case 14 check result end\n\n"); + } +#endif + + + //========== case 15: ======================// +#if 1 + { + printf("====long case 15 test start\n\n"); + + tableNum = 200; + rowsOfPerColum = 110; + bingNum = 100; + lenOfBinaryDef = 1000; + lenOfBinaryAct = 8; + columnNum = 11; + + int64_t startTs = 1591060628000; + prepareV_long(taos, 1, tableNum, lenOfBinaryDef); + + totalRowsPerTbl = 0; + for (int i = 0; i < g_runTimes; i++) { + stmt = taos_stmt_init(taos); + stmt_bind_case_001_long(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum, &startTs); + + totalRowsPerTbl += rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + checkResult(taos, "m11", 0, totalRowsPerTbl); + checkResult(taos, "m22", 0, totalRowsPerTbl); + checkResult(taos, "m133", 0, totalRowsPerTbl); + checkResult(taos, "m199", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + } + + printf("====long case 15 check result end\n\n"); + } +#endif + + return; + +} + +/*=======================*/ +/* +test scene: insert into tb1 (ts,f1) values (?,?) +*/ +static int stmt_specifyCol_bind_case_001(TAOS_STMT *stmt, int tableNum, int rowsOfPerColum, int bingNum, int lenOfBinaryDef, int lenOfBinaryAct, int columnNum) { + sampleValue* v = (sampleValue *)calloc(1, sizeof(sampleValue)); + + int totalRowsPerTbl = rowsOfPerColum * bingNum; + + v->ts = (int64_t *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * tableNum)); + v->br = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef)); + v->nr = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef)); + + int *lb = (int *)malloc(MAX_ROWS_OF_PER_COLUMN * sizeof(int)); + + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * (size_t)(bingNum * columnNum * (tableNum+1) * rowsOfPerColum)); + char* is_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN); + char* no_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN); + + int64_t tts = 1591060628000; + + for (int i = 0; i < rowsOfPerColum; ++i) { + lb[i] = lenOfBinaryAct; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v->b[i] = (int8_t)(i % 2); + v->v1[i] = (int8_t)((i+1) % 2); + v->v2[i] = (int16_t)i; + v->v4[i] = (int32_t)(i+1); + v->v8[i] = (int64_t)(i+2); + v->f4[i] = (float)(i+3); + v->f8[i] = (double)(i+4); + char tbuf[MAX_BINARY_DEF_LEN]; + memset(tbuf, 0, MAX_BINARY_DEF_LEN); + sprintf(tbuf, "binary-%d-0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", i%10); + memcpy(v->br + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct); + memset(tbuf, 0, MAX_BINARY_DEF_LEN); + sprintf(tbuf, "nchar-%d-0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", i%10); + memcpy(v->nr + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct); + v->ts2[i] = tts + i; + } + + int i = 0; + for (int j = 0; j < bingNum * tableNum; j++) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v->ts[j*rowsOfPerColum]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = rowsOfPerColum; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v->b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = rowsOfPerColum; + + params[i+2].buffer_type = TSDB_DATA_TYPE_INT; + params[i+2].buffer_length = sizeof(int32_t); + params[i+2].buffer = v->v4; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = rowsOfPerColum; + + params[i+3].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+3].buffer_length = sizeof(float); + params[i+3].buffer = v->f4; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = rowsOfPerColum; + + params[i+4].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+4].buffer_length = (uintptr_t)lenOfBinaryDef; + params[i+4].buffer = v->br; + params[i+4].length = lb; + params[i+4].is_null = is_null; + params[i+4].num = rowsOfPerColum; + + i+=columnNum; + } + + //int64_t tts = 1591060628000; + for (int i = 0; i < totalRowsPerTbl * tableNum; ++i) { + v->ts[i] = tts + i; + } + + unsigned long long starttime = getCurrentTime(); + +// create table m%d (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, br binary(%d), nr nchar(%d), ts2 timestamp) + char *sql = "insert into m0 (ts,b,v4,f4,br) values(?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + + int id = 0; + for (int l = 0; l < bingNum; l++) { + for (int zz = 0; zz < tableNum; zz++) { + //char buf[32]; + //sprintf(buf, "m%d", zz); + //code = taos_stmt_set_tbname(stmt, buf); + //if (code != 0){ + // printf("failed to execute taos_stmt_set_tbname. code:0x%x[%s]\n", code, tstrerror(code)); + // return -1; + //} + + for (int col=0; col < columnNum; ++col) { + code = taos_stmt_bind_single_param_batch(stmt, params + id, col); + if (code != 0){ + printf("failed to execute taos_stmt_bind_single_param_batch. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + id++; + } + + code = taos_stmt_add_batch(stmt); + if (code != 0) { + printf("failed to execute taos_stmt_add_batch. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + } + + code = taos_stmt_execute(stmt); + if (code != 0) { + printf("failed to execute taos_stmt_execute. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + } + + unsigned long long endtime = getCurrentTime(); + unsigned long long totalRows = (uint32_t)(totalRowsPerTbl * tableNum); + printf("insert total %d records, used %u seconds, avg:%u useconds per record\n", totalRows, (endtime-starttime)/1000000UL, (endtime-starttime)/totalRows); + + free(v->ts); + free(v->br); + free(v->nr); + free(v); + free(lb); + free(params); + free(is_null); + free(no_null); + + return 0; +} + +/*=======================*/ +/* +test scene: insert into ? (ts,f1) values (?,?) +*/ +static int stmt_specifyCol_bind_case_002(TAOS_STMT *stmt, int tableNum, int rowsOfPerColum, int bingNum, int lenOfBinaryDef, int lenOfBinaryAct, int columnNum) { + sampleValue* v = (sampleValue *)calloc(1, sizeof(sampleValue)); + + int totalRowsPerTbl = rowsOfPerColum * bingNum; + + v->ts = (int64_t *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * tableNum)); + v->br = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef)); + v->nr = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef)); + + int *lb = (int *)malloc(MAX_ROWS_OF_PER_COLUMN * sizeof(int)); + + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * (size_t)(bingNum * columnNum * (tableNum+1) * rowsOfPerColum)); + char* is_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN); + char* no_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN); + + int64_t tts = 1591060628000; + + for (int i = 0; i < rowsOfPerColum; ++i) { + lb[i] = lenOfBinaryAct; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v->b[i] = (int8_t)(i % 2); + v->v1[i] = (int8_t)((i+1) % 2); + v->v2[i] = (int16_t)i; + v->v4[i] = (int32_t)(i+1); + v->v8[i] = (int64_t)(i+2); + v->f4[i] = (float)(i+3); + v->f8[i] = (double)(i+4); + char tbuf[MAX_BINARY_DEF_LEN]; + memset(tbuf, 0, MAX_BINARY_DEF_LEN); + sprintf(tbuf, "binary-%d", i%10); + memcpy(v->br + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct); + memset(tbuf, 0, MAX_BINARY_DEF_LEN); + sprintf(tbuf, "nchar-%d", i%10); + memcpy(v->nr + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct); + v->ts2[i] = tts + i; + } + + int i = 0; + for (int j = 0; j < bingNum * tableNum; j++) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v->ts[j*rowsOfPerColum]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = rowsOfPerColum; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v->b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = rowsOfPerColum; + + params[i+2].buffer_type = TSDB_DATA_TYPE_INT; + params[i+2].buffer_length = sizeof(int32_t); + params[i+2].buffer = v->v4; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = rowsOfPerColum; + + params[i+3].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+3].buffer_length = sizeof(float); + params[i+3].buffer = v->f4; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = rowsOfPerColum; + + params[i+4].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+4].buffer_length = (uintptr_t)lenOfBinaryDef; + params[i+4].buffer = v->br; + params[i+4].length = lb; + params[i+4].is_null = is_null; + params[i+4].num = rowsOfPerColum; + + i+=columnNum; + } + + //int64_t tts = 1591060628000; + for (int i = 0; i < totalRowsPerTbl * tableNum; ++i) { + v->ts[i] = tts + i; + } + + unsigned long long starttime = getCurrentTime(); + +// create table m%d (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, br binary(%d), nr nchar(%d), ts2 timestamp) + char *sql = "insert into ? (ts,b,v4,f4,br) values(?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + + int id = 0; + for (int l = 0; l < bingNum; l++) { + for (int zz = 0; zz < tableNum; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + + for (int col=0; col < columnNum; ++col) { + code = taos_stmt_bind_single_param_batch(stmt, params + id, col); + if (code != 0){ + printf("failed to execute taos_stmt_bind_single_param_batch. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + id++; + } + + code = taos_stmt_add_batch(stmt); + if (code != 0) { + printf("failed to execute taos_stmt_add_batch. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + } + + code = taos_stmt_execute(stmt); + if (code != 0) { + printf("failed to execute taos_stmt_execute. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + } + + unsigned long long endtime = getCurrentTime(); + unsigned long long totalRows = (uint32_t)(totalRowsPerTbl * tableNum); + printf("insert total %d records, used %u seconds, avg:%u useconds per record\n", totalRows, (endtime-starttime)/1000000UL, (endtime-starttime)/totalRows); + + free(v->ts); + free(v->br); + free(v->nr); + free(v); + free(lb); + free(params); + free(is_null); + free(no_null); + + return 0; +} + +/*=======================*/ +/* +test scene: insert into tb1 (ts,f1) values (?,?) +*/ +static int stmt_specifyCol_bind_case_001_maxRows(TAOS_STMT *stmt, int tableNum, int rowsOfPerColum, int bingNum, int lenOfBinaryDef, int lenOfBinaryAct, int columnNum) { + sampleValue* v = (sampleValue *)calloc(1, sizeof(sampleValue)); + + int totalRowsPerTbl = rowsOfPerColum * bingNum; + + v->ts = (int64_t *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * tableNum)); + v->br = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef)); + v->nr = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef)); + + int *lb = (int *)malloc(MAX_ROWS_OF_PER_COLUMN * sizeof(int)); + + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * (size_t)(bingNum * columnNum * (tableNum+1) * rowsOfPerColum)); + char* is_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN); + char* no_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN); + + int64_t tts = 1591060628000; + + for (int i = 0; i < rowsOfPerColum; ++i) { + lb[i] = lenOfBinaryAct; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v->b[i] = (int8_t)(i % 2); + v->v1[i] = (int8_t)((i+1) % 2); + v->v2[i] = (int16_t)i; + v->v4[i] = (int32_t)(i+1); + v->v8[i] = (int64_t)(i+2); + v->f4[i] = (float)(i+3); + v->f8[i] = (double)(i+4); + char tbuf[MAX_BINARY_DEF_LEN]; + memset(tbuf, 0, MAX_BINARY_DEF_LEN); + sprintf(tbuf, "binary-%d-0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", i%10); + memcpy(v->br + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct); + memset(tbuf, 0, MAX_BINARY_DEF_LEN); + sprintf(tbuf, "nchar-%d-0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", i%10); + memcpy(v->nr + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct); + v->ts2[i] = tts + i; + } + + int i = 0; + for (int j = 0; j < bingNum * tableNum; j++) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v->ts[j*rowsOfPerColum]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = rowsOfPerColum; + + params[i+1].buffer_type = TSDB_DATA_TYPE_INT; + params[i+1].buffer_length = sizeof(int32_t); + params[i+1].buffer = v->v4; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = rowsOfPerColum; + + i+=columnNum; + } + + //int64_t tts = 1591060628000; + for (int i = 0; i < totalRowsPerTbl * tableNum; ++i) { + v->ts[i] = tts + i; + } + + unsigned long long starttime = getCurrentTime(); + +// create table m%d (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, br binary(%d), nr nchar(%d), ts2 timestamp) + char *sql = "insert into m0 (ts,b,v4,f4,br) values(?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + + int id = 0; + for (int l = 0; l < bingNum; l++) { + for (int zz = 0; zz < tableNum; zz++) { + //char buf[32]; + //sprintf(buf, "m%d", zz); + //code = taos_stmt_set_tbname(stmt, buf); + //if (code != 0){ + // printf("failed to execute taos_stmt_set_tbname. code:0x%x[%s]\n", code, tstrerror(code)); + // return -1; + //} + + for (int col=0; col < columnNum; ++col) { + code = taos_stmt_bind_single_param_batch(stmt, params + id, col); + if (code != 0){ + printf("failed to execute taos_stmt_bind_single_param_batch. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + id++; + } + + code = taos_stmt_add_batch(stmt); + if (code != 0) { + printf("failed to execute taos_stmt_add_batch. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + } + + code = taos_stmt_execute(stmt); + if (code != 0) { + printf("failed to execute taos_stmt_execute. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + } + + unsigned long long endtime = getCurrentTime(); + unsigned long long totalRows = (uint32_t)(totalRowsPerTbl * tableNum); + printf("insert total %d records, used %u seconds, avg:%u useconds per record\n", totalRows, (endtime-starttime)/1000000UL, (endtime-starttime)/totalRows); + + free(v->ts); + free(v->br); + free(v->nr); + free(v); + free(lb); + free(params); + free(is_null); + free(no_null); + + return 0; +} + +static void SpecifyColumnBatchCase(TAOS *taos) { + TAOS_STMT *stmt = NULL; + + int tableNum; + int lenOfBinaryDef; + int rowsOfPerColum; + int bingNum; + int lenOfBinaryAct; + int columnNum; + + int totalRowsPerTbl; + +//=======================================================================// +//=============================== single table ==========================// +//========== case 1: ======================// +#if 1 +{ + stmt = taos_stmt_init(taos); + + tableNum = 1; + rowsOfPerColum = 1; + bingNum = 1; + lenOfBinaryDef = 40; + lenOfBinaryAct = 8; + columnNum = 5; + + prepareVcolumn(taos, 1, tableNum, lenOfBinaryDef, "db1"); + stmt_specifyCol_bind_case_001(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 1 check result end\n\n"); +} +#endif + + //========== case 2: ======================// +#if 1 +{ + stmt = taos_stmt_init(taos); + + tableNum = 1; + rowsOfPerColum = 5; + bingNum = 1; + lenOfBinaryDef = 1000; + lenOfBinaryAct = 15; + columnNum = 5; + + prepareVcolumn(taos, 1, tableNum, lenOfBinaryDef, "db2"); + stmt_specifyCol_bind_case_001(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + //checkResult(taos, "m1", 0, totalRowsPerTbl); + //checkResult(taos, "m2", 0, totalRowsPerTbl); + //checkResult(taos, "m3", 0, totalRowsPerTbl); + //checkResult(taos, "m4", 0, totalRowsPerTbl); + //checkResult(taos, "m5", 0, totalRowsPerTbl); + //checkResult(taos, "m6", 0, totalRowsPerTbl); + //checkResult(taos, "m7", 0, totalRowsPerTbl); + //checkResult(taos, "m8", 0, totalRowsPerTbl); + //checkResult(taos, "m9", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 2 check result end\n\n"); +} +#endif + + //========== case 2-1: ======================// +#if 1 + { + stmt = taos_stmt_init(taos); + + tableNum = 1; + rowsOfPerColum = 32767; + bingNum = 1; + lenOfBinaryDef = 1000; + lenOfBinaryAct = 15; + columnNum = 5; + + prepareVcolumn(taos, 1, tableNum, lenOfBinaryDef, "db2_1"); + stmt_specifyCol_bind_case_001(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + //checkResult(taos, "m1", 0, totalRowsPerTbl); + //checkResult(taos, "m2", 0, totalRowsPerTbl); + //checkResult(taos, "m3", 0, totalRowsPerTbl); + //checkResult(taos, "m4", 0, totalRowsPerTbl); + //checkResult(taos, "m5", 0, totalRowsPerTbl); + //checkResult(taos, "m6", 0, totalRowsPerTbl); + //checkResult(taos, "m7", 0, totalRowsPerTbl); + //checkResult(taos, "m8", 0, totalRowsPerTbl); + //checkResult(taos, "m9", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 2-1 check result end\n\n"); + } +#endif + //========== case 2-2: ======================// +#if 1 + { + printf("====case 2-2 error test start\n"); + stmt = taos_stmt_init(taos); + + tableNum = 1; + rowsOfPerColum = 32768; + bingNum = 1; + lenOfBinaryDef = 1000; + lenOfBinaryAct = 15; + columnNum = 5; + + prepareVcolumn(taos, 1, tableNum, lenOfBinaryDef, "db2_2"); + stmt_specifyCol_bind_case_001(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + //checkResult(taos, "m1", 0, totalRowsPerTbl); + //checkResult(taos, "m2", 0, totalRowsPerTbl); + //checkResult(taos, "m3", 0, totalRowsPerTbl); + //checkResult(taos, "m4", 0, totalRowsPerTbl); + //checkResult(taos, "m5", 0, totalRowsPerTbl); + //checkResult(taos, "m6", 0, totalRowsPerTbl); + //checkResult(taos, "m7", 0, totalRowsPerTbl); + //checkResult(taos, "m8", 0, totalRowsPerTbl); + //checkResult(taos, "m9", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("====case 2-2 check result end\n\n"); + } +#endif + + + //========== case 3: ======================// +#if 1 + { + stmt = taos_stmt_init(taos); + + tableNum = 1; + rowsOfPerColum = 1; + bingNum = 5; + lenOfBinaryDef = 1000; + lenOfBinaryAct = 20; + columnNum = 5; + + prepareVcolumn(taos, 1, tableNum, lenOfBinaryDef, "db3"); + stmt_specifyCol_bind_case_001(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + //checkResult(taos, "m1", 0, totalRowsPerTbl); + //checkResult(taos, "m2", 0, totalRowsPerTbl); + //checkResult(taos, "m3", 0, totalRowsPerTbl); + //checkResult(taos, "m4", 0, totalRowsPerTbl); + //checkResult(taos, "m5", 0, totalRowsPerTbl); + //checkResult(taos, "m6", 0, totalRowsPerTbl); + //checkResult(taos, "m7", 0, totalRowsPerTbl); + //checkResult(taos, "m8", 0, totalRowsPerTbl); + //checkResult(taos, "m9", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 3 check result end\n\n"); + } +#endif + + //========== case 4: ======================// +#if 1 + { + stmt = taos_stmt_init(taos); + + tableNum = 1; + rowsOfPerColum = 5; + bingNum = 5; + lenOfBinaryDef = 1000; + lenOfBinaryAct = 33; + columnNum = 5; + + prepareVcolumn(taos, 1, tableNum, lenOfBinaryDef, "db4"); + stmt_specifyCol_bind_case_001(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + //checkResult(taos, "m1", 0, totalRowsPerTbl); + //checkResult(taos, "m2", 0, totalRowsPerTbl); + //checkResult(taos, "m3", 0, totalRowsPerTbl); + //checkResult(taos, "m4", 0, totalRowsPerTbl); + //checkResult(taos, "m5", 0, totalRowsPerTbl); + //checkResult(taos, "m6", 0, totalRowsPerTbl); + //checkResult(taos, "m7", 0, totalRowsPerTbl); + //checkResult(taos, "m8", 0, totalRowsPerTbl); + //checkResult(taos, "m9", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 4 check result end\n\n"); + } +#endif + +//=======================================================================// +//=============================== multi tables ==========================// + //========== case 5: ======================// +#if 1 + { + stmt = taos_stmt_init(taos); + + tableNum = 5; + rowsOfPerColum = 1; + bingNum = 1; + lenOfBinaryDef = 40; + lenOfBinaryAct = 16; + columnNum = 5; + + prepareVcolumn(taos, 1, tableNum, lenOfBinaryDef, "db5"); + stmt_specifyCol_bind_case_002(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + checkResult(taos, "m1", 0, totalRowsPerTbl); + checkResult(taos, "m2", 0, totalRowsPerTbl); + checkResult(taos, "m3", 0, totalRowsPerTbl); + checkResult(taos, "m4", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 5 check result end\n\n"); + } +#endif + + //========== case 6: ======================// +#if 1 + { + stmt = taos_stmt_init(taos); + + tableNum = 5; + rowsOfPerColum = 5; + bingNum = 1; + lenOfBinaryDef = 1000; + lenOfBinaryAct = 20; + columnNum = 5; + + prepareVcolumn(taos, 1, tableNum, lenOfBinaryDef, "db6"); + stmt_specifyCol_bind_case_002(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + checkResult(taos, "m1", 0, totalRowsPerTbl); + checkResult(taos, "m2", 0, totalRowsPerTbl); + checkResult(taos, "m3", 0, totalRowsPerTbl); + checkResult(taos, "m4", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 6 check result end\n\n"); + } +#endif + + //========== case 7: ======================// +#if 1 + { + stmt = taos_stmt_init(taos); + + tableNum = 5; + rowsOfPerColum = 1; + bingNum = 5; + lenOfBinaryDef = 1000; + lenOfBinaryAct = 33; + columnNum = 5; + + prepareVcolumn(taos, 1, tableNum, lenOfBinaryDef, "db7"); + stmt_specifyCol_bind_case_002(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + checkResult(taos, "m1", 0, totalRowsPerTbl); + checkResult(taos, "m2", 0, totalRowsPerTbl); + checkResult(taos, "m3", 0, totalRowsPerTbl); + checkResult(taos, "m4", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 7 check result end\n\n"); + } +#endif + + //========== case 8: ======================// +#if 1 +{ + stmt = taos_stmt_init(taos); + + tableNum = 5; + rowsOfPerColum = 5; + bingNum = 5; + lenOfBinaryDef = 1000; + lenOfBinaryAct = 40; + columnNum = 5; + + prepareVcolumn(taos, 1, tableNum, lenOfBinaryDef, "db8"); + stmt_specifyCol_bind_case_002(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + checkResult(taos, "m1", 0, totalRowsPerTbl); + checkResult(taos, "m2", 0, totalRowsPerTbl); + checkResult(taos, "m3", 0, totalRowsPerTbl); + checkResult(taos, "m4", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 8 check result end\n\n"); +} +#endif + + //=======================================================================// + //=============================== multi-rows to single table ==========================// + //========== case 9: ======================// +#if 1 + { + stmt = taos_stmt_init(taos); + + tableNum = 1; + rowsOfPerColum = 23740; + bingNum = 1; + lenOfBinaryDef = 40; + lenOfBinaryAct = 8; + columnNum = 5; + + prepareVcolumn(taos, 1, tableNum, lenOfBinaryDef, "db9"); + stmt_specifyCol_bind_case_001(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 9 check result end\n\n"); + } +#endif + + //========== case 10: ======================// +#if 0 + { + printf("====case 10 error test start\n"); + stmt = taos_stmt_init(taos); + + tableNum = 1; + rowsOfPerColum = 23741; // WAL size exceeds limit + bingNum = 1; + lenOfBinaryDef = 40; + lenOfBinaryAct = 8; + columnNum = 5; + + prepareV(taos, 1, tableNum, lenOfBinaryDef); + stmt_specifyCol_bind_case_001(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("====case 10 check result end\n\n"); + } +#endif + + + //=======================================================================// + //=============================== multi tables, multi bind one same table ==========================// + //========== case 13: ======================// +#if 1 + { + stmt = taos_stmt_init(taos); + + tableNum = 5; + rowsOfPerColum = 1; + bingNum = 5; + lenOfBinaryDef = 40; + lenOfBinaryAct = 28; + columnNum = 5; + + prepareVcolumn(taos, 1, tableNum, lenOfBinaryDef, "db13"); + stmt_specifyCol_bind_case_002(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + checkResult(taos, "m1", 0, totalRowsPerTbl); + checkResult(taos, "m2", 0, totalRowsPerTbl); + checkResult(taos, "m3", 0, totalRowsPerTbl); + checkResult(taos, "m4", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 13 check result end\n\n"); + } +#endif + + //========== case 14: ======================// +#if 1 + { + stmt = taos_stmt_init(taos); + + tableNum = 5; + rowsOfPerColum = 5; + bingNum = 5; + lenOfBinaryDef = 1000; + lenOfBinaryAct = 33; + columnNum = 5; + + prepareVcolumn(taos, 1, tableNum, lenOfBinaryDef, "db14"); + stmt_specifyCol_bind_case_002(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + checkResult(taos, "m1", 0, totalRowsPerTbl); + checkResult(taos, "m2", 0, totalRowsPerTbl); + checkResult(taos, "m3", 0, totalRowsPerTbl); + checkResult(taos, "m4", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 14 check result end\n\n"); + } +#endif + + + //========== case 15: ======================// +#if 1 + { + stmt = taos_stmt_init(taos); + + tableNum = 1000; + rowsOfPerColum = 10; + bingNum = 5; + lenOfBinaryDef = 1000; + lenOfBinaryAct = 8; + columnNum = 5; + + prepareVcolumn(taos, 1, tableNum, lenOfBinaryDef, "db15"); + stmt_specifyCol_bind_case_002(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + checkResult(taos, "m111", 0, totalRowsPerTbl); + checkResult(taos, "m222", 0, totalRowsPerTbl); + checkResult(taos, "m333", 0, totalRowsPerTbl); + checkResult(taos, "m500", 0, totalRowsPerTbl); + checkResult(taos, "m999", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 15 check result end\n\n"); + } +#endif + + //========== case 17: ======================// +#if 1 + { + //printf("case 17 test start\n"); + stmt = taos_stmt_init(taos); + + tableNum = 10; + rowsOfPerColum = 100; + bingNum = 1; + lenOfBinaryDef = 100; + lenOfBinaryAct = 8; + columnNum = 5; + + prepareVcolumn(taos, 1, tableNum, lenOfBinaryDef, "db17"); + stmt_specifyCol_bind_case_002(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + checkResult(taos, "m3", 0, totalRowsPerTbl); + checkResult(taos, "m5", 0, totalRowsPerTbl); + checkResult(taos, "m8", 0, totalRowsPerTbl); + checkResult(taos, "m9", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 17 check result end\n\n"); + } +#endif + + return ; + +} + + +/*=======================*/ +/* +test scene: insert into tb1 (ts,f1) values (?,?) +*/ +static int stmt_specifyCol_bind_case_001_autoCreateTbl(TAOS_STMT *stmt, int tableNum, int rowsOfPerColum, int bingNum, int lenOfBinaryDef, int lenOfBinaryAct, int columnNum) { + sampleValue* v = (sampleValue *)calloc(1, sizeof(sampleValue)); + + int totalRowsPerTbl = rowsOfPerColum * bingNum; + + v->ts = (int64_t *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * tableNum)); + v->br = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef)); + v->nr = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef)); + + int *lb = (int *)malloc(MAX_ROWS_OF_PER_COLUMN * sizeof(int)); + + TAOS_BIND *tags = calloc(1, sizeof(TAOS_BIND) * 9 * 1); + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * (size_t)(bingNum * columnNum * (tableNum+1) * rowsOfPerColum)); + char* is_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN); + char* no_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN); + int one_not_null = 0; + + int64_t tts = 1591060628000; + + for (int i = 0; i < rowsOfPerColum; ++i) { + lb[i] = lenOfBinaryAct; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v->b[i] = (int8_t)(i % 2); + v->v1[i] = (int8_t)((i+1) % 2); + v->v2[i] = (int16_t)i; + v->v4[i] = (int32_t)(i+1); + v->v8[i] = (int64_t)(i+2); + v->f4[i] = (float)(i+3); + v->f8[i] = (double)(i+4); + char tbuf[MAX_BINARY_DEF_LEN]; + memset(tbuf, 0, MAX_BINARY_DEF_LEN); + sprintf(tbuf, "binary-%d-0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", i%10); + memcpy(v->br + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct); + memset(tbuf, 0, MAX_BINARY_DEF_LEN); + sprintf(tbuf, "nchar-%d-0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", i%10); + memcpy(v->nr + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct); + v->ts2[i] = tts + i; + } + + int i = 0; + for (int j = 0; j < bingNum * tableNum; j++) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v->ts[j*rowsOfPerColum]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = rowsOfPerColum; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v->b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = rowsOfPerColum; + + params[i+2].buffer_type = TSDB_DATA_TYPE_INT; + params[i+2].buffer_length = sizeof(int32_t); + params[i+2].buffer = v->v4; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = rowsOfPerColum; + + params[i+3].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+3].buffer_length = sizeof(float); + params[i+3].buffer = v->f4; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = rowsOfPerColum; + + params[i+4].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+4].buffer_length = (uintptr_t)lenOfBinaryDef; + params[i+4].buffer = v->br; + params[i+4].length = lb; + params[i+4].is_null = is_null; + params[i+4].num = rowsOfPerColum; + + i+=columnNum; + } + + //int64_t tts = 1591060628000; + for (int i = 0; i < totalRowsPerTbl * tableNum; ++i) { + v->ts[i] = tts + i; + } + + for (int i = 0; i < 1; ++i) { + tags[i+0].buffer_type = TSDB_DATA_TYPE_INT; + tags[i+0].buffer = v->v4; + tags[i+0].is_null = &one_not_null; + tags[i+0].length = NULL; + + tags[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + tags[i+1].buffer = v->b; + tags[i+1].is_null = &one_not_null; + tags[i+1].length = NULL; + + tags[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + tags[i+2].buffer = v->v1; + tags[i+2].is_null = &one_not_null; + tags[i+2].length = NULL; + + tags[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + tags[i+3].buffer = v->v2; + tags[i+3].is_null = &one_not_null; + tags[i+3].length = NULL; + + tags[i+4].buffer_type = TSDB_DATA_TYPE_BIGINT; + tags[i+4].buffer = v->v8; + tags[i+4].is_null = &one_not_null; + tags[i+4].length = NULL; + + tags[i+5].buffer_type = TSDB_DATA_TYPE_FLOAT; + tags[i+5].buffer = v->f4; + tags[i+5].is_null = &one_not_null; + tags[i+5].length = NULL; + + tags[i+6].buffer_type = TSDB_DATA_TYPE_DOUBLE; + tags[i+6].buffer = v->f8; + tags[i+6].is_null = &one_not_null; + tags[i+6].length = NULL; + + tags[i+7].buffer_type = TSDB_DATA_TYPE_BINARY; + tags[i+7].buffer = v->br; + tags[i+7].is_null = &one_not_null; + tags[i+7].length = (uintptr_t *)lb; + + tags[i+8].buffer_type = TSDB_DATA_TYPE_NCHAR; + tags[i+8].buffer = v->nr; + tags[i+8].is_null = &one_not_null; + tags[i+8].length = (uintptr_t *)lb; + } + + + unsigned long long starttime = getCurrentTime(); + +// create table m%d (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, br binary(%d), nr nchar(%d), ts2 timestamp) + //char *sql = "insert into ? (ts,b,v4,f4,br) using stb1 tags (?,?,?,?,?,?,?,?,?) values(?,?,?,?,?)"; + char *sql = "insert into ? using stb1 tags (?,?,?,?,?,?,?,?,?) (ts,b,v4,f4,br) values(?,?,?,?,?)"; + + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + + int id = 0; + for (int l = 0; l < bingNum; l++) { + for (int zz = 0; zz < tableNum; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname_tags(stmt, buf, tags); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + + for (int col=0; col < columnNum; ++col) { + code = taos_stmt_bind_single_param_batch(stmt, params + id, col); + if (code != 0){ + printf("failed to execute taos_stmt_bind_single_param_batch. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + id++; + } + + code = taos_stmt_add_batch(stmt); + if (code != 0) { + printf("failed to execute taos_stmt_add_batch. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + } + + code = taos_stmt_execute(stmt); + if (code != 0) { + printf("failed to execute taos_stmt_execute. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + } + + unsigned long long endtime = getCurrentTime(); + unsigned long long totalRows = (uint32_t)(totalRowsPerTbl * tableNum); + printf("insert total %d records, used %u seconds, avg:%u useconds per record\n", totalRows, (endtime-starttime)/1000000UL, (endtime-starttime)/totalRows); + + free(v->ts); + free(v->br); + free(v->nr); + free(v); + free(lb); + free(params); + free(tags); + free(is_null); + free(no_null); + + return 0; +} + +static int stmt_specifyCol_bind_case_002_autoCreateTbl(TAOS_STMT *stmt, int tableNum, int rowsOfPerColum, int bingNum, int lenOfBinaryDef, int lenOfBinaryAct, int columnNum) { + sampleValue* v = (sampleValue *)calloc(1, sizeof(sampleValue)); + + int totalRowsPerTbl = rowsOfPerColum * bingNum; + + v->ts = (int64_t *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * tableNum)); + v->br = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef)); + v->nr = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef)); + + int *lb = (int *)malloc(MAX_ROWS_OF_PER_COLUMN * sizeof(int)); + + TAOS_BIND *tags = calloc(1, sizeof(TAOS_BIND) * 9 * 1); + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * (size_t)(bingNum * columnNum * (tableNum+1) * rowsOfPerColum)); + char* is_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN); + char* no_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN); + int one_not_null = 0; + + int64_t tts = 1591060628000; + + for (int i = 0; i < rowsOfPerColum; ++i) { + lb[i] = lenOfBinaryAct; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v->b[i] = (int8_t)(i % 2); + v->v1[i] = (int8_t)((i+1) % 2); + v->v2[i] = (int16_t)i; + v->v4[i] = (int32_t)(i+1); + v->v8[i] = (int64_t)(i+2); + v->f4[i] = (float)(i+3); + v->f8[i] = (double)(i+4); + char tbuf[MAX_BINARY_DEF_LEN]; + memset(tbuf, 0, MAX_BINARY_DEF_LEN); + sprintf(tbuf, "binary-%d-0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", i%10); + memcpy(v->br + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct); + memset(tbuf, 0, MAX_BINARY_DEF_LEN); + sprintf(tbuf, "nchar-%d-0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", i%10); + memcpy(v->nr + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct); + v->ts2[i] = tts + i; + } + + int i = 0; + for (int j = 0; j < bingNum * tableNum; j++) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v->ts[j*rowsOfPerColum]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = rowsOfPerColum; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v->b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = rowsOfPerColum; + + params[i+2].buffer_type = TSDB_DATA_TYPE_INT; + params[i+2].buffer_length = sizeof(int32_t); + params[i+2].buffer = v->v4; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = rowsOfPerColum; + + params[i+3].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+3].buffer_length = sizeof(float); + params[i+3].buffer = v->f4; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = rowsOfPerColum; + + params[i+4].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+4].buffer_length = (uintptr_t)lenOfBinaryDef; + params[i+4].buffer = v->br; + params[i+4].length = lb; + params[i+4].is_null = is_null; + params[i+4].num = rowsOfPerColum; + + i+=columnNum; + } + + //int64_t tts = 1591060628000; + for (int i = 0; i < totalRowsPerTbl * tableNum; ++i) { + v->ts[i] = tts + i; + } + + for (int i = 0; i < 1; ++i) { + //tags[i+0].buffer_type = TSDB_DATA_TYPE_INT; + //tags[i+0].buffer = v->v4; + //tags[i+0].is_null = &one_not_null; + //tags[i+0].length = NULL; + + tags[i+0].buffer_type = TSDB_DATA_TYPE_BOOL; + tags[i+0].buffer = v->b; + tags[i+0].is_null = &one_not_null; + tags[i+0].length = NULL; + + //tags[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + //tags[i+2].buffer = v->v1; + //tags[i+2].is_null = &one_not_null; + //tags[i+2].length = NULL; + + tags[i+1].buffer_type = TSDB_DATA_TYPE_SMALLINT; + tags[i+1].buffer = v->v2; + tags[i+1].is_null = &one_not_null; + tags[i+1].length = NULL; + + tags[i+2].buffer_type = TSDB_DATA_TYPE_BIGINT; + tags[i+2].buffer = v->v8; + tags[i+2].is_null = &one_not_null; + tags[i+2].length = NULL; + + tags[i+3].buffer_type = TSDB_DATA_TYPE_FLOAT; + tags[i+3].buffer = v->f4; + tags[i+3].is_null = &one_not_null; + tags[i+3].length = NULL; + + tags[i+4].buffer_type = TSDB_DATA_TYPE_DOUBLE; + tags[i+4].buffer = v->f8; + tags[i+4].is_null = &one_not_null; + tags[i+4].length = NULL; + + tags[i+5].buffer_type = TSDB_DATA_TYPE_BINARY; + tags[i+5].buffer = v->br; + tags[i+5].is_null = &one_not_null; + tags[i+5].length = (uintptr_t *)lb; + + tags[i+6].buffer_type = TSDB_DATA_TYPE_NCHAR; + tags[i+6].buffer = v->nr; + tags[i+6].is_null = &one_not_null; + tags[i+6].length = (uintptr_t *)lb; + } + + + unsigned long long starttime = getCurrentTime(); + +// create table m%d (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, br binary(%d), nr nchar(%d), ts2 timestamp) + //char *sql = "insert into ? (ts,b,v4,f4,br) using stb1 tags (?,?,?,?,?,?,?,?,?) values(?,?,?,?,?)"; + char *sql = "insert into ? using stb1 tags (33,?,99,?,?,?,?,?,?) (ts,b,v4,f4,br) values(?,?,?,?,?)"; + + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + + int id = 0; + for (int l = 0; l < bingNum; l++) { + for (int zz = 0; zz < tableNum; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname_tags(stmt, buf, tags); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + + for (int col=0; col < columnNum; ++col) { + code = taos_stmt_bind_single_param_batch(stmt, params + id, col); + if (code != 0){ + printf("failed to execute taos_stmt_bind_single_param_batch. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + id++; + } + + code = taos_stmt_add_batch(stmt); + if (code != 0) { + printf("failed to execute taos_stmt_add_batch. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + } + + code = taos_stmt_execute(stmt); + if (code != 0) { + printf("failed to execute taos_stmt_execute. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + } + + unsigned long long endtime = getCurrentTime(); + unsigned long long totalRows = (uint32_t)(totalRowsPerTbl * tableNum); + printf("insert total %d records, used %u seconds, avg:%u useconds per record\n", totalRows, (endtime-starttime)/1000000UL, (endtime-starttime)/totalRows); + + free(v->ts); + free(v->br); + free(v->nr); + free(v); + free(lb); + free(params); + free(tags); + free(is_null); + free(no_null); + + return 0; +} + +// some tags are null +static int stmt_specifyCol_bind_case_003_autoCreateTbl(TAOS_STMT *stmt, int tableNum, int rowsOfPerColum, int bingNum, int lenOfBinaryDef, int lenOfBinaryAct, int columnNum) { + sampleValue* v = (sampleValue *)calloc(1, sizeof(sampleValue)); + + int totalRowsPerTbl = rowsOfPerColum * bingNum; + + v->ts = (int64_t *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * tableNum)); + v->br = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef)); + v->nr = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef)); + + int *lb = (int *)malloc(MAX_ROWS_OF_PER_COLUMN * sizeof(int)); + + TAOS_BIND *tags = calloc(1, sizeof(TAOS_BIND) * 9 * 1); + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * (size_t)(bingNum * columnNum * (tableNum+1) * rowsOfPerColum)); + char* is_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN); + char* no_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN); + int one_not_null = 0; + int one_is_null = 1; + + int64_t tts = 1591060628000; + + for (int i = 0; i < rowsOfPerColum; ++i) { + lb[i] = lenOfBinaryAct; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v->b[i] = (int8_t)(i % 2); + v->v1[i] = (int8_t)((i+1) % 2); + v->v2[i] = (int16_t)i; + v->v4[i] = (int32_t)(i+1); + v->v8[i] = (int64_t)(i+2); + v->f4[i] = (float)(i+3); + v->f8[i] = (double)(i+4); + char tbuf[MAX_BINARY_DEF_LEN]; + memset(tbuf, 0, MAX_BINARY_DEF_LEN); + sprintf(tbuf, "binary-%d-0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", i%10); + memcpy(v->br + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct); + memset(tbuf, 0, MAX_BINARY_DEF_LEN); + sprintf(tbuf, "nchar-%d-0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", i%10); + memcpy(v->nr + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct); + v->ts2[i] = tts + i; + } + + int i = 0; + for (int j = 0; j < bingNum * tableNum; j++) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v->ts[j*rowsOfPerColum]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = rowsOfPerColum; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v->b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = rowsOfPerColum; + + params[i+2].buffer_type = TSDB_DATA_TYPE_INT; + params[i+2].buffer_length = sizeof(int32_t); + params[i+2].buffer = v->v4; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = rowsOfPerColum; + + params[i+3].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+3].buffer_length = sizeof(float); + params[i+3].buffer = v->f4; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = rowsOfPerColum; + + params[i+4].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+4].buffer_length = (uintptr_t)lenOfBinaryDef; + params[i+4].buffer = v->br; + params[i+4].length = lb; + params[i+4].is_null = is_null; + params[i+4].num = rowsOfPerColum; + + i+=columnNum; + } + + //int64_t tts = 1591060628000; + for (int i = 0; i < totalRowsPerTbl * tableNum; ++i) { + v->ts[i] = tts + i; + } + + for (int i = 0; i < 1; ++i) { + tags[i+0].buffer_type = TSDB_DATA_TYPE_INT; + tags[i+0].buffer = v->v4; + tags[i+0].is_null = &one_not_null; + tags[i+0].length = NULL; + + tags[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + tags[i+1].buffer = v->b; + tags[i+1].is_null = &one_is_null; + tags[i+1].length = NULL; + + tags[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + tags[i+2].buffer = v->v1; + tags[i+2].is_null = &one_is_null; + tags[i+2].length = NULL; + + tags[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + tags[i+3].buffer = v->v2; + tags[i+3].is_null = &one_not_null; + tags[i+3].length = NULL; + + tags[i+4].buffer_type = TSDB_DATA_TYPE_BIGINT; + tags[i+4].buffer = v->v8; + tags[i+4].is_null = &one_not_null; + tags[i+4].length = NULL; + + tags[i+5].buffer_type = TSDB_DATA_TYPE_FLOAT; + tags[i+5].buffer = v->f4; + tags[i+5].is_null = &one_is_null; + tags[i+5].length = NULL; + + tags[i+6].buffer_type = TSDB_DATA_TYPE_DOUBLE; + tags[i+6].buffer = v->f8; + tags[i+6].is_null = &one_not_null; + tags[i+6].length = NULL; + + tags[i+7].buffer_type = TSDB_DATA_TYPE_BINARY; + tags[i+7].buffer = v->br; + tags[i+7].is_null = &one_not_null; + tags[i+7].length = (uintptr_t *)lb; + + tags[i+8].buffer_type = TSDB_DATA_TYPE_NCHAR; + tags[i+8].buffer = v->nr; + tags[i+8].is_null = &one_not_null; + tags[i+8].length = (uintptr_t *)lb; + } + + + unsigned long long starttime = getCurrentTime(); + +// create table m%d (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, br binary(%d), nr nchar(%d), ts2 timestamp) + //char *sql = "insert into ? (ts,b,v4,f4,br) using stb1 tags (?,?,?,?,?,?,?,?,?) values(?,?,?,?,?)"; + char *sql = "insert into ? using stb1 tags (?,?,?,?,?,?,?,?,?) (ts,b,v4,f4,br) values(?,?,?,?,?)"; + + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + + int id = 0; + for (int l = 0; l < bingNum; l++) { + for (int zz = 0; zz < tableNum; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname_tags(stmt, buf, tags); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + + for (int col=0; col < columnNum; ++col) { + code = taos_stmt_bind_single_param_batch(stmt, params + id, col); + if (code != 0){ + printf("failed to execute taos_stmt_bind_single_param_batch. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + id++; + } + + code = taos_stmt_add_batch(stmt); + if (code != 0) { + printf("failed to execute taos_stmt_add_batch. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + } + + code = taos_stmt_execute(stmt); + if (code != 0) { + printf("failed to execute taos_stmt_execute. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + } + + unsigned long long endtime = getCurrentTime(); + unsigned long long totalRows = (uint32_t)(totalRowsPerTbl * tableNum); + printf("insert total %d records, used %u seconds, avg:%u useconds per record\n", totalRows, (endtime-starttime)/1000000UL, (endtime-starttime)/totalRows); + + free(v->ts); + free(v->br); + free(v->nr); + free(v); + free(lb); + free(params); + free(tags); + free(is_null); + free(no_null); + + return 0; +} + +// specify tags field, and not support , then is error case +static int stmt_specifyCol_bind_case_004_autoCreateTbl(TAOS_STMT *stmt, int tableNum, int rowsOfPerColum, int bingNum, int lenOfBinaryDef, int lenOfBinaryAct, int columnNum) { + sampleValue* v = (sampleValue *)calloc(1, sizeof(sampleValue)); + + int totalRowsPerTbl = rowsOfPerColum * bingNum; + + v->ts = (int64_t *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * tableNum)); + v->br = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef)); + v->nr = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef)); + + int *lb = (int *)malloc(MAX_ROWS_OF_PER_COLUMN * sizeof(int)); + + TAOS_BIND *tags = calloc(1, sizeof(TAOS_BIND) * 9 * 1); + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * (size_t)(bingNum * columnNum * (tableNum+1) * rowsOfPerColum)); + char* is_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN); + char* no_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN); + int one_not_null = 0; + + int64_t tts = 1591060628000; + + for (int i = 0; i < rowsOfPerColum; ++i) { + lb[i] = lenOfBinaryAct; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v->b[i] = (int8_t)(i % 2); + v->v1[i] = (int8_t)((i+1) % 2); + v->v2[i] = (int16_t)i; + v->v4[i] = (int32_t)(i+1); + v->v8[i] = (int64_t)(i+2); + v->f4[i] = (float)(i+3); + v->f8[i] = (double)(i+4); + char tbuf[MAX_BINARY_DEF_LEN]; + memset(tbuf, 0, MAX_BINARY_DEF_LEN); + sprintf(tbuf, "binary-%d-0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", i%10); + memcpy(v->br + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct); + memset(tbuf, 0, MAX_BINARY_DEF_LEN); + sprintf(tbuf, "nchar-%d-0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", i%10); + memcpy(v->nr + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct); + v->ts2[i] = tts + i; + } + + int i = 0; + for (int j = 0; j < bingNum * tableNum; j++) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v->ts[j*rowsOfPerColum]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = rowsOfPerColum; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v->b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = rowsOfPerColum; + + params[i+2].buffer_type = TSDB_DATA_TYPE_INT; + params[i+2].buffer_length = sizeof(int32_t); + params[i+2].buffer = v->v4; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = rowsOfPerColum; + + params[i+3].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+3].buffer_length = sizeof(float); + params[i+3].buffer = v->f4; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = rowsOfPerColum; + + params[i+4].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+4].buffer_length = (uintptr_t)lenOfBinaryDef; + params[i+4].buffer = v->br; + params[i+4].length = lb; + params[i+4].is_null = is_null; + params[i+4].num = rowsOfPerColum; + + i+=columnNum; + } + + //int64_t tts = 1591060628000; + for (int i = 0; i < totalRowsPerTbl * tableNum; ++i) { + v->ts[i] = tts + i; + } + + for (int i = 0; i < 1; ++i) { + //tags[i+0].buffer_type = TSDB_DATA_TYPE_INT; + //tags[i+0].buffer = v->v4; + //tags[i+0].is_null = &one_not_null; + //tags[i+0].length = NULL; + + tags[i+0].buffer_type = TSDB_DATA_TYPE_BOOL; + tags[i+0].buffer = v->b; + tags[i+0].is_null = &one_not_null; + tags[i+0].length = NULL; + + //tags[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + //tags[i+2].buffer = v->v1; + //tags[i+2].is_null = &one_not_null; + //tags[i+2].length = NULL; + + tags[i+1].buffer_type = TSDB_DATA_TYPE_SMALLINT; + tags[i+1].buffer = v->v2; + tags[i+1].is_null = &one_not_null; + tags[i+1].length = NULL; + + tags[i+2].buffer_type = TSDB_DATA_TYPE_BIGINT; + tags[i+2].buffer = v->v8; + tags[i+2].is_null = &one_not_null; + tags[i+2].length = NULL; + + tags[i+3].buffer_type = TSDB_DATA_TYPE_FLOAT; + tags[i+3].buffer = v->f4; + tags[i+3].is_null = &one_not_null; + tags[i+3].length = NULL; + + tags[i+4].buffer_type = TSDB_DATA_TYPE_DOUBLE; + tags[i+4].buffer = v->f8; + tags[i+4].is_null = &one_not_null; + tags[i+4].length = NULL; + + tags[i+5].buffer_type = TSDB_DATA_TYPE_BINARY; + tags[i+5].buffer = v->br; + tags[i+5].is_null = &one_not_null; + tags[i+5].length = (uintptr_t *)lb; + + tags[i+6].buffer_type = TSDB_DATA_TYPE_NCHAR; + tags[i+6].buffer = v->nr; + tags[i+6].is_null = &one_not_null; + tags[i+6].length = (uintptr_t *)lb; + } + + + unsigned long long starttime = getCurrentTime(); + +// create table m%d (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, br binary(%d), nr nchar(%d), ts2 timestamp) + //char *sql = "insert into ? (ts,b,v4,f4,br) using stb1 tags (?,?,?,?,?,?,?,?,?) values(?,?,?,?,?)"; + char *sql = "insert into ? using stb1 (id1, id2, id3, id4, id5, id6, id7, id8, id9) tags (33,?,99,?,?,?,?,?,?) (ts,b,v4,f4,br) values(?,?,?,?,?)"; + + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + + int id = 0; + for (int l = 0; l < bingNum; l++) { + for (int zz = 0; zz < tableNum; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname_tags(stmt, buf, tags); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + + for (int col=0; col < columnNum; ++col) { + code = taos_stmt_bind_single_param_batch(stmt, params + id, col); + if (code != 0){ + printf("failed to execute taos_stmt_bind_single_param_batch. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + id++; + } + + code = taos_stmt_add_batch(stmt); + if (code != 0) { + printf("failed to execute taos_stmt_add_batch. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + } + + code = taos_stmt_execute(stmt); + if (code != 0) { + printf("failed to execute taos_stmt_execute. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + } + + unsigned long long endtime = getCurrentTime(); + unsigned long long totalRows = (uint32_t)(totalRowsPerTbl * tableNum); + printf("insert total %d records, used %u seconds, avg:%u useconds per record\n", totalRows, (endtime-starttime)/1000000UL, (endtime-starttime)/totalRows); + + free(v->ts); + free(v->br); + free(v->nr); + free(v); + free(lb); + free(params); + free(tags); + free(is_null); + free(no_null); + + return 0; +} + +static void SpecifyColumnBatchCase_autoCreateTbl(TAOS *taos) { + TAOS_STMT *stmt = NULL; + + int tableNum; + int lenOfBinaryDef; + int rowsOfPerColum; + int bingNum; + int lenOfBinaryAct; + int columnNum; + + int totalRowsPerTbl; + +//=======================================================================// +//=============================== single table ==========================// +//========== case 1: ======================// +#if 1 +{ + stmt = taos_stmt_init(taos); + + tableNum = 1; + rowsOfPerColum = 1; + bingNum = 1; + lenOfBinaryDef = 40; + lenOfBinaryAct = 8; + columnNum = 5; + + prepareVcolumn_autoCreateTbl(taos, 1, tableNum, lenOfBinaryDef, "db1"); + stmt_specifyCol_bind_case_001_autoCreateTbl(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 1 check result end\n\n"); +} +#endif + + //========== case 2: ======================// +#if 1 +{ + stmt = taos_stmt_init(taos); + + tableNum = 1; + rowsOfPerColum = 5; + bingNum = 1; + lenOfBinaryDef = 1000; + lenOfBinaryAct = 15; + columnNum = 5; + + prepareVcolumn_autoCreateTbl(taos, 1, tableNum, lenOfBinaryDef, "db2"); + stmt_specifyCol_bind_case_001_autoCreateTbl(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + //checkResult(taos, "m1", 0, totalRowsPerTbl); + //checkResult(taos, "m2", 0, totalRowsPerTbl); + //checkResult(taos, "m3", 0, totalRowsPerTbl); + //checkResult(taos, "m4", 0, totalRowsPerTbl); + //checkResult(taos, "m5", 0, totalRowsPerTbl); + //checkResult(taos, "m6", 0, totalRowsPerTbl); + //checkResult(taos, "m7", 0, totalRowsPerTbl); + //checkResult(taos, "m8", 0, totalRowsPerTbl); + //checkResult(taos, "m9", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 2 check result end\n\n"); +} +#endif + + //========== case 2-1: ======================// +#if 1 + { + stmt = taos_stmt_init(taos); + + tableNum = 1; + rowsOfPerColum = 32767; + bingNum = 1; + lenOfBinaryDef = 1000; + lenOfBinaryAct = 15; + columnNum = 5; + + prepareVcolumn_autoCreateTbl(taos, 1, tableNum, lenOfBinaryDef, "db2_1"); + stmt_specifyCol_bind_case_001_autoCreateTbl(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + //checkResult(taos, "m1", 0, totalRowsPerTbl); + //checkResult(taos, "m2", 0, totalRowsPerTbl); + //checkResult(taos, "m3", 0, totalRowsPerTbl); + //checkResult(taos, "m4", 0, totalRowsPerTbl); + //checkResult(taos, "m5", 0, totalRowsPerTbl); + //checkResult(taos, "m6", 0, totalRowsPerTbl); + //checkResult(taos, "m7", 0, totalRowsPerTbl); + //checkResult(taos, "m8", 0, totalRowsPerTbl); + //checkResult(taos, "m9", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 2-1 check result end\n\n"); + } +#endif + //========== case 2-2: ======================// +#if 1 + { + printf("====case 2-2 error test start\n"); + stmt = taos_stmt_init(taos); + + tableNum = 1; + rowsOfPerColum = 32768; + bingNum = 1; + lenOfBinaryDef = 1000; + lenOfBinaryAct = 15; + columnNum = 5; + + prepareVcolumn_autoCreateTbl(taos, 1, tableNum, lenOfBinaryDef, "db2_2"); + stmt_specifyCol_bind_case_001_autoCreateTbl(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + //checkResult(taos, "m1", 0, totalRowsPerTbl); + //checkResult(taos, "m2", 0, totalRowsPerTbl); + //checkResult(taos, "m3", 0, totalRowsPerTbl); + //checkResult(taos, "m4", 0, totalRowsPerTbl); + //checkResult(taos, "m5", 0, totalRowsPerTbl); + //checkResult(taos, "m6", 0, totalRowsPerTbl); + //checkResult(taos, "m7", 0, totalRowsPerTbl); + //checkResult(taos, "m8", 0, totalRowsPerTbl); + //checkResult(taos, "m9", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("====case 2-2 check result end\n\n"); + } +#endif + + + //========== case 3: ======================// +#if 1 + { + stmt = taos_stmt_init(taos); + + tableNum = 1; + rowsOfPerColum = 1; + bingNum = 5; + lenOfBinaryDef = 1000; + lenOfBinaryAct = 20; + columnNum = 5; + + prepareVcolumn_autoCreateTbl(taos, 1, tableNum, lenOfBinaryDef, "db3"); + stmt_specifyCol_bind_case_001_autoCreateTbl(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + //checkResult(taos, "m1", 0, totalRowsPerTbl); + //checkResult(taos, "m2", 0, totalRowsPerTbl); + //checkResult(taos, "m3", 0, totalRowsPerTbl); + //checkResult(taos, "m4", 0, totalRowsPerTbl); + //checkResult(taos, "m5", 0, totalRowsPerTbl); + //checkResult(taos, "m6", 0, totalRowsPerTbl); + //checkResult(taos, "m7", 0, totalRowsPerTbl); + //checkResult(taos, "m8", 0, totalRowsPerTbl); + //checkResult(taos, "m9", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 3 check result end\n\n"); + } +#endif + + //========== case 4: ======================// +#if 1 + { + stmt = taos_stmt_init(taos); + + tableNum = 1; + rowsOfPerColum = 5; + bingNum = 5; + lenOfBinaryDef = 1000; + lenOfBinaryAct = 33; + columnNum = 5; + + prepareVcolumn_autoCreateTbl(taos, 1, tableNum, lenOfBinaryDef, "db4"); + stmt_specifyCol_bind_case_001_autoCreateTbl(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + //checkResult(taos, "m1", 0, totalRowsPerTbl); + //checkResult(taos, "m2", 0, totalRowsPerTbl); + //checkResult(taos, "m3", 0, totalRowsPerTbl); + //checkResult(taos, "m4", 0, totalRowsPerTbl); + //checkResult(taos, "m5", 0, totalRowsPerTbl); + //checkResult(taos, "m6", 0, totalRowsPerTbl); + //checkResult(taos, "m7", 0, totalRowsPerTbl); + //checkResult(taos, "m8", 0, totalRowsPerTbl); + //checkResult(taos, "m9", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 4 check result end\n\n"); + } +#endif + + //=======================================================================// + //=============================== multi-rows to single table ==========================// + //========== case 5: ======================// +#if 1 + { + stmt = taos_stmt_init(taos); + + tableNum = 1; + rowsOfPerColum = 23740; + bingNum = 1; + lenOfBinaryDef = 40; + lenOfBinaryAct = 8; + columnNum = 5; + + prepareVcolumn_autoCreateTbl(taos, 1, tableNum, lenOfBinaryDef, "db5"); + stmt_specifyCol_bind_case_001_autoCreateTbl(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 5 check result end\n\n"); + } +#endif + +// ============== error test: 1.multi table, 2.specify some tags + //========== case 6: ======================// +#if 1 + { + stmt = taos_stmt_init(taos); + + tableNum = 2; + rowsOfPerColum = 5; + bingNum = 1; + lenOfBinaryDef = 40; + lenOfBinaryAct = 8; + columnNum = 5; + + prepareVcolumn_autoCreateTbl(taos, 1, tableNum, lenOfBinaryDef, "db6"); + stmt_specifyCol_bind_case_001_autoCreateTbl(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + checkResult(taos, "m1", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 6 check result end\n\n"); + } +#endif + + //========== case 7: ======================// +#if 1 + { + stmt = taos_stmt_init(taos); + + tableNum = 200; + rowsOfPerColum = 60; + bingNum = 1; + lenOfBinaryDef = 40; + lenOfBinaryAct = 8; + columnNum = 5; + + prepareVcolumn_autoCreateTbl(taos, 1, tableNum, lenOfBinaryDef, "db7"); + stmt_specifyCol_bind_case_001_autoCreateTbl(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + checkResult(taos, "m1", 0, totalRowsPerTbl); + checkResult(taos, "m99", 0, totalRowsPerTbl); + checkResult(taos, "m139", 0, totalRowsPerTbl); + checkResult(taos, "m199", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 7 check result end\n\n"); + } +#endif + + //========== case 8: ======================// +#if 1 + { + stmt = taos_stmt_init(taos); + + tableNum = 1; + rowsOfPerColum = 5; + bingNum = 1; + lenOfBinaryDef = 40; + lenOfBinaryAct = 8; + columnNum = 5; + + prepareVcolumn_autoCreateTbl(taos, 1, tableNum, lenOfBinaryDef, "db8"); + stmt_specifyCol_bind_case_002_autoCreateTbl(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 8 check result end\n\n"); + } +#endif + + //========== case 9: ======================// + +#if 1 + { + stmt = taos_stmt_init(taos); + + tableNum = 10; + rowsOfPerColum = 5; + bingNum = 1; + lenOfBinaryDef = 40; + lenOfBinaryAct = 8; + columnNum = 5; + + prepareVcolumn_autoCreateTbl(taos, 1, tableNum, lenOfBinaryDef, "db9"); + stmt_specifyCol_bind_case_002_autoCreateTbl(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + checkResult(taos, "m3", 0, totalRowsPerTbl); + checkResult(taos, "m6", 0, totalRowsPerTbl); + checkResult(taos, "m9", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 9 check result end\n\n"); + } +#endif + + //========== case 10: ======================// +#if 1 + { + stmt = taos_stmt_init(taos); + + tableNum = 1; + rowsOfPerColum = 23740; + bingNum = 1; + lenOfBinaryDef = 40; + lenOfBinaryAct = 8; + columnNum = 5; + + prepareVcolumn_autoCreateTbl(taos, 1, tableNum, lenOfBinaryDef, "db10"); + stmt_specifyCol_bind_case_003_autoCreateTbl(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 10 check result end\n\n"); + } +#endif + + //========== case 11: ======================// +#if 1 + { + stmt = taos_stmt_init(taos); + + tableNum = 2; + rowsOfPerColum = 5; + bingNum = 1; + lenOfBinaryDef = 40; + lenOfBinaryAct = 8; + columnNum = 5; + + prepareVcolumn_autoCreateTbl(taos, 1, tableNum, lenOfBinaryDef, "db11"); + stmt_specifyCol_bind_case_003_autoCreateTbl(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + checkResult(taos, "m1", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 11 check result end\n\n"); + } +#endif + + //========== case 12: ======================// +#if 1 + { + stmt = taos_stmt_init(taos); + + tableNum = 200; + rowsOfPerColum = 60; + bingNum = 1; + lenOfBinaryDef = 40; + lenOfBinaryAct = 8; + columnNum = 5; + + prepareVcolumn_autoCreateTbl(taos, 1, tableNum, lenOfBinaryDef, "db12"); + stmt_specifyCol_bind_case_003_autoCreateTbl(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + checkResult(taos, "m1", 0, totalRowsPerTbl); + checkResult(taos, "m99", 0, totalRowsPerTbl); + checkResult(taos, "m139", 0, totalRowsPerTbl); + checkResult(taos, "m199", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 12 check result end\n\n"); + } +#endif + + + //========== case 13: ======================// +#if 1 + { + printf("====case 13 error test start\n"); + stmt = taos_stmt_init(taos); + + tableNum = 1; + rowsOfPerColum = 8; + bingNum = 1; + lenOfBinaryDef = 40; + lenOfBinaryAct = 8; + columnNum = 5; + + prepareVcolumn_autoCreateTbl(taos, 1, tableNum, lenOfBinaryDef, "db13"); + stmt_specifyCol_bind_case_004_autoCreateTbl(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("====case 13 check result end\n\n"); + } +#endif + + return ; + +} + + +/*=======================*/ +/* +char * taos_stmt_errstr(TAOS_STMT *stmt) 用于在其他stmt API 返回错误(返回错误码或空指针)时获取错误信息,返回的错误信息可能是以下3种的一个: +1. 当stmt或sqlobj为空时的terrno对于的错误消息; +2. (可有的)详细错误消息; +3. 返回的错误码对于的错误消息; +*/ +static int stmt_specifyCol_bind_error_case_001(TAOS_STMT *stmt, int tableNum, int rowsOfPerColum, int bingNum, int lenOfBinaryDef, int lenOfBinaryAct, int columnNum) { + sampleValue* v = (sampleValue *)calloc(1, sizeof(sampleValue)); + + int totalRowsPerTbl = rowsOfPerColum * bingNum; + + v->ts = (int64_t *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * tableNum)); + v->br = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef)); + v->nr = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef)); + + int *lb = (int *)malloc(MAX_ROWS_OF_PER_COLUMN * sizeof(int)); + + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * (size_t)(bingNum * columnNum * (tableNum+1) * rowsOfPerColum)); + char* is_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN); + char* no_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN); + + int64_t tts = 1591060628000; + + for (int i = 0; i < rowsOfPerColum; ++i) { + lb[i] = lenOfBinaryAct; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v->b[i] = (int8_t)(i % 2); + v->v1[i] = (int8_t)((i+1) % 2); + v->v2[i] = (int16_t)i; + v->v4[i] = (int32_t)(i+1); + v->v8[i] = (int64_t)(i+2); + v->f4[i] = (float)(i+3); + v->f8[i] = (double)(i+4); + char tbuf[MAX_BINARY_DEF_LEN]; + memset(tbuf, 0, MAX_BINARY_DEF_LEN); + sprintf(tbuf, "binary-%d-0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", i%10); + memcpy(v->br + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct); + memset(tbuf, 0, MAX_BINARY_DEF_LEN); + sprintf(tbuf, "nchar-%d-0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", i%10); + memcpy(v->nr + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct); + v->ts2[i] = tts + i; + } + + int i = 0; + for (int j = 0; j < bingNum * tableNum; j++) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v->ts[j*rowsOfPerColum]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = rowsOfPerColum; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v->b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = rowsOfPerColum; + + params[i+2].buffer_type = TSDB_DATA_TYPE_INT; + params[i+2].buffer_length = sizeof(int32_t); + params[i+2].buffer = v->v4; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = rowsOfPerColum; + + params[i+3].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+3].buffer_length = sizeof(float); + params[i+3].buffer = v->f4; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = rowsOfPerColum; + + params[i+4].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+4].buffer_length = (uintptr_t)lenOfBinaryDef; + params[i+4].buffer = v->br; + params[i+4].length = lb; + params[i+4].is_null = is_null; + params[i+4].num = rowsOfPerColum; + + i+=columnNum; + } + + //int64_t tts = 1591060628000; + for (int i = 0; i < totalRowsPerTbl * tableNum; ++i) { + v->ts[i] = tts + i; + } + + unsigned long long starttime = getCurrentTime(); + +// create table m%d (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, br binary(%d), nr nchar(%d), ts2 timestamp) + char *sql = "insert into m0 (ts,b,v4,f4,br) values(?,?,?,?,?)"; + + int code; + //TAOS_STMT *stmtNull = NULL; + //int code = taos_stmt_prepare(stmtNull, sql, 0); + //if (code != 0){ + // printf("failed to execute taos_stmt_prepare. code:0x%x[%s][%s]\n", code, tstrerror(code), taos_stmt_errstr(stmtNull)); + // return -1; + //} + + //char* sqlNull = NULL; + //code = taos_stmt_prepare(stmt, sqlNull, 0); + //if (code != 0){ + // printf("failed to execute taos_stmt_prepare. code:0x%x[%s][%s]\n", code, tstrerror(code), taos_stmt_errstr(stmt)); + //} + + code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x[%s][%s]\n", code, tstrerror(code), taos_stmt_errstr(stmt)); + return -1; + } + + int id = 0; + for (int l = 0; l < bingNum; l++) { + for (int zz = 0; zz < tableNum; zz++) { + //char buf[32]; + //sprintf(buf, "m%d", zz); + //code = taos_stmt_set_tbname(stmt, buf); + //if (code != 0){ + // printf("failed to execute taos_stmt_set_tbname. code:0x%x[%s]\n", code, tstrerror(code)); + // return -1; + //} + + //for (int col=0; col < columnNum + 1000; ++col) { + for (int col=0; col < columnNum; ++col) { + if (col >= columnNum) col = 0; + //code = taos_stmt_bind_single_param_batch(NULL, params + id, col); + //code = taos_stmt_bind_single_param_batch(stmt, NULL, col); + //code = taos_stmt_bind_single_param_batch(stmt, params + id, columnNum); + code = taos_stmt_bind_single_param_batch(stmt, params + id, col); + if (code != 0){ + printf("failed to execute taos_stmt_bind_single_param_batch. code:0x%x[%s][%s]\n", code, tstrerror(code), taos_stmt_errstr(stmt)); + return -1; + } + id++; + } + + //code = taos_stmt_add_batch(NULL); + code = taos_stmt_add_batch(stmt); + if (code != 0) { + printf("failed to execute taos_stmt_add_batch. code:0x%x[%s][%s]\n", code, tstrerror(code), taos_stmt_errstr(stmt)); + return -1; + } + + //code = taos_stmt_add_batch(stmt); + //if (code != 0) { + // printf("failed to execute taos_stmt_add_batch second. code:0x%x[%s][%s]\n", code, tstrerror(code), taos_stmt_errstr(stmt)); + // return -1; + //} + } + + code = taos_stmt_execute(stmt); + if (code != 0) { + printf("failed to execute taos_stmt_execute. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + } + + unsigned long long endtime = getCurrentTime(); + unsigned long long totalRows = (uint32_t)(totalRowsPerTbl * tableNum); + printf("insert total %d records, used %u seconds, avg:%u useconds per record\n", totalRows, (endtime-starttime)/1000000UL, (endtime-starttime)/totalRows); + + free(v->ts); + free(v->br); + free(v->nr); + free(v); + free(lb); + free(params); + free(is_null); + free(no_null); + + return 0; +} + +static int stmt_specifyCol_bind_error_case_002(TAOS_STMT *stmt, int tableNum, int rowsOfPerColum, int bingNum, int lenOfBinaryDef, int lenOfBinaryAct, int columnNum) { + sampleValue* v = (sampleValue *)calloc(1, sizeof(sampleValue)); + + int totalRowsPerTbl = rowsOfPerColum * bingNum; + + v->ts = (int64_t *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * tableNum)); + v->br = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef)); + v->nr = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef)); + + int *lb = (int *)malloc(MAX_ROWS_OF_PER_COLUMN * sizeof(int)); + + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * (size_t)(bingNum * columnNum * (tableNum+1) * rowsOfPerColum)); + char* is_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN); + char* no_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN); + + int64_t tts = 1591060628000; + + for (int i = 0; i < rowsOfPerColum; ++i) { + lb[i] = lenOfBinaryAct; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v->b[i] = (int8_t)(i % 2); + v->v1[i] = (int8_t)((i+1) % 2); + v->v2[i] = (int16_t)i; + v->v4[i] = (int32_t)(i+1); + v->v8[i] = (int64_t)(i+2); + v->f4[i] = (float)(i+3); + v->f8[i] = (double)(i+4); + char tbuf[MAX_BINARY_DEF_LEN]; + memset(tbuf, 0, MAX_BINARY_DEF_LEN); + sprintf(tbuf, "binary-%d", i%10); + memcpy(v->br + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct); + memset(tbuf, 0, MAX_BINARY_DEF_LEN); + sprintf(tbuf, "nchar-%d", i%10); + memcpy(v->nr + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct); + v->ts2[i] = tts + i; + } + + int i = 0; + for (int j = 0; j < bingNum * tableNum; j++) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v->ts[j*rowsOfPerColum]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = rowsOfPerColum; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v->b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = rowsOfPerColum; + + params[i+2].buffer_type = TSDB_DATA_TYPE_INT; + params[i+2].buffer_length = sizeof(int32_t); + params[i+2].buffer = v->v4; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = rowsOfPerColum; + + params[i+3].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+3].buffer_length = sizeof(float); + params[i+3].buffer = v->f4; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = rowsOfPerColum; + + params[i+4].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+4].buffer_length = (uintptr_t)lenOfBinaryDef; + params[i+4].buffer = v->br; + params[i+4].length = lb; + params[i+4].is_null = is_null; + params[i+4].num = rowsOfPerColum; + + i+=columnNum; + } + + //int64_t tts = 1591060628000; + for (int i = 0; i < totalRowsPerTbl * tableNum; ++i) { + v->ts[i] = tts + i; + } + + unsigned long long starttime = getCurrentTime(); + +// create table m%d (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, br binary(%d), nr nchar(%d), ts2 timestamp) + char *sql = "insert into ? (ts,b,v4,f4,br) values(?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + + int id = 0; + for (int l = 0; l < bingNum; l++) { + for (int zz = 0; zz < tableNum; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + + //stmt=NULL; + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x[%s][%s]\n", code, tstrerror(code), taos_stmt_errstr(stmt)); + return -1; + } + + for (int col=0; col < columnNum; ++col) { + code = taos_stmt_bind_single_param_batch(stmt, params + id, col); + if (code != 0){ + printf("failed to execute taos_stmt_bind_single_param_batch. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + id++; + } + + code = taos_stmt_add_batch(stmt); + if (code != 0) { + printf("failed to execute taos_stmt_add_batch. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + } + + code = taos_stmt_execute(stmt); + if (code != 0) { + printf("failed to execute taos_stmt_execute. code:0x%x[%s]\n", code, tstrerror(code)); + return -1; + } + } + + unsigned long long endtime = getCurrentTime(); + unsigned long long totalRows = (uint32_t)(totalRowsPerTbl * tableNum); + printf("insert total %d records, used %u seconds, avg:%u useconds per record\n", totalRows, (endtime-starttime)/1000000UL, (endtime-starttime)/totalRows); + + free(v->ts); + free(v->br); + free(v->nr); + free(v); + free(lb); + free(params); + free(is_null); + free(no_null); + + return 0; +} + +static void SpecifyColumnBatchErrorCase(TAOS *taos) { + TAOS_STMT *stmt = NULL; + + int tableNum; + int lenOfBinaryDef; + int rowsOfPerColum; + int bingNum; + int lenOfBinaryAct; + int columnNum; + + int totalRowsPerTbl; + +//=======================================================================// +//=============================== single table ==========================// +//========== case 1: ======================// +#if 0 +{ + stmt = taos_stmt_init(taos); + + tableNum = 1; + rowsOfPerColum = 1; + bingNum = 1; + lenOfBinaryDef = 40; + lenOfBinaryAct = 8; + columnNum = 5; + + prepareVcolumn(taos, 1, tableNum, lenOfBinaryDef, "db1"); + stmt_specifyCol_bind_error_case_001(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 1 check result end\n\n"); +} +#endif + + //========== case 2: ======================// +#if 1 +{ + stmt = taos_stmt_init(taos); + + tableNum = 1; + rowsOfPerColum = 5; + bingNum = 1; + lenOfBinaryDef = 1000; + lenOfBinaryAct = 15; + columnNum = 5; + + prepareVcolumn(taos, 1, tableNum, lenOfBinaryDef, "db2"); + stmt_specifyCol_bind_error_case_002(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + //checkResult(taos, "m1", 0, totalRowsPerTbl); + //checkResult(taos, "m2", 0, totalRowsPerTbl); + //checkResult(taos, "m3", 0, totalRowsPerTbl); + //checkResult(taos, "m4", 0, totalRowsPerTbl); + //checkResult(taos, "m5", 0, totalRowsPerTbl); + //checkResult(taos, "m6", 0, totalRowsPerTbl); + //checkResult(taos, "m7", 0, totalRowsPerTbl); + //checkResult(taos, "m8", 0, totalRowsPerTbl); + //checkResult(taos, "m9", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 2 check result end\n\n"); +} +#endif + + //========== case 2-1: ======================// +#if 0 + { + stmt = taos_stmt_init(taos); + + tableNum = 1; + rowsOfPerColum = 32767; + bingNum = 1; + lenOfBinaryDef = 1000; + lenOfBinaryAct = 15; + columnNum = 5; + + prepareVcolumn(taos, 1, tableNum, lenOfBinaryDef, "db2_1"); + stmt_specifyCol_bind_case_001(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + //checkResult(taos, "m1", 0, totalRowsPerTbl); + //checkResult(taos, "m2", 0, totalRowsPerTbl); + //checkResult(taos, "m3", 0, totalRowsPerTbl); + //checkResult(taos, "m4", 0, totalRowsPerTbl); + //checkResult(taos, "m5", 0, totalRowsPerTbl); + //checkResult(taos, "m6", 0, totalRowsPerTbl); + //checkResult(taos, "m7", 0, totalRowsPerTbl); + //checkResult(taos, "m8", 0, totalRowsPerTbl); + //checkResult(taos, "m9", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 2-1 check result end\n\n"); + } +#endif + //========== case 2-2: ======================// +#if 0 + { + printf("====case 2-2 error test start\n"); + stmt = taos_stmt_init(taos); + + tableNum = 1; + rowsOfPerColum = 32768; + bingNum = 1; + lenOfBinaryDef = 1000; + lenOfBinaryAct = 15; + columnNum = 5; + + prepareVcolumn(taos, 1, tableNum, lenOfBinaryDef, "db2_2"); + stmt_specifyCol_bind_case_001(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + //checkResult(taos, "m1", 0, totalRowsPerTbl); + //checkResult(taos, "m2", 0, totalRowsPerTbl); + //checkResult(taos, "m3", 0, totalRowsPerTbl); + //checkResult(taos, "m4", 0, totalRowsPerTbl); + //checkResult(taos, "m5", 0, totalRowsPerTbl); + //checkResult(taos, "m6", 0, totalRowsPerTbl); + //checkResult(taos, "m7", 0, totalRowsPerTbl); + //checkResult(taos, "m8", 0, totalRowsPerTbl); + //checkResult(taos, "m9", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("====case 2-2 check result end\n\n"); + } +#endif + + + //========== case 3: ======================// +#if 0 + { + stmt = taos_stmt_init(taos); + + tableNum = 1; + rowsOfPerColum = 1; + bingNum = 5; + lenOfBinaryDef = 1000; + lenOfBinaryAct = 20; + columnNum = 5; + + prepareVcolumn(taos, 1, tableNum, lenOfBinaryDef, "db3"); + stmt_specifyCol_bind_case_001(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + //checkResult(taos, "m1", 0, totalRowsPerTbl); + //checkResult(taos, "m2", 0, totalRowsPerTbl); + //checkResult(taos, "m3", 0, totalRowsPerTbl); + //checkResult(taos, "m4", 0, totalRowsPerTbl); + //checkResult(taos, "m5", 0, totalRowsPerTbl); + //checkResult(taos, "m6", 0, totalRowsPerTbl); + //checkResult(taos, "m7", 0, totalRowsPerTbl); + //checkResult(taos, "m8", 0, totalRowsPerTbl); + //checkResult(taos, "m9", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 3 check result end\n\n"); + } +#endif + + //========== case 4: ======================// +#if 0 + { + stmt = taos_stmt_init(taos); + + tableNum = 1; + rowsOfPerColum = 5; + bingNum = 5; + lenOfBinaryDef = 1000; + lenOfBinaryAct = 33; + columnNum = 5; + + prepareVcolumn(taos, 1, tableNum, lenOfBinaryDef, "db4"); + stmt_specifyCol_bind_case_001(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + //checkResult(taos, "m1", 0, totalRowsPerTbl); + //checkResult(taos, "m2", 0, totalRowsPerTbl); + //checkResult(taos, "m3", 0, totalRowsPerTbl); + //checkResult(taos, "m4", 0, totalRowsPerTbl); + //checkResult(taos, "m5", 0, totalRowsPerTbl); + //checkResult(taos, "m6", 0, totalRowsPerTbl); + //checkResult(taos, "m7", 0, totalRowsPerTbl); + //checkResult(taos, "m8", 0, totalRowsPerTbl); + //checkResult(taos, "m9", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 4 check result end\n\n"); + } +#endif + +//=======================================================================// +//=============================== multi tables ==========================// + //========== case 5: ======================// +#if 0 + { + stmt = taos_stmt_init(taos); + + tableNum = 5; + rowsOfPerColum = 1; + bingNum = 1; + lenOfBinaryDef = 40; + lenOfBinaryAct = 16; + columnNum = 5; + + prepareVcolumn(taos, 1, tableNum, lenOfBinaryDef, "db5"); + stmt_specifyCol_bind_case_002(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + checkResult(taos, "m1", 0, totalRowsPerTbl); + checkResult(taos, "m2", 0, totalRowsPerTbl); + checkResult(taos, "m3", 0, totalRowsPerTbl); + checkResult(taos, "m4", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 5 check result end\n\n"); + } +#endif + + //========== case 6: ======================// +#if 0 + { + stmt = taos_stmt_init(taos); + + tableNum = 5; + rowsOfPerColum = 5; + bingNum = 1; + lenOfBinaryDef = 1000; + lenOfBinaryAct = 20; + columnNum = 5; + + prepareVcolumn(taos, 1, tableNum, lenOfBinaryDef, "db6"); + stmt_specifyCol_bind_case_002(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + checkResult(taos, "m1", 0, totalRowsPerTbl); + checkResult(taos, "m2", 0, totalRowsPerTbl); + checkResult(taos, "m3", 0, totalRowsPerTbl); + checkResult(taos, "m4", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 6 check result end\n\n"); + } +#endif + + //========== case 7: ======================// +#if 0 + { + stmt = taos_stmt_init(taos); + + tableNum = 5; + rowsOfPerColum = 1; + bingNum = 5; + lenOfBinaryDef = 1000; + lenOfBinaryAct = 33; + columnNum = 5; + + prepareVcolumn(taos, 1, tableNum, lenOfBinaryDef, "db7"); + stmt_specifyCol_bind_case_002(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + checkResult(taos, "m1", 0, totalRowsPerTbl); + checkResult(taos, "m2", 0, totalRowsPerTbl); + checkResult(taos, "m3", 0, totalRowsPerTbl); + checkResult(taos, "m4", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 7 check result end\n\n"); + } +#endif + + //========== case 8: ======================// +#if 0 +{ + stmt = taos_stmt_init(taos); + + tableNum = 5; + rowsOfPerColum = 5; + bingNum = 5; + lenOfBinaryDef = 1000; + lenOfBinaryAct = 40; + columnNum = 5; + + prepareVcolumn(taos, 1, tableNum, lenOfBinaryDef, "db8"); + stmt_specifyCol_bind_case_002(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + checkResult(taos, "m1", 0, totalRowsPerTbl); + checkResult(taos, "m2", 0, totalRowsPerTbl); + checkResult(taos, "m3", 0, totalRowsPerTbl); + checkResult(taos, "m4", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 8 check result end\n\n"); +} +#endif + + //=======================================================================// + //=============================== multi-rows to single table ==========================// + //========== case 9: ======================// +#if 0 + { + stmt = taos_stmt_init(taos); + + tableNum = 1; + rowsOfPerColum = 23740; + bingNum = 1; + lenOfBinaryDef = 40; + lenOfBinaryAct = 8; + columnNum = 5; + + prepareVcolumn(taos, 1, tableNum, lenOfBinaryDef, "db9"); + stmt_specifyCol_bind_case_001(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum); + + totalRowsPerTbl = rowsOfPerColum * bingNum; + checkResult(taos, "m0", 0, totalRowsPerTbl); + taos_stmt_close(stmt); + printf("case 9 check result end\n\n"); + } +#endif + + return ; + +} + +int main(int argc, char *argv[]) +{ + TAOS *taos; + char host[32] = "127.0.0.1"; + char* serverIp = NULL; + //int threadNum = 1; + + // connect to server + if (argc == 1) { + serverIp = host; + } else if (argc == 2) { + serverIp = argv[1]; + } else if (argc == 3) { + serverIp = argv[1]; + //threadNum = atoi(argv[2]); + } else if (argc == 4) { + serverIp = argv[1]; + //threadNum = atoi(argv[2]); + g_runTimes = atoi(argv[3]); + } + + printf("server:%s, runTimes:%d\n\n", serverIp, g_runTimes); + +#if 0 + printf("server:%s, threadNum:%d, rows:%d\n\n", serverIp, threadNum, g_rows); + + pthread_t *pThreadList = (pthread_t *) calloc(sizeof(pthread_t), (size_t)threadNum); + ThreadInfo* threadInfo = (ThreadInfo *) calloc(sizeof(ThreadInfo), (size_t)threadNum); + + ThreadInfo* tInfo = threadInfo; + for (int i = 0; i < threadNum; i++) { + taos = taos_connect(serverIp, "root", "taosdata", NULL, 0); + if (taos == NULL) { + printf("failed to connect to TDengine, reason:%s\n", taos_errstr(taos)); + return -1; + } + + tInfo->taos = taos; + tInfo->idx = i; + if (0 == i) { + //pthread_create(&(pThreadList[0]), NULL, runCase, (void *)tInfo); + pthread_create(&(pThreadList[0]), NULL, SpecifyColumnBatchCase, (void *)tInfo); + } else if (1 == i){ + pthread_create(&(pThreadList[0]), NULL, runCase_long, (void *)tInfo); + } + tInfo++; + } + + for (int i = 0; i < threadNum; i++) { + pthread_join(pThreadList[i], NULL); + } + + free(pThreadList); + free(threadInfo); +#endif + + taos = taos_connect(serverIp, "root", "taosdata", NULL, 0); + if (taos == NULL) { + printf("failed to connect to TDengine, reason:%s\n", taos_errstr(taos)); + return -1; + } + + //runCase(taos); + //runCase_long(taos); + //SpecifyColumnBatchCase(taos); + SpecifyColumnBatchCase_autoCreateTbl(taos); + //SpecifyColumnBatchErrorCase(taos); + return 0; +} + diff --git a/tests/script/api/stmtTest.c b/tests/script/api/stmtTest.c new file mode 100644 index 0000000000000000000000000000000000000000..9595fe5b2d72e3291959828badf45abc2f7cb71e --- /dev/null +++ b/tests/script/api/stmtTest.c @@ -0,0 +1,238 @@ +#include +#include +#include +#include "taos.h" +#include +#include +#include + +#define PRINT_ERROR printf("\033[31m"); +#define PRINT_SUCCESS printf("\033[32m"); + +void execute_simple_sql(void *taos, char *sql) { + TAOS_RES *result = taos_query(taos, sql); + if ( result == NULL || taos_errno(result) != 0) { + PRINT_ERROR + printf("failed to %s, Reason: %s\n", sql, taos_errstr(result)); + taos_free_result(result); + exit(EXIT_FAILURE); + } + taos_free_result(result); + PRINT_SUCCESS + printf("Successfully %s\n", sql); +} + +void check_result(TAOS *taos, int id, int expected) { + char sql[256] = {0}; + sprintf(sql, "select * from t%d", id); + TAOS_RES *result; + result = taos_query(taos, sql); + if ( result == NULL || taos_errno(result) != 0) { + PRINT_ERROR + printf("failed to %s, Reason: %s\n", sql, taos_errstr(result)); + exit(EXIT_FAILURE); + } + PRINT_SUCCESS + printf("Successfully execute %s\n", sql); + int rows = 0; + TAOS_ROW row; + while ((row = taos_fetch_row(result))) { + rows++; + } + if (rows == expected) { + PRINT_SUCCESS + printf("table t%d's %d rows are fetched as expected\n", id, rows); + } else { + PRINT_ERROR + printf("table t%d's %d rows are fetched but %d expected\n", id, rows, expected); + } + taos_free_result(result); +} + +int main(int argc, char *argv[]) { + void *taos = taos_connect("127.0.0.1", "root", "taosdata", NULL, 0); + if (taos == NULL) { + PRINT_ERROR + printf("TDengine error: failed to connect\n"); + exit(EXIT_FAILURE); + } + PRINT_SUCCESS + printf("Successfully connected to TDengine\n"); + + execute_simple_sql(taos, "drop database if exists test"); + execute_simple_sql(taos, "create database test"); + execute_simple_sql(taos, "use test"); + execute_simple_sql(taos, "create table super(ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 binary(8), c6 smallint, c7 tinyint, c8 bool, c9 nchar(8), c10 timestamp) tags (t1 int, t2 bigint, t3 float, t4 double, t5 binary(8), t6 smallint, t7 tinyint, t8 bool, t9 nchar(8))"); + + char *sql = calloc(1, 1024*1024); + int sqlLen = 0; + sqlLen = sprintf(sql, "create table"); + for (int i = 0; i < 10; i++) { + sqlLen += sprintf(sql + sqlLen, " t%d using super tags (%d, 2147483648, 0.1, 0.000000001, 'abcdefgh', 32767, 127, 1, '一二三四五六七八')", i, i); + } + execute_simple_sql(taos, sql); + + + int code = taos_load_table_info(taos, "t0,t1,t2,t3,t4,t5,t6,t7,t8,t9"); + if (code != 0) { + PRINT_ERROR + printf("failed to load table info: 0x%08x\n", code); + exit(EXIT_FAILURE); + } + PRINT_SUCCESS + printf("Successfully load table info\n"); + + TAOS_STMT *stmt = taos_stmt_init(taos); + if (stmt == NULL) { + PRINT_ERROR + printf("TDengine error: failed to init taos_stmt\n"); + exit(EXIT_FAILURE); + } + PRINT_SUCCESS + printf("Successfully init taos_stmt\n"); + + uintptr_t c10len = 0; + struct { + int64_t c1; + int32_t c2; + int64_t c3; + float c4; + double c5; + unsigned char c6[8]; + int16_t c7; + int8_t c8; + int8_t c9; + char c10[32]; + } v = {0}; + TAOS_BIND params[11]; + params[0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[0].buffer_length = sizeof(v.c1); + params[0].buffer = &v.c1; + params[0].length = ¶ms[0].buffer_length; + params[0].is_null = NULL; + + params[1].buffer_type = TSDB_DATA_TYPE_INT; + params[1].buffer_length = sizeof(v.c2); + params[1].buffer = &v.c2; + params[1].length = ¶ms[1].buffer_length; + params[1].is_null = NULL; + + params[2].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[2].buffer_length = sizeof(v.c3); + params[2].buffer = &v.c3; + params[2].length = ¶ms[2].buffer_length; + params[2].is_null = NULL; + + params[3].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[3].buffer_length = sizeof(v.c4); + params[3].buffer = &v.c4; + params[3].length = ¶ms[3].buffer_length; + params[3].is_null = NULL; + + params[4].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[4].buffer_length = sizeof(v.c5); + params[4].buffer = &v.c5; + params[4].length = ¶ms[4].buffer_length; + params[4].is_null = NULL; + + params[5].buffer_type = TSDB_DATA_TYPE_BINARY; + params[5].buffer_length = sizeof(v.c6); + params[5].buffer = &v.c6; + params[5].length = ¶ms[5].buffer_length; + params[5].is_null = NULL; + + params[6].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[6].buffer_length = sizeof(v.c7); + params[6].buffer = &v.c7; + params[6].length = ¶ms[6].buffer_length; + params[6].is_null = NULL; + + params[7].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[7].buffer_length = sizeof(v.c8); + params[7].buffer = &v.c8; + params[7].length = ¶ms[7].buffer_length; + params[7].is_null = NULL; + + params[8].buffer_type = TSDB_DATA_TYPE_BOOL; + params[8].buffer_length = sizeof(v.c9); + params[8].buffer = &v.c9; + params[8].length = ¶ms[8].buffer_length; + params[8].is_null = NULL; + + params[9].buffer_type = TSDB_DATA_TYPE_NCHAR; + params[9].buffer_length = sizeof(v.c10); + params[9].buffer = &v.c10; + params[9].length = &c10len; + params[9].is_null = NULL; + + params[10].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[10].buffer_length = sizeof(v.c1); + params[10].buffer = &v.c1; + params[10].length = ¶ms[10].buffer_length; + params[10].is_null = NULL; + + char *stmt_sql = "insert into ? values (?,?,?,?,?,?,?,?,?,?,?)"; + code = taos_stmt_prepare(stmt, stmt_sql, 0); + if (code != 0){ + PRINT_ERROR + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + exit(EXIT_FAILURE); + } + PRINT_SUCCESS + printf("Successfully execute taos_stmt_prepare\n"); + + for (int i = 0; i < 10; i++) { + char buf[32]; + sprintf(buf, "t%d", i); + if (i == 0) { + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0) { + PRINT_ERROR + printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code); + exit(EXIT_FAILURE); + } + PRINT_SUCCESS + printf("Successfully execute taos_stmt_set_tbname\n"); + } else { + code = taos_stmt_set_sub_tbname(stmt, buf); + if (code != 0) { + PRINT_ERROR + printf("failed to execute taos_stmt_set_sub_tbname. code:0x%x\n", code); + exit(EXIT_FAILURE); + } + PRINT_SUCCESS + printf("Successfully execute taos_stmt_set_sub_tbname\n"); + } + + v.c1 = (int64_t)1591060628000; + v.c2 = (int32_t)2147483647; + v.c3 = (int64_t)2147483648; + v.c4 = (float)0.1; + v.c5 = (double)0.000000001; + for (int j = 0; j < sizeof(v.c6); j++) { + v.c6[j] = (char)('a'); + } + v.c7 = 32767; + v.c8 = 127; + v.c9 = 1; + strcpy(v.c10, "一二三四五六七八"); + c10len=strlen(v.c10); + taos_stmt_bind_param(stmt, params); + taos_stmt_add_batch(stmt); + } + + if (taos_stmt_execute(stmt) != 0) { + PRINT_ERROR + printf("failed to execute insert statement.\n"); + exit(EXIT_FAILURE); + } + PRINT_SUCCESS + printf("Successfully execute insert statement.\n"); + + taos_stmt_close(stmt); + for (int i = 0; i < 10; i++) { + check_result(taos, i, 1); + } + + return 0; +} diff --git a/tests/script/basicSuite.sim b/tests/script/basicSuite.sim new file mode 100644 index 0000000000000000000000000000000000000000..5e22e02297bba63ec023780e425019f713dfd8d8 --- /dev/null +++ b/tests/script/basicSuite.sim @@ -0,0 +1,19 @@ +run general/cache/new_metrics.sim +run general/compute/interval.sim +run general/http/restful_full.sim +run general/import/commit.sim +run general/import/replica1.sim +run general/parser/auto_create_tb_drop_tb.sim +run general/parser/binary_escapeCharacter.sim +run general/parser/select_from_cache_disk.sim +run general/parser/null_char.sim +run general/parser/alter.sim +run general/stable/vnode3.sim +run general/tag/filter.sim +run general/table/vgroup.sim +run general/user/authority.sim +run general/vector/metrics_mix.sim +run general/vector/table_field.sim +run general/tag/set.sim +run general/table/delete_writing.sim +run general/stable/disk.sim diff --git a/tests/script/bug.sim b/tests/script/bug.sim new file mode 100644 index 0000000000000000000000000000000000000000..625b9b0cadb78f8d75e8611dbf60664f9cf7e65a --- /dev/null +++ b/tests/script/bug.sim @@ -0,0 +1,2 @@ +run general/parser/projection_limit_offset.sim +run general/parser/limit2.sim \ No newline at end of file diff --git a/tests/script/fullGeneralSuite.sim b/tests/script/fullGeneralSuite.sim new file mode 100644 index 0000000000000000000000000000000000000000..34b426752ab0953fec0f648c01c6effde317342b --- /dev/null +++ b/tests/script/fullGeneralSuite.sim @@ -0,0 +1,226 @@ +#unsupport run general/alter/cached_schema_after_alter.sim +run general/alter/count.sim +run general/alter/import.sim +#unsupport run general/alter/insert1.sim +run general/alter/insert2.sim +run general/alter/metrics.sim +run general/alter/table.sim +run general/cache/new_metrics.sim +run general/cache/restart_metrics.sim +run general/cache/restart_table.sim +run general/connection/connection.sim +run general/column/commit.sim +run general/column/metrics.sim +run general/column/table.sim +run general/compress/commitlog.sim +run general/compress/compress.sim +run general/compress/compress2.sim +run general/compress/uncompress.sim +run general/compute/avg.sim +run general/compute/bottom.sim +run general/compute/count.sim +run general/compute/diff.sim +run general/compute/diff2.sim +run general/compute/first.sim +run general/compute/interval.sim +run general/compute/last.sim +run general/compute/last_row.sim +run general/compute/leastsquare.sim +run general/compute/max.sim +run general/compute/min.sim +run general/compute/null.sim +run general/compute/percentile.sim +run general/compute/stddev.sim +run general/compute/sum.sim +run general/compute/top.sim +run general/compute/block_dist.sim +run general/db/alter_option.sim +run general/db/alter_tables_d2.sim +run general/db/alter_tables_v1.sim +run general/db/alter_tables_v4.sim +run general/db/alter_vgroups.sim +run general/db/basic.sim +run general/db/basic1.sim +run general/db/basic2.sim +run general/db/basic3.sim +run general/db/basic4.sim +run general/db/basic5.sim +run general/db/delete_reuse1.sim +run general/db/delete_reuse2.sim +run general/db/delete_reusevnode.sim +run general/db/delete_reusevnode2.sim +run general/db/delete_writing1.sim +run general/db/delete_writing2.sim +run general/db/delete.sim +run general/db/len.sim +run general/db/repeat.sim +run general/db/tables.sim +run general/db/vnodes.sim +run general/field/2.sim +run general/field/3.sim +run general/field/4.sim +run general/field/5.sim +run general/field/6.sim +run general/field/bigint.sim +run general/field/binary.sim +run general/field/bool.sim +run general/field/single.sim +run general/field/smallint.sim +run general/field/tinyint.sim +run general/http/restful.sim +run general/http/restful_insert.sim +run general/http/restful_limit.sim +run general/http/restful_full.sim +run general/http/prepare.sim +run general/http/telegraf.sim +run general/http/grafana_bug.sim +run general/http/grafana.sim +run general/import/basic.sim +run general/import/commit.sim +run general/import/large.sim +run general/import/replica1.sim +run general/insert/basic.sim +run general/insert/insert_drop.sim +run general/insert/query_block1_memory.sim +run general/insert/query_block2_memory.sim +run general/insert/query_block1_file.sim +run general/insert/query_block2_file.sim +run general/insert/query_file_memory.sim +run general/insert/query_multi_file.sim +run general/insert/tcp.sim +#unsupport run general/parser/alter.sim +run general/parser/alter1.sim +run general/parser/alter_stable.sim +run general/parser/auto_create_tb.sim +run general/parser/auto_create_tb_drop_tb.sim +run general/parser/col_arithmetic_operation.sim +run general/parser/columnValue.sim +run general/parser/commit.sim +run general/parser/create_db.sim +run general/parser/create_mt.sim +run general/parser/create_tb.sim +run general/parser/dbtbnameValidate.sim +run general/parser/import_commit1.sim +run general/parser/import_commit2.sim +run general/parser/import_commit3.sim +run general/parser/insert_tb.sim +run general/parser/first_last.sim +run general/parser/line_insert.sim +#unsupport run general/parser/import_file.sim +run general/parser/lastrow.sim +run general/parser/nchar.sim +#unsupport run general/parser/null_char.sim +run general/parser/single_row_in_tb.sim +run general/parser/select_from_cache_disk.sim +run general/parser/limit.sim +run general/parser/limit1.sim +run general/parser/limit1_tblocks100.sim +run general/parser/mixed_blocks.sim +run general/parser/selectResNum.sim +run general/parser/select_across_vnodes.sim +run general/parser/slimit1.sim +run general/parser/tbnameIn.sim +run general/parser/binary_escapeCharacter.sim +run general/parser/projection_limit_offset.sim +run general/parser/limit2.sim +run general/parser/slimit.sim +run general/parser/fill.sim +run general/parser/fill_stb.sim +run general/parser/interp.sim +run general/parser/where.sim +run general/parser/join.sim +run general/parser/join_multivnode.sim +run general/parser/select_with_tags.sim +run general/parser/groupby.sim +run general/parser/top_groupby.sim +run general/parser/tags_dynamically_specifiy.sim +run general/parser/set_tag_vals.sim +#unsupport run general/parser/repeatAlter.sim +#unsupport run general/parser/slimit_alter_tags.sim +run general/parser/precision_ns.sim +run general/stable/disk.sim +run general/stable/dnode3.sim +run general/stable/metrics.sim +run general/stable/values.sim +run general/stable/vnode3.sim +run general/table/autocreate.sim +run general/table/basic1.sim +run general/table/basic2.sim +run general/table/basic3.sim +run general/table/bigint.sim +run general/table/binary.sim +run general/table/bool.sim +run general/table/column_name.sim +run general/table/column_num.sim +run general/table/column_value.sim +run general/table/column2.sim +run general/table/date.sim +run general/table/db.table.sim +run general/table/delete_reuse1.sim +run general/table/delete_reuse2.sim +run general/table/delete_writing.sim +run general/table/describe.sim +run general/table/double.sim +run general/table/fill.sim +run general/table/float.sim +run general/table/int.sim +run general/table/limit.sim +run general/table/smallint.sim +run general/table/table_len.sim +run general/table/table.sim +run general/table/tinyint.sim +run general/table/vgroup.sim +run general/tag/3.sim +run general/tag/4.sim +run general/tag/5.sim +run general/tag/6.sim +run general/tag/add.sim +run general/tag/bigint.sim +run general/tag/binary_binary.sim +run general/tag/binary.sim +run general/tag/bool_binary.sim +run general/tag/bool_int.sim +run general/tag/bool.sim +run general/tag/change.sim +run general/tag/column.sim +#unsupport run general/tag/commit.sim +run general/tag/create.sim +run general/tag/delete.sim +run general/tag/double.sim +run general/tag/filter.sim +run general/tag/float.sim +run general/tag/int_binary.sim +run general/tag/int_float.sim +run general/tag/int.sim +run general/tag/set.sim +run general/tag/smallint.sim +run general/tag/tinyint.sim +run general/user/authority.sim +run general/user/monitor.sim +run general/user/pass_alter.sim +run general/user/pass_len.sim +run general/user/user_create.sim +run general/user/user_len.sim +run general/vector/metrics_field.sim +run general/vector/metrics_mix.sim +run general/vector/metrics_query.sim +run general/vector/metrics_tag.sim +run general/vector/metrics_time.sim +run general/vector/multi.sim +run general/vector/single.sim +run general/vector/table_field.sim +run general/vector/table_mix.sim +run general/vector/table_query.sim +run general/vector/table_time.sim +run general/stream/restart_stream.sim +run general/stream/stream_3.sim +run general/stream/stream_restart.sim +run general/stream/table_del.sim +run general/stream/metrics_del.sim +run general/stream/table_replica1_vnoden.sim +run general/stream/metrics_replica1_vnoden.sim +run general/db/show_create_db.sim +run general/db/show_create_table.sim +run general/parser/like.sim +run general/parser/interp_blocks.sim +run general/parser/create_tb_with_timestamp_tag.sim diff --git a/tests/script/general/alter/cached_schema_after_alter.sim b/tests/script/general/alter/cached_schema_after_alter.sim new file mode 100644 index 0000000000000000000000000000000000000000..96ee4390845450d53508cc90c48a3148a0a827dd --- /dev/null +++ b/tests/script/general/alter/cached_schema_after_alter.sim @@ -0,0 +1,123 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +$db = csaa_db +$stb = csaastb +$tb1 = csaatb1 +$tb2 = csaatb2 + +$ts0 = 1537146000000 +$delta = 600000 +print ========== cached_schema_after_alter.sim + +sql drop database $db -x step1 +step1: +sql create database $db +print ====== create tables +sql use $db + +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +sql create table $tb1 using $stb tags( 1 ) +sql create table $tb2 using $stb tags( 2 ) + +sql_error alter table $tb1 add column c0 int +sql alter table $stb add column c2 int + +sql insert into $tb2 values ( $ts0 , 1, 1) +sql select * from $stb +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi + +sql select * from $tb2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed +sleep 3000 +sql connect + +sql use $db +sql select * from $stb +print select * from $stb ==> $data00 $data01 $data02 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi + +sql select * from $tb2 +print select * from $tb2 ==> $data00 $data01 $data02 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi + +$ts = $ts0 + $delta +sql insert into $tb2 values ( $ts , 2, 2) +sql select * from $stb order by ts asc +if $rows != 2 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 2 then + return -1 +endi + +sql select * from $tb2 order by ts asc +if $rows != 2 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 2 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/alter/count.sim b/tests/script/general/alter/count.sim new file mode 100644 index 0000000000000000000000000000000000000000..fc936668b8ea08f9cd08874ad98668a4d8904315 --- /dev/null +++ b/tests/script/general/alter/count.sim @@ -0,0 +1,266 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 + +print ========= start dnode1 as master +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ======== step1 +sql create database d1 replica 1 days 7 keep 50 +sql use d1 +sql create table tb (ts timestamp, a int) +sql insert into tb values(now-28d, -28) +sql insert into tb values(now-27d, -27) +sql insert into tb values(now-26d, -26) +sql select count(a) from tb +if $data00 != 3 then + return -1 +endi + +print ======== step2 +sql alter table tb add column b smallint +sql insert into tb values(now-25d, -25, 0) +sql insert into tb values(now-24d, -24, 1) +sql insert into tb values(now-23d, -23, 2) +sql select count(b) from tb +if $data00 != 3 then + return -1 +endi + +print ======== step3 +# sql alter table tb(ts timestamp, a int, b smallint, c tinyint) +sql alter table tb add column c tinyint +sql insert into tb values(now-22d, -22, 3, 0) +sql insert into tb values(now-21d, -21, 4, 1) +sql insert into tb values(now-20d, -20, 5, 2) +sql select count(c) from tb +if $data00 != 3 then + return -1 +endi + +print ======== step4 +# sql alter table tb(ts timestamp, a int, b smallint, c tinyint, d int) +sql alter table tb add column d int +sql insert into tb values(now-19d, -19, 6, 0, 0) +sql insert into tb values(now-18d, -18, 7, 1, 1) +sql insert into tb values(now-17d, -17, 8, 2, 2) +sql select count(d) from tb +if $data00 != 3 then + return -1 +endi + +print ======== step5 +# sql alter table tb(ts timestamp, a int, b smallint, c tinyint, d int, e bigint) +sql alter table tb add column e bigint +sql insert into tb values(now-16d, -16, 9, 0, 0, 0) +sql insert into tb values(now-15d, -15, 10, 1, 1, 1) +sql insert into tb values(now-14d, -14, 11, 2, 2, 2) +sql select count(e) from tb +if $data00 != 3 then + return -1 +endi + +print ======== step6 +# sql alter table tb(ts timestamp, a int, b smallint, c tinyint, d int, e bigint, f float) +sql alter table tb add column f float +sql insert into tb values(now-13d, -13, 12, 0, 0, 0, 0) +sql insert into tb values(now-12d, -12, 13, 1, 1, 1, 1) +sql insert into tb values(now-11d, -11, 24, 2, 2, 2, 2) +sql select count(f) from tb +if $data00 != 3 then + return -1 +endi + +print ======== step7 +# sql alter table tb(ts timestamp, a int, b smallint, c tinyint, d int, e bigint, f float, g double) +sql alter table tb add column g double +sql insert into tb values(now-10d, -10, 15, 0, 0, 0, 0, 0) +sql insert into tb values(now-9d, -9, 16, 1, 1, 1, 1, 1) +sql insert into tb values(now-8d, -8, 17, 2, 2, 2, 2, 2) +sql select count(g) from tb +if $data00 != 3 then + return -1 +endi + +print ======== step8 +# sql alter table tb(ts timestamp, a int, b smallint, c tinyint, d int, e bigint, f float, g double, h binary(10) ) +sql alter table tb add column h binary(10) +sql insert into tb values(now-7d, -7, 18, 0, 0, 0, 0, 0, '0') +sql insert into tb values(now-6d, -6, 19, 1, 1, 1, 1, 1, '1') +sql insert into tb values(now-5d, -5, 20, 2, 2, 2, 2, 2, '2') +sql select count(h) from tb +if $data00 != 3 then + return -1 +endi + +print ======== step9 +sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb +if $data00 != 24 then + return -1 +endi + +sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb +if $data01 != 21 then + return -1 +endi + +sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb +if $data02 != 18 then + return -1 +endi + +sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb +if $data03 != 15 then + return -1 +endi + +sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb +if $data04 != 12 then + return -1 +endi + +sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb +if $data05 != 9 then + return -1 +endi + +sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb +if $data06 != 6 then + return -1 +endi + +sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb +if $data07 != 3 then + return -1 +endi + +print ============= step10 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb +if $data00 != 24 then + return -1 +endi + +sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb +if $data01 != 21 then + return -1 +endi + +sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb +if $data02 != 18 then + return -1 +endi + +sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb +if $data03 != 15 then + return -1 +endi + +sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb +if $data04 != 12 then + return -1 +endi + +sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb +if $data05 != 9 then + return -1 +endi + +sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb +if $data06 != 6 then + return -1 +endi + +sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb +if $data07 != 3 then + return -1 +endi + +print ======== step11 +#sql alter table tb(ts timestamp, b smallint, c tinyint, d int, e bigint, f float, g double, h binary(20)) +sql alter table tb drop column a +sql insert into tb values(now-4d, 1, 1, 1, 1, 1, 1, '1') +sql select count(g) from tb +if $data00 != 7 then + return -1 +endi + +print ======== step12 +#sql alter table tb(ts timestamp, c tinyint, d int, e bigint, f float, g double, h binary(20)) +sql alter table tb drop column b +sql insert into tb values(now-3d, 1, 1, 1, 1, 1, '1') +sql select count(g) from tb +if $data00 != 8 then + return -1 +endi + +print ======== step13 +#sql alter table tb(ts timestamp, d int, e bigint, f float, g double, h binary(20)) +sql alter table tb drop column c +sql insert into tb values(now-2d, 1, 1, 1, 1, '1') +sql select count(g) from tb +if $data00 != 9 then + return -1 +endi + +print ======== step14 +#sql alter table tb(ts timestamp, e bigint, f float, g double, h binary(20)) +sql alter table tb drop column d +sql insert into tb values(now-1d, 1, 1, 1, '1') +sql select count(g) from tb +if $data00 != 10 then + return -1 +endi + +print ======== step15 +#sql alter table tb(ts timestamp, f float, g double, h binary(20)) +sql alter table tb drop column e +sql insert into tb values(now, 1, 1, '1') +sql select count(g) from tb +if $data00 != 11 then + return -1 +endi + +print ======== step16 +#sql alter table tb(ts timestamp, g double, h binary(20)) +sql alter table tb drop column f +sql insert into tb values(now+1d, 1, '1') +sql select count(g) from tb +if $data00 != 12 then + return -1 +endi + +print ======== step17 +#sql alter table tb(ts timestamp, h binary(20)) +sql alter table tb drop column g +sql insert into tb values(now+2d, '1') +sql select count(h) from tb +if $data00 != 10 then + return -1 +endi + +print ============== step18 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +#sql select count(g) from tb +#if $data00 != 12 then +# return -1 +#endi +sql select count(*) from tb +if $data00 != 31 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/alter/dnode.sim b/tests/script/general/alter/dnode.sim new file mode 100644 index 0000000000000000000000000000000000000000..7b31218fc231cfdbb79ca97573cfc6f6f149037d --- /dev/null +++ b/tests/script/general/alter/dnode.sim @@ -0,0 +1,71 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======== step1 +sql alter dnode 1 resetlog +sql alter dnode 1 monitor 1 + +sleep 3000 +sql select * from log.dn +if $rows <= 0 then + return -1 +endi + +print ======== step2 + +sql alter dnode 1 resetquerycache +sql alter dnode 1 debugFlag 135 +sql alter dnode 1 debugFlag 131 +sql alter dnode 1 monitor 0 +sql alter dnode 1 debugFlag 135 +sql alter dnode 1 monDebugFlag 135 +sql alter dnode 1 vDebugFlag 135 +sql alter dnode 1 mDebugFlag 135 +sql alter dnode 1 cDebugFlag 135 +sql alter dnode 1 httpDebugFlag 135 +sql alter dnode 1 qDebugflag 135 +sql alter dnode 1 sdbDebugFlag 135 +sql alter dnode 1 uDebugFlag 135 +sql alter dnode 1 tsdbDebugFlag 135 +sql alter dnode 1 sDebugflag 135 +sql alter dnode 1 rpcDebugFlag 135 +sql alter dnode 1 dDebugFlag 135 +sql alter dnode 1 mqttDebugFlag 135 +sql alter dnode 1 wDebugFlag 135 +sql alter dnode 1 tmrDebugFlag 135 +sql_error alter dnode 2 wDebugFlag 135 +sql_error alter dnode 2 tmrDebugFlag 135 + +print ======== step3 +sql_error alter $hostname1 debugFlag 135 +sql_error alter $hostname1 monDebugFlag 135 +sql_error alter $hostname1 vDebugFlag 135 +sql_error alter $hostname1 mDebugFlag 135 +sql_error alter dnode $hostname2 debugFlag 135 +sql_error alter dnode $hostname2 monDebugFlag 135 +sql_error alter dnode $hostname2 vDebugFlag 135 +sql_error alter dnode $hostname2 mDebugFlag 135 +sql alter dnode $hostname1 debugFlag 135 +sql alter dnode $hostname1 monDebugFlag 135 +sql alter dnode $hostname1 vDebugFlag 135 +sql alter dnode $hostname1 tmrDebugFlag 131 + +print ======== step4 +sql_error sql alter dnode 1 balance 0 +sql_error sql alter dnode 1 balance vnode:1-dnode:1 +sql_error sql alter dnode 1 balance "vnode:1" +sql_error sql alter dnode 1 balance "vnode:1-dnode:1" +sql_error sql alter dnode 1 balance "dnode:1-vnode:1" +sql_error sql alter dnode 1 balance "dnode:1-" +sql_error sql alter dnode 1 balance "vnode:2-dnod" +sql alter dnode 1 balance "vnode:2-dnode:1" -x step4 +step4: + +print ======= over +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/alter/import.sim b/tests/script/general/alter/import.sim new file mode 100644 index 0000000000000000000000000000000000000000..aef0a258b24563e915cd8aa3dd42f6623a29170a --- /dev/null +++ b/tests/script/general/alter/import.sim @@ -0,0 +1,50 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 + +print ========= start dnode1 as master +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ======== step1 +sql create database d1 replica 1 days 7 keep 50 +sql use d1 +sql create table tb (ts timestamp, a int) +sql insert into tb values(now-30d, -28) +sql insert into tb values(now-27d, -27) +sql insert into tb values(now-26d, -26) +sql select count(a) from tb +if $data00 != 3 then + return -1 +endi + +print ======== step2 +#sql alter table tb(ts timestamp, a int, b smallint) +sql alter table tb add column b smallint +sql insert into tb values(now-25d, -25, 0) +sql insert into tb values(now-22d, -24, 1) +sql insert into tb values(now-20d, -23, 2) +sql select count(b) from tb +if $data00 != 3 then + return -1 +endi + +print ========= step3 +sql import into tb values(now-23d, -23, 0) +sql import into tb values(now-21d, -21, 0) +sql select count(b) from tb +if $data00 != 5 then + return -1 +endi + +sql import into tb values(now-29d, -29, 0) +sql select count(b) from tb +if $data00 != 6 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/alter/insert1.sim b/tests/script/general/alter/insert1.sim new file mode 100644 index 0000000000000000000000000000000000000000..12ab09beb989dd963a9e8c9c3ff5926e78d8b0ac --- /dev/null +++ b/tests/script/general/alter/insert1.sim @@ -0,0 +1,1147 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======== step1 +sql create database d3 +sql use d3 +sql create table tb (ts timestamp, a int) +sql insert into tb values(now-28d, -28) +sql select * from tb order by ts desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 + +if $rows != 1 then + return -1 +endi +if $data01 != -28 then + return -1 +endi +if $data02 != null then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data04 != null then + return -1 +endi +if $data05 != null then + return -1 +endi +if $data06 != null then + return -1 +endi +if $data07 != null then + return -1 +endi +if $data08 != null then + return -1 +endi + +print ======== step2 +sql alter table tb add column b smallint +sql insert into tb values(now-25d, -25, 0) +sql select * from tb order by ts desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 +if $rows != 2 then + return -1 +endi +if $data01 != -25 then + return -1 +endi +if $data11 != -28 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data12 != NULL then + return -1 +endi +if $data13 != null then + return -1 +endi +if $data14 != null then + return -1 +endi +if $data15 != null then + return -1 +endi +if $data16 != null then + return -1 +endi +if $data17 != null then + return -1 +endi +if $data18 != null then + return -1 +endi + +print ======== step3 +sql alter table tb add column c tinyint +sql insert into tb values(now-22d, -22, 3, 0) +sql select * from tb order by ts asc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 +print $data20 $data21 $data22 $data23 $data24 $data25 $data26 +if $rows != 3 then then + return -1 +endi +if $data01 != -28 then + return -1 +endi +if $data02 != NULL then + return -1 +endi +if $data03 != NULL then + return -1 +endi +if $data04 != null then + return -1 +endi +if $data05 != null then + return -1 +endi +if $data06 != null then + return -1 +endi +if $data07 != null then + return -1 +endi +if $data08 != null then + return -1 +endi +if $data11 != -25 then + return -1 +endi +if $data12 != 0 then + return -1 +endi +if $data13 != NULL then + return -1 +endi +if $data14 != null then + return -1 +endi +if $data15 != null then + return -1 +endi +if $data16 != null then + return -1 +endi +if $data17 != null then + return -1 +endi +if $data18 != null then + return -1 +endi +if $data21 != -22 then + return -1 +endi +if $data22 != 3 then + return -1 +endi +if $data23 != 0 then + return -1 +endi +if $data24 != null then + return -1 +endi +if $data25 != null then + return -1 +endi +if $data26 != null then + return -1 +endi +if $data27 != null then + return -1 +endi +if $data28 != null then + return -1 +endi + +print ======== step4 +sql alter table tb add column d int +sql insert into tb values(now-19d, -19, 6, 3, 0) +sql select * from tb order by ts asc +if $rows != 4 then then + return -1 +endi +if $data01 != -28 then + return -1 +endi +if $data02 != NULL then + return -1 +endi +if $data03 != NULL then + return -1 +endi +if $data04 != NULL then + return -1 +endi +if $data05 != null then + return -1 +endi +if $data06 != null then + return -1 +endi +if $data07 != null then + return -1 +endi +if $data08 != null then + return -1 +endi +if $data11 != -25 then + return -1 +endi +if $data12 != 0 then + return -1 +endi +if $data13 != NULL then + return -1 +endi +if $data14 != NULL then + return -1 +endi +if $data15 != null then + return -1 +endi +if $data16 != null then + return -1 +endi +if $data17 != null then + return -1 +endi +if $data18 != null then + return -1 +endi +if $data21 != -22 then + return -1 +endi +if $data22 != 3 then + return -1 +endi +if $data23 != 0 then + return -1 +endi +if $data24 != NULL then + return -1 +endi +if $data25 != null then + return -1 +endi +if $data26 != null then + return -1 +endi +if $data27 != null then + return -1 +endi +if $data28 != null then + return -1 +endi +if $data31 != -19 then + return -1 +endi +if $data32 != 6 then + return -1 +endi +if $data33 != 3 then + return -1 +endi +if $data34 != 0 then + return -1 +endi +if $data35 != null then + return -1 +endi +if $data36 != null then + return -1 +endi +if $data37 != null then + return -1 +endi +if $data38 != null then + return -1 +endi + +print ======== step5 +sql alter table tb add column e bigint +sql insert into tb values(now-16d, -16, 9, 5, 4, 3) +sql select count(e) from tb +if $data00 != 1 then + return -1 +endi +sql select count(c) from tb +if $data00 != 3 then then + return -1 +endi +sql select * from tb order by ts asc +if $rows != 5 then then + return -1 +endi +if $data01 != -28 then + return -1 +endi +if $data02 != NULL then + return -1 +endi +if $data03 != NULL then + return -1 +endi +if $data04 != NULL then + return -1 +endi +if $data05 != NULL then + return -1 +endi +if $data06 != null then + return -1 +endi +if $data07 != null then + return -1 +endi +if $data08 != null then + return -1 +endi +if $data11 != -25 then + return -1 +endi +if $data12 != 0 then + return -1 +endi +if $data13 != NULL then + return -1 +endi +if $data14 != NULL then + return -1 +endi +if $data15 != NULL then + return -1 +endi +if $data16 != null then + return -1 +endi +if $data17 != null then + return -1 +endi +if $data18 != null then + return -1 +endi +if $data21 != -22 then + return -1 +endi +if $data22 != 3 then + return -1 +endi +if $data23 != 0 then + return -1 +endi +if $data24 != NULL then + return -1 +endi +if $data25 != NULL then + return -1 +endi +if $data26 != null then + return -1 +endi +if $data27 != null then + return -1 +endi +if $data28 != null then + return -1 +endi +if $data31 != -19 then + return -1 +endi +if $data32 != 6 then + return -1 +endi +if $data33 != 3 then + return -1 +endi +if $data34 != 0 then + return -1 +endi +if $data35 != NULL then + return -1 +endi +if $data36 != null then + return -1 +endi +if $data37 != null then + return -1 +endi +if $data38 != null then + return -1 +endi +if $data41 != -16 then + return -1 +endi +if $data42 != 9 then + return -1 +endi +if $data43 != 5 then + return -1 +endi +if $data44 != 4 then + return -1 +endi +if $data45 != 3 then + return -1 +endi +if $data46 != null then + return -1 +endi +if $data47 != null then + return -1 +endi +if $data48 != null then + return -1 +endi + +print ======== step6 +sql alter table tb add column f float +sql insert into tb values(now-13d, -13, 12, 11, 10, 9, 8) +sql select * from tb order by ts asc +if $rows != 6 then then + return -1 +endi +if $data01 != -28 then + return -1 +endi +if $data02 != NULL then + return -1 +endi +if $data03 != NULL then + return -1 +endi +if $data04 != NULL then + return -1 +endi +if $data05 != NULL then + return -1 +endi +if $data06 != NULL then + return -1 +endi +if $data07 != null then + return -1 +endi +if $data08 != null then + return -1 +endi +if $data11 != -25 then + return -1 +endi +if $data12 != 0 then + return -1 +endi +if $data13 != NULL then + return -1 +endi +if $data14 != NULL then + return -1 +endi +if $data15 != NULL then + return -1 +endi +if $data16 != NULL then + return -1 +endi +if $data17 != null then + return -1 +endi +if $data18 != null then + return -1 +endi +if $data21 != -22 then + return -1 +endi +if $data22 != 3 then + return -1 +endi +if $data23 != 0 then + return -1 +endi +if $data24 != NULL then + return -1 +endi +if $data25 != NULL then + return -1 +endi +if $data26 != NULL then + return -1 +endi +if $data27 != null then + return -1 +endi +if $data28 != null then + return -1 +endi +if $data31 != -19 then + return -1 +endi +if $data32 != 6 then + return -1 +endi +if $data33 != 3 then + return -1 +endi +if $data34 != 0 then + return -1 +endi +if $data35 != NULL then + return -1 +endi +if $data36 != NULL then + return -1 +endi +if $data37 != null then + return -1 +endi +if $data38 != null then + return -1 +endi +if $data41 != -16 then + return -1 +endi +if $data42 != 9 then + return -1 +endi +if $data43 != 5 then + return -1 +endi +if $data44 != 4 then + return -1 +endi +if $data45 != 3 then + return -1 +endi +if $data46 != NULL then + return -1 +endi +if $data47 != null then + return -1 +endi +if $data48 != null then + return -1 +endi +if $data51 != -13 then + return -1 +endi +if $data52 != 12 then + return -1 +endi +if $data53 != 11 then + return -1 +endi +if $data54 != 10 then + return -1 +endi +if $data55 != 9 then + return -1 +endi +if $data56 != 8.00000 then + return -1 +endi +if $data57 != null then + return -1 +endi +if $data58 != null then + return -1 +endi + +print ======== step7 +sql alter table tb add column g double +sql insert into tb values(now-10d, -10, 15, 14, 13, 12, 11, 10) +sql select * from tb order by ts asc +if $rows != 7 then + return -1 +endi +if $data01 != -28 then + return -1 +endi +if $data02 != NULL then + return -1 +endi +if $data03 != NULL then + return -1 +endi +if $data04 != NULL then + return -1 +endi +if $data05 != NULL then + return -1 +endi +if $data06 != NULL then + return -1 +endi +if $data07 != NULL then + return -1 +endi +if $data08 != null then + return -1 +endi +if $data11 != -25 then + return -1 +endi +if $data12 != 0 then + return -1 +endi +if $data13 != NULL then + return -1 +endi +if $data14 != NULL then + return -1 +endi +if $data15 != NULL then + return -1 +endi +if $data16 != NULL then + return -1 +endi +if $data17 != NULL then + return -1 +endi +if $data18 != null then + return -1 +endi +if $data21 != -22 then + return -1 +endi +if $data22 != 3 then + return -1 +endi +if $data23 != 0 then + return -1 +endi +if $data24 != NULL then + return -1 +endi +if $data25 != NULL then + return -1 +endi +if $data26 != NULL then + return -1 +endi +if $data27 != NULL then + return -1 +endi +if $data28 != null then + return -1 +endi +if $data31 != -19 then + return -1 +endi +if $data32 != 6 then + return -1 +endi +if $data33 != 3 then + return -1 +endi +if $data34 != 0 then + return -1 +endi +if $data35 != NULL then + return -1 +endi +if $data36 != NULL then + return -1 +endi +if $data37 != NULL then + return -1 +endi +if $data38 != null then + return -1 +endi +if $data41 != -16 then + return -1 +endi +if $data42 != 9 then + return -1 +endi +if $data43 != 5 then + return -1 +endi +if $data44 != 4 then + return -1 +endi +if $data45 != 3 then + return -1 +endi +if $data46 != NULL then + return -1 +endi +if $data47 != NULL then + return -1 +endi +if $data48 != null then + return -1 +endi +if $data51 != -13 then + return -1 +endi +if $data52 != 12 then + return -1 +endi +if $data53 != 11 then + return -1 +endi +if $data54 != 10 then + return -1 +endi +if $data55 != 9 then + return -1 +endi +if $data56 != 8.00000 then + return -1 +endi +if $data57 != NULL then + return -1 +endi +if $data58 != null then + return -1 +endi +if $data61 != -10 then + return -1 +endi +if $data62 != 15 then + return -1 +endi +if $data63 != 14 then + return -1 +endi +if $data64 != 13 then + return -1 +endi +if $data65 != 12 then + return -1 +endi +if $data66 != 11.00000 then + return -1 +endi +if $data67 != 10.000000000 then + return -1 +endi +if $data68 != null then + return -1 +endi + +print ======== step8 +sql alter table tb add column h binary(10) +sql insert into tb values(now-7d, -7, 18, 17, 16, 15, 14, 13, '11') +sql select * from tb order by ts asc +if $rows != 8 then + return -1 +endi +if $data01 != -28 then + return -1 +endi +if $data02 != NULL then + return -1 +endi +if $data03 != NULL then + return -1 +endi +if $data04 != NULL then + return -1 +endi +if $data05 != NULL then + return -1 +endi +if $data06 != NULL then + return -1 +endi +if $data07 != NULL then + return -1 +endi +if $data08 != NULL then + return -1 +endi +if $data11 != -25 then + return -1 +endi +if $data12 != 0 then + return -1 +endi +if $data13 != NULL then + return -1 +endi +if $data14 != NULL then + return -1 +endi +if $data15 != NULL then + return -1 +endi +if $data16 != NULL then + return -1 +endi +if $data17 != NULL then + return -1 +endi +if $data18 != NULL then + return -1 +endi +if $data21 != -22 then + return -1 +endi +if $data22 != 3 then + return -1 +endi +if $data23 != 0 then + return -1 +endi +if $data24 != NULL then + return -1 +endi +if $data25 != NULL then + return -1 +endi +if $data26 != NULL then + return -1 +endi +if $data27 != NULL then + return -1 +endi +if $data28 != NULL then + return -1 +endi +if $data31 != -19 then + return -1 +endi +if $data32 != 6 then + return -1 +endi +if $data33 != 3 then + return -1 +endi +if $data34 != 0 then + return -1 +endi +if $data35 != NULL then + return -1 +endi +if $data36 != NULL then + return -1 +endi +if $data37 != NULL then + return -1 +endi +if $data38 != NULL then + return -1 +endi +if $data41 != -16 then + return -1 +endi +if $data42 != 9 then + return -1 +endi +if $data43 != 5 then + return -1 +endi +if $data44 != 4 then + return -1 +endi +if $data45 != 3 then + return -1 +endi +if $data46 != NULL then + return -1 +endi +if $data47 != NULL then + return -1 +endi +if $data48 != NULL then + return -1 +endi +if $data51 != -13 then + return -1 +endi +if $data52 != 12 then + return -1 +endi +if $data53 != 11 then + return -1 +endi +if $data54 != 10 then + return -1 +endi +if $data55 != 9 then + return -1 +endi +if $data56 != 8.00000 then + return -1 +endi +if $data57 != NULL then + return -1 +endi +if $data58 != NULL then + return -1 +endi +if $data61 != -10 then + return -1 +endi +if $data62 != 15 then + return -1 +endi +if $data63 != 14 then + return -1 +endi +if $data64 != 13 then + return -1 +endi +if $data65 != 12 then + return -1 +endi +if $data66 != 11.00000 then + return -1 +endi +if $data67 != 10.000000000 then + return -1 +endi +if $data68 != NULL then + return -1 +endi +if $data71 != -7 then + return -1 +endi +if $data72 != 18 then + return -1 +endi +if $data73 != 17 then + return -1 +endi +if $data74 != 16 then + return -1 +endi +if $data75 != 15 then + return -1 +endi +if $data76 != 14.00000 then + return -1 +endi +if $data77 != 13.000000000 then + return -1 +endi +if $data78 != 11 then + return -1 +endi +if $data79 != null then + return -1 +endi + +print ======== step9 + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +sql select * from tb order by ts asc +if $rows != 8 then + return -1 +endi +if $data01 != -28 then + return -1 +endi +if $data02 != NULL then + return -1 +endi +if $data03 != NULL then + return -1 +endi +if $data04 != NULL then + return -1 +endi +if $data05 != NULL then + return -1 +endi +if $data06 != NULL then + return -1 +endi +if $data07 != NULL then + return -1 +endi +if $data08 != NULL then + return -1 +endi +if $data11 != -25 then + return -1 +endi +if $data12 != 0 then + return -1 +endi +if $data13 != NULL then + return -1 +endi +if $data14 != NULL then + return -1 +endi +if $data15 != NULL then + return -1 +endi +if $data16 != NULL then + return -1 +endi +if $data17 != NULL then + return -1 +endi +if $data18 != NULL then + return -1 +endi +if $data21 != -22 then + return -1 +endi +if $data22 != 3 then + return -1 +endi +if $data23 != 0 then + return -1 +endi +if $data24 != NULL then + return -1 +endi +if $data25 != NULL then + return -1 +endi +if $data26 != NULL then + return -1 +endi +if $data27 != NULL then + return -1 +endi +if $data28 != NULL then + return -1 +endi +if $data31 != -19 then + return -1 +endi +if $data32 != 6 then + return -1 +endi +if $data33 != 3 then + return -1 +endi +if $data34 != 0 then + return -1 +endi +if $data35 != NULL then + return -1 +endi +if $data36 != NULL then + return -1 +endi +if $data37 != NULL then + return -1 +endi +if $data38 != NULL then + return -1 +endi +if $data41 != -16 then + return -1 +endi +if $data42 != 9 then + return -1 +endi +if $data43 != 5 then + return -1 +endi +if $data44 != 4 then + return -1 +endi +if $data45 != 3 then + return -1 +endi +if $data46 != NULL then + return -1 +endi +if $data47 != NULL then + return -1 +endi +if $data48 != NULL then + return -1 +endi +if $data51 != -13 then + return -1 +endi +if $data52 != 12 then + return -1 +endi +if $data53 != 11 then + return -1 +endi +if $data54 != 10 then + return -1 +endi +if $data55 != 9 then + return -1 +endi +if $data56 != 8.00000 then + return -1 +endi +if $data57 != NULL then + return -1 +endi +if $data58 != NULL then + return -1 +endi +if $data61 != -10 then + return -1 +endi +if $data62 != 15 then + return -1 +endi +if $data63 != 14 then + return -1 +endi +if $data64 != 13 then + return -1 +endi +if $data65 != 12 then + return -1 +endi +if $data66 != 11.00000 then + return -1 +endi +if $data67 != 10.000000000 then + return -1 +endi +if $data68 != NULL then + return -1 +endi +if $data71 != -7 then + return -1 +endi +if $data72 != 18 then + return -1 +endi +if $data73 != 17 then + return -1 +endi +if $data74 != 16 then + return -1 +endi +if $data75 != 15 then + return -1 +endi +if $data76 != 14.00000 then + return -1 +endi +if $data77 != 13.000000000 then + return -1 +endi +if $data78 != 11 then + return -1 +endi +if $data79 != null then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/alter/insert2.sim b/tests/script/general/alter/insert2.sim new file mode 100644 index 0000000000000000000000000000000000000000..dcd9f500304f906ddddb33bd1a04c5943c232d49 --- /dev/null +++ b/tests/script/general/alter/insert2.sim @@ -0,0 +1,671 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======== step1 +sql create database d4 +sql use d4 +sql create table tb (ts timestamp, a int, b smallint, c tinyint, d int, e bigint, f float, g double, h binary(10)) +sql insert into tb values(now-28d, 1, 2, 3, 4, 5, 6, 7, 8) +sql select * from tb order by ts desc +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 2 then + return -1 +endi +if $data03 != 3 then + return -1 +endi +if $data04 != 4 then + return -1 +endi +if $data05 != 5 then + return -1 +endi +if $data06 != 6.00000 then + return -1 +endi +if $data07 != 7.000000000 then + return -1 +endi +if $data08 != 8 then + return -1 +endi + +print ======== step2 +sql_error alter table tb add column b smallint +sql_error alter table tb add column b int +sql alter table tb drop column b +sql insert into tb values(now-25d, 2, 3, 4, 5, 6, 7, 8) +sql select * from tb order by ts desc +if $rows != 2 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 3 then + return -1 +endi +if $data03 != 4 then + return -1 +endi +if $data04 != 5 then + return -1 +endi +if $data05 != 6.00000 then + return -1 +endi +if $data06 != 7.000000000 then + return -1 +endi +if $data07 != 8 then + return -1 +endi +if $data08 != null then + return -1 +endi +if $data11 != 1 then + return -1 +endi +if $data12 != 3 then + return -1 +endi +if $data13 != 4 then + return -1 +endi +if $data14 != 5 then + return -1 +endi +if $data15 != 6.00000 then + return -1 +endi +if $data16 != 7.000000000 then + return -1 +endi +if $data17 != 8 then + return -1 +endi +if $data18 != null then + return -1 +endi + +print ======== step3 +sql alter table tb drop column c +sql insert into tb values(now-22d, 3, 4, 5, 6, 7, 8) +sql select * from tb order by ts desc +if $rows != 3 then + return -1 +endi +if $data01 != 3 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 6.00000 then + return -1 +endi +if $data05 != 7.000000000 then + return -1 +endi +if $data06 != 8 then + return -1 +endi +if $data07 != null then + return -1 +endi +if $data08 != null then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 4 then + return -1 +endi +if $data13 != 5 then + return -1 +endi +if $data14 != 6.00000 then + return -1 +endi +if $data15 != 7.000000000 then + return -1 +endi +if $data16 != 8 then + return -1 +endi +if $data17 != null then + return -1 +endi +if $data18 != null then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data22 != 4 then + return -1 +endi +if $data23 != 5 then + return -1 +endi +if $data24 != 6.00000 then + return -1 +endi +if $data25 != 7.000000000 then + return -1 +endi +if $data26 != 8 then + return -1 +endi +if $data27 != null then + return -1 +endi +if $data28 != null then + return -1 +endi + +print ======== step4 +sql alter table tb drop column d +sql alter table tb drop column e +sql insert into tb values(now-19d, -19, 6, 3, 0) +sql select * from tb order by ts desc +if $rows != 4 then + return -1 +endi +if $data01 != -19 then + return -1 +endi +if $data02 != 6.00000 then + return -1 +endi +if $data03 != 3.000000000 then + return -1 +endi +if $data04 != 0 then + return -1 +endi +if $data05 != null then + return -1 +endi +if $data06 != null then + return -1 +endi +if $data07 != null then + return -1 +endi +if $data08 != null then + return -1 +endi +if $data11 != 3 then + return -1 +endi +if $data12 != 6.00000 then + return -1 +endi +if $data13 != 7.000000000 then + return -1 +endi +if $data14 != 8 then + return -1 +endi +if $data15 != null then + return -1 +endi +if $data16 != null then + return -1 +endi +if $data17 != null then + return -1 +endi +if $data18 != null then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data22 != 6.00000 then + return -1 +endi +if $data23 != 7.000000000 then + return -1 +endi +if $data24 != 8 then + return -1 +endi +if $data25 != null then + return -1 +endi +if $data26 != null then + return -1 +endi +if $data27 != null then + return -1 +endi +if $data28 != null then + return -1 +endi +if $data31 != 1 then + return -1 +endi +if $data32 != 6.00000 then + return -1 +endi +if $data33 != 7.000000000 then + return -1 +endi +if $data34 != 8 then + return -1 +endi +if $data35 != null then + return -1 +endi +if $data36 != null then + return -1 +endi +if $data37 != null then + return -1 +endi +if $data38 != null then + return -1 +endi + +print ======== step5 +sql alter table tb drop column g +sql insert into tb values(now-16d, -16, 9, 5) +sql select count(f) from tb +if $data00 != 5 then + return -1 +endi +sql select * from tb order by ts desc +if $rows != 5 then + return -1 +endi +if $data01 != -16 then + return -1 +endi +if $data02 != 9.00000 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != null then + return -1 +endi +if $data05 != null then + return -1 +endi +if $data06 != null then + return -1 +endi +if $data07 != null then + return -1 +endi +if $data08 != null then + return -1 +endi +if $data11 != -19 then + return -1 +endi +if $data12 != 6.00000 then + return -1 +endi +if $data13 != 0 then + return -1 +endi +if $data14 != null then + return -1 +endi +if $data15 != null then + return -1 +endi +if $data16 != null then + return -1 +endi +if $data17 != null then + return -1 +endi +if $data18 != null then + return -1 +endi +if $data21 != 3 then + return -1 +endi +if $data22 != 6.00000 then + return -1 +endi +if $data23 != 8 then + return -1 +endi +if $data24 != null then + return -1 +endi +if $data25 != null then + return -1 +endi +if $data26 != null then + return -1 +endi +if $data27 != null then + return -1 +endi +if $data28 != null then + return -1 +endi +if $data31 != 2 then + return -1 +endi +if $data32 != 6.00000 then + return -1 +endi +if $data33 != 8 then + return -1 +endi +if $data34 != null then + return -1 +endi +if $data35 != null then + return -1 +endi +if $data36 != null then + return -1 +endi +if $data37 != null then + return -1 +endi +if $data38 != null then + return -1 +endi +if $data41 != 1 then + return -1 +endi +if $data42 != 6.00000 then + return -1 +endi +if $data43 != 8 then + return -1 +endi +if $data44 != null then + return -1 +endi +if $data45 != null then + return -1 +endi +if $data46 != null then + return -1 +endi +if $data47 != null then + return -1 +endi +if $data48 != null then + return -1 +endi + +print ======== step6 +sql alter table tb drop column f +sql insert into tb values(now-13d, -13, 7) +sql select * from tb order by ts desc +if $rows != 6 then + return -1 +endi +if $data01 != -13 then + return -1 +endi +if $data11 != -16 then + return -1 +endi +if $data12 != 5 then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data04 != null then + return -1 +endi +if $data05 != null then + return -1 +endi +if $data06 != null then + return -1 +endi +if $data07 != null then + return -1 +endi +if $data08 != null then + return -1 +endi +if $data21 != -19 then + return -1 +endi +if $data22 != 0 then + return -1 +endi +if $data23 != null then + return -1 +endi +if $data24 != null then + return -1 +endi +if $data25 != null then + return -1 +endi +if $data26 != null then + return -1 +endi +if $data27 != null then + return -1 +endi +if $data28 != null then + return -1 +endi +if $data31 != 3 then + return -1 +endi +if $data32 != 8 then + return -1 +endi +if $data33 != null then + return -1 +endi +if $data34 != null then + return -1 +endi +if $data35 != null then + return -1 +endi +if $data36 != null then + return -1 +endi +if $data37 != null then + return -1 +endi +if $data38 != null then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data42 != 8 then + return -1 +endi +if $data43 != null then + return -1 +endi +if $data44 != null then + return -1 +endi +if $data45 != null then + return -1 +endi +if $data46 != null then + return -1 +endi +if $data47 != null then + return -1 +endi +if $data48 != null then + return -1 +endi +if $data51 != 1 then + return -1 +endi +if $data52 != 8 then + return -1 +endi +if $data53 != null then + return -1 +endi +if $data54 != null then + return -1 +endi +if $data55 != null then + return -1 +endi +if $data57 != null then + return -1 +endi +if $data58 != null then + return -1 +endi + +print ======== step7 +sql alter table tb drop column h +sql insert into tb values(now-10d, -10) +sql select * from tb order by ts desc +if $rows != 7 then + return -1 +endi +print data01 = $data01 +if $data01 != -10 then + return -1 +endi +if $data02 != null then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data11 != -13 then + return -1 +endi +if $data12 != null then + return -1 +endi +if $data21 != -16 then + return -1 +endi +if $data22 != null then + return -1 +endi +if $data31 != -19 then + return -1 +endi +if $data32 != null then + return -1 +endi +if $data33 != null then + return -1 +endi +if $data41 != 3 then + return -1 +endi +if $data42 != null then + return -1 +endi +if $data51 != 2 then + return -1 +endi +if $data52 != null then + return -1 +endi +if $data53 != null then + return -1 +endi +if $data61 != 1 then + return -1 +endi +if $data62 != null then + return -1 +endi + +sql_error alter table tb drop column a + +print ======== step9 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +sql select * from tb order by ts desc +if $rows != 7 then + return -1 +endi +if $data01 != -10 then + return -1 +endi +if $data02 != null then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data11 != -13 then + return -1 +endi +if $data12 != null then + return -1 +endi +if $data21 != -16 then + return -1 +endi +if $data22 != null then + return -1 +endi +if $data31 != -19 then + return -1 +endi +if $data32 != null then + return -1 +endi +if $data33 != null then + return -1 +endi +if $data41 != 3 then + return -1 +endi +if $data42 != null then + return -1 +endi +if $data51 != 2 then + return -1 +endi +if $data52 != null then + return -1 +endi +if $data53 != null then + return -1 +endi +if $data61 != 1 then + return -1 +endi +if $data62 != null then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/alter/metrics.sim b/tests/script/general/alter/metrics.sim new file mode 100644 index 0000000000000000000000000000000000000000..fd0b210cd1b452b2a35ebcd9f74aec98c3817b03 --- /dev/null +++ b/tests/script/general/alter/metrics.sim @@ -0,0 +1,769 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======== step1 +sql create database d2 +sql use d2 +sql create table mt (ts timestamp, a int) TAGS (t int) +sql create table tb using mt tags (1) +sql insert into tb values(now-28d, -28) +sql insert into tb values(now-27d, -27) +sql insert into tb values(now-26d, -26) +sql select * from tb +if $rows != 3 then + return -1 +endi +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != t then + return -1 +endi +if $data21 != INT then + return -1 +endi + +print ======== step2 +sql alter table mt add column b smallint +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != t then + return -1 +endi +if $data31 != INT then + return -1 +endi + +print ======== step3 +sql alter table mt add column c tinyint +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != t then + return -1 +endi +if $data41 != INT then + return -1 +endi + +print ======== step4 +sql alter table mt add column d int +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != t then + return -1 +endi +if $data51 != INT then + return -1 +endi + +print ======== step5 +sql alter table mt add column e bigint +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != t then + return -1 +endi +if $data61 != INT then + return -1 +endi + +print ======== step6 +sql alter table mt add column f float +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != f then + return -1 +endi +if $data61 != FLOAT then + return -1 +endi +if $data70 != t then + return -1 +endi +if $data71 != INT then + return -1 +endi + +print ======== step7 +sql alter table mt add column g double +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != f then + return -1 +endi +if $data61 != FLOAT then + return -1 +endi +if $data70 != g then + return -1 +endi +if $data71 != DOUBLE then + return -1 +endi +if $data80 != t then + return -1 +endi +if $data81 != INT then + return -1 +endi + +print ======== step8 +sql alter table mt add column h binary(10) +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != f then + return -1 +endi +if $data61 != FLOAT then + return -1 +endi +if $data70 != g then + return -1 +endi +if $data71 != DOUBLE then + return -1 +endi +if $data80 != h then + return -1 +endi +if $data81 != BINARY then + return -1 +endi +if $data82 != 10 then + return -1 +endi +if $data90 != t then + return -1 +endi +if $data91 != INT then + return -1 +endi + +print ======== step9 +print ======== step10 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +sql use d2 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != f then + return -1 +endi +if $data61 != FLOAT then + return -1 +endi +if $data70 != g then + return -1 +endi +if $data71 != DOUBLE then + return -1 +endi +if $data80 != h then + return -1 +endi +if $data81 != BINARY then + return -1 +endi +if $data82 != 10 then + return -1 +endi +if $data90 != t then + return -1 +endi +if $data91 != INT then + return -1 +endi + +print ======== step11 +#sql alter table mt drop column a -x step111 +# return -1 +#step111: + +#sql alter table mt drop column ts -x step112 +# return -1 +#step112: + +#sql alter table mt drop column cdfg -x step113 +# return -1 +#step113: + +#sql alter table mt add column a -x step114 +# return -1 +#step114: + +#sql alter table mt add column b -x step115 +# return -1 +#step115: + +print ======== step12 +sql alter table mt drop column b +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != c then + return -1 +endi +if $data21 != TINYINT then + return -1 +endi +if $data30 != d then + return -1 +endi +if $data31 != INT then + return -1 +endi +if $data40 != e then + return -1 +endi +if $data41 != BIGINT then + return -1 +endi +if $data50 != f then + return -1 +endi +if $data51 != FLOAT then + return -1 +endi +if $data60 != g then + return -1 +endi +if $data61 != DOUBLE then + return -1 +endi +if $data70 != h then + return -1 +endi +if $data71 != BINARY then + return -1 +endi +if $data72 != 10 then + return -1 +endi +if $data80 != t then + return -1 +endi +if $data81 != INT then + return -1 +endi + +print ======== step13 +sql alter table mt drop column c +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != d then + return -1 +endi +if $data21 != INT then + return -1 +endi +if $data30 != e then + return -1 +endi +if $data31 != BIGINT then + return -1 +endi +if $data40 != f then + return -1 +endi +if $data41 != FLOAT then + return -1 +endi +if $data50 != g then + return -1 +endi +if $data51 != DOUBLE then + return -1 +endi +if $data60 != h then + return -1 +endi +if $data61 != BINARY then + return -1 +endi +if $data62 != 10 then + return -1 +endi +if $data70 != t then + return -1 +endi +if $data71 != INT then + return -1 +endi + +print ======== step14 +sql alter table mt drop column d +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != e then + return -1 +endi +if $data21 != BIGINT then + return -1 +endi +if $data30 != f then + return -1 +endi +if $data31 != FLOAT then + return -1 +endi +if $data40 != g then + return -1 +endi +if $data41 != DOUBLE then + return -1 +endi +if $data50 != h then + return -1 +endi +if $data51 != BINARY then + return -1 +endi +if $data52 != 10 then + return -1 +endi +if $data60 != t then + return -1 +endi +if $data61 != INT then + return -1 +endi + +print ======== step15 +sql alter table mt drop column e +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != f then + return -1 +endi +if $data21 != FLOAT then + return -1 +endi +if $data30 != g then + return -1 +endi +if $data31 != DOUBLE then + return -1 +endi +if $data40 != h then + return -1 +endi +if $data41 != BINARY then + return -1 +endi +if $data42 != 10 then + return -1 +endi +if $data50 != t then + return -1 +endi +if $data51 != INT then + return -1 +endi + +print ======== step16 +sql alter table mt drop column f +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != g then + return -1 +endi +if $data21 != DOUBLE then + return -1 +endi +if $data30 != h then + return -1 +endi +if $data31 != BINARY then + return -1 +endi +if $data32 != 10 then + return -1 +endi +if $data40 != t then + return -1 +endi +if $data41 != INT then + return -1 +endi + +print ======== step17 +sql alter table mt drop column g +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != h then + return -1 +endi +if $data21 != BINARY then + return -1 +endi +if $data22 != 10 then + return -1 +endi +if $data30 != t then + return -1 +endi +if $data31 != INT then + return -1 +endi + +print ============= step18 +sql alter table mt drop column h +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != t then + return -1 +endi +if $data21 != INT then + return -1 +endi +if $data30 != null then + return -1 +endi + +print ======= over +sql drop database d2 +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/alter/table.sim b/tests/script/general/alter/table.sim new file mode 100644 index 0000000000000000000000000000000000000000..06704eeca6b3149b47ddc2ffb90aaab9df934bd8 --- /dev/null +++ b/tests/script/general/alter/table.sim @@ -0,0 +1,672 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======== step1 +sql create database d1 +sql use d1 +sql create table tb (ts timestamp, a int) +sql insert into tb values(now-28d, -28) +sql insert into tb values(now-27d, -27) +sql insert into tb values(now-26d, -26) +sql select * from tb +if $rows != 3 then + return -1 +endi +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi + +print ======== step2 +sql alter table tb add column b smallint +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi + +print ======== step3 +sql alter table tb add column c tinyint +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi + +print ======== step4 +sql alter table tb add column d int +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi + +print ======== step5 +sql alter table tb add column e bigint +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi + +print ======== step6 +sql alter table tb add column f float +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != f then + return -1 +endi +if $data61 != FLOAT then + return -1 +endi + +print ======== step7 +sql alter table tb add column g double +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != f then + return -1 +endi +if $data61 != FLOAT then + return -1 +endi +if $data70 != g then + return -1 +endi +if $data71 != DOUBLE then + return -1 +endi + +print ======== step8 +sql alter table tb add column h binary(10) +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != f then + return -1 +endi +if $data61 != FLOAT then + return -1 +endi +if $data70 != g then + return -1 +endi +if $data71 != DOUBLE then + return -1 +endi +if $data80 != h then + return -1 +endi +if $data81 != BINARY then + return -1 +endi +if $data82 != 10 then + return -1 +endi + +print ======== step9 +print ======== step10 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +sql use d1 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != f then + return -1 +endi +if $data61 != FLOAT then + return -1 +endi +if $data70 != g then + return -1 +endi +if $data71 != DOUBLE then + return -1 +endi +if $data80 != h then + return -1 +endi +if $data81 != BINARY then + return -1 +endi +if $data82 != 10 then + return -1 +endi + +print ======== step11 +sql alter table drop column a -x step111 + return -1 +step111: + +sql alter table drop column ts -x step112 + return -1 +step112: + +sql alter table drop column cdfg -x step113 + return -1 +step113: + +sql alter table add column a -x step114 + return -1 +step114: + +sql alter table add column b -x step115 + return -1 +step115: + +print ======== step12 +sql alter table tb drop column b +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != c then + return -1 +endi +if $data21 != TINYINT then + return -1 +endi +if $data30 != d then + return -1 +endi +if $data31 != INT then + return -1 +endi +if $data40 != e then + return -1 +endi +if $data41 != BIGINT then + return -1 +endi +if $data50 != f then + return -1 +endi +if $data51 != FLOAT then + return -1 +endi +if $data60 != g then + return -1 +endi +if $data61 != DOUBLE then + return -1 +endi +if $data70 != h then + return -1 +endi +if $data71 != BINARY then + return -1 +endi +if $data72 != 10 then + return -1 +endi + +print ======== step13 +sql alter table tb drop column c +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != d then + return -1 +endi +if $data21 != INT then + return -1 +endi +if $data30 != e then + return -1 +endi +if $data31 != BIGINT then + return -1 +endi +if $data40 != f then + return -1 +endi +if $data41 != FLOAT then + return -1 +endi +if $data50 != g then + return -1 +endi +if $data51 != DOUBLE then + return -1 +endi +if $data60 != h then + return -1 +endi +if $data61 != BINARY then + return -1 +endi +if $data62 != 10 then + return -1 +endi + +print ======== step14 +sql alter table tb drop column d +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != e then + return -1 +endi +if $data21 != BIGINT then + return -1 +endi +if $data30 != f then + return -1 +endi +if $data31 != FLOAT then + return -1 +endi +if $data40 != g then + return -1 +endi +if $data41 != DOUBLE then + return -1 +endi +if $data50 != h then + return -1 +endi +if $data51 != BINARY then + return -1 +endi +if $data52 != 10 then + return -1 +endi + +print ======== step15 +sql alter table tb drop column e +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != f then + return -1 +endi +if $data21 != FLOAT then + return -1 +endi +if $data30 != g then + return -1 +endi +if $data31 != DOUBLE then + return -1 +endi +if $data40 != h then + return -1 +endi +if $data41 != BINARY then + return -1 +endi +if $data42 != 10 then + return -1 +endi + +print ======== step16 +sql alter table tb drop column f +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != g then + return -1 +endi +if $data21 != DOUBLE then + return -1 +endi +if $data30 != h then + return -1 +endi +if $data31 != BINARY then + return -1 +endi +if $data32 != 10 then + return -1 +endi + +print ======== step17 +sql alter table tb drop column g +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != h then + return -1 +endi +if $data21 != BINARY then + return -1 +endi +if $data22 != 10 then + return -1 +endi + +print ============= step18 +sql alter table tb drop column h +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != null then + return -1 +endi + +print ======= over +sql drop database d1 +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/alter/testSuite.sim b/tests/script/general/alter/testSuite.sim new file mode 100644 index 0000000000000000000000000000000000000000..cfac68144c080593499159eec81325924e7f25e6 --- /dev/null +++ b/tests/script/general/alter/testSuite.sim @@ -0,0 +1,7 @@ +run general/alter/cached_schema_after_alter.sim +run general/alter/count.sim +run general/alter/import.sim +run general/alter/insert1.sim +run general/alter/insert2.sim +run general/alter/metrics.sim +run general/alter/table.sim \ No newline at end of file diff --git a/tests/script/general/cache/new_metrics.sim b/tests/script/general/cache/new_metrics.sim new file mode 100644 index 0000000000000000000000000000000000000000..eb9b042483251856c2ac7b3f973ab31176a8ff56 --- /dev/null +++ b/tests/script/general/cache/new_metrics.sim @@ -0,0 +1,143 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$i = 0 +$dbPrefix = ca_nm_db +$tbPrefix = ca_nm_tb +$mtPrefix = ca_nm_mt +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +$mt = $mtPrefix . $i +$tbNum = 10 +$rowNum = 20 + +print =============== step1 +sql create database $db +sql use $db + +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool) +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + $x = 0 + while $x < $rowNum + $val = $x * 60000 + $ms = 1519833600000 + $val + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 + +sql select * from $tb order by ts desc +print ===>rows $rows, data $data01 +if $rows != 20 then + return -1 +endi +if $data01 != 19 then + return -1 +endi + +sql select * from $mt +print ===>rows $rows, data $data01 +if $rows != 100 then + return -1 +endi +if $data01 != 0 then + return -1 +endi + +sql select count(*) from $mt +print ===>rows $rows, data $data00 +if $rows != 1 then + return -1 +endi +if $data00 != 100 then + return -1 +endi + +print =============== step3 + +sql show stables +if $rows != 1 then + return -1 +endi +if $data00 != $mt then + return -1 +endi +if $data04 != 5 then + return -1 +endi + +print =============== step4 + +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $val = $x * 60000 + $ms = 1519833600000 + $val + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print ==> sleep 1 seconds to renew cache +sql reset query cache +sleep 1000 + +print =============== step5 + +sql select * from $tb order by ts desc +print ===>rows $rows, data $data01 +if $rows != 20 then + return -1 +endi +if $data01 != 19 then + return -1 +endi + +sql select * from $mt +print ===>rows $rows, data $data01 +if $rows != 200 then + return -1 +endi +if $data01 != 0 then + return -1 +endi + +sql select count(*) from $mt +print ===>rows $rows, data $data01 +if $rows != 1 then + return -1 +endi +if $data00 != 200 then + return -1 +endi + +print =============== step6 + +sql show stables +if $rows != 1 then + return -1 +endi +if $data00 != $mt then + return -1 +endi +if $data04 != 10 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/cache/restart_metrics.sim b/tests/script/general/cache/restart_metrics.sim new file mode 100644 index 0000000000000000000000000000000000000000..a1b2365b2aef739d7bdf97ba82b757648285fe97 --- /dev/null +++ b/tests/script/general/cache/restart_metrics.sim @@ -0,0 +1,93 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect +print ======================== dnode1 start + +$i = 0 +$dbPrefix = ca_rm_db +$tbPrefix = ca_rm_tb +$mtPrefix = ca_rm_mt +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +$mt = $mtPrefix . $i + +print =============== step1 +sql create database $db +sql use $db + +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(100)) +sql create table $tb using $mt tags( "1" ) +sql insert into $tb values (now, 1) + +sql select * from $tb +#print ===>rows $rows, data $data01 + +if $rows != 1 then + print expect 1, actual: $rows + return -1 +endi + +if $data01 != 1 then + print expect 1 actual: $data01 + return -1 +endi + +sql select * from $mt +print ===>rows $rows, data $data01 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +print =============== step2 +system sh/exec.sh -n dnode1 -s stop +sleep 3000 +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +print =============== step3 +print ==> sleep 1 seconds to renew cache +sql reset query cache +sleep 1000 + +print =============== step4 +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol bool) TAGS(tgcol int) +sql create table $tb using $mt tags( 3 ) +sql insert into $tb values (now, 2) + +sql select * from $tb +print ===>rows $rows, data $data01 +if $rows != 1 then + return -1 +endi + +if $data01 != 1 then + print expect 1, actual $data01 + return -1 +endi + +sql select * from $mt +print ===>rows $rows, data $data01 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 3 then + print expect 3 actual: $data02 + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/cache/restart_table.sim b/tests/script/general/cache/restart_table.sim new file mode 100644 index 0000000000000000000000000000000000000000..1f7d982a2848a5df443f32a8c2b5c1edb97874d2 --- /dev/null +++ b/tests/script/general/cache/restart_table.sim @@ -0,0 +1,57 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect +print ======================== dnode1 start + +$i = 0 +$dbPrefix = ca_rt_db +$tbPrefix = ca_rt_tb +$mtPrefix = ca_rt_mt +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db + +sql create table $tb (ts timestamp, speed bool) +sql insert into $tb values (now, 1) +sql select * from $tb +print ===>rows $rows, data $data01 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +print =============== step2 +system sh/exec.sh -n dnode1 -s stop +sleep 3000 +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +print =============== step3 +print ==> sleep 1 seconds to renew cache +sql reset query cache +sleep 1000 + +print =============== step4 +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed int) +sql insert into $tb values (now, 1) +sql select * from $tb +print ===>rows $rows, data $data01 +if $data01 != 1 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/cache/testSuite.sim b/tests/script/general/cache/testSuite.sim new file mode 100644 index 0000000000000000000000000000000000000000..f09ece89b6574af1261d6127624a78a222b5fbd5 --- /dev/null +++ b/tests/script/general/cache/testSuite.sim @@ -0,0 +1,3 @@ +run general/cache/new_metrics.sim +run general/cache/restart_table.sim +run general/cache/restart_metrics.sim diff --git a/tests/script/general/column/commit.sim b/tests/script/general/column/commit.sim new file mode 100644 index 0000000000000000000000000000000000000000..008bec3bf9dc6c0bd8ca0a4c2b5816a9a22c93b2 --- /dev/null +++ b/tests/script/general/column/commit.sim @@ -0,0 +1,151 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print =============== step1 +sql create database d3 +sql use d3 +sql create table d3.mt (ts timestamp, c000 int, c001 int, c002 int, c003 int, c004 int, c005 int, c006 int, c007 int, c008 int, c009 int, c010 int, c011 int, c012 int, c013 int, c014 int, c015 int, c016 int, c017 int, c018 int, c019 int, c020 int, c021 int, c022 int, c023 int, c024 int, c025 int, c026 int, c027 int, c028 int, c029 int, c030 int, c031 int, c032 int, c033 int, c034 int, c035 int, c036 int, c037 int, c038 int, c039 int, c040 int, c041 int, c042 int, c043 int, c044 int, c045 int, c046 int, c047 int, c048 int, c049 int, c050 int, c051 int, c052 int, c053 int, c054 int, c055 int, c056 int, c057 int, c058 int, c059 int, c060 int, c061 int, c062 int, c063 int, c064 int, c065 int, c066 int, c067 int, c068 int, c069 int, c070 int, c071 int, c072 int, c073 int, c074 int, c075 int, c076 int, c077 int, c078 int, c079 int, c080 int, c081 int, c082 int, c083 int, c084 int, c085 int, c086 int, c087 int, c088 int, c089 int, c090 int, c091 int, c092 int, c093 int, c094 int, c095 int, c096 int, c097 int, c098 int, c099 int, c100 int, c101 int, c102 int, c103 int, c104 int, c105 int, c106 int, c107 int, c108 int, c109 int, c110 int, c111 int, c112 int, c113 int, c114 int, c115 int, c116 int, c117 int, c118 int, c119 int, c120 int, c121 int, c122 int, c123 int, c124 int, c125 int, c126 int, c127 int, c128 int, c129 int, c130 int, c131 int, c132 int, c133 int, c134 int, c135 int, c136 int, c137 int, c138 int, c139 int, c140 int, c141 int, c142 int, c143 int, c144 int, c145 int, c146 int, c147 int, c148 int, c149 int, c150 int, c151 int, c152 int, c153 int, c154 int, c155 int, c156 int, c157 int, c158 int, c159 int, c160 int, c161 int, c162 int, c163 int, c164 int, c165 int, c166 int, c167 int, c168 int, c169 int, c170 int, c171 int, c172 int, c173 int, c174 int, c175 int, c176 int, c177 int, c178 int, c179 int, c180 int, c181 int, c182 int, c183 int, c184 int, c185 int, c186 int, c187 int, c188 int, c189 int, c190 int, c191 int, c192 int, c193 int, c194 int, c195 int, c196 int, c197 int, c198 int, c199 int, c200 int, c201 int, c202 int, c203 int, c204 int, c205 int, c206 int, c207 int, c208 int, c209 int, c210 int, c211 int, c212 int, c213 int, c214 int, c215 int, c216 int, c217 int, c218 int, c219 int, c220 int, c221 int, c222 int, c223 int, c224 int, c225 int, c226 int, c227 int, c228 int, c229 int, c230 int, c231 int, c232 int, c233 int, c234 int, c235 int, c236 int, c237 int, c238 int, c239 int, c240 int, c241 int, c242 int, c243 int, c244 int, c245 int, c246 int, c247 int, c248 int) tags(a int, b smallint, c binary(20), d float, e double, f bigint) +sql create table d3.t1 using d3.mt tags(1, 2, '3', 4, 5, 6) + +sql show tables +if $rows != 1 then + return -1 +endi + +sql show stables +if $rows != 1 then + return -1 +endi + +print =============== step2 + +sql insert into d3.t1 values (now -300d,0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ); +sql insert into d3.t1 values (now-200d,1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ); +sql insert into d3.t1 values (now-150d,2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 ); +sql insert into d3.t1 values (now-100d,3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 ); +sql insert into d3.t1 values (now-50d,4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 ); +sql insert into d3.t1 values (now-20d,5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 ); +sql insert into d3.t1 values (now-10d,6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 ); +sql insert into d3.t1 values (now-1d,7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 ); +sql insert into d3.t1 values (now,8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 ); +sql insert into d3.t1 values (now+1d,9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 ); + +print =============== step3 + +sql select * from d3.mt +if $rows != 10 then + return -1 +endi + +sql select * from d3.mt where c001 = 1 +if $rows != 1 then + return -1 +endi + +sql select * from d3.mt where c002 = 2 and c003 = 2 +if $rows != 1 then + return -1 +endi + +sql select count(c001), count(c248), avg(c001), avg(c248), sum(c001), max(c001), min(c248), avg(c235), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*) from d3.mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data00 != 10 then + return -1 +endi +if $data01 != 10 then + return -1 +endi +if $data02 != 4.500000000 then + return -1 +endi +if $data03 != 4.500000000 then + return -1 +endi +if $data04 != 45 then + return -1 +endi +if $data05 != 9 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data07 != 4.500000000 then + return -1 +endi +if $data08 != 10 then + return -1 +endi +if $data09 != 10 then + return -1 +endi + +print =============== step4 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +print =============== step5 + +sql select * from d3.mt +if $rows != 10 then + return -1 +endi + +sql select * from d3.mt where c001 = 1 +if $rows != 1 then + return -1 +endi + +sql select * from d3.mt where c002 = 2 and c003 = 2 +if $rows != 1 then + return -1 +endi + +sql select count(*) from d3.mt +if $data00 != 10 then + return -1 +endi + +sql select count(c001), count(c248), avg(c001), avg(c248), sum(c001), max(c001), min(c248), avg(c128), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*) from d3.mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data00 != 10 then + return -1 +endi +if $data01 != 10 then + return -1 +endi +if $data02 != 4.500000000 then + return -1 +endi +if $data03 != 4.500000000 then + return -1 +endi +if $data04 != 45 then + return -1 +endi +if $data05 != 9 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data07 != 4.500000000 then + return -1 +endi +if $data08 != 10 then + return -1 +endi +if $data09 != 10 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/column/metrics.sim b/tests/script/general/column/metrics.sim new file mode 100644 index 0000000000000000000000000000000000000000..580e2320cd139af4bd9174f7eecef6dbdef97396 --- /dev/null +++ b/tests/script/general/column/metrics.sim @@ -0,0 +1,219 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print =============== step1 +sql create database d2 +sql use d2 +sql create table d2.mt (ts timestamp, c000 int, c001 int, c002 int, c003 int, c004 int, c005 int, c006 int, c007 int, c008 int, c009 int, c010 int, c011 int, c012 int, c013 int, c014 int, c015 int, c016 int, c017 int, c018 int, c019 int, c020 int, c021 int, c022 int, c023 int, c024 int, c025 int, c026 int, c027 int, c028 int, c029 int, c030 int, c031 int, c032 int, c033 int, c034 int, c035 int, c036 int, c037 int, c038 int, c039 int, c040 int, c041 int, c042 int, c043 int, c044 int, c045 int, c046 int, c047 int, c048 int, c049 int, c050 int, c051 int, c052 int, c053 int, c054 int, c055 int, c056 int, c057 int, c058 int, c059 int, c060 int, c061 int, c062 int, c063 int, c064 int, c065 int, c066 int, c067 int, c068 int, c069 int, c070 int, c071 int, c072 int, c073 int, c074 int, c075 int, c076 int, c077 int, c078 int, c079 int, c080 int, c081 int, c082 int, c083 int, c084 int, c085 int, c086 int, c087 int, c088 int, c089 int, c090 int, c091 int, c092 int, c093 int, c094 int, c095 int, c096 int, c097 int, c098 int, c099 int, c100 int, c101 int, c102 int, c103 int, c104 int, c105 int, c106 int, c107 int, c108 int, c109 int, c110 int, c111 int, c112 int, c113 int, c114 int, c115 int, c116 int, c117 int, c118 int, c119 int, c120 int, c121 int, c122 int, c123 int, c124 int, c125 int, c126 int, c127 int, c128 int, c129 int, c130 int, c131 int, c132 int, c133 int, c134 int, c135 int, c136 int, c137 int, c138 int, c139 int, c140 int, c141 int, c142 int, c143 int, c144 int, c145 int, c146 int, c147 int, c148 int, c149 int, c150 int, c151 int, c152 int, c153 int, c154 int, c155 int, c156 int, c157 int, c158 int, c159 int, c160 int, c161 int, c162 int, c163 int, c164 int, c165 int, c166 int, c167 int, c168 int, c169 int, c170 int, c171 int, c172 int, c173 int, c174 int, c175 int, c176 int, c177 int, c178 int, c179 int, c180 int, c181 int, c182 int, c183 int, c184 int, c185 int, c186 int, c187 int, c188 int, c189 int, c190 int, c191 int, c192 int, c193 int, c194 int, c195 int, c196 int, c197 int, c198 int, c199 int, c200 int, c201 int, c202 int, c203 int, c204 int, c205 int, c206 int, c207 int, c208 int, c209 int, c210 int, c211 int, c212 int, c213 int, c214 int, c215 int, c216 int, c217 int, c218 int, c219 int, c220 int, c221 int, c222 int, c223 int, c224 int, c225 int, c226 int, c227 int, c228 int, c229 int, c230 int, c231 int, c232 int, c233 int, c234 int, c235 int, c236 int, c237 int, c238 int, c239 int, c240 int, c241 int, c242 int, c243 int, c244 int, c245 int, c246 int, c247 int, c248 int) tags(a int, b smallint, c binary(20), d float, e double, f bigint) +sql create table d2.t1 using d2.mt tags(1, 2, '3', 4, 5, 6) +sql create table d2.t2 using d2.mt tags(6, 7, '8', 9, 10, 11) + +sql show tables +if $rows != 2 then + return -1 +endi + +sql show stables +if $rows != 1 then + return -1 +endi + +print =============== step2 + +sql insert into d2.t1 values (now,0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ) +sql insert into d2.t1 values (now+1m,1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ) +sql insert into d2.t1 values (now+2m,2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 ) +sql insert into d2.t1 values (now+3m,3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 ) +sql insert into d2.t1 values (now+4m,4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 ) +sql insert into d2.t1 values (now+5m,5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 ) + +sql insert into d2.t1 values (now+6m,6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 ) + +sql insert into d2.t1 values (now+7m,7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 ) + +sql insert into d2.t1 values (now+8m,8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 ) + +sql insert into d2.t1 values (now+9m,9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 ) + +sql insert into d2.t2 values (now,0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ) +sql insert into d2.t2 values (now+1m,1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ) +sql insert into d2.t2 values (now+2m,2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 ) +sql insert into d2.t2 values (now+3m,3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 ) +sql insert into d2.t2 values (now+4m,4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 ) +sql insert into d2.t2 values (now+5m,5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 ) + +sql insert into d2.t2 values (now+6m,6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 ) + +sql insert into d2.t2 values (now+7m,7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 ) + +sql insert into d2.t2 values (now+8m,8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 ) + +sql insert into d2.t2 values (now+9m,9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 ) + +print =============== step3 + +sql select * from d2.mt +if $rows != 20 then + return -1 +endi + +sql select * from d2.mt where ts < now + 4m +if $rows != 10 then + return -1 +endi + +sql select * from d2.mt where c001 = 1 +if $rows != 2 then + return -1 +endi + +sql select * from d2.mt where c002 = 2 and c003 = 2 +if $rows != 2 then + return -1 +endi + +sql select * from d2.mt where c002 = 2 and c003 = 2 and ts < now + 4m +if $rows != 2 then + return -1 +endi + +sql select count(*) from d2.mt +if $data00 != 20 then + return -1 +endi + +sql select count(c001), count(c248), avg(c001), avg(c248), sum(c001), max(c001), min(c248), avg(c235), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*) from d2.mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data00 != 20 then + return -1 +endi +if $data01 != 20 then + return -1 +endi +if $data02 != 4.500000000 then + return -1 +endi +if $data03 != 4.500000000 then + return -1 +endi +if $data04 != 90 then + return -1 +endi +if $data05 != 9 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data07 != 4.500000000 then + return -1 +endi +if $data08 != 20 then + return -1 +endi +if $data09 != 20 then + return -1 +endi + +sql select count(c001), count(c248), avg(c001), avg(c248), sum(c001), max(c001), min(c248), avg(c238), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*) from d2.mt where a = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data00 != 10 then + return -1 +endi +if $data01 != 10 then + return -1 +endi +if $data02 != 4.500000000 then + return -1 +endi +if $data03 != 4.500000000 then + return -1 +endi +if $data04 != 45 then + return -1 +endi +if $data05 != 9 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data07 != 4.500000000 then + return -1 +endi +if $data08 != 10 then + return -1 +endi +if $data09 != 10 then + return -1 +endi + +print =============== step4 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +print =============== step5 + +sql select * from d2.mt +if $rows != 20 then + return -1 +endi + +sql select * from d2.mt where c001 = 1 +if $rows != 2 then + return -1 +endi + +sql select * from d2.mt where c002 = 2 and c003 = 2 +if $rows != 2 then + return -1 +endi + +sql select count(*) from d2.mt +if $data00 != 20 then + return -1 +endi + +sql select count(c001), count(c248), avg(c001), avg(c248), sum(c001), max(c001), min(c248), avg(c128), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*) from d2.mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data00 != 20 then + return -1 +endi +if $data01 != 20 then + return -1 +endi +if $data02 != 4.500000000 then + return -1 +endi +if $data03 != 4.500000000 then + return -1 +endi +if $data04 != 90 then + return -1 +endi +if $data05 != 9 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data07 != 4.500000000 then + return -1 +endi +if $data08 != 20 then + return -1 +endi +if $data09 != 20 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/column/table.sim b/tests/script/general/column/table.sim new file mode 100644 index 0000000000000000000000000000000000000000..46d5de1e82f957ac8ccd223ae28f80286a27a827 --- /dev/null +++ b/tests/script/general/column/table.sim @@ -0,0 +1,215 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print =============== step1 +sql create database d1 +sql use d1 +sql create table d1.t1 (ts timestamp, c000 int, c001 int, c002 int, c003 int, c004 int, c005 int, c006 int, c007 int, c008 int, c009 int, c010 int, c011 int, c012 int, c013 int, c014 int, c015 int, c016 int, c017 int, c018 int, c019 int, c020 int, c021 int, c022 int, c023 int, c024 int, c025 int, c026 int, c027 int, c028 int, c029 int, c030 int, c031 int, c032 int, c033 int, c034 int, c035 int, c036 int, c037 int, c038 int, c039 int, c040 int, c041 int, c042 int, c043 int, c044 int, c045 int, c046 int, c047 int, c048 int, c049 int, c050 int, c051 int, c052 int, c053 int, c054 int, c055 int, c056 int, c057 int, c058 int, c059 int, c060 int, c061 int, c062 int, c063 int, c064 int, c065 int, c066 int, c067 int, c068 int, c069 int, c070 int, c071 int, c072 int, c073 int, c074 int, c075 int, c076 int, c077 int, c078 int, c079 int, c080 int, c081 int, c082 int, c083 int, c084 int, c085 int, c086 int, c087 int, c088 int, c089 int, c090 int, c091 int, c092 int, c093 int, c094 int, c095 int, c096 int, c097 int, c098 int, c099 int, c100 int, c101 int, c102 int, c103 int, c104 int, c105 int, c106 int, c107 int, c108 int, c109 int, c110 int, c111 int, c112 int, c113 int, c114 int, c115 int, c116 int, c117 int, c118 int, c119 int, c120 int, c121 int, c122 int, c123 int, c124 int, c125 int, c126 int, c127 int, c128 int, c129 int, c130 int, c131 int, c132 int, c133 int, c134 int, c135 int, c136 int, c137 int, c138 int, c139 int, c140 int, c141 int, c142 int, c143 int, c144 int, c145 int, c146 int, c147 int, c148 int, c149 int, c150 int, c151 int, c152 int, c153 int, c154 int, c155 int, c156 int, c157 int, c158 int, c159 int, c160 int, c161 int, c162 int, c163 int, c164 int, c165 int, c166 int, c167 int, c168 int, c169 int, c170 int, c171 int, c172 int, c173 int, c174 int, c175 int, c176 int, c177 int, c178 int, c179 int, c180 int, c181 int, c182 int, c183 int, c184 int, c185 int, c186 int, c187 int, c188 int, c189 int, c190 int, c191 int, c192 int, c193 int, c194 int, c195 int, c196 int, c197 int, c198 int, c199 int, c200 int, c201 int, c202 int, c203 int, c204 int, c205 int, c206 int, c207 int, c208 int, c209 int, c210 int, c211 int, c212 int, c213 int, c214 int, c215 int, c216 int, c217 int, c218 int, c219 int, c220 int, c221 int, c222 int, c223 int, c224 int, c225 int, c226 int, c227 int, c228 int, c229 int, c230 int, c231 int, c232 int, c233 int, c234 int, c235 int, c236 int, c237 int, c238 int, c239 int, c240 int, c241 int, c242 int, c243 int, c244 int, c245 int, c246 int, c247 int, c248 int, c249 int, c250 int) + +sql show tables +if $rows != 1 then + return -1 +endi + +print =============== step2 + +sql insert into d1.t1 values (now,0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ) +sql insert into d1.t1 values (now+1m,1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ) +sql insert into d1.t1 values (now+2m,2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 ) +sql insert into d1.t1 values (now+3m,3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 ) +sql insert into d1.t1 values (now+4m,4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 ) +sql insert into d1.t1 values (now+5m,5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 ) + +sql insert into d1.t1 values (now+6m,6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 ) + +sql insert into d1.t1 values (now+7m,7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 ) + +sql insert into d1.t1 values (now+8m,8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 ) + +sql insert into d1.t1 values (now+9m,9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 ) + +print ======= step3 + +sql select * from d1.t1 +print select * from d1.t1 => rows $rows +if $rows != 10 then + return -1 +endi + +sql select * from d1.t1 where ts < now + 4m +print select * from d1.t1 where ts < now + 4m => rows $rows +if $rows != 5 then + return -1 +endi + +sql select * from d1.t1 where c001 = 1 +print select * from d1.t1 where c001 = 1 => rows $rows +if $rows != 1 then + return -1 +endi + +sql select * from d1.t1 where c002 = 2 and c003 = 2 +print select * from d1.t1 where c002 = 2 and c003 = 2 => rows $rows +if $rows != 1 then + return -1 +endi + +sql select * from d1.t1 where c002 = 2 and c003 = 2 and ts < now + 4m +print select * from d1.t1 where c002 = 2 and c003 = 2 and ts < now + 4m => rows $rows +if $rows != 1 then + return -1 +endi + +sql select count(*) from d1.t1 +print select count(*) from d1.t1 => $data00 +if $data00 != 10 then + return -1 +endi + +sql select count(c001), count(c250), avg(c001), avg(c250), sum(c001), max(c001), min(c250), stddev(c250) from d1.t1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 +if $data00 != 10 then + return -1 +endi +if $data01 != 10 then + return -1 +endi +if $data02 != 4.500000000 then + return -1 +endi +if $data03 != 4.500000000 then + return -1 +endi +if $data04 != 45 then + return -1 +endi +if $data05 != 9 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data07 != 2.872281323 then + return -1 +endi + +sql select count(c001), count(c250), avg(c001), avg(c250), sum(c001), max(c001), min(c250), stddev(c250), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*) from d1.t1 + +if $data00 != 10 then + return -1 +endi +if $data01 != 10 then + return -1 +endi +if $data02 != 4.500000000 then + return -1 +endi +if $data03 != 4.500000000 then + return -1 +endi +if $data04 != 45 then + return -1 +endi +if $data05 != 9 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data07 != 2.872281323 then + return -1 +endi + +print =============== step4 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +print ============== step5 + +sql select * from d1.t1 +print select * from d1.t1 => rows $rows +if $rows != 10 then + return -1 +endi + +sql select * from d1.t1 where c001 = 1 +print select * from d1.t1 where c001 = 1 => rows $rows +if $rows != 1 then + return -1 +endi + +sql select * from d1.t1 where c002 = 2 and c003 = 2 +print select * from d1.t1 where c002 = 2 and c003 = 2 => rows $rows +if $rows != 1 then + return -1 +endi + +sql select count(*) from d1.t1 +print select count(*) from d1.t1 => $data00 +if $data00 != 10 then + return -1 +endi + +sql select count(c001), count(c250), avg(c001), avg(c250), sum(c001), max(c001), min(c250), stddev(c250) from d1.t1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 +if $data00 != 10 then + return -1 +endi +if $data01 != 10 then + return -1 +endi +if $data02 != 4.500000000 then + return -1 +endi +if $data03 != 4.500000000 then + return -1 +endi +if $data04 != 45 then + return -1 +endi +if $data05 != 9 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data07 != 2.872281323 then + return -1 +endi + +sql select count(c001), count(c250), avg(c001), avg(c250), sum(c001), max(c001), min(c250), stddev(c250), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*) from d1.t1 +if $data00 != 10 then + return -1 +endi +if $data01 != 10 then + return -1 +endi +if $data02 != 4.500000000 then + return -1 +endi +if $data03 != 4.500000000 then + return -1 +endi +if $data04 != 45 then + return -1 +endi +if $data05 != 9 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data07 != 2.872281323 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/column/testSuite.sim b/tests/script/general/column/testSuite.sim new file mode 100644 index 0000000000000000000000000000000000000000..f60d197e95dd2285f2b5b155c0d361b8a28bd90e --- /dev/null +++ b/tests/script/general/column/testSuite.sim @@ -0,0 +1,3 @@ +run general/column/commit.sim +run general/column/metrics.sim +run general/column/table.sim diff --git a/tests/script/general/compress/commitlog.sim b/tests/script/general/compress/commitlog.sim new file mode 100644 index 0000000000000000000000000000000000000000..e8eab6ed0cd9b5b6c2ea70042bd0f24e92c512a6 --- /dev/null +++ b/tests/script/general/compress/commitlog.sim @@ -0,0 +1,126 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c comp -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect +print ============================ dnode1 start + +$i = 0 +$dbPrefix = db +$tbPrefix = tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +$N = 2000 + +print =============== step1 + +sql create database $db +sql use $db +sql create table $tb (ts timestamp, b bool, t tinyint, s smallint, i int, big bigint, str binary(256)) + +$count = 0 +while $count < $N + $ms = 1591200000000 + $count + sql insert into $tb values( $ms , 1, 0, $count , $count , $count ,'it is a string') + $count = $count + 1 +endw + +sql select * from $tb +if $rows != $N then + return -1 +endi + +print =============== step2 +$i = 1 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +sql create database $db +sql use $db +sql create table $tb (ts timestamp, f float, d double, str binary(256)) + +$count = 0 +while $count < $N + $ms = 1591286400000 + $count + sql insert into $tb values( $ms , $count , $count ,'it is a string') + $count = $count + 1 +endw + +sql select * from $tb +if $rows != $N then + return -1 +endi + +print =============== step3 +$i = 2 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +sql create database $db +sql use $db + +$x = 0 +step3: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create table $tb (ts timestamp, b bool, t tinyint, s smallint, i int, big bigint, f float, d double, str binary(256)) -x step3 + +$count = 0 +while $count < $N + $ms = 1591372800000 + $count + sql insert into $tb values( $ms , 1 , 0 , $count , $count , $count , $count , $count ,'it is a string') + $count = $count + 1 +endw + +sql select * from $tb +if $rows != $N then + return -1 +endi + +print =============== step4 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +print =============== step5 + +$i = 0 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +sql use $db +sql select * from $tb +print select * from $tb ==> $rows points +if $rows != $N then + return -1 +endi + +$i = 1 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +sql use $db +sql select * from $tb +print select * from $tb ==> $rows points +if $rows != $N then + return -1 +endi + +$i = 2 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +sql use $db +sql select * from $tb +print select * from $tb ==> $rows points +if $rows != $N then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compress/compress.sim b/tests/script/general/compress/compress.sim new file mode 100644 index 0000000000000000000000000000000000000000..cecfe61229667086d83e963b8833ae9b0fabc2da --- /dev/null +++ b/tests/script/general/compress/compress.sim @@ -0,0 +1,121 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c comp -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ============================ dnode1 start + +$i = 0 +$dbPrefix = db +$tbPrefix = tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +$N = 2000 + +print =============== step1 + +sql create database $db +sql use $db +sql create table $tb (ts timestamp, b bool, t tinyint, s smallint, i int, big bigint, str binary(256)) + +$count = 0 +while $count < $N + $ms = 1591200000000 + $count + sql insert into $tb values( $ms , 1, 0, $count , $count , $count ,'it is a string') + $count = $count + 1 +endw + +sql select * from $tb +if $rows != $N then + return -1 +endi + +print =============== step2 +$i = 1 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +sql create database $db +sql use $db + +sql create table $tb (ts timestamp, f float, d double, str binary(256)) + +$count = 0 +while $count < $N + $ms = 1591286400000 + $count + sql insert into $tb values( $ms , $count , $count ,'it is a string') + $count = $count + 1 +endw + +sql select * from $tb +if $rows != $N then + return -1 +endi + +print =============== step3 +$i = 2 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +sql create database $db +sql use $db + +sql create table $tb (ts timestamp, b bool, t tinyint, s smallint, i int, big bigint, f float, d double, str binary(256)) + +$count = 0 +while $count < $N + $ms = 1591372800000 + $count + sql insert into $tb values( $ms , 1 , 0 , $count , $count , $count , $count , $count ,'it is a string') + $count = $count + 1 +endw + +sql select * from $tb +if $rows != $N then + return -1 +endi + +print =============== step4 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +print =============== step5 + +$i = 0 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +sql use $db +sql select * from $tb +print select * from $tb ==> $rows points +if $rows != $N then + return -1 +endi + +$i = 1 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +sql use $db +sql select * from $tb +print select * from $tb ==> $rows points +if $rows != $N then + return -1 +endi + +$i = 2 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +sql use $db +sql select * from $tb +print select * from $tb ==> $rows points +if $rows != $N then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compress/compress2.sim b/tests/script/general/compress/compress2.sim new file mode 100644 index 0000000000000000000000000000000000000000..1e6868eaa6382218e4f4d1b8fb3f69c8762f77c8 --- /dev/null +++ b/tests/script/general/compress/compress2.sim @@ -0,0 +1,121 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c comp -v 2 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ============================ dnode1 start + +$i = 0 +$dbPrefix = db +$tbPrefix = tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +$N = 2000 + +print =============== step1 + +sql create database $db +sql use $db +sql create table $tb (ts timestamp, b bool, t tinyint, s smallint, i int, big bigint, str binary(256)) + +$count = 0 +while $count < $N + $ms = 1591200000000 + $count + sql insert into $tb values( $ms , 1, 0, $count , $count , $count ,'it is a string') + $count = $count + 1 +endw + +sql select * from $tb +if $rows != $N then + return -1 +endi + +print =============== step2 +$i = 1 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +sql create database $db +sql use $db + +sql create table $tb (ts timestamp, f float, d double, str binary(256)) + +$count = 0 +while $count < $N + $ms = 1591286400000 + $count + sql insert into $tb values( $ms , $count , $count ,'it is a string') + $count = $count + 1 +endw + +sql select * from $tb +if $rows != $N then + return -1 +endi + +print =============== step3 +$i = 2 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +sql create database $db +sql use $db + +sql create table $tb (ts timestamp, b bool, t tinyint, s smallint, i int, big bigint, f float, d double, str binary(256)) + +$count = 0 +while $count < $N + $ms = 1591372800000 + $count + sql insert into $tb values( $ms , 1 , 0 , $count , $count , $count , $count , $count ,'it is a string') + $count = $count + 1 +endw + +sql select * from $tb +if $rows != $N then + return -1 +endi + +print =============== step4 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +print =============== step5 + +$i = 0 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +sql use $db +sql select * from $tb +print select * from $tb ==> $rows points +if $rows != $N then + return -1 +endi + +$i = 1 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +sql use $db +sql select * from $tb +print select * from $tb ==> $rows points +if $rows != $N then + return -1 +endi + +$i = 2 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +sql use $db +sql select * from $tb +print select * from $tb ==> $rows points +if $rows != $N then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compress/testSuite.sim b/tests/script/general/compress/testSuite.sim new file mode 100644 index 0000000000000000000000000000000000000000..3573985c8a90be4cab0b5abeaa37dbae0b2eefdd --- /dev/null +++ b/tests/script/general/compress/testSuite.sim @@ -0,0 +1,4 @@ +run general/compress/commitlog.sim +run general/compress/compress2.sim +run general/compress/compress.sim +run general/compress/uncompress.sim diff --git a/tests/script/general/compress/uncompress.sim b/tests/script/general/compress/uncompress.sim new file mode 100644 index 0000000000000000000000000000000000000000..49945dcb79ef69b31aa8cc4e8b0009e2ceb691f1 --- /dev/null +++ b/tests/script/general/compress/uncompress.sim @@ -0,0 +1,120 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c comp -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect +print ============================ dnode1 start + +$i = 0 +$dbPrefix = cp_cp_db +$tbPrefix = cp_cp_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +$N = 2000 + +print =============== step1 + +sql create database $db +sql use $db + +sql create table $tb (ts timestamp, b bool, t tinyint, s smallint, i int, big bigint, str binary(256)) + +$count = 0 +while $count < $N + $ms = 1591200000000 + $count + sql insert into $tb values( $ms , 1, 0, $count , $count , $count ,'it is a string') + $count = $count + 1 +endw + +sql select * from $tb +if $rows != $N then + return -1 +endi + +print =============== step2 +$i = 1 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +sql create database $db +sql use $db + +sql create table $tb (ts timestamp, f float, d double, str binary(256)) + +$count = 0 +while $count < $N + $ms = 1591286400000 + $count + sql insert into $tb values( $ms , $count , $count ,'it is a string') + $count = $count + 1 +endw + +sql select * from $tb +if $rows != $N then + return -1 +endi + +print =============== step3 +$i = 2 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +sql create database $db +sql use $db + +sql create table $tb (ts timestamp, b bool, t tinyint, s smallint, i int, big bigint, f float, d double, str binary(256)) + +$count = 0 +while $count < $N + $ms = 1591372800000 + $count + sql insert into $tb values( $ms , 1 , 0 , $count , $count , $count , $count , $count ,'it is a string') + $count = $count + 1 +endw + +sql select * from $tb +if $rows != $N then + return -1 +endi + +print =============== step4 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +sleep 2000 + +print =============== step5 + +$i = 0 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +sql use $db +sql select * from $tb +print select * from $tb ==> $rows points +if $rows != $N then + return -1 +endi + +$i = 1 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +sql use $db +sql select * from $tb +print select * from $tb ==> $rows points +if $rows != $N then + return -1 +endi + +$i = 2 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +sql use $db +sql select * from $tb +print select * from $tb ==> $rows points +if $rows != $N then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compute/avg.sim b/tests/script/general/compute/avg.sim new file mode 100644 index 0000000000000000000000000000000000000000..db452b0344b6cbe14f313e613e737415780aeb27 --- /dev/null +++ b/tests/script/general/compute/avg.sim @@ -0,0 +1,170 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +$dbPrefix = m_av_db +$tbPrefix = m_av_tb +$mtPrefix = m_av_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select avg(tbcol) from $tb +print ===> $data00 +if $data00 != 9.500000000 then + return -1 +endi + +print =============== step3 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select avg(tbcol) from $tb where ts <= $ms +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +print =============== step4 +sql select avg(tbcol) as b from $tb +print ===> $data00 +if $data00 != 9.500000000 then + return -1 +endi + +print =============== step5 +sql select avg(tbcol) as b from $tb interval(1m) +print ===> $data01 +if $data11 != 1.000000000 then + return -1 +endi + +sql select avg(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != 9.500000000 then + return -1 +endi + +print =============== step6 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select avg(tbcol) as b from $tb where ts <= $ms interval(1m) +print ===> $data01 +if $data41 != 4.000000000 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select avg(tbcol) from $mt +print ===> $data00 +if $data00 != 9.500000000 then + return -1 +endi + +print =============== step8 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select avg(tbcol) as c from $mt where ts <= $ms +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select avg(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 9.500000000 then + return -1 +endi + +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select avg(tbcol) as c from $mt where tgcol < 5 and ts <= $ms +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +print =============== step9 +sql select avg(tbcol) as b from $mt interval(1m) +print ===> $data11 +if $data11 != 1.000000000 then + return -1 +endi + +sql select avg(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 9.500000000 then + return -1 +endi + +print =============== step10 +sql select avg(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != 9.500000000 then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select avg(tbcol) as b from $mt where ts <= $ms interval(1m) group by tgcol +print ===> $data11 +if $data11 != 1.000000000 then + return -1 +endi +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compute/block_dist.sim b/tests/script/general/compute/block_dist.sim new file mode 100644 index 0000000000000000000000000000000000000000..5343c1db286d41c6f1d588617a1123f4993ccf29 --- /dev/null +++ b/tests/script/general/compute/block_dist.sim @@ -0,0 +1,98 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +$dbPrefix = m_di_db +$tbPrefix = m_di_tb +$mtPrefix = m_di_mt +$ntPrefix = m_di_nt +$tbNum = 1 +$rowNum = 2000 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$nt = $ntPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $cc = $x * 60000 + $ms = 1601481600000 + $cc + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sql create table $nt (ts timestamp, tbcol int) +$x = 0 +while $x < $rowNum + $cc = $x * 60000 + $ms = 1601481600000 + $cc + sql insert into $nt values ($ms , $x ) + $x = $x + 1 +endw + +sleep 100 + +print =============== step2 +$i = 0 +$tb = $tbPrefix . $i + +sql select _block_dist() from $tb + +if $rows != 1 then + print expect 1, actual:$rows + return -1 +endi + +print =============== step3 +$i = 0 +$mt = $mtPrefix . $i +sql select _block_dist() from $mt + +if $rows != 1 then + print expect 1, actual:$rows + return -1 +endi + +print =============== step4 +$i = 0 +$nt = $ntPrefix . $i + +sql select _block_dist() from $nt + +if $rows != 1 then + print expect 1, actual:$rows + return -1 +endi + +print ============== TD-5998 +sql_error select _block_dist() from (select * from $nt) +sql_error select _block_dist() from (select * from $mt) + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/compute/bottom.sim b/tests/script/general/compute/bottom.sim new file mode 100644 index 0000000000000000000000000000000000000000..7af67ecbf0237bd591d84a243fd88b80e167e4f7 --- /dev/null +++ b/tests/script/general/compute/bottom.sim @@ -0,0 +1,105 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +$dbPrefix = m_bo_db +$tbPrefix = m_bo_tb +$mtPrefix = m_bo_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select bottom(tbcol, 1) from $tb +print ===> $data01 +if $data01 != 0 then + return -1 +endi + +print =============== step3 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select bottom(tbcol, 1) from $tb where ts > $ms +print ===> $data01 +if $data01 != 5 then + return -1 +endi + +print =============== step4 +sql select bottom(tbcol, 1) as b from $tb +print ===> $data01 +if $data01 != 0 then + return -1 +endi + +print =============== step5 +sql select bottom(tbcol, 2) as b from $tb +print ===> $data01 $data11 +if $data01 != 0 then + return -1 +endi +if $data11 != 1 then + return -1 +endi + +print =============== step6 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select bottom(tbcol, 2) as b from $tb where ts > $ms +print ===> $data01 $data11 +if $data01 != 5 then + return -1 +endi +if $data11 != 6 then + return -1 +endi + +sql select bottom(tbcol, 122) as b from $tb -x step6 + return -1 +step6: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compute/count.sim b/tests/script/general/compute/count.sim new file mode 100644 index 0000000000000000000000000000000000000000..cf84918f5b7c2bd5a396b6457c75b4c59b62bb19 --- /dev/null +++ b/tests/script/general/compute/count.sim @@ -0,0 +1,199 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +$dbPrefix = m_co_db +$tbPrefix = m_co_tb +$mtPrefix = m_co_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + + +sql select count(*) from $tb +print ===> select count(*) from $tb => $data00 +if $data00 != $rowNum then + return -1 +endi + +sql select count(1) from $tb +print ===> select count(1) from $tb => $data00 +if $data00 != $rowNum then + return -1 +endi + +sql select count(tbcol) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step3 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select count(tbcol) from $tb where ts <= $ms +print ===> $data00 +if $data00 != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol) as b from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step5 +sql select count(tbcol) as b from $tb interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi + +sql select count(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != $rowNum then + return -1 +endi + +print =============== step6 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select count(tbcol) as b from $tb where ts <= $ms interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select count(*) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +print =============== step8 +sql select count(1) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +sql select count(tbcol) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +print =============== step10 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select count(tbcol) as c from $mt where ts <= $ms +print ===> $data00 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 100 then + return -1 +endi + +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select count(tbcol) as c from $mt where tgcol < 5 and ts <= $ms +print ===> $data00 +if $data00 != 25 then + return -1 +endi + +print =============== step9 +sql select count(tbcol) as b from $mt interval(1m) +print ===> $data01 +if $data01 != 10 then + return -1 +endi +if $data11 != 10 then + return -1 +endi + +sql select count(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 200 then + return -1 +endi + +print =============== step10 +sql select count(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select count(tbcol) as b from $mt where ts <= $ms interval(1m) group by tgcol +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/compute/diff.sim b/tests/script/general/compute/diff.sim new file mode 100644 index 0000000000000000000000000000000000000000..bc303a9ca59152fb34836da6d37535d7e049d754 --- /dev/null +++ b/tests/script/general/compute/diff.sim @@ -0,0 +1,98 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +$dbPrefix = m_di_db +$tbPrefix = m_di_tb +$mtPrefix = m_di_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $cc = $x * 60000 + $ms = 1601481600000 + $cc + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select diff(tbcol) from $tb +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +print =============== step3 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select diff(tbcol) from $tb where ts > $ms +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select diff(tbcol) from $tb where ts <= $ms +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +print =============== step4 +sql select diff(tbcol) as b from $tb +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +print =============== step5 +sql select diff(tbcol) as b from $tb interval(1m) -x step5 + return -1 +step5: + +print =============== step6 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select diff(tbcol) as b from $tb where ts <= $ms interval(1m) -x step6 + return -1 +step6: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compute/diff2.sim b/tests/script/general/compute/diff2.sim new file mode 100644 index 0000000000000000000000000000000000000000..55fa1daa95516729fb37b2e541067fe7abda19e6 --- /dev/null +++ b/tests/script/general/compute/diff2.sim @@ -0,0 +1,159 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +$dbPrefix = m_di_db +$tbPrefix = m_di_tb +$mtPrefix = m_di_mt +$tbNum = 2 +$rowNum = 10000 +$totalNum = 20000 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 nchar(5), c9 binary(10)) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + $tinyint = $x / 128 + sql insert into $tb values ($ms , $x , $x , $x , $x , $tinyint , $x , $x , $x , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select diff(c1) from $tb +print ===> $data11 +if $data11 != 1 then + return -1 +endi +sql select diff(c2) from $tb +print ===> $data11 +if $data11 != 1.00000 then + return -1 +endi +sql select diff(c3) from $tb +print ===> $data11 +if $data11 != 1 then + return -1 +endi +sql select diff(c4) from $tb +print ===> $data11 +if $data11 != 1 then + return -1 +endi +sql select diff(c5) from $tb +print ===> $data11 +if $data11 != 0 then + return -1 +endi +sql select diff(c6) from $tb +print ===> $data11 +if $data11 != 1.000000000 then + return -1 +endi +sql_error select diff(c7) from $tb +sql_error select diff(c8) from $tb +sql_error select diff(c9) from $tb +sql_error select diff(ts) from $tb +sql_error select diff(c1), diff(c2) from $tb +#sql_error select 2+diff(c1) from $tb +sql_error select diff(c1+2) from $tb +sql_error select diff(c1) from $tb where ts > 0 and ts < now + 100m interval(10m) +sql_error select diff(c1) from $mt +sql_error select diff(diff(c1)) from $tb +sql_error select diff(c1) from m_di_tb1 where c2 like '2%' + + +print =============== step3 +sql select diff(c1) from $tb where c1 > 5 +print ===> $data11 +if $data11 != 1 then + return -1 +endi +sql select diff(c2) from $tb where c2 > 5 +print ===> $data11 +if $data11 != 1.00000 then + return -1 +endi +sql select diff(c3) from $tb where c3 > 5 +print ===> $data11 +if $data11 != 1 then + return -1 +endi +sql select diff(c4) from $tb where c4 > 5 +print ===> $data11 +if $data11 != 1 then + return -1 +endi +sql select diff(c5) from $tb where c5 > 5 +print ===> $data11 +if $data11 != 0 then + return -1 +endi +sql select diff(c6) from $tb where c6 > 5 +print ===> $data11 +if $data11 != 1.000000000 then + return -1 +endi + +print =============== step4 +sql select diff(c1) from $tb where c1 > 5 and c2 < $rowNum +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select diff(c1) from $tb where c9 like '%9' and c1 <= 20 +if $rows != 1 then + return -1 +endi +print ===> $data11 +if $data01 != 10 then + return -1 +endi + +print =============== step5 +sql select diff(c1) as b from $tb interval(1m) -x step5 + return -1 +step5: + +print =============== step6 +sql select diff(c1) as b from $tb where ts < now + 4m interval(1m) -x step6 + return -1 +step6: + +print =============== clear +#sql drop database $db +#sql show databases +#if $rows != 0 then +# return -1 +#endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compute/first.sim b/tests/script/general/compute/first.sim new file mode 100644 index 0000000000000000000000000000000000000000..fce334167b7b553bdd056b2372a2fae30f2af79b --- /dev/null +++ b/tests/script/general/compute/first.sim @@ -0,0 +1,172 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +$dbPrefix = m_fi_db +$tbPrefix = m_fi_tb +$mtPrefix = m_fi_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select first(tbcol) from $tb +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step3 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select first(tbcol) from $tb where ts <= $ms +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step4 +sql select first(tbcol) as b from $tb +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step5 +sql select first(tbcol) as b from $tb interval(1m) +print ===> $data01 +if $data01 != 0 then + return -1 +endi + +sql select first(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != 0 then + return -1 +endi + +print =============== step6 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select first(tbcol) as b from $tb where ts <= $ms interval(1m) +print ===> $data01 +if $data41 != 4 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select first(tbcol) from $mt +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step8 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select first(tbcol) as c from $mt where ts <= $ms +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +sql select first(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select first(tbcol) as c from $mt where tgcol < 5 and ts <= $ms +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step9 +sql select first(tbcol) as b from $mt interval(1m) +print select first(tbcol) as b from $mt interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select first(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 0 then + return -1 +endi + +print =============== step10 +sql select first(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select first(tbcol) as b from $mt where ts <= $ms interval(1m) group by tgcol +print ===> $data11 +if $data11 != 1 then + return -1 +endi +print ===> $rows +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compute/interval.sim b/tests/script/general/compute/interval.sim new file mode 100644 index 0000000000000000000000000000000000000000..c21003a6463d00d53a2b75bd402f5a2a905247a0 --- /dev/null +++ b/tests/script/general/compute/interval.sim @@ -0,0 +1,206 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +$dbPrefix = m_in_db +$tbPrefix = m_in_tb +$mtPrefix = m_in_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb interval(1m) +print ===> $rows +if $rows < $rowNum then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data05 != 1 then + return -1 +endi + +print =============== step3 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms interval(1m) +print ===> $rows +if $rows > 10 then + return -1 +endi +if $rows < 3 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data05 != 1 then + return -1 +endi + +print =============== step4 +$cc = 40 * 60000 +$ms = 1601481600000 + $cc + +$cc = 1 * 60000 +$ms2 = 1601481600000 - $cc + +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m) +print ===> $rows +if $rows < 18 then + return -1 +endi +if $rows > 22 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data05 != 1 then + return -1 +endi + +print =============== step5 +$cc = 40 * 60000 +$ms = 1601481600000 + $cc + +$cc = 1 * 60000 +$ms2 = 1601481600000 - $cc + +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m) fill(value,0) +print ===> $rows +if $rows < 30 then + return -1 +endi +if $rows > 50 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data25 != 1 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt interval(1m) +print ===> $rows +if $rows < 18 then + return -1 +endi +if $rows > 22 then + return -1 +endi +if $data11 > 15 then + return -1 +endi +if $data11 < 5 then + return -1 +endi + +print =============== step7 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms interval(1m) +print ===> $rows +if $rows < 3 then + return -1 +endi +if $rows > 7 then + return -1 +endi +if $data11 > 15 then + return -1 +endi +if $data11 < 5 then + return -1 +endi + +print =============== step8 +$cc = 40 * 60000 +$ms1 = 1601481600000 + $cc + +$cc = 1 * 60000 +$ms2 = 1601481600000 - $cc + +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m) +print ===> $rows +if $rows < 18 then + return -1 +endi +if $rows > 22 then + return -1 +endi +if $data11 > 15 then + return -1 +endi +if $data11 < 5 then + return -1 +endi + +print =============== step9 +$cc = 40 * 60000 +$ms1 = 1601481600000 + $cc + +$cc = 1 * 60000 +$ms2 = 1601481600000 - $cc + +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m) fill(value, 0) +if $rows < 30 then + return -1 +endi +if $rows > 50 then + return -1 +endi +if $data11 > 15 then + return -1 +endi +if $data11 < 5 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compute/last.sim b/tests/script/general/compute/last.sim new file mode 100644 index 0000000000000000000000000000000000000000..9f20f8c5aa63416119e2148da575166602d0a226 --- /dev/null +++ b/tests/script/general/compute/last.sim @@ -0,0 +1,176 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +$dbPrefix = m_la_db +$tbPrefix = m_la_tb +$mtPrefix = m_la_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select last(tbcol) from $tb +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +print =============== step3 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select last(tbcol) from $tb where ts <= $ms +print ===> $data00 +if $data00 != 4 then + return -1 +endi + +print =============== step4 +sql select last(tbcol) as b from $tb +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +print =============== step5 +sql select last(tbcol) as b from $tb interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select last(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != 19 then + return -1 +endi + +print =============== step6 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select last(tbcol) as b from $tb where ts <= $ms interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select last(tbcol) from $mt +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +print =============== step8 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select last(tbcol) as c from $mt where ts <= $ms +print ===> $data00 +if $data00 != 4 then + return -1 +endi + +sql select last(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select last(tbcol) as c from $mt where tgcol < 5 and ts <= $ms +print ===> $data00 +if $data00 != 4 then + return -1 +endi + +print =============== step9 +sql select last(tbcol) as b from $mt interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select last(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 19 then + return -1 +endi + +print =============== step10 +sql select last(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select last(tbcol) as b from $mt where ts <= $ms interval(1m) group by tgcol +print ===> $data11 +if $data11 != 1 then + return -1 +endi +print ===> $rows +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compute/last_row.sim b/tests/script/general/compute/last_row.sim new file mode 100644 index 0000000000000000000000000000000000000000..3b28b0baa54d179693db7be1e7386a8701b8ff7f --- /dev/null +++ b/tests/script/general/compute/last_row.sim @@ -0,0 +1,224 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +$dbPrefix = m_la_db +$tbPrefix = m_la_tb +$mtPrefix = m_la_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select last_row(tbcol) from $tb +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +print =============== step3 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select last_row(tbcol) from $tb where ts <= $ms +print ===> $data00 +if $data00 != 4 then + return -1 +endi + +print =============== step4 +sql select last_row(tbcol) as b from $tb +print ===> $data00 +if $data00 != 19 then + return -1 +endi + + + +print =============== step7 +sql select last_row(tbcol) from $mt +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +print =============== step8 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select last_row(tbcol) as c from $mt where ts <= $ms +print ===> $data00 +if $data00 != 4 then + return -1 +endi + +sql select last_row(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select last_row(tbcol) as c from $mt where tgcol < 5 and ts <= $ms +print ===> $data00 +if $data00 != 4 then + return -1 +endi + + + +print =============== step10 +sql select last_row(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 + +$cc = 1 * 3600000 +$ms = 1601481600000 + $cc +sql insert into $tb values( $ms , 10) + +$cc = 3 * 3600000 +$ms = 1601481600000 + $cc +sql insert into $tb values( $ms , null) + +$cc = 5 * 3600000 +$ms = 1601481600000 + $cc + +sql insert into $tb values( $ms , -1) + +$cc = 7 * 3600000 +$ms = 1601481600000 + $cc + +sql insert into $tb values( $ms , null) + +## for super table +$cc = 6 * 3600000 +$ms = 1601481600000 + $cc + +sql select last_row(*) from $mt where ts < $ms +if $data01 != -1 then + return -1 +endi + +$cc = 8 * 3600000 +$ms = 1601481600000 + $cc + +sql select last_row(*) from $mt where ts < $ms +if $data01 != NULL then + return -1 +endi + +sql select last_row(*) from $mt +if $data01 != NULL then + return -1 +endi + +$cc = 4 * 3600000 +$ms = 1601481600000 + $cc + +sql select last_row(*) from $mt where ts < $ms +if $data01 != NULL then + return -1 +endi + +$cc = 1 * 3600000 +$ms1 = 1601481600000 + $cc +$cc = 4 * 3600000 +$ms2 = 1601481600000 + $cc + +sql select last_row(*) from $mt where ts > $ms1 and ts <= $ms2 +if $data01 != NULL then + return -1 +endi + +## for table +$cc = 6 * 3600000 +$ms = 1601481600000 + $cc + +sql select last_row(*) from $tb where ts <= $ms +if $data01 != -1 then + return -1 +endi + +$cc = 8 * 3600000 +$ms = 1601481600000 + $cc + +sql select last_row(*) from $tb where ts <= $ms +if $data01 != NULL then + return -1 +endi + +sql select last_row(*) from $tb +if $data01 != NULL then + return -1 +endi + +$cc = 4 * 3600000 +$ms = 1601481600000 + $cc + +sql select last_row(*) from $tb where ts <= $ms +if $data01 != NULL then + return -1 +endi + +$cc = 1 * 3600000 +$ms1 = 1601481600000 + $cc +$cc = 4 * 3600000 +$ms2 = 1601481600000 + $cc + +sql select last_row(*) from $tb where ts > $ms1 and ts <= $ms2 +if $data01 != NULL then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/compute/leastsquare.sim b/tests/script/general/compute/leastsquare.sim new file mode 100644 index 0000000000000000000000000000000000000000..1c8af7fe7fdceb6666000e79bb89ee7c11ac3cac --- /dev/null +++ b/tests/script/general/compute/leastsquare.sim @@ -0,0 +1,100 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +$dbPrefix = m_le_db +$tbPrefix = m_le_tb +$mtPrefix = m_le_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db keep 36500 +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 2 + $ms = 1000 + while $x < $rowNum + $ms = $ms + 1000 + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select leastsquares(tbcol, 1, 1) from $tb +print ===> $data00 +if $data00 != @{slop:1.000000, intercept:1.000000}@ then + return -1 +endi + +print =============== step3 +sql select leastsquares(tbcol, 1, 1) from $tb where ts < now + 4m +print ===> $data00 +if $data00 != @{slop:1.000000, intercept:1.000000}@ then + return -1 +endi + +print =============== step4 +sql select leastsquares(tbcol, 1, 1) as b from $tb +print ===> $data00 +if $data00 != @{slop:1.000000, intercept:1.000000}@ then + return -1 +endi + +print =============== step5 +sql select leastsquares(tbcol, 1, 1) as b from $tb interval(1m) +print ===> $data01 +if $data01 != @{slop:1.000000, intercept:1.000000}@ then + return -1 +endi + +sql select leastsquares(tbcol, 1, 1) as b from $tb interval(1d) +print ===> $data01 +if $data01 != @{slop:1.000000, intercept:1.000000}@ then + return -1 +endi + +print =============== step6 +sql select leastsquares(tbcol, 1, 1) as b from $tb where ts < now + 4m interval(1m) +print ===> $data01 +if $data01 != @{slop:1.000000, intercept:1.000000}@ then + return -1 +endi +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compute/max.sim b/tests/script/general/compute/max.sim new file mode 100644 index 0000000000000000000000000000000000000000..f9665a823db130a0eb5b4a7eb169a5900948c8a8 --- /dev/null +++ b/tests/script/general/compute/max.sim @@ -0,0 +1,176 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +$dbPrefix = m_ma_db +$tbPrefix = m_ma_tb +$mtPrefix = m_ma_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select max(tbcol) from $tb +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +print =============== step3 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select max(tbcol) from $tb where ts <= $ms +print ===> $data00 +if $data00 != 4 then + return -1 +endi + +print =============== step4 +sql select max(tbcol) as b from $tb +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +print =============== step5 +sql select max(tbcol) as b from $tb interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select max(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != 19 then + return -1 +endi + +print =============== step6 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select max(tbcol) as b from $tb where ts <= $ms interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select max(tbcol) from $mt +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +print =============== step8 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select max(tbcol) as c from $mt where ts <= $ms +print ===> $data00 +if $data00 != 4 then + return -1 +endi + +sql select max(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select max(tbcol) as c from $mt where tgcol < 5 and ts <= $ms +print ===> $data00 +if $data00 != 4 then + return -1 +endi + +print =============== step9 +sql select max(tbcol) as b from $mt interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select max(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 19 then + return -1 +endi + +print =============== step10 +sql select max(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select max(tbcol) as b from $mt where ts <= $ms interval(1m) group by tgcol +print ===> $data11 +if $data11 != 1 then + return -1 +endi +print ===> $rows +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compute/min.sim b/tests/script/general/compute/min.sim new file mode 100644 index 0000000000000000000000000000000000000000..4a9904e06594f63f4de7e13c193a2e8561ccbf10 --- /dev/null +++ b/tests/script/general/compute/min.sim @@ -0,0 +1,175 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$dbPrefix = m_mi_db +$tbPrefix = m_mi_tb +$mtPrefix = m_mi_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select min(tbcol) from $tb +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step3 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select min(tbcol) from $tb where ts < $ms +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step4 +sql select min(tbcol) as b from $tb +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step5 +sql select min(tbcol) as b from $tb interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select min(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != 0 then + return -1 +endi + +print =============== step6 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select min(tbcol) as b from $tb where ts <= $ms interval(1m) +print select min(tbcol) as b from $tb where ts <= $ms interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select min(tbcol) from $mt +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step8 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select min(tbcol) as c from $mt where ts < $ms +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +sql select min(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select min(tbcol) as c from $mt where tgcol < 5 and ts <= $ms +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step9 +sql select min(tbcol) as b from $mt interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select min(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 0 then + return -1 +endi + +print =============== step10 +sql select min(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select min(tbcol) as b from $mt where ts <= $ms interval(1m) group by tgcol +print ===> $data11 +if $data11 != 1 then + return -1 +endi +print ===> $rows +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compute/null.sim b/tests/script/general/compute/null.sim new file mode 100644 index 0000000000000000000000000000000000000000..cd00b7a69dae3c039794b19573bd25cbb436be1a --- /dev/null +++ b/tests/script/general/compute/null.sim @@ -0,0 +1,229 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + $v1 = $x + $v2 = $x + if $x == 0 then + $v1 = NULL + endi + + sql insert into $tb values ($ms , $v1 , $v2 ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select * from $tb +print $data00 $data01 $data02 +if $data01 != NULL then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $rows != 20 then + return -1 +endi + +print =============== step3 +sql select count(tbcol), count(tbcol2), avg(tbcol), avg(tbcol2), sum(tbcol), sum(tbcol2) from $tb +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +if $data00 != 19 then + return -1 +endi +if $data01 != 20 then + return -1 +endi +if $data02 != 10.000000000 then + return -1 +endi +if $data03 != 9.500000000 then + return -1 +endi +if $data04 != 190 then + return -1 +endi +if $data05 != 190 then + return -1 +endi + +print =============== step4 +sql select * from $tb where tbcol2 = 19 +print ===> $data01 $data02 +if $rows != 1 then + return -1 +endi +if $data01 != 19 then + return -1 +endi +if $data02 != 19 then + return -1 +endi + +sql select * from $tb where tbcol = NULL -x step3 + return -1 +step3: + +print =============== step5 +sql create table $tb using $mt tags( NULL ) +# return -1 +#step51: + +#sql alter table $tb set tgcol=NULL -x step52 +# return -1 +#step52: + +sql select * from $mt where tgcol = NULL -x step5 + return -1 +step5: + +print =============== step6 +sql select count(tbcol), count(tbcol2), avg(tbcol), avg(tbcol2), sum(tbcol), sum(tbcol2) from $mt +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +if $data00 != 190 then + return -1 +endi +if $data01 != 200 then + return -1 +endi +if $data02 != 10.000000000 then + return -1 +endi +if $data03 != 9.500000000 then + return -1 +endi +if $data04 != 1900 then + return -1 +endi +if $data05 != 1900 then + return -1 +endi + +print =============== step7 +sql create table t1 (ts timestamp, i bool) +sql create table t2 (ts timestamp, i smallint) +sql create table t3 (ts timestamp, i tinyint) +sql create table t4 (ts timestamp, i int) +sql create table t5 (ts timestamp, i bigint) +sql create table t6 (ts timestamp, i float) +sql create table t7 (ts timestamp, i double) +sql create table t8 (ts timestamp, i binary(10)) +sql insert into t1 values(now, NULL) +sql insert into t2 values(now, NULL) +sql insert into t3 values(now, NULL) +sql insert into t4 values(now, NULL) +sql insert into t5 values(now, NULL) +sql insert into t6 values(now, NULL) +sql insert into t7 values(now, NULL) +#sql insert into t8 values(now, NULL) + +#sql select * from t1 +#if $rows != 1 then +# return -1 +#endi +#if $data01 != NULL then +# return -1 +#endi + +sql select * from t2 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi + +sql select * from t3 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi + +sql select * from t4 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi + +sql select * from t5 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi + +sql select * from t6 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi + +sql select * from t7 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi + +#sql select * from t8 +#if $rows != 1 then +# return -1 +#endi +#if $data01 != NULL then +# return -1 +#endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compute/percentile.sim b/tests/script/general/compute/percentile.sim new file mode 100644 index 0000000000000000000000000000000000000000..b0f4fff8d7e9d36d62fab8a587e359ad9ab4f5ec --- /dev/null +++ b/tests/script/general/compute/percentile.sim @@ -0,0 +1,136 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +$dbPrefix = m_pe_db +$tbPrefix = m_pe_tb +$mtPrefix = m_pe_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select percentile(tbcol, 10) from $tb +print ===> $data00 +if $data00 != 1.900000000 then + return -1 +endi + +sql select percentile(tbcol, 20) from $tb +print ===> $data00 +if $data00 != 3.800000000 then + return -1 +endi + +sql select percentile(tbcol, 100) from $tb +print ===> $data00 +if $data00 != 19.000000000 then + return -1 +endi + +sql select percentile(tbcol, 110) from $tb -x step2 + return -1 +step2: + +print =============== step3 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select percentile(tbcol, 1) from $tb where ts > $ms +print ===> $data00 +if $data00 != 5.140000000 then + return -1 +endi + +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select percentile(tbcol, 5) from $tb where ts > $ms +print ===> $data00 +if $data00 != 5.700000000 then + return -1 +endi + +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select percentile(tbcol, 0) from $tb where ts > $ms +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +print =============== step4 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select percentile(tbcol, 1) as c from $tb where ts > $ms +print ===> $data00 +if $data00 != 5.140000000 then + return -1 +endi + +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select percentile(tbcol, 5) as c from $tb where ts > $ms +print ===> $data00 +if $data00 != 5.700000000 then + return -1 +endi + +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select percentile(tbcol, 0) as c from $tb where ts > $ms +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compute/stddev.sim b/tests/script/general/compute/stddev.sim new file mode 100644 index 0000000000000000000000000000000000000000..772ec8386a8d61167e4a208eef4c9b8830893f9c --- /dev/null +++ b/tests/script/general/compute/stddev.sim @@ -0,0 +1,106 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +$dbPrefix = m_st_db +$tbPrefix = m_st_tb +$mtPrefix = m_st_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select stddev(tbcol) from $tb +print ===> $data00 +if $data00 != 5.766281297 then + return -1 +endi + +print =============== step3 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select stddev(tbcol) from $tb where ts <= $ms +print ===> $data00 +if $data00 != 1.414213562 then + return -1 +endi + +print =============== step4 +sql select stddev(tbcol) as b from $tb +print ===> $data00 +if $data00 != 5.766281297 then + return -1 +endi + +print =============== step5 +sql select stddev(tbcol) as b from $tb interval(1m) +print ===> $data01 +if $data01 != 0.000000000 then + return -1 +endi + +sql select stddev(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != 5.766281297 then + return -1 +endi + +print =============== step6 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select stddev(tbcol) as b from $tb where ts <= $ms interval(1m) +print ===> $data01 +if $data01 != 0.000000000 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compute/sum.sim b/tests/script/general/compute/sum.sim new file mode 100644 index 0000000000000000000000000000000000000000..8fad9927504221b0313892360ab30b5d1e8b59c9 --- /dev/null +++ b/tests/script/general/compute/sum.sim @@ -0,0 +1,176 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +$dbPrefix = m_su_db +$tbPrefix = m_su_tb +$mtPrefix = m_su_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select sum(tbcol) from $tb +print ===> $data00 +if $data00 != 190 then + return -1 +endi + +print =============== step3 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select sum(tbcol) from $tb where ts <= $ms +print ===> $data00 +if $data00 != 10 then + return -1 +endi + +print =============== step4 +sql select sum(tbcol) as b from $tb +print ===> $data00 +if $data00 != 190 then + return -1 +endi + +print =============== step5 +sql select sum(tbcol) as b from $tb interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select sum(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != 190 then + return -1 +endi + +print =============== step6 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select sum(tbcol) as b from $tb where ts <= $ms interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select sum(tbcol) from $mt +print ===> $data00 +if $data00 != 1900 then + return -1 +endi + +print =============== step8 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select sum(tbcol) as c from $mt where ts <= $ms +print ===> $data00 +if $data00 != 100 then + return -1 +endi + +sql select sum(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 950 then + return -1 +endi + +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select sum(tbcol) as c from $mt where tgcol < 5 and ts <= $ms +print ===> $data00 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select sum(tbcol) as b from $mt interval(1m) +print ===> $data11 +if $data11 < 5 then + return -1 +endi + +sql select sum(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 1900 then + return -1 +endi + +print =============== step10 +sql select sum(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != 190 then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select sum(tbcol) as b from $mt where ts <= $ms interval(1d) group by tgcol +print select sum(tbcol) as b from $mt where ts <= $ms interval(1d) group by tgcol +print ===> $data01 +if $data01 != 10 then + return -1 +endi +if $rows != 10 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compute/testSuite.sim b/tests/script/general/compute/testSuite.sim new file mode 100644 index 0000000000000000000000000000000000000000..91bf4bf0cda54d300f4d284c9e057616d4d54abe --- /dev/null +++ b/tests/script/general/compute/testSuite.sim @@ -0,0 +1,17 @@ +run general/compute/avg.sim +run general/compute/bottom.sim +run general/compute/count.sim +run general/compute/diff.sim +run general/compute/diff2.sim +run general/compute/first.sim +run general/compute/interval.sim +run general/compute/last.sim +run general/compute/leastsquare.sim +run general/compute/max.sim +run general/compute/min.sim +run general/compute/null.sim +run general/compute/percentile.sim +run general/compute/stddev.sim +run general/compute/sum.sim +run general/compute/top.sim +run general/compute/block_dist.sim diff --git a/tests/script/general/compute/top.sim b/tests/script/general/compute/top.sim new file mode 100644 index 0000000000000000000000000000000000000000..1e9d302b7c9b8d4e8c690ff372d3c802fa2a8d7a --- /dev/null +++ b/tests/script/general/compute/top.sim @@ -0,0 +1,107 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +$dbPrefix = m_to_db +$tbPrefix = m_to_tb +$mtPrefix = m_to_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select top(tbcol, 1) from $tb +print ===> $data01 +if $data01 != 19 then + return -1 +endi + +print =============== step3 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select top(tbcol, 1) from $tb where ts <= $ms +print ===> $data01 +if $data01 != 4 then + return -1 +endi + +print =============== step4 +sql select top(tbcol, 1) as b from $tb +print ===> $data01 +if $data01 != 19 then + return -1 +endi + +print =============== step5 +sql select top(tbcol, 2) as b from $tb +print ===> $data01 $data11 +if $data01 != 18 then + return -1 +endi +if $data11 != 19 then + return -1 +endi + +print =============== step6 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc + +sql select top(tbcol, 2) as b from $tb where ts <= $ms +print ===> $data01 $data11 +if $data01 != 3 then + return -1 +endi +if $data11 != 4 then + return -1 +endi + +sql select top(tbcol, 122) as b from $tb -x step6 + return -1 +step6: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/connection/connection.sim b/tests/script/general/connection/connection.sim new file mode 100644 index 0000000000000000000000000000000000000000..1af6e1fda6989c8a9c6eed36e579f8325eee0ac6 --- /dev/null +++ b/tests/script/general/connection/connection.sim @@ -0,0 +1,21 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============= step1 +sql close +print close1 +sql connect + +print ============= step2 +sql close +sql connect + +print ============= step3 +sql close +sql connect + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/connection/mqtt.sim b/tests/script/general/connection/mqtt.sim new file mode 100644 index 0000000000000000000000000000000000000000..c2c50ef17e1264d6f27f64417f1500bc83346012 --- /dev/null +++ b/tests/script/general/connection/mqtt.sim @@ -0,0 +1,19 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 100000 +system sh/cfg.sh -n dnode1 -c http -v 1 +system sh/cfg.sh -n dnode1 -c mqtt -v 1 + +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect +sql create database mqttdb; +sql create table mqttdb.devices(ts timestamp, value double) tags(name binary(32), model binary(32), serial binary(16), param binary(16), unit binary(16)); + +sleep 1000 +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/connection/sim.tar.gz b/tests/script/general/connection/sim.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..10bc1a6bace1c8b6796a98c53e3aa3c15e0bfd7c Binary files /dev/null and b/tests/script/general/connection/sim.tar.gz differ diff --git a/tests/script/general/connection/test_old_data.sim b/tests/script/general/connection/test_old_data.sim new file mode 100644 index 0000000000000000000000000000000000000000..83df850f0bb93fd216520bbea4065400aa334091 --- /dev/null +++ b/tests/script/general/connection/test_old_data.sim @@ -0,0 +1,32 @@ +system sh/stop_dnodes.sh +system sh/mv_old_data.sh + +print ============== deploy + +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start + +print =============== step1 + +sql use test +sql select * from m1 + +print $rows points data are retrieved +if $rows != 7 then + return -1 +endi + +print =============== step 2 + +sql select * from t1 + +print $rows points data are retrieved +if $rows != 7 then + return -1 +endi + + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/db/alter_option.sim b/tests/script/general/db/alter_option.sim new file mode 100644 index 0000000000000000000000000000000000000000..36f4c0e7dcfca27f77b0e701adff47e06f9d1bb0 --- /dev/null +++ b/tests/script/general/db/alter_option.sim @@ -0,0 +1,263 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 0 +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 1000 + +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ============= create database +sql create database db cache 2 blocks 4 days 10 keep 20 minRows 300 maxRows 400 ctime 120 precision 'ms' comp 2 wal 1 replica 1 +sql show databases +if $data00 != db then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 0 then + return -1 +endi +if $data04 != 1 then + return -1 +endi +if $data06 != 10 then + return -1 +endi +if $data07 != 20,20,20 then + return -1 +endi +if $data08 != 2 then + return -1 +endi +if $data09 != 4 then + return -1 +endi + +print ============== step name +sql_error alter database db name d1 +sql_error alter database db name d2 + +print ============== step ntables +sql_error alter database db ntables -1 +sql_error alter database db ntables 0 +sql_error alter database db ntables 1 +sql_error alter database db ntables 10 + +print ============== step vgroups +sql_error alter database db vgroups -1 +sql_error alter database db vgroups 0 +sql_error alter database db vgroups 1 +sql_error alter database db vgroups 10 + +print ============== step replica +sql_error alter database db replica 2 +sql_error alter database db replica 3 +sql_error alter database db replica 0 + +sql alter database db replica 1 +sql show databases +print replica $data4_db +if $data4_db != 1 then + return -1 +endi + +print ============== step quorum +sql show databases +print quorum $data5_db +if $data5_db != 1 then + return -1 +endi + +sql alter database db quorum 1 +sql show databases +print quorum $data5_db +if $data5_db != 1 then + return -1 +endi + +sql_error alter database db quorum 2 + +sql_error alter database db quorum 3 + +sql_error alter database db quorum 0 +sql_error alter database db quorum 4 +sql_error alter database db quorum 5 +sql_error alter database db quorum -1 + +print ============== step days +sql_error alter database db days 0 +sql_error alter database db days 1 +sql_error alter database db days 2 +sql_error alter database db days 10 +sql_error alter database db days 50 +sql_error alter database db days 100 + +print ============== step keep +sql show databases +print keep $data7_db +if $data7_db != 20,20,20 then + return -1 +endi + +sql alter database db keep 20 +sql show databases +print keep $data7_db +if $data7_db != 20,20,20 then + return -1 +endi + +sql alter database db keep 30 +sql show databases +print keep $data7_db +if $data7_db != 30,30,30 then + return -1 +endi + +sql alter database db keep 40 +sql show databases +print keep $data7_db +if $data7_db != 40,40,40 then + return -1 +endi + +sql alter database db keep 40,50 +sql alter database db keep 30,31 +sql alter database db keep 20 +sql_error alter database db keep 10.0 +sql_error alter database db keep 9 +sql_error alter database db keep 1 +sql_error alter database db keep 0 +sql_error alter database db keep -1 +sql_error alter database db keep 365001 + +print ============== step cache +sql_error alter database db cache 60 +sql_error alter database db cache 50 +sql_error alter database db cache 20 +sql_error alter database db cache 3 +sql_error alter database db cache 129 +sql_error alter database db cache 300 +sql_error alter database db cache 0 +sql_error alter database db cache -1 + +print ============== step blocks +sql show databases +print blocks $data9_db +if $data9_db != 4 then + return -1 +endi + +sql alter database db blocks 10 +sql show databases +print blocks $data9_db +if $data9_db != 10 then + return -1 +endi + +sql alter database db blocks 20 +sql show databases +print blocks $data9_db +if $data9_db != 20 then + return -1 +endi + +sql alter database db blocks 30 +sql show databases +print blocks $data9_db +if $data9_db != 30 then + return -1 +endi + +sql alter database db blocks 40 +sql alter database db blocks 30 +sql alter database db blocks 20 +sql alter database db blocks 10 +sql_error alter database db blocks 2 +sql_error alter database db blocks 1 +sql_error alter database db blocks 0 +sql_error alter database db blocks -1 +sql_error alter database db blocks 10001 + +print ============== step minrows +sql_error alter database db minrows 1 +sql_error alter database db minrows 100 +sql_error alter database db minrows 1000 + +print ============== step maxrows +sql_error alter database db maxrows 1 +sql_error alter database db maxrows 100 +sql_error alter database db maxrows 1000 + +print ============== step wallevel +sql show databases +print wallevel $data12_db +if $data12_db != 1 then + return -1 +endi + +sql_error alter database db wal 1 + + +sql_error alter database db wal 1 +sql_error alter database db wal 2 +sql_error alter database db wal 1 +sql_error alter database db wal 2 +sql_error alter database db wal 0 +sql_error alter database db wal 3 +sql_error alter database db wal 4 +sql_error alter database db wal -1 +sql_error alter database db wal 1000 + +print ============== step fsync +sql_error alter database db fsync 0 +sql_error alter database db fsync 1 +sql_error alter database db fsync 3600 +sql_error alter database db fsync 18000 +sql_error alter database db fsync 180000 +sql_error alter database db fsync 180001 +sql_error alter database db fsync -1 + +print ============== step comp +sql show databases +print comp $data14_db +if $data14_db != 2 then + return -1 +endi + +sql alter database db comp 1 +sql show databases +print comp $data14_db +if $data14_db != 1 then + return -1 +endi + +sql alter database db comp 2 +sql show databases +print comp $data14_db +if $data14_db != 2 then + return -1 +endi + +sql alter database db comp 0 +sql show databases +print comp $data14_db +if $data14_db != 0 then + return -1 +endi + +sql_error alter database db comp 3 +sql_error alter database db comp 4 +sql_error alter database db comp 5 +sql_error alter database db comp -1 + + +print ============== step precision +sql_error alter database db prec 'us' + +print ============== step status +sql_error alter database db status 'delete' + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/db/alter_tables_d2.sim b/tests/script/general/db/alter_tables_d2.sim new file mode 100644 index 0000000000000000000000000000000000000000..f74f98d571e49090e2c25d2371a0e0c268c9a3ee --- /dev/null +++ b/tests/script/general/db/alter_tables_d2.sim @@ -0,0 +1,570 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 4 +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 5 + +system sh/deploy.sh -n dnode2 -i 2 +system sh/cfg.sh -n dnode2 -c wallevel -v 2 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 4 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 5 + +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +sql connect +sql create dnode $hostname2 + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +if $data4_1 != ready then + goto step1 +endi +if $data4_2 != ready then + goto step1 +endi + +print ============================ step1 + +sql create database db +sql create table db.st (ts timestamp, i int) tags(t int) +sql create table db.t000 using db.st tags(0) +sql create table db.t001 using db.st tags(1) +sql create table db.t002 using db.st tags(2) +sql create table db.t003 using db.st tags(3) +sql create table db.t004 using db.st tags(4) +sql create table db.t005 using db.st tags(5) +sql create table db.t006 using db.st tags(6) +sql create table db.t007 using db.st tags(7) +sql create table db.t008 using db.st tags(8) +sql create table db.t009 using db.st tags(9) +sql create table db.t010 using db.st tags(0) +sql create table db.t011 using db.st tags(1) +sql create table db.t012 using db.st tags(2) +sql create table db.t013 using db.st tags(3) +sql create table db.t014 using db.st tags(4) +sql create table db.t015 using db.st tags(5) +sql create table db.t016 using db.st tags(6) +sql create table db.t017 using db.st tags(7) +sql create table db.t018 using db.st tags(8) +sql create table db.t019 using db.st tags(9) + +sql show db.tables +if $rows != 20 then + return -1 +endi + +sql insert into db.t000 values(now, 1) +sql insert into db.t001 values(now, 1) +sql insert into db.t002 values(now, 1) +sql insert into db.t003 values(now, 1) +sql insert into db.t004 values(now, 1) +sql insert into db.t005 values(now, 1) +sql insert into db.t006 values(now, 1) +sql insert into db.t007 values(now, 1) +sql insert into db.t008 values(now, 1) +sql insert into db.t009 values(now, 1) +sql insert into db.t010 values(now, 1) +sql insert into db.t011 values(now, 1) +sql insert into db.t012 values(now, 1) +sql insert into db.t013 values(now, 1) +sql insert into db.t014 values(now, 1) +sql insert into db.t015 values(now, 1) +sql insert into db.t016 values(now, 1) +sql insert into db.t017 values(now, 1) +sql insert into db.t018 values(now, 1) +sql insert into db.t019 values(now, 1) + +print ============================ step2 +sql_error create table db.t100 using db.st tags(10) +sql show db.tables +if $rows != 20 then + return -1 +endi + +print ============================ step3 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 10 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 10 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +$x = 0 +step2: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show mnodes -x step1 +print mnode1 $data2_1 +print mnode1 $data2_2 +print mnode1 $data2_3 +if $data2_1 != master then + goto step2 +endi + +sql create table db.t100 using db.st tags(0) +sql create table db.t101 using db.st tags(1) +sql create table db.t102 using db.st tags(2) +sql create table db.t103 using db.st tags(3) +sql create table db.t104 using db.st tags(4) +sql create table db.t105 using db.st tags(5) +sql create table db.t106 using db.st tags(6) +sql create table db.t107 using db.st tags(7) +sql create table db.t108 using db.st tags(8) +sql create table db.t109 using db.st tags(9) +sql create table db.t110 using db.st tags(0) +sql create table db.t111 using db.st tags(1) +sql create table db.t112 using db.st tags(2) +sql create table db.t113 using db.st tags(3) +sql create table db.t114 using db.st tags(4) +sql create table db.t115 using db.st tags(5) +sql create table db.t116 using db.st tags(6) +sql create table db.t117 using db.st tags(7) +sql create table db.t118 using db.st tags(8) +sql create table db.t119 using db.st tags(9) +sql show db.tables +if $rows != 40 then + return -1 +endi + +sql insert into db.t100 values(now, 1) +sql insert into db.t101 values(now, 1) +sql insert into db.t102 values(now, 1) +sql insert into db.t103 values(now, 1) +sql insert into db.t104 values(now, 1) +sql insert into db.t105 values(now, 1) +sql insert into db.t106 values(now, 1) +sql insert into db.t107 values(now, 1) +sql insert into db.t108 values(now, 1) +sql insert into db.t109 values(now, 1) +sql insert into db.t110 values(now, 1) +sql insert into db.t111 values(now, 1) +sql insert into db.t112 values(now, 1) +sql insert into db.t113 values(now, 1) +sql insert into db.t114 values(now, 1) +sql insert into db.t115 values(now, 1) +sql insert into db.t116 values(now, 1) +sql insert into db.t117 values(now, 1) +sql insert into db.t118 values(now, 1) +sql insert into db.t119 values(now, 1) + +print ============================ step4 +sql_error create table db.t200 using db.st tags(10) +sql show db.tables +if $rows != 40 then + return -1 +endi + +print ============================ step5 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 15 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 15 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start + +$x = 0 +step3: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show mnodes -x step3 +print mnode1 $data2_1 +print mnode1 $data2_2 +print mnode1 $data2_3 +if $data2_1 != master then + goto step3 +endi + +sql create table db.t200 using db.st tags(0) +sql create table db.t201 using db.st tags(1) +sql create table db.t202 using db.st tags(2) +sql create table db.t203 using db.st tags(3) +sql create table db.t204 using db.st tags(4) +sql create table db.t205 using db.st tags(5) +sql create table db.t206 using db.st tags(6) +sql create table db.t207 using db.st tags(7) +sql create table db.t208 using db.st tags(8) +sql create table db.t209 using db.st tags(9) +sql create table db.t210 using db.st tags(0) +sql create table db.t211 using db.st tags(1) +sql create table db.t212 using db.st tags(2) +sql create table db.t213 using db.st tags(3) +sql create table db.t214 using db.st tags(4) +sql create table db.t215 using db.st tags(5) +sql create table db.t216 using db.st tags(6) +sql create table db.t217 using db.st tags(7) +sql create table db.t218 using db.st tags(8) +sql create table db.t219 using db.st tags(9) +sql show db.tables +if $rows != 60 then + return -1 +endi + +sql insert into db.t200 values(now, 1) +sql insert into db.t201 values(now, 1) +sql insert into db.t202 values(now, 1) +sql insert into db.t203 values(now, 1) +sql insert into db.t204 values(now, 1) +sql insert into db.t205 values(now, 1) +sql insert into db.t206 values(now, 1) +sql insert into db.t207 values(now, 1) +sql insert into db.t208 values(now, 1) +sql insert into db.t209 values(now, 1) +sql insert into db.t210 values(now, 1) +sql insert into db.t211 values(now, 1) +sql insert into db.t212 values(now, 1) +sql insert into db.t213 values(now, 1) +sql insert into db.t214 values(now, 1) +sql insert into db.t215 values(now, 1) +sql insert into db.t216 values(now, 1) +sql insert into db.t217 values(now, 1) +sql insert into db.t218 values(now, 1) +sql insert into db.t219 values(now, 1) + +print ============================ step6 + +sql reset query cache +sleep 100 + +sql select * from db.t000 +if $rows != 1 then + return -1 +endi + +sql select * from db.t100 +if $rows != 1 then + return -1 +endi + +sql select * from db.t200 +if $rows != 1 then + return -1 +endi + +sql select * from db.st +if $rows != 60 then + return -1 +endi + +print ============================ step7 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +sleep 3000 + +sql reset query cache +sleep 1000 + +sql show db.tables +if $rows != 60 then + return -1 +endi + +sql select * from db.t000 +if $rows != 1 then + return -1 +endi + +sql select * from db.t100 +if $rows != 1 then + return -1 +endi + +sql select * from db.t200 +if $rows != 1 then + return -1 +endi + +sql select * from db.st +if $rows != 60 then + return -1 +endi + +print ============================ step8 +sql_error create table db.t300 using db.st tags(10) +sql show db.tables +if $rows != 60 then + return -1 +endi + +print ============================ step9 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 20 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 20 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +$x = 0 +step9: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show mnodes -x step9 +print mnode1 $data2_1 +print mnode1 $data2_2 +print mnode1 $data2_3 +if $data2_1 != master then + goto step9 +endi + +sql create table db.t300 using db.st tags(0) +sql create table db.t301 using db.st tags(1) +sql create table db.t302 using db.st tags(2) +sql create table db.t303 using db.st tags(3) +sql create table db.t304 using db.st tags(4) +sql create table db.t305 using db.st tags(5) +sql create table db.t306 using db.st tags(6) +sql create table db.t307 using db.st tags(7) +sql create table db.t308 using db.st tags(8) +sql create table db.t309 using db.st tags(9) +sql create table db.t310 using db.st tags(0) +sql create table db.t311 using db.st tags(1) +sql create table db.t312 using db.st tags(2) +sql create table db.t313 using db.st tags(3) +sql create table db.t314 using db.st tags(4) +sql create table db.t315 using db.st tags(5) +sql create table db.t316 using db.st tags(6) +sql create table db.t317 using db.st tags(7) +sql create table db.t318 using db.st tags(8) +sql create table db.t319 using db.st tags(9) + +sql insert into db.t300 values(now, 1) +sql insert into db.t301 values(now, 1) +sql insert into db.t302 values(now, 1) +sql insert into db.t303 values(now, 1) +sql insert into db.t304 values(now, 1) +sql insert into db.t305 values(now, 1) +sql insert into db.t306 values(now, 1) +sql insert into db.t307 values(now, 1) +sql insert into db.t308 values(now, 1) +sql insert into db.t309 values(now, 1) +sql insert into db.t310 values(now, 1) +sql insert into db.t311 values(now, 1) +sql insert into db.t312 values(now, 1) +sql insert into db.t313 values(now, 1) +sql insert into db.t314 values(now, 1) +sql insert into db.t315 values(now, 1) +sql insert into db.t316 values(now, 1) +sql insert into db.t317 values(now, 1) +sql insert into db.t318 values(now, 1) +sql insert into db.t319 values(now, 1) + +sql show db.tables +if $rows != 80 then + return -1 +endi + +sql reset query cache +sleep 100 + +sql select * from db.t000 +if $rows != 1 then + return -1 +endi + +sql select * from db.t100 +if $rows != 1 then + return -1 +endi + +sql select * from db.t200 +if $rows != 1 then + return -1 +endi + +sql select * from db.t300 +if $rows != 1 then + return -1 +endi + +sql select * from db.st +if $rows != 80 then + return -1 +endi + +print ============================ step10 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +$x = 0 +step10: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show mnodes -x step10 +print mnode1 $data2_1 +print mnode1 $data2_2 +print mnode1 $data2_3 +if $data2_1 != master then + goto step10 +endi + +sql reset query cache +sleep 100 + +sql show db.tables +if $rows != 80 then + return -1 +endi + +sql select * from db.t000 +if $rows != 1 then + return -1 +endi + +sql select * from db.t100 +if $rows != 1 then + return -1 +endi + +sql select * from db.t200 +if $rows != 1 then + return -1 +endi + +sql select * from db.t300 +if $rows != 1 then + return -1 +endi + +sql select * from db.st +if $rows != 80 then + return -1 +endi + +print ============================ step11 +sql_error create table db.t400 using db.st tags(10) +sql show db.tables +if $rows != 80 then + return -1 +endi + +print ============================ step9 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 25 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 25 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +$x = 0 +step1xx: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show mnodes -x step1xx +print mnode1 $data2_1 +print mnode1 $data2_2 +print mnode1 $data2_3 +if $data2_1 != master then + goto step1xx +endi + +sql create table db.t400 using db.st tags(0) +sql create table db.t401 using db.st tags(1) +sql create table db.t402 using db.st tags(2) +sql create table db.t403 using db.st tags(3) +sql create table db.t404 using db.st tags(4) +sql create table db.t405 using db.st tags(5) +sql create table db.t406 using db.st tags(6) +sql create table db.t407 using db.st tags(7) +sql create table db.t408 using db.st tags(8) +sql create table db.t409 using db.st tags(9) +sql create table db.t410 using db.st tags(0) +sql create table db.t411 using db.st tags(1) +sql create table db.t412 using db.st tags(2) +sql create table db.t413 using db.st tags(3) +sql create table db.t414 using db.st tags(4) +sql create table db.t415 using db.st tags(5) +sql create table db.t416 using db.st tags(6) +sql create table db.t417 using db.st tags(7) +sql create table db.t418 using db.st tags(8) +sql create table db.t419 using db.st tags(9) + +sql insert into db.t400 values(now, 1) +sql insert into db.t401 values(now, 1) +sql insert into db.t402 values(now, 1) +sql insert into db.t403 values(now, 1) +sql insert into db.t404 values(now, 1) +sql insert into db.t405 values(now, 1) +sql insert into db.t406 values(now, 1) +sql insert into db.t407 values(now, 1) +sql insert into db.t408 values(now, 1) +sql insert into db.t409 values(now, 1) +sql insert into db.t410 values(now, 1) +sql insert into db.t411 values(now, 1) +sql insert into db.t412 values(now, 1) +sql insert into db.t413 values(now, 1) +sql insert into db.t414 values(now, 1) +sql insert into db.t415 values(now, 1) +sql insert into db.t416 values(now, 1) +sql insert into db.t417 values(now, 1) +sql insert into db.t418 values(now, 1) +sql insert into db.t419 values(now, 1) + +sql show db.tables +if $rows != 100 then + return -1 +endi + +sql reset query cache +sleep 100 + +sql select * from db.t000 +if $rows != 1 then + return -1 +endi + +sql select * from db.t100 +if $rows != 1 then + return -1 +endi + +sql select * from db.t200 +if $rows != 1 then + return -1 +endi + +sql select * from db.t300 +if $rows != 1 then + return -1 +endi + +sql select * from db.t400 +if $rows != 1 then + return -1 +endi + +sql select * from db.st +if $rows != 100 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/db/alter_tables_v1.sim b/tests/script/general/db/alter_tables_v1.sim new file mode 100644 index 0000000000000000000000000000000000000000..20c4c7336312b7eb701fe04c6b4158f466e43146 --- /dev/null +++ b/tests/script/general/db/alter_tables_v1.sim @@ -0,0 +1,436 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 0 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 10 + +system sh/exec.sh -n dnode1 -s start +sql connect + +print ============================ step1 + +sql create database db +sql create table db.st (ts timestamp, i int) tags(t int) +sql create table db.t0 using db.st tags(0) +sql create table db.t1 using db.st tags(1) +sql create table db.t2 using db.st tags(2) +sql create table db.t3 using db.st tags(3) +sql create table db.t4 using db.st tags(4) +sql create table db.t5 using db.st tags(5) +sql create table db.t6 using db.st tags(6) +sql create table db.t7 using db.st tags(7) +sql create table db.t8 using db.st tags(8) +sql create table db.t9 using db.st tags(9) + +sql show db.tables +if $rows != 10 then + return -1 +endi + +sql insert into db.t0 values(now, 1) +sql insert into db.t1 values(now, 1) +sql insert into db.t2 values(now, 1) +sql insert into db.t3 values(now, 1) +sql insert into db.t4 values(now, 1) +sql insert into db.t5 values(now, 1) +sql insert into db.t6 values(now, 1) +sql insert into db.t7 values(now, 1) +sql insert into db.t8 values(now, 1) +sql insert into db.t9 values(now, 1) + +print ============================ step2 +sql_error create table db.t10 using db.st tags(10) +sql show db.tables +if $rows != 10 then + return -1 +endi + +print ============================ step3 + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 20 +system sh/exec.sh -n dnode1 -s start +$x = 0 +step2: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show mnodes -x step2 +print mnode1 $data2_1 +print mnode1 $data2_2 +print mnode1 $data2_3 +if $data2_1 != master then + goto step2 +endi + +sql create table db.t10 using db.st tags(0) +sql create table db.t11 using db.st tags(1) +sql create table db.t12 using db.st tags(2) +sql create table db.t13 using db.st tags(3) +sql create table db.t14 using db.st tags(4) +sql create table db.t15 using db.st tags(5) +sql create table db.t16 using db.st tags(6) +sql create table db.t17 using db.st tags(7) +sql create table db.t18 using db.st tags(8) +sql create table db.t19 using db.st tags(9) +sql show db.tables +if $rows != 20 then + return -1 +endi + +sql insert into db.t10 values(now, 1) +sql insert into db.t11 values(now, 1) +sql insert into db.t12 values(now, 1) +sql insert into db.t13 values(now, 1) +sql insert into db.t14 values(now, 1) +sql insert into db.t15 values(now, 1) +sql insert into db.t16 values(now, 1) +sql insert into db.t17 values(now, 1) +sql insert into db.t18 values(now, 1) +sql insert into db.t19 values(now, 1) + +print ============================ step4 +sql_error create table db.t20 using db.st tags(10) +sql show db.tables +if $rows != 20 then + return -1 +endi + +print ============================ step5 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 30 +system sh/exec.sh -n dnode1 -s start +$x = 0 +step5: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show mnodes -x step5 +print mnode1 $data2_1 +print mnode1 $data2_2 +print mnode1 $data2_3 +if $data2_1 != master then + goto step5 +endi + +sql create table db.t20 using db.st tags(0) +sql create table db.t21 using db.st tags(1) +sql create table db.t22 using db.st tags(2) +sql create table db.t23 using db.st tags(3) +sql create table db.t24 using db.st tags(4) +sql create table db.t25 using db.st tags(5) +sql create table db.t26 using db.st tags(6) +sql create table db.t27 using db.st tags(7) +sql create table db.t28 using db.st tags(8) +sql create table db.t29 using db.st tags(9) +sql show db.tables +if $rows != 30 then + return -1 +endi + +sql insert into db.t20 values(now, 1) +sql insert into db.t21 values(now, 1) +sql insert into db.t22 values(now, 1) +sql insert into db.t23 values(now, 1) +sql insert into db.t24 values(now, 1) +sql insert into db.t25 values(now, 1) +sql insert into db.t26 values(now, 1) +sql insert into db.t27 values(now, 1) +sql insert into db.t28 values(now, 1) +sql insert into db.t29 values(now, 1) + +print ============================ step6 + +sql reset query cache +sleep 100 + +sql select * from db.t0 +if $rows != 1 then + return -1 +endi + +sql select * from db.t10 +if $rows != 1 then + return -1 +endi + +sql select * from db.t20 +if $rows != 1 then + return -1 +endi + +sql select * from db.st +if $rows != 30 then + return -1 +endi + +print ============================ step7 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s start +$x = 0 +step7: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show mnodes -x step7 +print mnode1 $data2_1 +print mnode1 $data2_2 +print mnode1 $data2_3 +if $data2_1 != master then + goto step7 +endi + +sql reset query cache +sleep 1000 + +sql show db.tables +if $rows != 30 then + return -1 +endi + +sql select * from db.t0 +if $rows != 1 then + return -1 +endi + +sql select * from db.t10 +if $rows != 1 then + return -1 +endi + +sql select * from db.t20 +if $rows != 1 then + return -1 +endi + +sql select * from db.st +if $rows != 30 then + return -1 +endi + +print ============================ step8 +sql_error create table db.t30 using db.st tags(10) +sql show db.tables +if $rows != 30 then + return -1 +endi + +print ============================ step9 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 40 +system sh/exec.sh -n dnode1 -s start +$x = 0 +step9: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show mnodes -x step9 +print mnode1 $data2_1 +print mnode1 $data2_2 +print mnode1 $data2_3 +if $data2_1 != master then + goto step9 +endi + +sql create table db.t30 using db.st tags(0) +sql create table db.t31 using db.st tags(1) +sql create table db.t32 using db.st tags(2) +sql create table db.t33 using db.st tags(3) +sql create table db.t34 using db.st tags(4) +sql create table db.t35 using db.st tags(5) +sql create table db.t36 using db.st tags(6) +sql create table db.t37 using db.st tags(7) +sql create table db.t38 using db.st tags(8) +sql create table db.t39 using db.st tags(9) + +sql insert into db.t30 values(now, 1) +sql insert into db.t31 values(now, 1) +sql insert into db.t32 values(now, 1) +sql insert into db.t33 values(now, 1) +sql insert into db.t34 values(now, 1) +sql insert into db.t35 values(now, 1) +sql insert into db.t36 values(now, 1) +sql insert into db.t37 values(now, 1) +sql insert into db.t38 values(now, 1) +sql insert into db.t39 values(now, 1) + +sql show db.tables +if $rows != 40 then + return -1 +endi + +sql reset query cache +sleep 1000 + +sql select * from db.t0 +if $rows != 1 then + return -1 +endi + +sql select * from db.t10 +if $rows != 1 then + return -1 +endi + +sql select * from db.t20 +if $rows != 1 then + return -1 +endi + +sql select * from db.t30 +if $rows != 1 then + return -1 +endi + +sql select * from db.st +if $rows != 40 then + return -1 +endi + +print ============================ step10 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s start +$x = 0 +step10: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show mnodes -x step10 +print mnode1 $data2_1 +print mnode1 $data2_2 +print mnode1 $data2_3 +if $data2_1 != master then + goto step10 +endi + +sql reset query cache +sleep 1000 + +sql show db.tables +if $rows != 40 then + return -1 +endi + +sql select * from db.t0 +if $rows != 1 then + return -1 +endi + +sql select * from db.t10 +if $rows != 1 then + return -1 +endi + +sql select * from db.t20 +if $rows != 1 then + return -1 +endi + +sql select * from db.st +if $rows != 40 then + return -1 +endi + +print ============================ step11 +sql_error create table db.t40 using db.st tags(10) +sql show db.tables +if $rows != 40 then + return -1 +endi + +print ============================ step12 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 50 +system sh/exec.sh -n dnode1 -s start +$x = 0 +step12: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show mnodes -x step12 +print mnode1 $data2_1 +print mnode1 $data2_2 +print mnode1 $data2_3 +if $data2_1 != master then + goto step12 +endi + +sql create table db.t40 using db.st tags(0) +sql create table db.t41 using db.st tags(1) +sql create table db.t42 using db.st tags(2) +sql create table db.t43 using db.st tags(3) +sql create table db.t44 using db.st tags(4) +sql create table db.t45 using db.st tags(5) +sql create table db.t46 using db.st tags(6) +sql create table db.t47 using db.st tags(7) +sql create table db.t48 using db.st tags(8) +sql create table db.t49 using db.st tags(9) + +sql insert into db.t40 values(now, 1) +sql insert into db.t41 values(now, 1) +sql insert into db.t42 values(now, 1) +sql insert into db.t43 values(now, 1) +sql insert into db.t44 values(now, 1) +sql insert into db.t45 values(now, 1) +sql insert into db.t46 values(now, 1) +sql insert into db.t47 values(now, 1) +sql insert into db.t48 values(now, 1) +sql insert into db.t49 values(now, 1) + +sql show db.tables +if $rows != 50 then + return -1 +endi + +sql reset query cache +sleep 1000 + +sql select * from db.t0 +if $rows != 1 then + return -1 +endi + +sql select * from db.t10 +if $rows != 1 then + return -1 +endi + +sql select * from db.t20 +if $rows != 1 then + return -1 +endi + +sql select * from db.t30 +if $rows != 1 then + return -1 +endi + +sql select * from db.t40 +if $rows != 1 then + return -1 +endi + +sql select * from db.st +if $rows != 50 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/db/alter_tables_v4.sim b/tests/script/general/db/alter_tables_v4.sim new file mode 100644 index 0000000000000000000000000000000000000000..10bb4e108bf7fc6c879e230565dad29599f15549 --- /dev/null +++ b/tests/script/general/db/alter_tables_v4.sim @@ -0,0 +1,529 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 0 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 4 +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 5 + +system sh/exec.sh -n dnode1 -s start +sql connect + +print ============================ step1 + +sql create database db +sql create table db.st (ts timestamp, i int) tags(t int) +sql create table db.t000 using db.st tags(0) +sql create table db.t001 using db.st tags(1) +sql create table db.t002 using db.st tags(2) +sql create table db.t003 using db.st tags(3) +sql create table db.t004 using db.st tags(4) +sql create table db.t005 using db.st tags(5) +sql create table db.t006 using db.st tags(6) +sql create table db.t007 using db.st tags(7) +sql create table db.t008 using db.st tags(8) +sql create table db.t009 using db.st tags(9) +sql create table db.t010 using db.st tags(0) +sql create table db.t011 using db.st tags(1) +sql create table db.t012 using db.st tags(2) +sql create table db.t013 using db.st tags(3) +sql create table db.t014 using db.st tags(4) +sql create table db.t015 using db.st tags(5) +sql create table db.t016 using db.st tags(6) +sql create table db.t017 using db.st tags(7) +sql create table db.t018 using db.st tags(8) +sql create table db.t019 using db.st tags(9) + +sql show db.tables +if $rows != 20 then + return -1 +endi + +sql insert into db.t000 values(now, 1) +sql insert into db.t001 values(now, 1) +sql insert into db.t002 values(now, 1) +sql insert into db.t003 values(now, 1) +sql insert into db.t004 values(now, 1) +sql insert into db.t005 values(now, 1) +sql insert into db.t006 values(now, 1) +sql insert into db.t007 values(now, 1) +sql insert into db.t008 values(now, 1) +sql insert into db.t009 values(now, 1) +sql insert into db.t010 values(now, 1) +sql insert into db.t011 values(now, 1) +sql insert into db.t012 values(now, 1) +sql insert into db.t013 values(now, 1) +sql insert into db.t014 values(now, 1) +sql insert into db.t015 values(now, 1) +sql insert into db.t016 values(now, 1) +sql insert into db.t017 values(now, 1) +sql insert into db.t018 values(now, 1) +sql insert into db.t019 values(now, 1) + +print ============================ step2 +sql_error create table db.t100 using db.st tags(10) +sql show db.tables +if $rows != 20 then + return -1 +endi + +print ============================ step3 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 10 +system sh/exec.sh -n dnode1 -s start +$x = 0 +step3: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show mnodes -x step3 +print mnode1 $data2_1 +print mnode1 $data2_2 +print mnode1 $data2_3 +if $data2_1 != master then + goto step3 +endi + +sql create table db.t100 using db.st tags(0) +sql create table db.t101 using db.st tags(1) +sql create table db.t102 using db.st tags(2) +sql create table db.t103 using db.st tags(3) +sql create table db.t104 using db.st tags(4) +sql create table db.t105 using db.st tags(5) +sql create table db.t106 using db.st tags(6) +sql create table db.t107 using db.st tags(7) +sql create table db.t108 using db.st tags(8) +sql create table db.t109 using db.st tags(9) +sql create table db.t110 using db.st tags(0) +sql create table db.t111 using db.st tags(1) +sql create table db.t112 using db.st tags(2) +sql create table db.t113 using db.st tags(3) +sql create table db.t114 using db.st tags(4) +sql create table db.t115 using db.st tags(5) +sql create table db.t116 using db.st tags(6) +sql create table db.t117 using db.st tags(7) +sql create table db.t118 using db.st tags(8) +sql create table db.t119 using db.st tags(9) +sql show db.tables +if $rows != 40 then + return -1 +endi + + +sql insert into db.t100 values(now, 1) +sql insert into db.t101 values(now, 1) +sql insert into db.t102 values(now, 1) +sql insert into db.t103 values(now, 1) +sql insert into db.t104 values(now, 1) +sql insert into db.t105 values(now, 1) +sql insert into db.t106 values(now, 1) +sql insert into db.t107 values(now, 1) +sql insert into db.t108 values(now, 1) +sql insert into db.t109 values(now, 1) +sql insert into db.t110 values(now, 1) +sql insert into db.t111 values(now, 1) +sql insert into db.t112 values(now, 1) +sql insert into db.t113 values(now, 1) +sql insert into db.t114 values(now, 1) +sql insert into db.t115 values(now, 1) +sql insert into db.t116 values(now, 1) +sql insert into db.t117 values(now, 1) +sql insert into db.t118 values(now, 1) +sql insert into db.t119 values(now, 1) + +print ============================ step4 +sql_error create table db.t200 using db.st tags(10) +sql show db.tables +if $rows != 40 then + return -1 +endi + +print ============================ step5 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 15 +system sh/exec.sh -n dnode1 -s start +$x = 0 +step5: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show mnodes -x step5 +print mnode1 $data2_1 +print mnode1 $data2_2 +print mnode1 $data2_3 +if $data2_1 != master then + goto step5 +endi + +sql create table db.t200 using db.st tags(0) +sql create table db.t201 using db.st tags(1) +sql create table db.t202 using db.st tags(2) +sql create table db.t203 using db.st tags(3) +sql create table db.t204 using db.st tags(4) +sql create table db.t205 using db.st tags(5) +sql create table db.t206 using db.st tags(6) +sql create table db.t207 using db.st tags(7) +sql create table db.t208 using db.st tags(8) +sql create table db.t209 using db.st tags(9) +sql create table db.t210 using db.st tags(0) +sql create table db.t211 using db.st tags(1) +sql create table db.t212 using db.st tags(2) +sql create table db.t213 using db.st tags(3) +sql create table db.t214 using db.st tags(4) +sql create table db.t215 using db.st tags(5) +sql create table db.t216 using db.st tags(6) +sql create table db.t217 using db.st tags(7) +sql create table db.t218 using db.st tags(8) +sql create table db.t219 using db.st tags(9) +sql show db.tables +if $rows != 60 then + return -1 +endi + +sql insert into db.t200 values(now, 1) +sql insert into db.t201 values(now, 1) +sql insert into db.t202 values(now, 1) +sql insert into db.t203 values(now, 1) +sql insert into db.t204 values(now, 1) +sql insert into db.t205 values(now, 1) +sql insert into db.t206 values(now, 1) +sql insert into db.t207 values(now, 1) +sql insert into db.t208 values(now, 1) +sql insert into db.t209 values(now, 1) +sql insert into db.t210 values(now, 1) +sql insert into db.t211 values(now, 1) +sql insert into db.t212 values(now, 1) +sql insert into db.t213 values(now, 1) +sql insert into db.t214 values(now, 1) +sql insert into db.t215 values(now, 1) +sql insert into db.t216 values(now, 1) +sql insert into db.t217 values(now, 1) +sql insert into db.t218 values(now, 1) +sql insert into db.t219 values(now, 1) + +print ============================ step6 + +sql reset query cache +sleep 100 + +sql select * from db.t000 +if $rows != 1 then + return -1 +endi + +sql select * from db.t100 +if $rows != 1 then + return -1 +endi + +sql select * from db.t200 +if $rows != 1 then + return -1 +endi + +sql select * from db.st +if $rows != 60 then + return -1 +endi + +print ============================ step7 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +sql reset query cache +sleep 1000 + +sql show db.tables +if $rows != 60 then + return -1 +endi + +sql select * from db.t000 +if $rows != 1 then + return -1 +endi + +sql select * from db.t100 +if $rows != 1 then + return -1 +endi + +sql select * from db.t200 +if $rows != 1 then + return -1 +endi + +sql select * from db.st +if $rows != 60 then + return -1 +endi + +print ============================ step8 +sql_error create table db.t300 using db.st tags(10) +sql show db.tables +if $rows != 60 then + return -1 +endi + +print ============================ step9 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 20 +system sh/exec.sh -n dnode1 -s start +$x = 0 +step9: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show mnodes -x step9 +print mnode1 $data2_1 +print mnode1 $data2_2 +print mnode1 $data2_3 +if $data2_1 != master then + goto step9 +endi + +sql create table db.t300 using db.st tags(0) +sql create table db.t301 using db.st tags(1) +sql create table db.t302 using db.st tags(2) +sql create table db.t303 using db.st tags(3) +sql create table db.t304 using db.st tags(4) +sql create table db.t305 using db.st tags(5) +sql create table db.t306 using db.st tags(6) +sql create table db.t307 using db.st tags(7) +sql create table db.t308 using db.st tags(8) +sql create table db.t309 using db.st tags(9) +sql create table db.t310 using db.st tags(0) +sql create table db.t311 using db.st tags(1) +sql create table db.t312 using db.st tags(2) +sql create table db.t313 using db.st tags(3) +sql create table db.t314 using db.st tags(4) +sql create table db.t315 using db.st tags(5) +sql create table db.t316 using db.st tags(6) +sql create table db.t317 using db.st tags(7) +sql create table db.t318 using db.st tags(8) +sql create table db.t319 using db.st tags(9) + +sql insert into db.t300 values(now, 1) +sql insert into db.t301 values(now, 1) +sql insert into db.t302 values(now, 1) +sql insert into db.t303 values(now, 1) +sql insert into db.t304 values(now, 1) +sql insert into db.t305 values(now, 1) +sql insert into db.t306 values(now, 1) +sql insert into db.t307 values(now, 1) +sql insert into db.t308 values(now, 1) +sql insert into db.t309 values(now, 1) +sql insert into db.t310 values(now, 1) +sql insert into db.t311 values(now, 1) +sql insert into db.t312 values(now, 1) +sql insert into db.t313 values(now, 1) +sql insert into db.t314 values(now, 1) +sql insert into db.t315 values(now, 1) +sql insert into db.t316 values(now, 1) +sql insert into db.t317 values(now, 1) +sql insert into db.t318 values(now, 1) +sql insert into db.t319 values(now, 1) + +sql show db.tables +if $rows != 80 then + return -1 +endi + +sql reset query cache +sleep 1000 + +sql select * from db.t000 +if $rows != 1 then + return -1 +endi + +sql select * from db.t100 +if $rows != 1 then + return -1 +endi + +sql select * from db.t200 +if $rows != 1 then + return -1 +endi + +sql select * from db.t300 +if $rows != 1 then + return -1 +endi + +sql select * from db.st +if $rows != 80 then + return -1 +endi + +print ============================ step10 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s start +$x = 0 +step10: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show mnodes -x step10 +print mnode1 $data2_1 +print mnode1 $data2_2 +print mnode1 $data2_3 +if $data2_1 != master then + goto step10 +endi + +sql reset query cache +sleep 1000 + +sql show db.tables +if $rows != 80 then + return -1 +endi + +sql select * from db.t000 +if $rows != 1 then + return -1 +endi + +sql select * from db.t100 +if $rows != 1 then + return -1 +endi + +sql select * from db.t200 +if $rows != 1 then + return -1 +endi + +sql select * from db.t300 +if $rows != 1 then + return -1 +endi + +sql select * from db.st +if $rows != 80 then + return -1 +endi + +print ============================ step11 +sql_error create table db.t400 using db.st tags(10) +sql show db.tables +if $rows != 80 then + return -1 +endi + +print ============================ step12 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 25 +system sh/exec.sh -n dnode1 -s start +$x = 0 +step12: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show mnodes -x step12 +print mnode1 $data2_1 +print mnode1 $data2_2 +print mnode1 $data2_3 +if $data2_1 != master then + goto step12 +endi + + +sql create table db.t400 using db.st tags(0) +sql create table db.t401 using db.st tags(1) +sql create table db.t402 using db.st tags(2) +sql create table db.t403 using db.st tags(3) +sql create table db.t404 using db.st tags(4) +sql create table db.t405 using db.st tags(5) +sql create table db.t406 using db.st tags(6) +sql create table db.t407 using db.st tags(7) +sql create table db.t408 using db.st tags(8) +sql create table db.t409 using db.st tags(9) +sql create table db.t410 using db.st tags(0) +sql create table db.t411 using db.st tags(1) +sql create table db.t412 using db.st tags(2) +sql create table db.t413 using db.st tags(3) +sql create table db.t414 using db.st tags(4) +sql create table db.t415 using db.st tags(5) +sql create table db.t416 using db.st tags(6) +sql create table db.t417 using db.st tags(7) +sql create table db.t418 using db.st tags(8) +sql create table db.t419 using db.st tags(9) + +sql insert into db.t400 values(now, 1) +sql insert into db.t401 values(now, 1) +sql insert into db.t402 values(now, 1) +sql insert into db.t403 values(now, 1) +sql insert into db.t404 values(now, 1) +sql insert into db.t405 values(now, 1) +sql insert into db.t406 values(now, 1) +sql insert into db.t407 values(now, 1) +sql insert into db.t408 values(now, 1) +sql insert into db.t409 values(now, 1) +sql insert into db.t410 values(now, 1) +sql insert into db.t411 values(now, 1) +sql insert into db.t412 values(now, 1) +sql insert into db.t413 values(now, 1) +sql insert into db.t414 values(now, 1) +sql insert into db.t415 values(now, 1) +sql insert into db.t416 values(now, 1) +sql insert into db.t417 values(now, 1) +sql insert into db.t418 values(now, 1) +sql insert into db.t419 values(now, 1) + +sql show db.tables +if $rows != 100 then + return -1 +endi + +sql reset query cache +sleep 1000 + +sql select * from db.t000 +if $rows != 1 then + return -1 +endi + +sql select * from db.t100 +if $rows != 1 then + return -1 +endi + +sql select * from db.t200 +if $rows != 1 then + return -1 +endi + +sql select * from db.t300 +if $rows != 1 then + return -1 +endi + +sql select * from db.t400 +if $rows != 1 then + return -1 +endi + +sql select * from db.st +if $rows != 100 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/db/alter_vgroups.sim b/tests/script/general/db/alter_vgroups.sim new file mode 100644 index 0000000000000000000000000000000000000000..81ffc7d443ce6b21978d338bfeb01f00f89a17b1 --- /dev/null +++ b/tests/script/general/db/alter_vgroups.sim @@ -0,0 +1,210 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 0 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 20 + +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ============================ step1 + +sql create database db +sql create table db.st (ts timestamp, i int) tags(t int) +sql create table db.t000 using db.st tags(0) +sql create table db.t001 using db.st tags(1) +sql create table db.t002 using db.st tags(2) +sql create table db.t003 using db.st tags(3) +sql create table db.t004 using db.st tags(4) +sql create table db.t005 using db.st tags(5) +sql create table db.t006 using db.st tags(6) +sql create table db.t007 using db.st tags(7) +sql create table db.t008 using db.st tags(8) +sql create table db.t009 using db.st tags(9) +sql create table db.t010 using db.st tags(0) +sql create table db.t011 using db.st tags(1) +sql create table db.t012 using db.st tags(2) +sql create table db.t013 using db.st tags(3) +sql create table db.t014 using db.st tags(4) +sql create table db.t015 using db.st tags(5) +sql create table db.t016 using db.st tags(6) +sql create table db.t017 using db.st tags(7) +sql create table db.t018 using db.st tags(8) +sql create table db.t019 using db.st tags(9) + +sql show db.tables +if $rows != 20 then + return -1 +endi + +sql insert into db.t000 values(now, 1) +sql insert into db.t001 values(now, 1) +sql insert into db.t002 values(now, 1) +sql insert into db.t003 values(now, 1) +sql insert into db.t004 values(now, 1) +sql insert into db.t005 values(now, 1) +sql insert into db.t006 values(now, 1) +sql insert into db.t007 values(now, 1) +sql insert into db.t008 values(now, 1) +sql insert into db.t009 values(now, 1) +sql insert into db.t010 values(now, 1) +sql insert into db.t011 values(now, 1) +sql insert into db.t012 values(now, 1) +sql insert into db.t013 values(now, 1) +sql insert into db.t014 values(now, 1) +sql insert into db.t015 values(now, 1) +sql insert into db.t016 values(now, 1) +sql insert into db.t017 values(now, 1) +sql insert into db.t018 values(now, 1) +sql insert into db.t019 values(now, 1) + +print ============================ step2 +sql_error create table db.t100 using db.st tags(10) +sql show db.tables +if $rows != 20 then + return -1 +endi + +print ============================ step3 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 2 +sleep 3000 +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +sql create table db.t100 using db.st tags(0) +sql create table db.t101 using db.st tags(1) +sql create table db.t102 using db.st tags(2) +sql create table db.t103 using db.st tags(3) +sql create table db.t104 using db.st tags(4) +sql create table db.t105 using db.st tags(5) +sql create table db.t106 using db.st tags(6) +sql create table db.t107 using db.st tags(7) +sql create table db.t108 using db.st tags(8) +sql create table db.t109 using db.st tags(9) +sql create table db.t110 using db.st tags(0) +sql create table db.t111 using db.st tags(1) +sql create table db.t112 using db.st tags(2) +sql create table db.t113 using db.st tags(3) +sql create table db.t114 using db.st tags(4) +sql create table db.t115 using db.st tags(5) +sql create table db.t116 using db.st tags(6) +sql create table db.t117 using db.st tags(7) +sql create table db.t118 using db.st tags(8) +sql create table db.t119 using db.st tags(9) +sql show db.tables +if $rows != 40 then + return -1 +endi + + +sql insert into db.t100 values(now, 1) +sql insert into db.t101 values(now, 1) +sql insert into db.t102 values(now, 1) +sql insert into db.t103 values(now, 1) +sql insert into db.t104 values(now, 1) +sql insert into db.t105 values(now, 1) +sql insert into db.t106 values(now, 1) +sql insert into db.t107 values(now, 1) +sql insert into db.t108 values(now, 1) +sql insert into db.t109 values(now, 1) +sql insert into db.t110 values(now, 1) +sql insert into db.t111 values(now, 1) +sql insert into db.t112 values(now, 1) +sql insert into db.t113 values(now, 1) +sql insert into db.t114 values(now, 1) +sql insert into db.t115 values(now, 1) +sql insert into db.t116 values(now, 1) +sql insert into db.t117 values(now, 1) +sql insert into db.t118 values(now, 1) +sql insert into db.t119 values(now, 1) + +print ============================ step4 +sql_error create table db.t200 using db.st tags(10) +sql show db.tables +if $rows != 40 then + return -1 +endi + +print ============================ step5 + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 3 +sleep 3000 +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +sql create table db.t200 using db.st tags(0) +sql create table db.t201 using db.st tags(1) +sql create table db.t202 using db.st tags(2) +sql create table db.t203 using db.st tags(3) +sql create table db.t204 using db.st tags(4) +sql create table db.t205 using db.st tags(5) +sql create table db.t206 using db.st tags(6) +sql create table db.t207 using db.st tags(7) +sql create table db.t208 using db.st tags(8) +sql create table db.t209 using db.st tags(9) +sql create table db.t210 using db.st tags(0) +sql create table db.t211 using db.st tags(1) +sql create table db.t212 using db.st tags(2) +sql create table db.t213 using db.st tags(3) +sql create table db.t214 using db.st tags(4) +sql create table db.t215 using db.st tags(5) +sql create table db.t216 using db.st tags(6) +sql create table db.t217 using db.st tags(7) +sql create table db.t218 using db.st tags(8) +sql create table db.t219 using db.st tags(9) +sql show db.tables +if $rows != 60 then + return -1 +endi + +sql insert into db.t200 values(now, 1) +sql insert into db.t201 values(now, 1) +sql insert into db.t202 values(now, 1) +sql insert into db.t203 values(now, 1) +sql insert into db.t204 values(now, 1) +sql insert into db.t205 values(now, 1) +sql insert into db.t206 values(now, 1) +sql insert into db.t207 values(now, 1) +sql insert into db.t208 values(now, 1) +sql insert into db.t209 values(now, 1) +sql insert into db.t210 values(now, 1) +sql insert into db.t211 values(now, 1) +sql insert into db.t212 values(now, 1) +sql insert into db.t213 values(now, 1) +sql insert into db.t214 values(now, 1) +sql insert into db.t215 values(now, 1) +sql insert into db.t216 values(now, 1) +sql insert into db.t217 values(now, 1) +sql insert into db.t218 values(now, 1) +sql insert into db.t219 values(now, 1) + +print ============================ step6 + +sql reset query cache +sleep 1000 + +sql select * from db.t000 +if $rows != 1 then + return -1 +endi + +sql select * from db.t100 +if $rows != 1 then + return -1 +endi + +sql select * from db.t200 +if $rows != 1 then + return -1 +endi + +sql select * from db.st +if $rows != 60 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/db/back_insert.sim b/tests/script/general/db/back_insert.sim new file mode 100644 index 0000000000000000000000000000000000000000..642df63ff280c6b2c41ef68e645b43fd0c998386 --- /dev/null +++ b/tests/script/general/db/back_insert.sim @@ -0,0 +1,9 @@ +sql connect +$x = 1 +begin: + sql reset query cache + sleep 1000 + sql insert into db.tb values(now, $x ) -x begin + #print ===> insert successed $x + $x = $x + 1 +goto begin \ No newline at end of file diff --git a/tests/script/general/db/backup/keep.sim b/tests/script/general/db/backup/keep.sim new file mode 100644 index 0000000000000000000000000000000000000000..4d157b39857a639a83d24e1d8eb027492a4d40de --- /dev/null +++ b/tests/script/general/db/backup/keep.sim @@ -0,0 +1,209 @@ +system sh/stop_dnodes.sh + + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 + +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode3 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 + +print ========= start dnode1 as master +system sh/exec.sh -n dnode1 -s start +sql connect + +print ========= start other dnodes +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start +sleep 2000 + +print ======== step1 create db +sql create database keepdb replica 1 keep 30 days 7 +sql use keepdb +sql create table tb (ts timestamp, i int) + +$x = 1 +while $x < 41 + $time = $x . d + sql insert into tb values (now + $time , $x ) + $x = $x + 1 +endw + +sql select * from tb +print ===> rows $rows +print ===> last $data01 + +if $rows != 40 then + return -1 +endi +if $data01 != 40 then + return -1 +endi + +print ======== step2 stop dnode +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode2 -s start +sleep 3000 + +sql select * from tb +print ===> rows $rows +print ===> last $data01 + +if $rows >= 40 then + return -1 +endi +if $rows <= 20 then + return -1 +endi +if $data01 != 40 then + return -1 +endi + +$num1 = $rows + 40 + +print ======== step3 alter db +sql alter database keepdb keep 60 +sleep 1000 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 +if $data02 != 1 then + return -1 +endi +if $data03 != 1 then + return -1 +endi +if $data04 != 1 then + return -1 +endi +if $data05 != 7 then + return -1 +endi +if $data06 != 60 then + return -1 +endi + +print ======== step4 insert data +$x = 41 +while $x < 81 + $time = $x . d + sql insert into tb values (now + $time , $x ) + $x = $x + 1 +endw + +sql select * from tb +print ===> rows $rows +print ===> last $data01 + +if $rows != $num1 then + return -1 +endi +if $data01 != 80 then + return -1 +endi + +print ======== step5 stop dnode +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode2 -s start +sleep 3000 + +sql select * from tb +print ===> rows $rows +print ===> last $data01 + +if $rows >= $num1 then + return -1 +endi +if $rows <= 50 then + return -1 +endi +if $data01 != 80 then + return -1 +endi + +print ======== step6 alter db +sql alter database keepdb keep 30 +sleep 1000 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 +if $data02 != 1 then + return -1 +endi +if $data03 != 1 then + return -1 +endi +if $data04 != 1 then + return -1 +endi +if $data05 != 7 then + return -1 +endi +if $data06 != 30 then + return -1 +endi + +print ======== step7 stop dnode +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 2000 +system sh/exec.sh -n dnode2 -s start +sleep 2000 + +sql select * from tb +print ===> rows $rows +print ===> last $data01 + +if $rows >= 40 then + return -1 +endi +if $rows <= 20 then + return -1 +endi +if $data01 != 80 then + return -1 +endi + +$num3 = $rows + 40 + +print ======== step8 insert data +$x = 81 +while $x < 121 + $time = $x . d + sql insert into tb values (now + $time , $x ) + $x = $x + 1 +endw + +sql select * from tb +print ===> rows $rows +print ===> last $data01 + +if $rows != $num3 then + return -1 +endi +if $data01 != 120 then + return -1 +endi + +print ======== step9 alter db +sql alter database keepdb keep -1 -x error1 + return -1 +error1: + +sql alter database keepdb keep 0 -x error2 + return -1 +error2: + +sql alter database keepdb days 1 -x error3 + return -1 +error3: + +print ======= test success + \ No newline at end of file diff --git a/tests/script/general/db/basic.sim b/tests/script/general/db/basic.sim new file mode 100644 index 0000000000000000000000000000000000000000..684ce825fecb64ef580751a8df104fd4e1c7cf24 --- /dev/null +++ b/tests/script/general/db/basic.sim @@ -0,0 +1,195 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 0 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 4 +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 1000 + +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect +print ============================ dnode1 start + +$i = 0 +$dbPrefix = ob_db_db +$tbPrefix = ob_db_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db replica 1 days 20 keep 2000 cache 16 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 +if $data00 != $db then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 0 then + return -1 +endi +if $data04 != 1 then + return -1 +endi +if $data06 != 20 then + return -1 +endi +if $data08 != 16 then + return -1 +endi + +print =============== step2 +sql create database $db +sql show databases +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +print =============== step4 +sql_error drop database $db + +print =============== step5 +sql create database $db replica 1 days 15 keep 1500 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 +if $data00 != $db then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 0 then + return -1 +endi +if $data04 != 1 then + return -1 +endi +if $data06 != 15 then + return -1 +endi + +print =============== step6 +sql use $db +sql create table $tb (ts timestamp, speed int) +$i = 1 +while $i < 4 + $db = $dbPrefix . $i + $tb = $tbPrefix . $i + sql create database $db + sql use $db + sql create table $tb (ts timestamp, speed int) + $i = $i + 1 +endw + +sql show databases +if $rows != 4 then + return -1 +endi + +$i = 4 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed int) + +print =============== step7 +$i = 0 +while $i < 5 + $db = $dbPrefix . $i + sql drop database $db + $i = $i + 1 +endw + +print =============== step8 +$i = 0 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed int) +sql show tables +if $rows != 1 then + return -1 +endi + +print =============== step9 +sql drop database $db + +print =============== step10 +sql create database $db +sql use $db +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step11 +sql create table $tb (ts timestamp, speed int) +sql show tables +if $rows != 1 then + return -1 +endi + +print =============== step12 +sql drop database $db + +print =============== step13 +sql create database $db +sql use $db +sql show tables +if $rows != 0 then + return -1 +endi +sql create table $tb (ts timestamp, speed int) +sql show tables +if $rows != 1 then + return -1 +endi +sql insert into $tb values (now+1a, 0) +sql insert into $tb values (now+2a, 1) +sql insert into $tb values (now+3a, 2) +sql insert into $tb values (now+4a, 3) +sql insert into $tb values (now+5a, 4) +sql select * from $tb +if $rows != 5 then + return -1 +endi + +print =============== step14 +sql drop database $db + +print =============== step15 +sql create database $db +sql use $db +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step16 +sql create table $tb (ts timestamp, speed int) +sql show tables +if $rows != 1 then + return -1 +endi +sql select * from $tb +if $rows != 0 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/db/basic1.sim b/tests/script/general/db/basic1.sim new file mode 100644 index 0000000000000000000000000000000000000000..9ec1aabe98ba21af5927faec2e26aef1c3a14aeb --- /dev/null +++ b/tests/script/general/db/basic1.sim @@ -0,0 +1,62 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print =============== create database +sql create database d1 +sql show databases +if $rows != 1 then + return -1 +endi + +if $data00 != d1 then + return -1 +endi + +if $data02 != 0 then + return -1 +endi + +if $data03 != 0 then + return -1 +endi + +print =============== drop database +sql drop database d1 +sql show databases +if $rows != 0 then + return -1 +endi + +print =============== more databases +sql create database d2 +sql create database d3 +sql create database d4 +sql show databases +if $rows != 3 then + return -1 +endi + +print =============== drop database +sql drop database d2 +sql drop database d3 +sql show databases +if $rows != 1 then + return -1 +endi + +if $data00 != d4 then + return -1 +endi + +if $data02 != 0 then + return -1 +endi + +if $data03 != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/db/basic2.sim b/tests/script/general/db/basic2.sim new file mode 100644 index 0000000000000000000000000000000000000000..acd035bd744eb53b856c32beaf69445eb24e8315 --- /dev/null +++ b/tests/script/general/db/basic2.sim @@ -0,0 +1,54 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print =============== create database d1 +sql create database d1 +sql use d1 +sql create table t1 (ts timestamp, i int); +sql create table t2 (ts timestamp, i int); +sql create table t3 (ts timestamp, i int); +sql create table t4 (ts timestamp, i int); + +sql show databases +if $rows != 1 then + return -1 +endi + +if $data00 != d1 then + return -1 +endi + +if $data02 != 4 then + return -1 +endi + +if $data03 != 1 then + return -1 +endi + +sql show tables +if $rows != 4 then + return -1 +endi + +print =============== create database d2 +sql create database d2 +sql use d2 +sql create table t1 (ts timestamp, i int); +sql create table t2 (ts timestamp, i int); +sql create table t3 (ts timestamp, i int); + +sql show databases +if $rows != 2 then + return -1 +endi + +sql show tables +if $rows != 3 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/db/basic3.sim b/tests/script/general/db/basic3.sim new file mode 100644 index 0000000000000000000000000000000000000000..fb64476696c7aba65d5f5f87c68857ed32ff24fc --- /dev/null +++ b/tests/script/general/db/basic3.sim @@ -0,0 +1,52 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print =============== create database d1 +sql create database d1 +sql create table d1.t1 (ts timestamp, i int); +sql create table d1.t2 (ts timestamp, i int); +sql create table d1.t3 (ts timestamp, i int); +sql create table d1.t4 (ts timestamp, i int); + +sql show databases +if $rows != 1 then + return -1 +endi + +if $data00 != d1 then + return -1 +endi + +if $data02 != 4 then + return -1 +endi + +if $data03 != 1 then + return -1 +endi + +sql show d1.tables +if $rows != 4 then + return -1 +endi + +print =============== create database d2 +sql create database d2 +sql create table d2.t1 (ts timestamp, i int); +sql create table d2.t2 (ts timestamp, i int); +sql create table d2.t3 (ts timestamp, i int); + +sql show databases +if $rows != 2 then + return -1 +endi + +sql show d2.tables +if $rows != 3 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/db/basic4.sim b/tests/script/general/db/basic4.sim new file mode 100644 index 0000000000000000000000000000000000000000..ce6d352d12412c95d0883ca246e2603b36617bb8 --- /dev/null +++ b/tests/script/general/db/basic4.sim @@ -0,0 +1,115 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print =============== create database d1 +sql create database d1 +sql create table d1.t1 (ts timestamp, i int); +sql create table d1.t2 (ts timestamp, i int); +sql create table d1.t3 (ts timestamp, i int); +sql create table d1.t4 (ts timestamp, i int); + +sql show databases +if $rows != 1 then + return -1 +endi + +if $data00 != d1 then + return -1 +endi + +if $data02 != 4 then + return -1 +endi + +if $data03 != 1 then + return -1 +endi + +sql show d1.tables +if $rows != 4 then + return -1 +endi + +sql show d1.vgroups +if $rows != 1 then + return -1 +endi +if $data00 != 2 then + return -1 +endi +if $data01 != 4 then + return -1 +endi + +print =============== drop table +sql drop table d1.t1 + +sql show databases +if $rows != 1 then + return -1 +endi + +if $data00 != d1 then + return -1 +endi + +if $data02 != 3 then + return -1 +endi + +if $data03 != 1 then + return -1 +endi + +sql show d1.tables +if $rows != 3 then + return -1 +endi + +sql show d1.vgroups +if $rows != 1 then + return -1 +endi +if $data00 != 2 then + return -1 +endi +if $data01 != 3 then + return -1 +endi + +print =============== drop all table +sql drop table d1.t2 +sql drop table d1.t3 +sql drop table d1.t4 + +sql show databases +if $rows != 1 then + return -1 +endi + +if $data00 != d1 then + return -1 +endi + +if $data02 != 0 then + return -1 +endi + +if $data03 != 0 then + return -1 +endi + +sql show d1.tables +if $rows != 0 then + return -1 +endi + +sql show d1.vgroups +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/db/basic5.sim b/tests/script/general/db/basic5.sim new file mode 100644 index 0000000000000000000000000000000000000000..08c9db23323ba7d4257671d6f0a71c3dd133ad03 --- /dev/null +++ b/tests/script/general/db/basic5.sim @@ -0,0 +1,57 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print =============== create database d1 +sql create database d1 +sql create table d1.t1 (ts timestamp, i int); +sql create table d1.t2 (ts timestamp, i int); +sql create table d1.t3 (ts timestamp, i int); +sql create table d1.t4 (ts timestamp, i int); + +sql show databases +if $rows != 1 then + return -1 +endi + +if $data00 != d1 then + return -1 +endi + +if $data02 != 4 then + return -1 +endi + +if $data03 != 1 then + return -1 +endi + +sql show d1.tables +if $rows != 4 then + return -1 +endi + +sql show d1.vgroups +if $rows != 1 then + return -1 +endi +if $data00 != 2 then + return -1 +endi +if $data01 != 4 then + return -1 +endi + +print =============== drop database +sql drop database d1 + +sql show databases +if $rows != 0 then + return -1 +endi + +sql_error show d1.vgroups + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/db/delete.sim b/tests/script/general/db/delete.sim new file mode 100644 index 0000000000000000000000000000000000000000..4384044885e7c6a660079551b1190481ace3554e --- /dev/null +++ b/tests/script/general/db/delete.sim @@ -0,0 +1,66 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 10 +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 1000 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ======== step1 +sql create database db blocks 3 +sql create table db.mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$tbPrefix = db.t +$i = 0 +while $i < 2000 + $tb = $tbPrefix . $i + sql create table $tb using db.mt tags( $i ) + $i = $i + 1 +endw + +sql show db.vgroups +if $rows != 10 then + return -1 +endi + +return +print ======== step2 +sleep 1000 +sql drop database db +sql show databases +if $rows != 0 then + return -1 +endi + +sleep 1000 +sql show dnodes +print dnode1 openVnodes $data2_1 +if $data2_1 != 0 then + return -1 +endi + +print ======= step3 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start + +$x = 0 +step3: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi + +sql show mnodes +print dnode1 role $data2_1 +if $data2_1 != master then + goto step3 +endi + +sleep 1000 + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/db/delete_reuse1.sim b/tests/script/general/db/delete_reuse1.sim new file mode 100644 index 0000000000000000000000000000000000000000..9d02e041c461000982079b86b5359a0b5d3107a3 --- /dev/null +++ b/tests/script/general/db/delete_reuse1.sim @@ -0,0 +1,107 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode3 -c walLevel -v 1 +system sh/cfg.sh -n dnode4 -c walLevel -v 1 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ======== step1 +sql create database d1 replica 1 +sql create database d2 replica 1 +sql create database d3 replica 1 +sql create database d4 replica 1 + +sql create table d1.t1 (ts timestamp, i int) +sql create table d2.t2 (ts timestamp, i int) +sql create table d3.t3 (ts timestamp, i int) +sql create table d4.t4 (ts timestamp, i int) + +sql insert into d2.t2 values(now, 1) +sql insert into d1.t1 values(now, 1) +sql insert into d3.t3 values(now, 1) +sql insert into d4.t4 values(now, 1) + +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 1 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 1 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 1 then + return -1 +endi + +print ======== step2 +sql drop database d1 +sleep 1000 +sql insert into d1.t1 values(now, 2) -x step2 + return -1 +step2: + +print ========= step3 +sql reset query cache +sleep 1000 +sql create database d1 replica 1 +sql create table d1.t1 (ts timestamp, i int) +sql insert into d1.t1 values(now, 2) +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi + +print ========= step4 +$x = 0 +while $x < 20 + + sql drop database d1 + sleep 1000 + sql insert into d1.t1 values(now, -1) -x step4 + return -1 + step4: + + sql create database d1 replica 1 + sql reset query cache + sleep 1000 + sql create table d1.t1 (ts timestamp, i int) + sql insert into d1.t1 values(now, $x ) + sql select * from d1.t1 + if $rows != 1 then + return -1 + endi + + $x = $x + 1 + + print ===> loop times: $x +endw + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/db/delete_reuse2.sim b/tests/script/general/db/delete_reuse2.sim new file mode 100644 index 0000000000000000000000000000000000000000..889c8f46f74783ff084e1dfaa06fb1fc9d900d5d --- /dev/null +++ b/tests/script/general/db/delete_reuse2.sim @@ -0,0 +1,117 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode3 -c walLevel -v 1 +system sh/cfg.sh -n dnode4 -c walLevel -v 1 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sleep 2000 + +sql connect +sql reset query cache + +print ======== step1 +sql create database d1 replica 1 +sql create database d2 replica 1 +sql create database d3 replica 1 +sql create database d4 replica 1 + +sql create table d1.t1 (ts timestamp, i int) +sql create table d2.t2 (ts timestamp, i int) +sql create table d3.t3 (ts timestamp, i int) +sql create table d4.t4 (ts timestamp, i int) + +sql insert into d2.t2 values(now, 1) +sql insert into d1.t1 values(now, 1) +sql insert into d3.t3 values(now, 1) +sql insert into d4.t4 values(now, 1) + +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 1 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 1 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 1 then + return -1 +endi + +print ======== step2 +sql drop database d1 +sleep 500 +sql insert into d1.t1 values(now, 2) -x step2 + return -1 +step2: + +print ========= step3 +sql create database db1 replica 1 +sql reset query cache +sleep 500 +sql create table db1.tb1 (ts timestamp, i int) +sql insert into db1.tb1 values(now, 2) +sql select * from db1.tb1 +if $rows != 1 then + return -1 +endi + +print ========= step4 +$x = 1 +while $x < 20 + + $db = db . $x + $tb = tb . $x + sql use $db + sql drop database $db + + sleep 500 + sql insert into $tb values(now, -1) -x step4 + return -1 + step4: + + $x = $x + 1 + $db = db . $x + $tb = tb . $x + + sql reset query cache + sleep 500 + + sql create database $db replica 1 + sql use $db + sql create table $tb (ts timestamp, i int) + sql insert into $tb values(now, $x ) + sql select * from $tb + if $rows != 1 then + return -1 + endi + + print ===> loop times: $x +endw + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/db/delete_reusevnode.sim b/tests/script/general/db/delete_reusevnode.sim new file mode 100644 index 0000000000000000000000000000000000000000..4364a760a6b61be89f00f5a22d19c9ecf9015cb2 --- /dev/null +++ b/tests/script/general/db/delete_reusevnode.sim @@ -0,0 +1,106 @@ +system sh/stop_dnodes.sh + +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 +system sh/deploy.sh -n dnode1 -i 1 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sql connect + +print ======== step1 + +$tbPrefix = t +$i = 0 +while $i < 30 + $db = db . $i + sql create database $db + sql use $db + + $tb = $tbPrefix . $i + sql create table $tb (ts timestamp, i int); + + sql insert into $tb values(now, 1); + + sleep 1000 + sql drop database $db + + print times $i + $i = $i + 1 + +endw + +print ======== step2 +sleep 1000 +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sql connect + +print ======== step1 + +$tbPrefix = t +$i = 0 +while $i < 10 + $db = db . $i + sql create database $db + sql use $db + + sql create table st (ts timestamp, i int) tags(j int); + $tb = $tbPrefix . $i + $tb = $tb . a + + $tb1 = $tb . 1 + sql create table $tb1 using st tags(1) + sql insert into $tb1 values(now, 1); + + $tb1 = $tb . 2 + sql create table $tb1 using st tags(1) + sql insert into $tb1 values(now, 1); + + $tb1 = $tb . 3 + sql create table $tb1 using st tags(1) + sql insert into $tb1 values(now, 1); + + $tb1 = $tb . 5 + sql create table $tb1 using st tags(1) + sql insert into $tb1 values(now, 1); + + $tb1 = $tb . 5 + sql create table $tb1 using st tags(1) + sql insert into $tb1 values(now, 1); + + $tb1 = $tb . 6 + sql create table $tb1 using st tags(1) + sql insert into $tb1 values(now, 1); + + $tb1 = $tb . 7 + sql create table $tb1 using st tags(1) + sql insert into $tb1 values(now, 1); + + $tb1 = $tb . 8 + sql create table $tb1 using st tags(1) + sql insert into $tb1 values(now, 1); + + sleep 1000 + sql drop database $db + + print times $i + $i = $i + 1 + +endw + +print ======== step2 +sleep 1000 +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/db/delete_reusevnode2.sim b/tests/script/general/db/delete_reusevnode2.sim new file mode 100644 index 0000000000000000000000000000000000000000..c05db6b65a43df2cec9cb410aef69ac23985307e --- /dev/null +++ b/tests/script/general/db/delete_reusevnode2.sim @@ -0,0 +1,71 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ======== step1 + +sql create database db; +sql use db + +$tbPrefix = t +$i = 0 +while $i < 10 + + sql create table st (ts timestamp, i int) tags(j int); + $tb = $tbPrefix . $i + $tb = $tb . a + + $tb1 = $tb . 1 + sql create table $tb1 using st tags(1) + sql insert into $tb1 values(now, 1); + + $tb1 = $tb . 2 + sql create table $tb1 using st tags(1) + sql insert into $tb1 values(now, 1); + + $tb1 = $tb . 3 + sql create table $tb1 using st tags(1) + sql insert into $tb1 values(now, 1); + + $tb1 = $tb . 4 + sql create table $tb1 using st tags(1) + sql insert into $tb1 values(now, 1); + + $tb1 = $tb . 5 + sql create table $tb1 using st tags(1) + sql insert into $tb1 values(now, 1); + + $tb1 = $tb . 6 + sql create table $tb1 using st tags(1) + sql insert into $tb1 values(now, 1); + + $tb1 = $tb . 7 + sql create table $tb1 using st tags(1) + sql insert into $tb1 values(now, 1); + + $tb1 = $tb . 8 + sql create table $tb1 using st tags(1) + sql insert into $tb1 values(now, 1); + + sql drop table st + + sleep 2000 + print times $i + $i = $i + 1 + +endw + +print ======== step2 +sleep 1000 +sql drop database db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/db/delete_writing1.sim b/tests/script/general/db/delete_writing1.sim new file mode 100644 index 0000000000000000000000000000000000000000..010bd707434afe3fe85c2f8d0ecbe77e67d6b252 --- /dev/null +++ b/tests/script/general/db/delete_writing1.sim @@ -0,0 +1,51 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode3 -c walLevel -v 1 +system sh/cfg.sh -n dnode4 -c walLevel -v 1 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create database db +sql create table db.tb (ts timestamp, i int) +sql insert into db.tb values(now, 1) + +print ======== start back +run_back general/db/back_insert.sim +sleep 1000 + +print ======== step1 +$x = 1 +while $x < 20 + + print drop database times $x + sql drop database db -x step1 + step1: + + sql create database db + sql create table db.tb (ts timestamp, i int) + + sleep 2000 + + $x = $x + 1 +endw + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/db/delete_writing2.sim b/tests/script/general/db/delete_writing2.sim new file mode 100644 index 0000000000000000000000000000000000000000..2d1b0c8d9cb4b4bfc8774436accf6b8ff90843da --- /dev/null +++ b/tests/script/general/db/delete_writing2.sim @@ -0,0 +1,47 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 0 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +sql create database db +sql create table db.tb (ts timestamp, i int) +sql insert into db.tb values(now, 1) + +sql create database db2 +sql create table db2.tb2 (ts timestamp, i int) +sql insert into db2.tb2 values(now, 1) + +sql create database db3 +sql create table db3.tb3 (ts timestamp, i int) +sql insert into db3.tb3 values(now, 1) + +sql create database db4 +sql create table db4.tb4 (ts timestamp, i int) +sql insert into db4.tb4 values(now, 1) + +print ======== start back +run_back general/db/back_insert.sim +sleep 1000 + +print ======== step1 +$x = 1 +while $x < 10 + + print drop database times $x + sql drop database db -x step1 + step1: + + sql create database db + sql create table db.tb (ts timestamp, i int) + + sleep 2000 + + $x = $x + 1 +endw + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/db/dropdnodes.sim b/tests/script/general/db/dropdnodes.sim new file mode 100644 index 0000000000000000000000000000000000000000..8a46d5f9ce405cb84957900c37986cbede044464 --- /dev/null +++ b/tests/script/general/db/dropdnodes.sim @@ -0,0 +1,107 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/deploy.sh -n dnode2 -i 2 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4 + +print ========== prepare data +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start + +sleep 2000 +sql connect + +sql create dnode $hostname2 +sleep 2000 + +sql create database db +sql use db + +print ========== step1 +sql create table mt (ts timestamp, tbcol int) TAGS(tgcol int) +sql create table db.t1 using db.mt tags(1) +sql create table db.t2 using db.mt tags(2) +sql create table db.t3 using db.mt tags(3) +sql create table db.t4 using db.mt tags(4) +sql create table db.t5 using db.mt tags(5) +sql create table db.t6 using db.mt tags(6) +sql create table db.t7 using db.mt tags(7) +sql create table db.t8 using db.mt tags(8) +sql create table db.t9 using db.mt tags(9) +sql create table db.t10 using db.mt tags(10) +sql create table db.t11 using db.mt tags(11) +sql create table db.t12 using db.mt tags(12) +sql create table db.t13 using db.mt tags(13) +sql create table db.t14 using db.mt tags(14) +sql create table db.t15 using db.mt tags(15) +sql create table db.t16 using db.mt tags(16) + +sql insert into db.t1 values(now, 1) +sql insert into db.t2 values(now, 1) +sql insert into db.t3 values(now, 1) +sql insert into db.t4 values(now, 1) +sql insert into db.t5 values(now, 1) +sql insert into db.t6 values(now, 1) +sql insert into db.t7 values(now, 1) +sql insert into db.t8 values(now, 1) +sql insert into db.t9 values(now, 1) +sql insert into db.t10 values(now, 1) +sql insert into db.t11 values(now, 1) +sql insert into db.t12 values(now, 1) +sql insert into db.t13 values(now, 1) +sql insert into db.t14 values(now, 1) +sql insert into db.t15 values(now, 1) +sql insert into db.t16 values(now, 1) + +print ========== step2 +sql show tables +print $rows +if $rows != 16 then + return -1 +endi + +sql select * from mt +print $rows +if $rows != 16 then + return -1 +endi + +print ========== step3 + +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 3000 +sql drop dnode $hostname2 +sleep 2000 + +print ========== step3 + +sql show tables +print $rows +if $rows != 8 then + return -1 +endi + +sql select * from mt +print $rows +if $rows != 8 then + return -1 +endi + +sql select * from db.t5 +if $rows != 1 then + return -1 +endi + +sql select * from db.t13 +if $rows != 1 then + return -1 +endi + +sql_error select * from db.t1 +sql_error select * from db.t9 + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/db/len.sim b/tests/script/general/db/len.sim new file mode 100644 index 0000000000000000000000000000000000000000..8c08d2b09afe713907f6e8f104874ee19b7a2fae --- /dev/null +++ b/tests/script/general/db/len.sim @@ -0,0 +1,95 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2000 + +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print =============== step1 +sql_error drop database dd + +sql create database -x step1 + return -1 +step1: + +sql show databases +if $rows != 0 then + return -1 +endi + +print =============== step2 +sql create database a +sql show databases +if $rows != 1 then + return -1 +endi + +sql drop database a +sql show databases +if $rows != 0 then + return -1 +endi + +print =============== step3 +sql create database a12345678 +sql show databases +if $rows != 1 then + return -1 +endi + +sql drop database a12345678 +sql show databases +if $rows != 0 then + return -1 +endi + +print =============== step4 +sql create database a012345678901201234567890120123456789012a012345678901201234567890120123456789012 -x step4 + return -1 +step4: +sql show databases +if $rows != 0 then + return -1 +endi + +print =============== step5 +sql create database a;1 +sql drop database a +sql show databases +if $rows != 0 then + return -1 +endi + +print =============== step6 +sql create database a'1 -x step6 + return -1 +step6: + +sql show databases +if $rows != 0 then + return -1 +endi + +print =============== step7 +sql create database (a) -x step7 + return -1 +step7: +sql show databases +if $rows != 0 then + return -1 +endi + +print =============== step8 +sql create database a.1 -x step8 + return -1 +step8: +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/db/nosuchfile.sim b/tests/script/general/db/nosuchfile.sim new file mode 100644 index 0000000000000000000000000000000000000000..69db8c0dc53ff39fff9840b3c86deef85e6d6dfa --- /dev/null +++ b/tests/script/general/db/nosuchfile.sim @@ -0,0 +1,66 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 2 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect +sleep 2000 + +print ========== step3 +sql create database d1 +sql create table d1.t1 (t timestamp, i int) +sql insert into d1.t1 values(now+1s, 35) +sql insert into d1.t1 values(now+2s, 34) +sql insert into d1.t1 values(now+3s, 33) +sql insert into d1.t1 values(now+4s, 32) +sql insert into d1.t1 values(now+5s, 31) + +print ========== step4 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s start +sleep 2000 + +print ========== step5 +sql select * from d1.t1 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 31 then + return -1 +endi +if $data11 != 32 then + return -1 +endi +if $data21 != 33 then + return -1 +endi +if $data31 != 34 then + return -1 +endi +if $data41 != 35 then + return -1 +endi + +print ========== step6 +system_content rm -rf ../../../sim/dnode1/data/vnode/vnode2/tsdb/data + +print ========== step7 +sql select * from d1.t1 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != null then + return -1 +endi +if $data11 != null then + return -1 +endi +if $data21 != null then + return -1 +endi +if $data31 != null then + return -1 +endi +if $data41 != null then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/db/repeat.sim b/tests/script/general/db/repeat.sim new file mode 100644 index 0000000000000000000000000000000000000000..b3bbca2d19012e49c3c4210dbbb3b94256cfe278 --- /dev/null +++ b/tests/script/general/db/repeat.sim @@ -0,0 +1,70 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 0 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 + +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect +print ============================ dnode1 start + +sql create database d1 +sql create table d1.t1(ts timestamp, i int) + +sql create database d2 +sql create table d2.t1(ts timestamp, i int) + +sql create database d3 +sql create table d3.t1(ts timestamp, i int) + +sql create database d4 +sql create table d4.t1(ts timestamp, i int) + +sleep 2000 + +sql drop database d1 +sql drop database d2 +sql drop database d3 +sql drop database d4 +sleep 2000 + +sql create database d5 +sql create table d5.t1(ts timestamp, i int) + +sql create database d6 +sql create table d6.t1(ts timestamp, i int) + +sql create database d7 +sql create table d7.t1(ts timestamp, i int) + +sql create database d8 +sql create table d8.t1(ts timestamp, i int) + +sleep 2000 + +sql drop database d5 +sql drop database d6 +sql drop database d7 +sql drop database d8 + +sleep 2000 + +sql create database d9; +sql create table d9.t1(ts timestamp, i int) + +sql create database d10; +sql create table d10.t1(ts timestamp, i int) + +sql create database d11 +sql create table d11.t1(ts timestamp, i int) + +sql create database d12 +sql create table d12.t1(ts timestamp, i int) + +sql drop database d9 +sql drop database d10 +sql drop database d11 +sql drop database d12 + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/db/show_create_db.sim b/tests/script/general/db/show_create_db.sim new file mode 100644 index 0000000000000000000000000000000000000000..f2e8011a0e789792a1a9a345e7f59eb3a8d4a0e7 --- /dev/null +++ b/tests/script/general/db/show_create_db.sim @@ -0,0 +1,32 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 + +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print =============== step2 +sql create database db +sql show create database db + +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql use db +sql show create database db + +if $rows != 1 then + return -1 +endi + +if $data00 != db then + return -1 +endi + +sql drop database db + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/db/show_create_table.sim b/tests/script/general/db/show_create_table.sim new file mode 100644 index 0000000000000000000000000000000000000000..5f2ae61343f51e52a39b11ebce75de2f2c305cad --- /dev/null +++ b/tests/script/general/db/show_create_table.sim @@ -0,0 +1,87 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 + +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ===============create three type table +sql create database db +sql use db +sql create table meters(ts timestamp, f binary(8)) tags(loc int, zone binary(8)) +sql create table t0 using meters tags(1,'ch') +sql create table normalTbl(ts timestamp, zone binary(8)) + +sql use db +sql show create table meters +if $rows != 1 then + return -1 +endi + +print ===============check sub table +sql show create table t0 +if $rows != 1 then + return -1 +endi +if $data00 == 't0' then + return -1 +endi + +print ===============check normal table + +sql show create table normalTbl +if $rows != 1 then + return -1 +endi + +if $data00 == 'normalTbl' then + return -1 +endi + +print ===============check super table +sql show create table meters +if $rows != 1 then + return -1 +endi + +if $data00 == 'meters' then + return -1 +endi + +print ===============check sub table with prefix + +sql show create table db.t0 +if $rows != 1 then + return -1 +endi + +if $data00 == 't0' then + return -1 +endi + +print ===============check normal table with prefix +sql show create table db.normalTbl +if $rows != 1 then + return -1 +endi + +if $data00 == 'normalTbl' then + return -1 +endi + + +print ===============check super table with prefix +sql show create table db.meters +if $rows != 1 then + return -1 +endi + +if $data00 == 'meters' then + return -1 +endi + +sql drop database db + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/db/tables.sim b/tests/script/general/db/tables.sim new file mode 100644 index 0000000000000000000000000000000000000000..b32fae25e0a12084e473cd82f482501eb3d99716 --- /dev/null +++ b/tests/script/general/db/tables.sim @@ -0,0 +1,135 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 4 +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 + +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print =============== step2 +sql create database db +sql show databases +print $rows $data07 + +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql use db +sql create table t1 (ts timestamp, i int) +sql create table t2 (ts timestamp, i int) +sql create table t3 (ts timestamp, i int) +sql create table t4 (ts timestamp, i int) +sql create table t11 (ts timestamp, i int) +sql create table t12 (ts timestamp, i int) +sql create table t13 (ts timestamp, i int) +sql create table t14 (ts timestamp, i int) +sql create table t21 (ts timestamp, i int) +sql create table t22 (ts timestamp, i int) +sql create table t23 (ts timestamp, i int) +sql create table t24 (ts timestamp, i int) +sql create table t31 (ts timestamp, i int) +sql create table t32 (ts timestamp, i int) +sql create table t33 (ts timestamp, i int) +sql create table t34 (ts timestamp, i int) + +print =============== step4 +sql insert into t1 values(now, 1) +sql insert into t2 values(now, 2) +sql insert into t3 values(now, 3) +sql insert into t4 values(now, 4) +sql insert into t11 values(now, 1) +sql insert into t22 values(now, 2) +sql insert into t33 values(now, 3) +sql insert into t34 values(now, 4) + +print =============== step5 +sql select * from t1 +if $data01 != 1 then + return -1 +endi + +sql select * from t2 +if $data01 != 2 then + return -1 +endi + +sql select * from t3 +if $data01 != 3 then + return -1 +endi + +sql select * from t4 +if $data01 != 4 then + return -1 +endi + +print =============== step6 +sql drop database db +sql reset query cache +sleep 4000 + +print =============== step7 +sql create database db +sql show databases +print $rows $data07 + +if $rows != 1 then + return -1 +endi + +print =============== step8 +sql use db +sql create table t1 (ts timestamp, i int) +sql create table t2 (ts timestamp, i int) +sql create table t3 (ts timestamp, i int) +sql create table t4 (ts timestamp, i int) +sql create table t11 (ts timestamp, i int) +sql create table t12 (ts timestamp, i int) +sql create table t13 (ts timestamp, i int) +sql create table t14 (ts timestamp, i int) +sql create table t21 (ts timestamp, i int) +sql create table t22 (ts timestamp, i int) +sql create table t23 (ts timestamp, i int) +sql create table t24 (ts timestamp, i int) +sql create table t31 (ts timestamp, i int) +sql create table t32 (ts timestamp, i int) +sql create table t33 (ts timestamp, i int) +sql create table t34 (ts timestamp, i int) + +print =============== step9 +sql insert into t1 values(now, 1) +sql insert into t2 values(now, 2) +sql insert into t3 values(now, 3) +sql insert into t4 values(now, 4) +sql insert into t11 values(now, 1) +sql insert into t22 values(now, 2) +sql insert into t33 values(now, 3) +sql insert into t34 values(now, 4) + +print =============== step10 +sql select * from t1 +if $data01 != 1 then + return -1 +endi + +sql select * from t2 +if $data01 != 2 then + return -1 +endi + +sql select * from t3 +if $data01 != 3 then + return -1 +endi + +sql select * from t4 +if $data01 != 4 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/db/testSuite.sim b/tests/script/general/db/testSuite.sim new file mode 100644 index 0000000000000000000000000000000000000000..87863001a3dfab6bb16a9919910b5e7bedd7863d --- /dev/null +++ b/tests/script/general/db/testSuite.sim @@ -0,0 +1,16 @@ +run general/db/basic.sim +run general/db/basic1.sim +run general/db/basic2.sim +run general/db/basic3.sim +run general/db/basic4.sim +run general/db/basic5.sim +run general/db/delete_reuse1.sim +run general/db/delete_reuse2.sim +run general/db/delete_reusevnode.sim +run general/db/delete_reusevnode2.sim +run general/db/delete_writing1.sim +run general/db/delete_writing2.sim +run general/db/len.sim +run general/db/repeat.sim +run general/db/tables.sim +run general/db/vnodes.sim diff --git a/tests/script/general/db/topic1.sim b/tests/script/general/db/topic1.sim new file mode 100644 index 0000000000000000000000000000000000000000..16399731208915602fea6dcd123fb85edf2e085b --- /dev/null +++ b/tests/script/general/db/topic1.sim @@ -0,0 +1,857 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 100 +system sh/cfg.sh -n dnode1 -c partitions -v 4 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ====step1 create with default para +sql create topic t1; +sql use t1; + +sql show topics; +if $rows != 1 then + return -1 +endi +if $data00 != t1 then + return -1 +endi +if $data02 != 4 then + return -1 +endi + +sql show databases; +if $rows != 1 then + return -1 +endi +if $data00 != t1 then + return -1 +endi +#tables +if $data02 < 1 then + return -1 +endi +#numofvgroups +if $data03 < 1 then + return -1 +endi + +sql show t1.vgroups; +if $rows < 1 then + return -1 +endi + +sql show t1.stables; +if $rows != 1 then + return -1 +endi +if $data04 < 1 then + return -1 +endi + +sql show t1.tables; +if $rows < 1 then + return -1 +endi + +sql drop topic t1 +sql show topics; +if $rows != 0 then + return -1 +endi +sql show databases; +if $rows != 0 then + return -1 +endi + +sql_error use t1; +sql_error show t1.vgroups; +sql_error show t1.stables; +sql_error show t1.tables; + +print ====step2 create with giving para +sql create topic t1 partitions 6; + +sql show topics; +if $rows != 1 then + return -1 +endi +if $data00 != t1 then + return -1 +endi +if $data02 != 6 then + return -1 +endi + +sql show databases; +if $rows != 1 then + return -1 +endi +if $data00 != t1 then + return -1 +endi +#tables +if $data02 != 6 then + return -1 +endi +#numofvgroups +if $data03 != 6 then + return -1 +endi + +sql show t1.vgroups; +if $rows != 6 then + return -1 +endi + +sql show t1.stables; +if $rows != 1 then + return -1 +endi +if $data00 != ps then + return -1 +endi +if $data04 != 6 then + return -1 +endi + +sql show t1.tables; +if $rows != 6 then + return -1 +endi + +sql describe t1.ps; +if $data00 != off then + return -1 +endi +if $data10 != ts then + return -1 +endi +if $data20 != content then + return -1 +endi +if $data30 != pid then + return -1 +endi + +sql describe t1.p1; +if $data00 != off then + return -1 +endi +if $data10 != ts then + return -1 +endi +if $data20 != content then + return -1 +endi +if $data30 != pid then + return -1 +endi + +sql drop topic t1 +sql show topics; +if $rows != 0 then + return -1 +endi + +sql show databases; +if $rows != 0 then + return -1 +endi + +sql_error show t1.vgroups; +sql_error show t1.stables; +sql_error show t1.tables; + +sql_error create topic t1 partitions -1; +#sql_error create topic t1 partitions 0; +sql_error create topic t1 partitions 10001; + +print =============step3 create with db para +sql create topic db cache 2 blocks 4 days 10 keep 20 minRows 300 maxRows 400 ctime 120 precision 'ms' comp 2 wal 1 replica 1 +sql show databases +if $data00 != db then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data03 != 4 then + return -1 +endi +if $data04 != 1 then + return -1 +endi +if $data06 != 10 then + return -1 +endi +if $data07 != 20,20,20 then + return -1 +endi +if $data08 != 2 then + return -1 +endi +if $data09 != 4 then + return -1 +endi +sql drop topic db; + +sql create topic db cache 2 blocks 4 days 10 keep 20 minRows 300 maxRows 400 ctime 120 precision 'ms' comp 2 wal 1 replica 1 partitions 7 +sql show databases +if $data00 != db then + return -1 +endi +if $data02 != 7 then + return -1 +endi +if $data03 != 7 then + return -1 +endi +if $data04 != 1 then + return -1 +endi +if $data06 != 10 then + return -1 +endi +if $data07 != 20,20,20 then + return -1 +endi +if $data08 != 2 then + return -1 +endi +if $data09 != 4 then + return -1 +endi + +sql show topics; +if $rows != 1 then + return -1 +endi +if $data00 != db then + return -1 +endi + +sql show databases; +if $rows != 1 then + return -1 +endi +if $data00 != db then + return -1 +endi +#tables +if $data02 != 7 then + return -1 +endi +#numofvgroups +sql show db.vgroups; +if $rows != 7 then + return -1 +endi +sql show db.stables; +if $rows != 1 then + return -1 +endi +sql show db.tables; +if $rows != 7 then + return -1 +endi + +print ============== step name +sql_error alter database db name d1 +sql_error alter database db name d2 +sql_error alter topic db name d1 +sql_error alter topic db name d2 + +print ============== step ntables +sql_error alter database db ntables -1 +sql_error alter database db ntables 0 +sql_error alter database db ntables 1 +sql_error alter database db ntables 10 +sql_error alter topic db ntables -1 +sql_error alter topic db ntables 0 +sql_error alter topic db ntables 1 +sql_error alter topic db ntables 10 + +print ============== step vgroups +sql_error alter database db vgroups -1 +sql_error alter database db vgroups 0 +sql_error alter database db vgroups 1 +sql_error alter database db vgroups 10 +sql_error alter topic db vgroups -1 +sql_error alter topic db vgroups 0 +sql_error alter topic db vgroups 1 +sql_error alter topic db vgroups 10 + +print ============== step replica +sql_error alter database db replica 2 +sql_error alter database db replica 3 +sql_error alter database db replica 0 +sql_error alter topic db replica 2 +sql_error alter topic db replica 3 +sql_error alter topic db replica 0 + +sql alter database db replica 1 +sql show databases +print replica $data4_db +if $data4_db != 1 then + return -1 +endi + +sql show topics +if $rows != 1 then + return -1 +endi + +print ============== step quorum +sql show databases +print quorum $data5_db +if $data5_db != 1 then + return -1 +endi + +sql_error alter topic db quorum 1 +sql alter database db quorum 1 +sql show databases +print quorum $data5_db +if $data5_db != 1 then + return -1 +endi + +sql_error alter database db quorum 2 +sql_error alter database db quorum 3 +sql_error alter topic db quorum 2 +sql_error alter topic db quorum 3 + +sql_error alter database db quorum 0 +sql_error alter database db quorum 4 +sql_error alter database db quorum 5 +sql_error alter database db quorum -1 +sql_error alter topic db quorum 0 +sql_error alter topic db quorum 4 +sql_error alter topic db quorum 5 +sql_error alter topic db quorum -1 + +print ============== step days +sql_error alter database db days 0 +sql_error alter database db days 1 +sql_error alter database db days 2 +sql_error alter database db days 10 +sql_error alter database db days 50 +sql_error alter database db days 100 +sql_error alter topic db days 0 +sql_error alter topic db days 1 +sql_error alter topic db days 2 +sql_error alter topic db days 10 +sql_error alter topic db days 50 +sql_error alter topic db days 100 + +print ============== step keep +sql show databases +print keep $data7_db +if $data7_db != 20,20,20 then + return -1 +endi + +sql_error topic db keep 20 +sql alter database db keep 20 +sql show databases +print keep $data7_db +if $data7_db != 20,20,20 then + return -1 +endi + +sql_error topic db keep 30 +sql alter database db keep 30 +sql show databases +print keep $data7_db +if $data7_db != 30,30,30 then + return -1 +endi + +sql_error alter topic db keep 40 +sql alter database db keep 40 +sql show databases +print keep $data7_db +if $data7_db != 40,40,40 then + return -1 +endi + +sql alter database db keep 40 +sql alter database db keep 30 +sql alter database db keep 20 +sql_error alter database db keep 10.0 +sql_error alter database db keep 9 +sql_error alter database db keep 1 +sql_error alter database db keep 0 +sql_error alter database db keep -1 +sql_error alter database db keep 365001 + +sql_error alter topic db keep 40 +sql_error alter topic db keep 30 +sql_error alter topic db keep 20 +sql_error alter topic db keep 10 +sql_error alter topic db keep 9 +sql_error alter topic db keep 1 +sql_error alter topic db keep 0 +sql_error alter topic db keep -1 +sql_error alter topic db keep 365001 + +print ============== step cache +sql_error alter database db cache 60 +sql_error alter database db cache 50 +sql_error alter database db cache 20 +sql_error alter database db cache 3 +sql_error alter database db cache 129 +sql_error alter database db cache 300 +sql_error alter database db cache 0 +sql_error alter database db cache -1 + +sql_error alter topic db cache 60 +sql_error alter topic db cache 50 +sql_error alter topic db cache 20 +sql_error alter topic db cache 3 +sql_error alter topic db cache 129 +sql_error alter topic db cache 300 +sql_error alter topic db cache 0 +sql_error alter topic db cache -1 + +print ============== step blocks +sql show databases +print blocks $data9_db +if $data9_db != 4 then + return -1 +endi + +sql_error alter topic db blocks 10 +sql alter database db blocks 10 +sql show databases +print blocks $data9_db +if $data9_db != 10 then + return -1 +endi + +sql_error alter topic db blocks 20 +sql alter database db blocks 20 +sql show databases +print blocks $data9_db +if $data9_db != 20 then + return -1 +endi + +sql_error alter topic db blocks 20 +sql alter database db blocks 30 +sql show databases +print blocks $data9_db +if $data9_db != 30 then + return -1 +endi + +sql alter database db blocks 40 +sql alter database db blocks 30 +sql alter database db blocks 20 +sql alter database db blocks 10 +sql_error alter database db blocks 2 +sql_error alter database db blocks 1 +sql_error alter database db blocks 0 +sql_error alter database db blocks -1 +sql_error alter database db blocks 10001 + +sql_error alter topic db blocks 40 +sql_error alter topic db blocks 30 +sql_error alter topic db blocks 20 +sql_error alter topic db blocks 10 +sql_error alter topic db blocks 2 +sql_error alter topic db blocks 1 +sql_error alter topic db blocks 0 +sql_error alter topic db blocks -1 +sql_error alter topic db blocks 10001 + +print ============== step minrows +sql_error alter database db minrows 1 +sql_error alter database db minrows 100 +sql_error alter database db minrows 1000 + +sql_error alter topic db minrows 1 +sql_error alter topic db minrows 100 +sql_error alter topic db minrows 1000 + +print ============== step maxrows +sql_error alter database db maxrows 1 +sql_error alter database db maxrows 100 +sql_error alter database db maxrows 1000 + +sql_error alter topic db maxrows 1 +sql_error alter topic db maxrows 100 +sql_error alter topic db maxrows 1000 + +print ============== step wallevel +sql show databases +print wallevel $data12_db +if $data12_db != 1 then + return -1 +endi + +sql_error alter topic db wal 1 +sql_error alter database db wal 1 + +sql_error alter database db wal 1 +sql_error alter database db wal 2 +sql_error alter database db wal 1 +sql_error alter database db wal 2 +sql_error alter database db wal 0 +sql_error alter database db wal 3 +sql_error alter database db wal 4 +sql_error alter database db wal -1 +sql_error alter database db wal 1000 + +sql_error alter topic db wal 1 +sql_error alter topic db wal 2 +sql_error alter topic db wal 1 +sql_error alter topic db wal 2 +sql_error alter topic db wal 0 +sql_error alter topic db wal 3 +sql_error alter topic db wal 4 +sql_error alter topic db wal -1 +sql_error alter topic db wal 1000 + +print ============== step fsync +sql_error alter database db fsync 0 +sql_error alter database db fsync 1 +sql_error alter database db fsync 3600 +sql_error alter database db fsync 18000 +sql_error alter database db fsync 180000 +sql_error alter database db fsync 180001 +sql_error alter database db fsync -1 + +sql_error alter topic db fsync 0 +sql_error alter topic db fsync 1 +sql_error alter topic db fsync 3600 +sql_error alter topic db fsync 18000 +sql_error alter topic db fsync 180000 +sql_error alter topic db fsync 180001 +sql_error alter topic db fsync -1 + +print ============== step comp +sql show databases +print comp $data14_db +if $data14_db != 2 then + return -1 +endi + +sql_error alter topic db comp 1 +sql alter database db comp 1 +sql show databases +print comp $data14_db +if $data14_db != 1 then + return -1 +endi + +sql_error alter topic db comp 2 +sql alter database db comp 2 +sql show databases +print comp $data14_db +if $data14_db != 2 then + return -1 +endi + +sql_error alter topic db comp 0 +sql alter database db comp 0 +sql show databases +print comp $data14_db +if $data14_db != 0 then + return -1 +endi + +sql_error alter database db comp 3 +sql_error alter database db comp 4 +sql_error alter database db comp 5 +sql_error alter database db comp -1 + +sql_error alter topic db comp 3 +sql_error alter topic db comp 4 +sql_error alter topic db comp 5 +sql_error alter topic db comp -1 + +print ============== step precision +sql_error alter database db prec 'us' +sql_error alter topic db prec 'us' + +print ============== step status +sql_error alter database db status 'delete' +sql_error alter topic db status 'delete' + +print ============== step drop +sql drop database db +sql show topics; +if $rows != 0 then + return -1 +endi + +sql show databases; +if $rows != 0 then + return -1 +endi + +print ============== step db1 +sql create database d1 +sql_error alter database d1 partitions 2 +sql_error alter topic d1 partitions 2 + +sql show topics; +if $rows != 0 then + return -1 +endi + +sql show databases; +if $rows != 1 then + return -1 +endi + +sql drop database d1 +sql show topics; +if $rows != 0 then + return -1 +endi + +sql show databases; +if $rows != 0 then + return -1 +endi + +print ============== step db2 +sql create topic d1 +sql show topics; +if $rows != 1 then + return -1 +endi + +sql show databases; +if $rows != 1 then + return -1 +endi + +sql drop database d1 +sql show topics; +if $rows != 0 then + return -1 +endi + +sql show databases; +if $rows != 0 then + return -1 +endi + +print ============== step db3 +sql create topic d1 +sql show topics; +if $rows != 1 then + return -1 +endi + +sql show databases; +if $rows != 1 then + return -1 +endi + +sql alter topic d1 partitions 2 +sql show topics; +if $rows != 1 then + return -1 +endi + +sql show databases; +if $rows != 1 then + return -1 +endi + +sql drop database d1 +sql show topics; +if $rows != 0 then + return -1 +endi + +sql show databases; +if $rows != 0 then + return -1 +endi + +print ============== step partitions +sql create topic t1 partitions 5 + +sql_error alter database t1 partitions -1 +sql_error alter database t1 partitions 0 +sql_error alter database t1 partitions 1 +sql_error alter database t1 partitions 2 +sql_error alter database t1 partitions 3 +sql_error alter database t1 partitions 100 +sql_error alter database t1 partitions 1000 +sql_error alter database t1 partitions 10000 + +sql_error alter topic t1 partitions -1 +#sql_error alter topic t1 partitions 0 +sql_error alter database t1 partitions 10000 + +sql alter topic t1 partitions 1 +sql show topics; +if $rows != 1 then + return -1 +endi +if $data00 != t1 then + return -1 +endi +sql show databases; +if $rows != 1 then + return -1 +endi +if $data00 != t1 then + return -1 +endi +#tables +if $data02 != 1 then + return -1 +endi + +sql show t1.stables; +if $rows != 1 then + return -1 +endi +sql show t1.tables; +if $rows != 1 then + return -1 +endi + +sql alter topic t1 partitions 2 +sql show topics; +if $rows != 1 then + return -1 +endi +if $data00 != t1 then + return -1 +endi +sql show databases; +if $rows != 1 then + return -1 +endi +if $data00 != t1 then + return -1 +endi +#tables +if $data02 != 2 then + return -1 +endi + + +sql show t1.stables; +if $rows != 1 then + return -1 +endi +sql show t1.tables; +if $rows != 2 then + return -1 +endi + +sql alter topic t1 partitions 3 +sql show topics; +if $rows != 1 then + return -1 +endi +if $data00 != t1 then + return -1 +endi +sql show databases; +if $rows != 1 then + return -1 +endi +if $data00 != t1 then + return -1 +endi +#tables +if $data02 != 3 then + return -1 +endi + +sql show t1.stables; +if $rows != 1 then + return -1 +endi +sql show t1.tables; +if $rows != 3 then + return -1 +endi + +sql alter topic t1 partitions 10 +sql show topics; +if $rows != 1 then + return -1 +endi +if $data00 != t1 then + return -1 +endi +sql show databases; +if $rows != 1 then + return -1 +endi +if $data00 != t1 then + return -1 +endi +#tables +if $data02 != 10 then + return -1 +endi +#numofvgroups +sql show t1.vgroups; +if $rows != 10 then + return -1 +endi +sql show t1.stables; +if $rows != 1 then + return -1 +endi +sql show t1.tables; +if $rows != 10 then + return -1 +endi + +sql drop topic t1 + +print ============== create same name topic +sql create database d2 +sql create topic t2 + +sql_error create topic d2 +sql_error create topic if not exists d2 +sql_error create topic t2 +sql create topic if not exists t2 +sql_error create topic t2 partitions 5; +sql_error create topic t2 partitions 6; +sql_error create topic t2 partitions 3; + +sql_error alter topic t3 partitions 1 +sql_error alter topic d2 partitions 1 +#sql_error alter topic t2 partitions 0 +sql_error alter topic t2 partitions 10000 + +sql_error drop topic d2 +sql_error drop topic d3 +sql drop database d2 +sql drop database t2 + +print ============== create partitons 0 +sql create topic t2 partitions 0 +sql show t2.stables; +if $rows != 0 then + return -1 +endi +sql show t2.tables; +if $rows != 0 then + return -1 +endi + +sql drop topic t2 +sql_error drop topic abc +sql drop topic if exists abc; + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/db/topic2.sim b/tests/script/general/db/topic2.sim new file mode 100644 index 0000000000000000000000000000000000000000..f933f5eee4dd9d0ec4784ba1e5beec4ccfc9a029 --- /dev/null +++ b/tests/script/general/db/topic2.sim @@ -0,0 +1,321 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 + +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ==== step1 +sql create topic t1 partitions 2; +sql show t1.tables +if $rows != 2 then + return -1 +endi +sql show t1.vgroups +if $rows != 2 then + return -1 +endi + +sql insert into t1.p1 values(1, now, '1'); +sql insert into t1.p1 values(1, now, '2'); +sql insert into t1.p1 values(1, now, '3'); +sql insert into t1.p1 values(1, now, '4')(2, now, '5')(3, now, '6')(4, now, '7')(5, now, '8')(6, now, '9'); +sql insert into t1.p1 values(1, now, '10')(2, now, '11')(3, now, '12')(4, now, '13')(5, now, '14')(6, now, '15'); +sql insert into t1.p1 values(1, now, '16')(2, now,'17')(3, now,'18')(4, now,'19')(5, now,'20')(6, now,'21')(7, now,'22')(8, now,'23')(9, now,'24')(10, now,'25')(11, now,'26')(12, now,'27')(13, now,'28')(14, now,'29')(15, now,'30')(16, now,'31')(17, now,'32')(18, now,'33'); + +sql insert into t1.p2 values(1, now, '1'); +sql insert into t1.p2 values(1, now, '2'); +sql insert into t1.p2 values(1, now, '3'); +sql insert into t1.p2 values(1, now, '4')(2, now, '5')(3, now, '6')(4, now, '7')(5, now, '8')(6, now, '9'); +sql insert into t1.p2 values(1, now, '10')(2, now, '11')(3, now, '12')(4, now, '13')(5, now, '14')(6, now, '15'); +sql insert into t1.p2 values(1, now, '16')(2, now,'17')(3, now,'18')(4, now,'19')(5, now,'20')(6, now,'21')(7, now,'22')(8, now,'23')(9, now,'24')(10, now,'25')(11, now,'26')(12, now,'27')(13, now,'28')(14, now,'29')(15, now,'30')(16, now,'31')(17, now,'32')(18, now,'33'); + +sql_error insert into t1.p3 values(1, now, '1'); +sql_error insert into t1.p3 values(1, now, '2'); +sql_error insert into t1.p3 values(1, now, '3'); +sql_error insert into t1.p3 values(1, now, '4')(2, now, '5')(3, now, '6')(4, now, '7')(5, now, '8')(6, now, '9'); +sql_error insert into t1.p3 values(1, now, '10')(2, now, '11')(3, now, '12')(4, now, '13')(5, now, '14')(6, now, '15'); +sql_error insert into t1.p3 values(1, now, '16')(2, now,'17')(3, now,'18')(4, now,'19')(5, now,'20')(6, now,'21')(7, now,'22')(8, now,'23')(9, now,'24')(10, now,'25')(11, now,'26')(12, now,'27')(13, now,'28')(14, now,'29')(15, now,'30')(16, now,'31')(17, now,'32')(18, now,'33'); + +sql select * from t1.p1 order by off asc +if $rows != 33 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data12 != 2 then + return -1 +endi +if $data22 != 3 then + return -1 +endi + +sql select * from t1.p2 order by off asc +if $rows != 33 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data12 != 2 then + return -1 +endi +if $data22 != 3 then + return -1 +endi + +print ==== step2 +sql alter topic t1 partitions 4; +sql show t1.tables +if $rows != 4 then + return -1 +endi +sql show t1.vgroups +if $rows != 4 then + return -1 +endi + +sql insert into t1.p1 values(1, now, '1'); +sql insert into t1.p1 values(1, now, '2'); +sql insert into t1.p1 values(1, now, '3'); +sql insert into t1.p1 values(1, now, '4')(2, now, '5')(3, now, '6')(4, now, '7')(5, now, '8')(6, now, '9'); +sql insert into t1.p1 values(1, now, '10')(2, now, '11')(3, now, '12')(4, now, '13')(5, now, '14')(6, now, '15'); +sql insert into t1.p1 values(1, now, '16')(2, now,'17')(3, now,'18')(4, now,'19')(5, now,'20')(6, now,'21')(7, now,'22')(8, now,'23')(9, now,'24')(10, now,'25')(11, now,'26')(12, now,'27')(13, now,'28')(14, now,'29')(15, now,'30')(16, now,'31')(17, now,'32')(18, now,'33'); + +sql insert into t1.p2 values(1, now, '1'); +sql insert into t1.p2 values(1, now, '2'); +sql insert into t1.p2 values(1, now, '3'); +sql insert into t1.p2 values(1, now, '4')(2, now, '5')(3, now, '6')(4, now, '7')(5, now, '8')(6, now, '9'); +sql insert into t1.p2 values(1, now, '10')(2, now, '11')(3, now, '12')(4, now, '13')(5, now, '14')(6, now, '15'); +sql insert into t1.p2 values(1, now, '16')(2, now,'17')(3, now,'18')(4, now,'19')(5, now,'20')(6, now,'21')(7, now,'22')(8, now,'23')(9, now,'24')(10, now,'25')(11, now,'26')(12, now,'27')(13, now,'28')(14, now,'29')(15, now,'30')(16, now,'31')(17, now,'32')(18, now,'33'); + +sql insert into t1.p3 values(1, now, '1'); +sql insert into t1.p3 values(1, now, '2'); +sql insert into t1.p3 values(1, now, '3'); +sql insert into t1.p3 values(1, now, '4')(2, now, '5')(3, now, '6')(4, now, '7')(5, now, '8')(6, now, '9'); +sql insert into t1.p3 values(1, now, '10')(2, now, '11')(3, now, '12')(4, now, '13')(5, now, '14')(6, now, '15'); +sql insert into t1.p3 values(1, now, '16')(2, now,'17')(3, now,'18')(4, now,'19')(5, now,'20')(6, now,'21')(7, now,'22')(8, now,'23')(9, now,'24')(10, now,'25')(11, now,'26')(12, now,'27')(13, now,'28')(14, now,'29')(15, now,'30')(16, now,'31')(17, now,'32')(18, now,'33'); + +sql insert into t1.p4 values(1, now, '1'); +sql insert into t1.p4 values(1, now, '2'); +sql insert into t1.p4 values(1, now, '3'); +sql insert into t1.p4 values(1, now, '4')(2, now, '5')(3, now, '6')(4, now, '7')(5, now, '8')(6, now, '9'); +sql insert into t1.p4 values(1, now, '10')(2, now, '11')(3, now, '12')(4, now, '13')(5, now, '14')(6, now, '15'); +sql insert into t1.p4 values(1, now, '16')(2, now,'17')(3, now,'18')(4, now,'19')(5, now,'20')(6, now,'21')(7, now,'22')(8, now,'23')(9, now,'24')(10, now,'25')(11, now,'26')(12, now,'27')(13, now,'28')(14, now,'29')(15, now,'30')(16, now,'31')(17, now,'32')(18, now,'33'); + +sql_error insert into t1.p5 values(1, now, '1'); +sql_error insert into t1.p5 values(1, now, '2'); +sql_error insert into t1.p5 values(1, now, '3'); +sql_error insert into t1.p5 values(1, now, '4')(2, now, '5')(3, now, '6')(4, now, '7')(5, now, '8')(6, now, '9'); +sql_error insert into t1.p5 values(1, now, '10')(2, now, '11')(3, now, '12')(4, now, '13')(5, now, '14')(6, now, '15'); +sql_error insert into t1.p5 values(1, now, '16')(2, now,'17')(3, now,'18')(4, now,'19')(5, now,'20')(6, now,'21')(7, now,'22')(8, now,'23')(9, now,'24')(10, now,'25')(11, now,'26')(12, now,'27')(13, now,'28')(14, now,'29')(15, now,'30')(16, now,'31')(17, now,'32')(18, now,'33'); + +sql select * from t1.p1 order by off asc +if $rows != 66 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data12 != 2 then + return -1 +endi +if $data22 != 3 then + return -1 +endi + +sql select * from t1.p2 order by off asc +if $rows != 66 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data12 != 2 then + return -1 +endi +if $data22 != 3 then + return -1 +endi + +sql select * from t1.p3 order by off asc +if $rows != 33 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data12 != 2 then + return -1 +endi +if $data22 != 3 then + return -1 +endi + +sql select * from t1.p4 order by off asc +if $rows != 33 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data12 != 2 then + return -1 +endi +if $data22 != 3 then + return -1 +endi + +print ==== step3 +sql alter topic t1 partitions 1; +sql show t1.tables +if $rows != 1 then + return -1 +endi +sql show t1.vgroups +if $rows != 1 then + return -1 +endi + +sql insert into t1.p1 values(1, now, '1'); +sql insert into t1.p1 values(1, now, '2'); +sql insert into t1.p1 values(1, now, '3'); +sql insert into t1.p1 values(1, now, '4')(2, now, '5')(3, now, '6')(4, now, '7')(5, now, '8')(6, now, '9'); +sql insert into t1.p1 values(1, now, '10')(2, now, '11')(3, now, '12')(4, now, '13')(5, now, '14')(6, now, '15'); +sql insert into t1.p1 values(1, now, '16')(2, now,'17')(3, now,'18')(4, now,'19')(5, now,'20')(6, now,'21')(7, now,'22')(8, now,'23')(9, now,'24')(10, now,'25')(11, now,'26')(12, now,'27')(13, now,'28')(14, now,'29')(15, now,'30')(16, now,'31')(17, now,'32')(18, now,'33'); + +sql_error insert into t1.p2 values(1, now, '1'); +sql_error insert into t1.p2 values(1, now, '2'); +sql_error insert into t1.p2 values(1, now, '3'); +sql_error insert into t1.p2 values(1, now, '4')(2, now, '5')(3, now, '6')(4, now, '7')(5, now, '8')(6, now, '9'); +sql_error insert into t1.p2 values(1, now, '10')(2, now, '11')(3, now, '12')(4, now, '13')(5, now, '14')(6, now, '15'); +sql_error insert into t1.p2 values(1, now, '16')(2, now,'17')(3, now,'18')(4, now,'19')(5, now,'20')(6, now,'21')(7, now,'22')(8, now,'23')(9, now,'24')(10, now,'25')(11, now,'26')(12, now,'27')(13, now,'28')(14, now,'29')(15, now,'30')(16, now,'31')(17, now,'32')(18, now,'33'); + +sql_error insert into t1.p3 values(1, now, '1'); +sql_error insert into t1.p3 values(1, now, '2'); +sql_error insert into t1.p3 values(1, now, '3'); +sql_error insert into t1.p3 values(1, now, '4')(2, now, '5')(3, now, '6')(4, now, '7')(5, now, '8')(6, now, '9'); +sql_error insert into t1.p3 values(1, now, '10')(2, now, '11')(3, now, '12')(4, now, '13')(5, now, '14')(6, now, '15'); +sql_error insert into t1.p3 values(1, now, '16')(2, now,'17')(3, now,'18')(4, now,'19')(5, now,'20')(6, now,'21')(7, now,'22')(8, now,'23')(9, now,'24')(10, now,'25')(11, now,'26')(12, now,'27')(13, now,'28')(14, now,'29')(15, now,'30')(16, now,'31')(17, now,'32')(18, now,'33'); + +sql_error insert into t1.p4 values(1, now, '1'); +sql_error insert into t1.p4 values(1, now, '2'); +sql_error insert into t1.p4 values(1, now, '3'); +sql_error insert into t1.p4 values(1, now, '4')(2, now, '5')(3, now, '6')(4, now, '7')(5, now, '8')(6, now, '9'); +sql_error insert into t1.p4 values(1, now, '10')(2, now, '11')(3, now, '12')(4, now, '13')(5, now, '14')(6, now, '15'); +sql_error insert into t1.p4 values(1, now, '16')(2, now,'17')(3, now,'18')(4, now,'19')(5, now,'20')(6, now,'21')(7, now,'22')(8, now,'23')(9, now,'24')(10, now,'25')(11, now,'26')(12, now,'27')(13, now,'28')(14, now,'29')(15, now,'30')(16, now,'31')(17, now,'32')(18, now,'33'); + +sql_error insert into t1.p5 values(1, now, '1'); +sql_error insert into t1.p5 values(1, now, '2'); +sql_error insert into t1.p5 values(1, now, '3'); +sql_error insert into t1.p5 values(1, now, '4')(2, now, '5')(3, now, '6')(4, now, '7')(5, now, '8')(6, now, '9'); +sql_error insert into t1.p5 values(1, now, '10')(2, now, '11')(3, now, '12')(4, now, '13')(5, now, '14')(6, now, '15'); +sql_error insert into t1.p5 values(1, now, '16')(2, now,'17')(3, now,'18')(4, now,'19')(5, now,'20')(6, now,'21')(7, now,'22')(8, now,'23')(9, now,'24')(10, now,'25')(11, now,'26')(12, now,'27')(13, now,'28')(14, now,'29')(15, now,'30')(16, now,'31')(17, now,'32')(18, now,'33'); + +sql select * from t1.p1 order by off asc +if $rows != 99 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data12 != 2 then + return -1 +endi +if $data22 != 3 then + return -1 +endi + +sql_error select * from t1.p2 order by off asc +sql_error select * from t1.p3 order by off asc +sql_error select * from t1.p4 order by off asc + +print ==== step4 +sql alter topic t1 partitions 3; +sql show t1.tables +if $rows != 3 then + return -1 +endi +sql show t1.vgroups +if $rows != 3 then + return -1 +endi + +sql insert into t1.p1 values(1, now, '1'); +sql insert into t1.p1 values(1, now, '2'); +sql insert into t1.p1 values(1, now, '3'); +sql insert into t1.p1 values(1, now, '4')(2, now, '5')(3, now, '6')(4, now, '7')(5, now, '8')(6, now, '9'); +sql insert into t1.p1 values(1, now, '10')(2, now, '11')(3, now, '12')(4, now, '13')(5, now, '14')(6, now, '15'); +sql insert into t1.p1 values(1, now, '16')(2, now,'17')(3, now,'18')(4, now,'19')(5, now,'20')(6, now,'21')(7, now,'22')(8, now,'23')(9, now,'24')(10, now,'25')(11, now,'26')(12, now,'27')(13, now,'28')(14, now,'29')(15, now,'30')(16, now,'31')(17, now,'32')(18, now,'33'); + +sql insert into t1.p2 values(1, now, '1'); +sql insert into t1.p2 values(1, now, '2'); +sql insert into t1.p2 values(1, now, '3'); +sql insert into t1.p2 values(1, now, '4')(2, now, '5')(3, now, '6')(4, now, '7')(5, now, '8')(6, now, '9'); +sql insert into t1.p2 values(1, now, '10')(2, now, '11')(3, now, '12')(4, now, '13')(5, now, '14')(6, now, '15'); +sql insert into t1.p2 values(1, now, '16')(2, now,'17')(3, now,'18')(4, now,'19')(5, now,'20')(6, now,'21')(7, now,'22')(8, now,'23')(9, now,'24')(10, now,'25')(11, now,'26')(12, now,'27')(13, now,'28')(14, now,'29')(15, now,'30')(16, now,'31')(17, now,'32')(18, now,'33'); + +sql insert into t1.p3 values(1, now, '1'); +sql insert into t1.p3 values(1, now, '2'); +sql insert into t1.p3 values(1, now, '3'); +sql insert into t1.p3 values(1, now, '4')(2, now, '5')(3, now, '6')(4, now, '7')(5, now, '8')(6, now, '9'); +sql insert into t1.p3 values(1, now, '10')(2, now, '11')(3, now, '12')(4, now, '13')(5, now, '14')(6, now, '15'); +sql insert into t1.p3 values(1, now, '16')(2, now,'17')(3, now,'18')(4, now,'19')(5, now,'20')(6, now,'21')(7, now,'22')(8, now,'23')(9, now,'24')(10, now,'25')(11, now,'26')(12, now,'27')(13, now,'28')(14, now,'29')(15, now,'30')(16, now,'31')(17, now,'32')(18, now,'33'); + +sql_error insert into t1.p4 values(1, now, '1'); +sql_error insert into t1.p5 values(1, now, '1'); +sql_error insert into t1.p6 values(1, now, '1'); +sql_error select * from t1.p4 order by off asc +sql_error select * from t1.p5 order by off asc +sql_error select * from t1.p6 order by off asc + +sql select * from t1.p1 order by off asc +if $rows != 132 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data12 != 2 then + return -1 +endi +if $data22 != 3 then + return -1 +endi + +sql select * from t1.p2 order by off asc +if $rows != 33 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data12 != 2 then + return -1 +endi +if $data22 != 3 then + return -1 +endi + +sql select * from t1.p3 order by off asc +if $rows != 33 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data12 != 2 then + return -1 +endi +if $data22 != 3 then + return -1 +endi + +sql select * from t1.ps order by off asc +if $rows != 198 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/db/vnodes.sim b/tests/script/general/db/vnodes.sim new file mode 100644 index 0000000000000000000000000000000000000000..96f68f16322a678ad6a6002a7f4fa6b092254616 --- /dev/null +++ b/tests/script/general/db/vnodes.sim @@ -0,0 +1,47 @@ +system sh/stop_dnodes.sh + +$totalVnodes = 10 +$maxTables = 4 +$totalRows = $totalVnodes * $maxTables + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v $maxTables +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v $totalVnodes +system sh/cfg.sh -n dnode1 -c maxVnodeConnections -v 100000 +system sh/cfg.sh -n dnode1 -c maxMeterConnections -v 100000 +system sh/cfg.sh -n dnode1 -c maxShellConns -v 100000 +system sh/cfg.sh -n dnode1 -c maxMgmtConnections -v 100000 + +print ========== prepare data +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect +sql create database db blocks 3 cache 1 +sql use db + +print ========== step1 +sql create table mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$x = 0 +while $x < $totalRows + $tb = t . $x + sql create table $tb using mt tags( $x ) + sql insert into $tb values (now, $x ) + $x = $x + 1 +endw + +print ========== step2 +sql select * from mt +print $rows +print $totalRows +if $rows != $totalRows then + return -1 +endi + +sql select count(*) from mt +if $data00 != $totalRows then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/field/2.sim b/tests/script/general/field/2.sim new file mode 100644 index 0000000000000000000000000000000000000000..cc6889fd75441c9fa4913f8219ebc1b50710b0cb --- /dev/null +++ b/tests/script/general/field/2.sim @@ -0,0 +1,298 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect +print ======================== dnode1 start + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol2 bool, tbcol int) TAGS(tgcol bool, tgcol2 int) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 + $ms , 0, 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 + $ms , 1, 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tbcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +# sql select * from $mt where ts > 1626739440001 and tbcol = 1 +sql select * from $mt where ts > 1626739440001 and tbcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts >= 1626739440001 and ts < 1626739500001 and tbcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts >= 1626739440001 and tbcol <> 0 and ts < 1626739500001 +if $rows != 5 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > 1626739440001 and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts >= 1626739440001 and ts < 1626739500001 and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts >= 1626739440001 and tbcol2 <> 0 and ts < 1626739500001 +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select * from $mt where ts > 1626739440001 and tbcol2 = 1 and tbcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol2 <> 1 and tbcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol2 = 0 and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol2 <> 0 and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol2 = 0 and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol2 <> 0 and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts >= 1626739440001 and ts < 1626739500001 and tbcol2 <> 0 and tbcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts >= 1626739440001 and tbcol2 <> 0 and ts < 1626739500001 and ts < 1626739500001 and tbcol <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol2 = 1 + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts <= 1626739440001 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol2 = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 and tbcol2 = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts <= 1626739440001 and tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol2 = 1 interval(1d) group by tgcol order by tgcol desc +print $db +print select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol2 = 1 interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/field/3.sim b/tests/script/general/field/3.sim new file mode 100644 index 0000000000000000000000000000000000000000..cb3c6621ac3723b09fba489d894657a457e12af1 --- /dev/null +++ b/tests/script/general/field/3.sim @@ -0,0 +1,521 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect +print ======================== dnode1 start + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol1 smallint, tbcol2 int, tbcol3 float) TAGS(tgcol1 smallint, tgcol2 int, tgcol3 float) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 + $ms , 0, 0, 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 + $ms , 1, 1, 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts <= 1626739440001 +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = 1626739440001 +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts >= 1626739440001 and ts < 1626739500001 +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tbcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tbcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where tbcol3 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step6 +sql select * from $mt where ts > 1626739440001 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts >= 1626739440001 and ts < 1626739500001 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts >= 1626739440001 and tbcol1 <> 0 and ts < 1626739500001 +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > 1626739440001 and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts >= 1626739440001 and ts < 1626739500001 and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts >= 1626739440001 and tbcol2 <> 0 and ts < 1626739500001 +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select * from $mt where ts > 1626739440001 and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts >= 1626739440001 and ts < 1626739500001 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts >= 1626739440001 and tbcol3 <> 0 and ts < 1626739500001 +if $rows != 5 then + return -1 +endi + +print =============== step9 +sql select * from $mt where ts > 1626739440001 and tbcol2 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol2 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol2 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol2 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol2 <> 0 and ts < 1626739500001 and ts < 1626739500001 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step10 +sql select * from $mt where ts > 1626739440001 and tbcol3 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol3 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol3 <> 0 and ts < 1626739500001 and ts < 1626739500001 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step11 +sql select * from $mt where ts > 1626739440001 and tbcol3 = 1 and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol3 <> 1 and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol3 = 0 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol3 = 0 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts >= 1626739440001 and ts < 1626739500001 and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts >= 1626739440001 and tbcol3 <> 0 and ts < 1626739500001 and ts < 1626739500001 and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step12 +sql select * from $mt where ts > 1626739440001 and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol1 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts >= 1626739440001 and ts < 1626739500001 and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts >= 1626739440001 and tbcol1 <> 0 and ts < 1626739500001 and ts < 1626739500001 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step13 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step14 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step15 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts <= 1626739440001 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step16 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step17 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step18 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 and tbcol2 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step19 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol1 order by tgcol1 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol2 order by tgcol2 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol3 order by tgcol3 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/field/4.sim b/tests/script/general/field/4.sim new file mode 100644 index 0000000000000000000000000000000000000000..2d893da777bea8260a333a957cf6f904b95eb6d0 --- /dev/null +++ b/tests/script/general/field/4.sim @@ -0,0 +1,711 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect +print ======================== dnode1 start + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol1 smallint, tbcol2 bigint, tbcol3 float, tbcol4 double) TAGS(tgcol1 smallint, tgcol2 bigint, tgcol3 float, tgcol4 double) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0, 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 + $ms , 0, 0, 0, 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1, 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 + $ms , 1, 1, 1, 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < 1626739440001 +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = 1626739440001 +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tbcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tbcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where tbcol3 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step6 +sql select * from $mt where tbcol4 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > 1626739440001 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol1 <> 0 and ts < 1626739500001 +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select * from $mt where ts > 1626739440001 and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol2 <> 0 and ts < 1626739500001 +if $rows != 5 then + return -1 +endi + +print =============== step9 +sql select * from $mt where ts > 1626739440001 and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol3 <> 0 and ts < 1626739500001 +if $rows != 5 then + return -1 +endi + +print =============== step10 +sql select * from $mt where ts > 1626739440001 and tbcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol4 <> 0 and ts < 1626739500001 +if $rows != 5 then + return -1 +endi + +print =============== step11 +sql select * from $mt where ts > 1626739440001 and tbcol2 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol2 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol2 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol2 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol2 <> 0 and ts < 1626739500001 and ts < 1626739500001 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step12 +sql select * from $mt where ts > 1626739440001 and tbcol3 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol3 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol3 <> 0 and ts < 1626739500001 and ts < 1626739500001 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step13 +sql select * from $mt where ts > 1626739440001 and tbcol3 = 1 and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol3 <> 1 and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol3 = 0 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol3 = 0 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol3 <> 0 and ts < 1626739500001 and ts < 1626739500001 and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step14 +sql select * from $mt where ts > 1626739440001 and tbcol3 = 1 and tbcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol3 <> 1 and tbcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol3 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol3 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol3 <> 0 and ts < 1626739500001 and ts < 1626739500001 and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step15 +sql select * from $mt where ts > 1626739440001 and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol1 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol1 <> 0 and ts < 1626739500001 and ts < 1626739500001 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step16 +sql select * from $mt where ts > 1626739440001 and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol4 <> 0 and ts < 1626739500001 and ts < 1626739500001 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step17 +sql select * from $mt where ts > 1626739440001 and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol4 <> 0 and ts < 1626739500001 and ts < 1626739500001 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step18 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step19 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step20 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step21 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step22 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step23 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 and tbcol2 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step24 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol1 order by tgcol1 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol2 order by tgcol2 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol3 order by tgcol3 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 interval(1d) group by tgcol4 order by tgcol4 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/field/5.sim b/tests/script/general/field/5.sim new file mode 100644 index 0000000000000000000000000000000000000000..e1421bdb4f9e25b37deeafe699feb1ce8c0f6c0a --- /dev/null +++ b/tests/script/general/field/5.sim @@ -0,0 +1,834 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect +print ======================== dnode1 start + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol1 tinyint, tbcol2 int, tbcol3 bigint, tbcol4 double, tbcol5 smallint) TAGS(tgcol1 tinyint, tgcol2 int, tgcol3 bigint, tgcol4 double, tgcol5 smallint) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0, 0, 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 + $ms , 0, 0, 0, 0, 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1, 1, 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 + $ms , 1, 1, 1, 1, 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < 1626739440001 +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = 1626739440001 +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tbcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tbcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where tbcol3 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step6 +sql select * from $mt where tbcol4 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step7 +sql select * from $mt where tbcol5 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol5 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol5 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol5 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step8 +sql select * from $mt where ts > 1626739440001 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol1 <> 0 and ts < 1626739500001 +if $rows != 5 then + return -1 +endi + +print =============== step9 +sql select * from $mt where ts > 1626739440001 and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol2 <> 0 and ts < 1626739500001 +if $rows != 5 then + return -1 +endi + +print =============== step10 +sql select * from $mt where ts > 1626739440001 and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol3 <> 0 and ts < 1626739500001 +if $rows != 5 then + return -1 +endi + +print =============== step11 +sql select * from $mt where ts > 1626739440001 and tbcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol4 <> 0 and ts < 1626739500001 +if $rows != 5 then + return -1 +endi + +print =============== step12 +sql select * from $mt where ts > 1626739440001 and tbcol5 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol5 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol5 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol5 <> 0 and ts < 1626739500001 +if $rows != 5 then + return -1 +endi + +print =============== step13 +sql select * from $mt where ts > 1626739440001 and tbcol2 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol2 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol2 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol2 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol2 <> 0 and ts < 1626739500001 and ts < 1626739500001 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step14 +sql select * from $mt where ts > 1626739440001 and tbcol3 = 1 and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol3 <> 1 and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol3 = 0 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol3 = 0 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol3 <> 0 and ts < 1626739500001 and ts < 1626739500001 and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step15 +sql select * from $mt where ts > 1626739440001 and tbcol3 = 1 and tbcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol3 <> 1 and tbcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol3 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol3 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol3 <> 0 and ts < 1626739500001 and ts < 1626739500001 and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step16 +sql select * from $mt where ts > 1626739440001 and tbcol5 = 1 and tbcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol5 <> 1 and tbcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol5 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol5 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol5 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol5 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol5 <> 0 and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol5 <> 0 and ts < 1626739500001 and ts < 1626739500001 and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step17 +sql select * from $mt where ts > 1626739440001 and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol1 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol1 <> 0 and ts < 1626739500001 and ts < 1626739500001 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step18 +sql select * from $mt where ts > 1626739440001 and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol4 <> 0 and ts < 1626739500001 and ts < 1626739500001 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step19 +sql select * from $mt where ts > 1626739440001 and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol4 <> 0 and ts < 1626739500001 and ts < 1626739500001 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step20 +sql select * from $mt where ts > 1626739440001 and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol1 = 1 and tbcol5 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 and tbcol1 <> 1 and tbcol5 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 and tbcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 and tbcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol4 <> 0 and ts < 1626739500001 and ts < 1626739500001 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step21 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step22 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step23 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step24 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol5 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step25 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step26 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 and tbcol2 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step27 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol1 order by tgcol1 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol2 order by tgcol2 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol3 order by tgcol3 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 interval(1d) group by tgcol4 order by tgcol4 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 interval(1d) group by tgcol5 order by tgcol5 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/field/6.sim b/tests/script/general/field/6.sim new file mode 100644 index 0000000000000000000000000000000000000000..27475d591fc6acaffb4e1f985f59d9a3c8778df5 --- /dev/null +++ b/tests/script/general/field/6.sim @@ -0,0 +1,989 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect +print ======================== dnode1 start + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol1 smallint, tbcol2 bigint, tbcol3 smallint, tbcol4 bigint, tbcol5 float, tbcol6 bool) TAGS(tgcol1 smallint, tgcol2 bigint, tgcol3 smallint, tgcol4 bigint, tgcol5 float, tgcol6 bool) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0, 0, 0, 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 + $ms , 0, 0, 0, 0, 0, 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1, 1, 1, 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 + $ms , 1, 1, 1, 1, 1, 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < 1626739440001 +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = 1626739440001 +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tbcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tbcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where tbcol3 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step6 +sql select * from $mt where tbcol4 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step7 +sql select * from $mt where tbcol5 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol5 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol5 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol5 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step8 +sql select * from $mt where tbcol6 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol6 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol6 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol6 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step9 +sql select * from $mt where ts > 1626739440001 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol1 <> 0 and ts < 1626739500001 +if $rows != 5 then + return -1 +endi + +print =============== step10 +sql select * from $mt where ts > 1626739440001 and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol2 <> 0 and ts < 1626739500001 +if $rows != 5 then + return -1 +endi + +print =============== step11 +sql select * from $mt where ts > 1626739440001 and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol3 <> 0 and ts < 1626739500001 +if $rows != 5 then + return -1 +endi + +print =============== step12 +sql select * from $mt where ts > 1626739440001 and tbcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol4 <> 0 and ts < 1626739500001 +if $rows != 5 then + return -1 +endi + +print =============== step13 +sql select * from $mt where ts > 1626739440001 and tbcol5 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol5 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol5 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol5 <> 0 and ts < 1626739500001 +if $rows != 5 then + return -1 +endi + +print =============== step14 +sql select * from $mt where ts > 1626739440001 and tbcol6 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol6 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol6 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol6 <> 0 and ts < 1626739500001 +if $rows != 5 then + return -1 +endi + +print =============== step15 +sql select * from $mt where ts > 1626739440001 and tbcol2 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol2 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol2 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol2 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol2 <> 0 and ts < 1626739500001 and ts < 1626739500001 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step16 +sql select * from $mt where ts > 1626739440001 and tbcol3 = 1 and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol3 <> 1 and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol3 = 0 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol3 = 0 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol3 <> 0 and ts < 1626739500001 and ts < 1626739500001 and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step17 +sql select * from $mt where ts > 1626739440001 and tbcol3 = 1 and tbcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol3 <> 1 and tbcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol3 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol3 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol3 <> 0 and ts < 1626739500001 and ts < 1626739500001 and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step18 +sql select * from $mt where ts > 1626739440001 and tbcol5 = 1 and tbcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol5 <> 1 and tbcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol5 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol5 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol5 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol5 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol5 <> 0 and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol5 <> 0 and ts < 1626739500001 and ts < 1626739500001 and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step19 +sql select * from $mt where ts > 1626739440001 and tbcol5 = 1 and tbcol6 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol5 <> 1 and tbcol6 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol5 = 0 and tbcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol5 <> 0 and tbcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol5 = 0 and tbcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol5 <> 0 and tbcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol5 <> 0 and tbcol6 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol5 <> 0 and ts < 1626739500001 and ts < 1626739500001 and tbcol6 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step20 +sql select * from $mt where ts > 1626739440001 and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol1 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol1 <> 0 and ts < 1626739500001 and ts < 1626739500001 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step21 +sql select * from $mt where ts > 1626739440001 and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol4 <> 0 and ts < 1626739500001 and ts < 1626739500001 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step22 +sql select * from $mt where ts > 1626739440001 and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol4 <> 0 and ts < 1626739500001 and ts < 1626739500001 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step23 +sql select * from $mt where ts > 1626739440001 and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol1 = 1 and tbcol5 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 and tbcol1 <> 1 and tbcol5 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 and tbcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 and tbcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol4 <> 0 and ts < 1626739500001 and ts < 1626739500001 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step24 +sql select * from $mt where ts > 1626739440001 and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol1 = 1 and tbcol5 = 1 and tbcol6 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 and tbcol1 <> 1 and tbcol5 <> 1 and tbcol6 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 and tbcol5 = 0 and tbcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 and tbcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 and tbcol5 = 0 and tbcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 and tbcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 and tbcol6 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol4 <> 0 and ts < 1626739500001 and ts < 1626739500001 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 and tbcol6 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step25 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step26 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 and tbcol6 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step27 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 and tbcol6 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step28 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol5 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol6 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step29 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 and tbcol6 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step30 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 and tbcol2 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < 1626739440001 and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 and tbcol6 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step31 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol1 order by tgcol1 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol2 order by tgcol2 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol3 order by tgcol3 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 interval(1d) group by tgcol4 order by tgcol4 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 interval(1d) group by tgcol5 order by tgcol5 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 and tbcol6 = 1 interval(1d) group by tgcol6 order by tgcol6 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/field/bigint.sim b/tests/script/general/field/bigint.sim new file mode 100644 index 0000000000000000000000000000000000000000..cfe8c561f0d852133267f7dd597f7796aee951f0 --- /dev/null +++ b/tests/script/general/field/bigint.sim @@ -0,0 +1,162 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect +print ======================== dnode1 start + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol bigint) TAGS(tgcol bigint) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 + $ms , 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 + $ms , 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step3 +sql select * from $mt where ts > 1626739440001 and tbcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol <> 0 and ts < 1626739500001 +if $rows != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 +if $data00 != 100 then + print expect 100, actual $data00 + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1626739440001 and tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 interval(1d) group by tgcol order by tgcol desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/field/binary.sim b/tests/script/general/field/binary.sim new file mode 100644 index 0000000000000000000000000000000000000000..821dbc9a82f7d8e6e21be419d6c28a7b67f1271d --- /dev/null +++ b/tests/script/general/field/binary.sim @@ -0,0 +1,77 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect +print ======================== dnode1 start + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol binary(10)) TAGS(tgcol binary(10)) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '0' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 + $ms , '0' ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '1' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 + $ms , '1' ) + $x = $x + 1 + endw + $i = $i + 1 +endw + + +print =============== step2 + +sql select * from $mt where tbcol = '0' +if $rows != 100 then + return -1 +endi + +sql select * from $mt where ts > 1626739440001 and tbcol = '1' +if $rows != 75 then + return -1 +endi + +print select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = '1' +sql_error select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = '1' group by tgcol +sql_error select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1626739440001 and tbcol = '1' group by tgcol +sql_error select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = '1' interval(1d) group by tgcol + +#can't filter binary fields + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/field/bool.sim b/tests/script/general/field/bool.sim new file mode 100644 index 0000000000000000000000000000000000000000..d94071b3282613a51c7580fc23f0bdc700cea03f --- /dev/null +++ b/tests/script/general/field/bool.sim @@ -0,0 +1,161 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect +print ======================== dnode1 start + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol bool) TAGS(tgcol bool) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 + $ms , 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 + $ms , 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = false +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> false +if $rows != 100 then + return -1 +endi + +print =============== step3 +sql select * from $mt where ts > 1626739440001 and tbcol = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol <> false and ts < 1626739500001 +if $rows != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = true +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = true group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1626739440001 and tbcol = true group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = true interval(1d) group by tgcol order by tgcol desc +print select count(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = true interval(1d) group by tgcol order by tgcol desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/field/double.sim b/tests/script/general/field/double.sim new file mode 100644 index 0000000000000000000000000000000000000000..0c9c23e3047466da264fd2ac3b2624ff22a5d0b0 --- /dev/null +++ b/tests/script/general/field/double.sim @@ -0,0 +1,160 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect +print ======================== dnode1 start + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol double) TAGS(tgcol double) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 + $ms , 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 + $ms , 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step3 +sql select * from $mt where ts > 1626739440001 and tbcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol <> 0 and ts < 1626739500001 +if $rows != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1626739440001 and tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 interval(1d) group by tgcol order by tgcol desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/field/float.sim b/tests/script/general/field/float.sim new file mode 100644 index 0000000000000000000000000000000000000000..00423c00b8515bafb7974604e1211c15868512d7 --- /dev/null +++ b/tests/script/general/field/float.sim @@ -0,0 +1,160 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect +print ======================== dnode1 start + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol float) TAGS(tgcol float) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 + $ms , 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 + $ms , 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step3 +sql select * from $mt where ts > 1626739440001 and tbcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol <> 0 and ts < 1626739500001 +if $rows != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1626739440001 and tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 interval(1d) group by tgcol order by tgcol desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/field/int.sim b/tests/script/general/field/int.sim new file mode 100644 index 0000000000000000000000000000000000000000..0e322e4f120d6eef933023467d1246a127780529 --- /dev/null +++ b/tests/script/general/field/int.sim @@ -0,0 +1,160 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect +print ======================== dnode1 start + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 + $ms , 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 + $ms , 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step3 +sql select * from $mt where ts > 1626739440001 and tbcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol <> 0 and ts < 1626739500001 +if $rows != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1626739440001 and tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 interval(1d) group by tgcol order by tgcol desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/field/single.sim b/tests/script/general/field/single.sim new file mode 100644 index 0000000000000000000000000000000000000000..3f6bf4309fac7ce45577094f3316c34edcd954c1 --- /dev/null +++ b/tests/script/general/field/single.sim @@ -0,0 +1,218 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect +print ======================== dnode1 start + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = st +$rowNum = 20 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql create database $db +sql use $db +sql create table $tb (ts timestamp, tbcol int) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 + $ms , $x ) + $x = $x + 1 + endw + +print =============== step2 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi + +sql select * from $tb where tbcol = 10 +if $rows != 1 then + return -1 +endi +if $data01 != 10 then + return -1 +endi + +sql select * from $tb where tbcol = 8 +if $rows != 1 then + return -1 +endi +if $data01 != 8 then + return -1 +endi + +sql select * from $tb where tbcol < 10 +if $rows != 10 then + return -1 +endi +if $data91 != 9 then + return -1 +endi + +sql select * from $tb where tbcol <= 10 +if $rows != 11 then + return -1 +endi +if $data81 != 8 then + return -1 +endi + +sql select * from $tb where tbcol > 10 +if $rows != 9 then + return -1 +endi +if $data81 != 19 then + return -1 +endi + +sql select * from $tb where tbcol > 10 order by ts asc +if $rows != 9 then + return -1 +endi +if $data01 != 11 then + return -1 +endi + +sql select * from $tb where tbcol < 10 and tbcol > 5 order by ts desc +if $rows != 4 then + return -1 +endi +if $data01 != 9 then + return -1 +endi +if $data31 != 6 then + return -1 +endi + +sql select * from $tb where tbcol < 10 and tbcol > 5 order by ts asc +if $rows != 4 then + return -1 +endi +if $data01 != 6 then + return -1 +endi +if $data31 != 9 then + return -1 +endi + +sql select * from $tb where tbcol > 10 and tbcol < 5 order by ts asc +if $rows != 0 then + return -1 +endi + +print =============== step3 +sql select * from $tb where ts < 1626739440001 +if $rows != 5 then + return -1 +endi + +sql select * from $tb where tbcol = 10 and ts < 1626739440001 +print select * from $tb where tbcol = 10 and ts < 1626739440001 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where tbcol = 4 and ts < 1626739440001 order by ts desc +if $rows != 1 then + return -1 +endi +if $data01 != 4 then + return -1 +endi + +sql select * from $tb where tbcol < 10 and ts < 1626739440001 order by ts desc +if $rows != 5 then + return -1 +endi +if $data01 != 4 then + return -1 +endi + +sql select * from $tb where tbcol < 10 and ts > 1626739440001 and ts < 1626739500001 order by ts desc +print $rows $data00 $data01 +if $rows != 1 then + return -1 +endi +if $data01 != 5 then + return -1 +endi + +print =============== step4 +sql select count(*) from $tb +if $data00 != $rowNum then + return -1 +endi + +sql select count(*) from $tb where tbcol = 10 +if $data00 != 1 then + return -1 +endi + +#sql select count(*) from $tb where tbcol = 8 or tbcol = 9 +#if $data00 != 2 then +# return -1 +#endi + +sql select count(*) from $tb where tbcol < 10 +if $data00 != 10 then + return -1 +endi + +sql select count(*) from $tb where tbcol <= 10 +if $data00 != 11 then + return -1 +endi + +sql select count(*) from $tb where tbcol < 10 and tbcol > 5 +if $data00 != 4 then + return -1 +endi + +sql select count(*) from $tb where tbcol < 10 and tbcol > 5 order by ts asc -x step4 +# return -1 +step4: + +print =============== step5 +sql select count(*) from $tb where ts < 1626739440001 +if $data00 != 5 then + return -1 +endi + +#sql select count(*) from $tb where tbcol = 10 and ts < 1626739440001 +#if $data00 != 0 then +# return -1 +#endi + +sql select count(*) from $tb where tbcol = 4 and ts < 1626739440001 +if $data00 != 1 then + return -1 +endi + +sql select count(*) from $tb where tbcol < 10 and ts < 1626739440001 +if $data00 != 5 then + return -1 +endi + +sql select count(*) from $tb where tbcol < 10 and ts > 1626739440001 and ts < 1626739500001 +if $data00 != 1 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/field/smallint.sim b/tests/script/general/field/smallint.sim new file mode 100644 index 0000000000000000000000000000000000000000..78b2b998cfa56f368b1480716dabe8be38a45b9a --- /dev/null +++ b/tests/script/general/field/smallint.sim @@ -0,0 +1,160 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect +print ======================== dnode1 start + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol smallint) TAGS(tgcol smallint) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 + $ms , 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 + $ms , 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step3 +sql select * from $mt where ts > 1626739440001 and tbcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol <> 0 and ts < 1626739500001 +if $rows != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1626739440001 and tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 interval(1d) group by tgcol order by tgcol desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/field/testSuite.sim b/tests/script/general/field/testSuite.sim new file mode 100644 index 0000000000000000000000000000000000000000..d12f0ebbd4df84f837104ab5078ba22b70a8034d --- /dev/null +++ b/tests/script/general/field/testSuite.sim @@ -0,0 +1,14 @@ +# run general/field/single.sim +run general/field/bool.sim +run general/field/smallint.sim +run general/field/tinyint.sim +run general/field/int.sim +run general/field/bigint.sim +run general/field/float.sim +run general/field/double.sim +# run general/field/binary.sim +# run general/field/2.sim +# run general/field/3.sim +# run general/field/4.sim +# run general/field/5.sim +# run general/field/6.sim diff --git a/tests/script/general/field/tinyint.sim b/tests/script/general/field/tinyint.sim new file mode 100644 index 0000000000000000000000000000000000000000..7e1a0c6e80022435a50c48398ee9098ce9ec43aa --- /dev/null +++ b/tests/script/general/field/tinyint.sim @@ -0,0 +1,161 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol tinyint) TAGS(tgcol tinyint) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 + $ms , 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 + $ms , 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step3 +sql select * from $mt where ts > 1626739440001 and tbcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol <> 0 and ts < 1626739500001 +if $rows != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1626739440001 and tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 interval(1d) group by tgcol order by tgcol desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/field/unsigined_bigint.sim b/tests/script/general/field/unsigined_bigint.sim new file mode 100644 index 0000000000000000000000000000000000000000..260128b5c2476911e8e1d809e63c7f89b4fd300a --- /dev/null +++ b/tests/script/general/field/unsigined_bigint.sim @@ -0,0 +1,166 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect +print ======================== dnode1 start + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol bigint unsigned) TAGS(tgcol bigint unsigned) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + sql create table $tb using $mt tags( -111 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 + $ms , 0 ) + $x = $x + 1 + sql_error insert into $tb values (1626739200000 + $ms , -10) + sql_error insert into $tb values (1626739200000 + $ms , -1000) + sql_error insert into $tb values (1626739200000 + $ms , -10000000) + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 + $ms , 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step3 +sql select * from $mt where ts > 1626739440001 and tbcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < 1626739440001 and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= 1626739440001 and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and ts < 1626739500001 and tbcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > 1626739440001 and tbcol <> 0 and ts < 1626739500001 +if $rows != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 +if $data00 != 100 then + print expect 100, actual $data00 + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1626739440001 and tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 interval(1d) group by tgcol order by tgcol desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/http/autocreate.sim b/tests/script/general/http/autocreate.sim new file mode 100644 index 0000000000000000000000000000000000000000..39af990b50d18fbcb6e7972d2adb67a1eb9900e3 --- /dev/null +++ b/tests/script/general/http/autocreate.sim @@ -0,0 +1,33 @@ +system sh/stop_dnodes.sh +sleep 2000 +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 0 +system sh/cfg.sh -n dnode1 -c http -v 1 +system sh/cfg.sh -n dnode1 -c httpEnableRecordSql -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ============================ dnode1 start + +print =============== step1 - prepare data +sql create database db +sql use db +sql create table if not exists db.win_cpu(ts timestamp,f_percent_dpc_time double,f_percent_idle_time double,f_percent_interrupt_time double,f_percent_privileged_time double,f_percent_processor_time double,f_percent_user_time double) tags(t_host binary(32),t_instance binary(32),t_objectname binary(32)); + +print =============== step2 - auto create + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'import into db.win_cpu_windows_1_processor using db.win_cpu tags('windows','1','Processor') values(1564641722000,0.000000,95.598305,0.000000,0.000000,0.000000,0.000000);' 127.0.0.1:7111/rest/sql +print curl 127.0.0.1:7111/rest/sql -----> $system_content +#if $system_content != @{"status":"succ","head":["ts","i"],"data":[["2017-12-25 21:28:41.022",1],["2017-12-25 21:28:42.022",2],["2017-12-25 21:28:43.022",3],["2017-12-25 21:28:44.022",4],["2017-12-25 21:28:45.022",5],["2017-12-25 21:28:46.022",6],["2017-12-25 21:28:47.022",7],["2017-12-25 21:28:48.022",8],["2017-12-25 21:28:49.022",9],["2017-12-25 21:28:50.022",10],["2017-12-25 21:28:51.022",11]],"rows":11}@ then +# return -1 +#endi + +sql select * from db.win_cpu_windows_1_processor +print rows: $rows +if $rows != 1 then + return -1 +endi + +#system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/http/bug.go b/tests/script/general/http/bug.go new file mode 100644 index 0000000000000000000000000000000000000000..61991f4d023dcf21bef7eda0b2bde43c5dd40eb7 --- /dev/null +++ b/tests/script/general/http/bug.go @@ -0,0 +1,329 @@ +package main + +import ( + "bytes" + "encoding/json" + "fmt" + "io/ioutil" + "math/rand" + "net/http" + "os" + "sync" + "sync/atomic" + "time" + "flag" +) + +var ( + token string + url string + config Config + request int64 + period int64 + errorNum int64 +) + +type Config struct { + HostIp string `json:"hostIp"` + ConnNum int `json:"connNum"` + InsertModel string `json:"insertModel"` + WaitTime int `json:"waitTime"` + TableDesc string `json:"tableDesc"` + TablePrefix string `json:"tablePrefix"` + TablePerConn int `json:"tablePerConn"` + TableCreate bool `json:"tableCreate"` + TableStart int `json:"tableStart"` + DbName string `json:"dbName"` + DbReplica int `json:"dbReplica"` + DbKeep int `json:"dbKeep"` + DbDays int `json:"dbDays"` + MetricsName string `json:"metricsName"` + TagNum int `json:"tagNum"` + DataNum int `json:"dataNum"` + DataBegin int64 `json:"dataBegin"` + DataInterval int `json:"dataInterval"` + DataBatch int `json:"dataBatch"` + DataInsert bool `json:"dataInsert"` + DataRandom bool `json:"dataRandom"` +} + +type TokenResult struct { + Status string `json:"status"` + Code int `json:"code"` + Desc string `json:"desc"` +} + +type JsonResult struct { + Status string `json:"status"` + Code int `json:"code"` +} + +func readFile(filename string) { + file, err := os.Open(filename) + if err != nil { + println("taos_cloud.json not found") + panic(err) + } + defer file.Close() + + dec := json.NewDecoder(file) + err = dec.Decode(&config) + if err != nil { + println("taos_cloud.json parse error") + panic(err) + } + + if config.TagNum <= 0 { + config.TagNum = 1 + } + request = 0 + period = 0 + errorNum = 0 + + fmt.Println("================config parameters======================") + fmt.Println("HostIp:", config.HostIp) + fmt.Println("connNum:", config.ConnNum) + fmt.Println("insertModel:", config.InsertModel) + fmt.Println("waitTime:", config.WaitTime) + fmt.Println("tableDesc:", config.TableDesc) + fmt.Println("tablePrefix:", config.TablePrefix) + fmt.Println("tablePerConn:", config.TablePerConn) + fmt.Println("tableCreate:", config.TableCreate) + fmt.Println("tableStart:", config.TableStart) + fmt.Println("dbName:", config.DbName) + fmt.Println("dbReplica:", config.DbReplica) + fmt.Println("dbKeep:", config.DbKeep) + fmt.Println("dbDays:", config.DbDays) + fmt.Println("metricsName:", config.MetricsName) + fmt.Println("tagNum:", config.TagNum) + fmt.Println("dataNum:", config.DataNum) + fmt.Println("dataBegin:", config.DataBegin) + fmt.Println("dataInterval:", config.DataInterval) + fmt.Println("dataBatch:", config.DataBatch) + fmt.Println("dataInsert:", config.DataInsert) + fmt.Println("dataRandom:", config.DataRandom) + + fmt.Println("================http token=============================") + token, err = getToken() + url = fmt.Sprintf("http://%s:%d/rest/sql", config.HostIp, 6020) + + fmt.Println("httpToken:", token) + fmt.Println("httpUrl:", url) + + if err != nil { + panic(err) + } +} + +func getToken() (string, error) { + resp, err := http.Get(fmt.Sprintf("http://%s:%d/rest/login/%s/%s", config.HostIp, 6020, "root", "taosdata")) + if err != nil { + return "", err + } + + defer resp.Body.Close() + + var tokenResult TokenResult + + data, err := ioutil.ReadAll(resp.Body) + + if err != nil { + return "", err + } + + err = json.Unmarshal(data, &tokenResult) + if err != nil { + return "", err + } + + if tokenResult.Status != "succ" { + fmt.Println("get http token failed") + fmt.Println(tokenResult) + return "", err + } + + return tokenResult.Desc, nil +} + +func exec(client *http.Client, sql string) { + for times := 0; times < 10; times++ { + + req, err1 := http.NewRequest("POST", url, bytes.NewReader([]byte(sql))) + if err1 != nil { + continue + } + req.Header.Add("Authorization", "Taosd "+token) + + begin := time.Now() + resp, err := client.Do(req) + + if err != nil { + continue + } + + data, err := ioutil.ReadAll(resp.Body) + if err != nil { + resp.Body.Close() + continue + } + + spend := (time.Since(begin).Nanoseconds()) + + var jsonResult JsonResult + err = json.Unmarshal(data, &jsonResult) + if err != nil { + resp.Body.Close() + continue + } + + if jsonResult.Status != "succ" { + resp.Body.Close() + continue + } + atomic.AddInt64(&request, 1) + if (request < 103) { + return + } + + atomic.AddInt64(&period, spend) + if request%5000 == 0 && request != 0 { + requestAvg := float64(period) / float64(1000000) / float64(request) + qps := float64(1000) / float64(requestAvg) * float64(config.ConnNum) + dps := qps * float64(config.DataBatch) + fmt.Println("====== req:", request, ", error:", errorNum, ", qps:", int64(qps), ", wait:", int64(requestAvg), "ms", ", data per second:", int64(dps)) + } + return + } + fmt.Println("xxxx>sql:", sql, ", retryTimes:", 10) + errorNum++ +} + +func insertTable(conn int) { + client := &http.Client{} + + tbStart := conn*config.TablePerConn + config.TableStart + tmStart := config.DataBegin + + + for j := 0; j < config.DataNum; j++ { + for i := 0; i < config.TablePerConn; i++ { + tmVal := int64(j)*int64(config.DataInterval) + tmStart + 1 + tbIndex := i + tbStart + + dataVal := j + if config.DataRandom { + dataVal = rand.Intn(1000) + } + + sql := fmt.Sprintf("import into %s.%s%d values(%d, %d)", config.DbName, config.TablePrefix, tbIndex, tmVal, dataVal) + exec(client, sql) + time.Sleep(time.Millisecond * time.Duration(10)) + } + } +} + +func insertLoop(conn int) { + client := &http.Client{} + + tbStart := conn*config.TablePerConn + config.TableStart + tmStart := config.DataBegin + + for j := 0; j < config.DataNum; j++ { + + for i := 0; i < config.TablePerConn; i++ { + tbIndex := i + tbStart + + tmVal := int64(j)*int64(config.DataInterval) + tmStart + + dataVal := j + if config.DataRandom { + dataVal = rand.Intn(1000) + } + + sql := fmt.Sprintf("insert into %s.%s%d values(%d, %d)", config.DbName, config.TablePrefix, tbIndex, tmVal, dataVal) + for k := 1; k < config.DataBatch; k++ { + tmVal := int64(j)*int64(config.DataInterval) + int64(k) + tmStart + + dataVal := j + k + if config.DataRandom { + dataVal = rand.Intn(1000) + } + sql += fmt.Sprintf("values(%d, %d)", tmVal, dataVal) + } + + j += (config.DataBatch - 1) + + exec(client, sql) + + if config.WaitTime != 0 { + time.Sleep(time.Millisecond * time.Duration(config.WaitTime)) + } + } + + } +} + +func insertTb(wg *sync.WaitGroup, conn int) { + defer wg.Done() + + if !config.DataInsert { + return + } + + if config.InsertModel == "insertTable" { + insertTable(conn) + } else { + insertLoop(conn) + } +} + +func selectData(wg *sync.WaitGroup, conn int) { + defer wg.Done() + + client := &http.Client{} + + + tbStart := conn*config.TablePerConn + config.TableStart + for j := 0; j < config.DataNum; j++ { + tbIndex := 0 + tbStart + sql := fmt.Sprintf("select max(i),min(i) from db.mt where tbname in ('%s%d'", config.TablePrefix, tbIndex) + for i := 1; i < 2000; i++ { + tbIndex := i + tbStart + sql += fmt.Sprintf(",'%s%d'", config.TablePrefix, tbIndex) + } + sql += ") group by orgno" + + //sql := fmt.Sprintf("select count(*) from db.mt") + //sql := fmt.Sprintf("select max(i),min(i) from db.mt", config.TablePrefix, tbIndex) + + exec(client, sql) + time.Sleep(time.Millisecond * time.Duration(10)) + } +} + +func main() { + filename := flag.String("config", "taos_cloud.json", "config file name") + + flag.Parse() + + readFile(*filename) + + fmt.Println("\n================http test start======================") + + var wg sync.WaitGroup + + fmt.Println("\n================select data ========================") + + + for i := 0; i < config.ConnNum; i++ { + wg.Add(1) + go insertTb(&wg, i) + } + for i := 0; i < config.ConnNum; i++ { + wg.Add(1) + go selectData(&wg, i) + } + wg.Wait() + + fmt.Println("\n================http test stop ======================") +} diff --git a/tests/script/general/http/chunked.sim b/tests/script/general/http/chunked.sim new file mode 100644 index 0000000000000000000000000000000000000000..c5855e5d2953ca36d95cd84a5590c47ef693d406 --- /dev/null +++ b/tests/script/general/http/chunked.sim @@ -0,0 +1,37 @@ +system sh/stop_dnodes.sh +sleep 2000 +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 0 +system sh/cfg.sh -n dnode1 -c http -v 1 +system sh/cfg.sh -n dnode1 -c maxSQLLength -v 340032 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ============================ dnode1 start + +print =============== step1 - prepare data +sql create database d1 +sql use d1 + +sql create table table_rest (ts timestamp, i int) +print sql length is 270KB +restful d1 table_rest 1591072800 10000 +restful d1 table_rest 1591172800 10000 +restful d1 table_rest 1591272800 10000 +restful d1 table_rest 1591372800 10000 +restful d1 table_rest 1591472800 10000 +restful d1 table_rest 1591572800 10000 +restful d1 table_rest 1591672800 10000 +restful d1 table_rest 1591772800 10000 +restful d1 table_rest 1591872800 10000 +restful d1 table_rest 1591972800 10000 + +sql select * from table_rest; +print rows: $rows +if $rows != 100000 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/http/grafana.sim b/tests/script/general/http/grafana.sim new file mode 100644 index 0000000000000000000000000000000000000000..b47edce28cb170a67fe119f76965eae704c4ff43 --- /dev/null +++ b/tests/script/general/http/grafana.sim @@ -0,0 +1,191 @@ +system sh/stop_dnodes.sh +sleep 2000 +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c http -v 1 +#system sh/cfg.sh -n dnode1 -c adminRowLimit -v 10 +system sh/cfg.sh -n dnode1 -c httpDebugFlag -v 135 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ============================ dnode1 start + +print =============== step1 - prepare data + +sql create database d1 +sql use d1 +sql create table table_gc (ts timestamp, db binary(10), tb binary(20), col binary(20)) +sql create table m1 (ts timestamp, v1 int, v2 float) +sql create table m2 (ts timestamp, v1 int, v2 float) + +sql insert into table_gc values('2017-12-25 21:28:41.022', 'd1', 'm1', 'v1') +sql insert into table_gc values('2017-12-25 21:28:42.022', 'd1', 'm1', 'v2') +sql insert into table_gc values('2017-12-25 21:28:43.022', 'd1', 'm2', 'v1') +sql insert into table_gc values('2017-12-25 21:28:44.022', 'd1', 'm2', 'v2') + +sql insert into m1 values(1514208523020, 1, 4.1) +sql insert into m1 values(1514208523021, 2, 5.1) +sql insert into m1 values(1514208523022, 3, 6.1) + +sql insert into m2 values(1514208523024, 3, 6.1) +sql insert into m2 values(1514208523025, 2, 5.1) +sql insert into m2 values(1514208523026, 1, 4.1) + +sql create table mt (ts timestamp, i int) tags(a int, b binary(10)) +sql create table t1 using mt tags (1, 'a') +sql create table t2 using mt tags (2, 'b') +sql create table t3 using mt tags (3, 'c') +sql insert into t1 values('2017-12-25 21:25:41', 1) +sql insert into t1 values('2017-12-25 21:26:41', 1) +sql insert into t1 values('2017-12-25 21:27:41', 1) +sql insert into t1 values('2017-12-25 21:28:41', 1) +sql insert into t1 values('2017-12-25 21:29:41', 1) +sql insert into t2 values('2017-12-25 21:25:41', 2) +sql insert into t2 values('2017-12-25 21:26:41', 2) +sql insert into t2 values('2017-12-25 21:27:41', 2) +sql insert into t2 values('2017-12-25 21:28:41', 2) +sql insert into t3 values('2017-12-25 21:25:41', 3) +sql insert into t3 values('2017-12-25 21:26:41', 3) +sql insert into t3 values('2017-12-25 21:27:41', 3) + +sql create table m3 (ts timestamp, col1 int, col2 float, txt binary(500)) +sql insert into m3 values(now, 1, 2.0, 'HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS') + +print =============== step2 - login + +system_content curl 127.0.0.1:7111/grafana/ +print 1-> $system_content +if $system_content != @{"status":"error","code":4357,"desc":"no auth info input"}@ then + return -1 +endi + +system_content curl 127.0.0.1:7111/grafana/xx +print 2-> $system_content +if $system_content != @{"status":"error","code":4357,"desc":"no auth info input"}@ then + return -1 +endi + +system_content curl 127.0.0.1:7111/grafana/login/xx/xx/ +print 3-> $system_content +if $system_content != @{"status":"error","code":849,"desc":"Invalid user"}@ then + return -1 +endi + +system_content curl 127.0.0.1:7111/grafana/root/1/123/1/1/3 +print 4-> $system_content +if $system_content != @{"status":"error","code":4357,"desc":"no auth info input"}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'show databases' 127.0.0.1:7111/grafana/login/1/root/1/ +print 5-> $system_content +if $system_content != @{"status":"error","code":849,"desc":"Invalid user"}@ then + return -1 +endi + +system_content curl -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ3d3cudGFvc2RhdGEuY29tIiwicGFzcyI6InRhb3NkYXRhIiwic3ViIjoicm9vdCJ9.xPv3b5odlR7YF8G_QWASjIRbMtA5v4ItToJ35fFgi' -d 'show databases' 127.0.0.1:7111/grafana/root/1/login +print 6-> $system_content +if $system_content != @{"status":"error","code":4387,"desc":"invalid format of Authorization"}@ then + return -1 +endi + +system_content curl -H 'Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ3d3cudGFvc2RhdGEuY29tIiwicGFzcyI6InRhb3NkYXRhIiwic3ViIjoicm9vdCJ9.xPv3b5odlR7YF8G_QWASjIRbMtA5v4ItToJ35fFgi' -d 'show databases' 127.0.0.1:7111/grafana/root/1/login +print 7-> $system_content +if $system_content != @{"status":"error","code":4387,"desc":"invalid format of Authorization"}@ then + return -1 +endi + +sleep 2000 +system_content curl 127.0.0.1:7111/grafana/login/root/taosdata +print 8-> $system_content +if $system_content != @{"status":"succ","code":0,"desc":"/KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04"}@ then + return -1 +endi + +print =============== step3 - heartbeat + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' 127.0.0.1:7111/grafana/d1/table_gc +print 9-> $system_content +if $system_content != @{"message":"Grafana server receive a quest from you!"}@ then + return -1 +endi + +print =============== step4 - search + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' 127.0.0.1:7111/grafana/heartbeat +print 10-> $system_content +if $system_content != @{"message":"Grafana server receive a quest from you!"}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' 127.0.0.1:7111/grafana/d1/table_invalid/search +print 11-> $system_content +if $system_content != @{"message":"Grafana server receive a quest from you!"}@ then + return -1 +endi + +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' 127.0.0.1:7111/grafana/d1/m1/search +print 12-> $system_content +if $system_content != @{"message":"Grafana server receive a quest from you!"}@ then + return -1 +endi + +print =============== step5 - query + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d '[{"refId":"A","alias":"taosd","sql":"select first(v1) from d1.m1 where ts > 1514208523020 and ts < 1514208523030 interval(1m)"},{"refId":"B","alias":"system","sql":"select first(v2) from d1.m1 where ts > 1514208523020 and ts < 1514208523030 interval(1m)"}]' 127.0.0.1:7111/grafana/query +print 13-> $system_content +if $system_content != @[{"refId":"A","target":"taosd","datapoints":[[2,1514208480000]]},{"refId":"B","target":"system","datapoints":[[5.10000,1514208480000]]}]@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d '[{"refId":"A","alias":"","sql":"select first(v1) from d1.m1 where ts > 1514208523020 and ts < 1514208523030 interval(1m)"},{"refId":"B","alias":"","sql":"select first(v2) from d1.m1 where ts > 1514208523020 and ts < 1514208523030 interval(1m)"}]' 127.0.0.1:7111/grafana/query +print 14-> $system_content +if $system_content != @[{"refId":"A","target":"A","datapoints":[[2,1514208480000]]},{"refId":"B","target":"B","datapoints":[[5.10000,1514208480000]]}]@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d '[{"refId":"A","alias":"","sql":"select count(v1) from d1.m1"},{"refId":"B","alias":"","sql":"select count(v2) from d1.m1"}]' 127.0.0.1:7111/grafana/query +print 15-> $system_content +if $system_content != @[{"refId":"A","target":"A","datapoints":[[3,"-"]]},{"refId":"B","target":"B","datapoints":[[3,"-"]]}]@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d '[{"refId":"A","alias":"","sql":"select count(v1) from d1.m1"},{"refId":"B","alias":"","sql":"select count(v2) from d1.m1"}]' 127.0.0.1:7111/grafana/query +print 15-> $system_content +if $system_content != @[{"refId":"A","target":"A","datapoints":[[3,"-"]]},{"refId":"B","target":"B","datapoints":[[3,"-"]]}]@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d '[{"refId":"A","alias":"","sql":"select count(i) from d1.mt group by a"},{"refId":"B","alias":"","sql":"select sum(i) from d1.mt group by b"}]' 127.0.0.1:7111/grafana/query +print 16-> $system_content +if $system_content != @[{"refId":"A","target":"{a:1,}","datapoints":[[5,"-"]]},{"refId":"A","target":"{a:2,}","datapoints":[[4,"-"]]},{"refId":"A","target":"{a:3,}","datapoints":[[3,"-"]]},{"refId":"B","target":"{b:a}","datapoints":[[5,"-"]]},{"refId":"B","target":"{b:b}","datapoints":[[8,"-"]]},{"refId":"B","target":"{b:c}","datapoints":[[9,"-"]]}]@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d '[{"refId":"A","alias":"count","sql":"select count(i) from d1.mt group by a"},{"refId":"B","alias":"sum-","sql":"select sum(i) from d1.mt group by b"}]' 127.0.0.1:7111/grafana/query +print 17-> $system_content +if $system_content != @[{"refId":"A","target":"count{a:1,}","datapoints":[[5,"-"]]},{"refId":"A","target":"count{a:2,}","datapoints":[[4,"-"]]},{"refId":"A","target":"count{a:3,}","datapoints":[[3,"-"]]},{"refId":"B","target":"sum-{b:a}","datapoints":[[5,"-"]]},{"refId":"B","target":"sum-{b:b}","datapoints":[[8,"-"]]},{"refId":"B","target":"sum-{b:c}","datapoints":[[9,"-"]]}]@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d '[{"refId":"A","alias":"count","sql":"select count(i) from d1.mt interval(1m) group by a "}]' 127.0.0.1:7111/grafana/query +print 18-> $system_content +if $system_content != @[{"refId":"A","target":"count{a:1,}","datapoints":[[1,1514208300000],[1,1514208360000],[1,1514208420000],[1,1514208480000],[1,1514208540000]]},{"refId":"A","target":"count{a:2,}","datapoints":[[1,1514208300000],[1,1514208360000],[1,1514208420000],[1,1514208480000]]},{"refId":"A","target":"count{a:3,}","datapoints":[[1,1514208300000],[1,1514208360000],[1,1514208420000]]}]@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d '[{"refId":"A","alias":"","sql":"select sum(v2), count(v1) from d1.m1"},{"refId":"B","alias":"","sql":"select count(v2), sum(v2) from d1.m1"}]' 127.0.0.1:7111/grafana/query +print 19-> $system_content +if $system_content != @[{"refId":"A","target":"{count(v1):3}","datapoints":[[15.299999714,"-"]]},{"refId":"B","target":"{sum(v2):15.299999714}","datapoints":[[3,"-"]]}]@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d '[{"refId":"A","alias":"taosd","sql":"select last(col1), last(col2), last(txt) from d1.m3 group by txt"}]' 127.0.0.1:7111/grafana/query +print 20-> $system_content +if $system_content != @[{"refId":"A","target":"taosd{last(col2):2.00000, last(txt):HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS HELLO TAOS}","datapoints":[[1,"-"]]}]@ then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/http/grafana_bug.sim b/tests/script/general/http/grafana_bug.sim new file mode 100644 index 0000000000000000000000000000000000000000..ed184e17c6deceaa118c512a8ccf5f5b4df3ffbc --- /dev/null +++ b/tests/script/general/http/grafana_bug.sim @@ -0,0 +1,271 @@ +system sh/stop_dnodes.sh +sleep 2000 +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c http -v 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +#system sh/cfg.sh -n dnode1 -c adminRowLimit -v 10 +system sh/cfg.sh -n dnode1 -c httpDebugFlag -v 135 +system sh/exec.sh -n dnode1 -s start + +sql connect +sleep 2000 + +print ============================ dnode1 start + +print =============== step0 - prepare data + +sql create database db +sql use db + +sql create table tb (ts timestamp, val int, val1 int, val2 int) +sql create table tb2 (ts timestamp, val int, val1 int, val2 int) +sql create table t2 (ts timestamp, val int) +sql create table tb3 (ts timestamp, val int, val1 int, val2 int) + +sql insert into tb values('2020-01-01 00:00:00.000', 1, 11, 21) +sql insert into tb values('2020-01-02 00:00:00.000', 1, 12, 22) +sql insert into tb values('2020-01-03 00:00:00.000', 2, 13, 23) +sql insert into tb values('2020-01-04 00:00:00.000', 2, 14, 24) + + +sql insert into tb2 values('2020-01-01 00:00:00.000', 21, 211, 221) +sql insert into tb2 values('2020-01-02 00:00:00.000', 21, 212, 222) +sql insert into tb2 values('2020-01-03 00:00:00.000', 22, 213, 223) +sql insert into tb2 values('2020-01-04 00:00:00.000', 22, 214, 224) + + +sql insert into tb3 values('2020-01-01 00:00:00.000', NULL, NULL, NULL) +sql insert into tb3 values('2020-01-02 00:00:00.000', NULL, NULL, NULL) +print =============== step1 - one query, 1 column, with timestamp + +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select ts from db.tb where ts >= 1577980800000 "} ]' 127.0.0.1:7111/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"A","target":"A","datapoints":[[null,1577980800000],[null,1578067200000]]}]@ then + return -1 +endi + +print =============== step2 - one query, 2 column, with timestamp + +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select ts,val from db.tb where ts >= 1577980800000 "} ]' 127.0.0.1:7111/grafana/query +print step2-> $system_content +if $system_content != @[{"refId":"A","target":"A","datapoints":[[2,1577980800000],[2,1578067200000]]}]@ then + return -1 +endi + +print =============== step3 - one query, 3 column, with timestamp + +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select ts,val,val1 from db.tb where ts >= 1577980800000 "} ]' 127.0.0.1:7111/grafana/query +print step3.1-> $system_content +if $system_content != @[{"refId":"A","target":"{val1:13,}","datapoints":[[2,1577980800000]]},{"refId":"A","target":"{val1:14,}","datapoints":[[2,1578067200000]]}]@ then + return -1 +endi + +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select ts,val,val1 from db.tb "} ]' 127.0.0.1:7111/grafana/query +print step3.2-> $system_content +if $system_content != @[{"refId":"A","target":"{val1:11,}","datapoints":[[1,1577808000000]]},{"refId":"A","target":"{val1:12,}","datapoints":[[1,1577894400000]]},{"refId":"A","target":"{val1:13,}","datapoints":[[2,1577980800000]]},{"refId":"A","target":"{val1:14,}","datapoints":[[2,1578067200000]]}]@ then + return -1 +endi + +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select ts,val1,val from db.tb "} ]' 127.0.0.1:7111/grafana/query +print step3.3-> $system_content +if $system_content != @[{"refId":"A","target":"{val:1,}","datapoints":[[11,1577808000000],[12,1577894400000]]},{"refId":"A","target":"{val:2,}","datapoints":[[13,1577980800000],[14,1578067200000]]}]@ then + return -1 +endi + +print =============== step4 - one query, 4 column, with timestamp +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select ts,val2,val1,val from db.tb "} ]' 127.0.0.1:7111/grafana/query +print step4.1-> $system_content +if $system_content != @[{"refId":"A","target":"{val1:11,, val:1,}","datapoints":[[21,1577808000000]]},{"refId":"A","target":"{val1:12,, val:1,}","datapoints":[[22,1577894400000]]},{"refId":"A","target":"{val1:13,, val:2,}","datapoints":[[23,1577980800000]]},{"refId":"A","target":"{val1:14,, val:2,}","datapoints":[[24,1578067200000]]}]@ then + return -1 +endi + +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select ts,val,val1,val2 from db.tb "} ]' 127.0.0.1:7111/grafana/query +print step4.2-> $system_content +if $system_content != @[{"refId":"A","target":"{val1:11,, val2:21,}","datapoints":[[1,1577808000000]]},{"refId":"A","target":"{val1:12,, val2:22,}","datapoints":[[1,1577894400000]]},{"refId":"A","target":"{val1:13,, val2:23,}","datapoints":[[2,1577980800000]]},{"refId":"A","target":"{val1:14,, val2:24,}","datapoints":[[2,1578067200000]]}]@ then + return -1 +endi + +print =============== step5 - one query, 1 column, no timestamp +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select val from db.tb where ts >= 1577980800000 "} ]' 127.0.0.1:7111/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"A","target":"A","datapoints":[[2,"-"],[2,"-"]]}]@ then + return -1 +endi + +print =============== step6 - one query, 2 column, no timestamp +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select val1,val2 from db.tb where ts >= 1577980800000 "} ]' 127.0.0.1:7111/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"A","target":"{val2:23,}","datapoints":[[13,"-"]]},{"refId":"A","target":"{val2:24,}","datapoints":[[14,"-"]]}]@ then + return -1 +endi + +print =============== step7 - one query, 3 column, no timestamp +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select val1,val2,val from db.tb where ts >= 1577980800000 "} ]' 127.0.0.1:7111/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"A","target":"{val2:23,, val:2,}","datapoints":[[13,"-"]]},{"refId":"A","target":"{val2:24,, val:2,}","datapoints":[[14,"-"]]}]@ then + return -1 +endi + +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select val1,val2,val from db.tb"} ]' 127.0.0.1:7111/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"A","target":"{val2:21,, val:1,}","datapoints":[[11,"-"]]},{"refId":"A","target":"{val2:22,, val:1,}","datapoints":[[12,"-"]]},{"refId":"A","target":"{val2:23,, val:2,}","datapoints":[[13,"-"]]},{"refId":"A","target":"{val2:24,, val:2,}","datapoints":[[14,"-"]]}]@ then + return -1 +endi + +print =============== step8 - one query, no return +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select val1,val2,val from db.tb where ts >= 1677980800000 "} ]' 127.0.0.1:7111/grafana/query +print step1-> $system_content +if $system_content != @[]@ then + return -1 +endi + +print =============== step9 - one query, insert sql +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"insert into db.t2 values(now, 1) "} ]' 127.0.0.1:7111/grafana/query +print step1-> $system_content +if $system_content != @[]@ then + return -1 +endi + +print =============== step10 - one query, error sql +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select * from db.tt "} ]' 127.0.0.1:7111/grafana/query +print step1-> $system_content +if $system_content != @[]@ then + return -1 +endi + +print =============== step11 - two query, 1 column, with timestamp, 1 column, with timestamp + +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select ts from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"","sql":"select ts from db.tb where ts >= 1577980800000 "} ]' 127.0.0.1:7111/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"B","target":"BB","datapoints":[[null,1577980800000],[null,1578067200000]]},{"refId":"A","target":"A","datapoints":[[null,1577980800000],[null,1578067200000]]}]@ then + return -1 +endi + +print =============== step12 - two query, 1 column, with timestamp, 2 column, with timestamp + +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select ts from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"","sql":"select ts,val from db.tb where ts >= 1577980800000 "} ]' 127.0.0.1:7111/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"B","target":"BB","datapoints":[[null,1577980800000],[null,1578067200000]]},{"refId":"A","target":"A","datapoints":[[2,1577980800000],[2,1578067200000]]}]@ then + return -1 +endi + +print =============== step13 - two query, 1 column, with timestamp, 3 column, with timestamp +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select ts from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"","sql":"select ts,val,val1 from db.tb where ts >= 1577980800000 "} ]' 127.0.0.1:7111/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"B","target":"BB","datapoints":[[null,1577980800000],[null,1578067200000]]},{"refId":"A","target":"{val1:13,}","datapoints":[[2,1577980800000]]},{"refId":"A","target":"{val1:14,}","datapoints":[[2,1578067200000]]}]@ then + return -1 +endi + +print =============== step14 - two query, 2 column, with timestamp, 2 column, with timestamp +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select ts, val2 from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"AA","sql":"select ts,val from db.tb where ts >= 1577980800000 "} ]' 127.0.0.1:7111/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"B","target":"BB","datapoints":[[223,1577980800000],[224,1578067200000]]},{"refId":"A","target":"AA","datapoints":[[2,1577980800000],[2,1578067200000]]}]@ then + return -1 +endi + +print =============== step15 - two query, 2 column, with timestamp, 3 column, with timestamp +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select ts, val2, val1 from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"AA","sql":"select ts,val from db.tb where ts >= 1577980800000 "} ]' 127.0.0.1:7111/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"B","target":"BB{val1:213,}","datapoints":[[223,1577980800000]]},{"refId":"B","target":"BB{val1:214,}","datapoints":[[224,1578067200000]]},{"refId":"A","target":"AA","datapoints":[[2,1577980800000],[2,1578067200000]]}]@ then + return -1 +endi + +print =============== step16 - two query, 3 column, with timestamp, 4 column, with timestamp +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select ts, val, val1, val2, val1 from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"AA","sql":"select ts,val,val1 from db.tb where ts >= 1577980800000 "} ]' 127.0.0.1:7111/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"B","target":"BB{val1:213,, val2:223,, val1:213,}","datapoints":[[22,1577980800000]]},{"refId":"B","target":"BB{val1:214,, val2:224,, val1:214,}","datapoints":[[22,1578067200000]]},{"refId":"A","target":"AA{val1:13,}","datapoints":[[2,1577980800000]]},{"refId":"A","target":"AA{val1:14,}","datapoints":[[2,1578067200000]]}]@ then + return -1 +endi + +print =============== step17 - two query, 2 column, with timestamp, no return +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select ts, val from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"AA","sql":"select ts,val from db.tb where ts >= 1677980800000 "} ]' 127.0.0.1:7111/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"B","target":"BB","datapoints":[[22,1577980800000],[22,1578067200000]]}]@ then + return -1 +endi + +print =============== step18 - two query, 2 column, with timestamp, invalid sql +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select ts, val from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"AA","sql":"select ts,val from db.tb222 where ts >= 1677980800000 "} ]' 127.0.0.1:7111/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"B","target":"BB","datapoints":[[22,1577980800000],[22,1578067200000]]}]@ then + return -1 +endi + +print =============== step19 - two query, 2 column, with timestamp, insert sql +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select ts, val from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"AA","sql":"insert into db.t2 values(now, 1)"} ]' 127.0.0.1:7111/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"B","target":"BB","datapoints":[[22,1577980800000],[22,1578067200000]]}]@ then + return -1 +endi + +print =============== step20 - two query, 1 column, no timestamp, 1 column, with timestamp +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select val from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"AA","sql":"select ts from db.tb2 where ts >= 1577980800000 "} ]' 127.0.0.1:7111/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"B","target":"BB","datapoints":[[22,"-"],[22,"-"]]},{"refId":"A","target":"AA","datapoints":[[null,1577980800000],[null,1578067200000]]}]@ then + return -1 +endi + +print =============== step21 - two query, 1 column, no timestamp, 2 column, with timestamp +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select val from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"AA","sql":"select ts,val2 from db.tb2 where ts >= 1577980800000 "} ]' 127.0.0.1:7111/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"B","target":"BB","datapoints":[[22,"-"],[22,"-"]]},{"refId":"A","target":"AA","datapoints":[[223,1577980800000],[224,1578067200000]]}]@ then + return -1 +endi + +print =============== step22 - two query, 1 column, no timestamp, 3 column, with timestamp +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select val from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"AA","sql":"select ts,val1, val2 from db.tb2 where ts >= 1577980800000 "} ]' 127.0.0.1:7111/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"B","target":"BB","datapoints":[[22,"-"],[22,"-"]]},{"refId":"A","target":"AA{val2:223,}","datapoints":[[213,1577980800000]]},{"refId":"A","target":"AA{val2:224,}","datapoints":[[214,1578067200000]]}]@ then + return -1 +endi + +print =============== step23 - two query, 2 column, no timestamp, 1 column, no timestamp +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select val1,val2 from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"AA","sql":"select val1 from db.tb2 where ts >= 1577980800000 "} ]' 127.0.0.1:7111/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"B","target":"BB{val2:223,}","datapoints":[[213,"-"]]},{"refId":"B","target":"BB{val2:224,}","datapoints":[[214,"-"]]},{"refId":"A","target":"AA","datapoints":[[213,"-"],[214,"-"]]}]@ then + return -1 +endi + +print =============== step24 - two query, 2 column, no timestamp, 2 column, no timestamp +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select val1,val2 from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"AA","sql":"select val,val1 from db.tb2 where ts >= 1577980800000 "} ]' 127.0.0.1:7111/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"B","target":"BB{val2:223,}","datapoints":[[213,"-"]]},{"refId":"B","target":"BB{val2:224,}","datapoints":[[214,"-"]]},{"refId":"A","target":"AA{val1:213,}","datapoints":[[22,"-"]]},{"refId":"A","target":"AA{val1:214,}","datapoints":[[22,"-"]]}]@ then + return -1 +endi + +print =============== step25 - two query, 2 column, no timestamp, 3 column, no timestamp +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select val1,val2 from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"AA","sql":"select val,val1,val2 from db.tb2 where ts >= 1577980800000 "} ]' 127.0.0.1:7111/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"B","target":"BB{val2:223,}","datapoints":[[213,"-"]]},{"refId":"B","target":"BB{val2:224,}","datapoints":[[214,"-"]]},{"refId":"A","target":"AA{val1:213,, val2:223,}","datapoints":[[22,"-"]]},{"refId":"A","target":"AA{val1:214,, val2:224,}","datapoints":[[22,"-"]]}]@ then + return -1 +endi + +print =============== step26 - 2 column, no timestamp, NULL +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select * from db.tb3 "} ]' 127.0.0.1:7111/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"A","target":"{val1:nil, val2:nil}","datapoints":[[null,1577808000000],[null,1577894400000]]}]@ then + return -1 +endi + +sql create table tt (ts timestamp ,i int) tags(j binary(20),k binary(20)); +sql insert into t1 using tt tags('jnetworki','t1') values('2020-01-01 00:00:00.000',1)('2020-01-01 00:01:00.000',2)('2020-01-01 00:02:00.000',3)('2020-01-01 00:03:00.000',4)('2020-01-01 00:04:00.000',5); + +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select max(i) from db.tt where j like \u0027%network%\u0027 and ts >= \u00272020-01-01 00:00:00.000\u0027 and ts < \u00272020-01-01 00:05:00.000\u0027 interval(5m) group by k "} ]' 127.0.0.1:7111/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"A","target":"{k:t1}","datapoints":[[5,1577808000000]]}]@ then + return -1 +endi + +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select max(i) from db.tt where j like \u0027jnetwo%\u0027 and ts >= \u00272020-01-01 00:00:00.000\u0027 and ts < \u00272020-01-01 00:05:00.000\u0027 interval(5m) group by k "} ]' 127.0.0.1:7111/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"A","target":"{k:t1}","datapoints":[[5,1577808000000]]}]@ then + return -1 +endi + +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select max(i) from db.tt where j like \u0027%networki\u0027 and ts >= \u00272020-01-01 00:00:00.000\u0027 and ts < \u00272020-01-01 00:05:00.000\u0027 interval(5m) group by k "} ]' 127.0.0.1:7111/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"A","target":"{k:t1}","datapoints":[[5,1577808000000]]}]@ then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/http/gzip.sim b/tests/script/general/http/gzip.sim new file mode 100644 index 0000000000000000000000000000000000000000..ce358d84a177b79f8333c2bb4ce370b79b4e0eca --- /dev/null +++ b/tests/script/general/http/gzip.sim @@ -0,0 +1,39 @@ +system sh/stop_dnodes.sh +sleep 2000 +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 0 +system sh/cfg.sh -n dnode1 -c http -v 1 +system sh/cfg.sh -n dnode1 -c maxSQLLength -v 340032 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ============================ dnode1 start + +print =============== step1 - prepare data +sql create database d1 +sql use d1 + +sql create table table_rest (ts timestamp, i int) +print sql length is 270KB +restful d1 table_rest 1591072800 10000 gzip +restful d1 table_rest 1591172800 10000 gzip +restful d1 table_rest 1591272800 10000 gzip +restful d1 table_rest 1591372800 10000 gzip +restful d1 table_rest 1591472800 10000 gzip +restful d1 table_rest 1591572800 10000 gzip +restful d1 table_rest 1591672800 10000 gzip +restful d1 table_rest 1591772800 10000 gzip +restful d1 table_rest 1591872800 10000 gzip +restful d1 table_rest 1591972800 10000 gzip + +sql select * from table_rest; +print rows: $rows +if $rows != 100000 then + return -1 +endi + +system curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select * from d1.table_rest' 127.0.0.1:7111/rest/sql --compressed + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/http/http.json b/tests/script/general/http/http.json new file mode 100644 index 0000000000000000000000000000000000000000..087f4eab5b2d43ec1286c515aa7ef89ce2c42a92 --- /dev/null +++ b/tests/script/general/http/http.json @@ -0,0 +1,23 @@ +{ + "hostIp": "192.168.100.128", + "connNum": 1, + "insertModel": "insertTable", + "waitTime": 0, + "tableDesc": "ts timestamp i int", + "tablePrefix": "t", + "tablePerConn": 1, + "tableCreate": true, + "tableStart": 1, + "dbName": "db", + "dbReplica": 1, + "dbKeep": 3650, + "dbDays": 7, + "metricsName": "mt", + "tagNum": 10, + "dataNum": 100, + "dataBegin": 1485878400000, + "dataInterval": 1000, + "dataBatch": 1, + "dataInsert": true, + "dataRandom": false +} diff --git a/tests/script/general/http/httpTestNew.go b/tests/script/general/http/httpTestNew.go new file mode 100644 index 0000000000000000000000000000000000000000..7947f0a20a9706dc8567f4fb67a3c04c940a22b9 --- /dev/null +++ b/tests/script/general/http/httpTestNew.go @@ -0,0 +1,232 @@ +package main + +import ( + "bytes" + "encoding/json" + "flag" + "fmt" + "io/ioutil" + "math/rand" + "net/http" + "os" + "sync" + "sync/atomic" + "time" +) + +var ( + token string + url string + config Config + request int64 + begin time.Time + errorNum int64 +) + +type Config struct { + HostIp string `json:"hostIp"` + TableNum int `json:"tableNum"` + DbName string `json:"dbName"` + MetricsName string `json:"metricsName"` + DataNum int `json:"dataNum"` + BatchNum int `json:"batchNum"` +} + +type TokenResult struct { + Status string `json:"status"` + Code int `json:"code"` + Desc string `json:"desc"` +} + +type JsonResult struct { + Status string `json:"status"` + Code int `json:"code"` +} + +func readFile(filename string) { + file, err := os.Open(filename) + if err != nil { + println("taos.json not found") + panic(err) + } + defer file.Close() + + dec := json.NewDecoder(file) + err = dec.Decode(&config) + if err != nil { + println("taos.json parse error") + panic(err) + } + + request = 0 + errorNum = 0 + + fmt.Println("================config parameters======================") + fmt.Println("HostIp:", config.HostIp) + fmt.Println("TableNum:", config.TableNum) + fmt.Println("dbName:", config.DbName) + fmt.Println("metricsName:", config.MetricsName) + fmt.Println("dataNum:", config.DataNum) + fmt.Println("batchNum:", config.BatchNum) + + fmt.Println("================http token=============================") + token, err = getToken() + url = fmt.Sprintf("http://%s:%d/rest/sql", config.HostIp, 6020) + + fmt.Println("httpToken:", token) + fmt.Println("httpUrl:", url) + + if err != nil { + panic(err) + } +} + +func getToken() (string, error) { + resp, err := http.Get(fmt.Sprintf("http://%s:%d/rest/login/%s/%s", config.HostIp, 6020, "root", "taosdata")) + if err != nil { + return "", err + } + + defer resp.Body.Close() + + var tokenResult TokenResult + + data, err := ioutil.ReadAll(resp.Body) + + if err != nil { + return "", err + } + + err = json.Unmarshal(data, &tokenResult) + if err != nil { + return "", err + } + + if tokenResult.Status != "succ" { + fmt.Println("get http token failed") + fmt.Println(tokenResult) + return "", err + } + + return tokenResult.Desc, nil +} + +func exec(client *http.Client, sql string) { + for reTryTimes := 0; reTryTimes < 10; reTryTimes++ { + + req, err1 := http.NewRequest("POST", url, bytes.NewReader([]byte(sql))) + if err1 != nil { + continue + } + req.Header.Add("Authorization", "Taosd "+token) + + resp, err := client.Do(req) + + if err != nil { + continue + } + + data, err := ioutil.ReadAll(resp.Body) + if err != nil { + resp.Body.Close() + continue + } + + var jsonResult JsonResult + err = json.Unmarshal(data, &jsonResult) + if err != nil { + resp.Body.Close() + continue + } + + if jsonResult.Status != "succ" { + resp.Body.Close() + continue + } + + atomic.AddInt64(&request, 1) + + if (request*int64(config.BatchNum))%100000 == 0 && request != 0 { + spend := time.Since(begin).Seconds() + if spend >= 1 && spend < 10000000 { + total := (request - errorNum - 2 - int64(config.TableNum)) * int64(config.BatchNum) + fmt.Printf("request:%d, error:%d, insert:%d, spend:%.2f seconds, dps:%.1f \n", request, errorNum, total, spend, float64(total)/float64(spend)) + } + } + + return + } + + //fmt.Println("exec failed, sql:", sql) + errorNum++ +} + +func createDb() { + fmt.Println("================create database =====================") + + client := &http.Client{} + sql := fmt.Sprintf("create database %s", config.DbName) + exec(client, sql) +} + +func createTb() { + fmt.Println("================create table ========================") + + client := &http.Client{} + sql := fmt.Sprintf("create table %s.%s(ts timestamp, f1 int, f2 int) tags (tb int)", config.DbName, config.MetricsName) + exec(client, sql) + + for i := 0; i < config.TableNum; i++ { + sql := fmt.Sprintf("create table %s.t%d using %s.%s tags(%d)", config.DbName, i, config.DbName, config.MetricsName, i) + exec(client, sql) + } +} + +func insertData(wg *sync.WaitGroup, tableIndex int) { + defer wg.Done() + + client := &http.Client{} + beginTime := int64(1519833600000) + + for i := 0; i < config.DataNum; i += config.BatchNum { + var sql bytes.Buffer + sql.WriteString(fmt.Sprintf("insert into %s.t%d values", config.DbName, tableIndex)) + + for j := 0; j < config.BatchNum; j++ { + sql.WriteString(fmt.Sprintf("(%d,%d,%d)", beginTime+int64(i)+int64(j), rand.Intn(1000), rand.Intn(1000))) + } + exec(client, sql.String()) + } +} + +func main() { + filename := flag.String("config", "http.json", "config file name") + + flag.Parse() + + readFile(*filename) + + fmt.Println("\n================http test start======================") + + createDb() + createTb() + + begin = time.Now() + + var wg sync.WaitGroup + + fmt.Println("================insert data ========================") + for i := 0; i < config.TableNum; i++ { + wg.Add(1) + go insertData(&wg, i) + } + + wg.Wait() + + fmt.Println("\n================http test stop ======================") + + spend := time.Since(begin).Seconds() + + total := (request - errorNum - 2 - int64(config.TableNum)) * int64(config.BatchNum) + fmt.Printf("request:%d, error:%d, insert:%d, spend:%.2f seconds, dps:%.1f \n", request, errorNum, total, spend, float64(total)/float64(spend)) +} diff --git a/tests/script/general/http/httpTest_cloud.go b/tests/script/general/http/httpTest_cloud.go new file mode 100644 index 0000000000000000000000000000000000000000..feb3f1450bef122fc0ed3f5225f3d199fd38f16e --- /dev/null +++ b/tests/script/general/http/httpTest_cloud.go @@ -0,0 +1,372 @@ +package main + +import ( + "bytes" + "encoding/json" + "fmt" + "io/ioutil" + "math/rand" + "net/http" + "os" + "sync" + "sync/atomic" + "time" + "flag" +) + +var ( + token string + url string + config Config + request int64 + period int64 + errorNum int64 +) + +type Config struct { + HostIp string `json:"hostIp"` + ConnNum int `json:"connNum"` + InsertModel string `json:"insertModel"` + WaitTime int `json:"waitTime"` + TableDesc string `json:"tableDesc"` + TablePrefix string `json:"tablePrefix"` + TablePerConn int `json:"tablePerConn"` + TableCreate bool `json:"tableCreate"` + TableStart int `json:"tableStart"` + DbName string `json:"dbName"` + DbReplica int `json:"dbReplica"` + DbKeep int `json:"dbKeep"` + DbDays int `json:"dbDays"` + MetricsName string `json:"metricsName"` + TagNum int `json:"tagNum"` + DataNum int `json:"dataNum"` + DataBegin int64 `json:"dataBegin"` + DataInterval int `json:"dataInterval"` + DataBatch int `json:"dataBatch"` + DataInsert bool `json:"dataInsert"` + DataRandom bool `json:"dataRandom"` +} + +type TokenResult struct { + Status string `json:"status"` + Code int `json:"code"` + Desc string `json:"desc"` +} + +type JsonResult struct { + Status string `json:"status"` + Code int `json:"code"` +} + +func readFile(filename string) { + file, err := os.Open(filename) + if err != nil { + println("taos_cloud.json not found") + panic(err) + } + defer file.Close() + + dec := json.NewDecoder(file) + err = dec.Decode(&config) + if err != nil { + println("taos_cloud.json parse error") + panic(err) + } + + if config.TagNum <= 0 { + config.TagNum = 1 + } + request = 0 + period = 0 + errorNum = 0 + + fmt.Println("================config parameters======================") + fmt.Println("HostIp:", config.HostIp) + fmt.Println("connNum:", config.ConnNum) + fmt.Println("insertModel:", config.InsertModel) + fmt.Println("waitTime:", config.WaitTime) + fmt.Println("tableDesc:", config.TableDesc) + fmt.Println("tablePrefix:", config.TablePrefix) + fmt.Println("tablePerConn:", config.TablePerConn) + fmt.Println("tableCreate:", config.TableCreate) + fmt.Println("tableStart:", config.TableStart) + fmt.Println("dbName:", config.DbName) + fmt.Println("dbReplica:", config.DbReplica) + fmt.Println("dbKeep:", config.DbKeep) + fmt.Println("dbDays:", config.DbDays) + fmt.Println("metricsName:", config.MetricsName) + fmt.Println("tagNum:", config.TagNum) + fmt.Println("dataNum:", config.DataNum) + fmt.Println("dataBegin:", config.DataBegin) + fmt.Println("dataInterval:", config.DataInterval) + fmt.Println("dataBatch:", config.DataBatch) + fmt.Println("dataInsert:", config.DataInsert) + fmt.Println("dataRandom:", config.DataRandom) + + fmt.Println("================http token=============================") + token, err = getToken() + url = fmt.Sprintf("http://%s:%d/rest/sql", config.HostIp, 6020) + + fmt.Println("httpToken:", token) + fmt.Println("httpUrl:", url) + + if err != nil { + panic(err) + } +} + +func getToken() (string, error) { + resp, err := http.Get(fmt.Sprintf("http://%s:%d/rest/login/%s/%s", config.HostIp, 6020, "tiger", "tiger")) + if err != nil { + return "", err + } + + defer resp.Body.Close() + + var tokenResult TokenResult + + data, err := ioutil.ReadAll(resp.Body) + + if err != nil { + return "", err + } + + err = json.Unmarshal(data, &tokenResult) + if err != nil { + return "", err + } + + if tokenResult.Status != "succ" { + fmt.Println("get http token failed") + fmt.Println(tokenResult) + return "", err + } + + return tokenResult.Desc, nil +} + +func exec(client *http.Client, sql string) { + for times := 0; times < 10; times++ { + + req, err1 := http.NewRequest("POST", url, bytes.NewReader([]byte(sql))) + if err1 != nil { + continue + } + req.Header.Add("Authorization", "Taosd "+token) + + begin := time.Now() + resp, err := client.Do(req) + + if err != nil { + continue + } + + data, err := ioutil.ReadAll(resp.Body) + if err != nil { + resp.Body.Close() + continue + } + + spend := (time.Since(begin).Nanoseconds()) + + var jsonResult JsonResult + err = json.Unmarshal(data, &jsonResult) + if err != nil { + resp.Body.Close() + continue + } + + if jsonResult.Status != "succ" { + resp.Body.Close() + continue + } + atomic.AddInt64(&request, 1) + if (request < 103) { + return + } + + atomic.AddInt64(&period, spend) + if request%5000 == 0 && request != 0 { + requestAvg := float64(period) / float64(1000000) / float64(request) + qps := float64(1000) / float64(requestAvg) * float64(config.ConnNum) + dps := qps * float64(config.DataBatch) + fmt.Println("====== req:", request, ", error:", errorNum, ", qps:", int64(qps), ", wait:", int64(requestAvg), "ms", ", data per second:", int64(dps)) + } + return + } + fmt.Println("xxxx>sql:", sql, ", retryTimes:", 10) + errorNum++ +} + +func createDb() { + if !config.TableCreate { + return + } + + client := &http.Client{} + + fmt.Println("\n================create database =====================") + sql := fmt.Sprintf("create database %s keep %d", config.DbName, config.DbKeep) + exec(client, sql) +} + +func createTb() { + if !config.TableCreate { + return + } + client := &http.Client{} + + fmt.Println("\n================create table ========================") + sql := fmt.Sprintf("create table %s.%s(%s) tags (orgno int)", config.DbName, config.MetricsName, config.TableDesc) + exec(client, sql) + tbNum := config.TablePerConn*config.ConnNum + config.TableStart + for i := config.TableStart; i < tbNum; i++ { + sql := fmt.Sprintf("create table %s.%s%d using %s.%s tags(%d)", config.DbName, config.TablePrefix, i, config.DbName, config.MetricsName, i%config.TagNum+1) + exec(client, sql) + } + +} + +func insertTable(conn int) { + client := &http.Client{} + + tbStart := conn*config.TablePerConn + config.TableStart + tmStart := config.DataBegin + + for i := 0; i < config.TablePerConn; i++ { + tbIndex := i + tbStart + + for j := 0; j < config.DataNum; j++ { + tmVal := int64(j)*int64(config.DataInterval) + tmStart + + dataVal := j + if config.DataRandom { + dataVal = rand.Intn(1000) + } + + sql := fmt.Sprintf("insert into %s.%s%d values(%d, %d)", config.DbName, config.TablePrefix, tbIndex, tmVal, dataVal) + for k := 1; k < config.DataBatch; k++ { + tmVal := int64(j)*int64(config.DataInterval) + int64(k) + tmStart + + dataVal := j + k + if config.DataRandom { + dataVal = rand.Intn(1000) + } + + sql += fmt.Sprintf("(%d, %d)", tmVal, dataVal) + } + + j += (config.DataBatch - 1) + + exec(client, sql) + if config.WaitTime != 0 { + time.Sleep(time.Millisecond * time.Duration(config.WaitTime)) + } + } + } +} + +func insertLoop(conn int) { + client := &http.Client{} + + tbStart := conn*config.TablePerConn + config.TableStart + tmStart := config.DataBegin + + for j := 0; j < config.DataNum; j++ { + + for i := 0; i < config.TablePerConn; i++ { + tbIndex := i + tbStart + + tmVal := int64(j)*int64(config.DataInterval) + tmStart + + dataVal := j + if config.DataRandom { + dataVal = rand.Intn(1000) + } + + sql := fmt.Sprintf("insert into %s.%s%d values(%d, %d)", config.DbName, config.TablePrefix, tbIndex, tmVal, dataVal) + for k := 1; k < config.DataBatch; k++ { + tmVal := int64(j)*int64(config.DataInterval) + int64(k) + tmStart + + dataVal := j + k + if config.DataRandom { + dataVal = rand.Intn(1000) + } + sql += fmt.Sprintf("values(%d, %d)", tmVal, dataVal) + } + + j += (config.DataBatch - 1) + + exec(client, sql) + + if config.WaitTime != 0 { + time.Sleep(time.Millisecond * time.Duration(config.WaitTime)) + } + } + + } +} + +func insertTb(wg *sync.WaitGroup, conn int) { + defer wg.Done() + + if !config.DataInsert { + return + } + + if config.InsertModel == "insertTable" { + insertTable(conn) + } else { + insertLoop(conn) + } +} + +func selectData(wg *sync.WaitGroup, conn int) { + defer wg.Done() + + client := &http.Client{} + + for i := 0; i < config.DataNum; i++ { + exec(client, config.TableDesc) + } +} + +func main() { + filename := flag.String("config", "taos_cloud.json", "config file name") + + flag.Parse() + + readFile(*filename) + + fmt.Println("\n================http test start======================") + + var wg sync.WaitGroup + + if config.InsertModel == "selectData" { + fmt.Println("\n================select data ========================") + for i := 0; i < config.ConnNum; i++ { + wg.Add(1) + go selectData(&wg, i) + } + } else { + createDb() + createTb() + + if config.DataInsert { + fmt.Println("\n================insert data ========================") + } + + for i := 0; i < config.ConnNum; i++ { + wg.Add(1) + go insertTb(&wg, i) + } + } + + wg.Wait() + + fmt.Println("\n================http test stop ======================") + requestAvg := float64(period) / float64(1000000) / float64(request) + qps := float64(1000) / float64(requestAvg) * float64(config.ConnNum) + dps := qps * float64(config.DataBatch) + fmt.Println("====== req:", request, ", error:", errorNum, ", qps:", int64(qps), ", wait:", int64(requestAvg), "ms", ", data per second:", int64(dps)) +} diff --git a/tests/script/general/http/httpTest_private.go b/tests/script/general/http/httpTest_private.go new file mode 100644 index 0000000000000000000000000000000000000000..907b6c1d62e36ff0c5fecfa801a7559f50deefe8 --- /dev/null +++ b/tests/script/general/http/httpTest_private.go @@ -0,0 +1,372 @@ +package main + +import ( + "bytes" + "encoding/json" + "fmt" + "io/ioutil" + "math/rand" + "net/http" + "os" + "sync" + "sync/atomic" + "time" + "flag" +) + +var ( + token string + url string + config Config + request int64 + period int64 + errorNum int64 +) + +type Config struct { + HostIp string `json:"hostIp"` + ConnNum int `json:"connNum"` + InsertModel string `json:"insertModel"` + WaitTime int `json:"waitTime"` + TableDesc string `json:"tableDesc"` + TablePrefix string `json:"tablePrefix"` + TablePerConn int `json:"tablePerConn"` + TableCreate bool `json:"tableCreate"` + TableStart int `json:"tableStart"` + DbName string `json:"dbName"` + DbReplica int `json:"dbReplica"` + DbKeep int `json:"dbKeep"` + DbDays int `json:"dbDays"` + MetricsName string `json:"metricsName"` + TagNum int `json:"tagNum"` + DataNum int `json:"dataNum"` + DataBegin int64 `json:"dataBegin"` + DataInterval int `json:"dataInterval"` + DataBatch int `json:"dataBatch"` + DataInsert bool `json:"dataInsert"` + DataRandom bool `json:"dataRandom"` +} + +type TokenResult struct { + Status string `json:"status"` + Code int `json:"code"` + Desc string `json:"desc"` +} + +type JsonResult struct { + Status string `json:"status"` + Code int `json:"code"` +} + +func readFile(filename string) { + file, err := os.Open(filename) + if err != nil { + println("taos_cloud.json not found") + panic(err) + } + defer file.Close() + + dec := json.NewDecoder(file) + err = dec.Decode(&config) + if err != nil { + println("taos_cloud.json parse error") + panic(err) + } + + if config.TagNum <= 0 { + config.TagNum = 1 + } + request = 0 + period = 0 + errorNum = 0 + + fmt.Println("================config parameters======================") + fmt.Println("HostIp:", config.HostIp) + fmt.Println("connNum:", config.ConnNum) + fmt.Println("insertModel:", config.InsertModel) + fmt.Println("waitTime:", config.WaitTime) + fmt.Println("tableDesc:", config.TableDesc) + fmt.Println("tablePrefix:", config.TablePrefix) + fmt.Println("tablePerConn:", config.TablePerConn) + fmt.Println("tableCreate:", config.TableCreate) + fmt.Println("tableStart:", config.TableStart) + fmt.Println("dbName:", config.DbName) + fmt.Println("dbReplica:", config.DbReplica) + fmt.Println("dbKeep:", config.DbKeep) + fmt.Println("dbDays:", config.DbDays) + fmt.Println("metricsName:", config.MetricsName) + fmt.Println("tagNum:", config.TagNum) + fmt.Println("dataNum:", config.DataNum) + fmt.Println("dataBegin:", config.DataBegin) + fmt.Println("dataInterval:", config.DataInterval) + fmt.Println("dataBatch:", config.DataBatch) + fmt.Println("dataInsert:", config.DataInsert) + fmt.Println("dataRandom:", config.DataRandom) + + fmt.Println("================http token=============================") + token, err = getToken() + url = fmt.Sprintf("http://%s:%d/rest/sql", config.HostIp, 6020) + + fmt.Println("httpToken:", token) + fmt.Println("httpUrl:", url) + + if err != nil { + panic(err) + } +} + +func getToken() (string, error) { + resp, err := http.Get(fmt.Sprintf("http://%s:%d/rest/login/%s/%s", config.HostIp, 6020, "root", "taosdata")) + if err != nil { + return "", err + } + + defer resp.Body.Close() + + var tokenResult TokenResult + + data, err := ioutil.ReadAll(resp.Body) + + if err != nil { + return "", err + } + + err = json.Unmarshal(data, &tokenResult) + if err != nil { + return "", err + } + + if tokenResult.Status != "succ" { + fmt.Println("get http token failed") + fmt.Println(tokenResult) + return "", err + } + + return tokenResult.Desc, nil +} + +func exec(client *http.Client, sql string) { + for times := 0; times < 1; times++ { + + req, err1 := http.NewRequest("POST", url, bytes.NewReader([]byte(sql))) + if err1 != nil { + continue + } + req.Header.Add("Authorization", "Taosd "+token) + + begin := time.Now() + resp, err := client.Do(req) + + if err != nil { + continue + } + + data, err := ioutil.ReadAll(resp.Body) + if err != nil { + resp.Body.Close() + continue + } + + spend := (time.Since(begin).Nanoseconds()) + + var jsonResult JsonResult + err = json.Unmarshal(data, &jsonResult) + if err != nil { + resp.Body.Close() + continue + } + + if jsonResult.Status != "succ" { + resp.Body.Close() + continue + } + atomic.AddInt64(&request, 1) + if (request < 103) { + return + } + + atomic.AddInt64(&period, spend) + if request%5000 == 0 && request != 0 { + requestAvg := float64(period) / float64(1000000) / float64(request) + qps := float64(1000) / float64(requestAvg) * float64(config.ConnNum) + dps := qps * float64(config.DataBatch) + fmt.Println("====== req:", request, ", error:", errorNum, ", qps:", int64(qps), ", wait:", int64(requestAvg), "ms", ", data per second:", int64(dps)) + } + return + } + fmt.Println("xxxx>sql:", sql, ", retryTimes:", 10) + errorNum++ +} + +func createDb() { + if !config.TableCreate { + return + } + + client := &http.Client{} + + fmt.Println("\n================create database =====================") + sql := fmt.Sprintf("create database %s keep %d", config.DbName, config.DbKeep) + exec(client, sql) +} + +func createTb() { + if !config.TableCreate { + return + } + client := &http.Client{} + + fmt.Println("\n================create table ========================") + sql := fmt.Sprintf("create table %s.%s(%s) tags (orgno int)", config.DbName, config.MetricsName, config.TableDesc) + exec(client, sql) + tbNum := config.TablePerConn*config.ConnNum + config.TableStart + for i := config.TableStart; i < tbNum; i++ { + sql := fmt.Sprintf("create table %s.%s%d using %s.%s tags(%d)", config.DbName, config.TablePrefix, i, config.DbName, config.MetricsName, i%config.TagNum+1) + exec(client, sql) + } + +} + +func insertTable(conn int) { + client := &http.Client{} + + tbStart := conn*config.TablePerConn + config.TableStart + tmStart := config.DataBegin + + for j := 0; j < config.DataNum; j++ { + for i := 0; i < config.TablePerConn; i++ { + tbIndex := i + tbStart + + tmVal := int64(j)*int64(config.DataInterval) + tmStart + + dataVal := j + if config.DataRandom { + dataVal = rand.Intn(1000) + } + + sql := fmt.Sprintf("insert into %s.%s%d values(%d, %d)", config.DbName, config.TablePrefix, tbIndex, tmVal, dataVal) + for k := 1; k < config.DataBatch; k++ { + tmVal := int64(j)*int64(config.DataInterval) + int64(k) + tmStart + + dataVal := j + k + if config.DataRandom { + dataVal = rand.Intn(1000) + } + + sql += fmt.Sprintf("(%d, %d)", tmVal, dataVal) + } + + + exec(client, sql) + if config.WaitTime != 0 { + time.Sleep(time.Millisecond * time.Duration(config.WaitTime)) + } + } + j += (config.DataBatch - 1) + } +} + +func insertLoop(conn int) { + client := &http.Client{} + + tbStart := conn*config.TablePerConn + config.TableStart + tmStart := config.DataBegin + + for j := 0; j < config.DataNum; j++ { + + for i := 0; i < config.TablePerConn; i++ { + tbIndex := i + tbStart + + tmVal := int64(j)*int64(config.DataInterval) + tmStart + + dataVal := j + if config.DataRandom { + dataVal = rand.Intn(1000) + } + + sql := fmt.Sprintf("insert into %s.%s%d values(%d, %d)", config.DbName, config.TablePrefix, tbIndex, tmVal, dataVal) + for k := 1; k < config.DataBatch; k++ { + tmVal := int64(j)*int64(config.DataInterval) + int64(k) + tmStart + + dataVal := j + k + if config.DataRandom { + dataVal = rand.Intn(1000) + } + sql += fmt.Sprintf("values(%d, %d)", tmVal, dataVal) + } + + j += (config.DataBatch - 1) + + exec(client, sql) + + if config.WaitTime != 0 { + time.Sleep(time.Millisecond * time.Duration(config.WaitTime)) + } + } + + } +} + +func insertTb(wg *sync.WaitGroup, conn int) { + defer wg.Done() + + if !config.DataInsert { + return + } + + if config.InsertModel == "insertTable" { + insertTable(conn) + } else { + insertLoop(conn) + } +} + +func selectData(wg *sync.WaitGroup, conn int) { + defer wg.Done() + + client := &http.Client{} + + for i := 0; i < config.DataNum; i++ { + exec(client, config.TableDesc) + } +} + +func main() { + filename := flag.String("config", "taos_cloud.json", "config file name") + + flag.Parse() + + readFile(*filename) + + fmt.Println("\n================http test start======================") + + var wg sync.WaitGroup + + if config.InsertModel == "selectData" { + fmt.Println("\n================select data ========================") + for i := 0; i < config.ConnNum; i++ { + wg.Add(1) + go selectData(&wg, i) + } + } else { + createDb() + createTb() + + if config.DataInsert { + fmt.Println("\n================insert data ========================") + } + + for i := 0; i < config.ConnNum; i++ { + wg.Add(1) + go insertTb(&wg, i) + } + } + + wg.Wait() + + fmt.Println("\n================http test stop ======================") + requestAvg := float64(period) / float64(1000000) / float64(request) + qps := float64(1000) / float64(requestAvg) * float64(config.ConnNum) + dps := qps * float64(config.DataBatch) + fmt.Println("====== req:", request, ", error:", errorNum, ", qps:", int64(qps), ", wait:", int64(requestAvg), "ms", ", data per second:", int64(dps)) +} diff --git a/tests/script/general/http/prepare.sim b/tests/script/general/http/prepare.sim new file mode 100644 index 0000000000000000000000000000000000000000..4bf6b6119833563f85ee8f8de1a2393bf07a2e71 --- /dev/null +++ b/tests/script/general/http/prepare.sim @@ -0,0 +1,54 @@ +system sh/stop_dnodes.sh +sleep 2000 +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c http -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ============================ dnode1 start + +print =============== step1 - prepare data +sql create database d1 +sql use d1 + +sql create table t1 (ts timestamp, i int, b binary(100)) + +sql insert into t1 values('2017-12-25 21:28:41.022', 1, 11) +sql insert into t1 values('2017-12-25 21:28:42.022', 2, '22') +sql insert into t1 values('2017-12-25 21:28:43.022', 3, "33") +sql insert into t1 values('2017-12-25 21:28:44.022', 4, '44"') +sql insert into t1 values('2017-12-25 21:28:45.022', 5, "55'") +sql insert into t1 values('2017-12-25 21:28:46.022', 6, "66'6'") +sql insert into t1 values('2017-12-25 21:28:47.022', 7, '77"7"') +sql insert into t1 values('2017-12-25 21:28:48.022', 8, '88""88') +sql insert into t1 values('2017-12-25 21:28:49.022', 9, '99\99') +sql insert into t1 values('2017-12-25 21:28:51.022', 11, '11\\11') +sql insert into t1 values('2017-12-25 21:28:52.022', 12, '22\\11') +sql insert into t1 values('2017-12-25 21:28:53.022', 13, '33\\"33') +sql insert into t1 values('2017-12-25 21:28:54.022', 14, '44\\""44') + +sleep 4000 + +print =============== step2 - login + +system_content curl 127.0.0.1:7111/rest/login/root/taosdata +print curl 127.0.0.1:7111/rest/login/root/taosdata -----> $system_content + +if $system_content != @{"status":"succ","code":0,"desc":"/KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04"}@ then + return -1 +endi + +return + +print =============== step3 - query data + +system_content curl -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ3d3cudGFvc2RhdGEuY29tIiwia2V5IjoiYkVsOExjdkxVZDdhOHFkdE5abXRPTnJ5cDIwMW1hMDQiLCJzdWIiOiJyb290In0.k7CkgmpOJImIkLqZqzASlPmkdeEw7Wfk4XUrqGZX-LQ' -d 'select * from t1' 127.0.0.1:7111/rest/sql/d1 +print curl 127.0.0.1:7111/rest/sql/d1 -----> $system_content +if $system_content != @{"status":"succ","head":["ts","i","b"],"data":[["2017-12-25 21:28:54.022",14,"44\\\\\"\"44"],["2017-12-25 21:28:53.022",13,"33\\\\\"33"],["2017-12-25 21:28:52.022",12,"22\\\\11"],["2017-12-25 21:28:51.022",11,"11\\\\11"],["2017-12-25 21:28:49.022",9,"99\\99"],["2017-12-25 21:28:48.022",8,"88\"\"88"],["2017-12-25 21:28:47.022",7,"77\"7\""],["2017-12-25 21:28:46.022",6,"66'6'"],["2017-12-25 21:28:45.022",5,"55'"],["2017-12-25 21:28:44.022",4,"44\""],["2017-12-25 21:28:43.022",3,"33"],["2017-12-25 21:28:42.022",2,"22"],["2017-12-25 21:28:41.022",1,"11"]],"rows":13}@ then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/http/restful.sim b/tests/script/general/http/restful.sim new file mode 100644 index 0000000000000000000000000000000000000000..6ebf5644e7a99593ebac0302c3dcdbc0a27fc8c1 --- /dev/null +++ b/tests/script/general/http/restful.sim @@ -0,0 +1,82 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 0 +system sh/cfg.sh -n dnode1 -c http -v 1 +system sh/cfg.sh -n dnode1 -c httpEnableRecordSql -v 1 +system sh/exec.sh -n dnode1 -s start + +sql connect + +print ============================ dnode1 start + +print =============== step1 - prepare data +sql create database d1 +sql use d1 + +sql create table table_rest (ts timestamp, i int) + +sql insert into table_rest values('2017-12-25 21:28:41.022', 1) +sql insert into table_rest values('2017-12-25 21:28:42.022', 2) +sql insert into table_rest values('2017-12-25 21:28:43.022', 3) +sql insert into table_rest values('2017-12-25 21:28:44.022', 4) +sql insert into table_rest values('2017-12-25 21:28:45.022', 5) +sql insert into table_rest values('2017-12-25 21:28:46.022', 6) +sql insert into table_rest values('2017-12-25 21:28:47.022', 7) +sql insert into table_rest values('2017-12-25 21:28:48.022', 8) +sql insert into table_rest values('2017-12-25 21:28:49.022', 9) +sql insert into table_rest values('2017-12-25 21:28:50.022', 10) + +print =============== step2 - login + +system_content curl 127.0.0.1:7111/rest/login/root/taosdata +print curl 127.0.0.1:7111/rest/login/root/taosdata -----> $system_content + +if $system_content != {"status":"succ","code":0,"desc":"/KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04"} then + return -1 +endi + +print =============== step3 - query data + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select * from d1.table_rest' 127.0.0.1:7111/rest/sql +print curl 127.0.0.1:7111/rest/sql -----> $system_content +if $system_content != @{"status":"succ","head":["ts","i"],"column_meta":[["ts",9,8],["i",4,4]],"data":[["2017-12-25 21:28:41.022",1],["2017-12-25 21:28:42.022",2],["2017-12-25 21:28:43.022",3],["2017-12-25 21:28:44.022",4],["2017-12-25 21:28:45.022",5],["2017-12-25 21:28:46.022",6],["2017-12-25 21:28:47.022",7],["2017-12-25 21:28:48.022",8],["2017-12-25 21:28:49.022",9],["2017-12-25 21:28:50.022",10]],"rows":10}@ then + return -1 +endi + +print =============== step4 - insert data +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.table_rest values('2017-12-25 21:28:51.022', 11)" 127.0.0.1:7111/rest/sql +print curl 127.0.0.1:7111/rest/sql -----> $system_content +if $system_content != @{"status":"succ","head":["affected_rows"],"column_meta":[["affected_rows",4,4]],"data":[[1]],"rows":1}@ then + return -1 +endi + +print =============== step5 - query data + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select * from d1.table_rest' 127.0.0.1:7111/rest/sql +print curl 127.0.0.1:7111/rest/sql -----> $system_content +if $system_content != @{"status":"succ","head":["ts","i"],"column_meta":[["ts",9,8],["i",4,4]],"data":[["2017-12-25 21:28:41.022",1],["2017-12-25 21:28:42.022",2],["2017-12-25 21:28:43.022",3],["2017-12-25 21:28:44.022",4],["2017-12-25 21:28:45.022",5],["2017-12-25 21:28:46.022",6],["2017-12-25 21:28:47.022",7],["2017-12-25 21:28:48.022",8],["2017-12-25 21:28:49.022",9],["2017-12-25 21:28:50.022",10],["2017-12-25 21:28:51.022",11]],"rows":11}@ then + return -1 +endi + +print =============== step6 - query no db data + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'show dnodes' 127.0.0.1:7111/rest/sql +print curl 127.0.0.1:7111/rest/sql -----> $system_content + +print =============== step7 - change password +sql create user u1 PASS 'abcd@1234' +sql create user u2 PASS 'abcd_1234' + +system_content curl 127.0.0.1:7111/rest/login/u1/abcd@1234 +print curl 127.0.0.1:7111/rest/login/u1/abcd@1234 -----> $system_content +if $system_content != @{"status":"succ","code":0,"desc":"jIlItaLFFIPa8qdtNZmtONryp201ma04SXX8PEJowKAB/46k1gwnPNryp201ma04"}@ then + return -1 +endi + +system_content curl 127.0.0.1:7111/rest/login/u2/aabcd_1234 +print curl 127.0.0.1:7111/rest/login/u2/abcd_1234 -----> $system_content +if $system_content != @{"status":"error","code":3,"desc":"Authentication failure"}@ then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/http/restful_full.sim b/tests/script/general/http/restful_full.sim new file mode 100644 index 0000000000000000000000000000000000000000..a5d3ac2b862f3b2b72b0453a2c1bb2b578672246 --- /dev/null +++ b/tests/script/general/http/restful_full.sim @@ -0,0 +1,240 @@ +system sh/stop_dnodes.sh +sleep 2000 +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 0 +system sh/cfg.sh -n dnode1 -c http -v 1 +system sh/exec.sh -n dnode1 -s start + +#sleep 2000 +sql connect + +print ============================ dnode1 start + +print =============== step1 - login + +system_content curl 127.0.0.1:7111/rest/ +print 1-> $system_content +if $system_content != @{"status":"error","code":4357,"desc":"no auth info input"}@ then + print $system_content + return -1 +endi + +system_content curl 127.0.0.1:7111/rest/xx +print 2-> $system_content +if $system_content != @{"status":"error","code":4357,"desc":"no auth info input"}@ then + return -1 +endi + +system_content curl 127.0.0.1:7111/rest/login +print 3-> $system_content +if $system_content != @{"status":"error","code":4357,"desc":"no auth info input"}@ then + return -1 +endi + +#4 +system_content curl 127.0.0.1:7111/rest/login/root +print 4-> $system_content +if $system_content != @{"status":"error","code":4357,"desc":"no auth info input"}@ then + return -1 +endi + +system_content curl 127.0.0.1:7111/rest/login/root/123 +print 5-> $system_content +if $system_content != @{"status":"error","code":3,"desc":"Authentication failure"}@ then + return -1 +endi + +system_content curl 127.0.0.1:7111/rest/login/root/123/1/1/3 +print 6-> $system_content +if $system_content != @{"status":"error","code":3,"desc":"Authentication failure"}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'show databases' 127.0.0.1:7111/rest/login/root/1 +print 7-> $system_content +if $system_content != @{"status":"error","code":3,"desc":"Authentication failure"}@ then + return -1 +endi + +#8 +system_content curl -H 'Authorization: Beare eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9' -d 'show databases' 127.0.0.1:7111/rest/login/root/1 +print 8-> $system_content +if $system_content != @{"status":"error","code":4386,"desc":"invalid type of Authorization"}@ then + return -1 +endi + +system_content curl -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ3d3cudGFvc2RhdGEuY29tIiwicGFzcyI6InRhb3NkYXRhIiwic3ViIjoicm9vdCJ9.xPv3b5odlR7YF8G_QWASjIRbMtA5v4ItToJ35fFgi' -d 'show databases' 127.0.0.1:7111/rest/login/root/1 +print 8-> $system_content +if $system_content != @{"status":"error","code":4387,"desc":"invalid format of Authorization"}@ then + return -1 +endi + +system_content curl -H 'Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ3d3cudGFvc2RhdGEuY29tIiwicGFzcyI6InRhb3NkYXRhIiwic3ViIjoicm9vdCJ9.xPv3b5odlR7YF8G_QWASjIRbMtA5v4ItToJ35fFgi' -d 'show databases' 127.0.0.1:7111/rest/login/root/1 +print 9-> $system_content +if $system_content != @{"status":"error","code":4387,"desc":"invalid format of Authorization"}@ then + return -1 +endi + +sleep 2000 + +system_content curl 127.0.0.1:7111/rest/login/root/taosdata/ +print 10-> $system_content +if $system_content != @{"status":"succ","code":0,"desc":"/KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04"}@ then + return -1 +endi + +print =============== step2 - no db + +#11 +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'show databases' 127.0.0.1:7111/rest/sql +print 11-> $system_content +if $system_content != @{"status":"succ","head":["name","created_time","ntables","vgroups","replica","quorum","days","keep0,keep1,keep2","cache(MB)","blocks","minrows","maxrows","wallevel","fsync","comp","cachelast","precision","update","status"],"column_meta":[["name",8,32],["created_time",9,8],["ntables",4,4],["vgroups",4,4],["replica",3,2],["quorum",3,2],["days",3,2],["keep0,keep1,keep2",8,24],["cache(MB)",4,4],["blocks",4,4],["minrows",4,4],["maxrows",4,4],["wallevel",2,1],["fsync",4,4],["comp",2,1],["cachelast",2,1],["precision",8,3],["update",2,1],["status",8,10]],"data":[],"rows":0}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'create database d1' 127.0.0.1:7111/rest/sql +print 12-> $system_content +if $system_content != @{"status":"succ","head":["affected_rows"],"column_meta":[["affected_rows",4,4]],"data":[[0]],"rows":1}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'create database d1' 127.0.0.1:7111/rest/sql +print 13-> $system_content +if $system_content != @{"status":"error","code":897,"desc":"Database already exists"}@ then + return -1 +endi + +#14 +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d '' 127.0.0.1:7111/rest/sql +print 14-> $system_content +if $system_content != @{"status":"error","code":4359,"desc":"no sql input"}@ then + return -1 +endi + +#system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'use d1' 127.0.0.1:7111/rest/sql +#print 15-> $system_content +#if $system_content != @{"status":"error","code":5017,"desc":"no need to execute use db cmd"}@ then +#if $system_content != @{"status":"succ","head":["affected_rows"],"data":[[1]],"rows":1}@ then +# return -1 +#endi + +#system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' use d1' 127.0.0.1:7111/rest/sql +#print 16-> $system_content +#if $system_content != @{"status":"error","code":5017,"desc":"no need to execute use db cmd"}@ then +# return -1 +#endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' used1' 127.0.0.1:7111/rest/sql +print 17-> $system_content +if $system_content != @{"status":"error","code":534,"desc":"Syntax error in SQL"}@ then + return -1 +endi + +#18 +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' show tables;' 127.0.0.1:7111/rest/sql +print 18-> $system_content +if $system_content != @{"status":"error","code":896,"desc":"Database not specified or available"}@ then + return -1 +endi + +print =============== step3 - db + +#19 +#system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' show tables;' 127.0.0.1:7111/rest/sql/d4 +#print 19-> $system_content +#if $system_content != @{"status":"error","code":1000,"desc":"invalid DB"}@ then +# return -1 +#endi + +#system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' show tables;' 127.0.0.1:7111/rest/sql/d1 +#print 20-> $system_content +#if $system_content != @{"status":"succ","head":["name","created time","columns","metric"],"data":[],"rows":0}@ then +# return -1 +#endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' select * from d1.t1;' 127.0.0.1:7111/rest/sql +print 21-> $system_content +if $system_content != @{"status":"error","code":866,"desc":"Table does not exist"}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' create table d1.t1 (ts timestamp, speed int)' 127.0.0.1:7111/rest/sql +print 22-> $system_content +if $system_content != @{"status":"succ","head":["affected_rows"],"column_meta":[["affected_rows",4,4]],"data":[[0]],"rows":1}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' select * from d1.t1 ' 127.0.0.1:7111/rest/sql +print 23-> $system_content +if $system_content != @{"status":"succ","head":["ts","speed"],"column_meta":[["ts",9,8],["speed",4,4]],"data":[],"rows":0}@ then + return -1 +endi + +#24 +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.t1 values('2017-12-25 21:28:41.022', 1)" 127.0.0.1:7111/rest/sql +print 24-> $system_content +if $system_content != @{"status":"succ","head":["affected_rows"],"column_meta":[["affected_rows",4,4]],"data":[[1]],"rows":1}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' select * from d1.t1 ' 127.0.0.1:7111/rest/sql +print 25-> $system_content +if $system_content != @{"status":"succ","head":["ts","speed"],"column_meta":[["ts",9,8],["speed",4,4]],"data":[["2017-12-25 21:28:41.022",1]],"rows":1}@ then + return -1 +endi + +#26 +print 25-> no print +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.t1 values('2017-12-25 21:28:42.022', 2)" 127.0.0.1:7111/rest/sql + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.t1 values('2017-12-25 21:28:43.022', 3)" 127.0.0.1:7111/rest/sql + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.t1 values('2017-12-25 21:28:44.022', 4)" 127.0.0.1:7111/rest/sql + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.t1 values('2017-12-25 21:28:45.022', 5)" 127.0.0.1:7111/rest/sql + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.t1 values('2017-12-25 21:28:46.022', 6)" 127.0.0.1:7111/rest/sql + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.t1 values('2017-12-25 21:28:47.022', 7)" 127.0.0.1:7111/rest/sql + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.t1 values('2017-12-25 21:28:48.022', 8)" 127.0.0.1:7111/rest/sql + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.t1 values('2017-12-25 21:28:49.022', 9)" 127.0.0.1:7111/rest/sql + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.t1 values('2017-12-25 21:28:50.022', 10)" 127.0.0.1:7111/rest/sql + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.t1 values('2017-12-25 21:28:51.022', 11)" 127.0.0.1:7111/rest/sql + +#27 +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' select * from d1.t1 ' 127.0.0.1:7111/rest/sql +print 27-> $system_content +if $system_content != @{"status":"succ","head":["ts","speed"],"column_meta":[["ts",9,8],["speed",4,4]],"data":[["2017-12-25 21:28:41.022",1],["2017-12-25 21:28:42.022",2],["2017-12-25 21:28:43.022",3],["2017-12-25 21:28:44.022",4],["2017-12-25 21:28:45.022",5],["2017-12-25 21:28:46.022",6],["2017-12-25 21:28:47.022",7],["2017-12-25 21:28:48.022",8],["2017-12-25 21:28:49.022",9],["2017-12-25 21:28:50.022",10],["2017-12-25 21:28:51.022",11]],"rows":11}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'create database d2' 127.0.0.1:7111/rest/sql +print 28-> $system_content +if $system_content != @{"status":"succ","head":["affected_rows"],"column_meta":[["affected_rows",4,4]],"data":[[0]],"rows":1}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' create table d2.t1 (ts timestamp, speed int)' 127.0.0.1:7111/rest/sql +print 29-> $system_content +if $system_content != @{"status":"succ","head":["affected_rows"],"column_meta":[["affected_rows",4,4]],"data":[[0]],"rows":1}@ then + return -1 +endi + +#30 +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d2.t1 values('2017-12-25 21:28:41.022', 1)" 127.0.0.1:7111/rest/sql +print 30-> $system_content +if $system_content != @{"status":"succ","head":["affected_rows"],"column_meta":[["affected_rows",4,4]],"data":[[1]],"rows":1}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' select * from d2.t1 ' 127.0.0.1:7111/rest/sql +print 31-> $system_content +if $system_content != @{"status":"succ","head":["ts","speed"],"column_meta":[["ts",9,8],["speed",4,4]],"data":[["2017-12-25 21:28:41.022",1]],"rows":1}@ then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/http/restful_insert.sim b/tests/script/general/http/restful_insert.sim new file mode 100644 index 0000000000000000000000000000000000000000..b77a1dd49785bf9ad1f86e803f63e2ba0e40a8d7 --- /dev/null +++ b/tests/script/general/http/restful_insert.sim @@ -0,0 +1,53 @@ +system sh/stop_dnodes.sh +sleep 2000 +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c http -v 1 +system sh/cfg.sh -n dnode1 -c httpEnableRecordSql -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ============================ dnode1 start + +print =============== step1 - prepare data +sql create database d1 +sql use d1 + +sql create table d1.table_rest0 (ts timestamp, i int) +sql create table d1.table_rest1 (ts timestamp, i int) +sql create table d1.table_rest2 (ts timestamp, i int) +sql create table d1.table_rest3 (ts timestamp, i int) +sql create table d1.table_rest4 (ts timestamp, i int) +sql create table d1.table_rest5 (ts timestamp, i int) +sql create table d1.table_rest6 (ts timestamp, i int) +sql create table d1.table_rest7 (ts timestamp, i int) +sql create table d1.table_rest8 (ts timestamp, i int) +sql create table d1.table_rest9 (ts timestamp, i int) + +print =============== step2 - login + +system_content curl 127.0.0.1:7111/rest/login/root/taosdata +print curl 127.0.0.1:7111/rest/login/root/taosdata -----> $system_content + +if $system_content != {"status":"succ","code":0,"desc":"/KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04"} then + return -1 +endi + +print =============== step3 - query data + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'insert into d1.table_rest1 values('now+1s', 1) d1.table_rest2 values('now+1s', 1) d1.table_rest3 values('now+1s', 1) d1.table_rest4 values('now+1s', 1) ' 127.0.0.1:7111/rest/sql +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'insert into d1.table_rest1 values('now+1s', 1) d1.table_rest2 values('now+1s', 1) d1.table_rest3 values('now+1s', 1) d1.table_rest4 values('now+1s', 1) ' 127.0.0.1:7111/rest/sql +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'insert into d1.table_rest1 values('now+1s', 1) d1.table_rest2 values('now+1s', 1) d1.table_rest3 values('now+1s', 1) d1.table_rest4 values('now+1s', 1) ' 127.0.0.1:7111/rest/sql +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'insert into d1.table_rest1 values('now+1s', 1) d1.table_rest2 values('now+1s', 1) d1.table_rest3 values('now+1s', 1) d1.table_rest4 values('now+1s', 1) ' 127.0.0.1:7111/rest/sql +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'insert into d1.table_rest1 values('now+1s', 1) d1.table_rest2 values('now+1s', 1) d1.table_rest3 values('now+1s', 1) d1.table_rest4 values('now+1s', 1) ' 127.0.0.1:7111/rest/sql +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'insert into d1.table_rest1 values('now+1s', 1) d1.table_rest2 values('now+1s', 1) d1.table_rest3 values('now+1s', 1) d1.table_rest4 values('now+1s', 1) ' 127.0.0.1:7111/rest/sql +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'insert into d1.table_rest1 values('now+1s', 1) d1.table_rest2 values('now+1s', 1) d1.table_rest3 values('now+1s', 1) d1.table_rest4 values('now+1s', 1) ' 127.0.0.1:7111/rest/sql + +print =============== step5 - query data + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select * from d1.table_rest1' 127.0.0.1:7111/rest/sql +print curl 127.0.0.1:7111/rest/sql -----> $system_content + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/http/restful_limit.sim b/tests/script/general/http/restful_limit.sim new file mode 100644 index 0000000000000000000000000000000000000000..48a4fdf7d3f90d8d58337992b0b8198cb43e953c --- /dev/null +++ b/tests/script/general/http/restful_limit.sim @@ -0,0 +1,46 @@ +system sh/stop_dnodes.sh +sleep 2000 +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ============================ dnode1 start + +print =============== step1 - prepare data + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = st + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol bigint, t1 bigint, t2 bigint, t3 bigint, t4 bigint, t5 bigint, t6 bigint, t7 bigint, t8 bigint, t9 bigint, t0 nchar(20)) TAGS(tgcol bigint) + +$i = 0 +while $i < 2 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < 2000 + $ms = $x . m + sql insert into $tb values (now + $ms , 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, '你好' ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'select * from db0.st0 limit 100' 127.0.0.1:7111/rest/sql +print curl 127.0.0.1:7111/rest/sql -----> $system_content + +#system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d "select * from db0.st0 where tbname in ('tb0', 'tb1') limit 1000" 127.0.0.1:7111/rest/sql +#print curl 127.0.0.1:7111/rest/sql -----> $system_content + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/http/taos.json b/tests/script/general/http/taos.json new file mode 100644 index 0000000000000000000000000000000000000000..abc25f19a2e43282a4e474b95387ccf9a6d6b077 --- /dev/null +++ b/tests/script/general/http/taos.json @@ -0,0 +1,23 @@ +{ + "hostIp": "192.168.100.128", + "connNum": 1, + "insertModel": "insertTable", + "waitTime": 0, + "tableDesc": "ts timestamp, i int", + "tablePrefix": "t", + "tablePerConn": 1, + "tableCreate": true, + "tableStart": 1, + "dbName": "db", + "dbReplica": 1, + "dbKeep": 3650, + "dbDays": 7, + "metricsName": "mt", + "tagNum": 10, + "dataNum": 1000, + "dataBegin": 1485878400000, + "dataInterval": 1000, + "dataBatch": 1000, + "dataInsert": true, + "dataRandom": false +} diff --git a/tests/script/general/http/taos_cloud.json b/tests/script/general/http/taos_cloud.json new file mode 100644 index 0000000000000000000000000000000000000000..c54186b65c58d7a390bb6bc6dbb6130fb09e4b70 --- /dev/null +++ b/tests/script/general/http/taos_cloud.json @@ -0,0 +1,21 @@ +{ + "hostIp": "192.168.100.128", + "connNum": 10, + "insertModel": "insertTable", + "waitTime": 0, + "tableDesc": "ts timestamp, i int", + "tablePrefix": "t", + "tablePerConn": 1, + "tableCreate": true, + "tableStart": 1, + "dbName": "db", + "dbKeep": 3650, + "metricsName": "mt", + "tagNum": 10, + "dataNum": 1000, + "dataBegin": 1517414400000, + "dataInterval": 1000, + "dataBatch": 1000, + "dataInsert": true, + "dataRandom": false +} diff --git a/tests/script/general/http/telegraf.json b/tests/script/general/http/telegraf.json new file mode 100644 index 0000000000000000000000000000000000000000..baf7c5e71148ab360119523740357707eb637b05 --- /dev/null +++ b/tests/script/general/http/telegraf.json @@ -0,0 +1,7 @@ +{ + "hostIp": "192.168.0.1", + "machineNum": 100, + "loopNum": 100, + "dbName": "db", + "dataBegin": 1485878400000 +} diff --git a/tests/script/general/http/telegraf.req b/tests/script/general/http/telegraf.req new file mode 100644 index 0000000000000000000000000000000000000000..1a3b73299974b31549a218e448e3278a3803d564 --- /dev/null +++ b/tests/script/general/http/telegraf.req @@ -0,0 +1,621 @@ +{ + "metrics": [{ + "fields": { + "result_code": 2, + "result_type": "connection_failed" + }, + "name": "net_response", + "tags": { + "host": "panshi-gsl", + "port": "80", + "protocol": "tcp", + "result": "connection_failed", + "server": "localhost" + }, + "timestamp": 1536750390000 + },{ + "fields": { + "load1": 0.27, + "load15": 0.09, + "load5": 0.22, + "n_cpus": 4, + "n_users": 4 + }, + "name": "system", + "tags": { + "host": "panshi-gsl" + }, + "timestamp": 1536750390000 + },{ + "fields": { + "uptime": 122 + }, + "name": "system", + "tags": { + "host": "panshi-gsl" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "uptime_format": " 0:02" + }, + "name": "system", + "tags": { + "host": "panshi-gsl" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "bytes_recv": 19964, + "bytes_sent": 11077, + "drop_in": 0, + "drop_out": 0, + "err_in": 0, + "err_out": 0, + "packets_recv": 237, + "packets_sent": 124 + }, + "name": "net", + "tags": { + "host": "panshi-gsl", + "interface": "eth0" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "usage_guest": 0, + "usage_guest_nice": 0, + "usage_idle": 99.39879759519036, + "usage_iowait": 0, + "usage_irq": 0, + "usage_nice": 0, + "usage_softirq": 0, + "usage_steal": 0, + "usage_system": 0.300601202404812, + "usage_user": 0.30060120240480753 + }, + "name": "cpu", + "tags": { + "cpu": "cpu0", + "host": "panshi-gsl" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "usage_guest": 0, + "usage_guest_nice": 0, + "usage_idle": 99.79959919839683, + "usage_iowait": 0, + "usage_irq": 0, + "usage_nice": 0, + "usage_softirq": 0, + "usage_steal": 0, + "usage_system": 0.2004008016032065, + "usage_user": 0 + }, + "name": "cpu", + "tags": { + "cpu": "cpu1", + "host": "panshi-gsl" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "usage_guest": 0, + "usage_guest_nice": 0, + "usage_idle": 99.7999999999999, + "usage_iowait": 0, + "usage_irq": 0, + "usage_nice": 0, + "usage_softirq": 0, + "usage_steal": 0, + "usage_system": 0.10000000000000217, + "usage_user": 0.09999999999999995 + }, + "name": "cpu", + "tags": { + "cpu": "cpu2", + "host": "panshi-gsl" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "usage_guest": 0, + "usage_guest_nice": 0, + "usage_idle": 99.7999999999999, + "usage_iowait": 0, + "usage_irq": 0, + "usage_nice": 0, + "usage_softirq": 0.09999999999999988, + "usage_steal": 0, + "usage_system": 0.09999999999999995, + "usage_user": 0 + }, + "name": "cpu", + "tags": { + "cpu": "cpu3", + "host": "panshi-gsl" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "usage_guest": 0, + "usage_guest_nice": 0, + "usage_idle": 99.74956173303289, + "usage_iowait": 0, + "usage_irq": 0, + "usage_nice": 0, + "usage_softirq": 0.025043826696719312, + "usage_steal": 0, + "usage_system": 0.12521913348359823, + "usage_user": 0.10017530678687725 + }, + "name": "cpu", + "tags": { + "cpu": "cpu-total", + "host": "panshi-gsl" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "icmp_inaddrmaskreps": 0, + "icmp_inaddrmasks": 0, + "icmp_indestunreachs": 1, + "icmp_inechoreps": 0, + "icmp_inechos": 0, + "icmp_inerrors": 0, + "icmp_inmsgs": 1, + "icmp_inparmprobs": 0, + "icmp_inredirects": 0, + "icmp_insrcquenchs": 0, + "icmp_intimeexcds": 0, + "icmp_intimestampreps": 0, + "icmp_intimestamps": 0, + "icmp_outaddrmaskreps": 0, + "icmp_outaddrmasks": 0, + "icmp_outdestunreachs": 5, + "icmp_outechoreps": 0, + "icmp_outechos": 0, + "icmp_outerrors": 0, + "icmp_outmsgs": 5, + "icmp_outparmprobs": 0, + "icmp_outredirects": 0, + "icmp_outsrcquenchs": 0, + "icmp_outtimeexcds": 0, + "icmp_outtimestampreps": 0, + "icmp_outtimestamps": 0, + "icmpmsg_intype3": 1, + "icmpmsg_outtype3": 5, + "ip_defaultttl": 64, + "ip_forwarding": 2, + "ip_forwdatagrams": 0, + "ip_fragcreates": 0, + "ip_fragfails": 0, + "ip_fragoks": 0, + "ip_inaddrerrors": 0, + "ip_indelivers": 132, + "ip_indiscards": 0, + "ip_inhdrerrors": 0, + "ip_inreceives": 132, + "ip_inunknownprotos": 0, + "ip_outdiscards": 0, + "ip_outnoroutes": 40, + "ip_outrequests": 134, + "ip_reasmfails": 0, + "ip_reasmoks": 0, + "ip_reasmreqds": 0, + "ip_reasmtimeout": 0, + "tcp_activeopens": 11, + "tcp_attemptfails": 11, + "tcp_currestab": 0, + "tcp_estabresets": 0, + "tcp_inerrs": 0, + "tcp_insegs": 22, + "tcp_maxconn": -1, + "tcp_outrsts": 11, + "tcp_outsegs": 22, + "tcp_passiveopens": 0, + "tcp_retranssegs": 0, + "tcp_rtoalgorithm": 1, + "tcp_rtomax": 120000, + "tcp_rtomin": 200, + "udp_indatagrams": 101, + "udp_inerrors": 0, + "udp_noports": 5, + "udp_outdatagrams": 109, + "udp_rcvbuferrors": 0, + "udp_sndbuferrors": 0, + "udplite_indatagrams": 0, + "udplite_inerrors": 0, + "udplite_noports": 0, + "udplite_outdatagrams": 0, + "udplite_rcvbuferrors": 0, + "udplite_sndbuferrors": 0 + }, + "name": "net", + "tags": { + "host": "panshi-gsl", + "interface": "all" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "io_time": 44, + "iops_in_progress": 0, + "read_bytes": 569344, + "read_time": 44, + "reads": 108, + "weighted_io_time": 44, + "write_bytes": 0, + "write_time": 0, + "writes": 0 + }, + "name": "diskio", + "tags": { + "host": "panshi-gsl", + "name": "sda5" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "io_time": 4900, + "iops_in_progress": 0, + "read_bytes": 262294528, + "read_time": 13607, + "reads": 8122, + "weighted_io_time": 27970, + "write_bytes": 12054528, + "write_time": 14369, + "writes": 1073 + }, + "name": "diskio", + "tags": { + "host": "panshi-gsl", + "name": "sda" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "io_time": 4874, + "iops_in_progress": 0, + "read_bytes": 261522432, + "read_time": 13538, + "reads": 7963, + "weighted_io_time": 27901, + "write_bytes": 12054528, + "write_time": 14369, + "writes": 1073 + }, + "name": "diskio", + "tags": { + "host": "panshi-gsl", + "name": "sda1" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "io_time": 15, + "iops_in_progress": 0, + "read_bytes": 2048, + "read_time": 15, + "reads": 2, + "weighted_io_time": 15, + "write_bytes": 0, + "write_time": 0, + "writes": 0 + }, + "name": "diskio", + "tags": { + "host": "panshi-gsl", + "name": "sda2" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "free": 4106956800, + "inodes_free": 526746, + "inodes_total": 752192, + "inodes_used": 225446, + "total": 12112691200, + "used": 7390433280, + "used_percent": 64.27922535963918 + }, + "name": "disk", + "tags": { + "device": "rootfs", + "fstype": "rootfs", + "host": "panshi-gsl", + "mode": "rw", + "path": "/" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "free": 4106956800, + "inodes_free": 526746, + "inodes_total": 752192, + "inodes_used": 225446, + "total": 12112691200, + "used": 7390433280, + "used_percent": 64.27922535963918 + }, + "name": "disk", + "tags": { + "device": "disk/by-uuid/d4becabf-b49c-4c1c-a4ea-b2f593018766", + "fstype": "ext3", + "host": "panshi-gsl", + "mode": "rw", + "path": "/" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "boot_time": 1536750268, + "context_switches": 135890, + "entropy_avail": 514, + "interrupts": 112317, + "processes_forked": 3595 + }, + "name": "kernel", + "tags": { + "host": "panshi-gsl" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "active": 211845120, + "available": 3829399552, + "available_percent": 92.37877479393148, + "buffered": 12083200, + "cached": 254320640, + "commit_limit": 2648322048, + "committed_as": 549027840, + "dirty": 49152, + "free": 3562995712, + "high_free": 0, + "high_total": 0, + "huge_page_size": 2097152, + "huge_pages_free": 0, + "huge_pages_total": 0, + "inactive": 214351872, + "low_free": 0, + "low_total": 0, + "mapped": 81797120, + "page_tables": 13062144, + "shared": 2682880, + "slab": 33386496, + "swap_cached": 0, + "swap_free": 575660032, + "swap_total": 575660032, + "total": 4145324032, + "used": 315924480, + "used_percent": 7.621225206068523, + "vmalloc_chunk": 35184198369280, + "vmalloc_total": 35184372087808, + "vmalloc_used": 168906752, + "wired": 0, + "write_back": 0, + "write_back_tmp": 0 + }, + "name": "mem", + "tags": { + "host": "panshi-gsl" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "IpExtInBcastOctets": 1291, + "IpExtInBcastPkts": 6, + "IpExtInMcastOctets": 0, + "IpExtInMcastPkts": 0, + "IpExtInNoRoutes": 0, + "IpExtInOctets": 12160, + "IpExtInTruncatedPkts": 0, + "IpExtOutBcastOctets": 0, + "IpExtOutBcastPkts": 0, + "IpExtOutMcastOctets": 0, + "IpExtOutMcastPkts": 0, + "IpExtOutOctets": 9881, + "TcpExtArpFilter": 0, + "TcpExtDelayedACKLocked": 0, + "TcpExtDelayedACKLost": 0, + "TcpExtDelayedACKs": 0, + "TcpExtEmbryonicRsts": 0, + "TcpExtListenDrops": 0, + "TcpExtListenOverflows": 0, + "TcpExtLockDroppedIcmps": 0, + "TcpExtOfoPruned": 0, + "TcpExtOutOfWindowIcmps": 0, + "TcpExtPAWSActive": 0, + "TcpExtPAWSEstab": 0, + "TcpExtPAWSPassive": 0, + "TcpExtPruneCalled": 0, + "TcpExtRcvPruned": 0, + "TcpExtSyncookiesFailed": 0, + "TcpExtSyncookiesRecv": 0, + "TcpExtSyncookiesSent": 0, + "TcpExtTCPAbortFailed": 0, + "TcpExtTCPAbortOnClose": 0, + "TcpExtTCPAbortOnData": 0, + "TcpExtTCPAbortOnLinger": 0, + "TcpExtTCPAbortOnMemory": 0, + "TcpExtTCPAbortOnSyn": 0, + "TcpExtTCPAbortOnTimeout": 0, + "TcpExtTCPDSACKIgnoredNoUndo": 0, + "TcpExtTCPDSACKIgnoredOld": 0, + "TcpExtTCPDSACKOfoRecv": 0, + "TcpExtTCPDSACKOfoSent": 0, + "TcpExtTCPDSACKOldSent": 0, + "TcpExtTCPDSACKRecv": 0, + "TcpExtTCPDSACKUndo": 0, + "TcpExtTCPDirectCopyFromBacklog": 0, + "TcpExtTCPDirectCopyFromPrequeue": 0, + "TcpExtTCPFACKReorder": 0, + "TcpExtTCPFastRetrans": 0, + "TcpExtTCPForwardRetrans": 0, + "TcpExtTCPFullUndo": 0, + "TcpExtTCPHPAcks": 0, + "TcpExtTCPHPHits": 0, + "TcpExtTCPHPHitsToUser": 0, + "TcpExtTCPLoss": 0, + "TcpExtTCPLossFailures": 0, + "TcpExtTCPLossUndo": 0, + "TcpExtTCPLostRetransmit": 0, + "TcpExtTCPMD5NotFound": 0, + "TcpExtTCPMD5Unexpected": 0, + "TcpExtTCPMemoryPressures": 0, + "TcpExtTCPPartialUndo": 0, + "TcpExtTCPPrequeueDropped": 0, + "TcpExtTCPPrequeued": 0, + "TcpExtTCPPureAcks": 0, + "TcpExtTCPRcvCollapsed": 0, + "TcpExtTCPRenoFailures": 0, + "TcpExtTCPRenoRecovery": 0, + "TcpExtTCPRenoRecoveryFail": 0, + "TcpExtTCPRenoReorder": 0, + "TcpExtTCPSACKDiscard": 0, + "TcpExtTCPSACKReneging": 0, + "TcpExtTCPSACKReorder": 0, + "TcpExtTCPSackFailures": 0, + "TcpExtTCPSackMerged": 0, + "TcpExtTCPSackRecovery": 0, + "TcpExtTCPSackRecoveryFail": 0, + "TcpExtTCPSackShiftFallback": 0, + "TcpExtTCPSackShifted": 0, + "TcpExtTCPSchedulerFailed": 0, + "TcpExtTCPSlowStartRetrans": 0, + "TcpExtTCPSpuriousRTOs": 0, + "TcpExtTCPTSReorder": 0, + "TcpExtTCPTimeouts": 0, + "TcpExtTW": 0, + "TcpExtTWKilled": 0, + "TcpExtTWRecycled": 0 + }, + "name": "nstat", + "tags": { + "host": "panshi-gsl", + "name": "netstat" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "IcmpInAddrMaskReps": 0, + "IcmpInAddrMasks": 0, + "IcmpInDestUnreachs": 1, + "IcmpInEchoReps": 0, + "IcmpInEchos": 0, + "IcmpInErrors": 0, + "IcmpInMsgs": 1, + "IcmpInParmProbs": 0, + "IcmpInRedirects": 0, + "IcmpInSrcQuenchs": 0, + "IcmpInTimeExcds": 0, + "IcmpInTimestampReps": 0, + "IcmpInTimestamps": 0, + "IcmpMsgInType3": 1, + "IcmpMsgOutType3": 5, + "IcmpOutAddrMaskReps": 0, + "IcmpOutAddrMasks": 0, + "IcmpOutDestUnreachs": 5, + "IcmpOutEchoReps": 0, + "IcmpOutEchos": 0, + "IcmpOutErrors": 0, + "IcmpOutMsgs": 5, + "IcmpOutParmProbs": 0, + "IcmpOutRedirects": 0, + "IcmpOutSrcQuenchs": 0, + "IcmpOutTimeExcds": 0, + "IcmpOutTimestampReps": 0, + "IcmpOutTimestamps": 0, + "IpDefaultTTL": 64, + "IpForwDatagrams": 0, + "IpForwarding": 2, + "IpFragCreates": 0, + "IpFragFails": 0, + "IpFragOKs": 0, + "IpInAddrErrors": 0, + "IpInDelivers": 132, + "IpInDiscards": 0, + "IpInHdrErrors": 0, + "IpInReceives": 132, + "IpInUnknownProtos": 0, + "IpOutDiscards": 0, + "IpOutNoRoutes": 40, + "IpOutRequests": 134, + "IpReasmFails": 0, + "IpReasmOKs": 0, + "IpReasmReqds": 0, + "IpReasmTimeout": 0, + "TcpActiveOpens": 12, + "TcpAttemptFails": 12, + "TcpCurrEstab": 0, + "TcpEstabResets": 0, + "TcpInErrs": 0, + "TcpInSegs": 24, + "TcpMaxConn": -1, + "TcpOutRsts": 12, + "TcpOutSegs": 24, + "TcpPassiveOpens": 0, + "TcpRetransSegs": 0, + "TcpRtoAlgorithm": 1, + "TcpRtoMax": 120000, + "TcpRtoMin": 200, + "UdpInDatagrams": 101, + "UdpInErrors": 0, + "UdpLiteInDatagrams": 0, + "UdpLiteInErrors": 0, + "UdpLiteNoPorts": 0, + "UdpLiteOutDatagrams": 0, + "UdpLiteRcvbufErrors": 0, + "UdpLiteSndbufErrors": 0, + "UdpNoPorts": 5, + "UdpOutDatagrams": 109, + "UdpRcvbufErrors": 0, + "UdpSndbufErrors": 0 + }, + "name": "nstat", + "tags": { + "host": "panshi-gsl", + "name": "snmp" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "blocked": 0, + "dead": 0, + "idle": 0, + "paging": 0, + "running": 1, + "sleeping": 181, + "stopped": 0, + "total": 182, + "total_threads": 280, + "unknown": 0, + "zombies": 0 + }, + "name": "processes", + "tags": { + "host": "panshi-gsl" + }, + "timestamp": 1536750390000 + }] +} \ No newline at end of file diff --git a/tests/script/general/http/telegraf.sim b/tests/script/general/http/telegraf.sim new file mode 100644 index 0000000000000000000000000000000000000000..9fc153b2329bac70efe2506814af4a60b89966ae --- /dev/null +++ b/tests/script/general/http/telegraf.sim @@ -0,0 +1,292 @@ +system sh/stop_dnodes.sh +sleep 2000 +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c http -v 1 +system sh/cfg.sh -n dnode1 -c httpEnableRecordSql -v 1 +system sh/cfg.sh -n dnode1 -c telegrafUseFieldNum -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ============================ dnode1 start + +print =============== step1 - parse +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1535784122}' 127.0.0.1:7111/telegraf/ +print $system_content + +if $system_content != @{"status":"error","code":4448,"desc":"database name can not be null"}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select * from d1.table_admin' -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1535784122}' 127.0.0.1:7111/telegraf/ +print $system_content + +if $system_content != @{"status":"error","code":4448,"desc":"database name can not be null"}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select * from d1.table_admin' -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1535784122}' 127.0.0.1:7111/telegraf/d123456789012345678901234567890123456 +print $system_content + +if $system_content != @{"status":"error","code":4449,"desc":"database name too long"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[]' 127.0.0.1:7111/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":4453,"desc":"metric name not find"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{}' 127.0.0.1:7111/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":4453,"desc":"metric name not find"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{}]' 127.0.0.1:7111/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":4453,"desc":"metric name not find"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"metrics": []}' 127.0.0.1:7111/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":4451,"desc":"metrics size is 0"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"metrics": [{}]}' 127.0.0.1:7111/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":4453,"desc":"metric name not find"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"metrics": 12}' 127.0.0.1:7111/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":4451,"desc":"metrics size is 0"}@ then + return -1 +endi + +#system_content curl -u root:taosdata -d '{"metrics": [{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}]}' 127.0.0.1:7111/telegraf/db/root/taosdata1 +#print $system_content + +#if $system_content != @{"status":"error","code":4452,"desc":"metrics size can not more than 50"}@ then +# return -1 +#endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1535784122}' 127.0.0.1:7111/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":4453,"desc":"metric name not find"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":111,"tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1535784122}' 127.0.0.1:7111/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":4454,"desc":"metric name type should be string"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1535784122}' 127.0.0.1:7111/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":4455,"desc":"metric name length is 0"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"a1234567890123456789012345678901234a1234567890123456789012345678901234a1234567890123456789012345678901234a1234567890123456789012345678901234a1234567890123456789012345678901234a1234567890123456789012345678901234a1234567890123456789012345678901234a1234567890123456789012345678901234a1234567890123456789012345678901234a1234567890123456789012345678901234a1234567890123456789012345678901234a1234567890123456789012345678901234","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1535784122}' 127.0.0.1:7111/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":4456,"desc":"metric name length too long"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"windows","instance":"1","objectname":"Processor"}}' 127.0.0.1:7111/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":4457,"desc":"timestamp not find"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":""}' 127.0.0.1:7111/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":4458,"desc":"timestamp type should be integer"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":-1}' 127.0.0.1:7111/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":4459,"desc":"timestamp value smaller than 0"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","timestamp":1535784122}' 127.0.0.1:7111/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":4460,"desc":"tags not find"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{},"timestamp":1535784122}' 127.0.0.1:7111/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":4461,"desc":"tags size is 0"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":"","timestamp":1535784122}' 127.0.0.1:7111/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":4461,"desc":"tags size is 0"}@ then + return -1 +endi + +#system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"windows","instance":"1","objectname":"Processor","host":"windows","instance":"1","objectname":"Processor","objectname":"Processor"},"timestamp":1535784122}' 127.0.0.1:7111/telegraf/db/root/taosdata +#print $system_content + +#if $system_content != @{"status":"error","code":4461,"desc":"tags size too long"}@ then +# return -1 +#endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{},"timestamp":1535784122}' 127.0.0.1:7111/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":4461,"desc":"tags size is 0"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"":"windows"},"timestamp":1535784122}' 127.0.0.1:7111/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":4464,"desc":"tag name is null"}@ then + return -1 +endi + +#system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host111111111111222222222222222222222":""},"timestamp":1535784122}' 127.0.0.1:7111/telegraf/db/root/taosdata1 +#print $system_content + +#if $system_content != @{"status":"error","code":4465,"desc":"tag name length too long"}@ then +# return -1 +#endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":true},"timestamp":1535784122}' 127.0.0.1:7111/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":4466,"desc":"tag value type should be number or string"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":""},"timestamp":1535784122}' 127.0.0.1:7111/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":4467,"desc":"tag value is null"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"5022":"111"},"timestamp":1535784122}' 127.0.0.1:7111/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":4468,"desc":"table is null"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"host111111111111222222222222222222222host111111111111222222222222222222222host111111111111222222222222222222222host111111111111222222222222222222222host111111111111222222222222222222222host111111111111222222222222222222222host111111111111222222222222222222222host111111111111222222222222222222222"},"timestamp":1535784122}' 127.0.0.1:7111/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":4469,"desc":"table name length too long"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{},"name":"win_cpu","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1535784122}' 127.0.0.1:7111/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":4471,"desc":"fields size is 0"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{"":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1535784122}' 127.0.0.1:7111/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":4474,"desc":"field name is null"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":"","Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1535784122}' 127.0.0.1:7111/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":4477,"desc":"field value is null"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":true,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1535784122}' 127.0.0.1:7111/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":4476,"desc":"field value type should be number or string"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1564641722000}' 127.0.0.1:7111/telegraf/db + +print $system_content + +if $system_content != @{"metrics":[{"metric":"win_cpu","stable":"win_cpu","table":"win_cpu_windows_1_Processor","timestamp":"1564641722000","affected_rows":1,"status":"succ"}]}@ then + return -1 +endi + +sleep 2000 + +print =============== step2 - insert single data +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1564641722000}' 127.0.0.1:7111/telegraf/db/ + +print $system_content + +#if $system_content != @{"metrics":[{"metric":"win_cpu","stable":"win_cpu","table":"win_cpu_windows_1_Processor","timestamp":"1564641722000","affected_rows":1,"status":"succ"}]}@ then +# return -1 +#endi + +system_content curl -u root:taosdata -d 'select * from db.win_cpu_windows_1_Processor' 127.0.0.1:7111/rest/sql/ + +print $system_content + +#if $system_content != @{"status":"succ","head":["ts","f_percent_dpc_time","f_percent_idle_time","f_percent_interrupt_time","f_percent_privileged_time","f_percent_processor_time","f_percent_user_time"],"data":[["2019-08-01 06:42:02.000",0.000000000,95.598305000,0.000000000,0.000000000,0.000000000,0.000000000]],"rows":1}@ then +# return -1 +#endi + +print =============== step3 - multi-query data +system_content curl -u root:taosdata -d '{"metrics": [{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"window1","instance":"1","objectname":"Processor"},"timestamp":1564641723000},{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"window2","instance":"1","objectname":"Processor"},"timestamp":1564641723000}]}' 127.0.0.1:7111/telegraf/db/ + +print $system_content + +if $system_content != @{"metrics":[{"metric":"win_cpu","stable":"win_cpu","table":"win_cpu_window1_1_Processor","timestamp":"1564641723000","affected_rows":1,"status":"succ"},{"metric":"win_cpu","stable":"win_cpu","table":"win_cpu_window2_1_Processor","timestamp":"1564641723000","affected_rows":1,"status":"succ"}]}@ then + return -1 +endi + +system_content curl -u root:taosdata -d 'select * from db.win_cpu_window1_1_Processor' 127.0.0.1:7111/rest/sql/ + +print $system_content + +#if $system_content != @{"status":"succ","head":["ts","f_percent_dpc_time","f_percent_idle_time","f_percent_interrupt_time","f_percent_privileged_time","f_percent_processor_time","f_percent_user_time"],"data":[["2019-08-01 14:42:03.000",0.000000000,95.598305000,0.000000000,0.000000000,0.000000000,0.000000000]],"rows":1}@ then +# return -1 +#endi + +system_content curl -u root:taosdata -d 'select count(*) from db.win_cpu' 127.0.0.1:7111/rest/sql/ + +print $system_content + +if $system_content != @{"status":"succ","head":["count(*)"],"column_meta":[["count(*)",5,8]],"data":[[3]],"rows":1}@ then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/http/telegrafTest.go b/tests/script/general/http/telegrafTest.go new file mode 100644 index 0000000000000000000000000000000000000000..b8cbb43ce81a75f6c3ed3978d44d3479e9d2d844 --- /dev/null +++ b/tests/script/general/http/telegrafTest.go @@ -0,0 +1,223 @@ +package main + +import ( + "bytes" + "encoding/json" + "fmt" + "strings" + "io/ioutil" + "net/http" + "os" + "sync" + "sync/atomic" + "time" + "flag" +) + +var ( + token string + url string + config Config + request int64 + period int64 + errorNum int64 + template string +) + +type Config struct { + HostIp string `json:"hostIp"` + MachineNum int `json:"machineNum"` + LoopNum int `json:"loopNum"` + DbName string `json:"dbName"` + DataBegin int64 `json:"dataBegin"` +} + +type TokenResult struct { + Status string `json:"status"` + Code int `json:"code"` + Desc string `json:"desc"` +} + +type JsonResult struct { + Status string `json:"status"` + Code int `json:"code"` +} + +func readConf(filename string) { + file, err := os.Open(filename) + if err != nil { + println("%s not found", filename) + panic(err) + } + defer file.Close() + + dec := json.NewDecoder(file) + err = dec.Decode(&config) + if err != nil { + println("%s parse error", filename) + panic(err) + } + + request = 0 + period = 0 + errorNum = 0 + + fmt.Println("================config parameters======================") + fmt.Println("HostIp:", config.HostIp) + fmt.Println("MachineNum:", config.MachineNum) + fmt.Println("LoopNum:", config.LoopNum) + fmt.Println("dbName:", config.DbName) + fmt.Println("dataBegin:", config.DataBegin) + + fmt.Println("================http token=============================") + token, err = getToken() + url = fmt.Sprintf("http://%s:%d/telegraf/%s", config.HostIp, 6020, config.DbName) + + fmt.Println("httpToken:", token) + fmt.Println("httpUrl:", url) + + if err != nil { + panic(err) + } +} + +func readReq(filename string) { + file, err := os.Open(filename) + if err != nil { + println("%s not found", filename) + panic(err) + } + defer file.Close() + + data, _ := ioutil.ReadAll(file) + + template = string(data[:]) + + //fmt.Println(template) +} + +func getToken() (string, error) { + resp, err := http.Get(fmt.Sprintf("http://%s:%d/rest/login/%s/%s", config.HostIp, 6020, "root", "taosdata")) + if err != nil { + return "", err + } + + defer resp.Body.Close() + + var tokenResult TokenResult + + data, err := ioutil.ReadAll(resp.Body) + + if err != nil { + return "", err + } + + err = json.Unmarshal(data, &tokenResult) + if err != nil { + return "", err + } + + if tokenResult.Status != "succ" { + fmt.Println("get http token failed") + fmt.Println(tokenResult) + return "", err + } + + return tokenResult.Desc, nil +} + +func exec(client *http.Client, sql string) { + for times := 0; times < 10; times++ { + + req, err1 := http.NewRequest("POST", url, bytes.NewReader([]byte(sql))) + if err1 != nil { + continue + } + req.Header.Add("Authorization", "Taosd "+token) + + begin := time.Now() + resp, err := client.Do(req) + + if err != nil { + continue + } + + data, err := ioutil.ReadAll(resp.Body) + if err != nil { + fmt.Println(data) + resp.Body.Close() + continue + } + + spend := (time.Since(begin).Nanoseconds()) + + var jsonResult JsonResult + err = json.Unmarshal(data, &jsonResult) + if err != nil { + fmt.Println("parse json error: ", string(data[:])) + resp.Body.Close() + continue + } + + + atomic.AddInt64(&request, 1) + atomic.AddInt64(&period, spend) + + if request%1000 == 0 && request != 0 { + requestAvg := float64(period) / float64(1000000) / float64(request) + qps := float64(1000) / float64(requestAvg) * float64(config.MachineNum) + dps := qps * float64(22) + fmt.Println("====== req:", request, ", error:", errorNum, ", qps:", int64(qps), ", wait:", int64(requestAvg), "ms", ", data per second:", int64(dps)) + } + return + } + //fmt.Println("xxxx>sql:", sql, ", retryTimes:", 10) + fmt.Println("exec sql failed") + errorNum++ +} + +func writeData(wg *sync.WaitGroup, tbIndex int) { + defer wg.Done() + client := &http.Client{} + + tbName := fmt.Sprintf("t%d", tbIndex) + + for j := 0; j < config.LoopNum; j++ { + tmVal := fmt.Sprintf("%d", int64(j)*int64(10000) + config.DataBegin) + //fmt.Println(tmVal) + + req1 := strings.Replace(template, "panshi-gsl", tbName, -1) + req2 := strings.Replace(req1, "1536750390000", tmVal, -1) + + //fmt.Println(req2) + exec(client, req2) + } +} + +func main() { + filename := flag.String("config", "telegraf.json", "config file name") + + flag.Parse() + + readReq("telegraf.req") + + readConf(*filename) + + fmt.Println("\n================telegraf test start======================") + + var wg sync.WaitGroup + + for i := 0; i < config.MachineNum; i++ { + wg.Add(1) + go writeData(&wg, i) + } + + wg.Wait() + + fmt.Println("\n================telegraf test stop ======================") + + requestAvg := float64(period) / float64(1000000) / float64(request) + qps := float64(1000) / float64(requestAvg) * float64(config.MachineNum) + dps := qps * float64(22) + fmt.Println("====== req:", request, ", error:", errorNum, ", qps:", int64(qps), ", wait:", int64(requestAvg), "ms", ", data per second:", int64(dps)) +} diff --git a/tests/script/general/http/telegraf_help.txt b/tests/script/general/http/telegraf_help.txt new file mode 100644 index 0000000000000000000000000000000000000000..a2e6d6e49c9348b8aa257f0362c0baf0875ada01 --- /dev/null +++ b/tests/script/general/http/telegraf_help.txt @@ -0,0 +1,24 @@ +1. +main.goɿִļtelegrafTest +2.ִ +./telegrafTest +3. telegraf.jsonļ + hostIp TDengineIPַ + machineNum ģĻ + loopNum ÿĴ + dbName ݿ + dataBegin ģݵĿʼʱ +4.telegraf.reqͨ䣩 + 1滻panshi-gsl1536750380000ַhttp + 2ͨhttp͸TDengine +5.ע + 1޸ļ/etc/taos/taos.cfg + httpDebugFlag Ϊ131131-httpDebug,135-httpDebug + httpMaxThreads ջã÷ΧΪ1-cpu cores) + httpCacheSessions Ϊܵhttpӵ2 + maxVnodeConnections Ϊ100000 + maxMeterConnections Ϊ100000 + maxShellConns Ϊ100000 + maxMgmtConnections Ϊ100000 + 2linux + ulimit -n 600000 \ No newline at end of file diff --git a/tests/script/general/http/testSuite.sim b/tests/script/general/http/testSuite.sim new file mode 100644 index 0000000000000000000000000000000000000000..f35362bf070a11e2fa2f1dd870acfe2074c0cbf5 --- /dev/null +++ b/tests/script/general/http/testSuite.sim @@ -0,0 +1,10 @@ +run general/http/autocreate.sim +run general/http/chunked.sim +run general/http/restful.sim +run general/http/restful_insert.sim +run general/http/restful_limit.sim +run general/http/restful_full.sim +run general/http/prepare.sim +run general/http/telegraf.sim +run general/http/grafana_bug.sim +run general/http/grafana.sim diff --git a/tests/script/general/import/basic.sim b/tests/script/general/import/basic.sim new file mode 100644 index 0000000000000000000000000000000000000000..f72d132ca39cdf0138b0c79d94857d6d646bccb5 --- /dev/null +++ b/tests/script/general/import/basic.sim @@ -0,0 +1,146 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 10 + +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2000 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 2000 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 2000 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 2000 + +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode3 -c walLevel -v 1 +system sh/cfg.sh -n dnode4 -c walLevel -v 1 + +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +sql create database ibadb +sql use ibadb +sql create table tb(ts timestamp, i int) + +print ================= step1 + +sql import into tb values(1564641710000, 10000) +sql select * from tb; +if $rows != 1 then + return -1 +endi + +print ================= step2 +sql insert into tb values(1564641708000, 8000) +sql select * from tb; +if $rows != 2 then + return -1 +endi + +print ================= step3 +sql insert into tb values(1564641720000, 20000) +sql select * from tb; +if $rows != 3 then + return -1 +endi + +print ================= step4 +sql import into tb values(1564641708000, 8000) +sql import into tb values(1564641715000, 15000) +sql import into tb values(1564641730000, 30000) +sql select * from tb; +if $rows != 5 then + return -1 +endi + +print ================= step5 +sql insert into tb values(1564641708000, 8000) +sql insert into tb values(1564641714000, 14000) +sql insert into tb values(1564641725000, 25000) +sql insert into tb values(1564641740000, 40000) +sql select * from tb; +if $rows != 8 then + return -1 +endi + +print ================= step6 +sql import into tb values(1564641707000, 7000) +sql import into tb values(1564641712000, 12000) +sql import into tb values(1564641723000, 23000) +sql import into tb values(1564641734000, 34000) +sql import into tb values(1564641750000, 50000) +sql select * from tb; +if $rows != 13 then + return -1 +endi + +print ================= step7 +sql import into tb values(1564641707001, 7001) +sql import into tb values(1564641712001, 12001) +sql import into tb values(1564641723001, 23001) +sql import into tb values(1564641734001, 34001) +sql import into tb values(1564641750001, 50001) +sql select * from tb; +if $rows != 18 then + return -1 +endi + +print ================= step8 +sql insert into tb values(1564641708002, 8002) +sql insert into tb values(1564641714002, 14002) +sql insert into tb values(1564641725002, 25002) +sql insert into tb values(1564641900000, 200000) +sql select * from tb; +if $rows != 22 then + return -1 +endi + +print ================= step9 only insert last one +sql import into tb values(1564641705000, 5000)(1564641718000, 18000)(1564642400000, 700000) +sql select * from tb; +if $rows != 25 then + return -1 +endi + +print ================= step10 +sql import into tb values(1564641705000, 5000)(1564641718000, 18000)(1564642400000, 70000) +sql select * from tb; +if $rows != 25 then + return -1 +endi + +print ================= step11 +sql import into tb values(1564642400000, 700000) +sql select * from tb; +if $rows != 25 then + return -1 +endi + +print ================= step12 +sql import into tb values(1564641709527, 9527)(1564641709527, 9528) +sql select * from tb; +print rows=> $rows +if $rows != 26 then + return -1 +endi + +print ================= step13 +sql import into tb values(1564641709898, 9898)(1564641709897, 9897) +sql select * from tb; +print rows=> $rows +if $rows != 28 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/import/commit.sim b/tests/script/general/import/commit.sim new file mode 100644 index 0000000000000000000000000000000000000000..3b4055d7128442ee67621ffafa9869527b7a3801 --- /dev/null +++ b/tests/script/general/import/commit.sim @@ -0,0 +1,91 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 10 + +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2000 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 2000 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 2000 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 2000 + +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode3 -c walLevel -v 1 +system sh/cfg.sh -n dnode4 -c walLevel -v 1 + +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ========= step1 +sql create database ic1db days 7; +sql create table ic1db.tb(ts timestamp, s int); +sql insert into ic1db.tb values(now-30d, -30); +sql insert into ic1db.tb values(now-20d, -20); +sql insert into ic1db.tb values(now-10d, -10); +sql insert into ic1db.tb values(now-5d, -5); +sql insert into ic1db.tb values(now+1m, 1); +sql insert into ic1db.tb values(now+2m, 2); +sql insert into ic1db.tb values(now+3m, 6); +sql insert into ic1db.tb values(now+4m, 8); +sql insert into ic1db.tb values(now+5m, 10); +sql insert into ic1db.tb values(now+6m, 12); +sql insert into ic1db.tb values(now+7m, 14); +sql insert into ic1db.tb values(now+8m, 16); +sql select * from ic1db.tb; +if $rows != 12 then + return -1 +endi + +print ========= step2 +sql create database ic2db days 7; +sql create table ic2db.tb(ts timestamp, s int); +sql insert into ic2db.tb values(now, 0); +sql import into ic2db.tb values(now-30d, -30); +sql import into ic2db.tb values(now-20d, -20); +sql import into ic2db.tb values(now-10d, -10); +sql import into ic2db.tb values(now-5d, -5); +sql import into ic2db.tb values(now+1m, 1); +sql import into ic2db.tb values(now+2m, 2); +sql import into ic2db.tb values(now+3m, 6); +sql import into ic2db.tb values(now+4m, 8); +sql import into ic2db.tb values(now+5m, 10); +sql import into ic2db.tb values(now+6m, 12); +sql import into ic2db.tb values(now+7m, 14); +sql import into ic2db.tb values(now+8m, 16); +sql select * from ic2db.tb; +if $rows != 13 then + return -1 +endi + +print ========= step3 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +print ========= step4 +sql select * from ic2db.tb; +if $rows != 13 then + print expect 13, actual:$rows + return -1 +endi + +sql select * from ic1db.tb; +if $rows != 12 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/import/large.sim b/tests/script/general/import/large.sim new file mode 100644 index 0000000000000000000000000000000000000000..23fbcc75eae55623e3ed2afa8b8ebf42c77a1012 --- /dev/null +++ b/tests/script/general/import/large.sim @@ -0,0 +1,98 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 10 + +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2000 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 2000 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 2000 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 2000 + +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode3 -c walLevel -v 1 +system sh/cfg.sh -n dnode4 -c walLevel -v 1 + +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +sql create database db +sql use db +sql create table tb1(ts timestamp, i int, j float, k double) + +print ================= step1 + +$i = 0 +$timestamp = 1564641700000 +while $i < 1000 + + $val = 10 * $i + $val = $val + 2 + $ts = $timestamp + 200 + sql insert into tb1 values ( $ts , $val , $val , $val ) + + $val = 10 * $i + $val = $val + 3 + $ts = $timestamp + 300 + sql insert into tb1 values ( $ts , $val , $val , $val ) + + $val = 10 * $i + $val = $val + 4 + $ts = $timestamp + 400 + sql insert into tb1 values ( $ts , $val , $val , $val ) + + $val = 10 * $i + $val = $val + 5 + $ts = $timestamp + 500 + sql insert into tb1 values ( $ts , $val , $val , $val ) + + $val = 10 * $i + $val = $val + 6 + $ts = $timestamp + 600 + sql insert into tb1 values ( $ts , $val , $val , $val ) + + $val = 10 * $i + $val = $val + 7 + $ts = $timestamp + 700 + sql insert into tb1 values ( $ts , $val , $val , $val ) + + $val = 10 * $i + $val = $val + 8 + $ts = $timestamp + 800 + sql insert into tb1 values ( $ts , $val , $val , $val ) + + $val = 10 * $i + $val = $val + 9 + $ts = $timestamp + 900 + sql insert into tb1 values ( $ts , $val , $val , $val ) + + $val = 10 * $i + $val = $val + 1 + $ts = $timestamp + 100 + sql import into tb1 values ( $ts , $val , $val , $val ) + + $val = 10 * $i + $val = $val + 0 + $ts = $timestamp + 0 + sql import into tb1 values ( $ts , $val , $val , $val ) + + $timestamp = $timestamp + 1000 + $i = $i + 1 +endw + +print ================= step2 + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/import/replica1.sim b/tests/script/general/import/replica1.sim new file mode 100644 index 0000000000000000000000000000000000000000..48d5455b7931bfc167112574c8193097aad74334 --- /dev/null +++ b/tests/script/general/import/replica1.sim @@ -0,0 +1,211 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 10 + +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2000 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 2000 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 2000 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 2000 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +sql create database ir1db days 7 +sql use ir1db +sql create table tb(ts timestamp, i bigint) + +print ================= step1 +sql import into tb values(1520000010000, 1520000010000) +sql select * from tb; +print $rows +if $rows != 1 then + return -1 +endi + +print ================= step2 +sql insert into tb values(1520000008000, 1520000008000) +print $rows +sql select * from tb; +if $rows != 2 then + return -1 +endi + +print ================= step3 +sql insert into tb values(1520000020000, 1520000020000) +sql select * from tb; +print $rows +if $rows != 3 then + return -1 +endi + +print ================= step4 +sql import into tb values(1520000009000, 1520000009000) +sql import into tb values(1520000015000, 1520000015000) +sql import into tb values(1520000030000, 1520000030000) +sql select * from tb; +print $rows +if $rows != 6 then + return -1 +endi + +print ================= step5 +sql insert into tb values(1520000008000, 1520000008000) +sql insert into tb values(1520000014000, 1520000014000) +sql insert into tb values(1520000025000, 1520000025000) +sql insert into tb values(1520000040000, 1520000040000) +sql select * from tb; +print $rows +if $rows != 9 then + return -1 +endi + +print ================= step6 +sql import into tb values(1520000007000, 1520000007000) +sql import into tb values(1520000012000, 1520000012000) +sql import into tb values(1520000023000, 1520000023000) +sql import into tb values(1520000034000, 1520000034000) +sql import into tb values(1520000050000, 1520000050000) +sql select * from tb; +print $rows +if $rows != 14 then + return -1 +endi + +print ================== dnode restart +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +sql use ir1db +sql select * from tb; +if $rows != 14 then + return -1 +endi + +print ================= step7 +sql import into tb values(1520000007001, 1520000007001) +sql import into tb values(1520000012001, 1520000012001) +sql import into tb values(1520000023001, 1520000023001) +sql import into tb values(1520000034001, 1520000034001) +sql import into tb values(1520000050001, 1520000050001) +sql select * from tb; +print $rows +if $rows != 19 then + print expect 19, actual: $rows + return -1 +endi + +print ================= step8 +sql insert into tb values(1520000008002, 1520000008002) +sql insert into tb values(1520000014002, 1520000014002) +sql insert into tb values(1520000025002, 1520000025002) +sql insert into tb values(1520000060000, 1520000060000) +sql select * from tb; +print $rows +if $rows != 23 then + return -1 +endi + +print ================= step9 +#1520000000000 +#sql import into tb values(now-30d, 7003) +#sql import into tb values(now-20d, 34003) +#sql import into tb values(now-10d, 34003) +#sql import into tb values(now-5d, 34003) +#sql import into tb values(now+1d, 50001) +#sql import into tb values(now+2d, 50001) +#sql import into tb values(now+6d, 50001) +#sql import into tb values(now+8d, 50002) +#sql import into tb values(now+10d, 50003) +#sql import into tb values(now+12d, 50004) +#sql import into tb values(now+14d, 50001) +#sql import into tb values(now+16d, 500051) + +sql import into tb values(1517408000000, 1517408000000) +sql import into tb values(1518272000000, 1518272000000) +sql import into tb values(1519136000000, 1519136000000) +sql import into tb values(1519568000000, 1519568000000) +sql import into tb values(1519654400000, 1519654400000) +sql import into tb values(1519827200000, 1519827200000) +sql import into tb values(1520345600000, 1520345600000) +sql import into tb values(1520691200000, 1520691200000) +sql import into tb values(1520864000000, 1520864000000) +sql import into tb values(1521900800000, 1521900800000) +sql import into tb values(1523110400000, 1523110400000) +sql import into tb values(1521382400000, 1521382400000) +sql select * from tb; +print $rows +if $rows != 35 then + return -1 +endi + +print ================= step10 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +sql use ir1db +sql select * from tb; +print $rows +if $rows != 35 then + return -1 +endi + +print ================= step11 + +#sql import into tb values(now-50d, 7003) (now-48d, 7003) (now-46d, 7003) (now-44d, 7003) (now-42d, 7003) +sql import into tb values(1515680000000, 1) (1515852800000, 2) (1516025600000, 3) (1516198400000, 4) (1516371200000, 5) +sql select * from tb; +if $rows != 40 then + return -1 +endi + +print ================= step12 +#1520000000000 +#sql import into tb values(now-19d, -19) (now-18d, -18) (now-17d, -17) (now-16d, -16) (now-15d, -15) (now-14d, -14) (now-13d, -13) (now-12d, -12) (now-11d, -11) +sql import into tb values(1518358400000, 6) (1518444800000, 7) (1518531200000, 8) (1518617600000, 9) (1518704000000, 10) (1518790400000, 11) (1518876800000, 12) (1518963200000, 13) (1519049600000, 14) +sql select * from tb; +print $rows +if $rows != 49 then + return -1 +endi + + +print ================= step14 +#1520000000000 +#sql import into tb values(now-48d, -48) +#sql import into tb values(now-38d, -38) +#sql import into tb values(now-28d, -28) + +sql import into tb values(1515852800001, -48) +sql import into tb values(1516716800000, -38) +sql import into tb values(1517580800000, -28) + +sql select * from tb; +if $rows != 52 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/import/testSuite.sim b/tests/script/general/import/testSuite.sim new file mode 100644 index 0000000000000000000000000000000000000000..9157410ea562ed924725013b81cac2fd78946c75 --- /dev/null +++ b/tests/script/general/import/testSuite.sim @@ -0,0 +1,4 @@ +run general/import/basic.sim +run general/import/commit.sim +run general/import/large.sim +run general/import/replica1.sim diff --git a/tests/script/general/insert/basic.sim b/tests/script/general/insert/basic.sim new file mode 100644 index 0000000000000000000000000000000000000000..88eb30a1ad819a26cdc9d61cb692fde9f1446cd7 --- /dev/null +++ b/tests/script/general/insert/basic.sim @@ -0,0 +1,49 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$i = 0 +$dbPrefix = d +$tbPrefix = t +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop database -x step1 +step1: +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed int) + +$x = 0 +while $x < 10 + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + sql insert into $tb values ($ms , $x ) + $x = $x + 1 +endw + +print =============== step 2 +$x = 0 +while $x < 5 + $cc = $x * 60000 + $ms = 1551481600000 + $cc + + sql insert into $tb values ($ms , $x ) + $x = $x + 1 +endw + +sql select * from $tb + +print $rows points data are retrieved +if $rows != 15 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/insert/insert_drop.sim b/tests/script/general/insert/insert_drop.sim new file mode 100644 index 0000000000000000000000000000000000000000..859263762620b193873e4a355b061f12359c4f2a --- /dev/null +++ b/tests/script/general/insert/insert_drop.sim @@ -0,0 +1,88 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$tbNum = 10 +$rowNum = 10 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== insert_drop.sim +$i = 0 +$db = iddb +$stb = stb + +sql drop database $db -x step1 +step1: +sql create database $db ctime 30 +print ====== create tables +sql use $db +sql create table $stb (ts timestamp, c1 int) tags(t1 int) + +$i = 0 +$ts = $ts0 +while $i < 10 + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + sql insert into $tb values ( $ts , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +print ====== tables created + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed + +sql reset query cache +sleep 1000 + +sql use $db +sql drop table tb5 +$i = 0 +while $i < 4 + + $tb = tb . $i + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + sql insert into $tb values ( $ts , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed + +sql reset query cache +sleep 1000 + +sql use $db + +sql create table tb5 using $stb tags(5) +sql select * from tb5 +print $rows should be 0 +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/insert/query_block1_file.sim b/tests/script/general/insert/query_block1_file.sim new file mode 100644 index 0000000000000000000000000000000000000000..636b9530f9729a98e6e290a3c360e6dfc94945ba --- /dev/null +++ b/tests/script/general/insert/query_block1_file.sim @@ -0,0 +1,197 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$i = 0 +$dbPrefix = tb_1f_db +$tbPrefix = tb_1f_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop database -x step1 +step1: +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed int) + +#commit to file will trigger if insert 82 rows + +$N = 82 + +print =============== step 1 +$x = $N +$y = $N / 2 +while $x > $y + $ms = $x . m + $xt = - . $x + sql insert into $tb values (now - $ms , -$x ) + $x = $x - 1 +endw + +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $y then + return -1 +endi + +$x = $N / 2 +$y = $N +while $x < $y + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 +endw +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $N then + return -1 +endi + +print =============== step 2 + +$R = 4 +$x = $N * 2 +$y = $N * $R +$expect = $y + $N +$y = $y + $x +while $x < $y + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $expect then + return -1 +endi + +print =============== step 3 + +$N1 = $N + 1 +$result1 = $N / 2 +$result2 = $N +$step = $N1 . m + +$start1 = now- . $step +$start2 = now +$start3 = now+ . $step +$end1 = now- . $step +$end2 = now +$end3 = now+ . $step + + +sql select * from $tb where ts < $start1 and ts > $end1 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 +print select * from $tb where ts < $start2 and ts > $end1 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 +print sql select * from $tb where ts < $start3 and ts > $end1 -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 +print sql select * from $tb where ts < $start3 and ts > $end2 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 +if $rows != 0 then + return -1 +endi + +print ================= order by ts desc + +sql select * from $tb where ts < $start1 and ts > $end1 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 order by ts desc +print select * from $tb where ts < $start2 and ts > $end1 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +clear: + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/insert/query_block1_memory.sim b/tests/script/general/insert/query_block1_memory.sim new file mode 100644 index 0000000000000000000000000000000000000000..823e466ee939263ed3fdbd0bd2fdd82a597a71e0 --- /dev/null +++ b/tests/script/general/insert/query_block1_memory.sim @@ -0,0 +1,182 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$i = 0 +$dbPrefix = tb_1m_db +$tbPrefix = tb_1m_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop database -x step1 +step1: +sql create database $db +sql use $db + +sql create table $tb (ts timestamp, speed int) + +#commit to file will trigger if insert 82 rows + +$N = 82 + +print =============== step 1 +$x = $N +$y = $N / 2 +while $x > $y + $z = $x * 60000 + $ms = 1601481600000 - $z + + $xt = - . $x + sql insert into $tb values ($ms , -$x ) + $x = $x - 1 +endw + +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $y then + return -1 +endi + +$x = $N / 2 +$y = $N +while $x < $y + $z = $x * 60000 + $ms = 1601481600000 + $z + + sql insert into $tb values ($ms , $x ) + $x = $x + 1 +endw +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $N then + return -1 +endi + +print =============== step 2 + +$N1 = $N + 1 +$result1 = $N / 2 +$result2 = $N +$step = $N1 * 60000 + +$start1 = 1601481600000 - $step +$start2 = 1601481600000 +$start3 = 1601481600000 + $step +$end1 = 1601481600000 - $step +$end2 = 1601481600000 +$end3 = 1601481600000 + $step + +sql select * from $tb where ts < $start1 and ts > $end1 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 +print select * from $tb where ts < $start2 and ts > $end1 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 +print sql select * from $tb where ts < $start3 and ts > $end1 -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 +print sql select * from $tb where ts < $start3 and ts > $end2 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 +if $rows != 0 then + return -1 +endi + +print ================= order by ts desc + +sql select * from $tb where ts < $start1 and ts > $end1 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 order by ts desc +print select * from $tb where ts < $start2 and ts > $end1 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +clear: + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/insert/query_block2_file.sim b/tests/script/general/insert/query_block2_file.sim new file mode 100644 index 0000000000000000000000000000000000000000..5b7438875e8bfff0eb63ed308f7e06b2e7428da7 --- /dev/null +++ b/tests/script/general/insert/query_block2_file.sim @@ -0,0 +1,211 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$i = 0 +$dbPrefix = tb_2f_db +$tbPrefix = tb_2f_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop database -x step1 +step1: +sql create database $db +sql use $db + +$x = 0 +create1: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create table $tb (ts timestamp, speed int) -x create1 + +#commit to file will trigger if insert 82 rows +$N = 82 + +print =============== step 1 +$x = $N * 2 +$y = $N +$expect = $N +while $x > $y + $ms = $x . m + $xt = - . $x + sql insert into $tb values (now - $ms , $xt ) + $x = $x - 1 +endw + +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $expect then + return -1 +endi + +$x = $N +$y = $N * 2 +$expect = $N * 2 +while $x < $y + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 +endw +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $expect then + return -1 +endi + +print =============== step 2 + +$R = 4 +$y = $N * $R + +$expect = $y + $N +$expect = $expect + $N + +$x = $N * 3 +$y = $y + $x + +while $x < $y + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $expect then + return -1 +endi + + +print =============== step 2 + +$N2 = $N +$result1 = $N +$result2 = 2 * $N +$N1 = $result2 + 1 +$step = $N1 . m + +$start1 = now- . $step +$start2 = now +$start3 = now+ . $step +$end1 = now- . $step +$end2 = now +$end3 = now+ . $step + +sql select * from $tb where ts < $start1 and ts > $end1 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 +print select * from $tb where ts < $start2 and ts > $end1 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 +print sql select * from $tb where ts < $start3 and ts > $end1 -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 +print sql select * from $tb where ts < $start3 and ts > $end2 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 +if $rows != 0 then + return -1 +endi + +print ================= order by ts desc + +sql select * from $tb where ts < $start1 and ts > $end1 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 order by ts desc +print select * from $tb where ts < $start2 and ts > $end1 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +clear: + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/insert/query_block2_memory.sim b/tests/script/general/insert/query_block2_memory.sim new file mode 100644 index 0000000000000000000000000000000000000000..fb41981c89cd08bc8597de5ba48d379d07858af8 --- /dev/null +++ b/tests/script/general/insert/query_block2_memory.sim @@ -0,0 +1,174 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$i = 0 +$dbPrefix = tb_2m_db +$tbPrefix = tb_2m_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop database -x step1 +step1: +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed int) + +$N = 82 + +$x = $N * 2 +$y = $N +while $x > $y + $ms = $x . m + $xt = - . $x + sql insert into $tb values (now - $ms , $xt ) + $x = $x - 1 +endw + +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $y then + return -1 +endi + +$x = $N +$y = $N * 2 +$expect = $N * 2 +while $x < $y + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 +endw +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $expect then + return -1 +endi + +print =============== step 2 + +$result1 = $N +$result2 = $N * 2 + +$N1 = $result2 + 1 +$step = $N1 . m + +$start1 = now- . $step +$start2 = now +$start3 = now+ . $step +$end1 = now- . $step +$end2 = now +$end3 = now+ . $step + +sql select * from $tb where ts < $start1 and ts > $end1 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 +print select * from $tb where ts < $start2 and ts > $end1 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 +print sql select * from $tb where ts < $start3 and ts > $end1 -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 +print sql select * from $tb where ts < $start3 and ts > $end2 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 +if $rows != 0 then + return -1 +endi + +print ================= order by ts desc + +sql select * from $tb where ts < $start1 and ts > $end1 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 order by ts desc +print select * from $tb where ts < $start2 and ts > $end1 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/insert/query_file_memory.sim b/tests/script/general/insert/query_file_memory.sim new file mode 100644 index 0000000000000000000000000000000000000000..f920c215c084f288fe7ce93752ac501b43a0cb9c --- /dev/null +++ b/tests/script/general/insert/query_file_memory.sim @@ -0,0 +1,209 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$i = 0 +$dbPrefix = tb_fm_db +$tbPrefix = tb_fm_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop database -x step1 +step1: +sql create database $db +sql use $db + +$x = 0 +create1: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create table $tb (ts timestamp, speed int) -x create1 + +#commit to file will trigger if insert 82 rows + +$N = 82 + +$x = $N * 2 +$y = $N +$expect = $y +while $x > $y + $ms = $x . m + $xt = - . $x + sql insert into $tb values (now - $ms , $xt ) + $x = $x - 1 +endw + +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $expect then + return -1 +endi + +$x = $N +$y = $N * 2 +$expect = $N * 2 +while $x < $y + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 +endw +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $expect then + return -1 +endi + +$R = 4 +$R = $R - 1 + +$y = $N * $R +$expect = $y + $N +$expect = $expect + $N + +$x = $N * 3 +$y = $y + $x +while $x < $y + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $expect then + return -1 +endi + + +print =============== step 2 + +$result1 = $N +$result2 = $N * 2 +$N1 = $result2 + 1 +$step = $N1 . m + +$start1 = now- . $step +$start2 = now +$start3 = now+ . $step +$end1 = now- . $step +$end2 = now +$end3 = now+ . $step + + +sql select * from $tb where ts < $start1 and ts > $end1 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 +print select * from $tb where ts < $start2 and ts > $end1 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 +print sql select * from $tb where ts < $start3 and ts > $end1 -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 +print sql select * from $tb where ts < $start3 and ts > $end2 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 +if $rows != 0 then + return -1 +endi + +print ================= order by ts desc + +sql select * from $tb where ts < $start1 and ts > $end1 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 order by ts desc +print select * from $tb where ts < $start2 and ts > $end1 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +clear: + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/insert/query_multi_file.sim b/tests/script/general/insert/query_multi_file.sim new file mode 100644 index 0000000000000000000000000000000000000000..bbca53d309146a91dc87167756371b4ffbf2617b --- /dev/null +++ b/tests/script/general/insert/query_multi_file.sim @@ -0,0 +1,56 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$i = 0 +$dbPrefix = tb_mf_db +$tbPrefix = tb_mf_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop database -x step1 +step1: +sql create database $db +sql use $db + +$x = 0 +create1: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create table $tb (ts timestamp, speed int) -x create1 + +$N = 20000 + +$x = 0 + +while $x < $N + $ms = $x . s + #print insert into $tb values (now + $ms , $x ) + sql insert into $tb values (now + $ms , $x ) -x error_insert + $x = $x + 1 +endw +error_insert: + +sql select * from $tb +print $rows points data are retrieved -> exepct $N rows +if $rows < $N then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/insert/tcp.sim b/tests/script/general/insert/tcp.sim new file mode 100644 index 0000000000000000000000000000000000000000..002d84dcaea4f81adb1911e5eb9df691ee4f3605 --- /dev/null +++ b/tests/script/general/insert/tcp.sim @@ -0,0 +1,31 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +sql create database d1; +sql create table d1.t1(ts timestamp, test binary(1000)); +sql insert into d1.t1 values (now , '1' ) + +sql create database d2; +sql create table d2.t2(ts timestamp, test binary(1000)); +sql insert into d2.t2 values (now , '1' ) + +sql create database db +sql use db +sql create table tb (ts timestamp, test binary(1000)) + +$x = 0 +while $x < 10000 + $ms = $x . s + sql insert into tb values (now + $ms , '1' ) + $x = $x + 1 +endw + +sql select * from tb + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/insert/testSuite.sim b/tests/script/general/insert/testSuite.sim new file mode 100644 index 0000000000000000000000000000000000000000..da44167be57a6a2083c49c73a02999ba647f513e --- /dev/null +++ b/tests/script/general/insert/testSuite.sim @@ -0,0 +1,9 @@ +run general/insert/basic.sim +run general/insert/insert_drop.sim +run general/insert/query_block1_memory.sim +run general/insert/query_block2_memory.sim +run general/insert/query_block1_file.sim +run general/insert/query_block2_file.sim +run general/insert/query_file_memory.sim +run general/insert/query_multi_file.sim +run general/insert/tcp.sim diff --git a/tests/script/general/parser/README.txt b/tests/script/general/parser/README.txt new file mode 100644 index 0000000000000000000000000000000000000000..1072976380c5e1d9b2fba61110cef3aebe8f0e14 --- /dev/null +++ b/tests/script/general/parser/README.txt @@ -0,0 +1,27 @@ +This file contains a brief info about the parser test scripts directory. + +The directory contains scripts for TDengine parser testing, mainly focus on syntax parsing and datatype support. The tests are organized in the way database languages are catagorized. + +DML: +{ +SELECT +INSERT +INTERVAL +FILL +DESCRIBE +SHOW +} + +DDL: +{ +CREATE DATABASE/METRIC/TABLE +DROP DATABASE/METRIC/TABLE +} + +DCL: +{ +CREATE ACCOUNT/USER +DROP ACCOUNT/USER +*ALTER USER PRIVILEGE +} + diff --git a/tests/script/general/parser/alter.sim b/tests/script/general/parser/alter.sim new file mode 100644 index 0000000000000000000000000000000000000000..d1a4702a69dce22e7de0de005d912e7813648e01 --- /dev/null +++ b/tests/script/general/parser/alter.sim @@ -0,0 +1,323 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = m_alt_db +$tbPrefix = m_alt_tb +$mtPrefix = m_alt_mt +$tbNum = 10 +$rowNum = 5 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== alter.sim +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database if exists $db +sql create database $db days 10 keep 20,20,20 +sql use $db + +sql_error alter database $db keep "20" +sql_error alter database $db keep "20","20","20" +sql_error alter database $db keep 20,19 +sql_error alter database $db keep 20.0 +sql_error alter database $db keep 20.0,20.0,20.0 +sql_error alter database $db keep 0,0,0 +sql_error alter database $db keep -1,-1,-1 +sql_error alter database $db keep 9,20 +sql_error alter database $db keep 9,9,9 +sql_error alter database $db keep 20,20,19 +sql_error alter database $db keep 20,19,20 +sql_error alter database $db keep 20,19,19 +sql_error alter database $db keep 20,19,18 +sql_error alter database $db keep 20,20,20,20 +sql_error alter database $db keep 365001,365001,365001 +sql alter database $db keep 21 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 21,21,21 then + return -1 +endi +sql alter database $db keep 11,12 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 11,12,12 then + return -1 +endi +sql alter database $db keep 20,20,20 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 20,20,20 then + return -1 +endi +sql alter database $db keep 10,10,10 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 10,10,10 then + return -1 +endi +sql alter database $db keep 10,10,11 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 10,10,11 then + return -1 +endi +sql alter database $db keep 11,12,13 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 11,12,13 then + return -1 +endi +sql alter database $db keep 365000,365000,365000 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 365000,365000,365000 then + return -1 +endi + + +##### alter table test, simeplest case +sql create table tb (ts timestamp, c1 int, c2 int, c3 int) +sql insert into tb values (now, 1, 1, 1) +sql select * from tb order by ts desc +if $rows != 1 then + return -1 +endi +sql alter table tb drop column c3 +sql select * from tb order by ts desc +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != null then + return -1 +endi +sql alter table tb add column c3 nchar(4) +sql select * from tb order by ts desc +if $rows != 1 then + return -1 +endi +if $data03 != NULL then + return -1 +endi +sql insert into tb values (now, 2, 2, 'taos') +sql select * from tb order by ts desc +if $rows != 2 then + return -1 +endi +print data03 = $data03 +if $data03 != taos then + print expect taos, actual: $data03 + return -1 +endi +sql drop table tb + +##### alter metric test, simplest case +sql create table mt (ts timestamp, c1 int, c2 int, c3 int) tags (t1 int) +sql create table tb using mt tags(1) +sql insert into tb values (now, 1, 1, 1) +sql alter table mt drop column c3 +sql select * from tb order by ts desc +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != null then + return -1 +endi + +sql alter table mt add column c3 nchar(4) +sql select * from tb order by ts desc +if $data03 != NULL then + return -1 +endi +sql insert into tb values (now, 2, 2, 'taos') +sql select * from tb order by ts desc +if $rows != 2 then + return -1 +endi +if $data03 != taos then + return -1 +endi +if $data13 != NULL then + return -1 +endi +sql drop table tb +sql drop table mt + +## [TBASE272] +sql create table tb (ts timestamp, c1 int, c2 int, c3 int) +sql insert into tb values (now, 1, 1, 1) +sql alter table tb drop column c3 +sql alter table tb add column c3 nchar(5) +sql insert into tb values(now, 2, 2, 'taos') +sql drop table tb +sql create table mt (ts timestamp, c1 int, c2 int, c3 int) tags (t1 int) +sql create table tb using mt tags(1) +sql insert into tb values (now, 1, 1, 1) +sql alter table mt drop column c3 +sql select * from tb order by ts desc +if $rows != 1 then + return -1 +endi +sql drop table tb +sql drop table mt + +sleep 100 +### ALTER TABLE WHILE STREAMING [TBASE271] +#sql create table tb1 (ts timestamp, c1 int, c2 nchar(5), c3 int) +#sql create table strm as select count(*), avg(c1), first(c2), sum(c3) from tb1 interval(2s) +#sql select * from strm +#if $rows != 0 then +# return -1 +#endi +##sleep 12000 +#sql insert into tb1 values (now, 1, 'taos', 1) +#sleep 20000 +#sql select * from strm +#print rows = $rows +#if $rows != 1 then +# return -1 +#endi +#if $data04 != 1 then +# return -1 +#endi +#sql alter table tb1 drop column c3 +#sleep 500 +#sql insert into tb1 values (now, 2, 'taos') +#sleep 30000 +#sql select * from strm +#if $rows != 2 then +# return -1 +#endi +#if $data04 != 1 then +# return -1 +#endi +#sql alter table tb1 add column c3 int +#sleep 500 +#sql insert into tb1 values (now, 3, 'taos', 3); +#sleep 100 +#sql select * from strm +#if $rows != 3 then +# return -1 +#endi +#if $data04 != 1 then +# return -1 +#endi + +## ALTER TABLE AND INSERT BY COLUMNS +sql create table mt (ts timestamp, c1 int, c2 int) tags(t1 int) +sql create table tb using mt tags(0) +sql insert into tb values (now-1m, 1, 1) +sql alter table mt drop column c2 +sql_error insert into tb (ts, c1, c2) values (now, 2, 2) +sql insert into tb (ts, c1) values (now, 2) +sql select * from tb order by ts desc +if $rows != 2 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != null then + return -1 +endi +sql alter table mt add column c2 int +sql insert into tb (ts, c2) values (now, 3) +sql select * from tb order by ts desc +if $data02 != 3 then + return -1 +endi + +## ALTER TABLE AND IMPORT +sql drop database $db +sql create database $db +sql use $db +sql create table mt (ts timestamp, c1 int, c2 nchar(7), c3 int) tags (t1 int) +sql create table tb using mt tags(1) +sleep 100 +sql insert into tb values ('2018-11-01 16:30:00.000', 1, 'insert', 1) +sql alter table mt drop column c3 + +sql insert into tb values ('2018-11-01 16:29:59.000', 1, 'insert') +sql import into tb values ('2018-11-01 16:29:59.000', 1, 'import') +sql select * from tb order by ts desc +if $data01 != 1 then + return -1 +endi +if $data02 != insert then + return -1 +endi +sql alter table mt add column c3 nchar(4) +sql select * from tb order by ts desc +if $data03 != NULL then + return -1 +endi + +print ============================>TD-3366 TD-3486 +sql insert into td_3366(ts, c3, c1) using mt(t1) tags(911) values('2018-1-1 11:11:11', 'new1', 12); +sql insert into td_3486(ts, c3, c1) using mt(t1) tags(-12) values('2018-1-1 11:11:11', 'new1', 12); +sql insert into ttxu(ts, c3, c1) using mt(t1) tags('-121') values('2018-1-1 11:11:11', 'new1', 12); + +sql insert into tb(ts, c1, c3) using mt(t1) tags(123) values('2018-11-01 16:29:58.000', 2, 'port') + +sql insert into tb values ('2018-11-01 16:29:58.000', 2, 'import', 3) +sql import into tb values ('2018-11-01 16:29:58.000', 2, 'import', 3) +sql import into tb values ('2018-11-01 16:39:58.000', 2, 'import', 3) +sql select * from tb order by ts desc +if $rows != 4 then + return -1 +endi + +if $data03 != 3 then + return -1 +endi + +##### ILLEGAL OPERATIONS + +# try dropping columns that are defined in metric +sql_error alter table tb drop column c1; + +# try dropping primary key +sql_error alter table mt drop column ts; + +# try modifying two columns in a single statement +sql_error alter table mt add column c5 nchar(3) c6 nchar(4) + +# duplicate columns +sql_error alter table mt add column c1 int + +# drop non-existing columns +sql_error alter table mt drop column c9 + +#sql drop database $db +#sql show databases +#if $rows != 0 then +# return -1 +#endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/alter1.sim b/tests/script/general/parser/alter1.sim new file mode 100644 index 0000000000000000000000000000000000000000..3b6b0d946599a642cd78b7fbc917d9b5e3d5ed50 --- /dev/null +++ b/tests/script/general/parser/alter1.sim @@ -0,0 +1,136 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect +sql reset query cache + +$dbPrefix = alt1_db + +print ========== alter1.sim +$db = $dbPrefix + +sql drop database if exists $db +sql create database $db +sql use $db + +sql create table stb (ts timestamp, speed double, mileage double) tags(carId int, carModel int) +sql create table car1 using stb tags (1, 1) +sql create table car2 using stb tags (2, 1) +sql create table car3 using stb tags (3, 2) +sql insert into car1 values (now-1s, 100, 10000) +sql insert into car2 values (now, 100, 10000) +sql insert into car3 values (now, 100, 10000) +sql insert into car1 values (now, 120, 11000) +print ================== add a column +sql alter table stb add column c1 int +sql describe stb +if $rows != 6 then + return -1 +endi + +sql select * from stb +print rows = $rows +if $rows != 4 then + return -1 +endi +if $data03 != NULL then + return -1 +endi +if $data13 != NULL then + return -1 +endi +if $data23 != NULL then + return -1 +endi +if $data33 != NULL then + return -1 +endi + +sql select c1 from stb +if $rows != 4 then + return -1 +endi +if $data00 != NULL then + return -1 +endi +if $data30 != NULL then + return -1 +endi + +sql select c1+speed from stb +if $rows != 4 then + return -1 +endi + +sql select c1+speed from car1 +if $rows != 2 then + return -1 +endi +if $data00 != NULL then + return -1 +endi +if $data10 != NULL then + return -1 +endi + +sql select * from car1 +if $rows != 2 then + return -1 +endi +if $data03 != NULL then + return -1 +endi +if $data13 != NULL then + return -1 +endi + +sleep 100 +print ================== insert values into table +sql insert into car1 values (now, 1, 1,1 ) (now +1s, 2,2,2,) car2 values (now, 1,3,3) + +sql select c1+speed from stb where c1 > 0 +if $rows != 3 then + return -1 +endi + +print ================== add a tag +sql alter table stb add tag t1 int +sql describe stb +if $rows != 7 then + return -1 +endi +if $data60 != t1 then + return -1 +endi + +print ================== change a tag value +sql alter table car1 set tag carid=10 +sql select carId, carmodel from car1 +if $rows != 1 then + return -1 +endi + +if $data00 != 10 then + return -1 +endi + +sql select * from stb where carid = 10 +if $rows != 4 then + return -1 +endi + +sql alter table car2 set tag carmodel = 2 +sql select * from stb where carmodel = 2 +print $rows +if $rows != 3 then + return -1 +endi + +#sql drop database $db +#sql show databases +#if $rows != 0 then +# return -1 +#endi diff --git a/tests/script/general/parser/alter__for_community_version.sim b/tests/script/general/parser/alter__for_community_version.sim new file mode 100644 index 0000000000000000000000000000000000000000..f55fb812a74eead44e54808b000a48c3db92b66d --- /dev/null +++ b/tests/script/general/parser/alter__for_community_version.sim @@ -0,0 +1,316 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = m_alt_db +$tbPrefix = m_alt_tb +$mtPrefix = m_alt_mt +$tbNum = 10 +$rowNum = 5 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== alter.sim +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database if exists $db +sql create database $db days 10 keep 20 +sql use $db +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 20 then + return -1 +endi + +sql_error alter database $db keep "20" +sql_error alter database $db keep "20","20","20" +sql_error alter database $db keep 0 +sql_error alter database $db keep 20.0 +sql_error alter database $db keep 20.0,20.0,20.0 +sql_error alter database $db keep 0,0,0 +sql_error alter database $db keep 3 +sql_error alter database $db keep -1,-1,-1 +sql_error alter database $db keep 20,20 +sql_error alter database $db keep 9,9,9 +sql_error alter database $db keep 20,20,19 +sql_error alter database $db keep 20,19,20 +sql_error alter database $db keep 20,19,19 +sql_error alter database $db keep 20,19,18 +sql_error alter database $db keep 20,20,20,20 +sql_error alter database $db keep 365001,365001,365001 +sql_error alter database $db keep 365001 +sql alter database $db keep 20 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 20 then + return -1 +endi +sql alter database $db keep 10 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 10 then + return -1 +endi +sql alter database $db keep 11 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 11 then + return -1 +endi +sql alter database $db keep 13 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 13 then + return -1 +endi +sql alter database $db keep 365000 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 365000 then + return -1 +endi + + +##### alter table test, simeplest case +sql create table tb (ts timestamp, c1 int, c2 int, c3 int) +sql insert into tb values (now, 1, 1, 1) +sql select * from tb order by ts desc +if $rows != 1 then + return -1 +endi +sql alter table tb drop column c3 +sql select * from tb order by ts desc +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != null then + return -1 +endi +sql alter table tb add column c3 nchar(4) +sql select * from tb order by ts desc +if $rows != 1 then + return -1 +endi +if $data03 != NULL then + return -1 +endi +sql insert into tb values (now, 2, 2, 'taos') +sql select * from tb order by ts desc +if $rows != 2 then + return -1 +endi +print data03 = $data03 +if $data03 != taos then + print expect taos, actual: $data03 + return -1 +endi +sql drop table tb + +##### alter metric test, simplest case +sql create table mt (ts timestamp, c1 int, c2 int, c3 int) tags (t1 int) +sql create table tb using mt tags(1) +sql insert into tb values (now, 1, 1, 1) +sql alter table mt drop column c3 +sql select * from tb order by ts desc +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != null then + return -1 +endi + +sql alter table mt add column c3 nchar(4) +sql select * from tb order by ts desc +if $data03 != NULL then + return -1 +endi +sql insert into tb values (now, 2, 2, 'taos') +sql select * from tb order by ts desc +if $rows != 2 then + return -1 +endi +if $data03 != taos then + return -1 +endi +if $data13 != NULL then + return -1 +endi +sql drop table tb +sql drop table mt + +## [TBASE272] +sql create table tb (ts timestamp, c1 int, c2 int, c3 int) +sql insert into tb values (now, 1, 1, 1) +sql alter table tb drop column c3 +sql alter table tb add column c3 nchar(5) +sql insert into tb values(now, 2, 2, 'taos') +sql drop table tb +sql create table mt (ts timestamp, c1 int, c2 int, c3 int) tags (t1 int) +sql create table tb using mt tags(1) +sql insert into tb values (now, 1, 1, 1) +sql alter table mt drop column c3 +sql select * from tb order by ts desc +if $rows != 1 then + return -1 +endi +sql drop table tb +sql drop table mt + +sleep 100 +### ALTER TABLE WHILE STREAMING [TBASE271] +#sql create table tb1 (ts timestamp, c1 int, c2 nchar(5), c3 int) +#sql create table strm as select count(*), avg(c1), first(c2), sum(c3) from tb1 interval(2s) +#sql select * from strm +#if $rows != 0 then +# return -1 +#endi +##sleep 12000 +#sql insert into tb1 values (now, 1, 'taos', 1) +#sleep 20000 +#sql select * from strm +#print rows = $rows +#if $rows != 1 then +# return -1 +#endi +#if $data04 != 1 then +# return -1 +#endi +#sql alter table tb1 drop column c3 +#sleep 500 +#sql insert into tb1 values (now, 2, 'taos') +#sleep 30000 +#sql select * from strm +#if $rows != 2 then +# return -1 +#endi +#if $data04 != 1 then +# return -1 +#endi +#sql alter table tb1 add column c3 int +#sleep 500 +#sql insert into tb1 values (now, 3, 'taos', 3); +#sleep 100 +#sql select * from strm +#if $rows != 3 then +# return -1 +#endi +#if $data04 != 1 then +# return -1 +#endi + +## ALTER TABLE AND INSERT BY COLUMNS +sql create table mt (ts timestamp, c1 int, c2 int) tags(t1 int) +sql create table tb using mt tags(0) +sql insert into tb values (now-1m, 1, 1) +sql alter table mt drop column c2 +sql_error insert into tb (ts, c1, c2) values (now, 2, 2) +sql insert into tb (ts, c1) values (now, 2) +sql select * from tb order by ts desc +if $rows != 2 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != null then + return -1 +endi +sql alter table mt add column c2 int +sql insert into tb (ts, c2) values (now, 3) +sql select * from tb order by ts desc +if $data02 != 3 then + return -1 +endi + +## ALTER TABLE AND IMPORT +sql drop database $db +sql create database $db +sql use $db +sql create table mt (ts timestamp, c1 int, c2 nchar(7), c3 int) tags (t1 int) +sql create table tb using mt tags(1) +sleep 100 +sql insert into tb values ('2018-11-01 16:30:00.000', 1, 'insert', 1) +sql alter table mt drop column c3 + +sql insert into tb values ('2018-11-01 16:29:59.000', 1, 'insert') +sql import into tb values ('2018-11-01 16:29:59.000', 1, 'import') +sql select * from tb order by ts desc +if $data01 != 1 then + return -1 +endi +if $data02 != insert then + return -1 +endi +sql alter table mt add column c3 nchar(4) +sql select * from tb order by ts desc +if $data03 != NULL then + return -1 +endi + +print ============================>TD-3366 TD-3486 +sql insert into td_3366(ts, c3, c1) using mt(t1) tags(911) values('2018-1-1 11:11:11', 'new1', 12); +sql insert into td_3486(ts, c3, c1) using mt(t1) tags(-12) values('2018-1-1 11:11:11', 'new1', 12); +sql insert into ttxu(ts, c3, c1) using mt(t1) tags('-121') values('2018-1-1 11:11:11', 'new1', 12); + +sql insert into tb(ts, c1, c3) using mt(t1) tags(123) values('2018-11-01 16:29:58.000', 2, 'port') + +sql insert into tb values ('2018-11-01 16:29:58.000', 2, 'import', 3) +sql import into tb values ('2018-11-01 16:29:58.000', 2, 'import', 3) +sql import into tb values ('2018-11-01 16:39:58.000', 2, 'import', 3) +sql select * from tb order by ts desc +if $rows != 4 then + return -1 +endi + +if $data03 != 3 then + return -1 +endi + +##### ILLEGAL OPERATIONS + +# try dropping columns that are defined in metric +sql_error alter table tb drop column c1; + +# try dropping primary key +sql_error alter table mt drop column ts; + +# try modifying two columns in a single statement +sql_error alter table mt add column c5 nchar(3) c6 nchar(4) + +# duplicate columns +sql_error alter table mt add column c1 int + +# drop non-existing columns +sql_error alter table mt drop column c9 + +#sql drop database $db +#sql show databases +#if $rows != 0 then +# return -1 +#endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/alter_column.sim b/tests/script/general/parser/alter_column.sim new file mode 100644 index 0000000000000000000000000000000000000000..fe109352d12ba42a5c9fe318766764a850132abf --- /dev/null +++ b/tests/script/general/parser/alter_column.sim @@ -0,0 +1,118 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = m_alt_db +$tbPrefix = m_alt_tb +$mtPrefix = m_alt_mt +$tbNum = 10 +$rowNum = 5 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== alter.sim +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database if exists $db +sql create database $db +sql use $db +##### alter table test, simeplest case +sql create table tb (ts timestamp, c1 int, c2 binary(10), c3 nchar(10)) +sql insert into tb values (now, 1, "1", "1") +sql alter table tb modify column c2 binary(20); +if $rows != 0 then + return -1 +endi +sql alter table tb modify column c3 nchar(20); +if $rows != 0 then + return -1 +endi + + +sql create stable stb (ts timestamp, c1 int, c2 binary(10), c3 nchar(10)) tags(id1 int, id2 binary(10), id3 nchar(10)) +sql create table tb1 using stb tags(1, "a", "b") +sql insert into tb1 values (now, 1, "1", "1") +sql alter stable stb modify column c2 binary(20); +if $rows != 0 then + return -1 +endi +sql alter table stb modify column c2 binary(30); +if $rows != 0 then + return -1 +endi +sql alter stable stb modify column c3 nchar(20); +if $rows != 0 then + return -1 +endi +sql alter table stb modify column c3 nchar(30); +if $rows != 0 then + return -1 +endi + +sql alter table stb modify tag id2 binary(11); +if $rows != 0 then + return -1 +endi +sql alter stable stb modify tag id2 binary(11); +if $rows != 0 then + return -1 +endi +sql alter table stb modify tag id3 nchar(11); +if $rows != 0 then + return -1 +endi +sql alter stable stb modify tag id3 nchar(11); +if $rows != 0 then + return -1 +endi + +##### ILLEGAL OPERATIONS + +# try dropping columns that are defined in metric +sql_error alter table tb modify column c1 binary(10); +sql_error alter table tb modify column c1 double; +sql_error alter table tb modify column c2 int; +sql_error alter table tb modify column c2 binary(10); +sql_error alter table tb modify column c2 binary(9); +sql_error alter table tb modify column c2 binary(-9); +sql_error alter table tb modify column c2 binary(0); +sql_error alter table tb modify column c2 binary(17000); +sql_error alter table tb modify column c2 nchar(30); +sql_error alter table tb modify column c3 double; +sql_error alter table tb modify column c3 nchar(10); +sql_error alter table tb modify column c3 nchar(0); +sql_error alter table tb modify column c3 nchar(-1); +sql_error alter table tb modify column c3 binary(80); +sql_error alter table tb modify column c3 nchar(17000); +sql_error alter table tb modify column c3 nchar(100), c2 binary(30); +sql_error alter table tb modify column c1 nchar(100), c2 binary(30); +sql_error alter stable tb modify column c2 binary(30); +sql_error alter table tb modify tag c2 binary(30); +sql_error alter table stb modify tag id2 binary(10); +sql_error alter table stb modify tag id2 nchar(30); +sql_error alter stable stb modify tag id2 binary(10); +sql_error alter stable stb modify tag id2 nchar(30); +sql_error alter table stb modify tag id3 nchar(10); +sql_error alter table stb modify tag id3 binary(30); +sql_error alter stable stb modify tag id3 nchar(10); +sql_error alter stable stb modify tag id3 binary(30); +sql_error alter stable stb modify tag id1 binary(30); +sql_error alter stable stb modify tag c1 binary(30); + + +sql_error alter table tb1 modify column c2 binary(30); +sql_error alter table tb1 modify column c3 nchar(30); +sql_error alter table tb1 modify tag id2 binary(30); +sql_error alter table tb1 modify tag id3 nchar(30); +sql_error alter stable tb1 modify tag id2 binary(30); +sql_error alter stable tb1 modify tag id3 nchar(30); +sql_error alter stable tb1 modify column c2 binary(30); + + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/alter_stable.sim b/tests/script/general/parser/alter_stable.sim new file mode 100644 index 0000000000000000000000000000000000000000..1406af608779eef2048de24b6e4aef6b99b54d7d --- /dev/null +++ b/tests/script/general/parser/alter_stable.sim @@ -0,0 +1,44 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +print ========== alter_stable.sim + +$db = demodb +sql drop database if exists $db +sql create database $db +sql use $db + +##### alter stable test : change tag name +# case-1 change tag name: new name inclue old name +sql create table mt1 (ts timestamp, c1 int) tags (a int) +sql alter table mt1 change tag a abcd +sql alter table mt1 change tag abcd a +sql_error alter table mt1 change tag a 1 + +sql_error create table mtx1 (ts timestamp, c1 int) tags (123 int) + +sql_error create table mt2 (ts timestamp, c1 int) tags (abc012345678901234567890123456789012345678901234567890123456789def int) +sql create table mt3 (ts timestamp, c1 int) tags (abc012345678901234567890123456789012345678901234567890123456789 int) +sql_error alter table mt3 change tag abc012345678901234567890123456789012345678901234567890123456789 abcdefg012345678901234567890123456789012345678901234567890123456789 +sql alter table mt3 change tag abc012345678901234567890123456789012345678901234567890123456789 abcdefg0123456789012345678901234567890123456789 + +# case-2 set tag value +sql create table mt4 (ts timestamp, c1 int) tags (name binary(16), len int) +sql create table tb1 using mt4 tags ("beijing", 100) +sql alter table tb1 set tag name = "shanghai" +sql alter table tb1 set tag name = "" +sql alter table tb1 set tag name = "shenzhen" +sql alter table tb1 set tag len = 379 + +# case TD-5594 +sql create stable st5520(ts timestamp, f int) tags(t0 bool, t1 nchar(4093), t2 nchar(1)) +sql_error alter stable st5520 modify tag t2 nchar(2); +# test end +sql drop database $db + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/auto_create_tb.sim b/tests/script/general/parser/auto_create_tb.sim new file mode 100644 index 0000000000000000000000000000000000000000..a902469fde690722698351f37dda7e89adff4b84 --- /dev/null +++ b/tests/script/general/parser/auto_create_tb.sim @@ -0,0 +1,308 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2 +system sh/exec.sh -n dnode1 -s start + +sleep 100 +sql connect +print ======================== dnode1 start + +$dbPrefix = ac_db +$tbPrefix = ac_tb +$stbPrefix = ac_stb +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 +$ts0 = 1537146000000 + +print excuting test script auto_create_tb.sim +print =============== set up +$i = 0 +$db = $dbPrefix +$stb = $stbPrefix +$tb = $tbPrefix . $i + +sql create database $db +sql use $db + +print =========== auto_create_tb.sim case1: test +sql CREATE TABLE $stb (TS TIMESTAMP, C1 INT, C2 BIGINT, C3 FLOAT, C4 DOUBLE, C5 BINARY(10), C6 BOOL, C7 SMALLINT, C8 TINYINT, C9 NCHAR(10)) TAGS (T1 INT) +sql show stables + +if $rows != 1 then + return -1 +endi +if $data00 != $stb then + return -1 +endi + +### create table on the fly +sql insert into tb1 using $stb tags (1) values ( $ts0 , 1,1,1,1,'bin',1,1,1,'涛思数据') +sql select * from tb1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data09 != 涛思数据 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 1.00000 then + return -1 +endi +if $data04 != 1.000000000 then + return -1 +endi +if $data05 != bin then + return -1 +endi + +### insert into an existing table +$ts1 = $ts0 + 1000 +$ts2 = $ts0 + 2000 +sql insert into tb1 using $stb tags (1) values ( $ts1 , 1,1,1,1,'bin',1,1,1,'涛思数据') ( $ts2 , 2,2,2,2,'binar', 1,1,1,'nchar') +sql select * from $stb +if $rows != 3 then + return -1 +endi +if $data19 != 涛思数据 then + return -1 +endi +if $data11 != 1 then + return -1 +endi +if $data22 != 2 then + return -2 +endi +if $data23 != 2.00000 then + return -1 +endi +if $data25 != binar then + return -1 +endi +if $data29 != nchar then + return -1 +endi + +### [TBASE-410] auto create table with a negative tag value +$ts1 = $ts0 + 1000 +$ts2 = $ts0 + 2000 +sql insert into tb_1 using $stb tags (-1) values ( $ts1 , 1,1,1,1,'bin',1,1,1,'涛思数据') ( $ts2 , 2,2,2,2,'binar', 1,1,1,'nchar') +sql select * from $stb +if $rows != 5 then + return -1 +endi +if $data09 != 涛思数据 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data42 != 2 then + return -2 +endi +if $data43 != 2.00000 then + return -1 +endi +if $data45 != binar then + return -1 +endi +if $data49 != nchar then + return -1 +endi +sql drop table tb_1 + +#### insert into an existing table with wrong tags +$ts3 = $ts0 + 3000 +$ts4 = $ts0 + 4000 +sql insert into tb1 using $stb tags (2) values ( $ts3 , 1,1,1,1,'bin',1,1,1,'涛思数据') ( $ts4 , 2,2,2,2,'binar', 1,1,1,'nchar') +sql select * from $stb +if $rows != 5 then + return -1 +endi +if $data09 != 涛思数据 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data42 != 2 then + return -2 +endi +if $data43 != 2.00000 then + return -1 +endi +if $data45 != binar then + return -1 +endi +if $data49 != nchar then + return -1 +endi + +sql drop table tb1 + +#### auto create multiple tables +sql insert into tb1 using $stb tags(1) values ( $ts0 , 1, 1, 1, 1, 'bin1', 1, 1, 1, '涛思数据1') tb2 using $stb tags(2) values ( $ts0 , 2, 2, 2, 2, 'bin2', 2, 2, 2, '涛思数据2') tb3 using $stb tags(3) values ( $ts0 , 3, 3, 3, 3, 'bin3', 3, 3, 3, '涛思数据3') +sql show tables +print $rows $data00 $data10 $data20 +if $rows != 3 then + return -1 +endi +if $data00 != tb1 then + return -1 +endi +if $data10 != tb2 then + return -1 +endi +if $data20 != tb3 then + return -1 +endi + +sql select ts,c1,c2,c3,c4,c5,c7,c8,c9 from $stb +if $rows != 3 then + return -1 +endi +#if $data00 != @18-09-17 09:00:00.000@ then +# return -1 +#endi +if $data01 != 1 then + return -1 +endi +if $data08 != 涛思数据1 then + return -1 +endi +if $data14 != 2.000000000 then + return -1 +endi +if $data18 != 涛思数据2 then + return -1 +endi +if $data28 != 涛思数据3 then + return -1 +endi + +sql select count(*), first(c9) from $stb group by t1 order by t1 asc slimit 2 soffset 1 +if $rows != 2 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data01 != 涛思数据2 then + return -1 +endi +if $data02 != 2 then + return -1 +endi +if $data11 != 涛思数据3 then + return -1 +endi +if $data12 != 3 then + return -1 +endi + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 500 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed +sql connect +sleep 100 +sql use $db + +#### auto create multiple tables +sql insert into tb1 using $stb tags(1) values ( $ts0 , 1, 1, 1, 1, 'bin1', 1, 1, 1, '涛思数据1') tb2 using $stb tags(2) values ( $ts0 , 2, 2, 2, 2, 'bin2', 2, 2, 2, '涛思数据2') tb3 using $stb tags(3) values ( $ts0 , 3, 3, 3, 3, 'bin3', 3, 3, 3, '涛思数据3') +sql show tables +if $rows != 3 then + return -1 +endi +if $data00 != tb1 then + return -1 +endi +if $data10 != tb2 then + return -1 +endi +if $data20 != tb3 then + return -1 +endi + +sql select ts,c1,c2,c3,c4,c5,c7,c8,c9 from $stb +if $rows != 3 then + return -1 +endi +#if $data00 != @18-09-17 09:00:00.000@ then +# return -1 +#endi +if $data01 != 1 then + return -1 +endi +if $data08 != 涛思数据1 then + return -1 +endi +if $data14 != 2.000000000 then + return -1 +endi +if $data18 != 涛思数据2 then + return -1 +endi +if $data28 != 涛思数据3 then + return -1 +endi + +sql select count(*), first(c9) from $stb group by t1 order by t1 asc slimit 2 soffset 1 +if $rows != 2 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data01 != 涛思数据2 then + return -1 +endi +if $data02 != 2 then + return -1 +endi +if $data11 != 涛思数据3 then + return -1 +endi +if $data12 != 3 then + return -1 +endi + +print ======= too many columns in auto create tables +sql create table tick (ts timestamp , last_prc double , volume int, amount double, oi int , bid_prc1 double, ask_prc1 double, bid_vol1 int, ask_vol1 int , bid_prc2 double, ask_prc2 double, bid_vol2 int, ask_vol2 int , bid_prc3 double, ask_prc3 double, bid_vol3 int, ask_vol3 int , bid_prc4 double, ask_prc4 double, bid_vol4 int, ask_vol4 int , bid_prc5 double, ask_prc5 double, bid_vol5 int, ask_vol5 int , open_prc double, highest_prc double, low_prc double, close_prc double , upper_limit double, lower_limit double) TAGS (ticker BINARY(32), product BINARY(8)); +sql show stables + +if $rows != 2 then + return -1 +endi + +sql insert into tick_000001 ('ts', 'last_prc', 'volume', 'amount', 'oi', 'bid_prc1', 'ask_prc1') using tick tags (000001, Stocks) VALUES (1546391700000, 0.000000, 0, 0.000000, 0, 0.000000, 10.320000); +sql select tbname from tick +if $rows != 1 then + return -1 +endi + +#sql drop database $db +#sql show databases +#if $rows != 0 then +# return -1 +#endi + +#[tbase-673] +sql create table tu(ts timestamp, k int); +sql_error create table txu using tu tags(0) values(now, 1); + +print =================> [TBASE-675] +sql insert into tu values(1565971200000, 1) (1565971200000,2) (1565971200001, 3)(1565971200001, 4) +sql select * from tu +if $rows != 2 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/parser/auto_create_tb_drop_tb.sim b/tests/script/general/parser/auto_create_tb_drop_tb.sim new file mode 100644 index 0000000000000000000000000000000000000000..b04d02464347ac70b2a0fa74005a72e159b9c78e --- /dev/null +++ b/tests/script/general/parser/auto_create_tb_drop_tb.sim @@ -0,0 +1,83 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode1 -c ctime -v 30 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = db +$tbPrefix = tb +$stbPrefix = stb +$tbNum = 5 +$rowNum = 1361 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== auto_create_tb_drop_tb.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db maxrows 200 cache 2 +print ====== create tables +sql use $db + +$i = 0 +$ts = $ts0 +$tb = $tbPrefix . $i +sql create table $stb (ts timestamp, c1 int) tags (t1 binary(10)) +$x = 0 +$t = 0 +while $t < $tbNum + $t1 = 'tb . $t + $t1 = $t1 . ' + $tbname = tb . $t + print t = $t + print tbname = $tbname + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + sql insert into $tbname using $stb tags( $t1 ) values ( $ts , $x ) + $x = $x + 1 + endw + $t = $t + 1 + $x = 0 +endw +print ====== tables created + +sleep 100 + +sql drop table tb2 +$x = 0 +while $x < $rowNum + $ts = $ts + $delta + $t1 = 'tb . $t + $t1 = $t1 . ' + sql insert into tb1 using $stb tags( $t1 ) values ( $ts , $x ) + $x = $x + 1 +endw + +$ts = $ts0 + $delta +$ts = $ts + 1 + +$x = 0 +while $x < 100 + $ts = $ts + $delta + sql insert into tb2 using stb0 tags('tb2') values ( $ts , 1) + sql select * from tb2 + $res = $x + 1 + if $rows != $res then + return -1 + endi + if $data01 != 1 then + return -1 + endi + $x = $x + 1 + print loop $x +endw + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/parser/between_and.sim b/tests/script/general/parser/between_and.sim new file mode 100644 index 0000000000000000000000000000000000000000..cdced47cb65aea79618540b57e159b741bf9288a --- /dev/null +++ b/tests/script/general/parser/between_and.sim @@ -0,0 +1,165 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2 +system sh/exec.sh -n dnode1 -s start + +sleep 100 +sql connect +print ======================== dnode1 start + +$db = testdb + +sql create database $db +sql use $db + +sql create stable st2 (ts timestamp, f1 int, f2 float, f3 double, f4 bigint, f5 smallint, f6 tinyint, f7 bool, f8 binary(10), f9 nchar(10)) tags (id1 int, id2 float, id3 nchar(10), id4 double, id5 smallint, id6 bigint, id7 binary(10)) + +sql create table tb1 using st2 tags (1,1.0,"1",1.0,1,1,"1"); +sql create table tb2 using st2 tags (2,2.0,"2",2.0,2,2,"2"); +sql create table tb3 using st2 tags (3,3.0,"3",3.0,3,3,"3"); +sql create table tb4 using st2 tags (4,4.0,"4",4.0,4,4,"4"); + +sql insert into tb1 values (now-200s,1,1.0,1.0,1,1,1,true,"1","1") +sql insert into tb1 values (now-100s,2,2.0,2.0,2,2,2,true,"2","2") +sql insert into tb1 values (now,3,3.0,3.0,3,3,3,true,"3","3") +sql insert into tb1 values (now+100s,4,4.0,4.0,4,4,4,true,"4","4") +sql insert into tb1 values (now+200s,4,4.0,4.0,4,4,4,true,"4","4") +sql insert into tb1 values (now+300s,4,4.0,4.0,4,4,4,true,"4","4") +sql insert into tb1 values (now+400s,4,4.0,4.0,4,4,4,true,"4","4") +sql insert into tb1 values (now+500s,4,4.0,4.0,4,4,4,true,"4","4") + +sql select tbname,id1 from st2; + +if $rows != 4 then + return -1 +endi + + +sql select * from st2; + +if $rows != 8 then + return -1 +endi + +sql select * from st2 where ts between now-50s and now+450s + +if $rows != 5 then + return -1 +endi + +sql select tbname,id1 from st2 where id1 between 2 and 3; + +if $rows != 2 then + return -1 +endi + +if $data00 != tb2 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data10 != tb3 then + return -1 +endi +if $data11 != 3 then + return -1 +endi + +sql select tbname,id2 from st2 where id2 between 2.0 and 3.0; + +if $rows != 2 then + return -1 +endi + +if $data00 != tb2 then + return -1 +endi +if $data01 != 2.00000 then + return -1 +endi +if $data10 != tb3 then + return -1 +endi +if $data11 != 3.00000 then + return -1 +endi + + +sql select tbname,id4 from st2 where id4 between 2.0 and 3.0; + +if $rows != 2 then + return -1 +endi + +if $data00 != tb2 then + return -1 +endi +if $data01 != 2.000000000 then + return -1 +endi +if $data10 != tb3 then + return -1 +endi +if $data11 != 3.000000000 then + return -1 +endi + + +sql select tbname,id5 from st2 where id5 between 2.0 and 3.0; + +if $rows != 2 then + return -1 +endi + +if $data00 != tb2 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data10 != tb3 then + return -1 +endi +if $data11 != 3 then + return -1 +endi + +sql select tbname,id6 from st2 where id6 between 2.0 and 3.0; + +if $rows != 2 then + return -1 +endi + +if $data00 != tb2 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data10 != tb3 then + return -1 +endi +if $data11 != 3 then + return -1 +endi + +sql select * from st2 where f1 between 2 and 3 and f2 between 2.0 and 3.0 and f3 between 2.0 and 3.0 and f4 between 2.0 and 3.0 and f5 between 2.0 and 3.0 and f6 between 2.0 and 3.0; + +if $rows != 2 then + return -1 +endi + +if $data01 != 2 then + return -1 +endi +if $data11 != 3 then + return -1 +endi + +sql_error select * from st2 where f7 between 2.0 and 3.0; +sql_error select * from st2 where f8 between 2.0 and 3.0; +sql_error select * from st2 where f9 between 2.0 and 3.0; + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/binary_escapeCharacter.sim b/tests/script/general/parser/binary_escapeCharacter.sim new file mode 100644 index 0000000000000000000000000000000000000000..176edd4e298d92689140644587622b20a267f63e --- /dev/null +++ b/tests/script/general/parser/binary_escapeCharacter.sim @@ -0,0 +1,108 @@ + +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +sql drop database if exists ecdb +sql create database ecdb +sql use ecdb + +sql create table tbx (ts timestamp, c1 int, c2 binary(20)) +sql insert into tbx values ('2019-10-05 18:00:01.000', 1, '\'') +sql insert into tbx values ('2019-10-05 18:00:02.000', 2, '\'abc') +sql insert into tbx values ('2019-10-05 18:00:03.000', 3, '123\'') +sql select * from tbx +print "=====rows:$rows, line0:$data02, line1:$data12, line2:$data22" +if $data02 != @'@ then + return -1 +endi + +if $data12 != @'abc@ then + return -1 +endi + +if $data22 != @123'@ then + return -1 +endi + +sql create table tb (ts timestamp, c1 binary(20)) +sql insert into tb values ('2019-10-05 18:00:01.000', 'abc''001') +sql insert into tb values ('2019-10-05 18:00:02.000', 'abc\'002') +sql insert into tb values ('2019-10-05 18:00:03.000', 'abc\\003') +sql insert into tb values ('2019-10-05 18:00:04.000', 'abc"004') +sql insert into tb values ('2019-10-05 18:00:05.000', 'abc\005') + +sql insert into tb values ('2019-10-05 18:00:06.000', "udp""001") +sql insert into tb values ('2019-10-05 18:00:07.000', "udp\"002") +sql insert into tb values ('2019-10-05 18:00:08.000', "udp\\003") +sql insert into tb values ('2019-10-05 18:00:09.000', "udp'004") +sql insert into tb values ('2019-10-05 18:00:10.000', "udp\005") + +sql select * from tb limit 5 +print "====rows: $rows " +if $rows != 5 then + return -1 +endi + +print "Single quotation ==== data01~05: $data01, $data11, $data21, $data31, $data41 " + +if $data01 != @abc'001@ then + return -1 +endi +if $data11 != @abc'002@ then + return -1 +endi +if $data21 != @abc\003@ then + #return -1 + print "[ERROR] expect: abc\003, act:$data21" +endi +if $data31 != @abc"004@ then + return -1 +endi +if $data41 != @abc005@ then + #return -1 + print "[ERROR] expect: abc005, act:$data41" +endi + +sql select * from tb limit 5 offset 5 + +if $rows != 5 then + return -1 +endi + +print "Double quotation ==== data01~05: $data01, $data11, $data21, $data31, $data41 " + +if $data01 != @udp"001@ then + return -1 +endi +if $data11 != @udp"002@ then + return -1 +endi +if $data21 != @udp\003@ then + # return -1 + print "[ERROR] expect: udp\003, act:$data21" +endi +if $data31 != @udp'004@ then + return -1 +endi +if $data41 != @udp005@ then + #return -1 + print "[ERROR] expect: udp005, act:$data41" +endi + +print ---------------------> TD-3967 +sql insert into tb values(now, '\\abc\\\\'); +sql insert into tb values(now, '\\abc\\\\'); +sql insert into tb values(now, '\\\\'); + +print ------------->sim bug +# sql_error insert into tb values(now, '\\\'); +sql_error insert into tb values(now, '\'); +#sql_error insert into tb values(now, '\\\n'); +sql insert into tb values(now, '\n'); + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/parser/col_arithmetic_operation.sim b/tests/script/general/parser/col_arithmetic_operation.sim new file mode 100644 index 0000000000000000000000000000000000000000..8bb692e3bbe8af3ec9ed179ad29d40b4712d257b --- /dev/null +++ b/tests/script/general/parser/col_arithmetic_operation.sim @@ -0,0 +1,154 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect +#========================================= setup environment ================================ + +$dbPrefix = ca_db +$tbPrefix = ca_tb +$stbPrefix = ca_stb +$tbNum = 10 +$rowNum = 10000 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== col_arithmetic_operation.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int) + +$i = 0 +$ts = $ts0 +$halfTbNum = $tbNum / 2 +#while $i < $halfTbNum + $t1 = $i + 1 + $t2 = $i + 2 + $t3 = $i + 3 + $t4 = $i + 4 + + $t5 = $i + $halfTbNum + $t6 = $t5 + 1 + $t7 = $t6 + 1 + $t8 = $t7 + 1 + $t9 = $t8 + 1 + + $tb0 = $tbPrefix . $i + $tb1 = $tbPrefix . $t1 + $tb2 = $tbPrefix . $t2 + $tb3 = $tbPrefix . $t3 + $tb4 = $tbPrefix . $t4 + + $tb5 = $tbPrefix . $t5 + $tb6 = $tbPrefix . $t6 + $tb7 = $tbPrefix . $t7 + $tb8 = $tbPrefix . $t8 + $tb9 = $tbPrefix . $t9 + + sql create table $tb0 using $stb tags( $i ) + sql create table $tb1 using $stb tags( $t1 ) + sql create table $tb2 using $stb tags( $t2 ) + sql create table $tb3 using $stb tags( $t3 ) + sql create table $tb4 using $stb tags( $t4 ) + + sql create table $tb5 using $stb tags( $t5 ) + sql create table $tb6 using $stb tags( $t6 ) + sql create table $tb7 using $stb tags( $t7 ) + sql create table $tb8 using $stb tags( $t8 ) + sql create table $tb9 using $stb tags( $t9 ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + sql insert into $tb0 values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) $tb1 values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) $tb2 values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) $tb3 values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) $tb4 values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) + $x = $x + 1 + endw + #$i = $i + 1 + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + + $ts = $ts + 1 + sql insert into $tb5 values ( $ts , NULL , $c , NULL , $c , NULL , $c , NULL, NULL , $nchar ) $tb6 values ( $ts , NULL , $c , NULL , $c , NULL , $c , NULL, NULL , $nchar ) $tb7 values ( $ts , NULL , $c , NULL , $c , NULL , $c , NULL, NULL , $nchar ) $tb8 values ( $ts , NULL , $c , NULL , $c , NULL , $c , NULL, NULL , $nchar ) $tb9 values ( $ts , NULL , $c , NULL , $c , NULL , $c , NULL, NULL , $nchar ) + $x = $x + 1 + endw + +#endw + +#=================================== above are setup test environment ============================= +run general/parser/col_arithmetic_query.sim + +#======================================= all in files query ======================================= +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 500 +system sh/exec.sh -n dnode1 -s start + +print ================== server restart completed +sql connect +sleep 5000 + +run general/parser/col_arithmetic_query.sim + +# ================================================================================================ + +print ====================> crash +sql use $db +sql select spread(ts )/(1000*3600*24) from $stb interval(1y) + +sql_error select first(c1, c2) - last(c1, c2) from $stb interval(1y) +sql_error select first(ts) - last(ts) from $stb interval(1y) +sql_error select top(c1, 2) - last(c1) from $stb; +sql_error select stddev(c1) - last(c1) from $stb; +sql_error select diff(c1) - last(c1) from $stb; +sql_error select first(c7) - last(c7) from $stb; +sql_error select first(c8) - last(c8) from $stb; +sql_error select first(c9) - last(c9) from $stb; +sql_error select max(c2*2) from $tb +sql_error select max(c1-c2) from $tb + +#========================================regression test cases==================================== +print =====================> td-1764 +sql select sum(c1)/count(*), sum(c1) as b, count(*) as b from $stb interval(1y) +if $rows != 1 then + return -1 +endi + +if $data00 != @18-01-01 00:00:00.000@ then + return -1 +endi + +if $data01 != 2.250000000 then + return -1 +endi + +if $data02 != 225000 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/parser/col_arithmetic_query.sim b/tests/script/general/parser/col_arithmetic_query.sim new file mode 100644 index 0000000000000000000000000000000000000000..2576b1442a7793ab4bb5d22d52ce950d885cdbd0 --- /dev/null +++ b/tests/script/general/parser/col_arithmetic_query.sim @@ -0,0 +1,657 @@ +# ======================================= query test cases ======================================== +# select from table + +$dbPrefix = ca_db +$tbPrefix = ca_tb +$stbPrefix = ca_stb +$rowNum = 10000 + +$i = 0 +$db = $dbPrefix . $i +sql use $db + +$tb = $tbPrefix . 0 +$stb = $stbPrefix . $i + +## TBASE-344 +sql select c1*2 from $tb +if $rows != $rowNum then + return -1 +endi +if $data00 != 0.000000000 then + return -1 +endi +if $data10 != 2.000000000 then + return -1 +endi +if $data20 != 4.000000000 then + return -1 +endi +if $data90 != 18.000000000 then + return -1 +endi + +# asc/desc order [d.2] ====================================================== +sql select c1 *( 2 / 3 ), c1/c1 from $tb order by ts asc; +if $rows != 10000 then + return -1 +endi + +if $data00 != 0.000000000 then + return -1 +endi + +#if $data01 != -nan then +# print expect -nan, actual: $data01 +# return -1 +#endi + +if $data10 != 0.666666667 then + return -1 +endi + +if $data11 != 1.000000000 then + return -1 +endi + +if $data90 != 6.000000000 then + return -1 +endi + +if $data91 != 1.000000000 then + return -1 +endi + +sql select (c1 * 2) % 7.9, c1*1, c1*1*1, c1*c1, c1*c1*c1 from $tb order by ts desc; +if $rows != 10000 then + return -1 +endi + +if $data00 != 2.200000000 then + print expect 2.200000000, actual:$data00 + return -1 +endi + +if $data01 != 9.000000000 then + return -1 +endi + +if $data02 != 9.000000000 then + return -1 +endi + +if $data03 != 81.000000000 then + return -1 +endi + +if $data04 != 729.000000000 then + return -1 +endi + + +if $data10 != 0.200000000 then + return -1 +endi + +if $data11 != 8.000000000 then + return -1 +endi + +if $data12 != 8.000000000 then + return -1 +endi + +if $data13 != 64.000000000 then + return -1 +endi + +if $data14 != 512.000000000 then + return -1 +endi + +if $data90 != 0.000000000 then + return -1 +endi + +if $data91 != 0.000000000 then + return -1 +endi + +if $data92 != 0.000000000 then + return -1 +endi + +if $data93 != 0.000000000 then + return -1 +endi + +if $data94 != 0.000000000 then + return -1 +endi + +# [d.3] +sql select c1 * c2 /4 from $tb where ts < 1537166000000 and ts > 1537156000000 +if $rows != 17 then + return -1 +endi + +if $data00 != 12.250000000 then + return -1 +endi + +if $data10 != 16.000000000 then + return -1 +endi + +if $data20 != 20.250000000 then + print expect 20.250000000, actual:$data21 + return -1 +endi + +if $data30 != 0.000000000 then + return -1 +endi + +# no result return [d.3] ============================================================== +sql select c1 * 91- 7 from $tb where ts < 1537146000000 +if $rows != 0 then + return -1 +endi + +# no result return [d.3] +sql select c2 - c2 from $tb where ts > '2018-09-17 12:50:00.000' and ts<'2018-09-17 13:00:00.000' +if $rows != 0 then + return -1 +endi + +# single row result aggregation [d.4] ================================================= +# not available + +# error cases +# not available + +# multi row result aggregation [d.4] +sql_error select top(c1, 1) - bottom(c1, 1) from $tb +sql_error select top(c1, 99) - bottom(c1, 99) from $tb +sql_error select top(c1,1) - 88 from $tb + +# all data types [d.6] ================================================================ +sql select c2-c1*1.1, c3/c2, c4*c3, c5%c4, (c6+c4)%22, c2-c2 from $tb +if $rows != 10000 then + return -1 +endi + +if $data00 != 0.000000000 then + return -1 +endi + +#if $data01 != -nan then +# return -1 +#endi + +if $data02 != 0.000000000 then + return -1 +endi + +if $data03 != NULL then + return -1 +endi + +if $data04 != 0.000000000 then + return -1 +endi + +if $data05 != 0.000000000 then + return -1 +endi + +if $data90 != -0.900000000 then + return -1 +endi + +if $data91 != 1.000000000 then + return -1 +endi + +if $data92 != 81.000000000 then + return -1 +endi + +if $data93 != 0.000000000 then + return -1 +endi + +if $data94 != 18.000000000 then + return -1 +endi + +# error case, ts/bool/binary/nchar not support arithmetic expression +sql_error select ts+ts from $tb +sql_error select ts+22 from $tb +sql_error select c7*12 from $tb +sql_error select c8/55 from $tb +sql_error select c9+c8 from $tb +sql_error select c7-c8, c9-c8 from $tb +sql_error select ts-c9 from $tb +sql_error select c8+c7, c9+c9+c8+c7/c6 from $tb + +# arithmetic expression in join [d.7]================================================== + + +# arithmetic expression in union [d.8]================================================= + + +# arithmetic expression in group by [d.9]============================================== +# in group by tag, not support for normal table +sql_error select c5*99 from $tb group by t1 + +# in group by column +sql_error select c6-(c6+c3)*12 from $tb group by c3; + + +# limit offset [d.10]================================================================== +sql select c6 * c1 + 12 from $tb limit 12 offset 99; +if $rows != 12 then + return -1 +endi + +if $data00 != 93.000000000 then + return -1 +endi + +if $data90 != 76.000000000 then + return -1 +endi + +sql select c4 / 99.123 from $tb limit 10 offset 9999; +if $rows != 1 then + return -1 +endi + +if $data00 != 0.090796283 then + return -1 +endi + +# slimit/soffset not support for normal table query. [d.11]============================ +sql_error select sum(c1) from $tb slimit 1 soffset 19; + +# fill [d.12]========================================================================== +sql_error select c2-c2, c3-c4, c5%c3 from $tb fill(value, 12); + +# constant column. [d.13]============================================================== +sql select c1, c2+c6, 12.9876545678, 1, 1.1 from $tb +if $rows != 10000 then + return -1 +endi + +if $data00 != 0 then + return -1 +endi + +if $data01 != 0.000000000 then + return -1 +endi + +if $data02 != 12.987654568 then + return -1 +endi + +if $data03 != 1 then + return -1 +endi + +if $data04 != 1.100000000 then + return -1 +endi + +if $data10 != 1 then + return -1 +endi + +# column value filter [d.14]=========================================================== +sql select c1, c2+c6, 12.9876545678, 1, 1.1 from $tb where c1<2 +if $rows != 2000 then + return -1 +endi + +if $data00 != 0 then + return -1 +endi + +if $data01 != 0.000000000 then + return -1 +endi + +if $data02 != 12.987654568 then + return -1 +endi + +if $data03 != 1 then + return -1 +endi + +if $data10 != 1 then + return -1 +endi + +if $data20 != 0 then + return -1 +endi + +# tag filter(not support for normal table). [d.15]===================================== +sql_error select c2+99 from $tb where t1=12; + +# multi-field output [d.16]============================================================ +sql select c4*1+1/2,c4*1+1/2,c4*1+1/2,c4*1+1/2,c4*1+1/2 from $tb +if $rows != $rowNum then + return -1 +endi +if $data00 != 0.500000000 then + return -1 +endi +if $data10 != 1.500000000 then + return -1 +endi +if $data90 != 9.500000000 then + return -1 +endi + +# interval query [d.17]================================================================== +sql_error select c2*c2, c3-c3, c4+9 from $tb interval(1s) +sql_error select c7-c9 from $tb interval(2y) + +# aggregation query [d.18]=============================================================== +# see test cases below + +# first/last query [d.19]=============================================================== +# see test cases below + +# multiple retrieve [d.20]=============================================================== +sql select c2-c2, 911 from $tb + +#======================================= aggregation function arithmetic query cases =================================== +# on $tb percentile() spread(ts) bug + +# asc/desc order [d.2] +sql select first(c1) * ( 2 / 3 ) from $stb order by ts asc; +if $rows != 1 then + return -1 +endi + +if $data00 != 0.000000000 then + return -1 +endi + +sql select first(c1) * (2/99) from $stb order by ts desc; +if $rows != 1 then + return -1 +endi + +if $data00 != 0.000000000 then + return -1 +endi + +sql select (count(c1) * 2) % 7.9, (count(c1) * 2), ( count(1)*2) from $stb order by ts desc; +if $rows != 1 then + return -1 +endi + +if $data00 != 1.800000000 then + return -1 +endi + +if $data01 != 100000.000000000 then + return -1 +endi + +if $data02 != 200000.000000000 then + return -1 +endi + +sql select spread( c1 )/44, spread(c1), 0.204545455 * 44 from $stb order by ts asc; +if $rows != 1 then + return -1 +endi + +if $data00 != 0.204545455 then + print expect 0.204545455, actual: $data00 + return -1 +endi + +if $data01 != 9.000000000 then + return -1 +endi + +if $data02 != 9.000000020 then + return -1 +endi + +# all possible function in the arithmetic expression, add more +sql select min(c1) * max(c2) /4, sum(c1) * apercentile(c2, 20), apercentile(c4, 33) + 52/9, spread(c5)/min(c2), count(1)/sum(c1), avg(c2)*count(c2) from $stb where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-11-25 19:30:01.000'; +if $rows != 1 then + return -1 +endi + +if $data00 != 0.000000000 then + return -1 +endi + +if $data01 != 225000.000000000 then + return -1 +endi + +if $data02 != 8.077777778 then + return -1 +endi + +if $data03 != NULL then + return -1 +endi + +if $data04 != 0.444444444 then + return -1 +endi + +if $data05 != 450000.000000000 then + return -1 +endi + +# no result return [d.3]=============================================================== +sql select first(c1) * 91 - 7, last(c3) from $stb where ts < 1537146000000 +if $rows != 0 then + return -1 +endi + +# no result return [d.3] +sql select sum(c2) - avg(c2) from $stb where ts > '2018-11-25 19:30:01.000' +if $rows != 0 then + return -1 +endi + +# single row result aggregation [d.4]=================================================== +# all those cases are aggregation test cases. + +# error cases +sql_error select first(c1, c2) - last(c1, c2) from $stb +sql_error select top(c1, 5) - bottom(c1, 5) from $stb +sql_error select first(*) - 99 from $stb + +# multi row result aggregation [d.4] +sql_error select top(c1, 1) - bottom(c1, 1) from $stb +sql_error select top(c1, 99) - bottom(c1, 99) from $stb + +# query on super table [d.5]============================================================= +# all cases in this part are query on super table + +# all data types [d.6]=================================================================== +sql select c2-c1, c3/c2, c4*c3, c5%c4, c6+99%22 from $stb + +# error case, ts/bool/binary/nchar not support arithmetic expression +sql_error select first(c7)*12 from $stb +sql_error select last(c8)/55 from $stb +sql_error select last_row(c9) + last_row(c8) from $stb + +# arithmetic expression in join [d.7]=============================================================== + + +# arithmetic expression in union [d.8]=============================================================== + + +# arithmetic expression in group by [d.9]=============================================================== +# in group by tag +sql select avg(c4)*99 from $stb group by t1 +if $rows != 10 then + return -1 +endi + +if $data00 != 445.500000000 then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +if $data90 != 445.500000000 then + return -1 +endi + +if $data91 != 9 then + return -1 +endi + +# in group by column +#sql select apercentile(c6, 50)-first(c6)+last(c5)*12, last(c5)*12 from ca_stb0 group by c2; +#if $rows != 10 then +# return -1 +#endi +# +#if $data00 != 0.000000000 then +# return -1 +#endi +# +#if $data01 != 0.000000000 then +# return -1 +#endi +# +#if $data10 != 12.000000000 then +# return -1 +#endi +# +#if $data11 != 12.000000000 then +# return -1 +#endi +# +#if $data20 != 24.000000000 then +# return -1 +#endi +# +#if $data21 != 24.000000000 then +# return -1 +#endi +# +sql_error select first(c6) - last(c6) *12 / count(*) from $stb group by c3; + +sql select first(c6) - last(c6) *12 / count(*) from $stb group by c5; +if $rows != 11 then + return -1 +endi + +if $data00 != -0.002160000 then + return -1 +endi + +if $data10 != 0.000000000 then + return -1 +endi + +if $data90 != 7.980800000 then + return -1 +endi + +# limit offset [d.10]=============================================================== +sql select first(c6) - sum(c6) + 12 from $stb limit 12 offset 0; +if $rows != 1 then + return -1 +endi + +if $data00 != -449988.000000000 then + return -1 +endi + +sql select apercentile(c4, 21) / 99.123 from $stb limit 1 offset 1; +if $rows != 0 then + return -1 +endi + +sql select apercentile(c4, 21) / sum(c4) from $stb interval(1s) limit 1 offset 1; +if $rows != 1 then + return -1 +endi + +# slimit/soffset not support for normal table query. [d.11]=============================================================== +sql select sum(c1) from $stb slimit 1 soffset 19; +if $rows != 0 then + return -1 +endi + +sql select sum(c1) from $stb interval(1s) group by tbname slimit 1 soffset 1 +sql select sum(c1) from ca_stb0 interval(1s) group by tbname slimit 2 soffset 4 limit 10 offset 1 + +# fill [d.12]=============================================================== +sql_error select first(c1)-last(c1), sum(c3)*count(c3), spread(c5 ) % count(*) from $stb interval(1s) fill(prev); +sql_error select first(c1) from $stb fill(value, 20); + +# constant column. [d.13]=============================================================== + + +# column value filter [d.14]=============================================================== + + +# tag filter. [d.15]=============================================================== +sql select sum(c2)+99 from $stb where t1=12; + +# multi-field output [d.16]=============================================================== +sql select count(*), sum(c1)*avg(c2), avg(c3)*count(c3), sum(c3), sum(c4), first(c7), last(c8), first(c9), first(c7), last(c8) from $tb + +sql select c4*1+1/2 from $tb +if $rows != $rowNum then + return -1 +endi +if $data00 != 0.500000000 then + return -1 +endi +if $data10 != 1.500000000 then + return -1 +endi +if $data90 != 9.500000000 then + return -1 +endi + +# interval query [d.17]=============================================================== +sql select avg(c2)*count(c2), sum(c3)-first(c3), last(c4)+9 from $stb interval(1s) +if $rows != 10000 then + return -1 +endi + +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi + +sql_error select first(c7)- last(c1) from $tb interval(2y) + +# aggregation query [d.18]=============================================================== +# all cases in this part are aggregation query test. + +# first/last query [d.19]=============================================================== + + +# multiple retrieve [d.20]=============================================================== +sql select c2-c2 from $tb + + +sql select first(c1)-last(c1), spread(c2), max(c3) - min(c3), avg(c4)*count(c4) from $tb + + +#====================================================super table query================================================== + diff --git a/tests/script/general/parser/columnValue.sim b/tests/script/general/parser/columnValue.sim new file mode 100644 index 0000000000000000000000000000000000000000..c98542fbf26a2d6098ca01c48c38d9fdca92b03f --- /dev/null +++ b/tests/script/general/parser/columnValue.sim @@ -0,0 +1,26 @@ +#### +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +print ========== columnValues.sim + +sql drop database if exists db +sql create database db +sql use db + +run general/parser/columnValue_bool.sim +run general/parser/columnValue_tinyint.sim +run general/parser/columnValue_smallint.sim +run general/parser/columnValue_int.sim +run general/parser/columnValue_bigint.sim +run general/parser/columnValue_float.sim +run general/parser/columnValue_double.sim +run general/parser/columnValue_unsign.sim + +system sh/exec.sh -n dnode1 -s stop -x SIGINT + diff --git a/tests/script/general/parser/columnValue_bigint.sim b/tests/script/general/parser/columnValue_bigint.sim new file mode 100644 index 0000000000000000000000000000000000000000..0d89d9e61c20175964304a6b5aa282c074e8b954 --- /dev/null +++ b/tests/script/general/parser/columnValue_bigint.sim @@ -0,0 +1,466 @@ +sleep 100 +sql connect +sql create database if not exists db +sql use db + +#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value + +######## case 0: bigint +print ========== bigint +sql create table mt_bigint (ts timestamp, c bigint) tags (tagname bigint) + +## case 00: static create table for test tag values +sql create table st_bigint_0 using mt_bigint tags (NULL) +sql select tagname from st_bigint_0 +if $data00 != NULL then + return -1 +endi +sql create table st_bigint_1 using mt_bigint tags (NULL) +sql select tagname from st_bigint_1 +if $data00 != NULL then + return -1 +endi +sql create table st_bigint_2 using mt_bigint tags ('NULL') +sql select tagname from st_bigint_2 +if $data00 != NULL then + return -1 +endi +sql create table st_bigint_3 using mt_bigint tags ('NULL') +sql select tagname from st_bigint_3 +if $data00 != NULL then + return -1 +endi +sql create table st_bigint_4 using mt_bigint tags ("NULL") +sql select tagname from st_bigint_4 +if $data00 != NULL then + return -1 +endi +sql create table st_bigint_5 using mt_bigint tags ("NULL") +sql select tagname from st_bigint_5 +if $data00 != NULL then + return -1 +endi +sql create table st_bigint_6 using mt_bigint tags (-9223372036854775807) +sql select tagname from st_bigint_6 +if $data00 != -9223372036854775807 then + return -1 +endi +sql create table st_bigint_7 using mt_bigint tags (9223372036854775807) +sql select tagname from st_bigint_7 +if $data00 != 9223372036854775807 then + return -1 +endi +sql create table st_bigint_8 using mt_bigint tags (37) +sql select tagname from st_bigint_8 +if $data00 != 37 then + return -1 +endi +sql create table st_bigint_9 using mt_bigint tags (-100) +sql select tagname from st_bigint_9 +if $data00 != -100 then + return -1 +endi +sql create table st_bigint_10 using mt_bigint tags (+113) +sql select tagname from st_bigint_10 +if $data00 != 113 then + return -1 +endi +sql create table st_bigint_11 using mt_bigint tags ('-100') +sql select tagname from st_bigint_11 +if $data00 != -100 then + return -1 +endi +sql create table st_bigint_12 using mt_bigint tags ("+78") +sql select tagname from st_bigint_12 +if $data00 != 78 then + return -1 +endi +sql create table st_bigint_13 using mt_bigint tags (+0078) +sql select tagname from st_bigint_13 +if $data00 != 78 then + return -1 +endi +sql create table st_bigint_14 using mt_bigint tags (-00078) +sql select tagname from st_bigint_14 +if $data00 != -78 then + return -1 +endi + +## case 01: insert values for test column values +sql insert into st_bigint_0 values (now, NULL) +sql select * from st_bigint_0 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_bigint_1 values (now, NULL) +sql select * from st_bigint_1 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_bigint_2 values (now, 'NULL') +sql select * from st_bigint_2 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_bigint_3 values (now, 'NULL') +sql select * from st_bigint_3 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_bigint_4 values (now, "NULL") +sql select * from st_bigint_4 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_bigint_5 values (now, "NULL") +sql select * from st_bigint_5 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_bigint_6 values (now, 9223372036854775807) +sql select * from st_bigint_6 +if $rows != 1 then + return -1 +endi +if $data01 != 9223372036854775807 then + return -1 +endi +sql insert into st_bigint_7 values (now, -9223372036854775807) +sql select * from st_bigint_7 +if $rows != 1 then + return -1 +endi +if $data01 != -9223372036854775807 then + return -1 +endi +sql insert into st_bigint_8 values (now, +100) +sql select * from st_bigint_8 +if $rows != 1 then + return -1 +endi +if $data01 != 100 then + return -1 +endi +sql insert into st_bigint_9 values (now, "-098") +sql select * from st_bigint_9 +if $rows != 1 then + return -1 +endi +if $data01 != -98 then + return -1 +endi +sql insert into st_bigint_10 values (now, '0') +sql select * from st_bigint_10 +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +sql insert into st_bigint_11 values (now, -0) +sql select * from st_bigint_11 +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +sql insert into st_bigint_12 values (now, "+056") +sql select * from st_bigint_12 +if $rows != 1 then + return -1 +endi +if $data01 != 56 then + return -1 +endi + +sql insert into st_bigint_13 values (now, +056) +sql select * from st_bigint_13 +if $rows != 1 then + return -1 +endi +if $data01 != 56 then + return -1 +endi + +sql insert into st_bigint_14 values (now, -056) +sql select * from st_bigint_14 +if $rows != 1 then + return -1 +endi +if $data01 != -56 then + return -1 +endi + +## case 02: dynamic create table for test tag values +sql insert into st_bigint_16 using mt_bigint tags (NULL) values (now, NULL) +sql select tagname from st_bigint_16 +if $data00 != NULL then + return -1 +endi +sql select * from st_bigint_16 +if $data01 != NULL then + return -1 +endi + +sql insert into st_bigint_17 using mt_bigint tags (NULL) values (now, NULL) +sql select tagname from st_bigint_17 +if $data00 != NULL then + return -1 +endi +sql select * from st_bigint_17 +if $data01 != NULL then + return -1 +endi +sql insert into st_bigint_18 using mt_bigint tags ('NULL') values (now, 'NULL') +sql select tagname from st_bigint_18 +if $data00 != NULL then + return -1 +endi +sql select * from st_bigint_18 +if $data01 != NULL then + return -1 +endi +sql insert into st_bigint_19 using mt_bigint tags ('NULL') values (now, 'NULL') +sql select tagname from st_bigint_19 +if $data00 != NULL then + return -1 +endi +sql select * from st_bigint_19 +if $data01 != NULL then + return -1 +endi +sql insert into st_bigint_20 using mt_bigint tags ("NULL") values (now, "NULL") +sql select tagname from st_bigint_20 +if $data00 != NULL then + return -1 +endi +sql select * from st_bigint_20 +if $data01 != NULL then + return -1 +endi +sql insert into st_bigint_21 using mt_bigint tags ("NULL") values (now, "NULL") +sql select tagname from st_bigint_21 +if $data00 != NULL then + return -1 +endi +sql select * from st_bigint_21 +if $data01 != NULL then + return -1 +endi +sql insert into st_bigint_22 using mt_bigint tags (9223372036854775807) values (now, 9223372036854775807) +sql select tagname from st_bigint_22 +if $data00 != 9223372036854775807 then + return -1 +endi +sql select * from st_bigint_22 +if $data01 != 9223372036854775807 then + return -1 +endi +sql insert into st_bigint_23 using mt_bigint tags (-9223372036854775807) values (now, -9223372036854775807) +sql select tagname from st_bigint_23 +if $data00 != -9223372036854775807 then + return -1 +endi +sql select * from st_bigint_23 +if $data01 != -9223372036854775807 then + return -1 +endi +sql insert into st_bigint_24 using mt_bigint tags (10) values (now, 10) +sql select tagname from st_bigint_24 +if $data00 != 10 then + return -1 +endi +sql select * from st_bigint_24 +if $data01 != 10 then + return -1 +endi +sql insert into st_bigint_25 using mt_bigint tags ("-0") values (now, "-0") +sql select tagname from st_bigint_25 +if $data00 != 0 then + return -1 +endi +sql select * from st_bigint_25 +if $data01 != 0 then + return -1 +endi +sql insert into st_bigint_26 using mt_bigint tags ('123') values (now, '123') +sql select tagname from st_bigint_26 +if $data00 != 123 then + return -1 +endi +sql select * from st_bigint_26 +if $data01 != 123 then + return -1 +endi +sql insert into st_bigint_27 using mt_bigint tags (+056) values (now, +00056) +sql select tagname from st_bigint_27 +if $data00 != 56 then + return -1 +endi +sql select * from st_bigint_27 +if $data01 != 56 then + return -1 +endi +sql insert into st_bigint_28 using mt_bigint tags (-056) values (now, -0056) +sql select tagname from st_bigint_28 +if $data00 != -56 then + return -1 +endi +sql select * from st_bigint_28 +if $data01 != -56 then + return -1 +endi + +### case 03: alter tag values +#sql alter table st_bigint_0 set tag tagname=9223372036854775807 +#sql select tagname from st_bigint_0 +#if $data00 != 9223372036854775807 then +# return -1 +#endi +#sql alter table st_bigint_0 set tag tagname=-9223372036854775807 +#sql select tagname from st_bigint_0 +#if $data00 != -9223372036854775807 then +# return -1 +#endi +#sql alter table st_bigint_0 set tag tagname=+100 +#sql select tagname from st_bigint_0 +#if $data00 != 100 then +# return -1 +#endi +#sql alter table st_bigint_0 set tag tagname=-33 +#sql select tagname from st_bigint_0 +#if $data00 != -33 then +# return -1 +#endi +#sql alter table st_bigint_0 set tag tagname='+98' +#sql select tagname from st_bigint_0 +#if $data00 != 98 then +# return -1 +#endi +#sql alter table st_bigint_0 set tag tagname='-076' +#sql select tagname from st_bigint_0 +#if $data00 != -76 then +# return -1 +#endi +#sql alter table st_bigint_0 set tag tagname=+0012 +#sql select tagname from st_bigint_0 +#if $data00 != 12 then +# return -1 +#endi +#sql alter table st_bigint_0 set tag tagname=-00063 +#sql select tagname from st_bigint_0 +#if $data00 != -63 then +# return -1 +#endi + +## case 04: illegal input +################## when overflow, auto set max +sql_error create table st_bigint_e0 using mt_bigint tags (9223372036854775808) +sql_error create table st_bigint_e0_1 using mt_bigint tags (-9223372036854775808) +sql_error create table st_bigint_e0_2 using mt_bigint tags (92233720368547758080) +sql_error create table st_bigint_e0_3 using mt_bigint tags (-9223372036854775809) +#sql_error create table st_bigint_e0 using mt_bigint tags (12.80) truncate integer part +#sql_error create table st_bigint_e0 using mt_bigint tags (-11.80) +sql_error create table st_bigint_e0 using mt_bigint tags (123abc) +sql_error create table st_bigint_e0 using mt_bigint tags ("123abc") +sql_error create table st_bigint_e0 using mt_bigint tags (abc) +sql_error create table st_bigint_e0 using mt_bigint tags ("abc") +sql_error create table st_bigint_e0 using mt_bigint tags (" ") +sql_error create table st_bigint_e0 using mt_bigint tags ('') + +sql create table st_bigint_e0 using mt_bigint tags (123) +sql create table st_bigint_e1 using mt_bigint tags (123) +sql create table st_bigint_e2 using mt_bigint tags (123) +sql create table st_bigint_e3 using mt_bigint tags (123) +sql create table st_bigint_e4 using mt_bigint tags (123) +sql create table st_bigint_e5 using mt_bigint tags (123) +sql create table st_bigint_e6 using mt_bigint tags (123) +sql create table st_bigint_e7 using mt_bigint tags (123) +sql create table st_bigint_e8 using mt_bigint tags (123) +sql create table st_bigint_e9 using mt_bigint tags (123) +sql create table st_bigint_e10 using mt_bigint tags (123) +sql create table st_bigint_e11 using mt_bigint tags (123) +sql create table st_bigint_e12 using mt_bigint tags (123) + +sql_error insert into st_bigint_e0 values (now, 9223372036854775808) +sql_error insert into st_bigint_e1 values (now, -9223372036854775808) +sql_error insert into st_bigint_e2 values (now, 9223372036854775809) +sql_error insert into st_bigint_e3 values (now, -9223372036854775808) +#sql_error insert into st_bigint_e4 values (now, 922337203.6854775808) +#sql_error insert into st_bigint_e5 values (now, -922337203685477580.9) +sql_error insert into st_bigint_e6 values (now, 123abc) +sql_error insert into st_bigint_e7 values (now, "123abc") +sql_error insert into st_bigint_e9 values (now, abc) +sql_error insert into st_bigint_e10 values (now, "abc") +sql_error insert into st_bigint_e11 values (now, " ") +sql_error insert into st_bigint_e12 values (now, '') + +sql_error insert into st_bigint_e13 using mt_bigint tags (033) values (now, 9223372036854775808) +sql_error insert into st_bigint_e14 using mt_bigint tags (033) values (now, -9223372036854775808) +sql_error insert into st_bigint_e15 using mt_bigint tags (033) values (now, 9223372036854775818) +sql_error insert into st_bigint_e16 using mt_bigint tags (033) values (now, -9923372036854775808) +#sql_error insert into st_bigint_e17 using mt_bigint tags (033) values (now, 92233720368547758.08) +#sql_error insert into st_bigint_e18 using mt_bigint tags (033) values (now, -92233720368547.75808) +sql_error insert into st_bigint_e19 using mt_bigint tags (033) values (now, 123abc) +sql_error insert into st_bigint_e20 using mt_bigint tags (033) values (now, "123abc") +sql_error insert into st_bigint_e22 using mt_bigint tags (033) values (now, abc) +sql_error insert into st_bigint_e23 using mt_bigint tags (033) values (now, "abc") +sql_error insert into st_bigint_e24 using mt_bigint tags (033) values (now, " ") +sql_error insert into st_bigint_e25 using mt_bigint tags (033) values (now, '') + +sql_error insert into st_bigint_e13_0 using mt_bigint tags (9223372036854775808) values (now, -033) +sql_error insert into st_bigint_e14_0 using mt_bigint tags (-9223372036854775808) values (now, -033) +sql_error insert into st_bigint_e15_0 using mt_bigint tags (9223372036854775809) values (now, -033) +sql_error insert into st_bigint_e16_0 using mt_bigint tags (-9223372036854775898) values (now, -033) +#sql_error insert into st_bigint_e17 using mt_bigint tags (12.80) values (now, -033) +#sql_error insert into st_bigint_e18 using mt_bigint tags (-11.80) values (now, -033) +sql_error insert into st_bigint_e19 using mt_bigint tags (123abc) values (now, -033) +sql_error insert into st_bigint_e20 using mt_bigint tags ("123abc") values (now, -033) +sql_error insert into st_bigint_e22 using mt_bigint tags (abc) values (now, -033) +sql_error insert into st_bigint_e23 using mt_bigint tags ("abc") values (now, -033) +sql_error insert into st_bigint_e24 using mt_bigint tags (" ") values (now, -033) +sql_error insert into st_bigint_e25 using mt_bigint tags ('') values (now, -033) + +sql insert into st_bigint_e13 using mt_bigint tags (033) values (now, 00062) +sql insert into st_bigint_e14 using mt_bigint tags (033) values (now, 00062) +sql insert into st_bigint_e15 using mt_bigint tags (033) values (now, 00062) +sql insert into st_bigint_e16 using mt_bigint tags (033) values (now, 00062) +sql insert into st_bigint_e17 using mt_bigint tags (033) values (now, 00062) +sql insert into st_bigint_e18 using mt_bigint tags (033) values (now, 00062) +sql insert into st_bigint_e19 using mt_bigint tags (033) values (now, 00062) +sql insert into st_bigint_e20 using mt_bigint tags (033) values (now, 00062) +sql insert into st_bigint_e21 using mt_bigint tags (033) values (now, 00062) +sql insert into st_bigint_e22 using mt_bigint tags (033) values (now, 00062) +sql insert into st_bigint_e23 using mt_bigint tags (033) values (now, 00062) +sql insert into st_bigint_e24 using mt_bigint tags (033) values (now, 00062) +sql insert into st_bigint_e25 using mt_bigint tags (033) values (now, 00062) + +#sql alter table st_bigint_e13 set tag tagname=9223372036854775808 +#sql_error alter table st_bigint_e14 set tag tagname=-9223372036854775808 +#sql alter table st_bigint_e15 set tag tagname=92233720368547758080 +#sql_error alter table st_bigint_e16 set tag tagname=-92233720368547758080 +#sql_error alter table st_bigint_e19 set tag tagname=123abc +#sql_error alter table st_bigint_e20 set tag tagname="123abc" +#sql_error alter table st_bigint_e22 set tag tagname=abc +#sql_error alter table st_bigint_e23 set tag tagname="abc" +#sql_error alter table st_bigint_e24 set tag tagname=" " +#sql_error alter table st_bigint_e25 set tag tagname='' diff --git a/tests/script/general/parser/columnValue_bool.sim b/tests/script/general/parser/columnValue_bool.sim new file mode 100644 index 0000000000000000000000000000000000000000..3a7dcab2654b372ef59065a59407144ab4fb39c1 --- /dev/null +++ b/tests/script/general/parser/columnValue_bool.sim @@ -0,0 +1,630 @@ +sleep 100 +sql connect +sql create database if not exists db +sql use db + +#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value + +######## case 0: bool +print ========== bool +sql create table mt_bool (ts timestamp, c bool) tags (tagname bool) + +## case 00: static create table for test tag values +sql create table st_bool_0 using mt_bool tags (NULL) +sql select tagname from st_bool_0 +if $data00 != NULL then + print ==1== expect: NULL, actually: $data00 + return -1 +endi +sql create table st_bool_1 using mt_bool tags (NULL) +sql select tagname from st_bool_1 +if $data00 != NULL then + print ==2== expect: NULL, actually: $data00 + return -1 +endi +sql create table st_bool_2 using mt_bool tags ('NULL') +sql select tagname from st_bool_2 +if $data00 != NULL then + print ==3== expect: NULL, actually: $data00 + return -1 +endi +sql create table st_bool_3 using mt_bool tags ('NULL') +sql select tagname from st_bool_3 +if $data00 != NULL then + print ==4== expect: NULL, actually: $data00 + return -1 +endi +sql create table st_bool_4 using mt_bool tags ("NULL") +sql select tagname from st_bool_4 +if $data00 != NULL then + print ==5== expect: NULL, actually: $data00 + return -1 +endi +sql create table st_bool_5 using mt_bool tags ("NULL") +sql select tagname from st_bool_5 +if $data00 != NULL then + print ==6== expect: NULL, actually: $data00 + return -1 +endi +sql create table st_bool_6 using mt_bool tags ("true") +sql select tagname from st_bool_6 +if $data00 != 1 then + print ==7== expect: 1, actually: $data00 + return -1 +endi +sql create table st_bool_7 using mt_bool tags ('true') +sql select tagname from st_bool_7 +if $data00 != 1 then + print ==8== expect: 1, actually: $data00 + return -1 +endi +sql create table st_bool_8 using mt_bool tags (true) +sql select tagname from st_bool_8 +if $data00 != 1 then + print ==9== expect: 1, actually: $data00 + return -1 +endi +sql create table st_bool_9 using mt_bool tags ("false") +sql select tagname from st_bool_9 +if $data00 != 0 then + print ==10== expect: 0, actually: $data00 + return -1 +endi +sql create table st_bool_10 using mt_bool tags ('false') +sql select tagname from st_bool_10 +if $data00 != 0 then + print ==11== expect: 0, actually: $data00 + return -1 +endi +sql create table st_bool_11 using mt_bool tags (false) +sql select tagname from st_bool_11 +if $data00 != 0 then + print ==12== expect: 0, actually: $data00 + return -1 +endi +sql create table st_bool_12 using mt_bool tags (0) +sql select tagname from st_bool_12 +if $data00 != 0 then + print ==13== expect: 0, actually: $data00 + return -1 +endi +sql create table st_bool_13 using mt_bool tags (1) +sql select tagname from st_bool_13 +if $data00 != 1 then + print ==14== expect: 1, actually: $data00 + return -1 +endi +sql create table st_bool_14 using mt_bool tags (6.9) +sql select tagname from st_bool_14 +if $data00 != 1 then + print ==15== expect: 1, actually: $data00 + return -1 +endi +sql create table st_bool_15 using mt_bool tags (-3) +sql select tagname from st_bool_15 +if $data00 != 1 then + print ==16== expect: 1, actually: $data00 + return -1 +endi +sql create table st_bool_15_0 using mt_bool tags (+300) +sql select tagname from st_bool_15_0 +if $data00 != 1 then + print ==16== expect: 1, actually: $data00 + return -1 +endi +sql create table st_bool_15_1 using mt_bool tags (-8.03) +sql select tagname from st_bool_15_1 +if $data00 != 1 then + print ==16== expect: 1, actually: $data00 + return -1 +endi + +## case 01: insert values for test column values +sql insert into st_bool_0 values (now, NULL) +sql select * from st_bool_0 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + print ==17== expect: NULL, actually: $data01 + return -1 +endi +sql insert into st_bool_1 values (now, NULL) +sql select * from st_bool_1 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + print ==18== expect: NULL, actually: $data01 + return -1 +endi +sql insert into st_bool_2 values (now, 'NULL') +sql select * from st_bool_2 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + print ==19== expect: NULL, actually: $data01 + return -1 +endi +sql insert into st_bool_3 values (now, 'NULL') +sql select * from st_bool_3 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + print ==20== expect: NULL, actually: $data01 + return -1 +endi +sql insert into st_bool_4 values (now, "NULL") +sql select * from st_bool_4 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + print ==21== expect: NULL, actually: $data01 + return -1 +endi +sql insert into st_bool_5 values (now, "NULL") +sql select * from st_bool_5 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + print ==22== expect: NULL, actually: $data01 + return -1 +endi +sql insert into st_bool_6 values (now, "true") +sql select * from st_bool_6 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + print ==23== expect: 1, actually: $data01 + return -1 +endi +sql insert into st_bool_7 values (now, 'true') +sql select * from st_bool_7 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + print ==24== expect: 1, actually: $data01 + return -1 +endi +sql insert into st_bool_8 values (now, true) +sql select * from st_bool_8 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + print ==25== expect: 1, actually: $data01 + return -1 +endi +sql insert into st_bool_9 values (now, "false") +sql select * from st_bool_9 +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + print ==26== expect: false, actually: $data01 + return -1 +endi +sql insert into st_bool_10 values (now, 'false') +sql select * from st_bool_10 +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + print ==27== expect: false, actually: $data01 + return -1 +endi +sql insert into st_bool_11 values (now, false) +sql select * from st_bool_11 +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + print ==28== expect: false, actually: $data01 + return -1 +endi +sql insert into st_bool_12 values (now, 0) +sql select * from st_bool_12 +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + print ==29== expect: false, actually: $data01 + return -1 +endi +sql insert into st_bool_13 values (now, 1) +sql select * from st_bool_13 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + print ==30== expect: 1, actually: $data01 + return -1 +endi +sql insert into st_bool_14 values (now, 6.9) +sql select * from st_bool_14 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + print ==31== expect: 1, actually: $data01 + return -1 +endi +sql insert into st_bool_15 values (now, -3) +sql select * from st_bool_15 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + print ==32== expect: true, actually: $data01 + return -1 +endi +sql insert into st_bool_15_0 values (now, +300) +sql select * from st_bool_15_0 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + print ==32== expect: true, actually: $data01 + return -1 +endi +sql insert into st_bool_15_1 values (now, -3.15) +sql select * from st_bool_15_1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + print ==32== expect: true, actually: $data01 + return -1 +endi + +## case 02: dynamic create table for test tag values +sql insert into st_bool_16 using mt_bool tags (NULL) values (now, NULL) +sql select tagname from st_bool_16 +if $data00 != NULL then + print ==33== expect: NULL, actually: $data00 + return -1 +endi +sql select * from st_bool_16 +if $data01 != NULL then + print ==34== expect: NULL, actually: $data01 + return -1 +endi + +sql insert into st_bool_17 using mt_bool tags (NULL) values (now, NULL) +sql select tagname from st_bool_17 +if $data00 != NULL then + print ==35== expect: NULL, actually: $data00 + return -1 +endi +sql select * from st_bool_17 +if $data01 != NULL then + print ==36== expect: NULL, actually: $data01 + return -1 +endi +sql insert into st_bool_18 using mt_bool tags ('NULL') values (now, 'NULL') +sql select tagname from st_bool_18 +if $data00 != NULL then + print ==37== expect: NULL, actually: $data00 + return -1 +endi +sql select * from st_bool_18 +if $data01 != NULL then + print ==38== expect: NULL, actually: $data01 + return -1 +endi +sql insert into st_bool_19 using mt_bool tags ('NULL') values (now, 'NULL') +sql select tagname from st_bool_19 +if $data00 != NULL then + print ==39== expect: NULL, actually: $data00 + return -1 +endi +sql select * from st_bool_19 +if $data01 != NULL then + print ==40== expect: NULL, actually: $data01 + return -1 +endi +sql insert into st_bool_20 using mt_bool tags ("NULL") values (now, "NULL") +sql select tagname from st_bool_20 +if $data00 != NULL then + print ==41== expect: NULL, actually: $data00 + return -1 +endi +sql select * from st_bool_20 +if $data01 != NULL then + print ==42== expect: NULL, actually: $data01 + return -1 +endi +sql insert into st_bool_21 using mt_bool tags ("NULL") values (now, "NULL") +sql select tagname from st_bool_21 +if $data00 != NULL then + print ==43== expect: NULL, actually: $data00 + return -1 +endi +sql select * from st_bool_21 +if $data01 != NULL then + print ==44== expect: NULL, actually: $data01 + return -1 +endi +sql insert into st_bool_22 using mt_bool tags ("true") values (now, "true") +sql select tagname from st_bool_22 +if $data00 != 1 then + print ==45== expect: 1, actually: $data00 + return -1 +endi +sql select * from st_bool_22 +if $data01 != 1 then + print ==46== expect: 1, actually: $data01 + return -1 +endi +sql insert into st_bool_23 using mt_bool tags ('true') values (now, 'true') +sql select tagname from st_bool_23 +if $data00 != 1 then + print ==47== expect: 1, actually: $data00 + return -1 +endi +sql select * from st_bool_23 +if $data01 != 1 then + print ==48== expect: 1, actually: $data01 + return -1 +endi +sql insert into st_bool_24 using mt_bool tags (true) values (now, true) +sql select tagname from st_bool_24 +if $data00 != 1 then + print ==49== expect: 1, actually: $data00 + return -1 +endi +sql select * from st_bool_24 +if $data01 != 1 then + print ==50== expect: 1, actually: $data01 + return -1 +endi +sql insert into st_bool_25 using mt_bool tags ("false") values (now, "false") +sql select tagname from st_bool_25 +if $data00 != 0 then + print ==51== expect: 0, actually: $data00 + return -1 +endi +sql select * from st_bool_25 +if $data01 != 0 then + print ==52== expect: 0, actually: $data01 + return -1 +endi +sql insert into st_bool_26 using mt_bool tags ('false') values (now, 'false') +sql select tagname from st_bool_26 +if $data00 != 0 then + print ==53== expect: 0, actually: $data00 + return -1 +endi +sql select * from st_bool_26 +if $data01 != 0 then + print ==54== expect: 0, actually: $data01 + return -1 +endi +sql insert into st_bool_27 using mt_bool tags (false) values (now, false) +sql select tagname from st_bool_27 +if $data00 != 0 then + print ==55== expect: 0, actually: $data00 + return -1 +endi +sql select * from st_bool_27 +if $data01 != 0 then + print ==56== expect: 0, actually: $data01 + return -1 +endi +sql insert into st_bool_28 using mt_bool tags (0) values (now, 0) +sql select tagname from st_bool_28 +if $data00 != 0 then + print ==57== expect: 0, actually: $data00 + return -1 +endi +sql select * from st_bool_28 +if $data01 != 0 then + print ==58== expect: 0, actually: $data01 + return -1 +endi +sql insert into st_bool_29 using mt_bool tags (1) values (now, 1) +sql select tagname from st_bool_29 +if $data00 != 1 then + print ==59== expect: 1, actually: $data00 + return -1 +endi +sql select * from st_bool_29 +if $data01 != 1 then + print ==60== expect: 1, actually: $data01 + return -1 +endi +sql insert into st_bool_30 using mt_bool tags (6.9) values (now, 6.9) +sql select tagname from st_bool_30 +if $data00 != 1 then + print ==61== expect: 1, actually: $data00 + return -1 +endi +sql select * from st_bool_30 +if $data01 != 1 then + print ==62== expect: 1, actually: $data01 + return -1 +endi +sql insert into st_bool_31 using mt_bool tags (-3) values (now, -3) +sql select tagname from st_bool_31 +if $data00 != 1 then + print ==63== expect: 1, actually: $data00 + return -1 +endi +sql select * from st_bool_31 +if $data01 != 1 then + print ==64== expect: 1, actually: $data01 + return -1 +endi +sql insert into st_bool_32 using mt_bool tags (+300) values (now, +300) +sql select tagname from st_bool_32 +if $data00 != 1 then + print ==63== expect: 1, actually: $data00 + return -1 +endi +sql select * from st_bool_32 +if $data01 != 1 then + print ==64== expect: 1, actually: $data01 + return -1 +endi +sql insert into st_bool_33 using mt_bool tags (+30.890) values (now, +30.890) +sql select tagname from st_bool_33 +if $data00 != 1 then + print ==63== expect: 1, actually: $data00 + return -1 +endi +sql select * from st_bool_33 +if $data01 != 1 then + print ==64== expect: 1, actually: $data01 + return -1 +endi + + + + + + +## case 03: alter tag values +#sql alter table st_bool_0 set tag tagname=true +#sql select tagname from st_bool_0 +#if $data00 != true then +# return -1 +#endi +#sql alter table st_bool_0 set tag tagname=NULL +#sql select tagname from st_bool_0 +#if $data00 != NULL then +# return -1 +#endi +#sql alter table st_bool_0 set tag tagname=false +#sql select tagname from st_bool_0 +#if $data00 != false then +# return -1 +#endi +#sql alter table st_bool_0 set tag tagname=NULL +#sql select tagname from st_bool_0 +#if $data00 != NULL then +# return -1 +#endi +#sql alter table st_bool_0 set tag tagname='true' +#sql select tagname from st_bool_0 +#if $data00 != true then +# return -1 +#endi +#sql alter table st_bool_0 set tag tagname='NULL' +#sql select tagname from st_bool_0 +#if $data00 != NULL then +# return -1 +#endi +#sql alter table st_bool_0 set tag tagname='false' +#sql select tagname from st_bool_0 +#if $data00 != false then +# return -1 +#endi +#sql alter table st_bool_0 set tag tagname='NULL' +#sql select tagname from st_bool_0 +#if $data00 != NULL then +# return -1 +#endi +#sql alter table st_bool_0 set tag tagname="true" +#sql select tagname from st_bool_0 +#if $data00 != true then +# return -1 +#endi +#sql alter table st_bool_0 set tag tagname="NULL" +#sql select tagname from st_bool_0 +#if $data00 != NULL then +# return -1 +#endi +#sql alter table st_bool_0 set tag tagname="false" +#sql select tagname from st_bool_0 +#if $data00 != false then +# return -1 +#endi +#sql alter table st_bool_0 set tag tagname="NULL" +#sql select tagname from st_bool_0 +#if $data00 != NULL then +# return -1 +#endi +#sql alter table st_bool_0 set tag tagname=1 +#sql select tagname from st_bool_0 +#if $data00 != true then +# return -1 +#endi +#sql alter table st_bool_0 set tag tagname=0 +#sql select tagname from st_bool_0 +#if $data00 != false then +# return -1 +#endi +#sql alter table st_bool_0 set tag tagname=6.9 +#sql select tagname from st_bool_0 +#if $data00 != true then +# return -1 +#endi +#sql alter table st_bool_0 set tag tagname=-3 +#sql select tagname from st_bool_0 +#if $data00 != true then +# return -1 +#endi + +# case 04: illegal input +sql_error create table st_bool_e0 using mt_bool tags (123abc) +sql_error create table st_bool_e1 using mt_bool tags ("123abc") +sql_error create table st_bool_e2 using mt_bool tags ("123") +sql_error create table st_bool_e3 using mt_bool tags (abc) +sql_error create table st_bool_e4 using mt_bool tags ("abc") +sql_error create table st_bool_e5 using mt_bool tags (" ") +sql_error create table st_bool_e6 using mt_bool tags ('') + +sql create table st_bool_e0 using mt_bool tags (true) +sql create table st_bool_e1 using mt_bool tags (true) +sql create table st_bool_e2 using mt_bool tags (true) +sql create table st_bool_e3 using mt_bool tags (true) +sql create table st_bool_e4 using mt_bool tags (true) +sql create table st_bool_e5 using mt_bool tags (true) +sql create table st_bool_e6 using mt_bool tags (true) + +sql_error insert into st_bool_e0 values (now, 123abc) +sql_error insert into st_bool_e1 values (now, "123abc") +sql_error insert into st_bool_e2 values (now, "123") +sql_error insert into st_bool_e3 values (now, abc) +sql_error insert into st_bool_e4 values (now, "abc") +sql_error insert into st_bool_e5 values (now, " ") +sql_error insert into st_bool_e6 values (now, '') + +sql_error insert into st_bool_e10 using mt_bool tags (123abc) values (now, 1) +sql_error insert into st_bool_e11 using mt_bool tags ("123abc") values (now, 1) +sql_error insert into st_bool_e12 using mt_bool tags ("123") values (now, 1) +sql_error insert into st_bool_e13 using mt_bool tags (abc) values (now, 1) +sql_error insert into st_bool_e14 using mt_bool tags ("abc") values (now, 1) +sql_error insert into st_bool_e15 using mt_bool tags (" ") values (now, 1) +sql_error insert into st_bool_e16 using mt_bool tags ('') values (now, 1) + +sql_error insert into st_bool_e17 using mt_bool tags (1) values (now, 123abc) +sql_error insert into st_bool_e18 using mt_bool tags (1) values (now, "123abc") +sql_error insert into st_bool_e19 using mt_bool tags (1) values (now, "123") +sql_error insert into st_bool_e20 using mt_bool tags (1) values (now, abc) +sql_error insert into st_bool_e21 using mt_bool tags (1) values (now, "abc") +sql_error insert into st_bool_e22 using mt_bool tags (1) values (now, " ") +sql_error insert into st_bool_e23 using mt_bool tags (1) values (now, '') + +sql insert into st_bool_e10 using mt_bool tags (1) values (now, 1) +sql insert into st_bool_e11 using mt_bool tags (1) values (now, 1) +sql insert into st_bool_e12 using mt_bool tags (1) values (now, 1) +sql insert into st_bool_e13 using mt_bool tags (1) values (now, 1) +sql insert into st_bool_e14 using mt_bool tags (1) values (now, 1) +sql insert into st_bool_e15 using mt_bool tags (1) values (now, 1) +sql insert into st_bool_e16 using mt_bool tags (1) values (now, 1) + +sql_error alter table st_bool_e10 set tag tagname=123abc +sql_error alter table st_bool_e11 set tag tagname="123abc" +sql_error alter table st_bool_e12 set tag tagname="123" +sql_error alter table st_bool_e13 set tag tagname=abc +sql_error alter table st_bool_e14 set tag tagname="abc" +sql_error alter table st_bool_e15 set tag tagname=" " +sql_error alter table st_bool_e16 set tag tagname='' + diff --git a/tests/script/general/parser/columnValue_double.sim b/tests/script/general/parser/columnValue_double.sim new file mode 100644 index 0000000000000000000000000000000000000000..e5ba89158bb98e56428ef7808af6fc4bcd751e48 --- /dev/null +++ b/tests/script/general/parser/columnValue_double.sim @@ -0,0 +1,525 @@ +#### +sleep 100 +sql connect +sql create database if not exists db +sql use db + +#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value + +######## case 0: double +print ========== double +sql create table mt_double (ts timestamp, c double) tags (tagname double) + +## case 00: static create table for test tag values +sql create table st_double_0 using mt_double tags (NULL ) +sql select tagname from st_double_0 +if $data00 != NULL then + return -1 +endi +sql create table st_double_1 using mt_double tags (NULL) +sql select tagname from st_double_1 +if $data00 != NULL then + return -1 +endi +sql create table st_double_2 using mt_double tags ('NULL') +sql select tagname from st_double_2 +if $data00 != NULL then + return -1 +endi +sql create table st_double_3 using mt_double tags ('NULL') +sql select tagname from st_double_3 +if $data00 != NULL then + return -1 +endi +sql create table st_double_4 using mt_double tags ("NULL") +sql select tagname from st_double_4 +if $data00 != NULL then + return -1 +endi +sql create table st_double_5 using mt_double tags ("NULL") +sql select tagname from st_double_5 +if $data00 != NULL then + return -1 +endi +sql create table st_double_6 using mt_double tags (-123.321) +sql select tagname from st_double_6 +if $data00 != -123.321000000 then + print expect -123.321000000, actual: $data00 + return -1 +endi +sql create table st_double_7 using mt_double tags (+1.567) +sql select tagname from st_double_7 +if $data00 != 1.567000000 then + return -1 +endi +sql create table st_double_8 using mt_double tags (379.001) +sql select tagname from st_double_8 +if $data00 != 379.001000000 then + return -1 +endi +sql create table st_double_9 using mt_double tags (1.5e+3) +sql select tagname from st_double_9 +if $data00 != 1500.000000000 then + return -1 +endi +sql create table st_double_10 using mt_double tags (-1.5e-3) +sql select tagname from st_double_10 +if $data00 != -0.001500000 then + return -1 +endi +sql create table st_double_11 using mt_double tags (+1.5e+3) +sql select tagname from st_double_11 +if $data00 != 1500.000000000 then + return -1 +endi +sql create table st_double_12 using mt_double tags (-1.5e+3) +sql select tagname from st_double_12 +if $data00 != -1500.000000000 then + return -1 +endi +sql create table st_double_13 using mt_double tags (1.5e-3) +sql select tagname from st_double_13 +if $data00 != 0.001500000 then + return -1 +endi +sql create table st_double_14 using mt_double tags (1.5E-3) +sql select tagname from st_double_14 +if $data00 != 0.001500000 then + return -1 +endi + +sql create table st_double_6_0 using mt_double tags ('-123.321') +sql select tagname from st_double_6_0 +if $data00 != -123.321000000 then + return -1 +endi +sql create table st_double_7_0 using mt_double tags ('+1.567') +sql select tagname from st_double_7_0 +if $data00 != 1.567000000 then + return -1 +endi +sql create table st_double_8_0 using mt_double tags ('379.001') +sql select tagname from st_double_8_0 +if $data00 != 379.001000000 then + return -1 +endi +sql create table st_double_9_0 using mt_double tags ('1.5e+3') +sql select tagname from st_double_9_0 +if $data00 != 1500.000000000 then + return -1 +endi +sql create table st_double_10_0 using mt_double tags ('-1.5e-3') +sql select tagname from st_double_10_0 +if $data00 != -0.001500000 then + return -1 +endi +sql create table st_double_11_0 using mt_double tags ('+1.5e+3') +sql select tagname from st_double_11_0 +if $data00 != 1500.000000000 then + return -1 +endi +sql create table st_double_12_0 using mt_double tags ('-1.5e+3') +sql select tagname from st_double_12_0 +if $data00 != -1500.000000000 then + return -1 +endi +sql create table st_double_13_0 using mt_double tags ('1.5e-3') +sql select tagname from st_double_13_0 +if $data00 != 0.001500000 then + return -1 +endi +sql create table st_double_14_0 using mt_double tags ('1.5E-3') +sql select tagname from st_double_14_0 +if $data00 != 0.001500000 then + return -1 +endi +sql create table st_double_15_0 using mt_double tags (1.7976931348623157e+308) +sql select tagname from st_double_15_0 +#if $data00 != 0.001500000 then +# return -1 +#endi +sql create table st_double_16_0 using mt_double tags (-1.7976931348623157e+308) +sql select tagname from st_double_16_0 +#if $data00 != 0.001500000 then +# return -1 +#endi + +## case 01: insert values for test column values +sql insert into st_double_0 values (now, NULL ) +sql select * from st_double_0 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_double_1 values (now, NULL) +sql select * from st_double_1 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_double_2 values (now, 'NULL') +sql select * from st_double_2 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_double_3 values (now, 'NULL') +sql select * from st_double_3 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_double_4 values (now, "NULL") +sql select * from st_double_4 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_double_5 values (now, "NULL") +sql select * from st_double_5 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi + +sql insert into st_double_6 values (now, 1.7976931348623157e+308) +sql select * from st_double_6 +if $rows != 1 then + return -1 +endi +#if $data01 != 340282346638528859811704183484516925440.00000 then +# print ==== data01:$data01, expect:340282346638528859811704183484516925440.00000 +# return -1 +#endi +sql insert into st_double_7 values (now, -1.7976931348623157e+308) +sql select * from st_double_7 +if $rows != 1 then + return -1 +endi +#if $data01 != -340282346638528859811704183484516925440.00000 then +# return -1 +#endi +sql insert into st_double_8 values (now, +100.89) +sql select * from st_double_8 +if $rows != 1 then + return -1 +endi +#if $data01 != 100.89000000 then +# return -1 +#endi +sql insert into st_double_9 values (now, "-0.98") +sql select * from st_double_9 +if $rows != 1 then + return -1 +endi +#if $data01 != -0.980000000 then +# return -1 +#endi +sql insert into st_double_10 values (now, '0') +sql select * from st_double_10 +if $rows != 1 then + return -1 +endi +#if $data01 != 0.00000000 then # tsim only print 4 bits after dot +# return -1 +#endi +sql insert into st_double_11 values (now, -0) +sql select * from st_double_11 +if $rows != 1 then + return -1 +endi +#if $data01 != 0.000000000 then +# return -1 +#endi +sql insert into st_double_12 values (now, "+056") +sql select * from st_double_12 +if $rows != 1 then + return -1 +endi +#if $data01 != 56.000000 then +# return -1 +#endi + +sql insert into st_double_13 values (now, +056) +sql select * from st_double_13 +if $rows != 1 then + return -1 +endi +#if $data01 != 56.000000000 then +# return -1 +#endi + +sql insert into st_double_14 values (now, -056) +sql select * from st_double_14 +if $rows != 1 then + return -1 +endi +#if $data01 != -56 then +# return -1 +#endi + +## case 02: dynamic create table for test tag values +sql insert into st_double_16 using mt_double tags (NULL ) values (now, NULL ) +sql select tagname from st_double_16 +if $data00 != NULL then + return -1 +endi +sql select * from st_double_16 +if $data01 != NULL then + return -1 +endi + +sql insert into st_double_17 using mt_double tags (NULL) values (now, NULL) +sql select tagname from st_double_17 +if $data00 != NULL then + return -1 +endi +sql select * from st_double_17 +if $data01 != NULL then + return -1 +endi +sql insert into st_double_18 using mt_double tags ('NULL') values (now, 'NULL') +sql select tagname from st_double_18 +if $data00 != NULL then + return -1 +endi +sql select * from st_double_18 +if $data01 != NULL then + return -1 +endi +sql insert into st_double_19 using mt_double tags ('NULL') values (now, 'NULL') +sql select tagname from st_double_19 +if $data00 != NULL then + return -1 +endi +sql select * from st_double_19 +if $data01 != NULL then + return -1 +endi +sql insert into st_double_20 using mt_double tags ("NULL") values (now, "NULL") +sql select tagname from st_double_20 +if $data00 != NULL then + return -1 +endi +sql select * from st_double_20 +if $data01 != NULL then + return -1 +endi +sql insert into st_double_21 using mt_double tags ("NULL") values (now, "NULL") +sql select tagname from st_double_21 +if $data00 != NULL then + return -1 +endi +sql select * from st_double_21 +if $data01 != NULL then + return -1 +endi +sql insert into st_double_22 using mt_double tags (127) values (now, 1.7976931348623157e+308) +sql select tagname from st_double_22 +#if $data00 != 127 then +# return -1 +#endi +sql select * from st_double_22 +#if $data01 != 127 then +# return -1 +#endi +sql insert into st_double_23 using mt_double tags (-127) values (now, -1.7976931348623157e+308) +sql select tagname from st_double_23 +#if $data00 != -127 then +# return -1 +#endi +sql select * from st_double_23 +#if $data01 != -127 then +# return -1 +#endi +sql insert into st_double_24 using mt_double tags (10) values (now, 10) +sql select tagname from st_double_24 +#if $data00 != 10 then +# return -1 +#endi +sql select * from st_double_24 +#if $data01 != 10 then +# return -1 +#endi +sql insert into st_double_25 using mt_double tags ("-0") values (now, "-0") +sql select tagname from st_double_25 +#if $data00 != 0 then +# return -1 +#endi +sql select * from st_double_25 +#if $data01 != 0 then +# return -1 +#endi +sql insert into st_double_26 using mt_double tags ('123') values (now, '12.3') +sql select tagname from st_double_26 +#if $data00 != 123 then +# return -1 +#endi +sql select * from st_double_26 +#if $data01 != 123 then +# return -1 +#endi +sql insert into st_double_27 using mt_double tags (+056) values (now, +0005.6) +sql select tagname from st_double_27 +#if $data00 != 56 then +# return -1 +#endi +sql select * from st_double_27 +#if $data01 != 56 then +# return -1 +#endi +sql insert into st_double_28 using mt_double tags (-056) values (now, -005.6) +sql select tagname from st_double_28 +#if $data00 != -56 then +# return -1 +#endi +sql select * from st_double_28 +#if $data01 != -56 then +# return -1 +#endi + +### case 03: alter tag values +#sql alter table st_double_0 set tag tagname=1.7976931348623157e+308 +#sql select tagname from st_double_0 +##if $data00 != 127 then +## return -1 +##endi +#sql alter table st_double_0 set tag tagname=-1.7976931348623157e+308 +#sql select tagname from st_double_0 +##if $data00 != -127 then +## return -1 +##endi +#sql alter table st_double_0 set tag tagname=+10.340 +#sql select tagname from st_double_0 +##if $data00 != 100 then +## return -1 +##endi +#sql alter table st_double_0 set tag tagname=-33.87 +#sql select tagname from st_double_0 +##if $data00 != -33 then +## return -1 +##endi +#sql alter table st_double_0 set tag tagname='+9.8' +#sql select tagname from st_double_0 +##if $data00 != 98 then +## return -1 +##endi +#sql alter table st_double_0 set tag tagname='-07.6' +#sql select tagname from st_double_0 +##if $data00 != -76 then +## return -1 +##endi +#sql alter table st_double_0 set tag tagname=+0012.871 +#sql select tagname from st_double_0 +##if $data00 != 12 then +## return -1 +##endi +#sql alter table st_double_0 set tag tagname=-00063.582 +#sql select tagname from st_double_0 +##if $data00 != -63 then +## return -1 +##endi + +## case 04: illegal input +sql_error create table st_double_e0 using mt_double tags (1.8976931348623157e+308) +sql_error create table st_double_e0 using mt_double tags (-1.8976931348623157e+308) +sql_error create table st_double_e0 using mt_double tags (31.7976931348623157e+308) +sql_error create table st_double_e0 using mt_double tags (-31.7976931348623157e+308) +#sql_error create table st_double_e0 using mt_double tags (12.80) truncate integer part +#sql_error create table st_double_e0 using mt_double tags (-11.80) +sql_error create table st_double_e0 using mt_double tags (123abc) +sql_error create table st_double_e0 using mt_double tags ("123abc") +sql_error create table st_double_e0 using mt_double tags (abc) +sql_error create table st_double_e0 using mt_double tags ("abc") +sql_error create table st_double_e0 using mt_double tags (" ") +sql_error create table st_double_e0 using mt_double tags ('') + +sql create table st_double_e0 using mt_double tags (123) +sql create table st_double_e1 using mt_double tags (123) +sql create table st_double_e2 using mt_double tags (123) +sql create table st_double_e3 using mt_double tags (123) +sql create table st_double_e4 using mt_double tags (123) +sql create table st_double_e5 using mt_double tags (123) +sql create table st_double_e6 using mt_double tags (123) +sql create table st_double_e7 using mt_double tags (123) +sql create table st_double_e8 using mt_double tags (123) +sql create table st_double_e9 using mt_double tags (123) +sql create table st_double_e10 using mt_double tags (123) +sql create table st_double_e11 using mt_double tags (123) +sql create table st_double_e12 using mt_double tags (123) + +sql_error insert into st_double_e0 values (now, 11.7976931348623157e+308) +sql_error insert into st_double_e1 values (now, -11.7976931348623157e+308) +sql_error insert into st_double_e2 values (now, 111.7976931348623157e+308) +sql_error insert into st_double_e3 values (now, -111.7976931348623157e+308) +#sql_error insert into st_double_e4 values (now, 12.80) +#sql_error insert into st_double_e5 values (now, -11.80) +sql_error insert into st_double_e6 values (now, 123abc) +sql_error insert into st_double_e7 values (now, "123abc") +sql_error insert into st_double_e9 values (now, abc) +sql_error insert into st_double_e10 values (now, "abc") +sql_error insert into st_double_e11 values (now, " ") +sql_error insert into st_double_e12 values (now, '') + +sql_error insert into st_double_e13 using mt_double tags (033) values (now, 11.7976931348623157e+308) +sql_error insert into st_double_e14 using mt_double tags (033) values (now, -11.7976931348623157e+308) +sql_error insert into st_double_e15 using mt_double tags (033) values (now, 131.7976931348623157e+308) +sql_error insert into st_double_e16 using mt_double tags (033) values (now, -131.7976931348623157e+308) +#sql_error insert into st_double_e17 using mt_double tags (033) values (now, 12.80) +#sql_error insert into st_double_e18 using mt_double tags (033) values (now, -11.80) +sql_error insert into st_double_e19 using mt_double tags (033) values (now, 123abc) +sql_error insert into st_double_e20 using mt_double tags (033) values (now, "123abc") +sql_error insert into st_double_e22 using mt_double tags (033) values (now, abc) +sql_error insert into st_double_e23 using mt_double tags (033) values (now, "abc") +sql_error insert into st_double_e24 using mt_double tags (033) values (now, " ") +sql_error insert into st_double_e25 using mt_double tags (033) values (now, '') + +sql_error insert into st_double_e13 using mt_double tags (31.7976931348623157e+308) values (now, -033) +sql_error insert into st_double_e14 using mt_double tags (-31.7976931348623157e+308) values (now, -033) +sql_error insert into st_double_e15 using mt_double tags (131.7976931348623157e+308) values (now, -033) +sql_error insert into st_double_e16 using mt_double tags (-131.7976931348623157e+308) values (now, -033) +#sql_error insert into st_double_e17 using mt_double tags (12.80) values (now, -033) +#sql_error insert into st_double_e18 using mt_double tags (-11.80) values (now, -033) +sql_error insert into st_double_e19 using mt_double tags (123abc) values (now, -033) +sql_error insert into st_double_e20 using mt_double tags ("123abc") values (now, -033) +sql_error insert into st_double_e22 using mt_double tags (abc) values (now, -033) +sql_error insert into st_double_e23 using mt_double tags ("abc") values (now, -033) +sql_error insert into st_double_e24 using mt_double tags (" ") values (now, -033) +sql_error insert into st_double_e25 using mt_double tags ('') values (now, -033) + +sql insert into st_double_e13 using mt_double tags (033) values (now, 00062) +sql insert into st_double_e14 using mt_double tags (033) values (now, 00062) +sql insert into st_double_e15 using mt_double tags (033) values (now, 00062) +sql insert into st_double_e16 using mt_double tags (033) values (now, 00062) +sql insert into st_double_e17 using mt_double tags (033) values (now, 00062) +sql insert into st_double_e18 using mt_double tags (033) values (now, 00062) +sql insert into st_double_e19 using mt_double tags (033) values (now, 00062) +sql insert into st_double_e20 using mt_double tags (033) values (now, 00062) +sql insert into st_double_e21 using mt_double tags (033) values (now, 00062) +sql insert into st_double_e22 using mt_double tags (033) values (now, 00062) +sql insert into st_double_e23 using mt_double tags (033) values (now, 00062) +sql insert into st_double_e24 using mt_double tags (033) values (now, 00062) +sql insert into st_double_e25 using mt_double tags (033) values (now, 00062) + +sql_error alter table st_double_e13 set tag tagname=1.8976931348623157e+308 +sql_error alter table st_double_e14 set tag tagname=-1.8976931348623157e+308 +sql_error alter table st_double_e15 set tag tagname=131.7976931348623157e+308 +sql_error alter table st_double_e16 set tag tagname=-131.7976931348623157e+308 +sql_error alter table st_double_e19 set tag tagname=123abc +sql_error alter table st_double_e20 set tag tagname="123abc" +sql_error alter table st_double_e22 set tag tagname=abc +sql_error alter table st_double_e23 set tag tagname="abc" +sql_error alter table st_double_e24 set tag tagname=" " +sql_error alter table st_double_e25 set tag tagname='' diff --git a/tests/script/general/parser/columnValue_float.sim b/tests/script/general/parser/columnValue_float.sim new file mode 100644 index 0000000000000000000000000000000000000000..c7008d0b132e1d82b32a773555c638e71340b731 --- /dev/null +++ b/tests/script/general/parser/columnValue_float.sim @@ -0,0 +1,555 @@ +#### +sleep 100 +sql connect +sql create database if not exists db +sql use db + +#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value + +######## case 0: float +print ========== float +sql create table mt_float (ts timestamp, c float) tags (tagname float) + +## case 00: static create table for test tag values +sql create table st_float_0 using mt_float tags (NULL) +sql select tagname from st_float_0 +if $data00 != NULL then + return -1 +endi +sql create table st_float_1 using mt_float tags (NULL) +sql select tagname from st_float_1 +if $data00 != NULL then + return -1 +endi +sql create table st_float_2 using mt_float tags ('NULL') +sql select tagname from st_float_2 +if $data00 != NULL then + return -1 +endi +sql create table st_float_3 using mt_float tags ('NULL') +sql select tagname from st_float_3 +if $data00 != NULL then + return -1 +endi +sql create table st_float_4 using mt_float tags ("NULL") +sql select tagname from st_float_4 +if $data00 != NULL then + return -1 +endi +sql create table st_float_5 using mt_float tags ("NULL") +sql select tagname from st_float_5 +if $data00 != NULL then + return -1 +endi +sql create table st_float_6 using mt_float tags (-123.321) +sql select tagname from st_float_6 +if $data00 != -123.32100 then + print expect -123.32100, actual: $data00 + return -1 +endi +sql create table st_float_7 using mt_float tags (+1.567) +sql select tagname from st_float_7 +if $data00 != 1.56700 then + print expect 1.56700, actual: $data00 + return -1 +endi +sql create table st_float_8 using mt_float tags (379.001) +sql select tagname from st_float_8 +if $data00 != 379.00101 then + print expect 379.00101, actual: $data00 + return -1 +endi +sql create table st_float_9 using mt_float tags (1.5e+3) +sql select tagname from st_float_9 +if $data00 != 1500.00000 then + print expect 1500.00000, actual: $data00 + return -1 +endi +sql create table st_float_10 using mt_float tags (-1.5e-3) +sql select tagname from st_float_10 +if $data00 != -0.00150 then + print expect -0.00150, actual: $data00 + return -1 +endi +sql create table st_float_11 using mt_float tags (+1.5e+3) +sql select tagname from st_float_11 +if $data00 != 1500.00000 then + print expect 1500.00000, actual: $data00 + return -1 +endi +sql create table st_float_12 using mt_float tags (-1.5e+3) +sql select tagname from st_float_12 +if $data00 != -1500.00000 then + print expect -1500.00000, actual: $data00 + return -1 +endi +sql create table st_float_13 using mt_float tags (1.5e-3) +sql select tagname from st_float_13 +if $data00 != 0.00150 then + print expect 0.00150, actual: $data00 + return -1 +endi +sql create table st_float_14 using mt_float tags (1.5E-3) +sql select tagname from st_float_14 +if $data00 != 0.00150 then + print expect 0.00150, actual: $data00 + return -1 +endi + +sql create table st_float_6_0 using mt_float tags ('-123.321') +sql select tagname from st_float_6_0 +if $data00 != -123.32100 then + print expect -123.32100, actual: $data00 + return -1 +endi +sql create table st_float_7_0 using mt_float tags ('+1.567') +sql select tagname from st_float_7_0 +if $data00 != 1.56700 then + print expect 1.56700, actual: $data00 + return -1 +endi +sql create table st_float_8_0 using mt_float tags ('379.001') +sql select tagname from st_float_8_0 +if $data00 != 379.00101 then + print expect 379.00101, actual: $data00 + return -1 +endi +sql create table st_float_9_0 using mt_float tags ('1.5e+3') +sql select tagname from st_float_9_0 +if $data00 != 1500.00000 then + print expect 1500.00000, actual: $data00 + return -1 +endi +sql create table st_float_10_0 using mt_float tags ('-1.5e-3') +sql select tagname from st_float_10_0 +if $data00 != -0.00150 then + print expect -0.00150, actual: $data00 + return -1 +endi +sql create table st_float_11_0 using mt_float tags ('+1.5e+3') +sql select tagname from st_float_11_0 +if $data00 != 1500.00000 then + print expect 1500.00000, actual: $data00 + return -1 +endi +sql create table st_float_12_0 using mt_float tags ('-1.5e+3') +sql select tagname from st_float_12_0 +if $data00 != -1500.00000 then + print expect -1500.00000, actual: $data00 + return -1 +endi +sql create table st_float_13_0 using mt_float tags ('1.5e-3') +sql select tagname from st_float_13_0 +if $data00 != 0.00150 then + print expect 0.00150, actual: $data00 + return -1 +endi +sql create table st_float_14_0 using mt_float tags ('1.5E-3') +sql select tagname from st_float_14_0 +if $data00 != 0.00150 then + print expect 0.00150, actual: $data00 + return -1 +endi +sql create table st_float_15_0 using mt_float tags (3.40282347e+38) +sql select tagname from st_float_15_0 +#if $data00 != 0.001500 then +# return -1 +#endi +sql create table st_float_16_0 using mt_float tags (-3.40282347e+38) +sql select tagname from st_float_16_0 +#if $data00 != 0.001500 then +# return -1 +#endi + +## case 01: insert values for test column values +sql insert into st_float_0 values (now, NULL) +sql select * from st_float_0 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_float_1 values (now, NULL) +sql select * from st_float_1 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_float_2 values (now, 'NULL') +sql select * from st_float_2 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_float_3 values (now, 'NULL') +sql select * from st_float_3 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_float_4 values (now, "NULL") +sql select * from st_float_4 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_float_5 values (now, "NULL") +sql select * from st_float_5 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi + +sql_error insert into st_float_6 values (now, 3.40282347e+38) +sql_error insert into st_float_6 values (now, -3.40282347e+38) + +sql insert into st_float_6 values(now, 340282346638528859811704183484516925440.00000) +sql select * from st_float_6 +if $rows != 1 then + return -1 +endi + +if $data01 != 340282346638528859811704183484516925440.00000 then + print ==== data01:$data01, expect:340282346638528859811704183484516925440.00000 + return -1 +endi +sql insert into st_float_7 values (now, -340282346638528859811704183484516925440.00000) +sql select * from st_float_7 +if $rows != 1 then + return -1 +endi +if $data01 != -340282346638528859811704183484516925440.00000 then + return -1 +endi + +sql insert into st_float_8 values (now, +100.89) +sql select * from st_float_8 +if $rows != 1 then + return -1 +endi +#if $data01 != 100.89000 then +# return -1 +#endi +sql insert into st_float_9 values (now, "-0.98") +sql select * from st_float_9 +if $rows != 1 then + return -1 +endi +#if $data01 != -0.980000 then +# return -1 +#endi +sql insert into st_float_10 values (now, '0') +sql select * from st_float_10 +if $rows != 1 then + return -1 +endi +#if $data01 != 0.00000 then # tsim only print 4 bits after dot +# return -1 +#endi +sql insert into st_float_11 values (now, -0) +sql select * from st_float_11 +if $rows != 1 then + return -1 +endi +#if $data01 != 0.00000 then +# return -1 +#endi +sql insert into st_float_12 values (now, "+056") +sql select * from st_float_12 +if $rows != 1 then + return -1 +endi +#if $data01 != 56.000000 then +# return -1 +#endi + +sql insert into st_float_13 values (now, +056) +sql select * from st_float_13 +if $rows != 1 then + return -1 +endi +#if $data01 != 56.000000 then +# return -1 +#endi + +sql insert into st_float_14 values (now, -056) +sql select * from st_float_14 +if $rows != 1 then + return -1 +endi +#if $data01 != -56 then +# return -1 +#endi + +## case 02: dynamic create table for test tag values +sql insert into st_float_16 using mt_float tags (NULL) values (now, NULL) +sql select tagname from st_float_16 +if $data00 != NULL then + return -1 +endi +sql select * from st_float_16 +if $data01 != NULL then + return -1 +endi + +sql insert into st_float_17 using mt_float tags (NULL) values (now, NULL) +sql select tagname from st_float_17 +if $data00 != NULL then + return -1 +endi +sql select * from st_float_17 +if $data01 != NULL then + return -1 +endi +sql insert into st_float_18 using mt_float tags ('NULL') values (now, 'NULL') +sql select tagname from st_float_18 +if $data00 != NULL then + return -1 +endi +sql select * from st_float_18 +if $data01 != NULL then + return -1 +endi +sql insert into st_float_19 using mt_float tags ('NULL') values (now, 'NULL') +sql select tagname from st_float_19 +if $data00 != NULL then + return -1 +endi +sql select * from st_float_19 +if $data01 != NULL then + return -1 +endi +sql insert into st_float_20 using mt_float tags ("NULL") values (now, "NULL") +sql select tagname from st_float_20 +if $data00 != NULL then + return -1 +endi +sql select * from st_float_20 +if $data01 != NULL then + return -1 +endi +sql insert into st_float_21 using mt_float tags ("NULL") values (now, "NULL") +sql select tagname from st_float_21 +if $data00 != NULL then + return -1 +endi +sql select * from st_float_21 +if $data01 != NULL then + return -1 +endi + +sql_error insert into st_float_22 using mt_float tags (127) values (now, 3.40282347e+38) + +sql insert into st_float_22 using mt_float tags (127) values (now, 340282346638528859811704183484516925440.00000) +sql select tagname from st_float_22 +if $data00 != 127.00000 then + print expect 127.00000, actual: $data00 + return -1 +endi + +sql select tbname, tagname from st_float_22 +if $data01 != 127.00000 then + return -1 +endi + +sql insert into st_float_23 using mt_float tags (-127) values (now, -340282346638528859811704183484516925440.00000) +sql select tagname from st_float_23 +if $data00 != -127.00000 then + return -1 +endi + +sql insert into st_float_24 using mt_float tags (10) values (now, 10) +sql select tagname from st_float_24 +if $data00 != 10.00000 then + return -1 +endi +sql select * from st_float_24 +if $data01 != 10.00000 then + return -1 +endi + +sql insert into st_float_25 using mt_float tags ("-0") values (now, "-0") +sql select tagname from st_float_25 +if $data00 != -0.00000 then + print expect -0.00000, actual: $data00 + return -1 +endi +sql select * from st_float_25 +if $data01 != -0.00000 then + return -1 +endi +sql insert into st_float_26 using mt_float tags ('123') values (now, '12.3') +sql select tagname from st_float_26 +if $data00 != 123.00000 then + print expect 123.00000, actual: $data00 + return -1 +endi +sql select * from st_float_26 +if $data01 != 12.30000 then + return -1 +endi +sql insert into st_float_27 using mt_float tags (+056) values (now, +0005.6) +sql select tagname from st_float_27 +if $data00 != 56.00000 then + print expect 56.00000, actual:$data00 + return -1 +endi +sql select * from st_float_27 +if $data01 != 5.60000 then + return -1 +endi +sql insert into st_float_28 using mt_float tags (-056) values (now, -005.6) +sql select tagname from st_float_28 +if $data00 != -56.00000 then + return -1 +endi +sql select * from st_float_28 +if $data01 != -5.60000 then + return -1 +endi + +### case 03: alter tag values +sql alter table st_float_0 set tag tagname=340282346638528859811704183484516925440.00000 +sql select tagname from st_float_0 +if $data00 != 340282346638528859811704183484516925440.00000 then + return -1 +endi + +sql alter table st_float_0 set tag tagname=-340282346638528859811704183484516925440.00000 +sql select tagname from st_float_0 +if $data00 != -340282346638528859811704183484516925440.00000 then + return -1 +endi +sql alter table st_float_0 set tag tagname=+10.340 +sql select tagname from st_float_0 +if $data00 != 10.34000 then + return -1 +endi +sql alter table st_float_0 set tag tagname=-33.87 +sql select tagname from st_float_0 +if $data00 != -33.87000 then + return -1 +endi +sql alter table st_float_0 set tag tagname='+9.8' +sql select tagname from st_float_0 +if $data00 != 9.80000 then + return -1 +endi +sql alter table st_float_0 set tag tagname='-07.6' +sql select tagname from st_float_0 +if $data00 != -7.60000 then + return -1 +endi +sql alter table st_float_0 set tag tagname=+0012.871 +sql select tagname from st_float_0 +if $data00 != 12.87100 then + return -1 +endi +sql alter table st_float_0 set tag tagname=-00063.582 +sql select tagname from st_float_0 +if $data00 != -63.58200 then + return -1 +endi + +## case 04: illegal input +sql_error create table st_float_e0 using mt_float tags (3.50282347e+38) +sql_error create table st_float_e0 using mt_float tags (-3.50282347e+38) +sql_error create table st_float_e0 using mt_float tags (333.40282347e+38) +sql_error create table st_float_e0 using mt_float tags (-333.40282347e+38) +#sql_error create table st_float_e0 using mt_float tags (12.80) truncate integer part +#sql_error create table st_float_e0 using mt_float tags (-11.80) +sql_error create table st_float_e0 using mt_float tags (123abc) +sql_error create table st_float_e0 using mt_float tags ("123abc") +sql_error create table st_float_e0 using mt_float tags (abc) +sql_error create table st_float_e0 using mt_float tags ("abc") +sql_error create table st_float_e0 using mt_float tags (" ") +sql_error create table st_float_e0 using mt_float tags ('') + +sql create table st_float_e0 using mt_float tags (123) +sql create table st_float_e1 using mt_float tags (123) +sql create table st_float_e2 using mt_float tags (123) +sql create table st_float_e3 using mt_float tags (123) +sql create table st_float_e4 using mt_float tags (123) +sql create table st_float_e5 using mt_float tags (123) +sql create table st_float_e6 using mt_float tags (123) +sql create table st_float_e7 using mt_float tags (123) +sql create table st_float_e8 using mt_float tags (123) +sql create table st_float_e9 using mt_float tags (123) +sql create table st_float_e10 using mt_float tags (123) +sql create table st_float_e11 using mt_float tags (123) +sql create table st_float_e12 using mt_float tags (123) + +sql_error insert into st_float_e0 values (now, 3.50282347e+38) +sql_error insert into st_float_e1 values (now, -3.50282347e+38) +sql_error insert into st_float_e2 values (now, 13.40282347e+38) +sql_error insert into st_float_e3 values (now, -13.40282347e+38) +#sql_error insert into st_float_e4 values (now, 12.80) +#sql_error insert into st_float_e5 values (now, -11.80) +sql_error insert into st_float_e6 values (now, 123abc) +sql_error insert into st_float_e7 values (now, "123abc") +sql_error insert into st_float_e9 values (now, abc) +sql_error insert into st_float_e10 values (now, "abc") +sql_error insert into st_float_e11 values (now, " ") +sql_error insert into st_float_e12 values (now, '') + +sql_error insert into st_float_e13 using mt_float tags (033) values (now, 3.50282347e+38) +sql_error insert into st_float_e14 using mt_float tags (033) values (now, -3.50282347e+38) +sql_error insert into st_float_e15 using mt_float tags (033) values (now, 13.40282347e+38) +sql_error insert into st_float_e16 using mt_float tags (033) values (now, -13.40282347e+38) +#sql_error insert into st_float_e17 using mt_float tags (033) values (now, 12.80) +#sql_error insert into st_float_e18 using mt_float tags (033) values (now, -11.80) +sql_error insert into st_float_e19 using mt_float tags (033) values (now, 123abc) +sql_error insert into st_float_e20 using mt_float tags (033) values (now, "123abc") +sql_error insert into st_float_e22 using mt_float tags (033) values (now, abc) +sql_error insert into st_float_e23 using mt_float tags (033) values (now, "abc") +sql_error insert into st_float_e24 using mt_float tags (033) values (now, " ") +sql_error insert into st_float_e25 using mt_float tags (033) values (now, '') + +sql_error insert into st_float_e13 using mt_float tags (3.50282347e+38) values (now, -033) +sql_error insert into st_float_e14 using mt_float tags (-3.50282347e+38) values (now, -033) +sql_error insert into st_float_e15 using mt_float tags (13.40282347e+38) values (now, -033) +sql_error insert into st_float_e16 using mt_float tags (-13.40282347e+38) values (now, -033) +#sql_error insert into st_float_e17 using mt_float tags (12.80) values (now, -033) +#sql_error insert into st_float_e18 using mt_float tags (-11.80) values (now, -033) +sql_error insert into st_float_e19 using mt_float tags (123abc) values (now, -033) +sql_error insert into st_float_e20 using mt_float tags ("123abc") values (now, -033) +sql_error insert into st_float_e22 using mt_float tags (abc) values (now, -033) +sql_error insert into st_float_e23 using mt_float tags ("abc") values (now, -033) +sql_error insert into st_float_e24 using mt_float tags (" ") values (now, -033) +sql_error insert into st_float_e25 using mt_float tags ('') values (now, -033) + +sql insert into st_float_e13 using mt_float tags (033) values (now, 00062) +sql insert into st_float_e14 using mt_float tags (033) values (now, 00062) +sql insert into st_float_e15 using mt_float tags (033) values (now, 00062) +sql insert into st_float_e16 using mt_float tags (033) values (now, 00062) +sql insert into st_float_e17 using mt_float tags (033) values (now, 00062) +sql insert into st_float_e18 using mt_float tags (033) values (now, 00062) +sql insert into st_float_e19 using mt_float tags (033) values (now, 00062) +sql insert into st_float_e20 using mt_float tags (033) values (now, 00062) +sql insert into st_float_e21 using mt_float tags (033) values (now, 00062) +sql insert into st_float_e22 using mt_float tags (033) values (now, 00062) +sql insert into st_float_e23 using mt_float tags (033) values (now, 00062) +sql insert into st_float_e24 using mt_float tags (033) values (now, 00062) +sql insert into st_float_e25 using mt_float tags (033) values (now, 00062) + +sql_error alter table st_float_e13 set tag tagname=3.50282347e+38 +sql_error alter table st_float_e14 set tag tagname=-3.50282347e+38 +sql_error alter table st_float_e15 set tag tagname=13.40282347e+38 +sql_error alter table st_float_e16 set tag tagname=-13.40282347e+38 +sql_error alter table st_float_e19 set tag tagname=123abc +sql_error alter table st_float_e20 set tag tagname="123abc" +sql_error alter table st_float_e22 set tag tagname=abc +sql_error alter table st_float_e23 set tag tagname="abc" +sql_error alter table st_float_e24 set tag tagname=" " +sql_error alter table st_float_e25 set tag tagname='' diff --git a/tests/script/general/parser/columnValue_int.sim b/tests/script/general/parser/columnValue_int.sim new file mode 100644 index 0000000000000000000000000000000000000000..5536293ed2d0dcac847829ba03891621cc62eab9 --- /dev/null +++ b/tests/script/general/parser/columnValue_int.sim @@ -0,0 +1,465 @@ +sleep 100 +sql connect +sql create database if not exists db +sql use db + +#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value + +######## case 0: int +print ========== int +sql create table mt_int (ts timestamp, c int) tags (tagname int) + +## case 00: static create table for test tag values +sql create table st_int_0 using mt_int tags (NULL) +sql select tagname from st_int_0 +if $data00 != NULL then + return -1 +endi +sql create table st_int_1 using mt_int tags (NULL) +sql select tagname from st_int_1 +if $data00 != NULL then + return -1 +endi +sql create table st_int_2 using mt_int tags ('NULL') +sql select tagname from st_int_2 +if $data00 != NULL then + return -1 +endi +sql create table st_int_3 using mt_int tags ('NULL') +sql select tagname from st_int_3 +if $data00 != NULL then + return -1 +endi +sql create table st_int_4 using mt_int tags ("NULL") +sql select tagname from st_int_4 +if $data00 != NULL then + return -1 +endi +sql create table st_int_5 using mt_int tags ("NULL") +sql select tagname from st_int_5 +if $data00 != NULL then + return -1 +endi +sql create table st_int_6 using mt_int tags (-2147483647) +sql select tagname from st_int_6 +if $data00 != -2147483647 then + return -1 +endi +sql create table st_int_7 using mt_int tags (2147483647) +sql select tagname from st_int_7 +if $data00 != 2147483647 then + return -1 +endi +sql create table st_int_8 using mt_int tags (37) +sql select tagname from st_int_8 +if $data00 != 37 then + return -1 +endi +sql create table st_int_9 using mt_int tags (-100) +sql select tagname from st_int_9 +if $data00 != -100 then + return -1 +endi +sql create table st_int_10 using mt_int tags (+113) +sql select tagname from st_int_10 +if $data00 != 113 then + return -1 +endi +sql create table st_int_11 using mt_int tags ('-100') +sql select tagname from st_int_11 +if $data00 != -100 then + return -1 +endi +sql create table st_int_12 using mt_int tags ("+78") +sql select tagname from st_int_12 +if $data00 != 78 then + return -1 +endi +sql create table st_int_13 using mt_int tags (+0078) +sql select tagname from st_int_13 +if $data00 != 78 then + return -1 +endi +sql create table st_int_14 using mt_int tags (-00078) +sql select tagname from st_int_14 +if $data00 != -78 then + return -1 +endi + +## case 01: insert values for test column values +sql insert into st_int_0 values (now, NULL) +sql select * from st_int_0 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_int_1 values (now, NULL) +sql select * from st_int_1 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_int_2 values (now, 'NULL') +sql select * from st_int_2 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_int_3 values (now, 'NULL') +sql select * from st_int_3 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_int_4 values (now, "NULL") +sql select * from st_int_4 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_int_5 values (now, "NULL") +sql select * from st_int_5 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_int_6 values (now, 2147483647) +sql select * from st_int_6 +if $rows != 1 then + return -1 +endi +if $data01 != 2147483647 then + return -1 +endi +sql insert into st_int_7 values (now, -2147483647) +sql select * from st_int_7 +if $rows != 1 then + return -1 +endi +if $data01 != -2147483647 then + return -1 +endi +sql insert into st_int_8 values (now, +100) +sql select * from st_int_8 +if $rows != 1 then + return -1 +endi +if $data01 != 100 then + return -1 +endi +sql insert into st_int_9 values (now, "-098") +sql select * from st_int_9 +if $rows != 1 then + return -1 +endi +if $data01 != -98 then + return -1 +endi +sql insert into st_int_10 values (now, '0') +sql select * from st_int_10 +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +sql insert into st_int_11 values (now, -0) +sql select * from st_int_11 +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +sql insert into st_int_12 values (now, "+056") +sql select * from st_int_12 +if $rows != 1 then + return -1 +endi +if $data01 != 56 then + return -1 +endi + +sql insert into st_int_13 values (now, +056) +sql select * from st_int_13 +if $rows != 1 then + return -1 +endi +if $data01 != 56 then + return -1 +endi + +sql insert into st_int_14 values (now, -056) +sql select * from st_int_14 +if $rows != 1 then + return -1 +endi +if $data01 != -56 then + return -1 +endi + +## case 02: dynamic create table for test tag values +sql insert into st_int_16 using mt_int tags (NULL) values (now, NULL) +sql select tagname from st_int_16 +if $data00 != NULL then + return -1 +endi +sql select * from st_int_16 +if $data01 != NULL then + return -1 +endi + +sql insert into st_int_17 using mt_int tags (NULL) values (now, NULL) +sql select tagname from st_int_17 +if $data00 != NULL then + return -1 +endi +sql select * from st_int_17 +if $data01 != NULL then + return -1 +endi +sql insert into st_int_18 using mt_int tags ('NULL') values (now, 'NULL') +sql select tagname from st_int_18 +if $data00 != NULL then + return -1 +endi +sql select * from st_int_18 +if $data01 != NULL then + return -1 +endi +sql insert into st_int_19 using mt_int tags ('NULL') values (now, 'NULL') +sql select tagname from st_int_19 +if $data00 != NULL then + return -1 +endi +sql select * from st_int_19 +if $data01 != NULL then + return -1 +endi +sql insert into st_int_20 using mt_int tags ("NULL") values (now, "NULL") +sql select tagname from st_int_20 +if $data00 != NULL then + return -1 +endi +sql select * from st_int_20 +if $data01 != NULL then + return -1 +endi +sql insert into st_int_21 using mt_int tags ("NULL") values (now, "NULL") +sql select tagname from st_int_21 +if $data00 != NULL then + return -1 +endi +sql select * from st_int_21 +if $data01 != NULL then + return -1 +endi +sql insert into st_int_22 using mt_int tags (2147483647) values (now, 2147483647) +sql select tagname from st_int_22 +if $data00 != 2147483647 then + return -1 +endi +sql select * from st_int_22 +if $data01 != 2147483647 then + return -1 +endi +sql insert into st_int_23 using mt_int tags (-2147483647) values (now, -2147483647) +sql select tagname from st_int_23 +if $data00 != -2147483647 then + return -1 +endi +sql select * from st_int_23 +if $data01 != -2147483647 then + return -1 +endi +sql insert into st_int_24 using mt_int tags (10) values (now, 10) +sql select tagname from st_int_24 +if $data00 != 10 then + return -1 +endi +sql select * from st_int_24 +if $data01 != 10 then + return -1 +endi +sql insert into st_int_25 using mt_int tags ("-0") values (now, "-0") +sql select tagname from st_int_25 +if $data00 != 0 then + return -1 +endi +sql select * from st_int_25 +if $data01 != 0 then + return -1 +endi +sql insert into st_int_26 using mt_int tags ('123') values (now, '123') +sql select tagname from st_int_26 +if $data00 != 123 then + return -1 +endi +sql select * from st_int_26 +if $data01 != 123 then + return -1 +endi +sql insert into st_int_27 using mt_int tags (+056) values (now, +00056) +sql select tagname from st_int_27 +if $data00 != 56 then + return -1 +endi +sql select * from st_int_27 +if $data01 != 56 then + return -1 +endi +sql insert into st_int_28 using mt_int tags (-056) values (now, -0056) +sql select tagname from st_int_28 +if $data00 != -56 then + return -1 +endi +sql select * from st_int_28 +if $data01 != -56 then + return -1 +endi + +### case 03: alter tag values +#sql alter table st_int_0 set tag tagname=2147483647 +#sql select tagname from st_int_0 +#if $data00 != 2147483647 then +# return -1 +#endi +#sql alter table st_int_0 set tag tagname=-2147483647 +#sql select tagname from st_int_0 +#if $data00 != -2147483647 then +# return -1 +#endi +#sql alter table st_int_0 set tag tagname=+100 +#sql select tagname from st_int_0 +#if $data00 != 100 then +# return -1 +#endi +#sql alter table st_int_0 set tag tagname=-33 +#sql select tagname from st_int_0 +#if $data00 != -33 then +# return -1 +#endi +#sql alter table st_int_0 set tag tagname='+98' +#sql select tagname from st_int_0 +#if $data00 != 98 then +# return -1 +#endi +#sql alter table st_int_0 set tag tagname='-076' +#sql select tagname from st_int_0 +#if $data00 != -76 then +# return -1 +#endi +#sql alter table st_int_0 set tag tagname=+0012 +#sql select tagname from st_int_0 +#if $data00 != 12 then +# return -1 +#endi +#sql alter table st_int_0 set tag tagname=-00063 +#sql select tagname from st_int_0 +#if $data00 != -63 then +# return -1 +#endi + +## case 04: illegal input +sql_error create table st_int_e0 using mt_int tags (2147483648) +sql_error create table st_int_e0 using mt_int tags (-2147483648) +sql_error create table st_int_e0 using mt_int tags (214748364800) +sql_error create table st_int_e0 using mt_int tags (-214748364800) +#sql_error create table st_int_e0 using mt_int tags (12.80) truncate integer part +#sql_error create table st_int_e0 using mt_int tags (-11.80) +sql_error create table st_int_e0 using mt_int tags (123abc) +sql_error create table st_int_e0 using mt_int tags ("123abc") +sql_error create table st_int_e0 using mt_int tags (abc) +sql_error create table st_int_e0 using mt_int tags ("abc") +sql_error create table st_int_e0 using mt_int tags (" ") +sql_error create table st_int_e0 using mt_int tags ('') + +sql create table st_int_e0 using mt_int tags (123) +sql create table st_int_e1 using mt_int tags (123) +sql create table st_int_e2 using mt_int tags (123) +sql create table st_int_e3 using mt_int tags (123) +sql create table st_int_e4 using mt_int tags (123) +sql create table st_int_e5 using mt_int tags (123) +sql create table st_int_e6 using mt_int tags (123) +sql create table st_int_e7 using mt_int tags (123) +sql create table st_int_e8 using mt_int tags (123) +sql create table st_int_e9 using mt_int tags (123) +sql create table st_int_e10 using mt_int tags (123) +sql create table st_int_e11 using mt_int tags (123) +sql create table st_int_e12 using mt_int tags (123) + +sql_error insert into st_int_e0 values (now, 2147483648) +sql_error insert into st_int_e1 values (now, -2147483648) +sql_error insert into st_int_e2 values (now, 3147483648) +sql_error insert into st_int_e3 values (now, -21474836481) +#sql_error insert into st_int_e4 values (now, 12.80) +#sql_error insert into st_int_e5 values (now, -11.80) +sql_error insert into st_int_e6 values (now, 123abc) +sql_error insert into st_int_e7 values (now, "123abc") +sql_error insert into st_int_e9 values (now, abc) +sql_error insert into st_int_e10 values (now, "abc") +sql_error insert into st_int_e11 values (now, " ") +sql_error insert into st_int_e12 values (now, '') + +sql_error insert into st_int_e13 using mt_int tags (033) values (now, 2147483648) +sql_error insert into st_int_e14 using mt_int tags (033) values (now, -2147483648) +sql_error insert into st_int_e15 using mt_int tags (033) values (now, 5147483648) +sql_error insert into st_int_e16 using mt_int tags (033) values (now, -21474836481) +#sql_error insert into st_int_e17 using mt_int tags (033) values (now, 12.80) +#sql_error insert into st_int_e18 using mt_int tags (033) values (now, -11.80) +sql_error insert into st_int_e19 using mt_int tags (033) values (now, 123abc) +sql_error insert into st_int_e20 using mt_int tags (033) values (now, "123abc") +sql_error insert into st_int_e22 using mt_int tags (033) values (now, abc) +sql_error insert into st_int_e23 using mt_int tags (033) values (now, "abc") +sql_error insert into st_int_e24 using mt_int tags (033) values (now, " ") +sql_error insert into st_int_e25 using mt_int tags (033) values (now, '') + +sql_error insert into st_int_e13 using mt_int tags (2147483648) values (now, -033) +sql_error insert into st_int_e14 using mt_int tags (-2147483648) values (now, -033) +sql_error insert into st_int_e15 using mt_int tags (21474836480) values (now, -033) +sql_error insert into st_int_e16 using mt_int tags (-2147483649) values (now, -033) +#sql_error insert into st_int_e17 using mt_int tags (12.80) values (now, -033) +#sql_error insert into st_int_e18 using mt_int tags (-11.80) values (now, -033) +sql_error insert into st_int_e19 using mt_int tags (123abc) values (now, -033) +sql_error insert into st_int_e20 using mt_int tags ("123abc") values (now, -033) +sql_error insert into st_int_e22 using mt_int tags (abc) values (now, -033) +sql_error insert into st_int_e23 using mt_int tags ("abc") values (now, -033) +sql_error insert into st_int_e24 using mt_int tags (" ") values (now, -033) +sql_error insert into st_int_e25 using mt_int tags ('') values (now, -033) + +sql insert into st_int_e13 using mt_int tags (033) values (now, 00062) +sql insert into st_int_e14 using mt_int tags (033) values (now, 00062) +sql insert into st_int_e15 using mt_int tags (033) values (now, 00062) +sql insert into st_int_e16 using mt_int tags (033) values (now, 00062) +sql insert into st_int_e17 using mt_int tags (033) values (now, 00062) +sql insert into st_int_e18 using mt_int tags (033) values (now, 00062) +sql insert into st_int_e19 using mt_int tags (033) values (now, 00062) +sql insert into st_int_e20 using mt_int tags (033) values (now, 00062) +sql insert into st_int_e21 using mt_int tags (033) values (now, 00062) +sql insert into st_int_e22 using mt_int tags (033) values (now, 00062) +sql insert into st_int_e23 using mt_int tags (033) values (now, 00062) +sql insert into st_int_e24 using mt_int tags (033) values (now, 00062) +sql insert into st_int_e25 using mt_int tags (033) values (now, 00062) + +sql_error alter table st_int_e13 set tag tagname=2147483648 +sql_error alter table st_int_e14 set tag tagname=-2147483648 +sql_error alter table st_int_e15 set tag tagname=12147483648 +sql_error alter table st_int_e16 set tag tagname=-3147483648 +sql_error alter table st_int_e19 set tag tagname=123abc +sql_error alter table st_int_e20 set tag tagname="123abc" +sql_error alter table st_int_e22 set tag tagname=abc +sql_error alter table st_int_e23 set tag tagname="abc" +sql_error alter table st_int_e24 set tag tagname=" " +sql_error alter table st_int_e25 set tag tagname='' diff --git a/tests/script/general/parser/columnValue_smallint.sim b/tests/script/general/parser/columnValue_smallint.sim new file mode 100644 index 0000000000000000000000000000000000000000..98b83fd0e19e07d9e95f355cbdebc7b84341891c --- /dev/null +++ b/tests/script/general/parser/columnValue_smallint.sim @@ -0,0 +1,465 @@ +sleep 100 +sql connect +sql create database if not exists db +sql use db + +#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value + +######## case 0: smallint +print ========== smallint +sql create table mt_smallint (ts timestamp, c smallint) tags (tagname smallint) + +## case 00: static create table for test tag values +sql create table st_smallint_0 using mt_smallint tags (NULL) +sql select tagname from st_smallint_0 +if $data00 != NULL then + return -1 +endi +sql create table st_smallint_1 using mt_smallint tags (NULL) +sql select tagname from st_smallint_1 +if $data00 != NULL then + return -1 +endi +sql create table st_smallint_2 using mt_smallint tags ('NULL') +sql select tagname from st_smallint_2 +if $data00 != NULL then + return -1 +endi +sql create table st_smallint_3 using mt_smallint tags ('NULL') +sql select tagname from st_smallint_3 +if $data00 != NULL then + return -1 +endi +sql create table st_smallint_4 using mt_smallint tags ("NULL") +sql select tagname from st_smallint_4 +if $data00 != NULL then + return -1 +endi +sql create table st_smallint_5 using mt_smallint tags ("NULL") +sql select tagname from st_smallint_5 +if $data00 != NULL then + return -1 +endi +sql create table st_smallint_6 using mt_smallint tags (-32767) +sql select tagname from st_smallint_6 +if $data00 != -32767 then + return -1 +endi +sql create table st_smallint_7 using mt_smallint tags (32767) +sql select tagname from st_smallint_7 +if $data00 != 32767 then + return -1 +endi +sql create table st_smallint_8 using mt_smallint tags (37) +sql select tagname from st_smallint_8 +if $data00 != 37 then + return -1 +endi +sql create table st_smallint_9 using mt_smallint tags (-100) +sql select tagname from st_smallint_9 +if $data00 != -100 then + return -1 +endi +sql create table st_smallint_10 using mt_smallint tags (+113) +sql select tagname from st_smallint_10 +if $data00 != 113 then + return -1 +endi +sql create table st_smallint_11 using mt_smallint tags ('-100') +sql select tagname from st_smallint_11 +if $data00 != -100 then + return -1 +endi +sql create table st_smallint_12 using mt_smallint tags ("+78") +sql select tagname from st_smallint_12 +if $data00 != 78 then + return -1 +endi +sql create table st_smallint_13 using mt_smallint tags (+0078) +sql select tagname from st_smallint_13 +if $data00 != 78 then + return -1 +endi +sql create table st_smallint_14 using mt_smallint tags (-00078) +sql select tagname from st_smallint_14 +if $data00 != -78 then + return -1 +endi + +## case 01: insert values for test column values +sql insert into st_smallint_0 values (now, NULL) +sql select * from st_smallint_0 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_smallint_1 values (now, NULL) +sql select * from st_smallint_1 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_smallint_2 values (now, 'NULL') +sql select * from st_smallint_2 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_smallint_3 values (now, 'NULL') +sql select * from st_smallint_3 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_smallint_4 values (now, "NULL") +sql select * from st_smallint_4 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_smallint_5 values (now, "NULL") +sql select * from st_smallint_5 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_smallint_6 values (now, 32767) +sql select * from st_smallint_6 +if $rows != 1 then + return -1 +endi +if $data01 != 32767 then + return -1 +endi +sql insert into st_smallint_7 values (now, -32767) +sql select * from st_smallint_7 +if $rows != 1 then + return -1 +endi +if $data01 != -32767 then + return -1 +endi +sql insert into st_smallint_8 values (now, +100) +sql select * from st_smallint_8 +if $rows != 1 then + return -1 +endi +if $data01 != 100 then + return -1 +endi +sql insert into st_smallint_9 values (now, "-098") +sql select * from st_smallint_9 +if $rows != 1 then + return -1 +endi +if $data01 != -98 then + return -1 +endi +sql insert into st_smallint_10 values (now, '0') +sql select * from st_smallint_10 +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +sql insert into st_smallint_11 values (now, -0) +sql select * from st_smallint_11 +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +sql insert into st_smallint_12 values (now, "+056") +sql select * from st_smallint_12 +if $rows != 1 then + return -1 +endi +if $data01 != 56 then + return -1 +endi + +sql insert into st_smallint_13 values (now, +056) +sql select * from st_smallint_13 +if $rows != 1 then + return -1 +endi +if $data01 != 56 then + return -1 +endi + +sql insert into st_smallint_14 values (now, -056) +sql select * from st_smallint_14 +if $rows != 1 then + return -1 +endi +if $data01 != -56 then + return -1 +endi + +## case 02: dynamic create table for test tag values +sql insert into st_smallint_16 using mt_smallint tags (NULL) values (now, NULL) +sql select tagname from st_smallint_16 +if $data00 != NULL then + return -1 +endi +sql select * from st_smallint_16 +if $data01 != NULL then + return -1 +endi + +sql insert into st_smallint_17 using mt_smallint tags (NULL) values (now, NULL) +sql select tagname from st_smallint_17 +if $data00 != NULL then + return -1 +endi +sql select * from st_smallint_17 +if $data01 != NULL then + return -1 +endi +sql insert into st_smallint_18 using mt_smallint tags ('NULL') values (now, 'NULL') +sql select tagname from st_smallint_18 +if $data00 != NULL then + return -1 +endi +sql select * from st_smallint_18 +if $data01 != NULL then + return -1 +endi +sql insert into st_smallint_19 using mt_smallint tags ('NULL') values (now, 'NULL') +sql select tagname from st_smallint_19 +if $data00 != NULL then + return -1 +endi +sql select * from st_smallint_19 +if $data01 != NULL then + return -1 +endi +sql insert into st_smallint_20 using mt_smallint tags ("NULL") values (now, "NULL") +sql select tagname from st_smallint_20 +if $data00 != NULL then + return -1 +endi +sql select * from st_smallint_20 +if $data01 != NULL then + return -1 +endi +sql insert into st_smallint_21 using mt_smallint tags ("NULL") values (now, "NULL") +sql select tagname from st_smallint_21 +if $data00 != NULL then + return -1 +endi +sql select * from st_smallint_21 +if $data01 != NULL then + return -1 +endi +sql insert into st_smallint_22 using mt_smallint tags (32767) values (now, 32767) +sql select tagname from st_smallint_22 +if $data00 != 32767 then + return -1 +endi +sql select * from st_smallint_22 +if $data01 != 32767 then + return -1 +endi +sql insert into st_smallint_23 using mt_smallint tags (-32767) values (now, -32767) +sql select tagname from st_smallint_23 +if $data00 != -32767 then + return -1 +endi +sql select * from st_smallint_23 +if $data01 != -32767 then + return -1 +endi +sql insert into st_smallint_24 using mt_smallint tags (10) values (now, 10) +sql select tagname from st_smallint_24 +if $data00 != 10 then + return -1 +endi +sql select * from st_smallint_24 +if $data01 != 10 then + return -1 +endi +sql insert into st_smallint_25 using mt_smallint tags ("-0") values (now, "-0") +sql select tagname from st_smallint_25 +if $data00 != 0 then + return -1 +endi +sql select * from st_smallint_25 +if $data01 != 0 then + return -1 +endi +sql insert into st_smallint_26 using mt_smallint tags ('123') values (now, '123') +sql select tagname from st_smallint_26 +if $data00 != 123 then + return -1 +endi +sql select * from st_smallint_26 +if $data01 != 123 then + return -1 +endi +sql insert into st_smallint_27 using mt_smallint tags (+056) values (now, +00056) +sql select tagname from st_smallint_27 +if $data00 != 56 then + return -1 +endi +sql select * from st_smallint_27 +if $data01 != 56 then + return -1 +endi +sql insert into st_smallint_28 using mt_smallint tags (-056) values (now, -0056) +sql select tagname from st_smallint_28 +if $data00 != -56 then + return -1 +endi +sql select * from st_smallint_28 +if $data01 != -56 then + return -1 +endi + +## case 03: alter tag values +#sql alter table st_smallint_0 set tag tagname=32767 +#sql select tagname from st_smallint_0 +#if $data00 != 32767 then +# return -1 +#endi +#sql alter table st_smallint_0 set tag tagname=-32767 +#sql select tagname from st_smallint_0 +#if $data00 != -32767 then +# return -1 +#endi +#sql alter table st_smallint_0 set tag tagname=+100 +#sql select tagname from st_smallint_0 +#if $data00 != 100 then +# return -1 +#endi +#sql alter table st_smallint_0 set tag tagname=-33 +#sql select tagname from st_smallint_0 +#if $data00 != -33 then +# return -1 +#endi +#sql alter table st_smallint_0 set tag tagname='+98' +#sql select tagname from st_smallint_0 +#if $data00 != 98 then +# return -1 +#endi +#sql alter table st_smallint_0 set tag tagname='-076' +#sql select tagname from st_smallint_0 +#if $data00 != -76 then +# return -1 +#endi +#sql alter table st_smallint_0 set tag tagname=+0012 +#sql select tagname from st_smallint_0 +#if $data00 != 12 then +# return -1 +#endi +#sql alter table st_smallint_0 set tag tagname=-00063 +#sql select tagname from st_smallint_0 +#if $data00 != -63 then +# return -1 +#endi + +## case 04: illegal input +sql_error create table st_smallint_e0 using mt_smallint tags (32768) +sql_error create table st_smallint_e0 using mt_smallint tags (-32768) +sql_error create table st_smallint_e0 using mt_smallint tags (3276899) +sql_error create table st_smallint_e0 using mt_smallint tags (-3276833) +#sql_error create table st_smallint_e0 using mt_smallint tags (12.80) truncate integer part +#sql_error create table st_smallint_e0 using mt_smallint tags (-11.80) +sql_error create table st_smallint_e0 using mt_smallint tags (123abc) +sql_error create table st_smallint_e0 using mt_smallint tags ("123abc") +sql_error create table st_smallint_e0 using mt_smallint tags (abc) +sql_error create table st_smallint_e0 using mt_smallint tags ("abc") +sql_error create table st_smallint_e0 using mt_smallint tags (" ") +sql_error create table st_smallint_e0 using mt_smallint tags ('') + +sql create table st_smallint_e0 using mt_smallint tags (123) +sql create table st_smallint_e1 using mt_smallint tags (123) +sql create table st_smallint_e2 using mt_smallint tags (123) +sql create table st_smallint_e3 using mt_smallint tags (123) +sql create table st_smallint_e4 using mt_smallint tags (123) +sql create table st_smallint_e5 using mt_smallint tags (123) +sql create table st_smallint_e6 using mt_smallint tags (123) +sql create table st_smallint_e7 using mt_smallint tags (123) +sql create table st_smallint_e8 using mt_smallint tags (123) +sql create table st_smallint_e9 using mt_smallint tags (123) +sql create table st_smallint_e10 using mt_smallint tags (123) +sql create table st_smallint_e11 using mt_smallint tags (123) +sql create table st_smallint_e12 using mt_smallint tags (123) + +sql_error insert into st_smallint_e0 values (now, 32768) +sql_error insert into st_smallint_e1 values (now, -32768) +sql_error insert into st_smallint_e2 values (now, 42768) +sql_error insert into st_smallint_e3 values (now, -32769) +#sql_error insert into st_smallint_e4 values (now, 12.80) +#sql_error insert into st_smallint_e5 values (now, -11.80) +sql_error insert into st_smallint_e6 values (now, 123abc) +sql_error insert into st_smallint_e7 values (now, "123abc") +sql_error insert into st_smallint_e9 values (now, abc) +sql_error insert into st_smallint_e10 values (now, "abc") +sql_error insert into st_smallint_e11 values (now, " ") +sql_error insert into st_smallint_e12 values (now, '') + +sql_error insert into st_smallint_e13 using mt_smallint tags (033) values (now, 32768) +sql_error insert into st_smallint_e14 using mt_smallint tags (033) values (now, -32768) +sql_error insert into st_smallint_e15 using mt_smallint tags (033) values (now, 32968) +sql_error insert into st_smallint_e16 using mt_smallint tags (033) values (now, -33768) +#sql_error insert into st_smallint_e17 using mt_smallint tags (033) values (now, 12.80) +#sql_error insert into st_smallint_e18 using mt_smallint tags (033) values (now, -11.80) +sql_error insert into st_smallint_e19 using mt_smallint tags (033) values (now, 123abc) +sql_error insert into st_smallint_e20 using mt_smallint tags (033) values (now, "123abc") +sql_error insert into st_smallint_e22 using mt_smallint tags (033) values (now, abc) +sql_error insert into st_smallint_e23 using mt_smallint tags (033) values (now, "abc") +sql_error insert into st_smallint_e24 using mt_smallint tags (033) values (now, " ") +sql_error insert into st_smallint_e25 using mt_smallint tags (033) values (now, '') + +sql_error insert into st_smallint_e13 using mt_smallint tags (32768) values (now, -033) +sql_error insert into st_smallint_e14 using mt_smallint tags (-32768) values (now, -033) +sql_error insert into st_smallint_e15 using mt_smallint tags (72768) values (now, -033) +sql_error insert into st_smallint_e16 using mt_smallint tags (-92768) values (now, -033) +#sql_error insert into st_smallint_e17 using mt_smallint tags (12.80) values (now, -033) +#sql_error insert into st_smallint_e18 using mt_smallint tags (-11.80) values (now, -033) +sql_error insert into st_smallint_e19 using mt_smallint tags (123abc) values (now, -033) +sql_error insert into st_smallint_e20 using mt_smallint tags ("123abc") values (now, -033) +sql_error insert into st_smallint_e22 using mt_smallint tags (abc) values (now, -033) +sql_error insert into st_smallint_e23 using mt_smallint tags ("abc") values (now, -033) +sql_error insert into st_smallint_e24 using mt_smallint tags (" ") values (now, -033) +sql_error insert into st_smallint_e25 using mt_smallint tags ('') values (now, -033) + +sql insert into st_smallint_e13 using mt_smallint tags (033) values (now, 00062) +sql insert into st_smallint_e14 using mt_smallint tags (033) values (now, 00062) +sql insert into st_smallint_e15 using mt_smallint tags (033) values (now, 00062) +sql insert into st_smallint_e16 using mt_smallint tags (033) values (now, 00062) +sql insert into st_smallint_e17 using mt_smallint tags (033) values (now, 00062) +sql insert into st_smallint_e18 using mt_smallint tags (033) values (now, 00062) +sql insert into st_smallint_e19 using mt_smallint tags (033) values (now, 00062) +sql insert into st_smallint_e20 using mt_smallint tags (033) values (now, 00062) +sql insert into st_smallint_e21 using mt_smallint tags (033) values (now, 00062) +sql insert into st_smallint_e22 using mt_smallint tags (033) values (now, 00062) +sql insert into st_smallint_e23 using mt_smallint tags (033) values (now, 00062) +sql insert into st_smallint_e24 using mt_smallint tags (033) values (now, 00062) +sql insert into st_smallint_e25 using mt_smallint tags (033) values (now, 00062) + +sql_error alter table st_smallint_e13 set tag tagname=32768 +sql_error alter table st_smallint_e14 set tag tagname=-32768 +sql_error alter table st_smallint_e15 set tag tagname=52768 +sql_error alter table st_smallint_e16 set tag tagname=-32778 +sql_error alter table st_smallint_e19 set tag tagname=123abc +sql_error alter table st_smallint_e20 set tag tagname="123abc" +sql_error alter table st_smallint_e22 set tag tagname=abc +sql_error alter table st_smallint_e23 set tag tagname="abc" +sql_error alter table st_smallint_e24 set tag tagname=" " +sql_error alter table st_smallint_e25 set tag tagname='' diff --git a/tests/script/general/parser/columnValue_tinyint.sim b/tests/script/general/parser/columnValue_tinyint.sim new file mode 100644 index 0000000000000000000000000000000000000000..7b0cad23dfdfe6970cf9bd24f2dc8673b266b10c --- /dev/null +++ b/tests/script/general/parser/columnValue_tinyint.sim @@ -0,0 +1,466 @@ +sleep 100 +sql connect +sql create database if not exists db +sql use db + +#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value + +######## case 0: tinyint +print ========== tinyint +sql create table mt_tinyint (ts timestamp, c tinyint) tags (tagname tinyint) + +## case 00: static create table for test tag values +sql create table st_tinyint_0 using mt_tinyint tags (NULL) +sql select tagname from st_tinyint_0 +if $data00 != NULL then + print expect NULL, actually: $data00 + return -1 +endi +sql create table st_tinyint_1 using mt_tinyint tags (NULL) +sql select tagname from st_tinyint_1 +if $data00 != NULL then + return -1 +endi +sql create table st_tinyint_2 using mt_tinyint tags ('NULL') +sql select tagname from st_tinyint_2 +if $data00 != NULL then + return -1 +endi +sql create table st_tinyint_3 using mt_tinyint tags ('NULL') +sql select tagname from st_tinyint_3 +if $data00 != NULL then + return -1 +endi +sql create table st_tinyint_4 using mt_tinyint tags ("NULL") +sql select tagname from st_tinyint_4 +if $data00 != NULL then + return -1 +endi +sql create table st_tinyint_5 using mt_tinyint tags ("NULL") +sql select tagname from st_tinyint_5 +if $data00 != NULL then + return -1 +endi +sql create table st_tinyint_6 using mt_tinyint tags (-127) +sql select tagname from st_tinyint_6 +if $data00 != -127 then + return -1 +endi +sql create table st_tinyint_7 using mt_tinyint tags (127) +sql select tagname from st_tinyint_7 +if $data00 != 127 then + return -1 +endi +sql create table st_tinyint_8 using mt_tinyint tags (37) +sql select tagname from st_tinyint_8 +if $data00 != 37 then + return -1 +endi +sql create table st_tinyint_9 using mt_tinyint tags (-100) +sql select tagname from st_tinyint_9 +if $data00 != -100 then + return -1 +endi +sql create table st_tinyint_10 using mt_tinyint tags (+113) +sql select tagname from st_tinyint_10 +if $data00 != 113 then + return -1 +endi +sql create table st_tinyint_11 using mt_tinyint tags ('-100') +sql select tagname from st_tinyint_11 +if $data00 != -100 then + return -1 +endi +sql create table st_tinyint_12 using mt_tinyint tags ("+78") +sql select tagname from st_tinyint_12 +if $data00 != 78 then + return -1 +endi +sql create table st_tinyint_13 using mt_tinyint tags (+0078) +sql select tagname from st_tinyint_13 +if $data00 != 78 then + return -1 +endi +sql create table st_tinyint_14 using mt_tinyint tags (-00078) +sql select tagname from st_tinyint_14 +if $data00 != -78 then + return -1 +endi + +## case 01: insert values for test column values +sql insert into st_tinyint_0 values (now, NULL) +sql select * from st_tinyint_0 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_tinyint_1 values (now, NULL) +sql select * from st_tinyint_1 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_tinyint_2 values (now, 'NULL') +sql select * from st_tinyint_2 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_tinyint_3 values (now, 'NULL') +sql select * from st_tinyint_3 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_tinyint_4 values (now, "NULL") +sql select * from st_tinyint_4 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_tinyint_5 values (now, "NULL") +sql select * from st_tinyint_5 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_tinyint_6 values (now, 127) +sql select * from st_tinyint_6 +if $rows != 1 then + return -1 +endi +if $data01 != 127 then + return -1 +endi +sql insert into st_tinyint_7 values (now, -127) +sql select * from st_tinyint_7 +if $rows != 1 then + return -1 +endi +if $data01 != -127 then + return -1 +endi +sql insert into st_tinyint_8 values (now, +100) +sql select * from st_tinyint_8 +if $rows != 1 then + return -1 +endi +if $data01 != 100 then + return -1 +endi +sql insert into st_tinyint_9 values (now, "-098") +sql select * from st_tinyint_9 +if $rows != 1 then + return -1 +endi +if $data01 != -98 then + return -1 +endi +sql insert into st_tinyint_10 values (now, '0') +sql select * from st_tinyint_10 +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +sql insert into st_tinyint_11 values (now, -0) +sql select * from st_tinyint_11 +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +sql insert into st_tinyint_12 values (now, "+056") +sql select * from st_tinyint_12 +if $rows != 1 then + return -1 +endi +if $data01 != 56 then + return -1 +endi + +sql insert into st_tinyint_13 values (now, +056) +sql select * from st_tinyint_13 +if $rows != 1 then + return -1 +endi +if $data01 != 56 then + return -1 +endi + +sql insert into st_tinyint_14 values (now, -056) +sql select * from st_tinyint_14 +if $rows != 1 then + return -1 +endi +if $data01 != -56 then + return -1 +endi + +## case 02: dynamic create table for test tag values +sql insert into st_tinyint_16 using mt_tinyint tags (NULL) values (now, NULL) +sql select tagname from st_tinyint_16 +if $data00 != NULL then + return -1 +endi +sql select * from st_tinyint_16 +if $data01 != NULL then + return -1 +endi + +sql insert into st_tinyint_17 using mt_tinyint tags (NULL) values (now, NULL) +sql select tagname from st_tinyint_17 +if $data00 != NULL then + return -1 +endi +sql select * from st_tinyint_17 +if $data01 != NULL then + return -1 +endi +sql insert into st_tinyint_18 using mt_tinyint tags ('NULL') values (now, 'NULL') +sql select tagname from st_tinyint_18 +if $data00 != NULL then + return -1 +endi +sql select * from st_tinyint_18 +if $data01 != NULL then + return -1 +endi +sql insert into st_tinyint_19 using mt_tinyint tags ('NULL') values (now, 'NULL') +sql select tagname from st_tinyint_19 +if $data00 != NULL then + return -1 +endi +sql select * from st_tinyint_19 +if $data01 != NULL then + return -1 +endi +sql insert into st_tinyint_20 using mt_tinyint tags ("NULL") values (now, "NULL") +sql select tagname from st_tinyint_20 +if $data00 != NULL then + return -1 +endi +sql select * from st_tinyint_20 +if $data01 != NULL then + return -1 +endi +sql insert into st_tinyint_21 using mt_tinyint tags ("NULL") values (now, "NULL") +sql select tagname from st_tinyint_21 +if $data00 != NULL then + return -1 +endi +sql select * from st_tinyint_21 +if $data01 != NULL then + return -1 +endi +sql insert into st_tinyint_22 using mt_tinyint tags (127) values (now, 127) +sql select tagname from st_tinyint_22 +if $data00 != 127 then + return -1 +endi +sql select * from st_tinyint_22 +if $data01 != 127 then + return -1 +endi +sql insert into st_tinyint_23 using mt_tinyint tags (-127) values (now, -127) +sql select tagname from st_tinyint_23 +if $data00 != -127 then + return -1 +endi +sql select * from st_tinyint_23 +if $data01 != -127 then + return -1 +endi +sql insert into st_tinyint_24 using mt_tinyint tags (10) values (now, 10) +sql select tagname from st_tinyint_24 +if $data00 != 10 then + return -1 +endi +sql select * from st_tinyint_24 +if $data01 != 10 then + return -1 +endi +sql insert into st_tinyint_25 using mt_tinyint tags ("-0") values (now, "-0") +sql select tagname from st_tinyint_25 +if $data00 != 0 then + return -1 +endi +sql select * from st_tinyint_25 +if $data01 != 0 then + return -1 +endi +sql insert into st_tinyint_26 using mt_tinyint tags ('123') values (now, '123') +sql select tagname from st_tinyint_26 +if $data00 != 123 then + return -1 +endi +sql select * from st_tinyint_26 +if $data01 != 123 then + return -1 +endi +sql insert into st_tinyint_27 using mt_tinyint tags (+056) values (now, +00056) +sql select tagname from st_tinyint_27 +if $data00 != 56 then + return -1 +endi +sql select * from st_tinyint_27 +if $data01 != 56 then + return -1 +endi +sql insert into st_tinyint_28 using mt_tinyint tags (-056) values (now, -0056) +sql select tagname from st_tinyint_28 +if $data00 != -56 then + return -1 +endi +sql select * from st_tinyint_28 +if $data01 != -56 then + return -1 +endi + +## case 03: alter tag values +#sql alter table st_tinyint_0 set tag tagname=127 +#sql select tagname from st_tinyint_0 +#if $data00 != 127 then +# return -1 +#endi +#sql alter table st_tinyint_0 set tag tagname=-127 +#sql select tagname from st_tinyint_0 +#if $data00 != -127 then +# return -1 +#endi +#sql alter table st_tinyint_0 set tag tagname=+100 +#sql select tagname from st_tinyint_0 +#if $data00 != 100 then +# return -1 +#endi +#sql alter table st_tinyint_0 set tag tagname=-33 +#sql select tagname from st_tinyint_0 +#if $data00 != -33 then +# return -1 +#endi +#sql alter table st_tinyint_0 set tag tagname='+98' +#sql select tagname from st_tinyint_0 +#if $data00 != 98 then +# return -1 +#endi +#sql alter table st_tinyint_0 set tag tagname='-076' +#sql select tagname from st_tinyint_0 +#if $data00 != -76 then +# return -1 +#endi +#sql alter table st_tinyint_0 set tag tagname=+0012 +#sql select tagname from st_tinyint_0 +#if $data00 != 12 then +# return -1 +#endi +#sql alter table st_tinyint_0 set tag tagname=-00063 +#sql select tagname from st_tinyint_0 +#if $data00 != -63 then +# return -1 +#endi + +## case 04: illegal input +sql_error create table st_tinyint_e0 using mt_tinyint tags (128) +sql_error create table st_tinyint_e0 using mt_tinyint tags (-128) +sql_error create table st_tinyint_e0 using mt_tinyint tags (1280) +sql_error create table st_tinyint_e0 using mt_tinyint tags (-1280) +#sql_error create table st_tinyint_e0 using mt_tinyint tags (12.80) truncate integer part +#sql_error create table st_tinyint_e0 using mt_tinyint tags (-11.80) +sql_error create table st_tinyint_e0 using mt_tinyint tags (123abc) +sql_error create table st_tinyint_e0 using mt_tinyint tags ("123abc") +sql_error create table st_tinyint_e0 using mt_tinyint tags (abc) +sql_error create table st_tinyint_e0 using mt_tinyint tags ("abc") +sql_error create table st_tinyint_e0 using mt_tinyint tags (" ") +sql_error create table st_tinyint_e0 using mt_tinyint tags ('') + +sql create table st_tinyint_e0 using mt_tinyint tags (123) +sql create table st_tinyint_e1 using mt_tinyint tags (123) +sql create table st_tinyint_e2 using mt_tinyint tags (123) +sql create table st_tinyint_e3 using mt_tinyint tags (123) +sql create table st_tinyint_e4 using mt_tinyint tags (123) +sql create table st_tinyint_e5 using mt_tinyint tags (123) +sql create table st_tinyint_e6 using mt_tinyint tags (123) +sql create table st_tinyint_e7 using mt_tinyint tags (123) +sql create table st_tinyint_e8 using mt_tinyint tags (123) +sql create table st_tinyint_e9 using mt_tinyint tags (123) +sql create table st_tinyint_e10 using mt_tinyint tags (123) +sql create table st_tinyint_e11 using mt_tinyint tags (123) +sql create table st_tinyint_e12 using mt_tinyint tags (123) + +sql_error insert into st_tinyint_e0 values (now, 128) +sql_error insert into st_tinyint_e1 values (now, -128) +sql_error insert into st_tinyint_e2 values (now, 1280) +sql_error insert into st_tinyint_e3 values (now, -1280) +#sql_error insert into st_tinyint_e4 values (now, 12.80) +#sql_error insert into st_tinyint_e5 values (now, -11.80) +sql_error insert into st_tinyint_e6 values (now, 123abc) +sql_error insert into st_tinyint_e7 values (now, "123abc") +sql_error insert into st_tinyint_e9 values (now, abc) +sql_error insert into st_tinyint_e10 values (now, "abc") +sql_error insert into st_tinyint_e11 values (now, " ") +sql_error insert into st_tinyint_e12 values (now, '') + +sql_error insert into st_tinyint_e13 using mt_tinyint tags (033) values (now, 128) +sql_error insert into st_tinyint_e14 using mt_tinyint tags (033) values (now, -128) +sql_error insert into st_tinyint_e15 using mt_tinyint tags (033) values (now, 1280) +sql_error insert into st_tinyint_e16 using mt_tinyint tags (033) values (now, -1280) +#sql_error insert into st_tinyint_e17 using mt_tinyint tags (033) values (now, 12.80) +#sql_error insert into st_tinyint_e18 using mt_tinyint tags (033) values (now, -11.80) +sql_error insert into st_tinyint_e19 using mt_tinyint tags (033) values (now, 123abc) +sql_error insert into st_tinyint_e20 using mt_tinyint tags (033) values (now, "123abc") +sql_error insert into st_tinyint_e22 using mt_tinyint tags (033) values (now, abc) +sql_error insert into st_tinyint_e23 using mt_tinyint tags (033) values (now, "abc") +sql_error insert into st_tinyint_e24 using mt_tinyint tags (033) values (now, " ") +sql_error insert into st_tinyint_e25 using mt_tinyint tags (033) values (now, '') + +sql_error insert into st_tinyint_e13 using mt_tinyint tags (128) values (now, -033) +sql_error insert into st_tinyint_e14 using mt_tinyint tags (-128) values (now, -033) +sql_error insert into st_tinyint_e15 using mt_tinyint tags (1280) values (now, -033) +sql_error insert into st_tinyint_e16 using mt_tinyint tags (-1280) values (now, -033) +#sql_error insert into st_tinyint_e17 using mt_tinyint tags (12.80) values (now, -033) +#sql_error insert into st_tinyint_e18 using mt_tinyint tags (-11.80) values (now, -033) +sql_error insert into st_tinyint_e19 using mt_tinyint tags (123abc) values (now, -033) +sql_error insert into st_tinyint_e20 using mt_tinyint tags ("123abc") values (now, -033) +sql_error insert into st_tinyint_e22 using mt_tinyint tags (abc) values (now, -033) +sql_error insert into st_tinyint_e23 using mt_tinyint tags ("abc") values (now, -033) +sql_error insert into st_tinyint_e24 using mt_tinyint tags (" ") values (now, -033) +sql_error insert into st_tinyint_e25 using mt_tinyint tags ('') values (now, -033) + +sql insert into st_tinyint_e13 using mt_tinyint tags (033) values (now, 00062) +sql insert into st_tinyint_e14 using mt_tinyint tags (033) values (now, 00062) +sql insert into st_tinyint_e15 using mt_tinyint tags (033) values (now, 00062) +sql insert into st_tinyint_e16 using mt_tinyint tags (033) values (now, 00062) +sql insert into st_tinyint_e17 using mt_tinyint tags (033) values (now, 00062) +sql insert into st_tinyint_e18 using mt_tinyint tags (033) values (now, 00062) +sql insert into st_tinyint_e19 using mt_tinyint tags (033) values (now, 00062) +sql insert into st_tinyint_e20 using mt_tinyint tags (033) values (now, 00062) +sql insert into st_tinyint_e21 using mt_tinyint tags (033) values (now, 00062) +sql insert into st_tinyint_e22 using mt_tinyint tags (033) values (now, 00062) +sql insert into st_tinyint_e23 using mt_tinyint tags (033) values (now, 00062) +sql insert into st_tinyint_e24 using mt_tinyint tags (033) values (now, 00062) +sql insert into st_tinyint_e25 using mt_tinyint tags (033) values (now, 00062) + +sql_error alter table st_tinyint_e13 set tag tagname=128 +sql_error alter table st_tinyint_e14 set tag tagname=-128 +sql_error alter table st_tinyint_e15 set tag tagname=1280 +sql_error alter table st_tinyint_e16 set tag tagname=-1280 +sql_error alter table st_tinyint_e19 set tag tagname=123abc +sql_error alter table st_tinyint_e20 set tag tagname="123abc" +sql_error alter table st_tinyint_e22 set tag tagname=abc +sql_error alter table st_tinyint_e23 set tag tagname="abc" +sql_error alter table st_tinyint_e24 set tag tagname=" " +sql_error alter table st_tinyint_e25 set tag tagname='' diff --git a/tests/script/general/parser/columnValue_unsign.sim b/tests/script/general/parser/columnValue_unsign.sim new file mode 100644 index 0000000000000000000000000000000000000000..9e011dd74ab49d8fc9617a20e6478d1e463c2433 --- /dev/null +++ b/tests/script/general/parser/columnValue_unsign.sim @@ -0,0 +1,208 @@ +sleep 100 +sql connect +sql create database if not exists db +sql use db + +sql drop table if exists mt_unsigned; + +sql create table mt_unsigned (ts timestamp, a tinyint unsigned, b smallint unsigned, c int unsigned, d bigint unsigned, e tinyint, f smallint, g int, h bigint, j bool) tags (t1 tinyint unsigned, t2 smallint unsigned, t3 int unsigned, t4 bigint unsigned, t5 tinyint, t6 smallint, t7 int, t8 bigint); +sql create table mt_unsigned_1 using mt_unsigned tags(0, 0, 0, 0, 0, 0, 0, 0); + +sql alter table mt_unsigned_1 set tag t1=138; +sql alter table mt_unsigned_1 set tag t2=32769; +sql alter table mt_unsigned_1 set tag t3=294967295; +sql alter table mt_unsigned_1 set tag t4=446744073709551615; +sql select t1,t2,t3,t4 from mt_unsigned_1 +if $rows != 1 then + return -1 +endi + +print $data00, $data01, $data02, $data03 + +if $data00 != 138 then + print expect 138, actual: $data00 + return -1 +endi + +if $data01 != 32769 then +return -1 +endi + +if $data02 != 294967295 then +return -1 +endi + +if $data03 != 446744073709551615 then +return -1 +endi + +sql_error sql alter table mt_unsigned_1 set tag t1 = 999; +sql_error sql alter table mt_unsigned_1 set tag t2 = 95535; +sql_error sql alter table mt_unsigned_1 set tag t3 = 8294967295l; +sql_error sql alter table mt_unsigned_1 set tag t4 = 19446744073709551615; + +sql_error create table mt_unsigned_2 using mt_unsigned tags(-1, 0, 0, 0, 0, 0, 0, 0); +sql_error create table mt_unsigned_3 using mt_unsigned tags(0, -1, 0, 0, 0, 0, 0, 0); +sql_error create table mt_unsigned_4 using mt_unsigned tags(0, 0, -1, 0, 0, 0, 0, 0); +sql_error create table mt_unsigned_5 using mt_unsigned tags(0, 0, 0, -1, 0, 0, 0, 0); + +sql_error create table mt_unsigned_2 using mt_unsigned tags(255, 0, 0, 0, 0, 0, 0, 0); +sql_error create table mt_unsigned_3 using mt_unsigned tags(0, 65535, 0, 0, 0, 0, 0, 0); +sql_error create table mt_unsigned_4 using mt_unsigned tags(0, 0, 4294967295, 0, 0, 0, 0, 0); +sql_error create table mt_unsigned_5 using mt_unsigned tags(0, 0, 0, 18446744073709551615, 0, 0, 0, 0); + +sql_error create table mt_unsigned_2 using mt_unsigned tags(999, 0, 0, 0, 0, 0, 0, 0); +sql_error create table mt_unsigned_3 using mt_unsigned tags(0, 95535, 0, 0, 0, 0, 0, 0); +sql_error create table mt_unsigned_4 using mt_unsigned tags(0, 0, 5294967295l, 0, 0, 0, 0, 0); +sql_error create table mt_unsigned_5 using mt_unsigned tags(0, 0, 0, 28446744073709551615u, 0, 0, 0, 0); + +sql alter table mt_unsigned_1 set tag t1=NULL; +sql alter table mt_unsigned_1 set tag t2=NULL; +sql alter table mt_unsigned_1 set tag t3=NULL; +sql alter table mt_unsigned_1 set tag t4=NULL; +sql select t1,t2,t3,t4 from mt_unsigned_1 +if $rows != 1 then + return -1; +endi + +if $data00 != NULL then + print expect NULL, actual: $data00 + return -1 +endi + +if $data01 != NULL then + return -1 +endi + +if $data02 != NULL then + return -1 +endi + +if $data03 != NULL then + return -1 +endi + +sql insert into mt_unsigned_1 values(now, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); +sql insert into mt_unsigned_1 values(now+1s, 1, 2, 3, 4, 5, 6, 7, 8, 9); + +sql_error insert into mt_unsigned_1 values(now, -1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); +sql_error insert into mt_unsigned_1 values(now, NULL, -1, NULL, NULL, NULL, NULL, NULL, NULL, NULL); +sql_error insert into mt_unsigned_1 values(now, NULL, NULL, -1, NULL, NULL, NULL, NULL, NULL, NULL); +sql_error insert into mt_unsigned_1 values(now, NULL, NULL, NULL, -1, NULL, NULL, NULL, NULL, NULL); +sql_error insert into mt_unsigned_1 values(now, 255, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); +sql_error insert into mt_unsigned_1 values(now, NULL, 65535, NULL, NULL, NULL, NULL, NULL, NULL, NULL); +sql_error insert into mt_unsigned_1 values(now, NULL, NULL, 4294967295, NULL, NULL, NULL, NULL, NULL, NULL); +sql_error insert into mt_unsigned_1 values(now, NULL, NULL, NULL, 18446744073709551615, NULL, NULL, NULL, NULL, NULL); +sql select count(a),count(b),count(c),count(d), count(e) from mt_unsigned_1 +if $rows != 1 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + +if $data01 != 1 then + return -1 +endi + +sql select a+b+c from mt_unsigned_1 where a is null; +if $rows != 1 then + return -1 +endi + +if $data00 != NULL then + print expect NULL, actual:$data00 + return -1 +endi + +sql select count(*), a from mt_unsigned_1 group by a; +if $rows != 2 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + +if $data01 != NULL then + return -1 +endi + +if $data10 != 1 then + return -1 +endi + +if $data11 != 1 then + return -1 +endi + +sql select count(*), b from mt_unsigned_1 group by b; +if $rows != 2 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + +if $data01 != NULL then + return -1 +endi + +if $data10 != 1 then + return -1 +endi + +if $data11 != 2 then + return -1 +endi + +sql select count(*), c from mt_unsigned_1 group by c; +if $rows != 2 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + +if $data01 != NULL then + return -1 +endi + +if $data10 != 1 then + return -1 +endi + +if $data11 != 3 then + return -1 +endi + +sql select count(*), d from mt_unsigned_1 group by d; +if $rows != 2 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + +if $data01 != NULL then + return -1 +endi + +if $data10 != 1 then + return -1 +endi + +if $data11 != 4 then + return -1 +endi + +## todo insert more rows and chec it +sql select first(a),count(b),last(c),sum(b),spread(d),avg(c),min(b),max(a),stddev(a) from mt_unsigned_1; +if $rows != 1 then + return -1 +endi + diff --git a/tests/script/general/parser/commit.sim b/tests/script/general/parser/commit.sim new file mode 100644 index 0000000000000000000000000000000000000000..7c4c883fb137607611ad2599f013bdd0ed5675b1 --- /dev/null +++ b/tests/script/general/parser/commit.sim @@ -0,0 +1,112 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxTablesperVnode -v 100 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = sc_db +$tbPrefix = sc_tb +$stbPrefix = sc_stb +$tbNum = 10 +$rowNum = 10000 +$totalNum = $tbNum * $rowNum +$loops = 5 +$log = 1 +$ts0 = 1537146000000 +$delta = 600000 +print ========== commit.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db maxrows 255 ctime 3600 +print ====== create tables +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int) + +$i = 0 +$ts = $ts0 +$halfNum = $tbNum / 2 +while $i < $halfNum + $tbId = $i + $halfNum + $tb = $tbPrefix . $i + $tb1 = $tbPrefix . $tbId + sql create table $tb using $stb tags( $i ) + sql create table $tb1 using $stb tags( $tbId ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) $tb1 values ( $ts , $c , NULL , $c , NULL , $c , $c , true, $binary , $nchar ) + $x = $x + 1 + endw + + $i = $i + 1 +endw +print ====== tables created + +sql use $db +##### select from table +print ====== select from table and check num of rows returned +$loop = 1 +$i = 0 +while $loop <= $loops + print repeat = $loop + while $i < 10 + sql select count(*) from $stb where t1 = $i + if $data00 != $rowNum then + print expect $rowNum , actual: $data00 + return -1 + endi + $i = $i + 1 + endw + sql select count(*) from $stb + if $data00 != $totalNum then + return -1 + endi + $loop = $loop + 1 +endw + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 500 +system sh/exec.sh -n dnode1 -s start +sleep 100 +print ================== server restart completed +sql connect +sleep 100 + +print ====== select from table and check num of rows returned +sql use $db +$loop = 1 +$i = 0 +while $loop <= $loops + print repeat = $loop + while $i < 10 + sql select count(*) from $stb where t1 = $i + if $data00 != $rowNum then + return -1 + endi + $i = $i + 1 + endw + sql select count(*) from $stb + if $data00 != $totalNum then + return -1 + endi + $loop = $loop + 1 +endw + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/parser/constCol.sim b/tests/script/general/parser/constCol.sim new file mode 100644 index 0000000000000000000000000000000000000000..66523517be92eb7bddcb248b54522143f27e09d5 --- /dev/null +++ b/tests/script/general/parser/constCol.sim @@ -0,0 +1,406 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 + +system sh/cfg.sh -n dnode1 -c dDebugFlag -v 135 +system sh/cfg.sh -n dnode1 -c mDebugFlag -v 135 +system sh/cfg.sh -n dnode1 -c sdbDebugFlag -v 135 +system sh/cfg.sh -n dnode1 -c rpcDebugFlag -v 135 +system sh/cfg.sh -n dnode1 -c cDebugFlag -v 135 +system sh/cfg.sh -n dnode1 -c monitorDebugflag -v 135 +system sh/cfg.sh -n dnode1 -c httpDebugFlag -v 135 +system sh/cfg.sh -n dnode1 -c uDebugFlag -v 135 + +system sh/cfg.sh -n dnode1 -c httpCacheSessions -v 10 +system sh/cfg.sh -n dnode1 -c httpMaxThreads -v 10 +system sh/cfg.sh -n dnode1 -c httpEnableCompress -v 0 + +system sh/cfg.sh -n dnode1 -c maxVnodeConnections -v 30000 +system sh/cfg.sh -n dnode1 -c maxMgmtConnections -v 30000 +system sh/cfg.sh -n dnode1 -c maxMeterConnections -v 30000 +system sh/cfg.sh -n dnode1 -c maxShellConns -v 30000 + +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create database db; +sql use db; +sql create table t (ts timestamp, i int); +sql create table st1 (ts timestamp, f1 int) tags(t1 int); +sql create table st2 (ts timestamp, f2 int) tags(t2 int); + +sql create table t1 using st1 tags(1); +sql create table t2 using st2 tags(1); + +sql insert into t1 values(1575880055000, 1); +sql insert into t1 values(1575880059000, 1); +sql insert into t1 values(1575880069000, 1); + +sql insert into t2 values(1575880055000, 2); + +sql select st1.ts, st1.f1, st2.f2 from db.st1, db.st2 where st1.t1=st2.t2 and st1.ts=st2.ts + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select st1.ts, st1.f1, st2.f2 from db.st1, db.st2 where st1.t1=st2.t2 and st1.ts=st2.ts' 127.0.0.1:7111/restful/sql + +print ==============select with user-defined columns +sql select 'abc' as f, ts,f1 from t1 +if $rows != 3 then + return -1 +endi + +if $data00 != @abc@ then + return -1 +endi + +if $data01 != @19-12-09 16:27:35.000@ then + return -1 +endi + +if $data02 != 1 then + return -1 +endi + +sql select 'abc', ts, f1 from t1 +if $rows != 3 then + return -1 +endi + +if $data01 != @19-12-09 16:27:35.000@ then + return -1 +endi + +if $data02 != 1 then + return -1 +endi + +if $data10 != @abc@ then + return -1 +endi + +sql select 'abc' from t1 +if $rows != 3 then + return -1 +endi + +if $data00 != @abc@ then + return -1 +endi + +sql select 'abc' as f1 from t1 +if $rows != 3 then + return -1 +endi + +if $data00 != @abc@ then + return -1 +endi + +sql select 1 from t1 +if $rows != 3 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + +if $data10 != 1 then + return -1 +endi + +if $data20 != 1 then + return -1 +endi + +sql select 1 as f1 from t1 +if $rows != 3 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + +sql select 1 as f, f1 from t1 +if $rows != 3 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + +if $data01 != 1 then + return -1 +endi + +sql select 1.123 as f, f1 from t1 +if $rows != 3 then + return -1 +endi + +if $data00 != 1.123000000 then + print expect 1.123000000 , actual:$data00 + return -1 +endi + +if $data10 != 1.123000000 then + print expect 1.123000000 , actual:$data10 + return -1 +endi + +sql select 1, f1 from t1 +if $rows != 3 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + +if $data01 != 1 then + return -1 +endi + +if $data10 != 1 then + return -1 +endi + +sql select 1.2391, f1 from t1 +if $rows != 3 then + return -1 +endi + +if $data00 != 1.239100000 then + print expect 1.239100000 actual: $data00 + return -1 +endi + +if $data10 != 1.239100000 then + print expect 1.239100000 actual: $data00 + return -1 +endi + +if $data01 != 1 then + return -1 +endi + +print ===================== user-defined columns with agg functions +sql select 1 as t, count(*) from t1 +if $rows != 1 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + +if $data01 != 3 then + return -1 +endi + +sql select 1, sum(f1) from t1 +if $rows != 1 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + +if $data01 != 3 then + return -1 +endi + +sql select 1,2,3, sum(f1)*99, 4,5,6,7,8,9,10 from t1 +if $rows != 1 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + +if $data01 != 2 then + return -1 +endi + +if $data02 != 3 then + return -1 +endi + +if $data03 != 297.000000000 then + print expect 297.000000000, actual:$data03 + return -1 +endi + +sql select sum(f1)*avg(f1)+12, 1,2,3,4,5,6,7,8,9,10 from t1 +if $rows != 1 then + return -1 +endi + +if $data00 != 15.000000000 then + print expect 15.000000000 actual:$data00 + return -1 +endi + +if $data01 != 1 then + return -1 +endi + +if $data02 != 2 then + return -1 +endi + +sql select 1.2987, f1, 'k' from t1 where f1=1 +if $rows != 3 then + return -1 +endi + +if $data00 != 1.298700000 then + print expect 1.298700000 actual:$data00 + return -1 +endi + +if $data01 != 1 then + return -1 +endi + +if $data02 != @k@ then + return -1 +endi + +print ====================user-defined columns with union +sql select f1, 'f1' from t1 union all select f1, 'f1' from t1; +if $rows != 6 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + +if $data01 != @f1@ then + return -1 +endi + +if $data10 != 1 then + return -1 +endi + +if $data11 != @f1@ then + return -1 +endi + +print =====================udc with join +sql select st1.ts, st1.f1, st2.f2, 'abc', 1.9827 from db.st1, db.st2 where st1.t1=st2.t2 and st1.ts=st2.ts +if $rows != 1 then + return -1 +endi + +if $data00 != @19-12-09 16:27:35.000@ then + print expect @19-12-09 16:27:35.000@ actual:$data00 + return -1 +endi + +if $data01 != 1 then + return -1 +endi + +if $data02 != 2 then + return -1 +endi + +if $data03 != @abc@ then + return -1 +endi + +if $data04 != 1.982700000 then + print expect 1.982700000 actual:$data04 + return -1 +endi + +print ======================udc with interval +sql select count(*), 'uuu' from t1 interval(1s) order by ts desc; +if $rows != 3 then + return -1 +endi + +print ======================udc with tags +sql select t1,'abc',tbname from st1 +if $rows != 1 then + return -1 +endi + +if $data01 != @abc@ then + return -1 +endi + +if $data02 != @t1@ then + return -1 +endi + +print ======================udc with arithmetic +sql select 1+1 from t1 +if $rows != 3 then + return -1 +endi + +sql select 0.1 + 0.2 from t1 +if $rows != 3 then + return -1 +endi + +print =============================> td-2036 +if $data00 != 0.300000000 then + print expect: 0.300000000, actual:$data00 + return -1 +endi + +print =============================> td-3996 +sql select 'abc' as res from t1 where f1 < 0 +if $rows != 0 then + return -1 +endi + + +print ======================udc with normal column group by + +sql_error select from t1 +sql_error select abc from t1 +sql_error select abc as tu from t1 + +print ========================> td-1756 +sql_error select * from t1 where ts>now-1y +sql_error select * from t1 where ts>now-1n + +print ========================> td-1752 +sql select * from db.st2 where t2 < 200 and t2 is not null; +if $rows != 1 then + return -1 +endi + +if $data00 != @19-12-09 16:27:35.000@ then + return -1 +endi + +if $data01 != 2 then + return -1 +endi + +if $data02 != 1 then + return -1 +endi + +sql select * from db.st2 where t2 > 200 or t2 is null; +if $rows != 0 then + return -1 +endi + +sql select * from st2 where t2 < 200 and t2 is null; +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/create_db.sim b/tests/script/general/parser/create_db.sim new file mode 100644 index 0000000000000000000000000000000000000000..a62a45e0233f5db81bc7565c856f08483c9d8aee --- /dev/null +++ b/tests/script/general/parser/create_db.sim @@ -0,0 +1,289 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 100 +sql connect +print ======================== dnode1 start + +$dbPrefix = fi_in_db +$tbPrefix = fi_in_tb +$mtPrefix = fi_in_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print excuting test script create_db.sim +print =============== set up +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql_error createdatabase $db +sql create database $db +sql use $db +sql show databases + +if $rows != 1 then + return -1 +endi +if $data00 != $db then + return -1 +endi +sql drop database $db + +# case1: case_insensitivity test +print =========== create_db.sim case1: case insensitivity test +sql_error CREATEDATABASE $db +sql CREATE DATABASE $db +sql use $db +sql show databases + +if $rows != 1 then + return -1 +endi +if $data00 != $db then + return -1 +endi +sql drop database $db +print case_insensitivity test passed + +# case2: illegal_db_name test +print =========== create_db.sim case2: illegal_db_name test +$illegal_db1 = 1db +$illegal_db2 = d@b + +sql_error create database $illegal_db1 +sql_error create database $illegal_db2 +print illegal_db_name test passed + +# case3: chinese_char_in_db_name test +print ========== create_db.sim case3: chinese_char_in_db_name test +$CN_db1 = 数据库 +$CN_db2 = 数据库1 +$CN_db3 = db数据库1 +sql_error create database $CN_db1 +sql_error create database $CN_db2 +sql_error create database $CN_db3 +#sql show databases +#if $rows != 3 then +# return -1 +#endi +#if $data00 != $CN_db1 then +# return -1 +#endi +#if $data10 != $CN_db2 then +# return -1 +#endi +#if $data20 != $CN_db3 then +# return -1 +#endi +#sql drop database $CN_db1 +#sql drop database $CN_db2 +#sql drop database $CN_db3 +print case_chinese_char_in_db_name test passed + +# case4: db_already_exists +print create_db.sim case4: db_already_exists +sql create database db0 +sql create database db0 +sql show databases +if $rows != 1 then + return -1 +endi +sql drop database db0 +print db_already_exists test passed + +# case5: db_meta_data +print create_db.sim case5: db_meta_data test +# cfg params +$replica = 1 # max=3 +$days = 10 +$keep = 365,365,365 +$rows_db = 1000 +$cache = 16 # 16MB +$ablocks = 100 +$tblocks = 32 # max=512, automatically trimmed when exceeding +$ctime = 36000 # 10 hours +$wal = 1 # valid value is 1, 2 +$comp = 1 # max=32, automatically trimmed when exceeding + +sql create database $db replica $replica days $days keep $keep maxrows $rows_db cache $cache blocks 4 ctime $ctime wal $wal comp $comp +sql show databases +if $rows != 1 then + return -1 +endi +if $data00 != $db then + return -1 +endi +if $data04 != $replica then + return -1 +endi +if $data06 != $days then + return -1 +endi +if $data07 != 365,365,365 then + return -1 +endi +print data08 = $data07 +if $data08 != $cache then + print expect $cache, actual:$data08 + return -1 +endi +if $data09 != 4 then + return -1 +endi + +sql drop database $db + +## param range tests +# replica [1,3] +#sql_error create database $db replica 0 +sql_error create database $db replica 4 + +# day [1, 3650] +sql_error create database $db day 0 +sql_error create database $db day 3651 + +# keep [1, infinity] +sql_error create database $db keep 0 +sql_error create database $db keep 0,0,0 +sql_error create database $db keep 3,3,3 +sql_error create database $db keep 11.0 +sql_error create database $db keep 11.0,11.0,11.0 +sql_error create database $db keep "11","11","11" +sql_error create database $db keep "11" +sql_error create database $db keep 13,12,11 +sql_error create database $db keep 11,12,11 +sql_error create database $db keep 12,11,12 +sql_error create database $db keep 8 +sql_error create database $db keep 12,11 +sql_error create database $db keep 365001,365001,365001 +sql create database dbk0 keep 19 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 19,19,19 then + return -1 +endi +sql drop database dbk0 +sql create database dbka keep 19,20 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 19,20,20 then + return -1 +endi +sql drop database dbka + +sql create database dbk1 keep 11,11,11 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 11,11,11 then + return -1 +endi +sql drop database dbk1 +sql create database dbk2 keep 11,12,13 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 11,12,13 then + return -1 +endi +sql drop database dbk2 +sql create database dbk3 keep 11,11,13 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 11,11,13 then + return -1 +endi +sql drop database dbk3 +sql create database dbk4 keep 11,13,13 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 11,13,13 then + return -1 +endi +sql drop database dbk4 +#sql_error create database $db keep 3651 + +# rows [200, 10000] +sql_error create database $db maxrows 199 +#sql_error create database $db maxrows 10001 + +# cache [100, 10485760] +sql_error create database $db cache 0 +#sql_error create database $db cache 10485761 + + +# blocks [32, 4096 overwriten by 4096 if exceeds, Note added:2018-10-24] +#sql_error create database $db tblocks 31 +#sql_error create database $db tblocks 4097 + +# ctime [30, 40960] +sql_error create database $db ctime 29 +sql_error create database $db ctime 40961 + +# wal {0, 2} +sql create database testwal wal 0 +sql show databases +if $rows != 1 then + return -1 +endi + +sql show databases +print wallevel $data12_testwal +if $data12_testwal != 0 then + return -1 +endi +sql drop database testwal + +sql create database testwal wal 1 +sql show databases +if $rows != 1 then + return -1 +endi +sql show databases +print wallevel $data12_testwal +if $data12_testwal != 1 then + return -1 +endi +sql drop database testwal + +sql create database testwal wal 2 +sql show databases +if $rows != 1 then + return -1 +endi +print wallevel $data12_testwal +if $data12_testwal != 2 then + return -1 +endi +sql drop database testwal + +sql_error create database $db wal -1 +sql_error create database $db wal 3 + +# comp {0, 1, 2} +sql_error create database $db comp -1 +sql_error create database $db comp 3 + +sql_error drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/create_db__for_community_version.sim b/tests/script/general/parser/create_db__for_community_version.sim new file mode 100644 index 0000000000000000000000000000000000000000..406e69b0e6a025c5e733ab753510f65677e4b550 --- /dev/null +++ b/tests/script/general/parser/create_db__for_community_version.sim @@ -0,0 +1,238 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 100 +sql connect +print ======================== dnode1 start + +$dbPrefix = fi_in_db +$tbPrefix = fi_in_tb +$mtPrefix = fi_in_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print excuting test script create_db.sim +print =============== set up +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql_error createdatabase $db +sql create database $db +sql use $db +sql show databases + +if $rows != 1 then + return -1 +endi +if $data00 != $db then + return -1 +endi +sql drop database $db + +# case1: case_insensitivity test +print =========== create_db.sim case1: case insensitivity test +sql_error CREATEDATABASE $db +sql CREATE DATABASE $db +sql use $db +sql show databases + +if $rows != 1 then + return -1 +endi +if $data00 != $db then + return -1 +endi +sql drop database $db +print case_insensitivity test passed + +# case2: illegal_db_name test +print =========== create_db.sim case2: illegal_db_name test +$illegal_db1 = 1db +$illegal_db2 = d@b + +sql_error create database $illegal_db1 +sql_error create database $illegal_db2 +print illegal_db_name test passed + +# case3: chinese_char_in_db_name test +print ========== create_db.sim case3: chinese_char_in_db_name test +$CN_db1 = 数据库 +$CN_db2 = 数据库1 +$CN_db3 = db数据库1 +sql_error create database $CN_db1 +sql_error create database $CN_db2 +sql_error create database $CN_db3 +#sql show databases +#if $rows != 3 then +# return -1 +#endi +#if $data00 != $CN_db1 then +# return -1 +#endi +#if $data10 != $CN_db2 then +# return -1 +#endi +#if $data20 != $CN_db3 then +# return -1 +#endi +#sql drop database $CN_db1 +#sql drop database $CN_db2 +#sql drop database $CN_db3 +print case_chinese_char_in_db_name test passed + +# case4: db_already_exists +print create_db.sim case4: db_already_exists +sql create database db0 +sql create database db0 +sql show databases +if $rows != 1 then + return -1 +endi +sql drop database db0 +print db_already_exists test passed + +# case5: db_meta_data +print create_db.sim case5: db_meta_data test +# cfg params +$replica = 1 # max=3 +$days = 10 +$keep = 365 +$rows_db = 1000 +$cache = 16 # 16MB +$ablocks = 100 +$tblocks = 32 # max=512, automatically trimmed when exceeding +$ctime = 36000 # 10 hours +$wal = 1 # valid value is 1, 2 +$comp = 1 # max=32, automatically trimmed when exceeding + +sql create database $db replica $replica days $days keep $keep maxrows $rows_db cache $cache blocks 4 ctime $ctime wal $wal comp $comp +sql show databases +if $rows != 1 then + return -1 +endi +if $data00 != $db then + return -1 +endi +if $data04 != $replica then + return -1 +endi +if $data06 != $days then + return -1 +endi +if $data07 != 365 then + return -1 +endi +print data08 = $data07 +if $data08 != $cache then + print expect $cache, actual:$data08 + return -1 +endi +if $data09 != 4 then + return -1 +endi + +sql drop database $db + +## param range tests +# replica [1,3] +#sql_error create database $db replica 0 +sql_error create database $db replica 4 + +# day [1, 3650] +sql_error create database $db day 0 +sql_error create database $db day 3651 + +# keep [1, infinity] +sql_error create database $db keep 0 +sql_error create database $db keep 0,0,0 +sql_error create database $db keep 3,3,3 +sql_error create database $db keep 3 +sql_error create database $db keep 11.0 +sql_error create database $db keep 11.0,11.0,11.0 +sql_error create database $db keep "11","11","11" +sql_error create database $db keep "11" +sql_error create database $db keep 13,12,11 +sql_error create database $db keep 11,12,11 +sql_error create database $db keep 12,11,12 +sql_error create database $db keep 11,12,13 +sql_error create database $db keep 11,12,13,14 +sql_error create database $db keep 11,11 +sql_error create database $db keep 365001,365001,365001 +sql_error create database $db keep 365001 +sql create database dbk1 keep 11 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 11 then + return -1 +endi +sql drop database dbk1 +sql create database dbk2 keep 12 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 12 then + return -1 +endi +sql drop database dbk2 +sql create database dbk3 keep 11 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 11 then + return -1 +endi +sql drop database dbk3 +sql create database dbk4 keep 13 +sql show databases +if $rows != 1 then + return -1 +endi +if $data07 != 13 then + return -1 +endi +sql drop database dbk4 +#sql_error create database $db keep 3651 + +# rows [200, 10000] +sql_error create database $db maxrows 199 +#sql_error create database $db maxrows 10001 + +# cache [100, 10485760] +sql_error create database $db cache 0 +#sql_error create database $db cache 10485761 + + +# blocks [32, 4096 overwriten by 4096 if exceeds, Note added:2018-10-24] +#sql_error create database $db tblocks 31 +#sql_error create database $db tblocks 4097 + +# ctime [30, 40960] +sql_error create database $db ctime 29 +sql_error create database $db ctime 40961 + +# wal {0, 2} +#sql_error create database $db wal 0 +sql_error create database $db wal -1 +sql_error create database $db wal 3 + +# comp {0, 1, 2} +sql_error create database $db comp -1 +sql_error create database $db comp 3 + +sql_error drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/create_mt.sim b/tests/script/general/parser/create_mt.sim new file mode 100644 index 0000000000000000000000000000000000000000..c606ba99ecb5f9060de9bb8f52af916c2d2b96b6 --- /dev/null +++ b/tests/script/general/parser/create_mt.sim @@ -0,0 +1,256 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 100 +sql connect +print ======================== dnode1 start + +$dbPrefix = fi_in_db +$tbPrefix = fi_in_tb +$mtPrefix = fi_in_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print excuting test script create_mt.sim +print =============== set up +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql create database $db +sql use $db + +# case1: case_insensitivity test +print =========== create_mt.sim case1: case insensitivity test +sql CREATE TABLE $mt (TS TIMESTAMP, COL1 INT, COL2 BIGINT, COL3 FLOAT, COL4 DOUBLE, COL5 BINARY(10), COL6 BOOL, COL7 SMALLINT, COL8 TINYINT, COL9 NCHAR(10)) TAGS (TAG1 INT, TAG2 BIGINT, TAG3 DOUBLE, TAG4 BINARY(10), TAG5 BOOL, TAG6 NCHAR(10)) +sql show stables + +if $rows != 1 then + return -1 +endi +if $data00 != $mt then + return -1 +endi +sql_error DROP METRIC $mt + +sql DROP TABLE $mt +sql show stables + +if $rows != 0 then + return -1 +endi +print case_insensitivity test passed + +# case2: illegal_metric_name test +print =========== create_mt.sim case2: illegal_mt_name test +$illegal_tb1 = 1db +$illegal_tb2 = d@b + +sql_error create table $illegal_tb1 (ts timestamp, tcol int) tags (tag1 int) + +sql_error create table $illegal_tb2 (ts timestamp, tcol int) tags (tag1 int) + +print illegal_metric_name test passed + +## case3: illegal_data_types_in_data_column test +print ========== create_mt.sim case3: metric illegal data types test + +$i_ts = time # illegal ts +$i_binary = binary # illegal binary +$i_bigint = long # illegal bigint +$i_smallint = short # illegal smallint +$i_tinyint = byte # illegal tinyint +$i_binary2 = varchar(20) # illegal string +$i_nchar = nchar # unspecified nchar length + +sql_error create table $mt (ts $i_ts , col int) tags (tag1 int) +sql_error create table $mt (ts timestamp, col $i_binary ) tags (tag1 int) +sql_error create table $mt (ts timestamp, col $i_bigint ) tags (tag1 int) +sql_error create table $mt (ts timestamp, col $i_smallint ) tags (tag1 int) +sql_error create table $mt (ts timestamp, col $i_binary2 ) tags (tag1 int) +sql_error create table $mt (ts timestamp, col $i_tinyint ) tags (tag1 int) +sql_error create table $mt (ts timestamp, col $i_nchar ) tags (tag1 int) + +# correct using of nchar +sql create table $mt (ts timestamp, col nchar(10)) tags (tag1 int) +sql show stables +if $rows != 1 then + return -1 +endi +if $data00 != $mt then + return -1 +endi +sql drop table $mt +print illegal_data_type_in_tags test passed + +## case4: illegal_data_type_in_tags test +$i_ts = time # illegal ts +$i_binary = binary # illegal binary +$i_bigint = long # illegal bigint +$i_smallint = short # illegal smallint +$i_tinyint = byte # illegal tinyint +$i_binary2 = varchar(20) # illegal string +$i_bool = boolean +$nchar = nchar # nchar with unspecified length +print ========== create_mt.sim case4: illegal data types in tags test +##sql_error create table $mt (ts timestamp, col int) tags (tag1 timestamp ) +sql_error create table $mt (ts timestamp, col int) tags (tag1 $i_ts ) +sql_error create table $mt (ts timestamp, col int) tags (tag1 $i_binary ) +sql_error create table $mt (ts timestamp, col int) tags (tag1 $i_bigint ) +sql_error create table $mt (ts timestamp, col int) tags (tag1 $i_smallint ) +sql_error create table $mt (ts timestamp, col int) tags (tag1 $i_tinyint ) +sql_error create table $mt (ts timestamp, col int) tags (tag1 $i_binary2 ) +sql_error create table $mt (ts timestamp, col int) tags (tag1 $i_bool ) +sql_error create table $mt (ts timestamp, col int) tags (tag1 $nchar ) +# correct use of nchar in tags +sql create table $mt (ts timestamp, col int) tags (tag1 nchar(20)) +sql show stables +if $rows != 1 then + return -1 +endi +if $data00 != $mt then + return -1 +endi +sql drop table $mt +print illegal_data_type_in_tags test passed + +# illegal_tag_name test +# Only frequently used key words are tested here +$tb_ = table +$tbs = tables +$db_ = database +$dbs = databases +$ses = session +$int = int +$bint = bigint +$binary = binary +$str = string +$tag = tag +$tags = tags +$sint = smallint +$tint = tinyint +$nchar = nchar +$bool = bool +$stable = stable +$stables = stables + +sql_error create table $mt (ts timestamp, col1 int) tags ( $tb_ int) +sql_error create table $mt (ts timestamp, col1 int) tags ( $tbs int) +sql_error create table $mt (ts timestamp, col1 int) tags ( $db_ int) +sql_error create table $mt (ts timestamp, col1 int) tags ( $dbs int) +sql_error create table $mt (ts timestamp, col1 int) tags ( $ses int) +sql_error create table $mt (ts timestamp, col1 int) tags ( $int int) +sql_error create table $mt (ts timestamp, col1 int) tags ( $bint int) +sql_error create table $mt (ts timestamp, col1 int) tags ( $binary int) +sql_error create table $mt (ts timestamp, col1 int) tags ( $str int) +sql_error create table $mt (ts timestamp, col1 int) tags ( $tag int) +sql_error create table $mt (ts timestamp, col1 int) tags ( $tags int) +sql_error create table $mt (ts timestamp, col1 int) tags ( $sint int) +sql_error create table $mt (ts timestamp, col1 int) tags ( $tint int) +sql_error create table $mt (ts timestamp, col1 int) tags ( $nchar int) +sql_error create table $mt (ts timestamp, col1 int) tags ( $stable int) +sql_error create table $mt (ts timestamp, col1 int) tags ( $stables int) +sql_error create table $mt (ts timestamp, col1 int) tags ( $bool int) + +print illegal_column_name test passed + +# case: negative tag values +sql create table $mt (ts timestamp, col1 int) tags (tg int) +sql create table $tb using $mt tags (-1) +# -x ng_tag_v +# return -1 +#ng_tag_v: +sql select tg from $tb +if $data00 != -1 then + return -1 +endi +sql drop table $tb + +# case: unmatched_tag_types +print create_mt.sim unmatched_tag_types +sql reset query cache +sql create table $tb using $mt tags ('123') +sql select tg from $tb +print data00 = $data00 +if $data00 != 123 then + return -1 +endi +sql drop table $tb +sql_error create table $tb using $mt tags (abc) +#the case below might need more consideration +sql_error create table $tb using $mt tags ('abc') +sql drop table if exists $tb +sql reset query cache +sql create table $tb using $mt tags (1e1) +sql select tg from $tb +if $data00 != 10 then + return -1 +endi +sql drop table $tb +sql create table $tb using $mt tags ('1e1') +sql select tg from $tb +if $data00 != 10 then + return -1 +endi +sql_error create table $tb using $mt tags (2147483649) + +## case: chinese_char_in_metric +print ========== create_mt.sim chinese_char_in_metrics_support test +$CN_char = 涛思 +$mt1 = mt1 +$mt2 = mt2 +# no chinese char allowed in db, metric, table, column names +#sql_error create table $CN_char (ts timestamp, col1 int) tags (tag1 int) +#sql_error create table $mt1 (ts timestamp, $CN_char int) tags (tag1 int) +#sql_error create table $mt2 (ts timestamp, col1 int) tags ( $CN_char int) +#sql show metrics +#if $rows != 3 then +# return -1 +#endi +##print expected: $CN_char +##print returned: $data00 +#if $data00 != $CN_char then +# return -1 +#endi +##print expected: $mt1 +##print returned: $data10 +#if $data10 != $mt1 then +# return -1 +#endi +##print expected: $mt2 +##print returned: $data20 +#if $data20 != $mt2 then +# return -1 +#endi +#sql select tg from $mt1 +##print expected $CN_char +##print returned $data10 +#if $data10 != $CN_char then +# return -1 +#endi +#sql select tg from $mt2 +##print expected: $CN_char +##print returned: $data20 +#if $data20 != $CN_char then +# return -1 +#endi +# +#sql drop table $CN_char +#sql drop table $mt1 +#sql drop table $mt2 + +print chinese_char_in_metrics test passed + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/create_tb.sim b/tests/script/general/parser/create_tb.sim new file mode 100644 index 0000000000000000000000000000000000000000..ca57f401b9e68b0f597eef8c80862a67d8f22ddb --- /dev/null +++ b/tests/script/general/parser/create_tb.sim @@ -0,0 +1,190 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 100 +sql connect +print ======================== dnode1 start + +$dbPrefix = fi_in_db +$tbPrefix = fi_in_tb +$mtPrefix = fi_in_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print create_tb test +print =============== set up +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql create database $db +sql use $db + +# case1: case_insensitivity test +print =========== create_tb.sim case1: case_insensitivity test +sql CREATE TABLE $tb (TS TIMESTAMP, COL1 INT, COL2 BIGINT, COL3 FLOAT, COL4 DOUBLE, COL5 BINARY(10), COL6 BOOL, COL7 SMALLINT, COL8 TINYINT, COL9 NCHAR(10)); +sql show tables + +if $rows != 1 then + return -1 +endi +print data00 = $data00 +if $data00 != $tb then + return -1 +endi +sql DROP TABLE $tb +sql show tables + +if $rows != 0 then + return -1 +endi +print case_insensitivity test passed + +# case2: illegal_table_name test +print =========== create_tb.sim case2: illegal_table_name test +$illegal_tb1 = 1db +$illegal_tb2 = d@b + +sql_error create table $illegal_db1 (ts timestamp, tcol int) +sql_error create table $illegal_db2 (ts timestamp, tcol int) +print illegal_table_name test passed + +# case3: illegal_data_types +print ========== create_tb.sim case3: illegal_data_types test +$i_ts = time # illegal ts +$i_binary = binary # illegal binary +$i_bigint = long # illegal bigint +$i_smallint = short # illegal smallint +$i_tinyint = byte # illegal tinyint +$i_binary2 = varchar(20) # illegal string +$nchar = nchar # unspecified nchar length + +sql_error create table $tb (ts $i_ts , col int) +sql_error create table $tb (ts timestamp, col $i_binary ) +sql_error create table $tb (ts timestamp, col $i_bigint ) +sql_error create table $tb (ts timestamp, col $i_smallint ) +sql_error create table $tb (ts timestamp, col $i_tinyint ) +sql_error create table $tb (ts timestamp, col $i_binary2 ) +sql_error create table $tb (ts timestamp, col $nchar ) +sql create table $tb (ts timestamp, col nchar(20)) +sql show tables +if $rows != 1 then + return -1 +endi +if $data00 != $tb then + return -1 +endi +sql drop table $tb +print illegal data type test passed + +# case4: illegal_column_names +# Only frequently used key words are tested here +print ========== create_tb.sim case4: illegal_column_names +$tb_ = table +$tbs = tables +$db_ = database +$dbs = databases +$ses = session +$int = int +$bint = bigint +$binary = binary +$str = string +$tag = tag +$tags = tags +$sint = smallint +$tint = tinyint +$nchar = nchar + +sql_error create table $tb (ts timestamp, $tb_ int) +sql_error create table $tb (ts timestamp, $tbs int) +sql_error create table $tb (ts timestamp, $db_ int) +sql_error create table $tb (ts timestamp, $dbs int) +sql_error create table $tb (ts timestamp, $ses int) +sql_error create table $tb (ts timestamp, $int int) +sql_error create table $tb (ts timestamp, $bint int) +sql_error create table $tb (ts timestamp, $binary int) +sql_error create table $tb (ts timestamp, $str int) +sql_error create table $tb (ts timestamp, $tag int) +sql_error create table $tb (ts timestamp, $tags int) +sql_error create table $tb (ts timestamp, $sint int) +sql_error create table $tb (ts timestamp, $tint int) +sql_error create table $tb (ts timestamp, $nchar int) + +# too long column name +sql_error create table $tb (ts timestamp, abcde_123456789_123456789_123456789_123456789_123456789_123456789 int) +sql_error create table tx(ts timestamp, k int) tags(abcd5_123456789_123456789_123456789_123456789_123456789_123456789 int) +print illegal_column_names test passed + +# case5: chinese_char_in_table_support +print ========== create_tb.sim case5: chinese_char_in_table_support test + +$CN_char = 涛思 +$tb1 = tb1 +sql_error create table $CN_char (ts timestamp, col1 int) +#sql show tables +#if $rows != 1 then +# return -1 +#endi +#print expected: $CN_char +#print returned: $data00 +#if $data00 != $CN_char then +# return -1 +#endi +#sql drop table $CN_char + +sql_error create table $tb1 (ts timestamp, $CN_char int) +#print expected: $tb1 +#print returned: $data10 +#sql show tables +#if $rows != 1 then +# return -1 +#endi +#if $data00 != $tb1 then +# return -1 +#endi +#sql describe $tb1 +##print expected $CN_char +##print returned $data10 +#if $data10 != $CN_char then +# return -1 +#endi +#sql drop table $tb1 +print chinese_char_in_table_support test passed + +# case6: table_already_exists +print ========== create_tb.sim case6: table_already_exists +sql create table tbs (ts timestamp, col int) +sql insert into tbs values (now, 1) +sql create table tbs (ts timestamp, col bool) +#sql_error create table tb (ts timestamp, col bool) +print table_already_exists test passed + +# case7: table_name_length_exceeds_limit +print ========== create_tb.sim case7: table_name_length_exceeds_limit +$tbname32 = _32_aaaabbbbccccddddaaaabbbbcccc +$tbname64 = _64_aaaabbbbccccddddaaaabbbbccccddddaaaabbbbccccddddaaaabbbbcccc +$tbname63 = _63_aaaabbbbccccddddaaaabbbbccccddddaaaabbbbccccddddaaaabbbbccc +$tbname65 = _65_aaaabbbbccccddddaaaabbbbccccddddaaaabbbbccccddddaaaabbbbcccca1111111111111111111111111111111111aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +sql create table $tbname32 (ts timestamp, col int) +sql insert into $tbname32 values (now, 1) +sql create table $tbname64 (ts timestamp, col int) +sql insert into $tbname64 values (now, 1) +sql create table $tbname63 (ts timestamp, col int) +sql insert into $tbname63 values (now, 1) +sql_error create table $tbname65 (ts timestamp, col int) +#sql_error create table tb (ts timestamp, col bool) +print table_already_exists test passed + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/parser/create_tb_with_tag_name.sim b/tests/script/general/parser/create_tb_with_tag_name.sim new file mode 100644 index 0000000000000000000000000000000000000000..130f4097f6547e50127afd86d8d73902a5653ae2 --- /dev/null +++ b/tests/script/general/parser/create_tb_with_tag_name.sim @@ -0,0 +1,162 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2 +system sh/exec.sh -n dnode1 -s start + +sleep 100 +sql connect +print ======================== dnode1 start + +$db = testdb + +sql create database $db +sql use $db + +sql create stable st2 (ts timestamp, f1 int) tags (id int, t1 int, t2 nchar(4), t3 double) + + +sql insert into tb1 using st2 (id, t1) tags(1,2) values (now, 1) + +sql select id,t1,t2,t3 from tb1 + +if $rows != 1 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != NULL then + return -1 +endi +if $data03 != NULL then + return -1 +endi + +sql create table tb2 using st2 (t2,t3) tags ("12",22.0) + +sql select id,t1,t2,t3 from tb2; + +if $rows != 1 then + return -1 +endi + +if $data00 != NULL then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data02 != 12 then + return -1 +endi +if $data03 != 22.000000000 then + return -1 +endi + + +sql create table tb3 using st2 tags (1,2,"3",33.0); + +sql select id,t1,t2,t3 from tb3; + + +if $rows != 1 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 3 then + return -1 +endi +if $data03 != 33.000000000 then + return -1 +endi + +sql insert into tb4 using st2 tags(1,2,"33",44.0) values (now, 1); + +sql select id,t1,t2,t3 from tb4; + +if $rows != 1 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 33 then + return -1 +endi +if $data03 != 44.000000000 then + return -1 +endi + +sql_error create table tb5 using st2() tags (3,3,"3",33.0); + +sql_error create table tb6 using st2 (id,t1) tags (3,3,"3",33.0); + +sql_error create table tb7 using st2 (id,t1) tags (3); + +sql_error create table tb8 using st2 (ide) tags (3); + +sql_error create table tb9 using st2 (id); + +sql_error create table tb10 using st2 (id t1) tags (1,1); + +sql_error create table tb10 using st2 (id,,t1) tags (1,1,1); + +sql_error create table tb11 using st2 (id,t1,) tags (1,1,1); + +sql create table tb12 using st2 (t1,id) tags (2,1); + +sql select id,t1,t2,t3 from tb12; +if $rows != 1 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != NULL then + return -1 +endi +if $data03 != NULL then + return -1 +endi + +sql create table tb13 using st2 ("t1",'id') tags (2,1); + +sql select id,t1,t2,t3 from tb13; + +if $rows != 1 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != NULL then + return -1 +endi +if $data03 != NULL then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/create_tb_with_timestamp_tag.sim b/tests/script/general/parser/create_tb_with_timestamp_tag.sim new file mode 100644 index 0000000000000000000000000000000000000000..452fd2ddbf7d475a00f2fdd334e5065b6da71dc9 --- /dev/null +++ b/tests/script/general/parser/create_tb_with_timestamp_tag.sim @@ -0,0 +1,115 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2 +system sh/exec.sh -n dnode1 -s start + +sleep 100 +sql connect +print ======================== dnode1 start + +$db = testdb + +sql create database $db precision 'ns' +sql use $db + +sql create stable st1 (ts timestamp , c1 int) tags(t1 timestamp, t2 int) + +sql create table t1_0 using st1 tags(now, 0) +#nanoseconds +sql create table t1_1 using st1 tags(now + 1b, 0) +#microseconds +sql create table t1_2 using st1 tags(now + 1u, 0) +#milliseconds +sql create table t1_3 using st1 tags(now + 1a, 0) +#seconds +sql create table t1_4 using st1 tags(now + 1s, 0) +#minutes +sql create table t1_5 using st1 tags(now + 1m, 0) +#hours +sql create table t1_6 using st1 tags(now + 1h, 0) +#days +sql create table t1_7 using st1 tags(now + 1d, 0) +#weeks +sql create table t1_8 using st1 tags(now + 1w, 0) +#months(not supported) +sql_error create table t1_9 using st1 tags(now + 1n, 0) +#years(not supported) +sql_error create table t1_10 using st1 tags(now + 1y, 0) + + +sql create stable st2 (ts timestamp , c1 int) tags(t1 timestamp, t2 int) + +sql create table t2_0 using st2 tags(now, 0) +#nanoseconds +sql create table t2_1 using st2 tags(now - 1b, 0) +#microseconds +sql create table t2_2 using st2 tags(now - 1u, 0) +#milliseconds +sql create table t2_3 using st2 tags(now - 1a, 0) +#seconds +sql create table t2_4 using st2 tags(now - 1s, 0) +#minutes +sql create table t2_5 using st2 tags(now - 1m, 0) +#hours +sql create table t2_6 using st2 tags(now - 1h, 0) +#days +sql create table t2_7 using st2 tags(now - 1d, 0) +#weeks +sql create table t2_8 using st2 tags(now - 1w, 0) +#months(not supported) +sql_error create table t2_9 using st2 tags(now - 1n, 0) +#years(not supported) +sql_error create table t2_10 using st2 tags(now - 1y, 0) + +sql insert into t1_0 values (now, 0) +sql insert into t1_1 values (now, 1) +sql insert into t1_2 values (now, 2) +sql insert into t1_3 values (now, 3) +sql insert into t1_4 values (now, 4) +sql insert into t1_5 values (now, 5) +sql insert into t1_6 values (now, 6) +sql insert into t1_7 values (now, 7) +sql insert into t1_8 values (now, 8) + +sql insert into t2_0 values (now, 0) +sql insert into t2_1 values (now, 1) +sql insert into t2_2 values (now, 2) +sql insert into t2_3 values (now, 3) +sql insert into t2_4 values (now, 4) +sql insert into t2_5 values (now, 5) +sql insert into t2_6 values (now, 6) +sql insert into t2_7 values (now, 7) +sql insert into t2_8 values (now, 8) + +sql select * from st1 + +if $rows != 9 then + return -1 +endi + +sql select * from st2 + +if $rows != 9 then + return -1 +endi + +sql create stable st3 (ts timestamp , c1 int) tags (t1 timestamp, t2 timestamp, t3 timestamp, t4 timestamp, t5 timestamp, t6 timestamp, t7 timestamp, t8 timestamp, t9 timestamp) +sql create table t3 using st3 tags(now, now + 1b, now + 1u, now + 1a, now + 1s, now + 1m, now + 1h, now + 1d, now + 1w) +sql insert into t3 values (now, 1) + +sql select * from st3 +if $rows != 1 then + return -1 +endi + +sql create stable st4 (ts timestamp , c1 int) tags (t1 timestamp, t2 timestamp, t3 timestamp, t4 timestamp, t5 timestamp, t6 timestamp, t7 timestamp, t8 timestamp, t9 timestamp) +sql create table t4 using st4 tags(now, now - 1b, now - 1u, now - 1a, now - 1s, now - 1m, now - 1h, now - 1d, now - 1w) +sql insert into t4 values (now, 1) + +sql select * from st4 +if $rows != 1 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/dbtbnameValidate.sim b/tests/script/general/parser/dbtbnameValidate.sim new file mode 100644 index 0000000000000000000000000000000000000000..bc3bfefafb1a8317844e01c67b9a9146626222e6 --- /dev/null +++ b/tests/script/general/parser/dbtbnameValidate.sim @@ -0,0 +1,126 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +print ========== db name and table name check in create and drop, describe +sql create database abc keep 36500 +sql create database 'abc123' +sql create database '_ab1234' +sql create database 'ABC123' +sql create database '_ABC123' +sql_error create database 'aABb123 ' +sql_error create database ' xyz ' +sql_error create database ' XYZ ' + +sql use 'abc123' +sql use '_ab1234' +sql use 'ABC123' +sql use '_ABC123' +sql_error use 'aABb123' +sql_error use ' xyz ' +sql_error use ' XYZ ' + +sql drop database 'abc123' +sql drop database '_ab1234' +sql_error drop database 'ABC123' +sql drop database '_ABC123' +sql_error drop database 'aABb123' +sql_error drop database ' xyz ' +sql_error drop database ' XYZ ' + + +sql use abc + +sql create table abc.cc (ts timestamp, c int) +sql create table 'abc.Dd' (ts timestamp, c int) +sql create table 'abc'.ee (ts timestamp, c int) +sql create table 'abc'.'FF' (ts timestamp, c int) +sql create table abc.'gG' (ts timestamp, c int) + +sql_error create table table.'a1' (ts timestamp, c int) +sql_error create table 'table'.'b1' (ts timestamp, c int) +sql_error create table 'table'.'b1' (ts timestamp, c int) + + +sql create table mt (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int, t2 nchar(20), t3 binary(20), t4 bigint, t5 smallint, t6 double) +sql create table sub_001 using mt tags ( 1 , 'tag_nchar' , 'tag_bianry' , 4 , 5 , 6.1 ) +sql_error create table sub_002 using mt tags( 2 , tag_nchar , tag_bianry , 4 , 5 , 6.2 ) +sql insert into sub_dy_tbl using mt tags ( 3 , 'tag_nchar' , 'tag_bianry' , 4 , 5 , 6.3 ) values (now, 1, 2, 3.01, 4.02, 5, 6, true, 'binary_8', 'nchar_9') + +sql describe abc.cc +sql describe 'abc.Dd' +sql describe 'abc'.ee +sql describe 'abc'.'FF' +sql describe abc.'gG' + +sql describe cc +sql describe 'Dd' +sql describe ee +sql describe 'FF' +sql describe 'gG' + +sql describe mt +sql describe sub_001 +sql describe sub_dy_tbl + +sql describe Dd +sql describe FF +sql describe gG + +sql drop table abc.cc +sql drop table 'abc.Dd' +sql drop table 'abc'.ee +sql drop table 'abc'.'FF' +sql drop table abc.'gG' + +sql drop table sub_001 + +sql drop table sub_dy_tbl +sql drop table mt + +print ========== insert data by multi-format +sql create table abc.tk_mt (ts timestamp, a int, b binary(16), c bool, d float, e double, f nchar(16)) tags (t1 int, t2 binary(16)) + +sql create table abc.tk_subt001 using tk_mt tags(1, 'subt001') +sql insert into abc.tk_subt001 values (now-1w, 3, 'binary_3', true, 1.003, 2.003, 'nchar_3') +sql insert into abc.tk_subt001 (ts, a, c, e, f) values (now-1d, 4, false, 2.004, 'nchar_4') +sql insert into abc.tk_subt001 (ts, a, c, e, f) values (now-1h, 5, false, 2.005, 'nchar_5') +sql insert into abc.tk_subt001 (ts, b, d) values (now-1m, 'binary_6', 1.006) +sql insert into abc.tk_subt001 (ts, b, d) values (now-1s, 'binary_7', 1.007) +sql insert into abc.tk_subt001 (ts, b, d) values (now-1a, 'binary_8', 1.008) +sql select * from tk_subt001 +if $rows != 6 then + print ==== expect rows is 6, but actually is $rows + return -1 +endi + +sql insert into abc.tk_subt002 using tk_mt tags (22, 'subt002x') values (now+1s, 2001, 'binary_2001', true, 2001.001, 2001.001, 'nchar_2001') +sql insert into abc.tk_subt002 using tk_mt tags (2, 'subt002') values (now+1m, 2002, 'binary_2002', false, 2002.001, 2002.001, 'nchar_2002') +sql insert into abc.tk_subt002 using tk_mt tags (2, 'subt002') values (now+1h, 2003, 'binary_2003', false, 2003.001, 2003.001, 'nchar_2003') +sql insert into abc.tk_subt002 using tk_mt tags (2, 'subt002') values (now+1d, 2004, 'binary_2004', true, 2004.001, 2004.001, 'nchar_2004') +sql insert into abc.tk_subt002 using tk_mt tags (2, 'subt002') values (now+1w, 2005, 'binary_2005', false, 2005.001, 2005.001, 'nchar_2005') +sql select * from tk_subt002 +if $rows != 5 then + print ==== expect rows is 5, but actually is $rows + return -1 +endi + +sql insert into abc.tk_subt003 (ts, a, c, e, f) using tk_mt tags (3, 'subt003') values (now-38d, 3004, false, 3004.001, 'nchar_3004') +sql insert into abc.tk_subt003 (ts, a, c, e, f) using tk_mt tags (3, 'subt003') values (now-37d, 3005, false, 3005.001, 'nchar_3005') +sql insert into abc.tk_subt003 values (now-36d, 3006, 'binary_3006', true, 3006.001, 3006.001, 'nchar_3006') +sql insert into abc.tk_subt003 (ts, a, c, e, f) using tk_mt tags (33, 'subt003x') values (now-35d, 3007, false, 3007.001, 'nchar_3007') +sql select * from tk_subt003 +if $rows != 4 then + print ==== expect rows is 4, but actually is $rows + return -1 +endi + +print ================>td-4147 +sql_error create table tx(ts timestamp, a1234_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789 int) + + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/fill.sim b/tests/script/general/parser/fill.sim new file mode 100644 index 0000000000000000000000000000000000000000..3413a0b59652550701b7220e3c8cc1fc90785b91 --- /dev/null +++ b/tests/script/general/parser/fill.sim @@ -0,0 +1,1081 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = m_fl_db +$tbPrefix = m_fl_tb +$mtPrefix = m_fl_mt +$tbNum = 10 +$rowNum = 5 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== fill.sim +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 bool, c7 binary(10), c8 nchar(10)) tags(tgcol int) + +$i = 0 +$ts = $ts0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + sql insert into $tb values ( $ts , $x , $x , $x , $x , $x , true, 'BINARY', 'NCHAR' ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +# setup +$i = 0 +$tb = $tbPrefix . $i +$tsu = 4 * $delta +$tsu = $tsu + $ts0 + +## fill syntax test +# number of fill values exceeds number of selected columns +sql select max(c1), max(c2), max(c3), max(c4), max(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6, 6, 6, 6) +if $data11 != 6 then + return -1 +endi +if $data12 != 6 then + return -1 +endi +if $data13 != 6.00000 then + return -1 +endi +if $data14 != 6.000000000 then + return -1 +endi + +# number of fill values is smaller than number of selected columns +sql select max(c1), max(c2), max(c3) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6) +if $data11 != 6 then + return -1 +endi +if $data12 != 6 then + return -1 +endi +if $data13 != 6.00000 then + return -1 +endi + +# unspecified filling method +sql_error select max(c1), max(c2), max(c3), max(c4), max(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill (6, 6, 6, 6, 6) + +## constant fill test +# count_with_fill +print constant_fill test +print count_with_constant_fill +sql select count(c1), count(c2), count(c3), count(c4), count(c5), count(c6), count(c7), count(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6, 6, 6, 6) +if $rows != 9 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data11 != 6 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != 6 then + return -1 +endi +if $data41 != 1 then + return -1 +endi +if $data51 != 6 then + return -1 +endi +if $data61 != 1 then + return -1 +endi +if $data71 != 6 then + return -1 +endi +if $data81 != 1 then + return -1 +endi + +# avg_with_fill +print avg_with_constant_fill +sql select avg(c1), avg(c2), avg(c3), avg(c4), avg(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6) +if $rows != 9 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data11 != 6.000000000 then + return -1 +endi +if $data21 != 1.000000000 then + return -1 +endi +if $data31 != 6.000000000 then + return -1 +endi +if $data41 != 2.000000000 then + return -1 +endi +if $data51 != 6.000000000 then + return -1 +endi +if $data61 != 3.000000000 then + return -1 +endi +if $data71 != 6.000000000 then + return -1 +endi +if $data81 != 4.000000000 then + return -1 +endi + +# max_with_fill +print max_with_fill +sql select max(c1), max(c2), max(c3), max(c4), max(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != 6 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != 6 then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != 6 then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != 6 then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +# min_with_fill +print min_with_fill +sql select min(c1), min(c2), min(c3), min(c4), min(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6, 6, 6, 6) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != 6 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != 6 then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != 6 then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != 6 then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +# first_with_fill +print first_with_fill +sql select first(c1), first(c2), first(c3), first(c4), first(c5), first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6, 6, 6, 6) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != 6 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != 6 then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != 6 then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != 6 then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +# check double type values +if $data04 != 0.000000000 then + return -1 +endi +print data14 = $data14 +if $data14 != 6.000000000 then + return -1 +endi +if $data24 != 1.000000000 then + return -1 +endi +if $data34 != 6.000000000 then + return -1 +endi +if $data44 != 2.000000000 then + return -1 +endi +if $data54 != 6.000000000 then + return -1 +endi +if $data64 != 3.000000000 then + return -1 +endi + +# check float type values +print $data03 $data13 +if $data03 != 0.00000 then + return -1 +endi +if $data13 != 6.00000 then + return -1 +endi +if $data23 != 1.00000 then + return -1 +endi +if $data33 != 6.00000 then + return -1 +endi +if $data43 != 2.00000 then + return -1 +endi +if $data53 != 6.00000 then + return -1 +endi +if $data63 != 3.00000 then + return -1 +endi +if $data73 != 6.00000 then + return -1 +endi +if $data83 != 4.00000 then + return -1 +endi + + +# last_with_fill +print last_with_fill +sql select last(c1), last(c2), last(c3), last(c4), last(c5), last(c6), last(c7), last(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6, 6, 6, 6) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + print expect 0, actual:$data01 + return -1 +endi +if $data11 != 6 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != 6 then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != 6 then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != 6 then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +# fill_negative_values +sql select sum(c1), avg(c2), max(c3), min(c4), count(c5), count(c6), count(c7), count(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, -1, -1, -1, -1, -1, -1, -1, -1) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != -1 then + return -1 +endi + +# fill_char_values_to_arithmetic_fields +sql_error select sum(c1), avg(c2), max(c3), min(c4), avg(c4), count(c6), last(c7), last(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c') + +# fill_multiple_columns +sql_error select sum(c1), avg(c2), min(c3), max(c4), count(c6), first(c7), last(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 99, 99, 99, 99, 99, abc, abc) +sql select sum(c1), avg(c2), min(c3), max(c4) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 99, 99, 99, 99) +if $rows != 9 then + return -1 +endi +print data01 = $data01 +print data11 = $data11 +if $data01 != 0 then + return -1 +endi +if $data11 != 99 then + return -1 +endi + +sql select * from $tb +if $data08 != NCHAR then + print expect NCHAR, actual:$data08 + return -1 +endi + +# fill_into_nonarithmetic_fieds +sql select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 20000000, 20000000, 20000000) +#if $data11 != 20000000 then +if $data11 != 1 then + return -1 +endi + +sql select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 1, 1, 1) +sql select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 1.1, 1.1, 1.1) +sql select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 1e1, 1e1, 1e1) +sql select first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '1e', '1e1') +# fill quoted values into bool column will throw error unless the value is 'true' or 'false' Note:2018-10-24 +# fill values into binary or nchar columns will be set to NULL automatically Note:2018-10-24 +sql_error select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '1e', '1e1','1e1') +sql select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, true, true, true) +sql select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 'true', 'true','true') + + +# fill nonarithmetic values into arithmetic fields +sql_error select count(*) where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, abc); +sql_error select count(*) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 'true'); + +sql select count(*) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '1e1'); +if $rows != 9 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data11 != 10 then + return -1 +endi + +sql select count(*) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 1e1); +if $rows != 9 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data11 != 10 then + return -1 +endi + +sql select count(*) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '10'); +if $rows != 9 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data11 != 10 then + return -1 +endi + + +## linear fill +# feature currently switched off 2018/09/29 +#sql select count(c1), count(c2), count(c3), count(c4), count(c5), count(c6), count(c7), count(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(linear) + +## previous fill +print fill(prev) +sql select count(c1), count(c2), count(c3), count(c4), count(c5), count(c6), count(c7), count(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(prev) +if $rows != 9 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data11 != 1 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != 1 then + return -1 +endi +if $data41 != 1 then + return -1 +endi +if $data51 != 1 then + return -1 +endi +if $data61 != 1 then + return -1 +endi +if $data71 != 1 then + return -1 +endi +if $data81 != 1 then + return -1 +endi + +# avg_with_fill +sql select avg(c1), avg(c2), avg(c3), avg(c4), avg(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(prev) +if $rows != 9 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data11 != 0.000000000 then + return -1 +endi +if $data21 != 1.000000000 then + return -1 +endi +if $data31 != 1.000000000 then + return -1 +endi +if $data41 != 2.000000000 then + return -1 +endi +if $data51 != 2.000000000 then + return -1 +endi +if $data61 != 3.000000000 then + return -1 +endi +if $data71 != 3.000000000 then + return -1 +endi +if $data81 != 4.000000000 then + return -1 +endi + +# max_with_fill +sql select max(c1), max(c2), max(c3), max(c4), max(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(prev) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != 0 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != 1 then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != 2 then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != 3 then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +# min_with_fill +sql select min(c1), min(c2), min(c3), min(c4), min(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(prev) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != 0 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != 1 then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != 2 then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != 3 then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +# first_with_fill +sql select first(c1), first(c2), first(c3), first(c4), first(c5), first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(prev) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != 0 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != 1 then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != 2 then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != 3 then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +# last_with_fill +sql select last(c1), last(c2), last(c3), last(c4), last(c5), last(c6), last(c7), last(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(prev) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != 0 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != 1 then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != 2 then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != 3 then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +## NULL fill +print fill(value, NULL) +# count_with_fill +sql select count(c1), count(c2), count(c3), count(c4), count(c5), count(c6), count(c7), count(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill( NULL) +print select count(c1), count(c2), count(c3), count(c4), count(c5), count(c6), count(c7), count(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill( NULL) +sql select count(c1), count(c2), count(c3), count(c4), count(c5), count(c6), count(c7), count(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, NULL) +if $rows != 9 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data11 != NULL then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != NULL then + return -1 +endi +if $data41 != 1 then + return -1 +endi +if $data51 != NULL then + return -1 +endi +if $data61 != 1 then + return -1 +endi +if $data71 != NULL then + return -1 +endi +if $data81 != 1 then + return -1 +endi +sql select count(c1), count(c2), count(c3), count(c4), count(c5), count(c6), count(c7), count(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(none) +if $rows != 5 then + return -1 +endi + +# avg_with_fill +sql select avg(c1), avg(c2), avg(c3), avg(c4), avg(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, NULL) +if $rows != 9 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data11 != NULL then + return -1 +endi +if $data21 != 1.000000000 then + return -1 +endi +if $data31 != NULL then + return -1 +endi +if $data41 != 2.000000000 then + return -1 +endi +if $data51 != NULL then + return -1 +endi +if $data61 != 3.000000000 then + return -1 +endi +if $data71 != NULL then + return -1 +endi +if $data81 != 4.000000000 then + return -1 +endi + +# max_with_fill +sql select max(c1), max(c2), max(c3), max(c4), max(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, NULL) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != NULL then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != NULL then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != NULL then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != NULL then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +# min_with_fill +sql select min(c1), min(c2), min(c3), min(c4), min(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, NULL) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != NULL then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != NULL then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != NULL then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != NULL then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +# first_with_fill +sql select first(c1), first(c2), first(c3), first(c4), first(c5), first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, NULL) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != NULL then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != NULL then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != NULL then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != NULL then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +# last_with_fill +sql select last(c1), last(c2), last(c3), last(c4), last(c5), last(c6), last(c7), last(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, NULL) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != NULL then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != NULL then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != NULL then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != NULL then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +# desc fill query +print desc fill query +sql select count(*) from m_fl_tb0 where ts>='2018-9-17 9:0:0' and ts<='2018-9-17 9:11:00' interval(1m) fill(value,10) order by ts desc; +if $rows != 12 then + return -1 +endi + +print =====================> aggregation + arithmetic + fill, need to add cases TODO +#sql select avg(cpu_taosd) - first(cpu_taosd) from dn1 where ts<'2020-11-13 11:00:00' and ts>'2020-11-13 10:50:00' interval(10s) fill(value, 99) +#sql select count(*), first(k), avg(k), avg(k)-first(k) from tm0 where ts>'2020-1-1 1:1:1' and ts<'2020-1-1 1:02:59' interval(10s) fill(value, 99); +#sql select count(*), first(k), avg(k), avg(k)-first(k) from tm0 where ts>'2020-1-1 1:1:1' and ts<'2020-1-1 1:02:59' interval(10s) fill(NULL); + +print =====================> td-2060 +sql create table m1 (ts timestamp, k int ) tags(a int); +sql create table if not exists tm0 using m1 tags(1); +sql insert into tm0 values('2020-1-1 1:1:1', 1); +sql insert into tm0 values('2020-1-1 1:1:2', 2); +sql insert into tm0 values('2020-1-1 1:1:3', 3); +sql insert into tm0 values('2020-1-1 1:2:4', 4); +sql insert into tm0 values('2020-1-1 1:2:5', 5); +sql insert into tm0 values('2020-1-1 1:2:6', 6); +sql insert into tm0 values('2020-1-1 1:3:7', 7); +sql insert into tm0 values('2020-1-1 1:3:8', 8); +sql insert into tm0 values('2020-1-1 1:3:9', 9); +sql insert into tm0 values('2020-1-1 1:4:10', 10); + +sql select max(k)-min(k),last(k)-first(k),0-spread(k) from tm0 where ts>='2020-1-1 1:1:1' and ts<='2020-1-1 1:2:15' interval(10s) fill(value, 99,91,90,89,88,87,86,85); +if $rows != 8 then + return -1 +endi + +if $data00 != @20-01-01 01:01:00.000@ then + return -1 +endi + +if $data01 != 2.000000000 then + return -1 +endi + +if $data02 != 2.000000000 then + return -1 +endi + +if $data03 != -2.000000000 then + return -1 +endi + +if $data10 != @20-01-01 01:01:10.000@ then + return -1 +endi + +if $data11 != 99.000000000 then + return -1 +endi + +if $data12 != 91.000000000 then + return -1 +endi + +if $data13 != 90.000000000 then + return -1 +endi + +if $data60 != @20-01-01 01:02:00.000@ then + return -1 +endi + +if $data61 != 2.000000000 then + return -1 +endi + +if $data62 != 2.000000000 then + return -1 +endi + +if $data63 != -2.000000000 then + return -1 +endi + +if $data70 != @20-01-01 01:02:10.000@ then + return -1 +endi + +if $data71 != 99.000000000 then + return -1 +endi + +if $data72 != 91.000000000 then + return -1 +endi + +if $data73 != 90.000000000 then + return -1 +endi + +sql select first(k)-avg(k),0-spread(k) from tm0 where ts>='2020-1-1 1:1:1' and ts<='2020-1-1 1:2:15' interval(10s) fill(NULL); +if $rows != 8 then + return -1 +endi + +if $data00 != @20-01-01 01:01:00.000@ then + return -1 +endi + +if $data01 != -1.000000000 then + return -1 +endi + +if $data02 != -2.000000000 then + return -1 +endi + +if $data10 != @20-01-01 01:01:10.000@ then + return -1 +endi + +if $data11 != NULL then + return -1 +endi + +if $data12 != NULL then + return -1 +endi + +sql select max(k)-min(k),last(k)-first(k),0-spread(k) from tm0 where ts>='2020-1-1 1:1:1' and ts<='2020-1-1 4:2:15' interval(500a) fill(value, 99,91,90,89,88,87,86,85) order by ts asc; +if $rows != 21749 then + return -1 +endi + +sql select max(k)-min(k),last(k)-first(k),0-spread(k),count(1) from m1 where ts>='2020-1-1 1:1:1' and ts<='2020-1-1 1:2:15' interval(10s) fill(value, 99,91,90,89,88,87,86,85) order by ts asc; +if $rows != 8 then + return -1 +endi + +if $data00 != @20-01-01 01:01:00.000@ then + return -1 +endi + +if $data01 != 2.000000000 then + return -1 +endi + +if $data02 != 2.000000000 then + return -1 +endi + +if $data03 != -2.000000000 then + return -1 +endi + +if $data04 != 3 then + return -1 +endi + +if $data10 != @20-01-01 01:01:10.000@ then + return -1 +endi + +if $data11 != 99.000000000 then + return -1 +endi + +if $data12 != 91.000000000 then + return -1 +endi + +if $data13 != 90.000000000 then + return -1 +endi + +if $data14 != 89 then + return -1 +endi + +print ==================> td-2115 +sql select count(*), min(c3)-max(c3) from m_fl_mt0 group by tgcol +if $rows != 10 then + return -1 +endi + +if $data00 != 5 then + return -1 +endi + +if $data01 != -4.000000000 then + return -1 +endi + +if $data02 != 0 then + return -1 +endi + +if $data12 != 1 then + return -1 +endi + +print =====================>td-1442, td-2190 , no time range for fill option +sql_error select count(*) from m_fl_tb0 interval(1s) fill(prev); + +sql_error select min(c3) from m_fl_mt0 interval(10a) fill(value, 20) +sql_error select min(c3) from m_fl_mt0 interval(10s) fill(value, 20) +sql_error select min(c3) from m_fl_mt0 interval(10m) fill(value, 20) +sql_error select min(c3) from m_fl_mt0 interval(10h) fill(value, 20) +sql_error select min(c3) from m_fl_mt0 interval(10d) fill(value, 20) +sql_error select min(c3) from m_fl_mt0 interval(10w) fill(value, 20) +sql_error select max(c3) from m_fl_mt0 interval(1n) fill(prev) +sql_error select min(c3) from m_fl_mt0 interval(1y) fill(value, 20) + +sql create table nexttb1 (ts timestamp, f1 int); +sql insert into nexttb1 values ('2021-08-08 1:1:1', NULL); +sql insert into nexttb1 values ('2021-08-08 1:1:5', 3); + +sql select last(*) from nexttb1 where ts >= '2021-08-08 1:1:1' and ts < '2021-08-08 1:1:10' interval(1s) fill(next); +if $rows != 9 then + return -1 +endi +if $data00 != @21-08-08 01:01:01.000@ then + return -1 +endi +if $data01 != @21-08-08 01:01:01.000@ then + return -1 +endi +if $data02 != 3 then + return -1 +endi + + + + +print =============== clear +#sql drop database $db +#sql show databases +#if $rows != 0 then +# return -1 +#endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/fill_stb.sim b/tests/script/general/parser/fill_stb.sim new file mode 100644 index 0000000000000000000000000000000000000000..ba8ddbdf6ac6e9035398b3ac7c26861c02771e99 --- /dev/null +++ b/tests/script/general/parser/fill_stb.sim @@ -0,0 +1,440 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = fl1_db +$tbPrefix = fl1_tb +$stbPrefix = fl1_stb +$tbNum = 10 +$rowNum = 10 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== fill.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int, t2 nchar(20), t3 binary(20), t4 bigint, t5 bool, t6 double) + +$i = 0 +$ts = $ts0 +$halfNum = $tbNum / 2 +while $i < $halfNum + $i1 = $i + $halfNum + $tb = $tbPrefix . $i + $tb1 = $tbPrefix . $i1 + $tgstr = 'tb . $i + $tgstr = $tgstr . ' + $tgstr1 = 'tb . $i1 + $tgstr1 = $tgstr1 . ' + sql create table $tb using $stb tags( $i , $tgstr , $tgstr , $i , $i , $i ) + sql create table $tb1 using $stb tags( $i1 , $tgstr1 , $tgstr1 , $i , $i , $i ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) + sql insert into $tb1 values ( $ts , $c , NULL , $c , NULL , $c , $c , true, $binary , $nchar ) + $x = $x + 1 + endw + + $i = $i + 1 +endw +print ====== tables created + +# setup +$i = 0 +$tb = $tbPrefix . $i +$tsu = $rowNum * $delta +$tsu = $tsu - $delta +$tsu = $tsu + $ts0 + +#### fill test cases for stables + +# NULL values in each group +#sql select count(*) from $stb where ts >= '2018-09-16 00:00:00.000' and ts <= $tsu interval(1d) fill(prev) group by t1 +#$val = $tbNum * 2 +#if rows != $val then +# return -1 +#endi +#if $data00 != @18-09-16 00:00:00.000@ then +# return -1 +#endi +#if $data01 != NULL then +# return -1 +#endi +#if $data02 != NULL then +# return -1 +#endi +#if $data11 != $rowNum then +# return -1 +#endi +#if $data12 != 0 then +# return -1 +#endi +#if $data20 != @18-09-16 00:00:00.000@ then +# return -1 +#endi +#if $data21 != NULL then +# return -1 +#endi +#if $data22 != NULL then +# return -1 +#endi + +# number of fill values exceeds number of selected columns +sql select max(c1), max(c2), max(c3), max(c4), max(c5) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, -1, -2, -3, -4, -5, -6, -7, -8) +$val = $rowNum * 2 +$val = $val - 1 +if $rows != $val then + return -1 +endi +if $data11 != -1 then + return -1 +endi +if $data12 != -2 then + return -1 +endi +if $data13 != -3.00000 then + return -1 +endi +if $data14 != -4.000000000 then + return -1 +endi +if $data15 != -5 then + return -1 +endi +if $data31 != -1 then + return -1 +endi +if $data52 != -2 then + return -1 +endi +if $data73 != -3.00000 then + return -1 +endi +if $data74 != -4.000000000 then + return -1 +endi + +## fill(value) + group by +sql select max(c1), max(c2), max(c3), max(c4), max(c5) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, -1, -2, -3, -4, -5, -6, -7, -8) group by t1 +$val = $rowNum * 2 +print $rowNum, $val + +$val = $val - 1 +$val = $val * $tbNum +print ==================== $val + +if $rows != 190 then + print expect 190, actual:$rows + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data11 != -1 then + return -1 +endi +#if $data16 != 0 then +# return -1 +#endi + +# number of fill values is smaller than number of selected columns +sql select max(c1), max(c2), max(c3) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6) +if $data11 != 6 then + return -1 +endi +if $data12 != 6 then + return -1 +endi +if $data13 != 6.00000 then + return -1 +endi + +# unspecified filling method +sql_error select max(c1), max(c2), max(c3), max(c4), max(c5) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill (6, 6, 6, 6, 6) + +# fill_char_values_to_arithmetic_fields +sql_error select sum(c1), avg(c2), max(c3), min(c4), avg(c4), count(c6), last(c7), last(c8) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c') + +# fill_multiple_columns +sql_error select sum(c1), avg(c2), min(c3), max(c4), count(c6), first(c7), last(c8) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 99, 99, 99, 99, 99, abc, abc) +sql select sum(c1), avg(c2), min(c3), max(c4) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 99, 99, 99, 99) +$val = $rowNum * 2 +$val = $val - 1 +if $rows != $val then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != 99 then + return -1 +endi + +sql select * from $stb +#print data08 = $data08 +if $data09 != nchar0 then + return -1 +endi +sql select max(c4) from $stb where t1 > 4 and ts >= $ts0 and ts <= $tsu interval(5m) fill(value, -1) group by t1 +if $rows != 0 then + return -1 +endi +sql select min(c1), max(c4) from $stb where t1 > 4 and ts >= $ts0 and ts <= $tsu interval(5m) fill(value, -1) +$val = $rowNum * 2 +$val = $val - 1 +if $rows != $val then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != -1.000000000 then + return -1 +endi +if $data11 != -1 then + return -1 +endi +if $data12 != -1.000000000 then + return -1 +endi + +# fill_into_nonarithmetic_fieds +sql select first(c7), first(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 20000000, 20000000, 20000000) +#if $data11 != 20000000 then +if $data11 != 1 then + return -1 +endi + +sql select first(c7), first(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 1, 1, 1) +sql select first(c7), first(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 1.1, 1.1, 1.1) +sql select first(c7), first(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 1e1, 1e1, 1e1) +sql select first(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '1e', '1e1') +# fill quoted values into bool column will throw error unless the value is 'true' or 'false' Note:2018-10-24 +# fill values into binary or nchar columns will be set to NULL automatically Note:2018-10-24 +sql_error select first(c7), first(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '1e', '1e1','1e1') +sql select first(c7), first(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, true, true, true) +sql select first(c7), first(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 'true', 'true','true') + + +# fill nonarithmetic values into arithmetic fields +sql_error select count(*) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, abc); +sql_error select count(*) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 'true'); + +sql select count(*) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '2e1'); +$val = $rowNum * 2 +$val = $val - 1 +if $rows != $val then + return -1 +endi +if $data01 != $rowNum then + return -1 +endi +if $data11 != 20 then + return -1 +endi + +sql select count(*) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 2e1); +if $rows != $val then + return -1 +endi +if $data01 != $rowNum then + return -1 +endi +if $data11 != 20 then + return -1 +endi + +sql select count(*) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '20'); +if $rows != $val then + return -1 +endi +if $data01 != $rowNum then + return -1 +endi +if $data11 != 20 then + return -1 +endi + +## linear fill +sql select max(c1), min(c2), avg(c3), sum(c4), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(linear) group by t1 +$val = $rowNum * 2 +$val = $val - 1 +$val = $val * $tbNum +if $rows != $val then + return -1 +endi +if $data08 != 0 then + return -1 +endi +if $data15 != NULL then + return -1 +endi +if $data16 != NULL then + return -1 +endi +if $data17 != NULL then + return -1 +endi +if $data18 != 0 then + return -1 +endi + +## [TBASE-365] +sql select max(c1), min(c2), avg(c3), sum(c4), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 4 interval(5m) fill(linear) group by t1 +if $rows != 95 then + return -1 +endi +#if $data02 != NULL then +# return -1 +#endi +#if $data04 != NULL then +# return -1 +#endi +if $data06 != binary0 then + return -1 +endi +if $data07 != nchar0 then + return -1 +endi +if $data12 != NULL then + return -1 +endi +if $data14 != NULL then + return -1 +endi +if $data16 != NULL then + return -1 +endi +if $data17 != NULL then + return -1 +endi +if $data08 != 5 then + return -1 +endi +if $data18 != 5 then + return -1 +endi + +sql select max(c1), min(c2), sum(c3), avg(c4), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(linear) +$val = $rowNum * 2 +$val = $val - 1 +if $rows != $val then + return -1 +endi +if $data07 != nchar0 then + return -1 +endi +if $data17 != NULL then + return -1 +endi + +sql select max(c1), min(c2), sum(c3), avg(c4), first(c9), last(c8), first(c9) from $stb where ts >= '2018-09-16 00:00:00.000' and ts <= '2018-09-18 00:00:00.000' interval(1d) fill(linear) +if $rows != 3 then + return -1 +endi + +## previous fill +print fill(prev) +sql select max(c1), min(c2), avg(c3), sum(c4), count(c5), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 4 interval(5m) fill(prev) group by t1 limit 5 +if $rows != 25 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != NULL then + return -1 +endi +if $data04 != NULL then + return -1 +endi +if $data09 != 5 then + return -1 +endi +if $data12 != NULL then + return -1 +endi +if $data19 != 5 then + return -1 +endi +if $data18 != nchar0 then + return -1 +endi +if $data59 != 6 then + return -1 +endi +if $data69 != 6 then + return -1 +endi + +## NULL fill +print fill(NULL) +sql select max(c1), min(c2), avg(c3), sum(c4), count(c5), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 4 interval(5m) fill(value, NULL) group by t1 limit 5 +if $rows != 25 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != NULL then + return -1 +endi +if $data04 != NULL then + return -1 +endi +if $data06 != 1 then + return -1 +endi +if $data09 != 5 then + return -1 +endi +if $data11 != NULL then + return -1 +endi +if $data12 != NULL then + return -1 +endi +if $data19 != 5 then + return -1 +endi +if $data18 != NULL then + return -1 +endi +if $data59 != 6 then + return -1 +endi +if $data69 != 6 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/parser/fill_us.sim b/tests/script/general/parser/fill_us.sim new file mode 100644 index 0000000000000000000000000000000000000000..762413d0a1e975c778ccd3d31e54e0f2d347cef2 --- /dev/null +++ b/tests/script/general/parser/fill_us.sim @@ -0,0 +1,1037 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = m_fl_db +$tbPrefix = m_fl_tb +$mtPrefix = m_fl_mt +$tbNum = 10 +$rowNum = 5 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000000 # 2018-09-17 09:00:00.000000 +$delta = 600000000 +print ========== fill_us.sim +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db precision 'us' +sql use $db +sql create table $mt (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 bool, c7 binary(10), c8 nchar(10)) tags(tgcol int) + +$i = 0 +$ts = $ts0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + sql insert into $tb values ( $ts , $x , $x , $x , $x , $x , true, 'BINARY', 'NCHAR' ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +# setup +$i = 0 +$tb = $tbPrefix . $i +$tsu = 4 * $delta +$tsu = $tsu + $ts0 + +## fill syntax test +# number of fill values exceeds number of selected columns +print select max(c1), max(c2), max(c3), max(c4), max(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6, 6, 6, 6) +sql select max(c1), max(c2), max(c3), max(c4), max(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6, 6, 6, 6) +if $data11 != 6 then + return -1 +endi +if $data12 != 6 then + return -1 +endi +if $data13 != 6.00000 then + return -1 +endi +if $data14 != 6.000000000 then + return -1 +endi + +# number of fill values is smaller than number of selected columns +print sql select max(c1), max(c2), max(c3) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6) +sql select max(c1), max(c2), max(c3) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6) +if $data11 != 6 then + return -1 +endi +if $data12 != 6 then + return -1 +endi +if $data13 != 6.00000 then + return -1 +endi + +# unspecified filling method +sql_error select max(c1), max(c2), max(c3), max(c4), max(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill (6, 6, 6, 6, 6) + +## constant fill test +# count_with_fill +print constant_fill test +print count_with_constant_fill +print sql select count(c1), count(c2), count(c3), count(c4), count(c5), count(c6), count(c7), count(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6, 6, 6, 6) +sql select count(c1), count(c2), count(c3), count(c4), count(c5), count(c6), count(c7), count(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6, 6, 6, 6) +if $rows != 9 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data11 != 6 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != 6 then + return -1 +endi +if $data41 != 1 then + return -1 +endi +if $data51 != 6 then + return -1 +endi +if $data61 != 1 then + return -1 +endi +if $data71 != 6 then + return -1 +endi +if $data81 != 1 then + return -1 +endi + +# avg_with_fill +print avg_witt_constant_fill +sql select avg(c1), avg(c2), avg(c3), avg(c4), avg(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6) +if $rows != 9 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data11 != 6.000000000 then + return -1 +endi +if $data21 != 1.000000000 then + return -1 +endi +if $data31 != 6.000000000 then + return -1 +endi +if $data41 != 2.000000000 then + return -1 +endi +if $data51 != 6.000000000 then + return -1 +endi +if $data61 != 3.000000000 then + return -1 +endi +if $data71 != 6.000000000 then + return -1 +endi +if $data81 != 4.000000000 then + return -1 +endi + +# max_with_fill +print max_with_fill +sql select max(c1), max(c2), max(c3), max(c4), max(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != 6 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != 6 then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != 6 then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != 6 then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +# min_with_fill +print min_with_fill +sql select min(c1), min(c2), min(c3), min(c4), min(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6, 6, 6, 6) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != 6 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != 6 then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != 6 then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != 6 then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +# first_with_fill +print first_with_fill +sql select first(c1), first(c2), first(c3), first(c4), first(c5), first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6, 6, 6, 6) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != 6 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != 6 then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != 6 then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != 6 then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +# check double type values +if $data04 != 0.000000000 then + return -1 +endi +print data14 = $data14 +if $data14 != 6.000000000 then + return -1 +endi +if $data24 != 1.000000000 then + return -1 +endi +if $data34 != 6.000000000 then + return -1 +endi +if $data44 != 2.000000000 then + return -1 +endi +if $data54 != 6.000000000 then + return -1 +endi +if $data64 != 3.000000000 then + return -1 +endi + +# check float type values +print $data03 $data13 +if $data03 != 0.00000 then + return -1 +endi +if $data13 != 6.00000 then + return -1 +endi +if $data23 != 1.00000 then + return -1 +endi +if $data33 != 6.00000 then + return -1 +endi +if $data43 != 2.00000 then + return -1 +endi +if $data53 != 6.00000 then + return -1 +endi +if $data63 != 3.00000 then + return -1 +endi +if $data73 != 6.00000 then + return -1 +endi +if $data83 != 4.00000 then + return -1 +endi + + +# last_with_fill +print last_with_fill +sql select last(c1), last(c2), last(c3), last(c4), last(c5), last(c6), last(c7), last(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6, 6, 6, 6) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != 6 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != 6 then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != 6 then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != 6 then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +# fill_negative_values +sql select sum(c1), avg(c2), max(c3), min(c4), count(c5), count(c6), count(c7), count(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, -1, -1, -1, -1, -1, -1, -1, -1) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != -1 then + return -1 +endi + +# fill_char_values_to_arithmetic_fields +sql_error select sum(c1), avg(c2), max(c3), min(c4), avg(c4), count(c6), last(c7), last(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c') + +# fill_multiple_columns +sql_error select sum(c1), avg(c2), min(c3), max(c4), count(c6), first(c7), last(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 99, 99, 99, 99, 99, abc, abc) +sql select sum(c1), avg(c2), min(c3), max(c4) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 99, 99, 99, 99) +if $rows != 9 then + return -1 +endi +print data01 = $data01 +print data11 = $data11 +if $data01 != 0 then + return -1 +endi +if $data11 != 99 then + return -1 +endi + +sql select * from $tb +#print data08 = $data08 +if $data08 != NCHAR then + return -1 +endi +#return -1 + + +# fill_into_nonarithmetic_fieds +sql select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 20000000, 20000000, 20000000) +#if $data11 != 20000000 then +if $data11 != 1 then + return -1 +endi + +sql select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 1, 1, 1) +sql select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 1.1, 1.1, 1.1) +sql select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 1e1, 1e1, 1e1) +sql select first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '1e', '1e1') +# fill quoted values into bool column will throw error unless the value is 'true' or 'false' Note:2018-10-24 +# fill values into binary or nchar columns will be set to null automatically Note:2018-10-24 +sql_error select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '1e', '1e1','1e1') +sql select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, true, true, true) +sql select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 'true', 'true','true') + + +# fill nonarithmetic values into arithmetic fields +sql_error select count(*) where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, abc); +sql_error select count(*) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 'true'); + +sql select count(*) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '1e1'); +if $rows != 9 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data11 != 10 then + return -1 +endi + +sql select count(*) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 1e1); +if $rows != 9 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data11 != 10 then + return -1 +endi + +sql select count(*) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '10'); +if $rows != 9 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data11 != 10 then + return -1 +endi + + +## linear fill +# feature currently switched off 2018/09/29 +#sql select count(c1), count(c2), count(c3), count(c4), count(c5), count(c6), count(c7), count(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(linear) + +## previous fill +print fill(prev) +sql select count(c1), count(c2), count(c3), count(c4), count(c5), count(c6), count(c7), count(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(prev) +if $rows != 9 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data11 != 1 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != 1 then + return -1 +endi +if $data41 != 1 then + return -1 +endi +if $data51 != 1 then + return -1 +endi +if $data61 != 1 then + return -1 +endi +if $data71 != 1 then + return -1 +endi +if $data81 != 1 then + return -1 +endi + +# avg_with_fill +sql select avg(c1), avg(c2), avg(c3), avg(c4), avg(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(prev) +if $rows != 9 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data11 != 0.000000000 then + return -1 +endi +if $data21 != 1.000000000 then + return -1 +endi +if $data31 != 1.000000000 then + return -1 +endi +if $data41 != 2.000000000 then + return -1 +endi +if $data51 != 2.000000000 then + return -1 +endi +if $data61 != 3.000000000 then + return -1 +endi +if $data71 != 3.000000000 then + return -1 +endi +if $data81 != 4.000000000 then + return -1 +endi + +# max_with_fill +sql select max(c1), max(c2), max(c3), max(c4), max(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(prev) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != 0 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != 1 then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != 2 then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != 3 then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +# min_with_fill +sql select min(c1), min(c2), min(c3), min(c4), min(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(prev) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != 0 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != 1 then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != 2 then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != 3 then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +# first_with_fill +sql select first(c1), first(c2), first(c3), first(c4), first(c5), first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(prev) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != 0 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != 1 then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != 2 then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != 3 then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +# last_with_fill +sql select last(c1), last(c2), last(c3), last(c4), last(c5), last(c6), last(c7), last(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(prev) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != 0 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != 1 then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != 2 then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != 3 then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +## NULL fill +print fill(value, NULL) +# count_with_fill +sql select count(c1), count(c2), count(c3), count(c4), count(c5), count(c6), count(c7), count(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill( NULL) +print select count(c1), count(c2), count(c3), count(c4), count(c5), count(c6), count(c7), count(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill( NULL) +sql select count(c1), count(c2), count(c3), count(c4), count(c5), count(c6), count(c7), count(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, NULL) +if $rows != 9 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data11 != NULL then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != NULL then + return -1 +endi +if $data41 != 1 then + return -1 +endi +if $data51 != NULL then + return -1 +endi +if $data61 != 1 then + return -1 +endi +if $data71 != NULL then + return -1 +endi +if $data81 != 1 then + return -1 +endi +sql select count(c1), count(c2), count(c3), count(c4), count(c5), count(c6), count(c7), count(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(none) +if $rows != 5 then + return -1 +endi + +# avg_with_fill +sql select avg(c1), avg(c2), avg(c3), avg(c4), avg(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, NULL) +if $rows != 9 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data11 != NULL then + return -1 +endi +if $data21 != 1.000000000 then + return -1 +endi +if $data31 != NULL then + return -1 +endi +if $data41 != 2.000000000 then + return -1 +endi +if $data51 != NULL then + return -1 +endi +if $data61 != 3.000000000 then + return -1 +endi +if $data71 != NULL then + return -1 +endi +if $data81 != 4.000000000 then + return -1 +endi + +# max_with_fill +sql select max(c1), max(c2), max(c3), max(c4), max(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, NULL) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != NULL then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != NULL then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != NULL then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != NULL then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +# min_with_fill +sql select min(c1), min(c2), min(c3), min(c4), min(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, NULL) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != NULL then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != NULL then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != NULL then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != NULL then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +# first_with_fill +sql select first(c1), first(c2), first(c3), first(c4), first(c5), first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, NULL) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != NULL then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != NULL then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != NULL then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != NULL then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +# last_with_fill +sql select last(c1), last(c2), last(c3), last(c4), last(c5), last(c6), last(c7), last(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, NULL) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != NULL then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != NULL then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != NULL then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != NULL then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +# desc fill query +print desc fill query +sql select count(*) from m_fl_tb0 where ts>='2018-9-17 9:0:0' and ts<='2018-9-17 9:11:00' interval(1m) fill(value,10) order by ts desc; +if $rows != 12 then + return -1 +endi + + +#print =============== clear +#sql drop database $db +#sql show databases +#if $rows != 0 then +# return -1 +#endi + +######################### us ########################## +$start = 1537146000000000 # 2018-09-17 09:00:00.000000 +$delta = 600000000 + +sql create table us_st (ts timestamp, c1 int, c2 double) tags(tgcol int) +sql create table us_t1 using us_st tags( 1 ) + +sql insert into us_t1 values ('2018-09-17 09:00:00.000001', 1 , 1) +sql insert into us_t1 values ('2018-09-17 09:00:00.000002', 2 , 2) +sql insert into us_t1 values ('2018-09-17 09:00:00.000003', 3 , 3) +sql insert into us_t1 values ('2018-09-17 09:00:00.000004', 4 , 4) +sql insert into us_t1 values ('2018-09-17 09:00:00.000005', 5 , 5) +sql insert into us_t1 values ('2018-09-17 09:00:00.000006', 6 , 6) +sql insert into us_t1 values ('2018-09-17 09:00:00.000007', 7 , 7) +sql insert into us_t1 values ('2018-09-17 09:00:00.000008', 8 , 8) +sql insert into us_t1 values ('2018-09-17 09:00:00.000009', 9 , 9) + +sql insert into us_t1 values ('2018-09-17 09:00:00.000015', 15 , 15) +sql insert into us_t1 values ('2018-09-17 09:00:00.000016', 16 , 16) +sql insert into us_t1 values ('2018-09-17 09:00:00.000017', 17 , 17) + +sql insert into us_t1 values ('2018-09-17 09:00:00.000021', 21 , 21) +sql insert into us_t1 values ('2018-09-17 09:00:00.000022', 22 , 22) +sql insert into us_t1 values ('2018-09-17 09:00:00.000023', 23 , 23) + +sql insert into us_t1 values ('2018-09-17 09:00:00.000027', 27 , 27) +sql insert into us_t1 values ('2018-09-17 09:00:00.000028', 28 , 28) +sql insert into us_t1 values ('2018-09-17 09:00:00.000029', 29 , 29) + +print sql select avg(c1), avg(c2) from us_t1 where ts >= '2018-09-17 09:00:00.000002' and ts <= '2018-09-17 09:00:00.000021' interval(3u) fill(value, 999, 999) +sql select avg(c1), avg(c2) from us_t1 where ts >= '2018-09-17 09:00:00.000002' and ts <= '2018-09-17 09:00:00.000021' interval(3u) fill(value, 999, 999) +if $rows != 8 then + return -1 +endi +if $data01 != 2.000000000 then + return -1 +endi +if $data11 != 4.000000000 then + return -1 +endi +if $data21 != 7.000000000 then + return -1 +endi +if $data31 != 9.000000000 then + return -1 +endi +if $data41 != 999.000000000 then + return -1 +endi +if $data51 != 16.000000000 then + return -1 +endi +if $data61 != 999.000000000 then + return -1 +endi +if $data71 != 21.000000000 then + return -1 +endi + +sql select avg(c1), avg(c2) from us_t1 where ts >= '2018-09-17 09:00:00.000002' and ts <= '2018-09-17 09:00:00.000021' interval(3u) fill(none) +if $rows != 6 then + return -1 +endi +if $data01 != 2.000000000 then + return -1 +endi +if $data11 != 4.000000000 then + return -1 +endi +if $data21 != 7.000000000 then + return -1 +endi +if $data31 != 9.000000000 then + return -1 +endi +if $data41 != 16.000000000 then + return -1 +endi +if $data51 != 21.000000000 then + return -1 +endi + +sql select avg(c1), avg(c2) from us_t1 where ts >= '2018-09-17 09:00:00.000002' and ts <= '2018-09-17 09:00:00.000021' interval(3u) fill(null) +if $rows != 8 then + return -1 +endi +if $data01 != 2.000000000 then + return -1 +endi +if $data11 != 4.000000000 then + return -1 +endi +if $data21 != 7.000000000 then + return -1 +endi +if $data31 != 9.000000000 then + return -1 +endi +if $data41 != NULL then + print ===== $data41 + return -1 +endi +if $data51 != 16.000000000 then + return -1 +endi +if $data61 != NULL then + print ===== $data61 + return -1 +endi +if $data71 != 21.000000000 then + return -1 +endi + + + +sql select avg(c1), avg(c2) from us_t1 where ts >= '2018-09-17 09:00:00.000002' and ts <= '2018-09-17 09:00:00.000021' interval(3u) fill(prev) +if $rows != 8 then + return -1 +endi +if $data01 != 2.000000000 then + return -1 +endi +if $data11 != 4.000000000 then + return -1 +endi +if $data21 != 7.000000000 then + return -1 +endi +if $data31 != 9.000000000 then + return -1 +endi +if $data41 != 9.000000000 then + return -1 +endi +if $data51 != 16.000000000 then + return -1 +endi +if $data61 != 16.000000000 then + return -1 +endi +if $data71 != 21.000000000 then + return -1 +endi + +sql select avg(c1), avg(c2) from us_t1 where ts >= '2018-09-17 09:00:00.000002' and ts <= '2018-09-17 09:00:00.000021' interval(3u) fill(linear) +if $rows != 8 then + return -1 +endi +if $data01 != 2.000000000 then + return -1 +endi +if $data11 != 4.000000000 then + return -1 +endi +if $data21 != 7.000000000 then + return -1 +endi +if $data31 != 9.000000000 then + return -1 +endi +if $data41 != 12.500000000 then + return -1 +endi +if $data51 != 16.000000000 then + return -1 +endi +if $data61 != 18.500000000 then + return -1 +endi +if $data71 != 21.000000000 then + return -1 +endi + +print ======== fill_us.sim run end...... ================ \ No newline at end of file diff --git a/tests/script/general/parser/first_last.sim b/tests/script/general/parser/first_last.sim new file mode 100644 index 0000000000000000000000000000000000000000..09047b4528a68219f27fc3b2e913a62fd567cd42 --- /dev/null +++ b/tests/script/general/parser/first_last.sim @@ -0,0 +1,127 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxTablespervnode -v 4 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = first_db +$tbPrefix = first_tb +$stbPrefix = first_stb +$tbNum = 10 +$rowNum = 1000 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 60000 +print ========== first_last.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: + +sql create database $db maxrows 400 cache 1 + +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int) + +$i = 0 +$ts = $ts0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c6 = $x / 128 + $c6 = $c6 * 128 + $c6 = $x - $c6 + sql insert into $tb values ( $ts , $x , $x , $x , $x , $x , $c6 , true, 'BINARY', 'NCHAR' ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +$ts = $ts + 60000 +$tb = $tbPrefix . 0 +sql insert into $tb (ts) values ( $ts ) +$tb = $tbPrefix . 1 +sql insert into $tb (ts) values ( $ts ) +$tb = $tbPrefix . 2 +sql insert into $tb (ts) values ( $ts ) +$tb = $tbPrefix . 3 +sql insert into $tb (ts) values ( $ts ) +$tb = $tbPrefix . 4 +sql insert into $tb (ts) values ( $ts ) +$ts = $ts0 - 60000 +$tb = $tbPrefix . 0 +sql import into $tb (ts) values ( $ts ) +$tb = $tbPrefix . 1 +sql import into $tb (ts) values ( $ts ) +$tb = $tbPrefix . 2 +sql import into $tb (ts) values ( $ts ) +$tb = $tbPrefix . 3 +sql import into $tb (ts) values ( $ts ) +$tb = $tbPrefix . 4 +sql import into $tb (ts) values ( $ts ) + +print ====== test data created + +run general/parser/first_last_query.sim + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 500 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed +sql connect +sleep 100 + +run general/parser/first_last_query.sim + +print =================> insert data regression test +sql create database test keep 36500 +sql use test +sql create table tm0 (ts timestamp, k int) + +print =========================> td-2298 +$ts0 = 1537146000000 +$xs = 6000 + +$x = 0 +while $x < 5000 + $ts = $ts0 + $xs + $ts1 = $ts + $xs + $x1 = $x + 1 + + sql insert into tm0 values ( $ts , $x ) ( $ts1 , $x1 ) + $x = $x1 + $ts0 = $ts1 +endw + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 1000 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed +sql connect +sleep 100 + +sql use test +sql select count(*), last(ts) from tm0 interval(1s) +if $rows != 10000 then + print expect 10000, actual: $rows + return -1 +endi + +sql select last(ts) from tm0 interval(1s) +if $rows != 10000 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/first_last_query.sim b/tests/script/general/parser/first_last_query.sim new file mode 100644 index 0000000000000000000000000000000000000000..2dff1dd51b4fe7d3646a013302b084f66b31669d --- /dev/null +++ b/tests/script/general/parser/first_last_query.sim @@ -0,0 +1,318 @@ +sleep 100 +sql connect + +$dbPrefix = first_db +$tbPrefix = first_tb +$stbPrefix = first_stb +$tbNum = 10 +$rowNum = 2000 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 60000 +print ========== first_last_query.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +print use $db +sql use $db + +##### select first/last from table +## TBASE-331 +print ====== select first/last from table +$tb = $tbPrefix . 0 +print select first(*) from $tb +sql select first(*) from $tb +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 08:59:00.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +print data03 = $data03 +if $data03 != 0.00000 then + print expect 0.00000, actual: $data03 + return -1 +endi +if $data04 != 0.000000000 then + return -1 +endi +if $data05 != 0 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data08 != BINARY then + print expect BINARY, actual: $data08 + return -1 +endi +#if $data09 != NULL then +if $data09 != NCHAR then + return -1 +endi + +print select last(*) from $tb +sql select last(*) from $tb +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-18 01:40:00.000@ then + return -1 +endi + +if $data01 != 999 then + return -1 +endi + +if $data02 != 999 then + return -1 +endi + +if $data03 != 999.00000 then + return -1 +endi + +if $data04 != 999.000000000 then + return -1 +endi + +#if $data05 != NULL then +if $data05 != 999 then + return -1 +endi +#if $data06 != NULL then +if $data06 != 103 then + return -1 +endi +#if $data07 != NULL then +if $data07 != 1 then + return -1 +endi +#if $data08 != NULL then +if $data08 != BINARY then + return -1 +endi +#if $data09 != NULL then +if $data09 != NCHAR then + return -1 +endi + +### test if first works for committed data. An 'order by ts desc' clause should be present, and queried data should come from at least 2 file blocks +$tb = $tbPrefix . 9 +sql select first(ts), first(c1) from $tb where ts < '2018-10-17 10:00:00.000' order by ts asc +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi + +$tb = $tbPrefix . 9 +sql select first(ts), first(c1) from $tb where ts < '2018-10-17 10:00:00.000' order by ts desc +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi + +print =============> add check for out of range first/last query +sql select first(ts),last(ts) from first_tb4 where ts>'2018-9-18 1:40:01'; +if $row != 0 then + return -1 +endi + +sql select first(ts),last(ts) from first_tb4 where ts<'2018-9-17 8:50:0'; +if $row != 0 then + return -1 +endi + +#first/last mix up query +#select first(size),last(size) from stest interval(1d) group by tbname; +print =====================>td-1477 + +sql create table stest(ts timestamp,size INT,filenum INT) tags (appname binary(500),tenant binary(500)); +sql insert into test1 using stest tags('test1','aaa') values ('2020-09-04 16:53:54.003',210,3); +sql insert into test2 using stest tags('test1','aaa') values ('2020-09-04 16:53:56.003',210,3); +sql insert into test11 using stest tags('test11','bbb') values ('2020-09-04 16:53:57.003',210,3); +sql insert into test12 using stest tags('test11','bbb') values ('2020-09-04 16:53:58.003',210,3); +sql insert into test21 using stest tags('test21','ccc') values ('2020-09-04 16:53:59.003',210,3); +sql insert into test22 using stest tags('test21','ccc') values ('2020-09-04 16:54:54.003',210,3); +sql select sum(size) from stest group by appname; +if $rows != 3 then + return -1 +endi + +if $data00 != 420 then + return -1 +endi +if $data10 != 420 then + return -1 +endi +if $data20 != 420 then + return -1 +endi + +if $data01 != @test1@ then +return -1 +endi +if $data11 != @test11@ then +return -1 +endi +if $data21 != @test21@ then +return -1 +endi + +sql select sum(size) from stest interval(1d) group by appname; +if $rows != 3 then + return -1 +endi + +#2020-09-04 00:00:00.000 | 420 | test1 | +#2020-09-04 00:00:00.000 | 420 | test11 | +#2020-09-04 00:00:00.000 | 420 | test21 | +if $data00 != @20-09-04 00:00:00.000@ then + return -1 +endi + +if $data10 != @20-09-04 00:00:00.000@ then + return -1 +endi + +if $data20 != @20-09-04 00:00:00.000@ then + return -1 +endi + +if $data01 != 420 then + print expect 420 , actual $data01 + return -1 +endi + +if $data11 != 420 then + return -1 +endi + +if $data21 != 420 then + return -1 +endi + +if $data02 != @test1@ then +return -1 +endi +if $data12 != @test11@ then +return -1 +endi +if $data22 != @test21@ then +return -1 +endi + +print ===================>td-1477, one table has only one block occurs this bug. +sql select first(size),count(*),LAST(SIZE) from stest where tbname in ('test1', 'test2') interval(1d) group by tbname; +if $rows != 2 then + return -1 +endi + +if $data00 != @20-09-04 00:00:00.000@ then + return -1 +endi + +if $data01 != 210 then + return -1 +endi + +if $data02 != 1 then + return -1 +endi + +if $data03 != 210 then + return -1 +endi + +if $data04 != @test1@ then + return -1 +endi + +if $data10 != @20-09-04 00:00:00.000@ then + return -1 +endi + +if $data11 != 210 then + return -1 +endi + +if $data12 != 1 then + return -1 +endi + +if $data13 != 210 then + return -1 +endi + +if $data14 != @test2@ then + print expect test2 , actual: $data14 + return -1 +endi + +sql drop table stest + +print ===================>td-3779 +sql create table m1(ts timestamp, k int) tags(a int); +sql create table tm0 using m1 tags(1); +sql create table tm1 using m1 tags(2); +sql insert into tm0 values('2020-3-1 1:1:1', 112); +sql insert into tm1 values('2020-1-1 1:1:1', 1)('2020-3-1 0:1:1', 421); +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 1000 + +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed +sleep 1000 +sql connect +sql use first_db0; + +sql select last(*) from m1 group by tbname; +if $rows != 2 then + return -1 +endi + +if $data00 != @20-03-01 01:01:01.000@ then + return -1 +endi + +if $data01 != 112 then + return -1 +endi + +if $data02 != @tm0@ then + return -1 +endi + +if $data10 != @20-03-01 00:01:01.000@ then + return -1 +endi + +if $data11 != 421 then + return -1 +endi + +if $data12 != @tm1@ then + return -1 +endi + +sql drop table m1 \ No newline at end of file diff --git a/tests/script/general/parser/function.sim b/tests/script/general/parser/function.sim new file mode 100644 index 0000000000000000000000000000000000000000..94f75962b4118720f2f4bdec82f4fbbe47d19cea --- /dev/null +++ b/tests/script/general/parser/function.sim @@ -0,0 +1,1212 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = m_func_db +$tbPrefix = m_func_tb +$mtPrefix = m_func_mt + +$tbNum = 10 +$rowNum = 5 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== alter.sim +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database if exists $db +sql create database $db keep 36500 +sql use $db + +print =====================================> td-4481 +sql create database $db + +print =====================================> test case for twa in single block + +sql create table t1 (ts timestamp, k float); +sql insert into t1 values('2015-08-18 00:00:00', 2.064); +sql insert into t1 values('2015-08-18 00:06:00', 2.116); +sql insert into t1 values('2015-08-18 00:12:00', 2.028); +sql insert into t1 values('2015-08-18 00:18:00', 2.126); +sql insert into t1 values('2015-08-18 00:24:00', 2.041); +sql insert into t1 values('2015-08-18 00:30:00', 2.051); + +sql select twa(k),avg(k),count(1) from t1 where ts>='2015-8-18 00:00:00' and ts<='2015-8-18 00:05:00' +if $rows != 1 then + return -1 +endi + +if $data00 != 2.063999891 then + return -1 +endi + +if $data01 != 2.063999891 then + return -1 +endi + +if $data02 != 1 then + return -1 +endi + +sql select twa(k),avg(k),count(1) from t1 where ts>='2015-8-18 00:00:00' and ts<='2015-8-18 00:07:00' +if $rows != 1 then + return -1 +endi + +if $data00 != 2.089999914 then + return -1 +endi + +if $data01 != 2.089999914 then + return -1 +endi + +if $data02 != 2 then + return -1 +endi + +sql select twa(k),avg(k),count(1) from t1 where ts>='2015-8-18 00:00:00' and ts<='2015-8-18 00:07:00' interval(1m) order by ts asc +if $rows != 2 then + return -1 +endi + +if $data00 != @15-08-18 00:00:00.000@ then + return -1 +endi + +if $data01 != 2.068333156 then + return -1 +endi + +if $data02 != 2.063999891 then + return -1 +endi + +if $data03 != 1 then + return -1 +endi + +if $data10 != @15-08-18 00:06:00.000@ then + return -1 +endi + +if $data11 != 2.115999937 then + return -1 +endi + +if $data12 != 2.115999937 then + return -1 +endi + +if $data13 != 1 then + return -1 +endi + +sql select twa(k),avg(k),count(1) from t1 where ts>='2015-8-18 00:00:00' and ts<='2015-8-18 00:07:00' interval(1m) order by ts desc; +if $rows != 2 then + return -1 +endi + +if $data00 != @15-08-18 00:06:00.000@ then + return -1 +endi + +if $data01 != 2.115999937 then + return -1 +endi + +if $data02 != 2.115999937 then + return -1 +endi + +if $data03 != 1 then + return -1 +endi + +if $data11 != 2.068333156 then + return -1 +endi + +sql select twa(k),avg(k),count(1) from t1 where ts>='2015-8-18 00:00:00' and ts<='2015-8-18 00:27:00' interval(10m) order by ts asc +if $rows != 3 then + return -1 +endi + +if $data01 != 2.088666666 then + return -1 +endi + +if $data02 != 2.089999914 then + return -1 +endi + +if $data03 != 2 then + return -1 +endi + +if $data11 != 2.077099980 then + return -1 +endi + +if $data12 != 2.077000022 then + return -1 +endi + +if $data13 != 2 then + return -1 +endi + +if $data21 != 2.069333235 then + return -1 +endi + +if $data22 != 2.040999889 then + return -1 +endi + +if $data23 != 1 then + return -1 +endi + +sql select twa(k),avg(k),count(1) from t1 where ts>='2015-8-18 00:00:00' and ts<='2015-8-18 00:27:00' interval(10m) order by ts desc +if $rows != 3 then + return -1 +endi + +if $data01 != 2.069333235 then + return -1 +endi + +if $data11 != 2.077099980 then + return -1 +endi + +if $data21 != 2.088666666 then + return -1 +endi + +sql select twa(k),avg(k),count(1) from t1 where ts>='2015-8-18 00:00:00' and ts<='2015-8-18 00:30:00' order by ts asc +if $data00 != 2.073699975 then + return -1 +endi + +if $data01 != 2.070999980 then + return -1 +endi + +if $data02 != 6 then + return -1 +endi + +sql select twa(k),avg(k),count(1) from t1 where ts>='2015-8-18 00:00:00' and ts<='2015-8-18 00:30:00' order by ts desc +if $rows != 1 then + return -1 +endi + +if $data00 != 2.073699975 then + return -1 +endi + +if $data01 != 2.070999980 then + return -1 +endi + +if $data02 != 6 then + return -1 +endi + +sql select twa(k) from t1 where ts>'2015-8-18 00:00:00' and ts<'2015-8-18 00:00:1' +if $rows != 0 then + return -1 +endi + +sql select twa(k),avg(k),count(1) from t1 where ts>='2015-8-18 00:00:00' and ts<='2015-8-18 00:30:00' interval(10m) order by ts asc +sql select twa(k),avg(k),count(1) from t1 where ts>='2015-8-18 00:00:00' and ts<='2015-8-18 00:30:00' interval(10m) order by ts desc + + +#todo add test case while column filter exists for twa query + +#sql select count(*),TWA(k) from tm0 where ts>='1970-1-1 13:43:00' and ts<='1970-1-1 13:44:10' interval(9s) + +sql create table tm0 (ts timestamp, k float); +sql insert into tm0 values(100000000, 5); +sql insert into tm0 values(100003000, -9); +sql select twa(k) from tm0 where ts td-2610 +sql select twa(k)from tm1 where ts>='2020-11-19 18:11:45.773' and ts<='2020-12-9 18:11:17.098' +if $rows != 0 then + return -1 +endi + +print =====================> td-2609 +sql select apercentile(k, 50) from tm1 where ts>='2020-10-30 18:11:56.680' and ts<='2020-12-09 18:11:17.098' +if $rows != 1 then + return -1 +endi + +if $data00 != -1000.000000000 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 1000 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed +sql connect +sleep 100 + +sql use m_func_db0 + +print =====================> td-2583 +sql select min(k) from tm1 where ts>='2020-11-19 18:11:45.773' and ts<='2020-12-20 18:11:49.412' +if $rows != 1 then + return -1 +endi + +if $data00 != 1 then + print expect 1, actual: $data00 + return -1 +endi + +print =====================> td-2601 +sql select count(*) from tm1 where ts<='2020-6-1 00:00:00' and ts>='2020-1-1 00:00:00' interval(1n) fill(NULL) +if $rows != 0 then + return -1 +endi + +print =====================> td-2615 +sql select last(ts) from tm1 interval(17a) limit 776 offset 3 +if $rows != 3 then + return -1 +endi + +sql select last(ts) from tm1 interval(17a) limit 1000 offset 4 +if $rows != 2 then + return -1 +endi + +sql select last(ts) from tm1 interval(17a) order by ts desc limit 1000 offset 0 +if $rows != 6 then + return -1 +endi + +print =============================> TD-6086 +sql create stable td6086st(ts timestamp, d double) tags(t nchar(50)); +sql create table td6086ct1 using td6086st tags("ct1"); +sql create table td6086ct2 using td6086st tags("ct2"); +sql SELECT LAST(d),t FROM td6086st WHERE tbname in ('td6086ct1', 'td6086ct2') and ts>="2019-07-30 00:00:00" and ts<="2021-08-31 00:00:00" interval(1800s) fill(prev) GROUP BY tbname; + +print ==================> td-2624 +sql create table tm2(ts timestamp, k int, b binary(12)); +sql insert into tm2 values('2011-01-02 18:42:45.326', -1,'abc'); +sql insert into tm2 values('2020-07-30 17:44:06.283', 0, null); +sql insert into tm2 values('2020-07-30 17:44:19.578', 9999999, null); +sql insert into tm2 values('2020-07-30 17:46:06.417', NULL, null); +sql insert into tm2 values('2020-11-09 18:42:25.538', 0, null); +sql insert into tm2 values('2020-12-29 17:43:11.641', 0, null); +sql insert into tm2 values('2020-12-29 18:43:17.129', 0, null); +sql insert into tm2 values('2020-12-29 18:46:19.109', NULL, null); +sql insert into tm2 values('2021-01-03 18:40:40.065', 0, null); + +sql select twa(k),first(ts) from tm2 where k <50 interval(17s); +if $rows != 6 then + return -1 +endi + +if $data00 != @11-01-02 18:42:42.000@ then + return -1 +endi + +if $data02 != @11-01-02 18:42:45.326@ then + return -1 +endi + +if $data10 != @20-07-30 17:43:59.000@ then + return -1 +endi + +if $data21 != 0.000000000 then + return -1 +endi + +sql select twa(k),first(ts) from tm2 where k <50 interval(17s) order by ts desc; +if $rows != 6 then + return -1 +endi + +sql select twa(k),first(ts),count(k),first(k) from tm2 interval(17s) limit 20 offset 0; +if $rows != 9 then + return -1 +endi + +if $data00 != @11-01-02 18:42:42.000@ then + return -1 +endi + +if $data10 != @20-07-30 17:43:59.000@ then + return -1 +endi + +print =================>td-2610 +sql select stddev(k) from tm2 where ts='2020-12-29 18:46:19.109' +if $rows != 0 then + print expect 0, actual:$rows + return -1 +endi + +sql select twa(k) from tm2 where ts='2020-12-29 18:46:19.109' +if $rows != 0 then + return -1 +endi + +print ========================> TD-1787 +sql create table cars(ts timestamp, c int) tags(id int); +sql create table car1 using cars tags(1); +sql create table car2 using cars tags(2); +sql insert into car1 (ts, c) values (now,1) car2(ts, c) values(now, 2); +sql drop table cars; +sql create table cars(ts timestamp, c int) tags(id int); +sql create table car1 using cars tags(1); +sql create table car2 using cars tags(2); +sql insert into car1 (ts, c) values (now,1) car2(ts, c) values(now, 2); + +print ========================> TD-2700 +sql create table tx(ts timestamp, k int); +sql insert into tx values(1500000001000, 0); +sql select sum(k) from tx interval(1d) sliding(1h); +if $rows != 24 then + print expect 24, actual:$rows + return -1 +endi + +print ========================> TD-3948 +sql drop table if exists meters +sql create stable meters (ts timestamp, current float, voltage int, phase float) tags (location binary(64), groupId int); +sql_error insert into td3948Err1(phase) using meters tags ("Beijng.Chaoyang", 2) (ts, current) values (now, 10.2); +sql_error insert into td3948Err2(phase, voltage) using meters tags ("Beijng.Chaoyang", 2) (ts, current) values (now, 10.2); +sql_error insert into td3948Err3(phase, current) using meters tags ("Beijng.Chaoyang", 2) (ts, current) values (now, 10.2); +sql insert into td3948 using meters tags ("Beijng.Chaoyang", 2) (ts, current) values (now, 10.2); +sql select count(ts) from td3948; +if $rows != 1 then + print expect 1, actual:$rows + return -1 +endi + +print ========================> TD-2740 +sql drop table if exists m1; +sql create table m1(ts timestamp, k int) tags(a int); +sql create table tm10 using m1 tags(0); +sql create table tm11 using m1 tags(1); +sql create table tm12 using m1 tags(2); +sql create table tm13 using m1 tags(3); +sql insert into tm10 values('2020-1-1 1:1:1', 0); +sql insert into tm11 values('2020-1-5 1:1:1', 0); +sql insert into tm12 values('2020-1-7 1:1:1', 0); +sql insert into tm13 values('2020-1-1 1:1:1', 0); +sql select count(*) from m1 where ts='2020-1-1 1:1:1' interval(1h) group by tbname; +if $rows != 2 then + return -1 +endi + +sql drop table m1; +sql drop table if exists tm1; +sql drop table if exists tm2; +sql create table m1(ts timestamp, k double, b double, c int, d smallint, e int unsigned) tags(a int); +sql create table tm1 using m1 tags(1); +sql create table tm2 using m1 tags(2); +sql insert into tm1 values('2021-01-27 22:22:39.294', 1, 10, NULL, 110, 123) ('2021-01-27 22:22:40.294', 2, 20, NULL, 120, 124) ('2021-01-27 22:22:41.294', 3, 30, NULL, 130, 125)('2021-01-27 22:22:43.294', 4, 40, NULL, 140, 126)('2021-01-27 22:22:44.294', 5, 50, NULL, 150, 127); +sql insert into tm2 values('2021-01-27 22:22:40.688', 5, 101, NULL, 210, 321) ('2021-01-27 22:22:41.688', 5, 102, NULL, 220, 322) ('2021-01-27 22:22:42.688', 5, 103, NULL, 230, 323)('2021-01-27 22:22:43.688', 5, 104, NULL, 240, 324)('2021-01-27 22:22:44.688', 5, 105, NULL, 250, 325)('2021-01-27 22:22:45.688', 5, 106, NULL, 260, 326); +sql select stddev(k) from m1 +if $rows != 1 then + return -1 +endi + +if $data00 != 1.378704626 then + return -1 +endi + +sql select stddev(c) from m1 +if $rows != 0 then + return -1 +endi + +sql select stddev(k), stddev(c) from m1 +if $rows != 1 then + return -1 +endi + +if $data00 != 1.378704626 then + return -1 +endi + +if $data01 != NULL then + return -1; +endi + +sql select stddev(b),stddev(b),stddev(k) from m1; +if $rows != 1 then + return -1 +endi + +if $data00 != 37.840465463 then + return -1 +endi + +if $data01 != 37.840465463 then + return -1 +endi + +if $data02 != 1.378704626 then + return -1 +endi + +sql select stddev(k), stddev(b) from m1 group by a +if $rows != 2 then + return -1 +endi + +if $data00 != 1.414213562 then + return -1 +endi + +if $data01 != 14.142135624 then + return -1 +endi + +if $data02 != 1 then + return -1 +endi + +if $data10 != 0.000000000 then + return -1 +endi + +if $data11 != 1.707825128 then + return -1 +endi + +if $data12 != 2 then + return -1 +endi + +sql select stddev(k), stddev(b) from m1 where a= 1 group by a +if $rows != 1 then + return -1 +endi + +if $data00 != 1.414213562 then + return -1 +endi + +if $data01 != 14.142135624 then + return -1 +endi + +if $data02 != 1 then + return -1 +endi + +sql select stddev(k), stddev(b) from m1 group by tbname +if $rows != 2 then + return -1 +endi + +if $data00 != 1.414213562 then + return -1 +endi + +if $data01 != 14.142135624 then + return -1 +endi + +if $data02 != @tm1@ then + return -1 +endi + +if $data10 != 0.000000000 then + return -1 +endi + +if $data11 != 1.707825128 then + return -1 +endi + +if $data12 != @tm2@ then + return -1 +endi + +sql select stddev(k), stddev(b) from m1 group by tbname,a +if $rows != 2 then + return -1 +endi + +sql select stddev(k), stddev(b), stddev(c) from m1 group by tbname,a +if $rows != 2 then + return -1 +endi + +if $data00 != 1.414213562 then + return -1 +endi + +if $data01 != 14.142135624 then + return -1 +endi + +if $data02 != NULL then + return -1 +endi + +if $data03 != @tm1@ then + return -1 +endi + +if $data04 != 1 then + return -1 +endi + +if $data10 != 0.000000000 then + return -1 +endi + +if $data11 != 1.707825128 then + return -1 +endi + +if $data12 != NULL then + return -1 +endi + +if $data13 != @tm2@ then + return -1 +endi + +if $data14 != 2 then + return -1 +endi + +sql select stddev(k), stddev(b), stddev(c) from m1 interval(10s) group by tbname,a +if $rows != 3 then + return -1 +endi + +if $data01 != 0.000000000 then + return -1 +endi + +if $data02 != 0.000000000 then + return -1 +endi + +if $data03 != NULL then + return -1 +endi + +if $data04 != @tm1@ then + return -1 +endi + +if $data05 != 1 then + return -1 +endi + +if $data11 != 1.118033989 then + return -1 +endi + +if $data12 != 11.180339887 then + return -1 +endi + +if $data13 != NULL then + return -1 +endi + +if $data14 != @tm1@ then + return -1 +endi + +if $data22 != 1.707825128 then + return -1 +endi + +if $data23 != NULL then + return -1 +endi + +if $data24 != @tm2@ then + return -1 +endi + +if $data25 != 2 then + return -1 +endi + +sql select count(*), first(b), stddev(b), stddev(c) from m1 interval(10s) group by a +if $rows != 3 then + return -1 +endi + +if $data00 != @21-01-27 22:22:30.000@ then + return -1 +endi + +if $data01 != 1 then + return -1 +endi + +if $data02 != 10.000000000 then + return -1 +endi + +if $data03 != 0.000000000 then + return -1 +endi + +if $data04 != NULL then + return -1 +endi + +if $data05 != 1 then + return -1 +endi + +if $data12 != 20.000000000 then + return -1 +endi + +if $data13 != 11.180339887 then + return -1 +endi + +if $data14 != NULL then + return -1 +endi + +if $data23 != 1.707825128 then + return -1 +endi + +sql select count(*), first(b), stddev(b), stddev(c) from m1 interval(10s) group by tbname,a +if $rows != 3 then + return -1 +endi + +if $data23 != 1.707825128 then + return -1 +endi + +if $data25 != @tm2@ then + return -1 +endi + +sql select count(*), stddev(b), stddev(b)+20, stddev(c) from m1 interval(10s) group by tbname,a +if $rows != 3 then + return -1 +endi + +if $data02 != 0.000000000 then + return -1 +endi + +if $data03 != 20.000000000 then + return -1 +endi + +if $data13 != 31.180339887 then + return -1 +endi + +if $data14 != NULL then + return -1 +endi + +sql select count(*), first(b), stddev(b)+first(b), stddev(c) from m1 interval(10s) group by tbname,a +if $rows != 3 then + return -1 +endi + +if $data02 != 10.000000000 then + return -1 +endi + +if $data03 != 10.000000000 then + return -1 +endi + +if $data12 != 20.000000000 then + return -1 +endi + +if $data13 != 31.180339887 then + return -1 +endi + +if $data22 != 101.000000000 then + return -1 +endi + +if $data23 != 102.707825128 then + return -1 +endi + +sql select stddev(e),stddev(k) from m1 where a=1 +if $rows != 1 then + return -1 +endi + +if $data00 != 1.414213562 then + return -1 +endi + +if $data01 != 1.414213562 then + return -1 +endi + +sql create stable st1 (ts timestamp, f1 int, f2 int) tags (id int); +sql create table tb1 using st1 tags(1); + +sql insert into tb1 values ('2021-07-02 00:00:00', 1, 1); + +sql select stddev(f1) from st1 group by f1; + +if $rows != 1 then + return -1 +endi + +if $data00 != 0.000000000 then + return -1 +endi + +sql select count(tbname) from st1 +if $rows != 1 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + +sql select count(id) from st1 +if $rows != 1 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + +print ====================> TODO stddev + normal column filter + + +print ====================> irate +sql_error select irate(f1) from st1; +sql select irate(f1) from st1 group by tbname; + +sql select irate(k) from t1 +if $rows != 1 then + return -1 +endi + +if $data00 != 0.000027778 then + return -1 +endi + +sql select irate(k) from t1 where ts>='2015-8-18 00:30:00.000' +if $rows != 1 then + return -1 +endi + +if $data00 != 0.000000000 then + print expect 0.000000000, actual $data00 + return -1 +endi + +sql select irate(k) from t1 where ts>='2015-8-18 00:06:00.000' and ts<='2015-8-18 00:12:000'; +if $rows != 1 then + return -1 +endi + +if $data00 != 0.005633334 then + return -1 +endi + +sql select irate(k) from t1 interval(10a) +if $rows != 6 then + return -1 +endi + +if $data01 != 0.000000000 then + return -1 +endi + +if $data11 != 0.000000000 then + return -1 +endi + +if $data51 != 0.000000000 then + return -1 +endi + +sql select count(*),irate(k) from t1 interval(10m) +if $rows != 4 then + return -1 +endi + +if $data00 != @15-08-18 00:00:00.000@ then + return -1 +endi + +if $data01 != 2 then + return -1 +endi + +if $data02 != 0.000144445 then + return -1 +endi + +if $data10 != @15-08-18 00:10:00.000@ then + return -1 +endi + +if $data11 != 2 then + return -1 +endi + +if $data12 != 0.000272222 then + return -1 +endi + +if $data20 != @15-08-18 00:20:00.000@ then + return -1 +endi + +if $data21 != 1 then + return -1 +endi + +if $data22 != 0.000000000 then + return -1 +endi + +if $data30 != @15-08-18 00:30:00.000@ then + return -1 +endi + +if $data31 != 1 then + return -1 +endi + +if $data32 != 0.000000000 then + return -1 +endi + +sql select count(*),irate(k) from t1 interval(10m) order by ts desc +if $rows != 4 then + return -1 +endi + +if $data30 != @15-08-18 00:00:00.000@ then + return -1 +endi + +if $data31 != 2 then + return -1 +endi + +if $data32 != 0.000144445 then + return -1 +endi + +sql insert into t1 values('2015-09-18 00:30:00', 3.0); +sql select irate(k) from t1 +if $rows != 1 then + return -1 +endi + +if $data00 != 0.000000354 then + return -1 +endi + + +print ===========================> derivative +sql drop table t1 +sql drop table tx; +sql drop table if exists m1; +sql drop table if exists tm0; +sql drop table if exists tm1; + +sql create table tm0(ts timestamp, k double) +sql insert into tm0 values('2015-08-18T00:00:00Z', 2.064) ('2015-08-18T00:06:00Z', 2.116) ('2015-08-18T00:12:00Z', 2.028) +sql insert into tm0 values('2015-08-18T00:18:00Z', 2.126) ('2015-08-18T00:24:00Z', 2.041) ('2015-08-18T00:30:00Z', 2.051) + +sql_error select derivative(ts) from tm0; +sql_error select derivative(k) from tm0; +sql_error select derivative(k, 0, 0) from tm0; +sql_error select derivative(k, 1, 911) from tm0; +sql_error select derivative(kx, 1s, 1) from tm0; +sql_error select derivative(k, -20s, 1) from tm0; +sql_error select derivative(k, 20a, 0) from tm0; +sql_error select derivative(k, 200a, 0) from tm0; +sql_error select derivative(k, 999a, 0) from tm0; +sql_error select derivative(k, 20s, -12) from tm0; + +sql select derivative(k, 1s, 0) from tm0 +if $rows != 5 then + return -1 +endi + +if $data00 != @15-08-18 08:06:00.000@ then + return -1 +endi + +if $data01 != 0.000144444 then + print expect 0.000144444, actual: $data01 + return -1 +endi + +if $data10 != @15-08-18 08:12:00.000@ then + return -1 +endi + +if $data11 != -0.000244444 then + return -1 +endi + +if $data20 != @15-08-18 08:18:00.000@ then + return -1 +endi + +if $data21 != 0.000272222 then + print expect 0.000272222, actual: $data21 + return -1 +endi + +if $data30 != @15-08-18 08:24:00.000@ then + return -1 +endi + +if $data31 != -0.000236111 then + print expect 0.000236111, actual: $data31 + return -1 +endi + +sql select derivative(k, 6m, 0) from tm0; +if $rows != 5 then + return -1 +endi + +if $data00 != @15-08-18 08:06:00.000@ then + return -1 +endi + +if $data01 != 0.052000000 then + print expect 0.052000000, actual: $data01 + return -1 +endi + +if $data10 != @15-08-18 08:12:00.000@ then + return -1 +endi + +if $data11 != -0.088000000 then + return -1 +endi + +if $data20 != @15-08-18 08:18:00.000@ then + return -1 +endi + +if $data21 != 0.098000000 then + return -1 +endi + +if $data30 != @15-08-18 08:24:00.000@ then + return -1 +endi + +if $data31 != -0.085000000 then + return -1 +endi + +sql select derivative(k, 12m, 0) from tm0; +if $rows != 5 then + return -1 +endi + +if $data00 != @15-08-18 08:06:00.000@ then + return -1 +endi + +if $data01 != 0.104000000 then + print expect 0.104000000, actual: $data01 + return -1 +endi + +sql select derivative(k, 6m, 1) from tm0; +if $rows != 3 then + return -1 +endi + +sql_error select derivative(k, 6m, 1) from tm0 interval(1s); +sql_error select derivative(k, 6m, 1) from tm0 session(ts, 1s); +sql_error select derivative(k, 6m, 1) from tm0 group by k; + +sql drop table if exists tm0 +sql drop table if exists m1 + +sql create table m1 (ts timestamp, k double ) tags(a int); +sql create table if not exists t0 using m1 tags(1); +sql create table if not exists t1 using m1 tags(2); + +sql insert into t0 values('2020-1-1 1:1:1', 1); +sql insert into t0 values('2020-1-1 1:1:3', 3); +sql insert into t0 values('2020-1-1 1:2:4', 4); +sql insert into t0 values('2020-1-1 1:2:5', 5); +sql insert into t0 values('2020-1-1 1:2:6', 6); +sql insert into t0 values('2020-1-1 1:3:7', 7); +sql insert into t0 values('2020-1-1 1:3:8', 8); +sql insert into t0 values('2020-1-1 1:3:9', 9); +sql insert into t0 values('2020-1-1 1:4:10', 10); + +sql insert into t1 values('2020-1-1 1:1:2', 2); +print ===========================>td-4739 +sql select diff(val) from (select derivative(k, 1s, 0) val from t1); +if $rows != 0 then + return -1 +endi + +sql insert into t1 values('2020-1-1 1:1:4', 20); +sql insert into t1 values('2020-1-1 1:1:6', 200); +sql insert into t1 values('2020-1-1 1:1:8', 2000); +sql insert into t1 values('2020-1-1 1:1:10', 20000); + +sql_error select derivative(k, 1s, 0) from m1; +sql_error select derivative(k, 1s, 0) from m1 group by a; +sql_error select derivative(f1, 1s, 0) from (select k from t1); + +sql select derivative(k, 1s, 0) from m1 group by tbname +if $rows != 12 then + return -1 +endi + +if $data00 != @20-01-01 01:01:03.000@ then + return -1 +endi + +if $data01 != 1.000000000 then + return -1 +endi + +if $data02 != @t0@ then + return -1 +endi + +if $data10 != @20-01-01 01:02:04.000@ then + return -1 +endi + +if $data11 != 0.016393443 then + return -1 +endi + +if $data12 != t0 then + return -1 +endi + +if $data90 != @20-01-01 01:01:06.000@ then + return -1 +endi + +if $data91 != 90.000000000 then + return -1 +endi + +if $data92 != t1 then + return -1 +endi + +print =========================>TD-5190 +sql select stddev(f1) from st1 where ts>'2021-07-01 1:1:1' and ts<'2021-07-30 00:00:00' interval(1d) fill(NULL); +if $rows != 29 then + return -1 +endi + +if $data00 != @21-07-01 00:00:00.000@ then + return -1 +endi + +if $data01 != NULL then + return -1 +endi + + +sql select derivative(test_column_alias_name, 1s, 0) from (select avg(k) test_column_alias_name from t1 interval(1s)); + +sql create table smeters (ts timestamp, current float, voltage int) tags (t1 int); +sql create table smeter1 using smeters tags (1); +sql insert into smeter1 values ('2021-08-08 10:10:10', 10, 2); +sql insert into smeter1 values ('2021-08-08 10:10:12', 10, 2); +sql insert into smeter1 values ('2021-08-08 10:10:14', 20, 1); + +sql select stddev(voltage) from smeters where ts>='2021-08-08 10:10:10.000' and ts < '2021-08-08 10:10:20.000' and current=10 interval(1000a); +if $rows != 2 then + return -1 +endi +if $data00 != @21-08-08 10:10:10.000@ then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data10 != @21-08-08 10:10:12.000@ then + return -1 +endi +if $data11 != 0.000000000 then + return -1 +endi + +sql select stddev(voltage) from smeters where ts>='2021-08-08 10:10:10.000' and ts < '2021-08-08 10:10:20.000' and current=10; +if $rows != 1 then + return -1 +endi +if $data00 != 0.000000000 then + return -1 +endi + +sql select derivative(aa,1m,0) from (select avg(voltage) as aa from smeters where ts>='2021-08-08 10:10:10.000' and ts < '2021-08-08 10:10:20.000' and current=10 interval(1000a)); +if $rows != 1 then + return -1 +endi +if $data00 != @21-08-08 10:10:12.000@ then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi + + + diff --git a/tests/script/general/parser/gendata.sh b/tests/script/general/parser/gendata.sh new file mode 100755 index 0000000000000000000000000000000000000000..b2074147ca0a0a4483d19192b45d875ad24a1541 --- /dev/null +++ b/tests/script/general/parser/gendata.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +Cur_Dir=$(pwd) +echo $Cur_Dir + +echo "'2020-1-1 1:1:1','abc','device',123,'9876', 'abc', 'net', 'mno', 'province', 'city', 'al'" >> ~/data.sql +echo "'2020-1-2 1:1:1','abc','device',123,'9876', 'abc', 'net', 'mno', 'province', 'city', 'al'" >> ~/data.sql +echo "'2020-1-3 1:1:1','abc','device',123,'9876', 'abc', 'net', 'mno', 'province', 'city', 'al'" >> ~/data.sql diff --git a/tests/script/general/parser/groupby.sim b/tests/script/general/parser/groupby.sim new file mode 100644 index 0000000000000000000000000000000000000000..1fe19714bbd516c2e8938ce1290f04f8d2053839 --- /dev/null +++ b/tests/script/general/parser/groupby.sim @@ -0,0 +1,795 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 4 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = group_db +$tbPrefix = group_tb +$mtPrefix = group_mt +$tbNum = 8 +$rowNum = 10000 +$totalNum = $tbNum * $rowNum + +print =============== groupby.sim +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +$tstart = 100000 + +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +$tstart = 100000 + +sql drop database if exists $db -x step1 +step1: +sql create database if not exists $db keep 36500 +sql use $db +sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12)) + +$half = $tbNum / 2 + +$i = 0 +while $i < $half + $tb = $tbPrefix . $i + $tg2 = ' . abc + $tg2 = $tg2 . ' + + $nextSuffix = $i + $half + $tb1 = $tbPrefix . $nextSuffix + + sql create table $tb using $mt tags( $i , $tg2 ) + sql create table $tb1 using $mt tags( $nextSuffix , $tg2 ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + $c = $x / 100 + $c = $c * 100 + $c = $x - $c + + $binary = ' . binary + $binary = $binary . $c + $binary = $binary . ' + + $nchar = ' . nchar + $nchar = $nchar . $c + $nchar = $nchar . ' + + sql insert into $tb values ($tstart , $c , $c , $x , $x , $c , $c , $c , $binary , $nchar ) $tb1 values ($tstart , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar ) + $tstart = $tstart + 1 + $x = $x + 1 + endw + + $i = $i + 1 + $tstart = 100000 +endw + +sleep 100 + +$i1 = 1 +$i2 = 0 + +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +$dbPrefix = group_db +$tbPrefix = group_tb +$mtPrefix = group_mt + +$tb1 = $tbPrefix . $i1 +$tb2 = $tbPrefix . $i2 +$ts1 = $tb1 . .ts +$ts2 = $tb2 . .ts + +print ===============================groupby_operation +sql select count(*),c1 from group_tb0 where c1 < 20 group by c1; +if $row != 20 then + return -1 +endi + +if $data00 != 100 then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +if $data10 != 100 then + return -1 +endi + +if $data11 != 1 then + return -1 +endi + +sql select first(ts),c1 from group_tb0 where c1<20 group by c1; +if $row != 20 then + return -1 +endi + +if $data00 != @70-01-01 08:01:40.000@ then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +if $data90 != @70-01-01 08:01:40.009@ then + return -1 +endi + +if $data91 != 9 then + return -1 +endi + +sql select first(ts), ts, c1 from group_tb0 where c1 < 20 group by c1; +print $row +if $row != 20 then + return -1 +endi + +if $data00 != $data01 then + return -1 +endi + +if $data10 != $data11 then + return -1 +endi + +if $data20 != $data21 then + return -1 +endi + +if $data90 != $data91 then + return -1 +endi + +if $data02 != 0 then + return -1 +endi + +if $data12 != 1 then + return -1 +endi + +if $data92 != 9 then + return -1 +endi + +sql select sum(c1), c1, avg(c1), min(c1), max(c2) from group_tb0 where c1 < 20 group by c1; +if $row != 20 then + return -1 +endi + +if $data00 != 0 then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +print $data02 +if $data02 != 0.000000000 then + return -1 +endi + +if $data03 != 0 then + return -1 +endi + +print $data04 +if $data04 != 0.00000 then + return -1 +endi + +if $data10 != 100 then + return -1 +endi + +if $data11 != 1 then + return -1 +endi + +print $data12 +if $data12 != 1.000000000 then + return -1 +endi + +if $data13 != 1 then + return -1 +endi + +if $data14 != 1.00000 then + print expect 1.00000, actual:$data14 + return -1 +endi + +sql_error select sum(c1), ts, c1 from group_tb0 where c1<20 group by c1; +sql_error select first(ts), ts, c2 from group_tb0 where c1 < 20 group by c1; +sql_error select sum(c3), ts, c2 from group_tb0 where c1 < 20 group by c1; +sql_error select sum(c3), first(ts), c2 from group_tb0 where c1 < 20 group by c1; +sql_error select first(c3), ts, c1, c2 from group_tb0 where c1 < 20 group by c1; +sql_error select first(c3), last(c3), ts, c1 from group_tb0 where c1 < 20 group by c1; +sql_error select ts from group_tb0 group by c1; + +#===========================interval=====not support====================== +sql_error select count(*), c1 from group_tb0 where c1<20 interval(1y) group by c1; +#=====tbname must be the first in the group by clause===================== +sql_error select count(*) from group_tb0 where c1 < 20 group by c1, tbname; + +#super table group by normal columns +sql select count(*), c1 from group_mt0 where c1< 20 group by c1; +if $row != 20 then + return -1 +endi + +if $data00 != 800 then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +if $data10 != 800 then + return -1 +endi + +if $data11 != 1 then + return -1 +endi + +if $data90 != 800 then + return -1 +endi + +if $data91 != 9 then + return -1 +endi + +sql select first(c1), c1, ts from group_mt0 where c1<20 group by c1; +if $row != 20 then + return -1 +endi + +if $data00 != $data01 then + return -1 +endi + +if $data02 != @70-01-01 08:01:40.000@ then + return -1 +endi + +if $data10 != $data11 then + return -1 +endi + +if $data12 != @70-01-01 08:01:40.001@ then + return -1 +endi + +if $data20 != $data21 then + return -1 +endi + +if $data22 != @70-01-01 08:01:40.002@ then + return -1 +endi + +if $data90 != $data91 then + return -1 +endi + +if $data92 != @70-01-01 08:01:40.009@ then + return -1 +endi + +sql select first(c1), last(ts), first(ts), last(c1),c1,sum(c1),avg(c1),count(*) from group_mt0 where c1<20 group by c1; +if $row != 20 then + return -1 +endi + +if $data00 != $data03 then + return -1 +endi + +if $data01 != @70-01-01 08:01:49.900@ then + return -1 +endi + +if $data02 != @70-01-01 08:01:40.000@ then + return -1 +endi + +if $data07 != 800 then + return -1 +endi + +if $data10 != $data13 then + return -1 +endi + +if $data11 != @70-01-01 08:01:49.901@ then + return -1 +endi + +if $data12 != @70-01-01 08:01:40.001@ then + return -1 +endi + +if $data17 != 800 then + return -1 +endi + +if $data90 != $data93 then + return -1 +endi + +if $data91 != @70-01-01 08:01:49.909@ then + return -1 +endi + +if $data92 != @70-01-01 08:01:40.009@ then + return -1 +endi + +if $data97 != 800 then + return -1 +endi + +if $data95 != 7200 then + return -1 +endi + +if $data94 != 9 then + return -1 +endi + +sql select c1,sum(c1),avg(c1),count(*) from group_mt0 where c1<5 group by c1; +if $row != 5 then + return -1 +endi + +if $data00 != 0 then + return -1 +endi + +if $data11 != 800 then + return -1 +endi + +sql select first(c1), last(ts), first(ts), last(c1),sum(c1),avg(c1),count(*) from group_mt0 where c1<20 group by tbname,c1; +if $row != 160 then + return -1 +endi + +print $data00 +if $data00 != 0 then + return -1 +endi + +if $data01 != @70-01-01 08:01:49.900@ then + return -1 +endi + +print $data01 +if $data02 != @70-01-01 08:01:40.000@ then + return -1 +endi + +if $data03 != 0 then + return -1 +endi + +if $data04 != 0 then + return -1 +endi + +if $data06 != 100 then + return -1 +endi + +if $data07 != @group_tb0@ then + return -1 +endi + +if $data90 != 9 then + return -1 +endi + +if $data91 != @70-01-01 08:01:49.909@ then + return -1 +endi + +if $data92 != @70-01-01 08:01:40.009@ then + return -1 +endi + +if $data93 != 9 then + return -1 +endi + +if $data94 != 900 then + return -1 +endi + +if $data96 != 100 then + return -1 +endi + +if $data97 != @group_tb0@ then + return -1 +endi + +sql select count(*),first(ts),last(ts),min(c3) from group_tb1 group by c4; +if $rows != 10000 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + +if $data01 != @70-01-01 08:01:40.000@ then + return -1 +endi + +if $data02 != @70-01-01 08:01:40.000@ then + return -1 +endi + +if $data03 != 0 then + return -1 +endi + +sql select count(*),first(ts),last(ts),min(c3) from group_tb1 group by c4 limit 1; +if $rows != 1 then + return -1 +endi + +sql select count(*),first(ts),last(ts),min(c3) from group_tb1 group by c4 limit 20 offset 9990; +if $rows != 10 then + return -1 +endi + +sql select count(*),first(ts),last(ts),min(c3),max(c3),sum(c3),avg(c3),sum(c4)/count(c4) from group_tb1 group by c4; +if $rows != 10000 then + return -1 +endi + +print ---------------------------------> group by binary|nchar data add cases +sql select count(*) from group_tb1 group by c8; +if $rows != 100 then + return -1 +endi + +sql select count(*),sum(c4), count(c4), sum(c4)/count(c4) from group_tb1 group by c8 +if $rows != 100 then + return -1 +endi + +if $data00 != 100 then + return -1 +endi + +if $data01 != 495000 then + return -1 +endi + +if $data02 != 100 then + return -1 +endi + +if $data03 != 4950.000000000 then + print expect 4950.000000000 , acutal $data03 + return -1 +endi + +if $data10 != 100 then + return -1 +endi + +if $data11 != 495100 then + return -1 +endi + +if $data13 != 4951.000000000 then + return -1 +endi + +print ====================> group by normal column + slimit + soffset +sql select count(*), c8 from group_mt0 group by c8 limit 1 offset 0; +if $rows != 100 then + return -1 +endi + +sql select sum(c2),c8,avg(c2), sum(c2)/count(*) from group_mt0 group by c8 slimit 2 soffset 99 +if $rows != 1 then + return -1 +endi + +if $data00 != 79200.000000000 then + return -1 +endi + +if $data01 != @binary99@ then + return -1 +endi + +if $data02 != 99.000000000 then + return -1 +endi + +if $data03 != 99.000000000 then + return -1 +endi + +print ============>td-1765 +sql select percentile(c4, 49),min(c4),max(c4),avg(c4),stddev(c4) from group_tb0 group by c8; +if $rows != 100 then + return -1 +endi + +if $data00 != 4851.000000000 then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +if $data02 != 9900 then + return -1 +endi + +if $data03 != 4950.000000000 then + return -1 +endi + +if $data04 != 2886.607004772 then + return -1 +endi + +if $data10 != 4852.000000000 then + return -1 +endi + +if $data11 != 1 then + return -1 +endi + +if $data12 != 9901 then + return -1 +endi + +if $data13 != 4951.000000000 then + return -1 +endi + +if $data14 != 2886.607004772 then + return -1 +endi + +print ================>td-2090 +sql select leastsquares(c2, 1, 1) from group_tb1 group by c8; +if $rows != 100 then + return -1 +endi + +if $data00 != @{slop:0.000000, intercept:0.000000}@ then + return -1 +endi + +if $data10 != @{slop:0.000000, intercept:1.000000}@ then + return -1 +endi + +if $data90 != @{slop:0.000000, intercept:9.000000}@ then + return -1 +endi + +#=========================== group by multi tags ====================== +sql create table st (ts timestamp, c int) tags (t1 int, t2 int, t3 int, t4 int); +sql create table t1 using st tags(1, 1, 1, 1); +sql create table t2 using st tags(1, 2, 2, 2); +sql insert into t1 values ('2020-03-27 04:11:16.000', 1)('2020-03-27 04:11:17.000', 2) ('2020-03-27 04:11:18.000', 3) ('2020-03-27 04:11:19.000', 4) ; +sql insert into t1 values ('2020-03-27 04:21:16.000', 1)('2020-03-27 04:31:17.000', 2) ('2020-03-27 04:51:18.000', 3) ('2020-03-27 05:10:19.000', 4) ; +sql insert into t2 values ('2020-03-27 04:11:16.000', 1)('2020-03-27 04:11:17.000', 2) ('2020-03-27 04:11:18.000', 3) ('2020-03-27 04:11:19.000', 4) ; +sql insert into t2 values ('2020-03-27 04:21:16.000', 1)('2020-03-27 04:31:17.000', 2) ('2020-03-27 04:51:18.000', 3) ('2020-03-27 05:10:19.000', 4) ; + +print =================>TD-2665 +sql_error create table txx as select avg(c) as t from st; +sql_error create table txx1 as select avg(c) as t from t1; + +sql select stddev(c),stddev(c) from st group by c; +if $rows != 4 then + return -1 +endi + +print =================>TD-2236 +sql select first(ts),last(ts) from t1 group by c; +if $rows != 4 then + return -1 +endi + +if $data00 != @20-03-27 04:11:16.000@ then + return -1 +endi + +if $data01 != @20-03-27 04:21:16.000@ then + return -1 +endi + +if $data10 != @20-03-27 04:11:17.000@ then + return -1 +endi + +if $data11 != @20-03-27 04:31:17.000@ then + return -1 +endi + +if $data20 != @20-03-27 04:11:18.000@ then + return -1 +endi + +if $data21 != @20-03-27 04:51:18.000@ then + return -1 +endi + +if $data30 != @20-03-27 04:11:19.000@ then + return -1 +endi + +if $data31 != @20-03-27 05:10:19.000@ then + return -1 +endi + +print ===============> +sql select stddev(c),c from st where t2=1 or t2=2 group by c; +if $rows != 4 then + return -1 +endi + +if $data00 != 0.000000000 then + return -1 +endi + +if $data01 != 1 then + return -1 +endi + +if $data10 != 0.000000000 then + return -1 +endi + +if $data11 != 2 then + return -1 +endi + +if $data20 != 0.000000000 then + return -1 +endi + +if $data21 != 3 then + return -1 +endi + +if $data30 != 0.000000000 then + return -1 +endi + +if $data31 != 4 then + return -1 +endi + +sql_error select irate(c) from st where t1="1" and ts >= '2020-03-27 04:11:17.732' and ts < '2020-03-27 05:11:17.732' interval(1m) sliding(15s) group by tbname,c; +sql select irate(c) from st where t1="1" and ts >= '2020-03-27 04:11:17.732' and ts < '2020-03-27 05:11:17.732' interval(1m) sliding(15s) group by tbname,t1,t2; +if $rows != 40 then + return -1 +endi + +if $data01 != 1.000000000 then + return -1 +endi +if $data02 != t1 then + return -1 +endi +if $data03 != 1 then + return -1 +endi +if $data04 != 1 then + return -1 +endi + +if $data11 != 1.000000000 then + return -1 +endi +if $data12 != t1 then + return -1 +endi +if $data13 != 1 then + return -1 +endi +if $data14 != 1 then + return -1 +endi + +sql select irate(c) from st where t1="1" and ts >= '2020-03-27 04:11:17.732' and ts < '2020-03-27 05:11:17.732' interval(1m) sliding(15s) group by tbname,t1,t2 limit 1; +if $rows != 2 then + return -1 +endi + +if $data11 != 1.000000000 then + return -1 +endi +if $data12 != t2 then + return -1 +endi +if $data13 != 1 then + return -1 +endi +if $data14 != 2 then + return -1 +endi + +sql create table m1 (ts timestamp, k int, f1 int) tags(a int); +sql create table tm0 using m1 tags(0); +sql create table tm1 using m1 tags(1); + +sql insert into tm0 values('2020-1-1 1:1:1', 1, 10); +sql insert into tm0 values('2020-1-1 1:1:2', 1, 20); +sql insert into tm1 values('2020-2-1 1:1:1', 2, 10); +sql insert into tm1 values('2020-2-1 1:1:2', 2, 20); + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 100 +system sh/exec.sh -n dnode1 -s start +sleep 100 + +sql connect +sleep 100 +sql use group_db0; + +print =========================>TD-4894 +sql select count(*),k from m1 group by k; +if $rows != 2 then + return -1 +endi + +if $data00 != 2 then + return -1 +endi + +if $data01 != 1 then + return -1 +endi + +if $data10 != 2 then + return -1 +endi + +if $data11 != 2 then + return -1 +endi + +sql_error select count(*) from m1 group by tbname,k,f1; +sql_error select count(*) from m1 group by tbname,k,a; +sql_error select count(*) from m1 group by k, tbname; +sql_error select count(*) from m1 group by k,f1; +sql_error select count(*) from tm0 group by tbname; +sql_error select count(*) from tm0 group by a; +sql_error select count(*) from tm0 group by k,f1; + +sql_error select count(*),f1 from m1 group by tbname,k; + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/having.sim b/tests/script/general/parser/having.sim new file mode 100644 index 0000000000000000000000000000000000000000..e063333853e04faf1a7f4988b6dd1f11207aee5d --- /dev/null +++ b/tests/script/general/parser/having.sim @@ -0,0 +1,1842 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2 +system sh/exec.sh -n dnode1 -s start + +sleep 100 +sql connect +print ======================== dnode1 start + +$db = testdb + +sql create database $db +sql use $db + +sql create stable st2 (ts timestamp, f1 int, f2 float, f3 double, f4 bigint, f5 smallint, f6 tinyint, f7 bool, f8 binary(10), f9 nchar(10)) tags (id1 int, id2 float, id3 nchar(10), id4 double, id5 smallint, id6 bigint, id7 binary(10)) + +sql create table tb1 using st2 tags (1,1.0,"1",1.0,1,1,"1"); +sql create table tb2 using st2 tags (2,2.0,"2",2.0,2,2,"2"); +sql create table tb3 using st2 tags (3,3.0,"3",3.0,3,3,"3"); +sql create table tb4 using st2 tags (4,4.0,"4",4.0,4,4,"4"); + +sql insert into tb1 values (now-200s,1,1.0,1.0,1,1,1,true ,"1","1") +sql insert into tb1 values (now-150s,1,1.0,1.0,1,1,1,false,"1","1") +sql insert into tb1 values (now-100s,2,2.0,2.0,2,2,2,true ,"2","2") +sql insert into tb1 values (now-50s ,2,2.0,2.0,2,2,2,false,"2","2") +sql insert into tb1 values (now ,3,3.0,3.0,3,3,3,true ,"3","3") +sql insert into tb1 values (now+50s ,3,3.0,3.0,3,3,3,false,"3","3") +sql insert into tb1 values (now+100s,4,4.0,4.0,4,4,4,true ,"4","4") +sql insert into tb1 values (now+150s,4,4.0,4.0,4,4,4,false,"4","4") + + +sql select count(*),f1 from st2 group by f1 having count(f1) > 0; +if $rows != 4 then + return -1 +endi +if $data00 != 2 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != 2 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data21 != 3 then + return -1 +endi +if $data30 != 2 then + return -1 +endi +if $data31 != 4 then + return -1 +endi + + + + +sql select count(*),f1 from st2 group by f1 having count(*) > 0; +if $rows != 4 then + return -1 +endi +if $data00 != 2 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != 2 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data21 != 3 then + return -1 +endi +if $data30 != 2 then + return -1 +endi +if $data31 != 4 then + return -1 +endi + + +sql select count(*),f1 from st2 group by f1 having count(f2) > 0; +if $rows != 4 then + return -1 +endi +if $data00 != 2 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != 2 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data21 != 3 then + return -1 +endi +if $data30 != 2 then + return -1 +endi +if $data31 != 4 then + return -1 +endi + +sql_error select top(f1,2) from st2 group by f1 having count(f2) > 0; + +sql select last(f1) from st2 group by f1 having count(f2) > 0; +if $rows != 4 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 2 then + return -1 +endi +if $data20 != 3 then + return -1 +endi +if $data30 != 4 then + return -1 +endi + +sql_error select top(f1,2) from st2 group by f1 having count(f2) > 0; +sql_error select top(f1,2) from st2 group by f1 having count(f2) > 0; +sql_error select top(f1,2) from st2 group by f1 having avg(f1) > 0; + +sql select avg(f1),count(f1) from st2 group by f1 having avg(f1) > 2; +if $rows != 2 then + return -1 +endi +if $data00 != 3.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data10 != 4.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi + + +sql select avg(f1),count(f1) from st2 group by f1 having avg(f1) > 2 and sum(f1) > 0; +if $rows != 2 then + return -1 +endi +if $data00 != 3.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data10 != 4.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi + +sql select avg(f1),count(f1),sum(f1) from st2 group by f1 having avg(f1) > 2 and sum(f1) > 0; +if $rows != 2 then + return -1 +endi +if $data00 != 3.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 6 then + return -1 +endi +if $data10 != 4.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 8 then + return -1 +endi + +sql select avg(f1),count(f1),sum(f1) from st2 group by f1 having avg(f1) > 2; +if $rows != 2 then + return -1 +endi +if $data00 != 3.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 6 then + return -1 +endi +if $data10 != 4.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 8 then + return -1 +endi + +sql select avg(f1),count(f1),sum(f1) from st2 group by f1 having sum(f1) > 0; +if $rows != 4 then + return -1 +endi +if $data00 != 1.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 2 then + return -1 +endi +if $data10 != 2.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 4 then + return -1 +endi +if $data20 != 3.000000000 then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data22 != 6 then + return -1 +endi +if $data30 != 4.000000000 then + return -1 +endi +if $data31 != 2 then + return -1 +endi +if $data32 != 8 then + return -1 +endi + +sql select avg(f1),count(f1),sum(f1) from st2 group by f1 having sum(f1) > 2 and sum(f1) < 6; +if $rows != 1 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 4 then + return -1 +endi + + +sql select avg(f1),count(f1),sum(f1) from st2 group by f1 having 1 <= sum(f1) and 5 >= sum(f1); +if $rows != 2 then + return -1 +endi +if $data00 != 1.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 2 then + return -1 +endi +if $data10 != 2.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 4 then + return -1 +endi + +sql select avg(f1),count(f1),sum(f1),twa(f1) from st2 group by tbname having twa(f1) > 0; +if $rows != 1 then + return -1 +endi +if $data00 != 2.500000000 then + return -1 +endi +if $data01 != 8 then + return -1 +endi +if $data02 != 20 then + return -1 +endi +if $data04 != tb1 then + return -1 +endi + +sql_error select avg(f1),count(f1),sum(f1),twa(f1) from st2 group by f1 having twa(f1) > 0; + +sql select avg(f1),count(f1),sum(f1),twa(f1) from st2 group by tbname having sum(f1) > 0; +if $rows != 1 then + return -1 +endi +if $data00 != 2.500000000 then + return -1 +endi +if $data01 != 8 then + return -1 +endi +if $data02 != 20 then + return -1 +endi +if $data04 != tb1 then + return -1 +endi + +sql_error select avg(f1),count(f1),sum(f1),twa(f1) from st2 group by f1 having sum(f1) > 0; + +sql select avg(f1),count(f1),sum(f1) from st2 group by f1 having sum(f1) > 0; +if $rows != 4 then + return -1 +endi +if $data00 != 1.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 2 then + return -1 +endi +if $data10 != 2.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 4 then + return -1 +endi +if $data20 != 3.000000000 then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data22 != 6 then + return -1 +endi +if $data30 != 4.000000000 then + return -1 +endi +if $data31 != 2 then + return -1 +endi +if $data32 != 8 then + return -1 +endi + +sql select avg(f1),count(f1),sum(f1) from st2 group by f1 having sum(f1) > 3; +if $rows != 3 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data10 != 3.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 6 then + return -1 +endi +if $data20 != 4.000000000 then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data22 != 8 then + return -1 +endi + +###########and issue +sql select avg(f1),count(f1),sum(f1) from st2 group by f1 having sum(f1) > 3 and sum(f1) > 1; +if $rows != 4 then + return -1 +endi +if $data00 != 1.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 2 then + return -1 +endi +if $data10 != 2.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 4 then + return -1 +endi +if $data20 != 3.000000000 then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data22 != 6 then + return -1 +endi +if $data30 != 4.000000000 then + return -1 +endi +if $data31 != 2 then + return -1 +endi +if $data32 != 8 then + return -1 +endi + + +sql select avg(f1),count(f1),sum(f1) from st2 group by f1 having sum(f1) > 3 or sum(f1) > 1; +if $rows != 4 then + return -1 +endi +if $data00 != 1.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 2 then + return -1 +endi +if $data10 != 2.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 4 then + return -1 +endi +if $data20 != 3.000000000 then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data22 != 6 then + return -1 +endi +if $data30 != 4.000000000 then + return -1 +endi +if $data31 != 2 then + return -1 +endi +if $data32 != 8 then + return -1 +endi + +sql select avg(f1),count(f1),sum(f1) from st2 group by f1 having sum(f1) > 3 or sum(f1) > 4; +if $rows != 3 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data10 != 3.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 6 then + return -1 +endi +if $data20 != 4.000000000 then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data22 != 8 then + return -1 +endi + +############or issue +sql select avg(f1),count(f1),sum(f1) from st2 group by f1 having sum(f1) > 3 or avg(f1) > 4; +if $rows != 0 then + return -1 +endi + +sql select avg(f1),count(f1),sum(f1) from st2 group by f1 having (sum(f1) > 3); +if $rows != 3 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data10 != 3.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 6 then + return -1 +endi +if $data20 != 4.000000000 then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data22 != 8 then + return -1 +endi + +sql_error select avg(f1),count(f1),sum(f1) from st2 group by f1 having (sum(*) > 3); + +sql select avg(f1),count(f1),sum(f1) from st2 group by f1 having (sum(st2.f1) > 3); +if $rows != 3 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data10 != 3.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 6 then + return -1 +endi +if $data20 != 4.000000000 then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data22 != 8 then + return -1 +endi + +sql select avg(f1),count(st2.*),sum(f1) from st2 group by f1 having (sum(st2.f1) > 3); +if $rows != 3 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data10 != 3.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 6 then + return -1 +endi +if $data20 != 4.000000000 then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data22 != 8 then + return -1 +endi + +sql select avg(f1),count(st2.*),sum(f1),stddev(f1),stddev(f1) from st2 group by f1; +if $rows != 4 then + return -1 +endi +if $data00 != 1.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 2 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data04 != 0.000000000 then + return -1 +endi +if $data10 != 2.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 4 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi +if $data14 != 0.000000000 then + return -1 +endi +if $data20 != 3.000000000 then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data22 != 6 then + return -1 +endi +if $data23 != 0.000000000 then + return -1 +endi +if $data24 != 0.000000000 then + return -1 +endi +if $data30 != 4.000000000 then + return -1 +endi +if $data31 != 2 then + return -1 +endi +if $data32 != 8 then + return -1 +endi +if $data33 != 0.000000000 then + return -1 +endi +if $data34 != 0.000000000 then + return -1 +endi + +sql select avg(f1),count(st2.*),sum(f1),stddev(f1) from st2 group by f1 having (stddev(st2.f1) > 3); +if $rows != 0 then + return -1 +endi + +sql select avg(f1),count(st2.*),sum(f1),stddev(f1) from st2 group by f1 having (stddev(st2.f1) < 1); +if $rows != 4 then + return -1 +endi +if $data00 != 1.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 2 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data10 != 2.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 4 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi +if $data20 != 3.000000000 then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data22 != 6 then + return -1 +endi +if $data23 != 0.000000000 then + return -1 +endi +if $data30 != 4.000000000 then + return -1 +endi +if $data31 != 2 then + return -1 +endi +if $data32 != 8 then + return -1 +endi +if $data33 != 0.000000000 then + return -1 +endi + + +sql_error select avg(f1),count(st2.*),sum(f1),stddev(f1) from st2 group by f1 having (LEASTSQUARES(f1) < 1); + +sql_error select avg(f1),count(st2.*),sum(f1),stddev(f1) from st2 group by f1 having LEASTSQUARES(f1) < 1; + +sql_error select avg(f1),count(st2.*),sum(f1),stddev(f1) from st2 group by f1 having LEASTSQUARES(f1,1,1) < 1; + +sql_error select avg(f1),count(st2.*),sum(f1),stddev(f1) from st2 group by f1 having LEASTSQUARES(f1,1,1) > 2; + +sql_error select avg(f1),count(st2.*),sum(f1),stddev(f1),LEASTSQUARES(f1,1,1) from st2 group by f1 having LEASTSQUARES(f1,1,1) > 2; + +sql_error select avg(f1),count(st2.*),sum(f1),stddev(f1),LEASTSQUARES(f1,1,1) from st2 group by f1 having sum(f1) > 2; + +sql select avg(f1),count(st2.*),sum(f1),stddev(f1) from st2 group by f1 having min(f1) > 2; +if $rows != 2 then + return -1 +endi +if $data00 != 3.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 6 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data10 != 4.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 8 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi + +sql select avg(f1),count(st2.*),sum(f1),stddev(f1),min(f1) from st2 group by f1 having min(f1) > 2; +if $rows != 2 then + return -1 +endi +if $data00 != 3.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 6 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data10 != 4.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 8 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi +if $data14 != 4 then + return -1 +endi + +sql select avg(f1),count(st2.*),sum(f1),stddev(f1),min(f1) from st2 group by f1 having max(f1) > 2; +if $rows != 2 then + return -1 +endi +if $data00 != 3.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 6 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data10 != 4.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 8 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi +if $data14 != 4 then + return -1 +endi + +sql select avg(f1),count(st2.*),sum(f1),stddev(f1),min(f1),max(f1) from st2 group by f1 having max(f1) != 2; +if $rows != 3 then + return -1 +endi +if $data00 != 1.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 2 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data04 != 1 then + return -1 +endi +if $data05 != 1 then + return -1 +endi +if $data10 != 3.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 6 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi +if $data14 != 3 then + return -1 +endi +if $data15 != 3 then + return -1 +endi +if $data20 != 4.000000000 then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data22 != 8 then + return -1 +endi +if $data23 != 0.000000000 then + return -1 +endi +if $data24 != 4 then + return -1 +endi +if $data25 != 4 then + return -1 +endi + +sql select avg(f1),count(st2.*),sum(f1),stddev(f1),min(f1),max(f1) from st2 group by f1 having first(f1) != 2; +if $rows != 3 then + return -1 +endi +if $data00 != 1.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 2 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data04 != 1 then + return -1 +endi +if $data05 != 1 then + return -1 +endi +if $data10 != 3.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 6 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi +if $data14 != 3 then + return -1 +endi +if $data15 != 3 then + return -1 +endi +if $data20 != 4.000000000 then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data22 != 8 then + return -1 +endi +if $data23 != 0.000000000 then + return -1 +endi +if $data24 != 4 then + return -1 +endi +if $data25 != 4 then + return -1 +endi + + + +sql select avg(f1),count(st2.*),sum(f1),stddev(f1),min(f1),max(f1),first(f1) from st2 group by f1 having first(f1) != 2; +if $rows != 3 then + return -1 +endi +if $data00 != 1.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 2 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data04 != 1 then + return -1 +endi +if $data05 != 1 then + return -1 +endi +if $data06 != 1 then + return -1 +endi +if $data10 != 3.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 6 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi +if $data14 != 3 then + return -1 +endi +if $data15 != 3 then + return -1 +endi +if $data16 != 3 then + return -1 +endi +if $data20 != 4.000000000 then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data22 != 8 then + return -1 +endi +if $data23 != 0.000000000 then + return -1 +endi +if $data24 != 4 then + return -1 +endi +if $data25 != 4 then + return -1 +endi +if $data26 != 4 then + return -1 +endi + + + +sql_error select avg(f1),count(st2.*),sum(f1),stddev(f1),min(f1),max(f1),first(f1),last(f1) from st2 group by f1 having top(f1,1); + +sql_error select avg(f1),count(st2.*),sum(f1),stddev(f1),min(f1),max(f1),first(f1),last(f1) from st2 group by f1 having top(f1,1) > 1; + +sql_error select avg(f1),count(st2.*),sum(f1),stddev(f1),min(f1),max(f1),first(f1),last(f1) from st2 group by f1 having bottom(f1,1) > 1; + +sql_error select avg(f1),count(st2.*),sum(f1),stddev(f1),min(f1),max(f1),first(f1),last(f1),top(f1,1),bottom(f1,1) from st2 group by f1 having bottom(f1,1) > 1; + +sql_error select avg(f1),count(st2.*),sum(f1),stddev(f1),min(f1),max(f1),first(f1),last(f1),top(f1,1),bottom(f1,1) from st2 group by f1 having sum(f1) > 1; + +sql_error select PERCENTILE(f1) from st2 group by f1 having sum(f1) > 1; + +sql_error select PERCENTILE(f1,20) from st2 group by f1 having sum(f1) > 1; + +sql select aPERCENTILE(f1,20) from st2 group by f1 having sum(f1) > 1; +if $rows != 4 then + return -1 +endi +if $data00 != 1.000000000 then + return -1 +endi +if $data10 != 2.000000000 then + return -1 +endi +if $data20 != 3.000000000 then + return -1 +endi +if $data30 != 4.000000000 then + return -1 +endi + +sql select aPERCENTILE(f1,20) from st2 group by f1 having apercentile(f1,1) > 1; +if $rows != 3 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi +if $data10 != 3.000000000 then + return -1 +endi +if $data20 != 4.000000000 then + return -1 +endi + +sql select aPERCENTILE(f1,20) from st2 group by f1 having apercentile(f1,1) > 1 and apercentile(f1,1) < 50; +if $rows != 3 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi +if $data10 != 3.000000000 then + return -1 +endi +if $data20 != 4.000000000 then + return -1 +endi + +sql select aPERCENTILE(f1,20) from st2 group by f1 having apercentile(f1,1) > 1 and apercentile(f1,1) < 3; +if $rows != 1 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi + +sql select aPERCENTILE(f1,20) from st2 group by f1 having apercentile(f1,1) > 1 and apercentile(f1,3) < 3; +if $rows != 1 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi + +sql_error select aPERCENTILE(f1,20) from st2 group by f1 having apercentile(1) > 1; + +sql_error select aPERCENTILE(f1,20),LAST_ROW(f1) from st2 group by f1 having apercentile(1) > 1; + +sql_error select aPERCENTILE(f1,20),LAST_ROW(f1) from st2 group by f1 having apercentile(f1,1) > 1; + +sql_error select sum(f1) from st2 group by f1 having last_row(f1) > 1; + +sql_error select avg(f1) from st2 group by f1 having diff(f1) > 0; + +sql_error select avg(f1),diff(f1) from st2 group by f1 having avg(f1) > 0; + +sql_error select avg(f1),diff(f1) from st2 group by f1 having spread(f2) > 0; + +sql select avg(f1) from st2 group by f1 having spread(f2) > 0; +if $rows != 0 then + return -1 +endi + +sql select avg(f1) from st2 group by f1 having spread(f2) = 0; +if $rows != 4 then + return -1 +endi +if $data00 != 1.000000000 then + return -1 +endi +if $data10 != 2.000000000 then + return -1 +endi +if $data20 != 3.000000000 then + return -1 +endi +if $data30 != 4.000000000 then + return -1 +endi + +sql select avg(f1),spread(f2) from st2 group by f1; +if $rows != 4 then + return -1 +endi +if $data00 != 1.000000000 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data10 != 2.000000000 then + return -1 +endi +if $data11 != 0.000000000 then + return -1 +endi +if $data20 != 3.000000000 then + return -1 +endi +if $data21 != 0.000000000 then + return -1 +endi +if $data30 != 4.000000000 then + return -1 +endi +if $data31 != 0.000000000 then + return -1 +endi + +sql select avg(f1),spread(f1,f2,st2.f1) from st2 group by f1 having spread(f1) = 0; +if $rows != 4 then + return -1 +endi +if $data00 != 1.000000000 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data10 != 2.000000000 then + return -1 +endi +if $data11 != 0.000000000 then + return -1 +endi +if $data12 != 0.000000000 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi +if $data20 != 3.000000000 then + return -1 +endi +if $data21 != 0.000000000 then + return -1 +endi +if $data22 != 0.000000000 then + return -1 +endi +if $data23 != 0.000000000 then + return -1 +endi +if $data30 != 4.000000000 then + return -1 +endi +if $data31 != 0.000000000 then + return -1 +endi +if $data32 != 0.000000000 then + return -1 +endi +if $data33 != 0.000000000 then + return -1 +endi + +sql select avg(f1),spread(f1,f2,st2.f1) from st2 group by f1 having spread(f1) != 0; +if $rows != 0 then + return -1 +endi + + +sql_error select avg(f1),spread(f1,f2,st2.f1) from st2 group by f1 having spread(f1) + 1 > 0; + +sql_error select avg(f1),spread(f1,f2,st2.f1) from st2 group by f1 having spread(f1) + 1; + +sql_error select avg(f1),spread(f1,f2,st2.f1) from st2 group by f1 having spread(f1) + sum(f1); + +sql_error select avg(f1),spread(f1,f2,st2.f1) from st2 group by f1 having spread(f1) + sum(f1) > 0; + +sql_error select avg(f1),spread(f1,f2,st2.f1) from st2 group by f1 having spread(f1) - sum(f1) > 0; + +sql_error select avg(f1),spread(f1,f2,st2.f1) from st2 group by f1 having spread(f1) * sum(f1) > 0; + +sql_error select avg(f1),spread(f1,f2,st2.f1) from st2 group by f1 having spread(f1) / sum(f1) > 0; + +sql_error select avg(f1),spread(f1,f2,st2.f1) from st2 group by f1 having spread(f1) > sum(f1); + +sql_error select avg(f1),spread(f1,f2,st2.f1) from st2 group by f1 having spread(f1) and sum(f1); + +sql_error select avg(f1),spread(f1,f2,st2.f1) from st2 group by f1 having spread(f1) 0 and sum(f1); + +sql_error select avg(f1),spread(f1,f2,st2.f1) from st2 group by f1 having spread(f1) + 0 and sum(f1); + +sql_error select avg(f1),spread(f1,f2,st2.f1) from st2 group by f1 having spread(f1) - f1 and sum(f1); + +sql_error select avg(f1),spread(f1,f2,st2.f1) from st2 group by f1 having spread(f1) - id1 and sum(f1); + +sql_error select avg(f1),spread(f1,f2,st2.f1) from st2 group by f1 having spread(f1) > id1 and sum(f1); + +sql_error select avg(f1),spread(f1,f2,st2.f1) from st2 group by f1 having spread(f1) > id1 and sum(f1) > 1; + +sql select avg(f1),spread(f1,f2,st2.f1) from st2 group by f1 having spread(f1) > 2 and sum(f1) > 1; +if $rows != 0 then + return -1 +endi + +sql select avg(f1),spread(f1,f2,st2.f1) from st2 group by f1 having spread(f1) = 0 and sum(f1) > 1; +if $rows != 4 then + return -1 +endi +if $data00 != 1.000000000 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data10 != 2.000000000 then + return -1 +endi +if $data11 != 0.000000000 then + return -1 +endi +if $data12 != 0.000000000 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi +if $data20 != 3.000000000 then + return -1 +endi +if $data21 != 0.000000000 then + return -1 +endi +if $data22 != 0.000000000 then + return -1 +endi +if $data23 != 0.000000000 then + return -1 +endi +if $data30 != 4.000000000 then + return -1 +endi +if $data31 != 0.000000000 then + return -1 +endi +if $data32 != 0.000000000 then + return -1 +endi +if $data33 != 0.000000000 then + return -1 +endi + +sql select avg(f1),spread(f1,f2,st2.f1) from st2 group by f1 having spread(f1) = 0 and avg(f1) > 1; +if $rows != 3 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data10 != 3.000000000 then + return -1 +endi +if $data11 != 0.000000000 then + return -1 +endi +if $data12 != 0.000000000 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi +if $data20 != 4.000000000 then + return -1 +endi +if $data21 != 0.000000000 then + return -1 +endi +if $data22 != 0.000000000 then + return -1 +endi +if $data23 != 0.000000000 then + return -1 +endi + +sql_error select avg(f1),spread(f1,f2,st2.f1) from st2 group by c1 having spread(f1) = 0 and avg(f1) > 1; + +sql_error select avg(f1),spread(f1,f2,st2.f1) from st2 group by id1 having avg(id1) > 0; + +sql_error select avg(f1),spread(f1,f2,st2.f1) from st2 group by id1 having avg(f1) > id1; + +sql_error select avg(f1),spread(f1,f2,st2.f1),avg(id1) from st2 group by id1 having avg(f1) > id1; + +sql select avg(f1),spread(f1,f2,st2.f1) from st2 group by id1 having avg(f1) > 0; +if $rows != 1 then + return -1 +endi +if $data00 != 2.500000000 then + return -1 +endi +if $data01 != 3.000000000 then + return -1 +endi +if $data02 != 3.000000000 then + return -1 +endi +if $data03 != 3.000000000 then + return -1 +endi +if $data04 != 1 then + return -1 +endi + +sql select avg(f1),spread(f1,f2,st2.f1) from st2 group by id1 having avg(f1) < 2; +if $rows != 0 then + return -1 +endi + +sql select avg(f1),spread(f1,f2,st2.f1) from st2 where f1 > 0 group by f1 having avg(f1) > 0; +if $rows != 4 then + return -1 +endi +if $data00 != 1.000000000 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data10 != 2.000000000 then + return -1 +endi +if $data11 != 0.000000000 then + return -1 +endi +if $data12 != 0.000000000 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi +if $data20 != 3.000000000 then + return -1 +endi +if $data21 != 0.000000000 then + return -1 +endi +if $data22 != 0.000000000 then + return -1 +endi +if $data23 != 0.000000000 then + return -1 +endi +if $data30 != 4.000000000 then + return -1 +endi +if $data31 != 0.000000000 then + return -1 +endi +if $data32 != 0.000000000 then + return -1 +endi +if $data33 != 0.000000000 then + return -1 +endi + +sql select avg(f1),spread(f1,f2,st2.f1) from st2 where f1 > 2 group by f1 having avg(f1) > 0; +if $rows != 2 then + return -1 +endi +if $data00 != 3.000000000 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data10 != 4.000000000 then + return -1 +endi +if $data11 != 0.000000000 then + return -1 +endi +if $data12 != 0.000000000 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi + +sql select avg(f1),spread(f1,f2,st2.f1) from st2 where f2 > 2 group by f1 having avg(f1) > 0; +if $rows != 2 then + return -1 +endi +if $data00 != 3.000000000 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data10 != 4.000000000 then + return -1 +endi +if $data11 != 0.000000000 then + return -1 +endi +if $data12 != 0.000000000 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi + +sql select avg(f1),spread(f1,f2,st2.f1) from st2 where f3 > 2 group by f1 having avg(f1) > 0; +if $rows != 2 then + return -1 +endi +if $data00 != 3.000000000 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data10 != 4.000000000 then + return -1 +endi +if $data11 != 0.000000000 then + return -1 +endi +if $data12 != 0.000000000 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi + +sql select avg(f1),spread(f1,f2,st2.f1) from st2 where f2 > 3 group by f1 having avg(f1) > 0; +if $rows != 1 then + return -1 +endi +if $data00 != 4.000000000 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi + +sql_error select avg(f1),spread(f1,f2,st2.f1) from st2 where f2 > 3 group by f1 having avg(ts) > 0; + +sql_error select avg(f1),spread(f1,f2,st2.f1) from st2 where f2 > 3 group by f1 having avg(f7) > 0; + +sql_error select avg(f1),spread(f1,f2,st2.f1) from st2 where f2 > 3 group by f1 having avg(f8) > 0; + +sql_error select avg(f1),spread(f1,f2,st2.f1) from st2 where f2 > 3 group by f1 having avg(f9) > 0; + +sql select avg(f1),spread(f1,f2,st2.f1) from st2 where f2 > 3 group by f1 having count(f9) > 0; +if $rows != 1 then + return -1 +endi +if $data00 != 4.000000000 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi + +sql_error select avg(f1),spread(f1,f2,st2.f1) from st2 where f2 > 3 group by f1 having last(f9) > 0; + +sql select avg(f1),spread(f1,f2,st2.f1) from st2 where f2 > 3 group by f1 having last(f2) > 0; +if $rows != 1 then + return -1 +endi +if $data00 != 4.000000000 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi + +sql select avg(f1),spread(f1,f2,st2.f1) from st2 where f2 > 3 group by f1 having last(f3) > 0; +if $rows != 1 then + return -1 +endi +if $data00 != 4.000000000 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi + +sql select avg(f1),spread(f1,f2,st2.f1) from st2 where f2 > 1 group by f1 having last(f3) > 0; +if $rows != 3 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data10 != 3.000000000 then + return -1 +endi +if $data11 != 0.000000000 then + return -1 +endi +if $data12 != 0.000000000 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi +if $data20 != 4.000000000 then + return -1 +endi +if $data21 != 0.000000000 then + return -1 +endi +if $data22 != 0.000000000 then + return -1 +endi +if $data23 != 0.000000000 then + return -1 +endi + +sql select avg(f1),spread(f1,f2,st2.f1) from st2 where f2 > 1 group by f1 having last(f4) > 0; +if $rows != 3 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data10 != 3.000000000 then + return -1 +endi +if $data11 != 0.000000000 then + return -1 +endi +if $data12 != 0.000000000 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi +if $data20 != 4.000000000 then + return -1 +endi +if $data21 != 0.000000000 then + return -1 +endi +if $data22 != 0.000000000 then + return -1 +endi +if $data23 != 0.000000000 then + return -1 +endi + +sql select avg(f1),spread(f1,f2,st2.f1) from st2 where f2 > 1 group by f1 having last(f5) > 0; +if $rows != 3 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data10 != 3.000000000 then + return -1 +endi +if $data11 != 0.000000000 then + return -1 +endi +if $data12 != 0.000000000 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi +if $data20 != 4.000000000 then + return -1 +endi +if $data21 != 0.000000000 then + return -1 +endi +if $data22 != 0.000000000 then + return -1 +endi +if $data23 != 0.000000000 then + return -1 +endi + +sql select avg(f1),spread(f1,f2,st2.f1) from st2 where f2 > 1 group by f1 having last(f6) > 0; +if $rows != 3 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data10 != 3.000000000 then + return -1 +endi +if $data11 != 0.000000000 then + return -1 +endi +if $data12 != 0.000000000 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi +if $data20 != 4.000000000 then + return -1 +endi +if $data21 != 0.000000000 then + return -1 +endi +if $data22 != 0.000000000 then + return -1 +endi +if $data23 != 0.000000000 then + return -1 +endi + + +sql_error select avg(f1),spread(f1,f2,st2.f1),f1,f2 from st2 where f2 > 1 group by f1 having last(f6) > 0; + +sql_error select avg(f1),spread(f1,f2,st2.f1),f1,f6 from st2 where f2 > 1 group by f1 having last(f6) > 0; + +sql_error select avg(f1),spread(f1,f2,st2.f1),f1,f6 from st2 where f2 > 1 group by f1,f2 having last(f6) > 0; + +sql_error select avg(f1),spread(f1,f2,st2.f1),f1,f6 from st2 where f2 > 1 group by f1,id1 having last(f6) > 0; + +sql_error select avg(f1),spread(f1,f2,st2.f1),f1,f6 from st2 where f2 > 1 group by id1 having last(f6) > 0; + +sql select avg(f1),spread(f1,f2,st2.f1) from st2 where f2 > 1 group by id1 having last(f6) > 0; +if $rows != 1 then + return -1 +endi +if $data00 != 3.000000000 then + return -1 +endi +if $data01 != 2.000000000 then + return -1 +endi +if $data02 != 2.000000000 then + return -1 +endi +if $data03 != 2.000000000 then + return -1 +endi +if $data04 != 1 then + return -1 +endi + +sql_error select top(f1,2) from tb1 group by f1 having count(f1) > 0; +sql_error select count(*) from tb1 group by f1 having last(*) > 0; + +print bug for select count(*) k from tb1 group by f1 having k > 0; + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/having_child.sim b/tests/script/general/parser/having_child.sim new file mode 100644 index 0000000000000000000000000000000000000000..0fe5448869a5720a62550a88981114e737e4965b --- /dev/null +++ b/tests/script/general/parser/having_child.sim @@ -0,0 +1,1860 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2 +system sh/exec.sh -n dnode1 -s start + +sleep 100 +sql connect +print ======================== dnode1 start + +$db = testdb + +sql create database $db +sql use $db + +sql create stable st2 (ts timestamp, f1 int, f2 float, f3 double, f4 bigint, f5 smallint, f6 tinyint, f7 bool, f8 binary(10), f9 nchar(10)) tags (id1 int, id2 float, id3 nchar(10), id4 double, id5 smallint, id6 bigint, id7 binary(10)) + +sql create table tb1 using st2 tags (1,1.0,"1",1.0,1,1,"1"); +sql create table tb2 using st2 tags (2,2.0,"2",2.0,2,2,"2"); +sql create table tb3 using st2 tags (3,3.0,"3",3.0,3,3,"3"); +sql create table tb4 using st2 tags (4,4.0,"4",4.0,4,4,"4"); + +sql insert into tb1 values (now-200s,1,1.0,1.0,1,1,1,true ,"1","1") +sql insert into tb1 values (now-150s,1,1.0,1.0,1,1,1,false,"1","1") +sql insert into tb1 values (now-100s,2,2.0,2.0,2,2,2,true ,"2","2") +sql insert into tb1 values (now-50s ,2,2.0,2.0,2,2,2,false,"2","2") +sql insert into tb1 values (now ,3,3.0,3.0,3,3,3,true ,"3","3") +sql insert into tb1 values (now+50s ,3,3.0,3.0,3,3,3,false,"3","3") +sql insert into tb1 values (now+100s,4,4.0,4.0,4,4,4,true ,"4","4") +sql insert into tb1 values (now+150s,4,4.0,4.0,4,4,4,false,"4","4") + + +sql select count(*),f1 from tb1 group by f1 having count(f1) > 0; +if $rows != 4 then + return -1 +endi +if $data00 != 2 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != 2 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data21 != 3 then + return -1 +endi +if $data30 != 2 then + return -1 +endi +if $data31 != 4 then + return -1 +endi + + +sql select count(*),f1 from tb1 group by f1 having count(*) > 0; +if $rows != 4 then + return -1 +endi +if $data00 != 2 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != 2 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data21 != 3 then + return -1 +endi +if $data30 != 2 then + return -1 +endi +if $data31 != 4 then + return -1 +endi + + +sql select count(*),f1 from tb1 group by f1 having count(f2) > 0; +if $rows != 4 then + return -1 +endi +if $data00 != 2 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != 2 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data21 != 3 then + return -1 +endi +if $data30 != 2 then + return -1 +endi +if $data31 != 4 then + return -1 +endi + +sql_error select top(f1,2) from tb1 group by f1 having count(f2) > 0; + +sql select last(f1) from tb1 group by f1 having count(f2) > 0; +if $rows != 4 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 2 then + return -1 +endi +if $data20 != 3 then + return -1 +endi +if $data30 != 4 then + return -1 +endi + +sql_error select top(f1,2) from tb1 group by f1 having count(f2) > 0; + +sql_error select top(f1,2) from tb1 group by f1 having count(f2) > 0; + +sql_error select top(f1,2) from tb1 group by f1 having avg(f1) > 0; + +sql select avg(f1),count(f1) from tb1 group by f1 having avg(f1) > 2; +if $rows != 2 then + return -1 +endi +if $data00 != 3.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data10 != 4.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi + + +sql select avg(f1),count(f1) from tb1 group by f1 having avg(f1) > 2 and sum(f1) > 0; +if $rows != 2 then + return -1 +endi +if $data00 != 3.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data10 != 4.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi + +sql select avg(f1),count(f1),sum(f1) from tb1 group by f1 having avg(f1) > 2 and sum(f1) > 0; +if $rows != 2 then + return -1 +endi +if $data00 != 3.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 6 then + return -1 +endi +if $data10 != 4.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 8 then + return -1 +endi + +sql select avg(f1),count(f1),sum(f1) from tb1 group by f1 having avg(f1) > 2; +if $rows != 2 then + return -1 +endi +if $data00 != 3.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 6 then + return -1 +endi +if $data10 != 4.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 8 then + return -1 +endi + +sql select avg(f1),count(f1),sum(f1) from tb1 group by f1 having sum(f1) > 0; +if $rows != 4 then + return -1 +endi +if $data00 != 1.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 2 then + return -1 +endi +if $data10 != 2.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 4 then + return -1 +endi +if $data20 != 3.000000000 then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data22 != 6 then + return -1 +endi +if $data30 != 4.000000000 then + return -1 +endi +if $data31 != 2 then + return -1 +endi +if $data32 != 8 then + return -1 +endi + +sql select avg(f1),count(f1),sum(f1) from tb1 group by f1 having sum(f1) > 2 and sum(f1) < 6; +if $rows != 1 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 4 then + return -1 +endi + + +sql select avg(f1),count(f1),sum(f1) from tb1 group by f1 having 1 <= sum(f1) and 5 >= sum(f1); +if $rows != 2 then + return -1 +endi +if $data00 != 1.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 2 then + return -1 +endi +if $data10 != 2.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 4 then + return -1 +endi + +sql_error select avg(f1),count(f1),sum(f1),twa(f1) from tb1 group by tbname having twa(f1) > 0; + +sql_error select avg(f1),count(f1),sum(f1),twa(f1) from tb1 group by f1 having twa(f1) > 3; + +sql_error select avg(f1),count(f1),sum(f1),twa(f1) from tb1 group by tbname having sum(f1) > 0; + +sql_error select avg(f1),count(f1),sum(f1),twa(f1) from tb1 group by f1 having sum(f1) = 4; + +sql select avg(f1),count(f1),sum(f1) from tb1 group by f1 having sum(f1) > 0; +if $rows != 4 then + return -1 +endi +if $data00 != 1.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 2 then + return -1 +endi +if $data10 != 2.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 4 then + return -1 +endi +if $data20 != 3.000000000 then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data22 != 6 then + return -1 +endi +if $data30 != 4.000000000 then + return -1 +endi +if $data31 != 2 then + return -1 +endi +if $data32 != 8 then + return -1 +endi + +sql select avg(f1),count(f1),sum(f1) from tb1 group by f1 having sum(f1) > 3; +if $rows != 3 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data10 != 3.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 6 then + return -1 +endi +if $data20 != 4.000000000 then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data22 != 8 then + return -1 +endi + +###########and issue +sql select avg(f1),count(f1),sum(f1) from tb1 group by f1 having sum(f1) > 3 and sum(f1) > 1; +if $rows != 4 then + return -1 +endi +if $data00 != 1.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 2 then + return -1 +endi +if $data10 != 2.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 4 then + return -1 +endi +if $data20 != 3.000000000 then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data22 != 6 then + return -1 +endi +if $data30 != 4.000000000 then + return -1 +endi +if $data31 != 2 then + return -1 +endi +if $data32 != 8 then + return -1 +endi + + +sql select avg(f1),count(f1),sum(f1) from tb1 group by f1 having sum(f1) > 3 or sum(f1) > 1; +if $rows != 4 then + return -1 +endi +if $data00 != 1.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 2 then + return -1 +endi +if $data10 != 2.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 4 then + return -1 +endi +if $data20 != 3.000000000 then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data22 != 6 then + return -1 +endi +if $data30 != 4.000000000 then + return -1 +endi +if $data31 != 2 then + return -1 +endi +if $data32 != 8 then + return -1 +endi + +sql select avg(f1),count(f1),sum(f1) from tb1 group by f1 having sum(f1) > 3 or sum(f1) > 4; +if $rows != 3 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data10 != 3.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 6 then + return -1 +endi +if $data20 != 4.000000000 then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data22 != 8 then + return -1 +endi + +############or issue +sql select avg(f1),count(f1),sum(f1) from tb1 group by f1 having sum(f1) > 3 or avg(f1) > 4; +if $rows != 0 then + return -1 +endi + +sql select avg(f1),count(f1),sum(f1) from tb1 group by f1 having (sum(f1) > 3); +if $rows != 3 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data10 != 3.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 6 then + return -1 +endi +if $data20 != 4.000000000 then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data22 != 8 then + return -1 +endi + +sql_error select avg(f1),count(f1),sum(f1) from tb1 group by f1 having (sum(*) > 3); + +sql select avg(f1),count(f1),sum(f1) from tb1 group by f1 having (sum(tb1.f1) > 3); +if $rows != 3 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data10 != 3.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 6 then + return -1 +endi +if $data20 != 4.000000000 then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data22 != 8 then + return -1 +endi + +sql select avg(f1),count(tb1.*),sum(f1) from tb1 group by f1 having (sum(tb1.f1) > 3); +if $rows != 3 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data10 != 3.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 6 then + return -1 +endi +if $data20 != 4.000000000 then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data22 != 8 then + return -1 +endi + +sql select avg(f1),count(tb1.*),sum(f1),stddev(f1),stddev(f1) from tb1 group by f1; +if $rows != 4 then + return -1 +endi +if $data00 != 1.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 2 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data04 != 0.000000000 then + return -1 +endi +if $data10 != 2.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 4 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi +if $data14 != 0.000000000 then + return -1 +endi +if $data20 != 3.000000000 then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data22 != 6 then + return -1 +endi +if $data23 != 0.000000000 then + return -1 +endi +if $data24 != 0.000000000 then + return -1 +endi +if $data30 != 4.000000000 then + return -1 +endi +if $data31 != 2 then + return -1 +endi +if $data32 != 8 then + return -1 +endi +if $data33 != 0.000000000 then + return -1 +endi +if $data34 != 0.000000000 then + return -1 +endi + +sql select avg(f1),count(tb1.*),sum(f1),stddev(f1) from tb1 group by f1 having (stddev(tb1.f1) > 3); +if $rows != 0 then + return -1 +endi + +sql select avg(f1),count(tb1.*),sum(f1),stddev(f1) from tb1 group by f1 having (stddev(tb1.f1) < 1); +if $rows != 4 then + return -1 +endi +if $data00 != 1.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 2 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data10 != 2.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 4 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi +if $data20 != 3.000000000 then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data22 != 6 then + return -1 +endi +if $data23 != 0.000000000 then + return -1 +endi +if $data30 != 4.000000000 then + return -1 +endi +if $data31 != 2 then + return -1 +endi +if $data32 != 8 then + return -1 +endi +if $data33 != 0.000000000 then + return -1 +endi + + +sql_error select avg(f1),count(tb1.*),sum(f1),stddev(f1) from tb1 group by f1 having (LEASTSQUARES(f1) < 1); + +sql_error select avg(f1),count(tb1.*),sum(f1),stddev(f1) from tb1 group by f1 having LEASTSQUARES(f1) < 1; + +sql_error select avg(f1),count(tb1.*),sum(f1),stddev(f1) from tb1 group by f1 having LEASTSQUARES(f1,1,1) < 1; + +sql_error select avg(f1),count(tb1.*),sum(f1),stddev(f1) from tb1 group by f1 having LEASTSQUARES(f1,1,1) > 2; + +sql_error select avg(f1),count(tb1.*),sum(f1),stddev(f1),LEASTSQUARES(f1,1,1) from tb1 group by f1 having LEASTSQUARES(f1,1,1) > 2; + +sql select avg(f1),count(tb1.*),sum(f1),stddev(f1),LEASTSQUARES(f1,1,1) from tb1 group by f1 having sum(f1) > 2; +if $rows != 3 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data10 != 3.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 6 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi +if $data20 != 4.000000000 then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data22 != 8 then + return -1 +endi +if $data23 != 0.000000000 then + return -1 +endi + +sql select avg(f1),count(tb1.*),sum(f1),stddev(f1) from tb1 group by f1 having min(f1) > 2; +if $rows != 2 then + return -1 +endi +if $data00 != 3.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 6 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data10 != 4.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 8 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi + +sql select avg(f1),count(tb1.*),sum(f1),stddev(f1),min(f1) from tb1 group by f1 having min(f1) > 2; +if $rows != 2 then + return -1 +endi +if $data00 != 3.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 6 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data10 != 4.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 8 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi +if $data14 != 4 then + return -1 +endi + +sql select avg(f1),count(tb1.*),sum(f1),stddev(f1),min(f1) from tb1 group by f1 having max(f1) > 2; +if $rows != 2 then + return -1 +endi +if $data00 != 3.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 6 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data10 != 4.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 8 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi +if $data14 != 4 then + return -1 +endi + +sql select avg(f1),count(tb1.*),sum(f1),stddev(f1),min(f1),max(f1) from tb1 group by f1 having max(f1) != 2; +if $rows != 3 then + return -1 +endi +if $data00 != 1.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 2 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data04 != 1 then + return -1 +endi +if $data05 != 1 then + return -1 +endi +if $data10 != 3.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 6 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi +if $data14 != 3 then + return -1 +endi +if $data15 != 3 then + return -1 +endi +if $data20 != 4.000000000 then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data22 != 8 then + return -1 +endi +if $data23 != 0.000000000 then + return -1 +endi +if $data24 != 4 then + return -1 +endi +if $data25 != 4 then + return -1 +endi + +sql select avg(f1),count(tb1.*),sum(f1),stddev(f1),min(f1),max(f1) from tb1 group by f1 having first(f1) != 2; +if $rows != 3 then + return -1 +endi +if $data00 != 1.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 2 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data04 != 1 then + return -1 +endi +if $data05 != 1 then + return -1 +endi +if $data10 != 3.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 6 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi +if $data14 != 3 then + return -1 +endi +if $data15 != 3 then + return -1 +endi +if $data20 != 4.000000000 then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data22 != 8 then + return -1 +endi +if $data23 != 0.000000000 then + return -1 +endi +if $data24 != 4 then + return -1 +endi +if $data25 != 4 then + return -1 +endi + + + +sql select avg(f1),count(tb1.*),sum(f1),stddev(f1),min(f1),max(f1),first(f1) from tb1 group by f1 having first(f1) != 2; +if $rows != 3 then + return -1 +endi +if $data00 != 1.000000000 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 2 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data04 != 1 then + return -1 +endi +if $data05 != 1 then + return -1 +endi +if $data06 != 1 then + return -1 +endi +if $data10 != 3.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 6 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi +if $data14 != 3 then + return -1 +endi +if $data15 != 3 then + return -1 +endi +if $data16 != 3 then + return -1 +endi +if $data20 != 4.000000000 then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data22 != 8 then + return -1 +endi +if $data23 != 0.000000000 then + return -1 +endi +if $data24 != 4 then + return -1 +endi +if $data25 != 4 then + return -1 +endi +if $data26 != 4 then + return -1 +endi + + + +sql_error select avg(f1),count(tb1.*),sum(f1),stddev(f1),min(f1),max(f1),first(f1),last(f1) from tb1 group by f1 having top(f1,1); + +sql_error select avg(f1),count(tb1.*),sum(f1),stddev(f1),min(f1),max(f1),first(f1),last(f1) from tb1 group by f1 having top(f1,1) > 1; + +sql_error select avg(f1),count(tb1.*),sum(f1),stddev(f1),min(f1),max(f1),first(f1),last(f1) from tb1 group by f1 having bottom(f1,1) > 1; + +sql_error select avg(f1),count(tb1.*),sum(f1),stddev(f1),min(f1),max(f1),first(f1),last(f1),top(f1,1),bottom(f1,1) from tb1 group by f1 having bottom(f1,1) > 1; + +sql_error select avg(f1),count(tb1.*),sum(f1),stddev(f1),min(f1),max(f1),first(f1),last(f1),top(f1,1),bottom(f1,1) from tb1 group by f1 having sum(f1) > 1; + +sql_error select PERCENTILE(f1) from tb1 group by f1 having sum(f1) > 1; + +sql select PERCENTILE(f1,20) from tb1 group by f1 having sum(f1) = 4; +if $rows != 1 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi + +sql select aPERCENTILE(f1,20) from tb1 group by f1 having sum(f1) > 1; +if $rows != 4 then + return -1 +endi +if $data00 != 1.000000000 then + return -1 +endi +if $data10 != 2.000000000 then + return -1 +endi +if $data20 != 3.000000000 then + return -1 +endi +if $data30 != 4.000000000 then + return -1 +endi + +sql select aPERCENTILE(f1,20) from tb1 group by f1 having apercentile(f1,1) > 1; +if $rows != 3 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi +if $data10 != 3.000000000 then + return -1 +endi +if $data20 != 4.000000000 then + return -1 +endi + +sql select aPERCENTILE(f1,20) from tb1 group by f1 having apercentile(f1,1) > 1 and apercentile(f1,1) < 50; +if $rows != 3 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi +if $data10 != 3.000000000 then + return -1 +endi +if $data20 != 4.000000000 then + return -1 +endi + +sql select aPERCENTILE(f1,20) from tb1 group by f1 having apercentile(f1,1) > 1 and apercentile(f1,1) < 3; +if $rows != 1 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi + +sql select aPERCENTILE(f1,20) from tb1 group by f1 having apercentile(f1,1) > 1 and apercentile(f1,3) < 3; +if $rows != 1 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi + +sql_error select aPERCENTILE(f1,20) from tb1 group by f1 having apercentile(1) > 1; + +sql_error select aPERCENTILE(f1,20),LAST_ROW(f1) from tb1 group by f1 having apercentile(1) > 1; + +sql_error select aPERCENTILE(f1,20),LAST_ROW(f1) from tb1 group by f1 having apercentile(f1,1) > 1; + +sql_error select sum(f1) from tb1 group by f1 having last_row(f1) > 1; + +sql_error select avg(f1) from tb1 group by f1 having diff(f1) > 0; + +sql_error select avg(f1),diff(f1) from tb1 group by f1 having avg(f1) > 0; + +sql_error select avg(f1),diff(f1) from tb1 group by f1 having spread(f2) > 0; + +sql select avg(f1) from tb1 group by f1 having spread(f2) > 0; +if $rows != 0 then + return -1 +endi + +sql select avg(f1) from tb1 group by f1 having spread(f2) = 0; +if $rows != 4 then + return -1 +endi +if $data00 != 1.000000000 then + return -1 +endi +if $data10 != 2.000000000 then + return -1 +endi +if $data20 != 3.000000000 then + return -1 +endi +if $data30 != 4.000000000 then + return -1 +endi + +sql select avg(f1),spread(f2) from tb1 group by f1; +if $rows != 4 then + return -1 +endi +if $data00 != 1.000000000 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data10 != 2.000000000 then + return -1 +endi +if $data11 != 0.000000000 then + return -1 +endi +if $data20 != 3.000000000 then + return -1 +endi +if $data21 != 0.000000000 then + return -1 +endi +if $data30 != 4.000000000 then + return -1 +endi +if $data31 != 0.000000000 then + return -1 +endi + +sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) = 0; +if $rows != 4 then + return -1 +endi +if $data00 != 1.000000000 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data10 != 2.000000000 then + return -1 +endi +if $data11 != 0.000000000 then + return -1 +endi +if $data12 != 0.000000000 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi +if $data20 != 3.000000000 then + return -1 +endi +if $data21 != 0.000000000 then + return -1 +endi +if $data22 != 0.000000000 then + return -1 +endi +if $data23 != 0.000000000 then + return -1 +endi +if $data30 != 4.000000000 then + return -1 +endi +if $data31 != 0.000000000 then + return -1 +endi +if $data32 != 0.000000000 then + return -1 +endi +if $data33 != 0.000000000 then + return -1 +endi + +sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) != 0; +if $rows != 0 then + return -1 +endi + + +sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) + 1 > 0; + +sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) + 1; + +sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) + sum(f1); + +sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) + sum(f1) > 0; + +sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) - sum(f1) > 0; + +sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) * sum(f1) > 0; + +sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) / sum(f1) > 0; + +sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) > sum(f1); + +sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) and sum(f1); + +sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) 0 and sum(f1); + +sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) + 0 and sum(f1); + +sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) - f1 and sum(f1); + +sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) - id1 and sum(f1); + +sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) > id1 and sum(f1); + +sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) > id1 and sum(f1) > 1; + +sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) > 2 and sum(f1) > 1; +if $rows != 0 then + return -1 +endi + +sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) = 0 and sum(f1) > 1; +if $rows != 4 then + return -1 +endi +if $data00 != 1.000000000 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data10 != 2.000000000 then + return -1 +endi +if $data11 != 0.000000000 then + return -1 +endi +if $data12 != 0.000000000 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi +if $data20 != 3.000000000 then + return -1 +endi +if $data21 != 0.000000000 then + return -1 +endi +if $data22 != 0.000000000 then + return -1 +endi +if $data23 != 0.000000000 then + return -1 +endi +if $data30 != 4.000000000 then + return -1 +endi +if $data31 != 0.000000000 then + return -1 +endi +if $data32 != 0.000000000 then + return -1 +endi +if $data33 != 0.000000000 then + return -1 +endi + +sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) = 0 and avg(f1) > 1; +if $rows != 3 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data10 != 3.000000000 then + return -1 +endi +if $data11 != 0.000000000 then + return -1 +endi +if $data12 != 0.000000000 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi +if $data20 != 4.000000000 then + return -1 +endi +if $data21 != 0.000000000 then + return -1 +endi +if $data22 != 0.000000000 then + return -1 +endi +if $data23 != 0.000000000 then + return -1 +endi + +sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by c1 having spread(f1) = 0 and avg(f1) > 1; + +sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by id1 having avg(id1) > 0; + +sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by id1 having avg(f1) > id1; + +sql_error select avg(f1),spread(f1,f2,tb1.f1),avg(id1) from tb1 group by id1 having avg(f1) > id1; + +sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by id1 having avg(f1) > 0; + +sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having avg(f1) > 0 and avg(f1) = 3; +if $rows != 1 then + return -1 +endi +if $data00 != 3.000000000 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi + +#sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having avg(f1) < 0 and avg(f1) = 3; +sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by id1 having avg(f1) < 2; + +sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f1 > 0 group by f1 having avg(f1) > 0; +if $rows != 4 then + return -1 +endi +if $data00 != 1.000000000 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data10 != 2.000000000 then + return -1 +endi +if $data11 != 0.000000000 then + return -1 +endi +if $data12 != 0.000000000 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi +if $data20 != 3.000000000 then + return -1 +endi +if $data21 != 0.000000000 then + return -1 +endi +if $data22 != 0.000000000 then + return -1 +endi +if $data23 != 0.000000000 then + return -1 +endi +if $data30 != 4.000000000 then + return -1 +endi +if $data31 != 0.000000000 then + return -1 +endi +if $data32 != 0.000000000 then + return -1 +endi +if $data33 != 0.000000000 then + return -1 +endi + +sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f1 > 2 group by f1 having avg(f1) > 0; +if $rows != 2 then + return -1 +endi +if $data00 != 3.000000000 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data10 != 4.000000000 then + return -1 +endi +if $data11 != 0.000000000 then + return -1 +endi +if $data12 != 0.000000000 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi + +sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f2 > 2 group by f1 having avg(f1) > 0; +if $rows != 2 then + return -1 +endi +if $data00 != 3.000000000 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data10 != 4.000000000 then + return -1 +endi +if $data11 != 0.000000000 then + return -1 +endi +if $data12 != 0.000000000 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi + +sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f3 > 2 group by f1 having avg(f1) > 0; +if $rows != 2 then + return -1 +endi +if $data00 != 3.000000000 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data10 != 4.000000000 then + return -1 +endi +if $data11 != 0.000000000 then + return -1 +endi +if $data12 != 0.000000000 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi + +sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f2 > 3 group by f1 having avg(f1) > 0; +if $rows != 1 then + return -1 +endi +if $data00 != 4.000000000 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi + +sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f2 > 3 group by f1 having avg(ts) > 0; + +sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f2 > 3 group by f1 having avg(f7) > 0; + +sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f2 > 3 group by f1 having avg(f8) > 0; + +sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f2 > 3 group by f1 having avg(f9) > 0; + +sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f2 > 3 group by f1 having count(f9) > 0; +if $rows != 1 then + return -1 +endi +if $data00 != 4.000000000 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi + +sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f2 > 3 group by f1 having last(f9) > 0; + +sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f2 > 3 group by f1 having last(f2) > 0; +if $rows != 1 then + return -1 +endi +if $data00 != 4.000000000 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi + +sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f2 > 3 group by f1 having last(f3) > 0; +if $rows != 1 then + return -1 +endi +if $data00 != 4.000000000 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi + +sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f2 > 1 group by f1 having last(f3) > 0; +if $rows != 3 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data10 != 3.000000000 then + return -1 +endi +if $data11 != 0.000000000 then + return -1 +endi +if $data12 != 0.000000000 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi +if $data20 != 4.000000000 then + return -1 +endi +if $data21 != 0.000000000 then + return -1 +endi +if $data22 != 0.000000000 then + return -1 +endi +if $data23 != 0.000000000 then + return -1 +endi + +sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f2 > 1 group by f1 having last(f4) > 0; +if $rows != 3 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data10 != 3.000000000 then + return -1 +endi +if $data11 != 0.000000000 then + return -1 +endi +if $data12 != 0.000000000 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi +if $data20 != 4.000000000 then + return -1 +endi +if $data21 != 0.000000000 then + return -1 +endi +if $data22 != 0.000000000 then + return -1 +endi +if $data23 != 0.000000000 then + return -1 +endi + +sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f2 > 1 group by f1 having last(f5) > 0; +if $rows != 3 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data10 != 3.000000000 then + return -1 +endi +if $data11 != 0.000000000 then + return -1 +endi +if $data12 != 0.000000000 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi +if $data20 != 4.000000000 then + return -1 +endi +if $data21 != 0.000000000 then + return -1 +endi +if $data22 != 0.000000000 then + return -1 +endi +if $data23 != 0.000000000 then + return -1 +endi + +sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f2 > 1 group by f1 having last(f6) > 0; +if $rows != 3 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data10 != 3.000000000 then + return -1 +endi +if $data11 != 0.000000000 then + return -1 +endi +if $data12 != 0.000000000 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi +if $data20 != 4.000000000 then + return -1 +endi +if $data21 != 0.000000000 then + return -1 +endi +if $data22 != 0.000000000 then + return -1 +endi +if $data23 != 0.000000000 then + return -1 +endi + + +sql_error select avg(f1),spread(f1,f2,tb1.f1),f1,f2 from tb1 where f2 > 1 group by f1 having last(f6) > 0; + +sql_error select avg(f1),spread(f1,f2,tb1.f1),f1,f6 from tb1 where f2 > 1 group by f1 having last(f6) > 0; + +sql_error select avg(f1),spread(f1,f2,tb1.f1),f1,f6 from tb1 where f2 > 1 group by f1,f2 having last(f6) > 0; + +sql_error select avg(f1),spread(f1,f2,tb1.f1),f1,f6 from tb1 where f2 > 1 group by f1,id1 having last(f6) > 0; + +sql_error select avg(f1),spread(f1,f2,tb1.f1),f1,f6 from tb1 where f2 > 1 group by id1 having last(f6) > 0; + +sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f2 > 1 and f2 < 4 group by f1 having last(f6) > 0; +if $rows != 2 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 0.000000000 then + return -1 +endi +if $data10 != 3.000000000 then + return -1 +endi +if $data11 != 0.000000000 then + return -1 +endi +if $data12 != 0.000000000 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi + +sql_error select top(f1,2) from tb1 group by f1 having count(f1) > 0; + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/import.sim b/tests/script/general/parser/import.sim new file mode 100644 index 0000000000000000000000000000000000000000..4468ab87a923fc65eeb22eff97dc7d56bfdc7dc9 --- /dev/null +++ b/tests/script/general/parser/import.sim @@ -0,0 +1,91 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = impt_db +$tbPrefix = tb +$stbPrefix = stb +$tbNum = 10 +$rowNum = 10 +$totalNum = $tbNum * $rowNum +print ========== import.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +print ====== create tables +sql use $db +sql create table tb (ts timestamp, c1 int, c2 timestamp) +sql insert into tb values ('2019-05-05 11:30:00.000', 1, now) +sql insert into tb values ('2019-05-05 12:00:00.000', 1, now) +sleep 500 +sql import into tb values ('2019-05-05 11:00:00.000', -1, now) +sleep 500 +sql import into tb values ('2019-05-05 11:59:00.000', -1, now) +sleep 500 +sql import into tb values ('2019-05-04 08:00:00.000', -1, now) +sleep 500 +sql import into tb values ('2019-05-04 07:59:00.000', -1, now) +sleep 500 + +sql select * from tb +if $rows != 6 then + return -1 +endi +if $data00 != @19-05-04 07:59:00.000@ then + return -1 +endi +if $data10 != @19-05-04 08:00:00.000@ then + return -1 +endi +if $data20 != @19-05-05 11:00:00.000@ then + return -1 +endi +if $data30 != @19-05-05 11:30:00.000@ then + return -1 +endi +if $data40 != @19-05-05 11:59:00.000@ then + return -1 +endi +if $data50 != @19-05-05 12:00:00.000@ then + return -1 +endi + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 500 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed +sql connect +sleep 100 + +sql use $db +sql select * from tb +if $rows != 6 then + return -1 +endi +if $data00 != @19-05-04 07:59:00.000@ then + return -1 +endi +if $data10 != @19-05-04 08:00:00.000@ then + return -1 +endi +if $data20 != @19-05-05 11:00:00.000@ then + return -1 +endi +if $data30 != @19-05-05 11:30:00.000@ then + return -1 +endi +if $data40 != @19-05-05 11:59:00.000@ then + return -1 +endi +if $data50 != @19-05-05 12:00:00.000@ then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/parser/import_commit1.sim b/tests/script/general/parser/import_commit1.sim new file mode 100644 index 0000000000000000000000000000000000000000..f330fe4cd94b1cba82ea985b9b4841245753e099 --- /dev/null +++ b/tests/script/general/parser/import_commit1.sim @@ -0,0 +1,56 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c ctime -v 30 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = ic_db +$tbPrefix = ic_tb +$stbPrefix = ic_stb +$tbNum = 1 +#$rowNum = 166 +$rowNum = 1361 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== limit.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db cache 16 +print ====== create tables +sql use $db + +$i = 0 +$ts = $ts0 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, c1 int) +$x = 0 +while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + sql insert into $tb values ( $ts , $x ) + $x = $x + 1 +endw +print ====== tables created + +sleep 500 + +$ts = $ts0 + $delta +$ts = $ts + 1 +sql import into $tb values ( $ts , -1) +sql select count(*) from $tb +$res = $rowNum + 1 +if $data00 != $res then + print expected: $res + print returned: $rows + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/parser/import_commit2.sim b/tests/script/general/parser/import_commit2.sim new file mode 100644 index 0000000000000000000000000000000000000000..47b30acb49111da69c1c0b8b1927fd7f13f0c31c --- /dev/null +++ b/tests/script/general/parser/import_commit2.sim @@ -0,0 +1,55 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c ctime -v 30 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = ic_db +$tbPrefix = ic_tb +$stbPrefix = ic_stb +$tbNum = 1 +$rowNum = 166 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== limit.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db cache 16 +print ====== create tables +sql use $db + +$i = 0 +$ts = $ts0 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, c1 int) +$x = 0 +while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + sql insert into $tb values ( $ts , $x ) + $x = $x + 1 +endw +print ====== tables created + +sleep 500 + +$ts = $ts0 + $delta +$ts = $ts + 1 +sql import into $tb values ( $ts , -1) +sql select count(*) from $tb +$res = $rowNum + 1 +if $data00 != $res then + print expected: $res + print returned: $rows + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/parser/import_commit3.sim b/tests/script/general/parser/import_commit3.sim new file mode 100644 index 0000000000000000000000000000000000000000..1e041375de3da7fc2a5c17ae40caa1251b5d9d1b --- /dev/null +++ b/tests/script/general/parser/import_commit3.sim @@ -0,0 +1,62 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c ctime -v 30 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = ic_db +$tbPrefix = ic_tb +$stbPrefix = ic_stb +$tbNum = 1 +$rowNum = 582 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== limit.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db cache 16 +print ====== create tables +sql use $db +sql reset query cache +$i = 0 +$ts = $ts0 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, c1 int, c2 int, c3 int, c4 int, c5 int) +$x = 0 +while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + sql insert into $tb values ( $ts , $x , $x , $x , $x , $x ) + $x = $x + 1 +endw +print ====== tables created + +sleep 500 + +$ts = $ts + 1 +sql insert into $tb values ( $ts , -1, -1, -1, -1, -1) +$ts = $ts0 + $delta +$ts = $ts + 1 +sql import into $tb values ( $ts , -2, -2, -2, -2, -2) + +sleep 500 + +sql show databases + +sql select count(*) from $tb +$res = $rowNum + 2 +if $data00 != $res then + print expected: $res + print returned: $rows + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/parser/import_file.sim b/tests/script/general/parser/import_file.sim new file mode 100644 index 0000000000000000000000000000000000000000..cf11194ba7c3b805725a665c6f92d6bb465b9e4e --- /dev/null +++ b/tests/script/general/parser/import_file.sim @@ -0,0 +1,73 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 500 +sql connect +sleep 500 + +sql drop database if exists indb +sql create database if not exists indb +sql use indb + +$inFileName = '~/data.csv' +$numOfRows = 10000 +system general/parser/gendata.sh + +sql create table stbx (ts TIMESTAMP, collect_area NCHAR(12), device_id BINARY(16), imsi BINARY(16), imei BINARY(16), mdn BINARY(10), net_type BINARY(4), mno NCHAR(4), province NCHAR(10), city NCHAR(16), alarm BINARY(2)) tags(a int, b binary(12)); + +sql create table tbx (ts TIMESTAMP, collect_area NCHAR(12), device_id BINARY(16), imsi BINARY(16), imei BINARY(16), mdn BINARY(10), net_type BINARY(4), mno NCHAR(4), province NCHAR(10), city NCHAR(16), alarm BINARY(2)) +print ====== create tables success, starting import data + +sql import into tbx file '~/data.sql' +sql import into tbx file '~/data.sql' + +sql select count(*) from tbx +if $rows != 1 then + print expect 1, actual: $rows + return -1 +endi + +if $data00 != 3 then + return -1 +endi + +sql drop table tbx; + +sql insert into tbx using stbx tags(1,'abc') file '~/data.sql'; +sql insert into tbx using stbx tags(1,'abc') file '~/data.sql'; + +sql select count(*) from tbx +if $rows != 1 then + return -1 +endi + +if $data00 != 3 then + return -1 +endi + +sql drop table tbx; +sql insert into tbx using stbx(b) tags('abcf') file '~/data.sql'; + +sql select ts,a,b from tbx; +if $rows != 3 then + return -1 +endi + +if $data00 != @20-01-01 01:01:01.000@ then + print expect 20-01-01 01:01:01.000 , actual: $data00 + return -1 +endi + +if $data01 != NULL then + return -1 +endi + +if $data02 != @abcf@ then + return -1 +endi + +system rm -f ~/data.sql + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/parser/insert_multiTbl.sim b/tests/script/general/parser/insert_multiTbl.sim new file mode 100644 index 0000000000000000000000000000000000000000..b17323280eb0297fc648fc6d06b38856b7a2299e --- /dev/null +++ b/tests/script/general/parser/insert_multiTbl.sim @@ -0,0 +1,68 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 500 +sql connect +sleep 100 +print ======================== dnode1 start + +sql create database mul_db +sql use mul_db +sql create table mul_st (ts timestamp, col1 int) tags (tag1 int) + +# case: insert multiple recordes for multiple table in a query +print =========== insert_multiTbl.sim case: insert multiple records for multiple table in a query +$ts = 1500000000000 +sql insert into mul_t0 using mul_st tags(0) values ( $ts , 0) ( $ts + 1s, 1) ( $ts + 2s, 2) mul_t1 using mul_st tags(1) values ( $ts , 10) ( $ts + 1s, 11) ( $ts + 2s, 12) mul_t2 using mul_st tags(2) values ( $ts , 20) ( $ts + 1s, 21) ( $ts + 2s, 22) mul_t3 using mul_st tags(3) values ( $ts , 30) ( $ts + 1s, 31) ( $ts + 2s, 32) +sql select * from mul_st +print rows = $rows +if $rows != 12 then + return -1 +endi +if $data01 != 0 then + return -1 +endi + +sql create table mul_b0 (ts timestamp, col1 int) +sql create table mul_b1 (ts timestamp, col1 int) +sql create table mul_b2 (ts timestamp, col1 int) +sql create table mul_b3 (ts timestamp, col1 int) + +sql insert into mul_b0 values ( $ts , 0) ( $ts + 1s, 1) ( $ts + 2s, 2) mul_b1 values ( $ts , 10) ( $ts + 1s, 11) ( $ts + 2s, 12) mul_b2 values ( $ts , 20) ( $ts + 1s, 21) ( $ts + 2s, 22) mul_b3 values ( $ts , 30) ( $ts + 1s, 31) ( $ts + 2s, 32) +sql select * from mul_b3 +print rows = $rows +if $rows != 3 then + return -1 +endi +if $data01 != 30 then + return -1 +endi + +# insert values for specified columns +sql create table mul_st1 (ts timestamp, col1 int, col2 float, col3 binary(10)) tags (tag1 int, tag2 int, tag3 binary(8)) +print =========== insert values for specified columns for multiple table in a query +$ts = 1500000000000 +sql insert into mul_t10 (ts, col1, col3) using mul_st1 (tag1, tag3) tags(0, 'tag3-0') values ( $ts , 00, 'binary00') ( $ts + 1s, 01, 'binary01') ( $ts + 2s, 02, 'binary02') mul_t11 (ts, col1, col3) using mul_st1 (tag1, tag3) tags(1, 'tag3-0') values ( $ts , 10, 'binary10') ( $ts + 1s, 11, 'binary11') ( $ts + 2s, 12, 'binary12') mul_t12 (ts, col1, col3) using mul_st1 (tag1, tag3) tags(2, 'tag3-0') values ( $ts , 20, 'binary20') ( $ts + 1s, 21, 'binary21') ( $ts + 2s, 22, 'binary22') mul_t13 (ts, col1, col3) using mul_st1 (tag1, tag3) tags(3, 'tag3-0') values ( $ts , 30, 'binary30') ( $ts + 1s, 31, 'binary31') ( $ts + 2s, 32, 'binary32') + +sql select * from mul_st1 +print rows = $rows +if $rows != 12 then + return -1 +endi +if $data02 != NULL then + print "expect: NULL, act: $data03" + return -1 +endi +if $data03 != @binary00@ then + return -1 +endi +if $data92 != NULL then + return -1 +endi +if $data93 != @binary30@ then + return -1 +endi + diff --git a/tests/script/general/parser/insert_tb.sim b/tests/script/general/parser/insert_tb.sim new file mode 100644 index 0000000000000000000000000000000000000000..1e431aef3dc8355b4766abb81db6a94ee34052bf --- /dev/null +++ b/tests/script/general/parser/insert_tb.sim @@ -0,0 +1,236 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 100 +sql connect +print ======================== dnode1 start + +$dbPrefix = fi_in_db +$tbPrefix = fi_in_tb +$mtPrefix = fi_in_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print create_tb test +print =============== set up +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, col1 int, col2 bigint, col3 float, col4 double, col5 binary(20), col6 bool, col7 smallint, col8 tinyint, col9 nchar(10)) tags (tag1 int) + +# case: insert multiple records in a query +print =========== create_tb.sim case: insert multiple records in a query +$ts = 1500000000000 +$col1 = 1 +$col2 = 1 +$col3 = 1.1e3 +$col4 = 1.1e3 +$col5 = 'Binary' +$col6 = true +$col7 = 1 +$col8 = 1 +$col9 = 'Nchar' +$tag1 = 1 +sql reset query cache +sql create table $tb using $mt tags( $tag1 ) +sql insert into $tb values ( $ts , $col1 , $col2 , $col3 , $col4 , $col5 , $col6 , $col7 , $col8 , $col9 ) ( $ts + 1000a, $col1 , $col2 , $col3 , $col4 , $col5 , $col6 , $col7 , $col8 , $col9 ) +sql select * from $tb order by ts desc +print rows = $rows +if $rows != 2 then + return -1 +endi +if $data01 != $col1 then + return -1 +endi +#sql drop table $tb + +# insert values for specified columns +$col1 = 2 +$col3 = 3 +$col5 = 5 +sql create table $tb using $mt tags( $tag1 ) +sql insert into $tb ( ts, col1, col3, col5) values ( $ts + 2000a, $col1 , $col3 , $col5 ) +sql select * from $tb order by ts desc +if $rows != 3 then + return -1 +endi +if $data01 != $col1 then + return -1 +endi +print data03 = $data03 +if $data03 != 3.00000 then + return -1 +endi +if $data05 != $col5 then + return -1 +endi + +sql insert into $tb (ts, col1, col2, col3, col4, col5, col6, col7, col8, col9) values ( $ts + 3000a, $col1 , $col2 , $col3 , $col4 , $col5 , $col6 , $col7 , $col8 , $col9 ) ( $ts + 4000a, $col1 , $col2 , $col3 , $col4 , $col5 , $col6 , $col7 , $col8 , $col9 ) +sql select * from $tb order by ts desc +print rows = $rows +if $rows != 5 then + return -1 +endi + +# case: insert records from .csv files +# manually test +#sql insert into $tb file parser/parser_test_data.csv +#sql select * from $tb +#if $rows != 10 then +# return -1 +#endi + +sql drop table $tb +sql create table tb1 (ts timestamp, c1 int) +sql create table tb2 (ts timestamp, c1 int) +sql insert into tb1 values(now, 1) tb2 values (now, 2) +sql select count(*) from tb1 +if $rows != 1 then + return -1 +endi +sql select count(*) from tb2 +if $rows != 1 then + return -1 +endi + +sql drop database $db +sleep 100 +sql create database $db +sql use $db +sql create table stb1 (ts timestamp, c1 int) tags(t1 int) +sql create table stb2 (ts timestamp, c1 double, c2 binary(10)) tags(t1 binary(10)) +sql create table tb1 using stb1 tags(1) +sql create table tb2 using stb2 tags('tb2') +sql insert into tb1 (ts, c1) values (now-1s, 1) (now, 2) tb2 (ts, c1) values (now-2s, 1) (now-1s, 2) (now, 3) +sql select * from tb1 order by ts asc +if $rows != 2 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +sql select * from tb2 order by ts desc +if $rows != 3 then + return -1 +endi +if $data01 != 3.000000000 then + return -1 +endi +if $data11 != 2.000000000 then + return -1 +endi +if $data21 != 1.000000000 then + return -1 +endi + +sql drop database $db +sleep 100 +sql create database $db +sql use $db +sql create table stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 nchar(10), c6 binary(20)) tags(t1 int, t2 bigint, t3 double, t4 float, t5 nchar(10)) +sql create table tb0 using stb tags(0, 0, 0, 0, '涛思') +sql create table tb1 using stb tags('1', 1, 1, 1, '涛思') +sql create table tb2 using stb tags(2, '2', 2, 2, '涛思') +sql create table tb3 using stb tags(3, 3, '3', 3, '涛思') +sql create table tb4 using stb tags(4, 4, 4, '4', '涛思') +sql insert into tb0 values ('2018-09-17 09:00:00.000', 1, 1, 1, 1, '涛思nchar', 'none quoted') +sql insert into tb1 values ('2018-09-17 09:00:00.000', '1', 1, 1, 1, '涛思nchar', 'quoted int') +sql insert into tb2 values ('2018-09-17 09:00:00.000', 1, '1', 1, 1, '涛思nchar', 'quoted bigint') +sql insert into tb3 values ('2018-09-17 09:00:00.000', 1, 1, '1', 1, '涛思nchar', 'quoted float') +sql insert into tb4 values ('2018-09-17 09:00:00.000', 1, 1, 1, '1', '涛思nchar', 'quoted double') +sql select * from stb +if $rows != 5 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data10 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data20 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data30 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data40 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 1.00000 then + return -1 +endi +if $data04 != 1.000000000 then + return -1 +endi +if $data05 != 涛思nchar then + return -1 +endi +if $data06 != @none quoted@ then + return -1 +endi +if $data13 != 1.00000 then + return -1 +endi +if $data14 != 1.000000000 then + return -1 +endi +if $data15 != 涛思nchar then + return -1 +endi +if $data16 != @quoted int@ then + return -1 +endi +if $data25 != 涛思nchar then + return -1 +endi +if $data26 != @quoted bigint@ then + return -1 +endi +if $data35 != 涛思nchar then + return -1 +endi +if $data36 != @quoted float@ then + return -1 +endi +if $data45 != 涛思nchar then + return -1 +endi +if $data46 != @quoted double@ then + return -1 +endi + +# case: support NULL char of the binary field [TBASE-660] +sql create table NULLb (ts timestamp, c1 binary(20), c2 binary(20), c3 float) +sql insert into NULLb values ('2018-09-17 09:00:00.000', '', '', 3.746) +sql select * from NULLb +if $rows != 1 then + return -1 +endi + +#sql drop database $db +#sql show databases +#if $rows != 0 then +# return -1 +#endi + + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/parser/interp.sim b/tests/script/general/parser/interp.sim new file mode 100644 index 0000000000000000000000000000000000000000..4654913d1ee80fdd6b8a274fac7bca48d06aeef0 --- /dev/null +++ b/tests/script/general/parser/interp.sim @@ -0,0 +1,86 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = intp_db +$tbPrefix = intp_tb +$stbPrefix = intp_stb +$tbNum = 4 +$rowNum = 10000 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== interp.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +print ====== create tables +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int) + +$i = 0 +$ts = $ts0 +$halfNum = $tbNum / 2 +while $i < $halfNum + $tbId = $i + $halfNum + $tb = $tbPrefix . $i + $tb1 = $tbPrefix . $tbId + sql create table $tb using $stb tags( $i ) + sql create table $tb1 using $stb tags( $tbId ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) $tb1 values ( $ts , $c , NULL , $c , NULL , $c , $c , true, $binary , $nchar ) + $x = $x + 1 + endw + + $i = $i + 1 +endw +print ====== tables created + +sql create table ap1 (ts timestamp, pav float); +sql INSERT INTO ap1 VALUES ('2021-07-25 02:19:54.100',1) ('2021-07-25 02:19:54.200',2) ('2021-07-25 02:19:54.300',3) ('2021-07-25 02:19:56.500',4) ('2021-07-25 02:19:57.500',5) ('2021-07-25 02:19:57.600',6) ('2021-07-25 02:19:57.900',7) ('2021-07-25 02:19:58.100',8) ('2021-07-25 02:19:58.300',9) ('2021-07-25 02:19:59.100',10) ('2021-07-25 02:19:59.300',11) ('2021-07-25 02:19:59.500',12) ('2021-07-25 02:19:59.700',13) ('2021-07-25 02:19:59.900',14) ('2021-07-25 02:20:05.000', 20) ('2021-07-25 02:25:00.000', 10000); + +run general/parser/interp_test.sim + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 500 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed + +run general/parser/interp_test.sim + +print ================= TD-5931 +sql create stable st5931(ts timestamp, f int) tags(t int) +sql create table ct5931 using st5931 tags(1) +sql create table nt5931(ts timestamp, f int) + +sql select interp(*) from nt5931 where ts=now + +sql select interp(*) from st5931 where ts=now + +sql select interp(*) from ct5931 where ts=now + +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/interp_blocks.sim b/tests/script/general/parser/interp_blocks.sim new file mode 100644 index 0000000000000000000000000000000000000000..6099e8c77cf960985cf06888eba6e80d5ebc7188 --- /dev/null +++ b/tests/script/general/parser/interp_blocks.sim @@ -0,0 +1,753 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c minRows -v 10 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +sql create database newplant; +print ====== create tables +sql use newplant +sql create table st_analogdef (ts TIMESTAMP,ip_value FLOAT,ip_quality TINYINT) TAGS (name NCHAR(50),st_type BINARY(10),st_plant_area NCHAR(10),st_description NCHAR(50),st_eng_units NCHAR(10),st_graph_maximum FLOAT,st_graph_minimum FLOAT,st_hh_limit FLOAT,st_h_limit FLOAT,st_l_limit FLOAT,st_ll_limit FLOAT,st_deadband FLOAT,is_sys_table INT); +sql CREATE TABLE ts_1171194 USING st_analogdef TAGS ("TD_A01009","analog","ss1","sss1009","%",30000.000000,NULL,12000.000000,10000.000000,100.000000,80.000000,NULL,0); + +sql insert into ts_1171194 values ('2021-08-16 16:09:40.000',1.00000,2) +sql insert into ts_1171194 values ('2021-08-16 16:10:10.000',2.00000,3) +sql insert into ts_1171194 values ('2021-08-16 16:10:40.000',3.00000,4) +sql insert into ts_1171194 values ('2021-08-16 16:11:10.000',4.00000,5) +sql insert into ts_1171194 values ('2021-08-16 16:11:40.000',5.00000,6) +sql insert into ts_1171194 values ('2021-08-16 16:12:10.000',6.00000,7) +sql insert into ts_1171194 values ('2021-08-16 16:12:40.000',7.00000,8) +sql insert into ts_1171194 values ('2021-08-16 16:13:20.000',8.00000,9) +sql insert into ts_1171194 values ('2021-08-16 16:13:50.000',9.00000,10) +sql insert into ts_1171194 values ('2021-08-16 16:58:00.000',10.00000,11) + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 500 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed + +sql insert into ts_1171194 values ('2021-08-16 16:59:00.000',11.00000,12) +sql insert into ts_1171194 values ('2021-08-16 17:10:10.000',12.00000,13) +sql insert into ts_1171194 values ('2021-08-16 17:10:40.000',13.00000,14) +sql insert into ts_1171194 values ('2021-08-16 17:11:10.000',14.00000,15) +sql insert into ts_1171194 values ('2021-08-16 17:11:40.000',15.00000,16) +sql insert into ts_1171194 values ('2021-08-16 17:12:10.000',16.00000,17) +sql insert into ts_1171194 values ('2021-08-16 17:12:40.000',17.00000,18) +sql insert into ts_1171194 values ('2021-08-16 17:13:20.000',18.00000,19) +sql insert into ts_1171194 values ('2021-08-16 17:13:50.000',19.00000,20) +sql insert into ts_1171194 values ('2021-08-16 17:58:00.000',20.00000,21) + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 500 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed + +sql insert into ts_1171194 values ('2021-08-16 17:59:00.000',21.00000,22) +sql insert into ts_1171194 values ('2021-08-16 18:10:10.000',22.00000,23) +sql insert into ts_1171194 values ('2021-08-16 18:10:40.000',23.00000,24) +sql insert into ts_1171194 values ('2021-08-16 18:11:10.000',24.00000,25) +sql insert into ts_1171194 values ('2021-08-16 18:11:40.000',25.00000,26) +sql insert into ts_1171194 values ('2021-08-16 18:12:10.000',26.00000,27) +sql insert into ts_1171194 values ('2021-08-16 18:12:40.000',27.00000,28) +sql insert into ts_1171194 values ('2021-08-16 18:13:20.000',28.00000,29) +sql insert into ts_1171194 values ('2021-08-16 18:13:50.000',29.00000,30) +sql insert into ts_1171194 values ('2021-08-16 18:58:00.000',30.00000,31) + + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 500 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed + + +sql select interp(ip_value,ip_quality) from st_analogdef where name='TD_A01009' and ts >='2021-08-16 16:00:00.000' and ts <='2021-08-16 19:00:00.000' every(1h) fill(linear); +if $rows != 4 then + return -1 +endi +if $data00 != @21-08-16 16:00:00.000@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data02 != NULL then + return -1 +endi +if $data10 != @21-08-16 17:00:00.000@ then + return -1 +endi +if $data11 != 11.08955 then + return -1 +endi +if $data12 != 12 then + return -1 +endi +if $data20 != @21-08-16 18:00:00.000@ then + return -1 +endi +if $data21 != 21.08955 then + return -1 +endi +if $data22 != 22 then + return -1 +endi +if $data30 != @21-08-16 19:00:00.000@ then + return -1 +endi +if $data31 != NULL then + return -1 +endi +if $data32 != NULL then + return -1 +endi + +sql select interp(ip_value,ip_quality) from st_analogdef where name='TD_A01009' and ts >='2021-08-16 16:00:00.000' and ts <='2021-08-16 19:00:00.000' every(30m) fill(linear); +if $rows != 7 then + return -1 +endi +if $data00 != @21-08-16 16:00:00.000@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data02 != NULL then + return -1 +endi +if $data10 != @21-08-16 16:30:00.000@ then + return -1 +endi +if $data11 != 9.36604 then + return -1 +endi +if $data12 != 10 then + return -1 +endi +if $data20 != @21-08-16 17:00:00.000@ then + return -1 +endi +if $data21 != 11.08955 then + return -1 +endi +if $data22 != 12 then + return -1 +endi +if $data30 != @21-08-16 17:30:00.000@ then + return -1 +endi +if $data31 != 19.36604 then + return -1 +endi +if $data32 != 20 then + return -1 +endi +if $data40 != @21-08-16 18:00:00.000@ then + return -1 +endi +if $data41 != 21.08955 then + return -1 +endi +if $data42 != 22 then + return -1 +endi +if $data50 != @21-08-16 18:30:00.000@ then + return -1 +endi +if $data51 != 29.36604 then + return -1 +endi +if $data52 != 30 then + return -1 +endi +if $data60 != @21-08-16 19:00:00.000@ then + return -1 +endi +if $data61 != NULL then + return -1 +endi +if $data62 != NULL then + return -1 +endi + +sql select interp(ip_value,ip_quality) from st_analogdef where name='TD_A01009' and ts >='2021-08-16 16:00:00.000' and ts <='2021-08-16 19:00:00.000' every(1h) fill(prev); +if $rows != 4 then + return -1 +endi +if $data00 != @21-08-16 16:00:00.000@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data02 != NULL then + return -1 +endi +if $data10 != @21-08-16 17:00:00.000@ then + return -1 +endi +if $data11 != 11.00000 then + return -1 +endi +if $data12 != 12 then + return -1 +endi +if $data20 != @21-08-16 18:00:00.000@ then + return -1 +endi +if $data21 != 21.00000 then + return -1 +endi +if $data22 != 22 then + return -1 +endi +if $data30 != @21-08-16 19:00:00.000@ then + return -1 +endi +if $data31 != 30.00000 then + return -1 +endi +if $data32 != 31 then + return -1 +endi + + +sql select interp(ip_value,ip_quality) from st_analogdef where name='TD_A01009' and ts >='2021-08-16 16:00:00.000' and ts <='2021-08-16 19:00:00.000' every(1h) fill(next); +if $rows != 4 then + return -1 +endi +if $data00 != @21-08-16 16:00:00.000@ then + return -1 +endi +if $data01 != 1.00000 then + return -1 +endi +if $data02 != 2 then + return -1 +endi +if $data10 != @21-08-16 17:00:00.000@ then + return -1 +endi +if $data11 != 12.00000 then + return -1 +endi +if $data12 != 13 then + return -1 +endi +if $data20 != @21-08-16 18:00:00.000@ then + return -1 +endi +if $data21 != 22.00000 then + return -1 +endi +if $data22 != 23 then + return -1 +endi +if $data30 != @21-08-16 19:00:00.000@ then + return -1 +endi +if $data31 != NULL then + return -1 +endi +if $data32 != NULL then + return -1 +endi + +sql select interp(ip_value,ip_quality) from st_analogdef where name='TD_A01009' and ts >='2021-08-16 16:00:00.000' and ts <='2021-08-16 19:00:00.000' every(1h) fill(value,1); +if $rows != 4 then + return -1 +endi +if $data00 != @21-08-16 16:00:00.000@ then + return -1 +endi +if $data01 != 1.00000 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data10 != @21-08-16 17:00:00.000@ then + return -1 +endi +if $data11 != 1.00000 then + return -1 +endi +if $data12 != 1 then + return -1 +endi +if $data20 != @21-08-16 18:00:00.000@ then + return -1 +endi +if $data21 != 1.00000 then + return -1 +endi +if $data22 != 1 then + return -1 +endi +if $data30 != @21-08-16 19:00:00.000@ then + return -1 +endi +if $data31 != 1.00000 then + return -1 +endi +if $data32 != 1 then + return -1 +endi + +sql select interp(ip_value,ip_quality) from st_analogdef where name='TD_A01009' and ts >='2021-08-16 16:00:00.000' and ts <='2021-08-16 19:00:00.000' every(1h) fill(linear) order by ts desc; +if $rows != 4 then + return -1 +endi +if $data00 != @21-08-16 19:00:00.000@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data02 != NULL then + return -1 +endi +if $data10 != @21-08-16 18:00:00.000@ then + return -1 +endi +if $data11 != 21.08955 then + return -1 +endi +if $data12 != 22 then + return -1 +endi +if $data20 != @21-08-16 17:00:00.000@ then + return -1 +endi +if $data21 != 11.08955 then + return -1 +endi +if $data22 != 12 then + return -1 +endi +if $data30 != @21-08-16 16:00:00.000@ then + return -1 +endi +if $data31 != NULL then + return -1 +endi +if $data32 != NULL then + return -1 +endi + +sql select interp(ip_value,ip_quality) from st_analogdef where name='TD_A01009' and ts >='2021-08-16 16:00:00.000' and ts <='2021-08-16 19:00:00.000' every(1h) fill(next) order by ts desc; +if $rows != 4 then + return -1 +endi +if $data00 != @21-08-16 19:00:00.000@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data02 != NULL then + return -1 +endi +if $data10 != @21-08-16 18:00:00.000@ then + return -1 +endi +if $data11 != 21.00000 then + return -1 +endi +if $data12 != 22 then + return -1 +endi +if $data20 != @21-08-16 17:00:00.000@ then + return -1 +endi +if $data21 != 11.00000 then + return -1 +endi +if $data22 != 12 then + return -1 +endi +if $data30 != @21-08-16 16:00:00.000@ then + return -1 +endi +if $data31 != NULL then + return -1 +endi +if $data32 != NULL then + return -1 +endi + +sql select interp(ip_value,ip_quality) from st_analogdef where name='TD_A01009' and ts >='2021-08-16 16:00:00.000' and ts <='2021-08-16 19:00:00.000' every(1h) fill(NULL) order by ts desc; +if $rows != 4 then + return -1 +endi +if $data00 != @21-08-16 19:00:00.000@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data02 != NULL then + return -1 +endi +if $data10 != @21-08-16 18:00:00.000@ then + return -1 +endi +if $data11 != NULL then + return -1 +endi +if $data12 != NULL then + return -1 +endi +if $data20 != @21-08-16 17:00:00.000@ then + return -1 +endi +if $data21 != NULL then + return -1 +endi +if $data22 != NULL then + return -1 +endi +if $data30 != @21-08-16 16:00:00.000@ then + return -1 +endi +if $data31 != NULL then + return -1 +endi +if $data32 != NULL then + return -1 +endi + +sql select interp(ip_value,ip_quality) from st_analogdef where name='TD_A01009' and ts >='2021-08-16 16:00:00.000' and ts <='2021-08-16 19:00:00.000' every(1h) fill(value, 5) order by ts desc; +if $rows != 4 then + return -1 +endi +if $data00 != @21-08-16 19:00:00.000@ then + return -1 +endi +if $data01 != 5.00000 then + return -1 +endi +if $data02 != 5 then + return -1 +endi +if $data10 != @21-08-16 18:00:00.000@ then + return -1 +endi +if $data11 != 5.00000 then + return -1 +endi +if $data12 != 5 then + return -1 +endi +if $data20 != @21-08-16 17:00:00.000@ then + return -1 +endi +if $data21 != 5.00000 then + return -1 +endi +if $data22 != 5 then + return -1 +endi +if $data30 != @21-08-16 16:00:00.000@ then + return -1 +endi +if $data31 != 5.00000 then + return -1 +endi +if $data32 != 5 then + return -1 +endi + +sql select interp(ip_value,ip_quality) from st_analogdef where name='TD_A01009' and ts >='2021-08-16 16:00:00.000' and ts <='2021-08-16 19:00:00.000' every(30m) fill(linear) order by ts desc; +if $rows != 7 then + return -1 +endi +if $data00 != @21-08-16 19:00:00.000@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data02 != NULL then + return -1 +endi +if $data10 != @21-08-16 18:30:00.000@ then + return -1 +endi +if $data11 != 29.36604 then + return -1 +endi +if $data12 != 30 then + return -1 +endi +if $data20 != @21-08-16 18:00:00.000@ then + return -1 +endi +if $data21 != 21.08955 then + return -1 +endi +if $data22 != 22 then + return -1 +endi +if $data30 != @21-08-16 17:30:00.000@ then + return -1 +endi +if $data31 != 19.36604 then + return -1 +endi +if $data32 != 20 then + return -1 +endi +if $data40 != @21-08-16 17:00:00.000@ then + return -1 +endi +if $data41 != 11.08955 then + return -1 +endi +if $data42 != 12 then + return -1 +endi +if $data50 != @21-08-16 16:30:00.000@ then + return -1 +endi +if $data51 != 9.36604 then + return -1 +endi +if $data52 != 10 then + return -1 +endi +if $data60 != @21-08-16 16:00:00.000@ then + return -1 +endi +if $data61 != NULL then + return -1 +endi +if $data62 != NULL then + return -1 +endi + + +sql select interp(ip_value,ip_quality) from st_analogdef where name='TD_A01009' and ts >='2021-08-16 16:00:00.000' and ts <='2021-08-16 19:00:00.000' every(30m) fill(next) order by ts desc; +if $rows != 7 then + return -1 +endi +if $data00 != @21-08-16 19:00:00.000@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data02 != NULL then + return -1 +endi +if $data10 != @21-08-16 18:30:00.000@ then + return -1 +endi +if $data11 != 29.00000 then + return -1 +endi +if $data12 != 30 then + return -1 +endi +if $data20 != @21-08-16 18:00:00.000@ then + return -1 +endi +if $data21 != 21.00000 then + return -1 +endi +if $data22 != 22 then + return -1 +endi +if $data30 != @21-08-16 17:30:00.000@ then + return -1 +endi +if $data31 != 19.00000 then + return -1 +endi +if $data32 != 20 then + return -1 +endi +if $data40 != @21-08-16 17:00:00.000@ then + return -1 +endi +if $data41 != 11.00000 then + return -1 +endi +if $data42 != 12 then + return -1 +endi +if $data50 != @21-08-16 16:30:00.000@ then + return -1 +endi +if $data51 != 9.00000 then + return -1 +endi +if $data52 != 10 then + return -1 +endi +if $data60 != @21-08-16 16:00:00.000@ then + return -1 +endi +if $data61 != NULL then + return -1 +endi +if $data62 != NULL then + return -1 +endi + +sql select interp(ip_value,ip_quality) from st_analogdef where name='TD_A01009' and ts >='2021-08-16 16:00:00.000' and ts <='2021-08-16 16:13:50.000' every(3m) fill(linear); +if $rows != 5 then + return -1 +endi +if $data00 != @21-08-16 16:00:00.000@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data02 != NULL then + return -1 +endi +if $data10 != @21-08-16 16:03:00.000@ then + return -1 +endi +if $data11 != NULL then + return -1 +endi +if $data12 != NULL then + return -1 +endi +if $data20 != @21-08-16 16:06:00.000@ then + return -1 +endi +if $data21 != NULL then + return -1 +endi +if $data22 != NULL then + return -1 +endi +if $data30 != @21-08-16 16:09:00.000@ then + return -1 +endi +if $data31 != NULL then + return -1 +endi +if $data32 != NULL then + return -1 +endi +if $data40 != @21-08-16 16:12:00.000@ then + return -1 +endi +if $data41 != 5.66667 then + return -1 +endi +if $data42 != 6 then + return -1 +endi + +sql select interp(ip_value,ip_quality) from st_analogdef where name='TD_A01009' and ts >='2021-08-16 16:00:00.000' and ts <='2021-08-16 16:13:50.000' every(3m) fill(linear) order by ts desc; +if $rows != 5 then + return -1 +endi +if $data00 != @21-08-16 16:12:00.000@ then + return -1 +endi +if $data01 != 5.66667 then + return -1 +endi +if $data02 != 6 then + return -1 +endi +if $data10 != @21-08-16 16:09:00.000@ then + return -1 +endi +if $data11 != NULL then + return -1 +endi +if $data12 != NULL then + return -1 +endi +if $data20 != @21-08-16 16:06:00.000@ then + return -1 +endi +if $data21 != NULL then + return -1 +endi +if $data22 != NULL then + return -1 +endi +if $data30 != @21-08-16 16:03:00.000@ then + return -1 +endi +if $data31 != NULL then + return -1 +endi +if $data32 != NULL then + return -1 +endi +if $data40 != @21-08-16 16:00:00.000@ then + return -1 +endi +if $data41 != NULL then + return -1 +endi +if $data42 != NULL then + return -1 +endi + +sql select interp(ip_value,ip_quality) from st_analogdef where name='TD_A01009' and ts >='2021-08-16 16:00:00.000' and ts <='2021-08-16 16:13:50.000' every(3m) fill(next) order by ts desc; +if $rows != 5 then + return -1 +endi +if $data00 != @21-08-16 16:12:00.000@ then + return -1 +endi +if $data01 != 5.00000 then + return -1 +endi +if $data02 != 6 then + return -1 +endi +if $data10 != @21-08-16 16:09:00.000@ then + return -1 +endi +if $data11 != NULL then + return -1 +endi +if $data12 != NULL then + return -1 +endi +if $data20 != @21-08-16 16:06:00.000@ then + return -1 +endi +if $data21 != NULL then + return -1 +endi +if $data22 != NULL then + return -1 +endi +if $data30 != @21-08-16 16:03:00.000@ then + return -1 +endi +if $data31 != NULL then + return -1 +endi +if $data32 != NULL then + return -1 +endi +if $data40 != @21-08-16 16:00:00.000@ then + return -1 +endi +if $data41 != NULL then + return -1 +endi +if $data42 != NULL then + return -1 +endi + +#system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/interp_test.sim b/tests/script/general/parser/interp_test.sim new file mode 100644 index 0000000000000000000000000000000000000000..8eac8a41d391508737232a3f068c477922bf77aa --- /dev/null +++ b/tests/script/general/parser/interp_test.sim @@ -0,0 +1,2496 @@ +sleep 100 +sql connect + +$dbPrefix = intp_db +$tbPrefix = intp_tb +$stbPrefix = intp_stb +$tbNum = 4 +$rowNum = 10000 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== intp_test.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i +$tsu = $rowNum * $delta +$tsu = $tsu - $delta +$tsu = $tsu + $ts0 + +print ====== use db +sql use $db + +##### select interp from table +print ====== select intp from table +$tb = $tbPrefix . 0 +## interp(*) from tb +sql select interp(*) from $tb where ts = $ts0 +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != 0 then + return -1 +endi + +## interp + limit offset +sql select interp(*) from $tb where ts = $ts0 limit 5 offset 1 +if $rows != 0 then + return -1 +endi + +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $ts0 +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 0.00000 then + return -1 +endi +if $data04 != 0.000000000 then + return -1 +endi +if $data05 != 0 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data08 != binary0 then + return -1 +endi +if $data09 != nchar0 then + return -1 +endi + +## intp + aggregation functions +$t = $ts0 + $delta +$t = $t + $delta +sql_error select interp(ts), max(c1), min(c2), count(c3), sum(c4), avg(c5), stddev(c6), first(c7), last(c8), interp(c9) from $tb where ts = $t +sql_error select interp(ts) from $tb where ts=$ts0 interval(1s) + +### illegal queries on a table +sql_error select interp(ts), c1 from $tb where ts = $ts0 +sql_error select interp(ts) from $tb where ts >= $ts0 +sql_error select interp(ts), max(c1), min(c2), count(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(NULL) + +### interp from tb + fill +$t = $ts0 + 1000 +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t +if $rows != 0 then + return -1 +endi + +## fill(none) +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(none) +if $rows != 0 then + return -1 +endi +$t = $tsu + 1000 +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(none) +if $rows != 0 then + return -1 +endi + +## fill(NULL) +$t = $tsu - 1000 +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(value, NULL) order by ts asc +if $rows != 1 then + return -1 +endi +if $data00 != @18-11-25 19:29:59.000@ then + return -1 +endi +if $data01 != NULL then + print expect NULL, actual $data01 + return -1 +endi +if $data02 != NULL then + return -1 +endi +if $data03 != NULL then + return -1 +endi +if $data04 != NULL then + return -1 +endi +if $data05 != NULL then + return -1 +endi +if $data06 != NULL then + return -1 +endi +if $data07 != NULL then + return -1 +endi +if $data08 != NULL then + return -1 +endi +if $data09 != NULL then + return -1 +endi + +$t = $tsu + 1000 +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(none) +if $rows != 0 then + return -1 +endi + +## fill(prev) +$t = $ts0 + 1000 +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(prev) +if $rows != 1 then + return -1 +endi + +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $ts0 fill(prev) +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 0.00000 then + return -1 +endi +if $data04 != 0.000000000 then + return -1 +endi +if $data05 != 0 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data08 != binary0 then + return -1 +endi +if $data09 != nchar0 then + return -1 +endi + +$t = $ts0 - 1000 +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(prev) +if $rows != 0 then + return -1 +endi + +$t = $ts0 + 1000 +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from intp_tb3 where ts = $t fill(prev) +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:01.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != NULL then + return -1 +endi +if $data03 != 0.00000 then + print expect 0.00000, actual:$data03 + return -1 +endi +# if $data04 != NULL then +# return -1 +# endi + +$t = $tsu + 1000 +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(prev) +if $rows != 0 then + return -1 +endi + +## fill(linear) +$t = $ts0 + 1000 +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(linear) +print ====== 0:$data00, 1:$data01, 2:$data02, 3:$data03, 4:$data04, 5:$data05, 6:$data06, 7:$data07, 8:$data08, 9:$data09 +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:01.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +print $data03 +if $data03 != 0.00167 then + return -1 +endi +if $data04 != 0.001666667 then + return -1 +endi +if $data05 != 0 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data07 != NULL then + return -1 +endi +if $data08 != NULL then + return -1 +endi +if $data09 != NULL then + return -1 +endi +# columns contain NULL values +$t = $ts0 + 1000 +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from intp_tb3 where ts = $t fill(linear) +print ====== 0:$data00, 1:$data01, 2:$data02, 3:$data03, 4:$data04, 5:$data05, 6:$data06, 7:$data07, 8:$data08, 9:$data09 +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:01.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != NULL then + return -1 +endi +if $data03 != 0.00167 then + return -1 +endi +if $data04 != NULL then + return -1 +endi +if $data05 != 0 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data07 != NULL then + return -1 +endi +if $data08 != NULL then + return -1 +endi +if $data09 != NULL then + return -1 +endi + +print select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $ts0 fill(linear) + +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $ts0 fill(linear) +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 0.00000 then + return -1 +endi +if $data04 != 0.000000000 then + return -1 +endi +if $data05 != 0 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data08 != binary0 then + return -1 +endi +if $data09 != nchar0 then + return -1 +endi +# columns contain NULL values + +print select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from intp_tb3 where ts = $ts0 fill(linear) +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from intp_tb3 where ts = $ts0 fill(linear) +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != NULL then + return -1 +endi +if $data03 != 0.00000 then + return -1 +endi +if $data04 != NULL then + return -1 +endi +if $data05 != 0 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data08 != binary0 then + return -1 +endi +if $data09 != nchar0 then + return -1 +endi + +$t = $ts0 - 1000 +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(linear) +if $rows != 0 then + return -1 +endi + +$t = $tsu + 1000 +print select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(linear) +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(linear) +if $rows != 0 then + return -1 +endi + +## fill(value) +$t = $ts0 + 1000 +print 91 +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(value, -1, -2) +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:01.000@ then + return -1 +endi +if $data01 != -2 then + return -1 +endi +if $data02 != -2 then + return -1 +endi +if $data03 != -2.00000 then + return -1 +endi +if $data04 != -2.000000000 then + return -1 +endi +if $data05 != -2 then + return -1 +endi +if $data06 != -2 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data08 != NULL then + return -1 +endi +if $data09 != NULL then + return -1 +endi + +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $ts0 fill(value, -1, -2, -3) +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 0.00000 then + return -1 +endi +if $data04 != 0.000000000 then + return -1 +endi +if $data05 != 0 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data08 != binary0 then + return -1 +endi +if $data09 != nchar0 then + return -1 +endi + +# table has NULL columns +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from intp_tb3 where ts = $ts0 fill(value, -1, -2, -3) +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != NULL then + return -1 +endi +if $data03 != 0.00000 then + return -1 +endi +if $data04 != NULL then + return -1 +endi + +$t = $ts0 - 1000 +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(value, -1, -2) +if $rows != 0 then + return -1 +endi + +$t = $tsu + 1000 +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(value, -1, -2) +if $rows != 0 then + return -1 +endi + +### select interp from stable +## interp(*) from stb +print select interp(*) from $stb where ts = $ts0 +sql select interp(*) from $stb where ts = $ts0 +if $rows != 1 then + return -1 +endi +$t = $ts0 + 1000 +print 92 + +sql select interp(*) from $stb where ts = $t +if $rows != 0 then + return -1 +endi +## interp(*) from stb + group by +sql select interp(ts, c1, c2, c3, c4, c5, c7, c9) from $stb where ts = $ts0 group by tbname order by tbname asc +print ====== select interp(ts, c1, c2, c3, c4, c5, c7, c9) from $stb where ts = $ts0 group by tbname order by tbname asc +print ====== 0:$data00, 1:$data01, 2:$data02, 3:$data03, 4:$data04, 5:$data05, 6:$data06, 7:$data07, 8:$data08, 9:$data09 +print ====== 0:$data20, 1:$data21, 2:$data22, 3:$data23, 4:$data24, 5:$data25, 6:$data26, 7:$data27, 8:$data28, 9:$data29 +if $rows != $tbNum then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data04 != 0.000000000 then + return -1 +endi +if $data08 != intp_tb0 then + return -1 +endi +if $data22 != NULL then + return -1 +endi +if $data24 != NULL then + return -1 +endi +if $data28 != intp_tb2 then + return -1 +endi + +## interp(*) from stb + group by + limit offset +sql select interp(*) from $stb where ts = $ts0 group by tbname limit 0 +if $rows != 0 then + return -1 +endi +sql select interp(*) from $stb where ts = $ts0 group by tbname limit 0 offset 1 + +## interp(*) from stb + group by + fill(none) +$t = $ts0 + 1000 +sql select interp(*) from $stb where ts = $t fill(none) group by tbname +if $rows != 0 then + return -1 +endi + +sql select interp(*) from $stb where ts = $ts0 fill(none) group by tbname +if $rows != 4 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data21 != 0 then + return -1 +endi +if $data22 != NULL then + return -1 +endi +if $data24 != NULL then + return -1 +endi + +## interp(*) from stb + group by + fill(none) +$t = $ts0 + 1000 +sql select interp(*) from $stb where ts = $t fill(NULL) group by tbname +if $rows != $tbNum then + return -1 +endi +if $data00 != @18-09-17 09:00:01.000@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data12 != NULL then + return -1 +endi +if $data23 != NULL then + return -1 +endi +if $data34 != NULL then + return -1 +endi +if $data05 != NULL then + return -1 +endi +if $data16 != NULL then + return -1 +endi +if $data27 != NULL then + return -1 +endi +if $data38 != NULL then + return -1 +endi +if $data09 != NULL then + return -1 +endi + +sql select interp(*) from $stb where ts = $ts0 fill(NULL) group by tbname +print $rows + +if $rows != 4 then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +if $data02 != 0 then + return -1 +endi +if $data21 != 0 then + return -1 +endi +if $data22 != NULL then + return -1 +endi +if $data24 != NULL then + return -1 +endi + +## interp(*) from stb + group by + fill(prev) +$t = $ts0 + 1000 +sql select interp(*) from $stb where ts = $t fill(prev) group by tbname +print ====== 0:$data00, 1:$data01, 2:$data02, 3:$data03, 4:$data04, 5:$data05, 6:$data06, 7:$data07, 8:$data08, 9:$data09 +print ====== 0:$data20, 1:$data21, 2:$data22, 3:$data23, 4:$data24, 5:$data25, 6:$data26, 7:$data27, 8:$data28, 9:$data29 +if $rows != $tbNum then + return -1 +endi +if $data00 != @18-09-17 09:00:01.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 0.00000 then + return -1 +endi +if $data04 != 0.000000000 then + return -1 +endi +if $data05 != 0 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data08 != binary0 then + return -1 +endi +if $data09 != nchar0 then + return -1 +endi +if $data20 != @18-09-17 09:00:01.000@ then + return -1 +endi +if $data21 != 0 then + return -1 +endi +if $data22 != NULL then + return -1 +endi +if $data23 != 0.00000 then + return -1 +endi +if $data24 != NULL then + return -1 +endi +if $data25 != 0 then + return -1 +endi +if $data26 != 0 then + return -1 +endi +if $data27 != 1 then + return -1 +endi +if $data28 != binary0 then + return -1 +endi +if $data29 != nchar0 then + return -1 +endi + +## interp(*) from stb + group by + fill(linear) +$t = $ts0 + 1000 +sql select interp(*) from $stb where ts = $t fill(linear) group by tbname +print ====== 0:$data00, 1:$data01, 2:$data02, 3:$data03, 4:$data04, 5:$data05, 6:$data06, 7:$data07, 8:$data08, 9:$data09 +print ====== 0:$data20, 1:$data21, 2:$data22, 3:$data23, 4:$data24, 5:$data25, 6:$data26, 7:$data27, 8:$data28, 9:$data29 +if $rows != $tbNum then + return -1 +endi +if $data00 != @18-09-17 09:00:01.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 0.00167 then + return -1 +endi +if $data04 != 0.001666667 then + return -1 +endi +if $data05 != 0 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data07 != NULL then + return -1 +endi +if $data08 != NULL then + return -1 +endi +if $data09 != NULL then + return -1 +endi +if $data20 != @18-09-17 09:00:01.000@ then + return -1 +endi +if $data21 != 0 then + return -1 +endi +if $data22 != NULL then + return -1 +endi +if $data23 != 0.00167 then + return -1 +endi +if $data24 != NULL then + return -1 +endi +if $data25 != 0 then + return -1 +endi +if $data26 != 0 then + return -1 +endi +if $data27 != NULL then + return -1 +endi +if $data28 != NULL then + return -1 +endi +if $data29 != NULL then + return -1 +endi + + ## interp(*) from stb + group by + fill(value) +$t = $ts0 + 1000 +sql select interp(*) from $stb where ts = $t fill(value, -1, -2) group by tbname +print ====== 0:$data00, 1:$data01, 2:$data02, 3:$data03, 4:$data04, 5:$data05, 6:$data06, 7:$data07, 8:$data08, 9:$data09 +print ====== 0:$data20, 1:$data21, 2:$data22, 3:$data23, 4:$data24, 5:$data25, 6:$data26, 7:$data27, 8:$data28, 9:$data29 +if $rows != $tbNum then + return -1 +endi +if $data00 != @18-09-17 09:00:01.000@ then + return -1 +endi +if $data01 != -2 then + return -1 +endi +if $data02 != -2 then + return -1 +endi +if $data03 != -2.00000 then + return -1 +endi +if $data04 != -2.000000000 then + return -1 +endi +if $data05 != -2 then + return -1 +endi +if $data06 != -2 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data08 != NULL then + return -1 +endi +if $data09 != NULL then + return -1 +endi +if $data20 != @18-09-17 09:00:01.000@ then + return -1 +endi +if $data21 != -2 then + return -1 +endi +if $data22 != -2 then + return -1 +endi +if $data23 != -2.00000 then + return -1 +endi +if $data24 != -2.000000000 then + return -1 +endi +if $data25 != -2 then + return -1 +endi +if $data26 != -2 then + return -1 +endi +if $data27 != 1 then + return -1 +endi +if $data28 != NULL then + return -1 +endi +if $data29 != NULL then + return -1 +endi + +sql_error select interp(ts,c1) from intp_tb0 where ts>'2018-11-25 19:19:00' and ts<'2018-11-25 19:19:12'; +sql select interp(ts,c1) from intp_tb0 where ts>'2018-11-25 19:19:00' and ts<'2018-11-25 19:19:12' every(1s) fill(linear); +if $rows != 0 then + return -1 +endi + +sql select interp(c1) from intp_tb0 where ts>'2018-11-25 18:09:00' and ts<'2018-11-25 19:20:12' every(18m); +if $rows != 1 then + return -1 +endi + +if $data00 != @18-11-25 18:30:00.000@ then + return -1 +endi + +if $data01 != 3 then + return -1 +endi + +sql select interp(c1,c3,c4,ts) from intp_tb0 where ts>'2018-11-25 18:09:00' and ts<'2018-11-25 19:20:12' every(18m) fill(linear) +if $rows != 5 then + return -1 +endi + +if $data00 != @18-11-25 17:54:00.000@ then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +if $data02 != 0.00000 then + return -1 +endi + +if $data03 != 0.000000000 then + return -1 +endi + +if $data04 != @18-11-25 17:54:00.000@ then + return -1 +endi + +if $data10 != @18-11-25 18:12:00.000@ then + return -1 +endi + +if $data11 != 1 then + return -1 +endi + +if $data12 != 1.20000 then + return -1 +endi + +if $data13 != 1.200000000 then + return -1 +endi + +if $data14 != @18-11-25 18:12:00.000@ then + return -1 +endi + +if $data40 != @18-11-25 19:06:00.000@ then + return -1 +endi + +if $data41 != 6 then + return -1 +endi + +if $data42 != 6.60000 then + return -1 +endi + +if $data43 != 6.600000000 then + return -1 +endi + +if $data44 != @18-11-25 19:06:00.000@ then + return -1 +endi + + +sql select interp(c1) from intp_stb0 where ts >= '2018-09-17 20:35:00.000' and ts <= '2018-09-17 20:42:00.000' every(1m) fill(linear); +if $rows != 8 then + return -1 +endi +if $data00 != @18-09-17 20:35:00.000@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data10 != @18-09-17 20:36:00.000@ then + return -1 +endi +if $data11 != NULL then + return -1 +endi +if $data20 != @18-09-17 20:37:00.000@ then + return -1 +endi +if $data21 != NULL then + return -1 +endi +if $data30 != @18-09-17 20:38:00.000@ then + return -1 +endi +if $data31 != NULL then + return -1 +endi +if $data40 != @18-09-17 20:39:00.000@ then + return -1 +endi +if $data41 != NULL then + return -1 +endi +if $data50 != @18-09-17 20:40:00.000@ then + return -1 +endi +if $data51 != 0 then + return -1 +endi +if $data60 != @18-09-17 20:41:00.000@ then + return -1 +endi +if $data61 != NULL then + return -1 +endi +if $data70 != @18-09-17 20:42:00.000@ then + return -1 +endi +if $data71 != NULL then + return -1 +endi + + +sql select interp(c1) from intp_stb0 where ts >= '2018-09-17 20:35:00.000' and ts <= '2018-09-17 20:42:00.000' every(1m) fill(linear) order by ts desc; +if $rows != 8 then + return -1 +endi +if $data00 != @18-09-17 20:42:00.000@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data10 != @18-09-17 20:41:00.000@ then + return -1 +endi +if $data11 != NULL then + return -1 +endi +if $data20 != @18-09-17 20:40:00.000@ then + return -1 +endi +if $data21 != 0 then + return -1 +endi +if $data30 != @18-09-17 20:39:00.000@ then + return -1 +endi +if $data31 != NULL then + return -1 +endi +if $data40 != @18-09-17 20:38:00.000@ then + return -1 +endi +if $data41 != NULL then + return -1 +endi +if $data50 != @18-09-17 20:37:00.000@ then + return -1 +endi +if $data51 != NULL then + return -1 +endi +if $data60 != @18-09-17 20:36:00.000@ then + return -1 +endi +if $data61 != NULL then + return -1 +endi +if $data70 != @18-09-17 20:35:00.000@ then + return -1 +endi +if $data71 != NULL then + return -1 +endi + +sql select interp(c3) from intp_stb0 where ts >= '2018-09-17 20:35:00.000' and ts <= '2018-09-17 20:50:00.000' every(2m) fill(linear) order by ts; +if $rows != 9 then + return -1 +endi +if $data00 != @18-09-17 20:34:00.000@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data10 != @18-09-17 20:36:00.000@ then + return -1 +endi +if $data11 != NULL then + return -1 +endi +if $data20 != @18-09-17 20:38:00.000@ then + return -1 +endi +if $data21 != NULL then + return -1 +endi +if $data30 != @18-09-17 20:40:00.000@ then + return -1 +endi +if $data31 != 0.00000 then + return -1 +endi +if $data40 != @18-09-17 20:42:00.000@ then + return -1 +endi +if $data41 != 0.20000 then + return -1 +endi +if $data50 != @18-09-17 20:44:00.000@ then + return -1 +endi +if $data51 != 0.40000 then + return -1 +endi +if $data60 != @18-09-17 20:46:00.000@ then + return -1 +endi +if $data61 != 0.60000 then + return -1 +endi +if $data70 != @18-09-17 20:48:00.000@ then + return -1 +endi +if $data71 != 0.80000 then + return -1 +endi +if $data80 != @18-09-17 20:50:00.000@ then + return -1 +endi +if $data81 != 1.00000 then + return -1 +endi + + +sql select interp(c3) from intp_stb0 where ts >= '2018-09-17 20:35:00.000' and ts <= '2018-09-17 20:50:00.000' every(3m) fill(linear) order by ts; +if $rows != 6 then + return -1 +endi +if $data00 != @18-09-17 20:33:00.000@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data10 != @18-09-17 20:36:00.000@ then + return -1 +endi +if $data11 != NULL then + return -1 +endi +if $data20 != @18-09-17 20:39:00.000@ then + return -1 +endi +if $data21 != NULL then + return -1 +endi +if $data30 != @18-09-17 20:42:00.000@ then + return -1 +endi +if $data31 != 0.20000 then + return -1 +endi +if $data40 != @18-09-17 20:45:00.000@ then + return -1 +endi +if $data41 != 0.50000 then + return -1 +endi +if $data50 != @18-09-17 20:48:00.000@ then + return -1 +endi +if $data51 != 0.80000 then + return -1 +endi + +sql select interp(c3) from intp_stb0 where ts >= '2018-09-17 20:35:00.000' and ts <= '2018-09-17 20:50:00.000' every(3m) fill(linear) order by ts desc; +if $rows != 6 then + return -1 +endi +if $data00 != @18-09-17 20:48:00.000@ then + return -1 +endi +if $data01 != 0.80000 then + return -1 +endi +if $data10 != @18-09-17 20:45:00.000@ then + return -1 +endi +if $data11 != 0.50000 then + return -1 +endi +if $data20 != @18-09-17 20:42:00.000@ then + return -1 +endi +if $data21 != 0.20000 then + return -1 +endi +if $data30 != @18-09-17 20:39:00.000@ then + return -1 +endi +if $data31 != NULL then + return -1 +endi +if $data40 != @18-09-17 20:36:00.000@ then + return -1 +endi +if $data41 != NULL then + return -1 +endi +if $data50 != @18-09-17 20:33:00.000@ then + return -1 +endi +if $data51 != NULL then + return -1 +endi + + + +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:20:00' every(1s) fill(linear); +if $rows != 6 then + return -1 +endi +if $data00 != @21-07-25 02:19:54.000@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data10 != @21-07-25 02:19:55.000@ then + return -1 +endi +if $data11 != 3.31818 then + return -1 +endi +if $data20 != @21-07-25 02:19:56.000@ then + return -1 +endi +if $data21 != 3.77273 then + return -1 +endi +if $data30 != @21-07-25 02:19:57.000@ then + return -1 +endi +if $data31 != 4.50000 then + return -1 +endi +if $data40 != @21-07-25 02:19:58.000@ then + return -1 +endi +if $data41 != 7.50000 then + return -1 +endi +if $data50 != @21-07-25 02:19:59.000@ then + return -1 +endi +if $data51 != 9.87500 then + return -1 +endi + +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:20:00' every(1s) fill(value, 1); +if $rows != 6 then + return -1 +endi +if $data00 != @21-07-25 02:19:54.000@ then + return -1 +endi +if $data01 != 1.00000 then + return -1 +endi +if $data10 != @21-07-25 02:19:55.000@ then + return -1 +endi +if $data11 != 1.00000 then + return -1 +endi +if $data20 != @21-07-25 02:19:56.000@ then + return -1 +endi +if $data21 != 1.00000 then + return -1 +endi +if $data30 != @21-07-25 02:19:57.000@ then + return -1 +endi +if $data31 != 1.00000 then + return -1 +endi +if $data40 != @21-07-25 02:19:58.000@ then + return -1 +endi +if $data41 != 1.00000 then + return -1 +endi +if $data50 != @21-07-25 02:19:59.000@ then + return -1 +endi +if $data51 != 1.00000 then + return -1 +endi + +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:20:00' every(1s) fill(NULL); +if $rows != 6 then + return -1 +endi +if $data00 != @21-07-25 02:19:54.000@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data10 != @21-07-25 02:19:55.000@ then + return -1 +endi +if $data11 != NULL then + return -1 +endi +if $data20 != @21-07-25 02:19:56.000@ then + return -1 +endi +if $data21 != NULL then + return -1 +endi +if $data30 != @21-07-25 02:19:57.000@ then + return -1 +endi +if $data31 != NULL then + return -1 +endi +if $data40 != @21-07-25 02:19:58.000@ then + return -1 +endi +if $data41 != NULL then + return -1 +endi +if $data50 != @21-07-25 02:19:59.000@ then + return -1 +endi +if $data51 != NULL then + return -1 +endi + +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:20:00' every(1s) fill(prev); +if $rows != 6 then + return -1 +endi +if $data00 != @21-07-25 02:19:54.000@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data10 != @21-07-25 02:19:55.000@ then + return -1 +endi +if $data11 != 3.00000 then + return -1 +endi +if $data20 != @21-07-25 02:19:56.000@ then + return -1 +endi +if $data21 != 3.00000 then + return -1 +endi +if $data30 != @21-07-25 02:19:57.000@ then + return -1 +endi +if $data31 != 4.00000 then + return -1 +endi +if $data40 != @21-07-25 02:19:58.000@ then + return -1 +endi +if $data41 != 7.00000 then + return -1 +endi +if $data50 != @21-07-25 02:19:59.000@ then + return -1 +endi +if $data51 != 9.00000 then + return -1 +endi + +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:20:00' every(1s) fill(next); +if $rows != 6 then + return -1 +endi +if $data00 != @21-07-25 02:19:54.000@ then + return -1 +endi +if $data01 != 1.00000 then + return -1 +endi +if $data10 != @21-07-25 02:19:55.000@ then + return -1 +endi +if $data11 != 4.00000 then + return -1 +endi +if $data20 != @21-07-25 02:19:56.000@ then + return -1 +endi +if $data21 != 4.00000 then + return -1 +endi +if $data30 != @21-07-25 02:19:57.000@ then + return -1 +endi +if $data31 != 5.00000 then + return -1 +endi +if $data40 != @21-07-25 02:19:58.000@ then + return -1 +endi +if $data41 != 8.00000 then + return -1 +endi +if $data50 != @21-07-25 02:19:59.000@ then + return -1 +endi +if $data51 != 10.00000 then + return -1 +endi + + +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:19:56' every(1s) fill(linear); +if $rows != 0 then + return -1 +endi +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:19:56' every(1s) fill(prev); +if $rows != 2 then + return -1 +endi +if $data00 != @21-07-25 02:19:54.000@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data10 != @21-07-25 02:19:55.000@ then + return -1 +endi +if $data11 != 3.00000 then + return -1 +endi + +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:19:56' every(1s) fill(next); +if $rows != 2 then + return -1 +endi +if $data00 != @21-07-25 02:19:54.000@ then + return -1 +endi +if $data01 != 1.00000 then + return -1 +endi +if $data10 != @21-07-25 02:19:55.000@ then + return -1 +endi +if $data11 != NULL then + return -1 +endi + +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:19:57' every(1s) fill(linear); +if $rows != 3 then + return -1 +endi +if $data00 != @21-07-25 02:19:54.000@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data10 != @21-07-25 02:19:55.000@ then + return -1 +endi +if $data11 != 3.31818 then + return -1 +endi +if $data20 != @21-07-25 02:19:56.000@ then + return -1 +endi +if $data21 != 3.77273 then + return -1 +endi + +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:19:57' every(1s) fill(prev); +if $rows != 3 then + return -1 +endi +if $data00 != @21-07-25 02:19:54.000@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data10 != @21-07-25 02:19:55.000@ then + return -1 +endi +if $data11 != 3.00000 then + return -1 +endi +if $data20 != @21-07-25 02:19:56.000@ then + return -1 +endi +if $data21 != 3.00000 then + return -1 +endi + +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:19:57' every(1s) fill(next); +if $rows != 3 then + return -1 +endi +if $data00 != @21-07-25 02:19:54.000@ then + return -1 +endi +if $data01 != 1.00000 then + return -1 +endi +if $data10 != @21-07-25 02:19:55.000@ then + return -1 +endi +if $data11 != 4.00000 then + return -1 +endi +if $data20 != @21-07-25 02:19:56.000@ then + return -1 +endi +if $data21 != 4.00000 then + return -1 +endi + +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:20:03' every(1s) fill(linear); +if $rows != 10 then + return -1 +endi +if $data00 != @21-07-25 02:19:54.000@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data10 != @21-07-25 02:19:55.000@ then + return -1 +endi +if $data11 != 3.31818 then + return -1 +endi +if $data20 != @21-07-25 02:19:56.000@ then + return -1 +endi +if $data21 != 3.77273 then + return -1 +endi +if $data30 != @21-07-25 02:19:57.000@ then + return -1 +endi +if $data31 != 4.50000 then + return -1 +endi +if $data40 != @21-07-25 02:19:58.000@ then + return -1 +endi +if $data41 != 7.50000 then + return -1 +endi +if $data50 != @21-07-25 02:19:59.000@ then + return -1 +endi +if $data51 != 9.87500 then + return -1 +endi +if $data60 != @21-07-25 02:20:00.000@ then + return -1 +endi +if $data61 != NULL then + return -1 +endi +if $data70 != @21-07-25 02:20:01.000@ then + return -1 +endi +if $data71 != NULL then + return -1 +endi +if $data80 != @21-07-25 02:20:02.000@ then + return -1 +endi +if $data81 != NULL then + return -1 +endi +if $data90 != @21-07-25 02:20:03.000@ then + return -1 +endi +if $data91 != NULL then + return -1 +endi + +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:20:03' every(1s) fill(prev); +if $rows != 10 then + return -1 +endi +if $data00 != @21-07-25 02:19:54.000@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data10 != @21-07-25 02:19:55.000@ then + return -1 +endi +if $data11 != 3.00000 then + return -1 +endi +if $data20 != @21-07-25 02:19:56.000@ then + return -1 +endi +if $data21 != 3.00000 then + return -1 +endi +if $data30 != @21-07-25 02:19:57.000@ then + return -1 +endi +if $data31 != 4.00000 then + return -1 +endi +if $data40 != @21-07-25 02:19:58.000@ then + return -1 +endi +if $data41 != 7.00000 then + return -1 +endi +if $data50 != @21-07-25 02:19:59.000@ then + return -1 +endi +if $data51 != 9.00000 then + return -1 +endi +if $data60 != @21-07-25 02:20:00.000@ then + return -1 +endi +if $data61 != 14.00000 then + return -1 +endi +if $data70 != @21-07-25 02:20:01.000@ then + return -1 +endi +if $data71 != 14.00000 then + return -1 +endi +if $data80 != @21-07-25 02:20:02.000@ then + return -1 +endi +if $data81 != 14.00000 then + return -1 +endi +if $data90 != @21-07-25 02:20:03.000@ then + return -1 +endi +if $data91 != 14.00000 then + return -1 +endi + +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:20:03' every(1s) fill(next); +if $rows != 10 then + return -1 +endi +if $data00 != @21-07-25 02:19:54.000@ then + return -1 +endi +if $data01 != 1.00000 then + return -1 +endi +if $data10 != @21-07-25 02:19:55.000@ then + return -1 +endi +if $data11 != 4.00000 then + return -1 +endi +if $data20 != @21-07-25 02:19:56.000@ then + return -1 +endi +if $data21 != 4.00000 then + return -1 +endi +if $data30 != @21-07-25 02:19:57.000@ then + return -1 +endi +if $data31 != 5.00000 then + return -1 +endi +if $data40 != @21-07-25 02:19:58.000@ then + return -1 +endi +if $data41 != 8.00000 then + return -1 +endi +if $data50 != @21-07-25 02:19:59.000@ then + return -1 +endi +if $data51 != 10.00000 then + return -1 +endi +if $data60 != @21-07-25 02:20:00.000@ then + return -1 +endi +if $data61 != NULL then + return -1 +endi +if $data70 != @21-07-25 02:20:01.000@ then + return -1 +endi +if $data71 != NULL then + return -1 +endi +if $data80 != @21-07-25 02:20:02.000@ then + return -1 +endi +if $data81 != NULL then + return -1 +endi +if $data90 != @21-07-25 02:20:03.000@ then + return -1 +endi +if $data91 != NULL then + return -1 +endi + +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:20:05' every(1s) fill(linear); +if $rows != 12 then + return -1 +endi +if $data00 != @21-07-25 02:19:54.000@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data10 != @21-07-25 02:19:55.000@ then + return -1 +endi +if $data11 != 3.31818 then + return -1 +endi +if $data20 != @21-07-25 02:19:56.000@ then + return -1 +endi +if $data21 != 3.77273 then + return -1 +endi +if $data30 != @21-07-25 02:19:57.000@ then + return -1 +endi +if $data31 != 4.50000 then + return -1 +endi +if $data40 != @21-07-25 02:19:58.000@ then + return -1 +endi +if $data41 != 7.50000 then + return -1 +endi +if $data50 != @21-07-25 02:19:59.000@ then + return -1 +endi +if $data51 != 9.87500 then + return -1 +endi +if $data60 != @21-07-25 02:20:00.000@ then + return -1 +endi +if $data61 != 14.11765 then + return -1 +endi +if $data70 != @21-07-25 02:20:01.000@ then + return -1 +endi +if $data71 != 15.29412 then + return -1 +endi + +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:20:05' every(1s) fill(prev); +if $rows != 12 then + return -1 +endi +if $data00 != @21-07-25 02:19:54.000@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data10 != @21-07-25 02:19:55.000@ then + return -1 +endi +if $data11 != 3.00000 then + return -1 +endi +if $data20 != @21-07-25 02:19:56.000@ then + return -1 +endi +if $data21 != 3.00000 then + return -1 +endi +if $data30 != @21-07-25 02:19:57.000@ then + return -1 +endi +if $data31 != 4.00000 then + return -1 +endi +if $data40 != @21-07-25 02:19:58.000@ then + return -1 +endi +if $data41 != 7.00000 then + return -1 +endi +if $data50 != @21-07-25 02:19:59.000@ then + return -1 +endi +if $data51 != 9.00000 then + return -1 +endi +if $data60 != @21-07-25 02:20:00.000@ then + return -1 +endi +if $data61 != 14.00000 then + return -1 +endi +if $data70 != @21-07-25 02:20:01.000@ then + return -1 +endi +if $data71 != 14.00000 then + return -1 +endi +if $data80 != @21-07-25 02:20:02.000@ then + return -1 +endi +if $data81 != 14.00000 then + return -1 +endi +if $data90 != @21-07-25 02:20:03.000@ then + return -1 +endi +if $data91 != 14.00000 then + return -1 +endi + +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:20:05' every(1s) fill(next); +if $rows != 12 then + return -1 +endi +if $data00 != @21-07-25 02:19:54.000@ then + return -1 +endi +if $data01 != 1.00000 then + return -1 +endi +if $data10 != @21-07-25 02:19:55.000@ then + return -1 +endi +if $data11 != 4.00000 then + return -1 +endi +if $data20 != @21-07-25 02:19:56.000@ then + return -1 +endi +if $data21 != 4.00000 then + return -1 +endi +if $data30 != @21-07-25 02:19:57.000@ then + return -1 +endi +if $data31 != 5.00000 then + return -1 +endi +if $data40 != @21-07-25 02:19:58.000@ then + return -1 +endi +if $data41 != 8.00000 then + return -1 +endi +if $data50 != @21-07-25 02:19:59.000@ then + return -1 +endi +if $data51 != 10.00000 then + return -1 +endi +if $data60 != @21-07-25 02:20:00.000@ then + return -1 +endi +if $data61 != 20.00000 then + return -1 +endi +if $data70 != @21-07-25 02:20:01.000@ then + return -1 +endi +if $data71 != 20.00000 then + return -1 +endi +if $data80 != @21-07-25 02:20:02.000@ then + return -1 +endi +if $data81 != 20.00000 then + return -1 +endi +if $data90 != @21-07-25 02:20:03.000@ then + return -1 +endi +if $data91 != 20.00000 then + return -1 +endi + +sql select interp(pav) from ap1 where ts> '2021-07-25 02:20:02' and ts<='2021-07-25 02:20:05' every(1s) fill(value, 1); +if $rows != 4 then + return -1 +endi +if $data00 != @21-07-25 02:20:02.000@ then + return -1 +endi +if $data01 != 1.00000 then + return -1 +endi +if $data10 != @21-07-25 02:20:03.000@ then + return -1 +endi +if $data11 != 1.00000 then + return -1 +endi +if $data20 != @21-07-25 02:20:04.000@ then + return -1 +endi +if $data21 != 1.00000 then + return -1 +endi +if $data30 != @21-07-25 02:20:05.000@ then + return -1 +endi +if $data31 != 20.00000 then + return -1 +endi + +sql select interp(pav) from ap1 where ts> '2021-07-25 02:20:02' and ts<='2021-07-25 02:20:05' every(1s) fill(null); +if $rows != 4 then + return -1 +endi +if $data00 != @21-07-25 02:20:02.000@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data10 != @21-07-25 02:20:03.000@ then + return -1 +endi +if $data11 != NULL then + return -1 +endi +if $data20 != @21-07-25 02:20:04.000@ then + return -1 +endi +if $data21 != NULL then + return -1 +endi +if $data30 != @21-07-25 02:20:05.000@ then + return -1 +endi +if $data31 != 20.00000 then + return -1 +endi + + +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:20:25' every(1s) fill(linear); +if $rows != 32 then + return -1 +endi +if $data00 != @21-07-25 02:19:54.000@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data10 != @21-07-25 02:19:55.000@ then + return -1 +endi +if $data11 != 3.31818 then + return -1 +endi +if $data20 != @21-07-25 02:19:56.000@ then + return -1 +endi +if $data21 != 3.77273 then + return -1 +endi +if $data30 != @21-07-25 02:19:57.000@ then + return -1 +endi +if $data31 != 4.50000 then + return -1 +endi +if $data40 != @21-07-25 02:19:58.000@ then + return -1 +endi +if $data41 != 7.50000 then + return -1 +endi +if $data50 != @21-07-25 02:19:59.000@ then + return -1 +endi +if $data51 != 9.87500 then + return -1 +endi +if $data60 != @21-07-25 02:20:00.000@ then + return -1 +endi +if $data61 != 14.11765 then + return -1 +endi +if $data70 != @21-07-25 02:20:01.000@ then + return -1 +endi +if $data71 != 15.29412 then + return -1 +endi + +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:20:25' every(1s) fill(prev); +if $rows != 32 then + return -1 +endi +if $data00 != @21-07-25 02:19:54.000@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data10 != @21-07-25 02:19:55.000@ then + return -1 +endi +if $data11 != 3.00000 then + return -1 +endi +if $data20 != @21-07-25 02:19:56.000@ then + return -1 +endi +if $data21 != 3.00000 then + return -1 +endi +if $data30 != @21-07-25 02:19:57.000@ then + return -1 +endi +if $data31 != 4.00000 then + return -1 +endi +if $data40 != @21-07-25 02:19:58.000@ then + return -1 +endi +if $data41 != 7.00000 then + return -1 +endi +if $data50 != @21-07-25 02:19:59.000@ then + return -1 +endi +if $data51 != 9.00000 then + return -1 +endi +if $data60 != @21-07-25 02:20:00.000@ then + return -1 +endi +if $data61 != 14.00000 then + return -1 +endi +if $data70 != @21-07-25 02:20:01.000@ then + return -1 +endi +if $data71 != 14.00000 then + return -1 +endi +if $data80 != @21-07-25 02:20:02.000@ then + return -1 +endi +if $data81 != 14.00000 then + return -1 +endi +if $data90 != @21-07-25 02:20:03.000@ then + return -1 +endi +if $data91 != 14.00000 then + return -1 +endi + +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:20:25' every(1s) fill(next); +if $rows != 32 then + return -1 +endi +if $data00 != @21-07-25 02:19:54.000@ then + return -1 +endi +if $data01 != 1.00000 then + return -1 +endi +if $data10 != @21-07-25 02:19:55.000@ then + return -1 +endi +if $data11 != 4.00000 then + return -1 +endi +if $data20 != @21-07-25 02:19:56.000@ then + return -1 +endi +if $data21 != 4.00000 then + return -1 +endi +if $data30 != @21-07-25 02:19:57.000@ then + return -1 +endi +if $data31 != 5.00000 then + return -1 +endi +if $data40 != @21-07-25 02:19:58.000@ then + return -1 +endi +if $data41 != 8.00000 then + return -1 +endi +if $data50 != @21-07-25 02:19:59.000@ then + return -1 +endi +if $data51 != 10.00000 then + return -1 +endi +if $data60 != @21-07-25 02:20:00.000@ then + return -1 +endi +if $data61 != 20.00000 then + return -1 +endi +if $data70 != @21-07-25 02:20:01.000@ then + return -1 +endi +if $data71 != 20.00000 then + return -1 +endi +if $data80 != @21-07-25 02:20:02.000@ then + return -1 +endi +if $data81 != 20.00000 then + return -1 +endi +if $data90 != @21-07-25 02:20:03.000@ then + return -1 +endi +if $data91 != 20.00000 then + return -1 +endi + + +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:25:00' every(1s) fill(linear); +if $rows != 307 then + return -1 +endi +if $data00 != @21-07-25 02:19:54.000@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data10 != @21-07-25 02:19:55.000@ then + return -1 +endi +if $data11 != 3.31818 then + return -1 +endi +if $data20 != @21-07-25 02:19:56.000@ then + return -1 +endi +if $data21 != 3.77273 then + return -1 +endi +if $data30 != @21-07-25 02:19:57.000@ then + return -1 +endi +if $data31 != 4.50000 then + return -1 +endi +if $data40 != @21-07-25 02:19:58.000@ then + return -1 +endi +if $data41 != 7.50000 then + return -1 +endi +if $data50 != @21-07-25 02:19:59.000@ then + return -1 +endi +if $data51 != 9.87500 then + return -1 +endi +if $data60 != @21-07-25 02:20:00.000@ then + return -1 +endi +if $data61 != 14.11765 then + return -1 +endi +if $data70 != @21-07-25 02:20:01.000@ then + return -1 +endi +if $data71 != 15.29412 then + return -1 +endi + +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:25:00' every(1s) fill(prev); +if $rows != 307 then + return -1 +endi +if $data00 != @21-07-25 02:19:54.000@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data10 != @21-07-25 02:19:55.000@ then + return -1 +endi +if $data11 != 3.00000 then + return -1 +endi +if $data20 != @21-07-25 02:19:56.000@ then + return -1 +endi +if $data21 != 3.00000 then + return -1 +endi +if $data30 != @21-07-25 02:19:57.000@ then + return -1 +endi +if $data31 != 4.00000 then + return -1 +endi +if $data40 != @21-07-25 02:19:58.000@ then + return -1 +endi +if $data41 != 7.00000 then + return -1 +endi +if $data50 != @21-07-25 02:19:59.000@ then + return -1 +endi +if $data51 != 9.00000 then + return -1 +endi +if $data60 != @21-07-25 02:20:00.000@ then + return -1 +endi +if $data61 != 14.00000 then + return -1 +endi +if $data70 != @21-07-25 02:20:01.000@ then + return -1 +endi +if $data71 != 14.00000 then + return -1 +endi +if $data80 != @21-07-25 02:20:02.000@ then + return -1 +endi +if $data81 != 14.00000 then + return -1 +endi +if $data90 != @21-07-25 02:20:03.000@ then + return -1 +endi +if $data91 != 14.00000 then + return -1 +endi + +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:25:00' every(1s) fill(next); +if $rows != 307 then + return -1 +endi +if $data00 != @21-07-25 02:19:54.000@ then + return -1 +endi +if $data01 != 1.00000 then + return -1 +endi +if $data10 != @21-07-25 02:19:55.000@ then + return -1 +endi +if $data11 != 4.00000 then + return -1 +endi +if $data20 != @21-07-25 02:19:56.000@ then + return -1 +endi +if $data21 != 4.00000 then + return -1 +endi +if $data30 != @21-07-25 02:19:57.000@ then + return -1 +endi +if $data31 != 5.00000 then + return -1 +endi +if $data40 != @21-07-25 02:19:58.000@ then + return -1 +endi +if $data41 != 8.00000 then + return -1 +endi +if $data50 != @21-07-25 02:19:59.000@ then + return -1 +endi +if $data51 != 10.00000 then + return -1 +endi +if $data60 != @21-07-25 02:20:00.000@ then + return -1 +endi +if $data61 != 20.00000 then + return -1 +endi +if $data70 != @21-07-25 02:20:01.000@ then + return -1 +endi +if $data71 != 20.00000 then + return -1 +endi +if $data80 != @21-07-25 02:20:02.000@ then + return -1 +endi +if $data81 != 20.00000 then + return -1 +endi +if $data90 != @21-07-25 02:20:03.000@ then + return -1 +endi +if $data91 != 20.00000 then + return -1 +endi + +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 03:25:00' every(1s) fill(linear); +if $rows != 3907 then + return -1 +endi +if $data00 != @21-07-25 02:19:54.000@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data10 != @21-07-25 02:19:55.000@ then + return -1 +endi +if $data11 != 3.31818 then + return -1 +endi +if $data20 != @21-07-25 02:19:56.000@ then + return -1 +endi +if $data21 != 3.77273 then + return -1 +endi +if $data30 != @21-07-25 02:19:57.000@ then + return -1 +endi +if $data31 != 4.50000 then + return -1 +endi +if $data40 != @21-07-25 02:19:58.000@ then + return -1 +endi +if $data41 != 7.50000 then + return -1 +endi +if $data50 != @21-07-25 02:19:59.000@ then + return -1 +endi +if $data51 != 9.87500 then + return -1 +endi +if $data60 != @21-07-25 02:20:00.000@ then + return -1 +endi +if $data61 != 14.11765 then + return -1 +endi +if $data70 != @21-07-25 02:20:01.000@ then + return -1 +endi +if $data71 != 15.29412 then + return -1 +endi + + +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 03:25:00' every(1s) fill(prev); +if $rows != 3907 then + return -1 +endi +if $data00 != @21-07-25 02:19:54.000@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data10 != @21-07-25 02:19:55.000@ then + return -1 +endi +if $data11 != 3.00000 then + return -1 +endi +if $data20 != @21-07-25 02:19:56.000@ then + return -1 +endi +if $data21 != 3.00000 then + return -1 +endi +if $data30 != @21-07-25 02:19:57.000@ then + return -1 +endi +if $data31 != 4.00000 then + return -1 +endi +if $data40 != @21-07-25 02:19:58.000@ then + return -1 +endi +if $data41 != 7.00000 then + return -1 +endi +if $data50 != @21-07-25 02:19:59.000@ then + return -1 +endi +if $data51 != 9.00000 then + return -1 +endi +if $data60 != @21-07-25 02:20:00.000@ then + return -1 +endi +if $data61 != 14.00000 then + return -1 +endi +if $data70 != @21-07-25 02:20:01.000@ then + return -1 +endi +if $data71 != 14.00000 then + return -1 +endi +if $data80 != @21-07-25 02:20:02.000@ then + return -1 +endi +if $data81 != 14.00000 then + return -1 +endi +if $data90 != @21-07-25 02:20:03.000@ then + return -1 +endi +if $data91 != 14.00000 then + return -1 +endi + +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 03:25:00' every(1s) fill(next); +if $rows != 3907 then + return -1 +endi +if $data00 != @21-07-25 02:19:54.000@ then + return -1 +endi +if $data01 != 1.00000 then + return -1 +endi +if $data10 != @21-07-25 02:19:55.000@ then + return -1 +endi +if $data11 != 4.00000 then + return -1 +endi +if $data20 != @21-07-25 02:19:56.000@ then + return -1 +endi +if $data21 != 4.00000 then + return -1 +endi +if $data30 != @21-07-25 02:19:57.000@ then + return -1 +endi +if $data31 != 5.00000 then + return -1 +endi +if $data40 != @21-07-25 02:19:58.000@ then + return -1 +endi +if $data41 != 8.00000 then + return -1 +endi +if $data50 != @21-07-25 02:19:59.000@ then + return -1 +endi +if $data51 != 10.00000 then + return -1 +endi +if $data60 != @21-07-25 02:20:00.000@ then + return -1 +endi +if $data61 != 20.00000 then + return -1 +endi +if $data70 != @21-07-25 02:20:01.000@ then + return -1 +endi +if $data71 != 20.00000 then + return -1 +endi +if $data80 != @21-07-25 02:20:02.000@ then + return -1 +endi +if $data81 != 20.00000 then + return -1 +endi +if $data90 != @21-07-25 02:20:03.000@ then + return -1 +endi +if $data91 != 20.00000 then + return -1 +endi + +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:20:07' every(1s); +if $rows != 1 then + return -1 +endi +if $data00 != @21-07-25 02:20:05.000@ then + return -1 +endi +if $data01 != 20.00000 then + return -1 +endi + diff --git a/tests/script/general/parser/join.sim b/tests/script/general/parser/join.sim new file mode 100644 index 0000000000000000000000000000000000000000..36deea0371486394125355cc92a9785764610569 --- /dev/null +++ b/tests/script/general/parser/join.sim @@ -0,0 +1,523 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c debugFlag -v 135 +system sh/cfg.sh -n dnode1 -c rpcDebugFlag -v 135 +system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 4 + +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = join_db +$tbPrefix = join_tb +$mtPrefix = join_mt +$tbNum = 2 +$rowNum = 1000 +$totalNum = $tbNum * $rowNum + +print =============== join.sim +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +$tstart = 100000 + +sql drop database if exists $db -x step1 +step1: +sql create database if not exists $db keep 36500 +sql use $db +sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12)) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + $tg2 = ' . abc + $tg2 = $tg2 . ' + sql create table $tb using $mt tags( $i , $tg2 ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + $c = $x / 100 + $c = $c * 100 + $c = $x - $c + + $binary = ' . binary + $binary = $binary . $c + $binary = $binary . ' + + $nchar = ' . nchar + $nchar = $nchar . $c + $nchar = $nchar . ' + + sql insert into $tb values ($tstart , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar ) + $tstart = $tstart + 1 + $x = $x + 1 + endw + + $i = $i + 1 + $tstart = 100000 +endw + +sleep 100 + +$tstart = 100000 +$mt = $mtPrefix . 1 . $i +sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12), t3 int) + +$i = 0 +$tbPrefix = join_1_tb + +while $i < $tbNum + $tb = $tbPrefix . $i + $c = $i + $t3 = $i + 1 + + $binary = ' . abc + $binary = $binary . $i + $binary = $binary . ' + + print $binary + sql create table $tb using $mt tags( $i , $binary , $t3 ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + $c = $x / 100 + $c = $c * 100 + $c = $x - $c + + $binary = ' . binary + $binary = $binary . $c + $binary = $binary . ' + + $nchar = ' . nchar + $nchar = $nchar . $c + $nchar = $nchar . ' + + sql insert into $tb values ($tstart , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar ) + $tstart = $tstart + 1 + $x = $x + 1 + endw + + $i = $i + 1 + $tstart = 100000 +endw + +sleep 100 + +$i1 = 1 +$i2 = 0 + +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +$dbPrefix = join_db +$tbPrefix = join_tb +$mtPrefix = join_mt + +$tb1 = $tbPrefix . $i1 +$tb2 = $tbPrefix . $i2 +$ts1 = $tb1 . .ts +$ts2 = $tb2 . .ts + +#single table join sql + +# select duplicate columns +sql select $ts1 , $ts2 from $tb1 , $tb2 where $ts1 = $ts2 + +$val = $rowNum +if $rows != $val then + return -1 +endi + +# select star1 +sql select join_tb1.*, join_tb0.ts from $tb1 , $tb2 where $ts1 = $ts2 + +$val = $rowNum +if $rows != $val then + return -1 +endi + +# select star2 +sql select join_tb1.*, join_tb0.* from $tb1 , $tb2 where $ts1 = $ts2 + +$val = $rowNum +if $rows != $val then + return -1 +endi + +# select star2 +sql select join_tb1.*, join_tb0.* from $tb1 , $tb2 where $ts1 = $ts2 limit 10; + +$val = 10 +if $rows != $val then + return -1 +endi + +# select star2 +sql select join_tb1.*, join_tb0.* from $tb1 , $tb2 where $ts1 = $ts2 limit 10; + +$val = 10 +if $rows != $val then + return -1 +endi + +# select star2 +sql select join_tb1.*, join_tb0.* from $tb1 , $tb2 where $ts1 = $ts2 limit 0; + +$val = 0 +if $rows != $val then + return -1 +endi + +# select star2 +sql select join_tb1.*, join_tb0.* from $tb1 , $tb2 where $ts1 = $ts2 limit 0; + +$val = 0 +if $rows != $val then + return -1 +endi + +#select + where condition +sql select join_tb1.*, join_tb0.* from $tb1 , $tb2 where $ts1 = $ts2 and join_tb1.ts = 100000 limit 10; + +$val = 1 +if $rows != $val then + return -1 +endi + +#select + where condition +sql select join_tb1.*, join_tb0.* from $tb1 , $tb2 where $ts1 = $ts2 and join_tb1.ts >= 100000 and join_tb0.c7 = false limit 10; + +$val = 10 +if $rows != $val then + return -1 +endi + +#select + where condition +sql select join_tb1.*, join_tb0.* from $tb1 , $tb2 where $ts1 = $ts2 and join_tb1.ts >= 100000 and join_tb0.c7 = false limit 10 offset 1; +print $rows +if $rows != 9 then + return -1 +endi + +if $data00 != @70-01-01 08:01:40.100@ then + print $data00 + return -1 +endi + +if $data10 != @70-01-01 08:01:40.200@ then + print $data10 + return -1 +endi + +print data06 = $data06 +print data07 = $data07 +print data08 = $data08 +print data00 = $data00 + +if $data07 != 0 then + return -1 +endi + +#select + where condition ======reverse query +sql select join_tb1.*, join_tb0.* from $tb1 , $tb2 where $ts1 = $ts2 and join_tb1.ts >= 100000 and join_tb0.c7 = true order by join_tb0.ts asc limit 1; + +$val = 1 +if $rows != $val then + return -1 +endi + +$val = @70-01-01 08:01:40.001@ +print $data00, $data01 + +if $data00 != $val then + return -1 +endi + +print 1 +#select + where condition + interval query +sql select count(join_tb1.*) from $tb1 , $tb2 where $ts1 = $ts2 and join_tb1.ts >= 100000 and join_tb0.c7 = true interval(10a) order by join_tb0.ts desc; + +$val = 100 +if $rows != $val then + return -1 +endi + +print 2 +#===========================aggregation=================================== +#select + where condition +sql select count(join_tb1.*), count(join_tb0.*) from $tb1 , $tb2 where $ts1 = $ts2 and join_tb1.ts >= 100000 and join_tb0.c7 = false; + +$val = 10 +if $data00 != $val then + return -1 +endi + +if $data01 != $val then + return -1 +endi + +sql select count(join_tb1.*) + count(join_tb0.*) from join_tb1 , join_tb0 where join_tb1.ts = join_tb0.ts and join_tb1.ts >= 100000 and join_tb0.c7 = false;; +if $rows != 1 then + return -1 +endi + +if $data00 != 20.000000000 then + print expect 20.000000000 actual $data00 + return -1 +endi + +sql select count(join_tb1.*)/10 from join_tb1 , join_tb0 where join_tb1.ts = join_tb0.ts and join_tb1.ts >= 100000 and join_tb0.c7 = false;; +if $data00 != 1.000000000 then + return -1 +endi + +print 3 +#agg + where condition +sql select count(join_tb1.c3), count(join_tb0.ts) from $tb1 , $tb2 where $ts1 = $ts2 and join_tb1.ts <= 100002 and join_tb0.c7 = true; +if $rows != 1 then + return -1 +endi + +print $data00 + +if $data00 != 2 then + return -1 +endi + +if $data01 != 2 then + return -1 +endi + +print 4 +#agg + where condition +sql select count(join_tb1.c3), count(join_tb0.ts), sum(join_tb0.c1), first(join_tb0.c7), last(join_tb1.c3), first(join_tb0.*) from $tb1 , $tb2 where $ts1 = $ts2 and join_tb1.ts <= 100002 and join_tb0.c7 = true; + +$val = 2 +if $data00 != $val then + return -1 +endi + +if $data01 != $val then + return -1 +endi + +if $data02 != 3 then + return -1 +endi + +if $data03 != 1 then + return -1 +endi + +if $data04 != 2 then + return -1 +endi + +print =============== join.sim -- error sql + +sql_error select count(join_tb1.c3), count(join_tb0.ts), sum(join_tb0.c1), first(join_tb0.c7), last(join_tb1.c3) from $tb1 , $tb2 where join_tb1.ts <= 100002 and join_tb0.c7 = true; +sql_error select count(join_tb1.c3), last(join_tb1.c3) from $tb1 , $tb2 where join_tb1.ts = join_tb0.ts or join_tb1.ts <= 100002 and join_tb0.c7 = true; +sql_error select count(join_tb3.*) from $tb1 , $tb2 where join_tb1.ts = join_tb0.ts and join_tb1.ts <= 100002 and join_tb0.c7 = true; +sql_error select first(join_tb1.*) from $tb1 , $tb2 where join_tb1.ts = join_tb0.ts and join_tb1.ts <= 100002 or join_tb0.c7 = true; +sql_error select join_tb3.* from $tb1 , $tb2 where join_tb1.ts = join_tb0.ts and join_tb1.ts <= 100002 and join_tb0.c7 = true; +sql_error select join_tb1.* from $tb1 , $tb2 where join_tb1.ts = join_tb0.ts and join_tb1.ts = join_tb0.c1; +sql_error select join_tb1.* from $tb1 , $tb2 where join_tb1.ts = join_tb0.c1; +sql_error select join_tb1.* from $tb1 , $tb2 where join_tb1.c7 = join_tb0.c1; +sql_error select join_tb1.* from $tb1 , $tb2 where join_tb1.ts > join_tb0.ts; +sql_error select join_tb1.* from $tb1 , $tb2 where join_tb1.ts <> join_tb0.ts; +sql_error select join_tb1.* from $tb1 , $tb2 where join_tb1.ts != join_tb0.ts and join_tb1.ts > 100000; +sql_error select join_tb1.* from $tb1 , $tb1 where join_tb1.ts = join_tb1.ts and join_tb1.ts >= 100000; +sql_error select join_tb1.* from $tb1 , $tb1 where join_tb1.ts = join_tb1.ts order by ts; +sql_error select join_tb1.* from $tb1 , $tb1 where join_tb1.ts = join_tb1.ts order by join_tb1.c7; +sql_error select * from join_tb0, join_tb1 +sql_error select last_row(*) from join_tb0, join_tb1 +sql_error select last_row(*) from $tb1, $tb2 where join_tb1.ts < now +sql_error select last_row(*) from $tb1, $tb2 where join_tb1.ts = join_tb2.ts + +print ==================================super table join ============================== +# select duplicate columns +sql select join_mt0.* from join_mt0, join_mt1 where join_mt0.ts = join_mt1.ts and join_mt0.t1=join_mt1.t1; + +$val = $rowNum + $rowNum +print $val +print $rows +if $rows != $val then + print expect $val , actual:$rows + return -1 +endi + +sql select join_mt0.* from join_mt0, join_mt1 where join_mt0.ts = join_mt1.ts and join_mt0.t1=join_mt1.t1 and join_mt0.ts = 100000; + +$val = 2 +if $rows != $val then + return -1 +endi + +sql select join_mt1.* from join_mt1 + +print $rows +if $rows != 2000 then + return -1 +endi + +sql select join_mt0.* from join_mt0, join_mt1 where join_mt0.ts = join_mt1.ts and join_mt0.t1=join_mt1.t1; + +$val = 2000 +if $rows != $val then + return -1 +endi + +sql select join_mt0.* from join_mt0, join_mt1 where join_mt0.ts = join_mt1.ts and join_mt0.t1=join_mt1.t1 and join_mt0.c2=99; + +$val = 20 +if $rows != $val then + return -1 +endi + +sql select count(*) from join_mt0, join_mt1 where join_mt0.ts = join_mt1.ts and join_mt0.t1=join_mt1.t1 and join_mt0.c2=99; + +$val = 20 +if $data00 != $val then + print expect 20, actual:$data00 + return -1 +endi + +sql select count(*) from join_mt0, join_mt1 where join_mt0.ts = join_mt1.ts and join_mt0.t1=join_mt1.t1 and join_mt0.c2=99 and join_mt1.ts=100999; + +$val = 2 +if $data00 != $val then + return -1 +endi + +# agg +sql select sum(join_mt0.c1) from join_mt0, join_mt1 where join_mt0.ts = join_mt1.ts and join_mt0.t1=join_mt1.t1 and join_mt0.c2=99 and join_mt1.ts=100999; + +$val = 198 +if $data00 != $val then + return -1 +endi + +sql select sum(join_mt0.c1)+sum(join_mt0.c1) from join_mt0, join_mt1 where join_mt0.ts = join_mt1.ts and join_mt0.t1=join_mt1.t1 and join_mt0.c2=99 and join_mt1.ts=100999; +if $rows != 1 then + return -1 +endi + +if $data00 != 396.000000000 then + return -1 +endi + +# first/last +sql select count(join_mt0.c1), sum(join_mt1.c2), first(join_mt0.c5), last(join_mt1.c7) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts and join_mt0.t1=1 interval(10a) order by join_mt0.ts asc; + +$val = 100 +if $rows != $val then + print $rows + return -1 +endi + +$val = 10 +if $data01 != $val then + return -1 +endi + +$val = 45.000000000 +print $data02 +if $data02 != $val then + return -1 +endi + +$val = 0 +if $data03 != 0 then + return -1 +endi + +# order by first/last +sql select count(join_mt0.c1), sum(join_mt1.c2), first(join_mt0.c5), last(join_mt1.c7) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts and join_mt0.t1=1 interval(10a) order by join_mt0.ts desc; + +$val = 100 +if $rows != $val then + return -1 +endi + +print ================>TD-5600 +sql select first(join_tb0.c8),first(join_tb0.c9) from join_tb1 , join_tb0 where join_tb1.ts = join_tb0.ts and join_tb1.ts <= 100002 and join_tb1.ts>=100000 interval(1s); + + +#=============================================================== +sql select first(join_tb0.c8),first(join_tb0.c9) from join_tb1 , join_tb0 where join_tb1.ts = join_tb0.ts and join_tb1.ts <= 100002 and join_tb0.c7 = true + +#====================group by========================================= +print =================>"group by not supported" + + + +#======================limit offset=================================== +# tag values not int +sql_error select count(*) from join_mt0, join_mt1 where join_mt0.ts=join_mt1.ts and join_mt0.t2=join_mt1.t2; + +# tag type not identical +sql_error select count(*) from join_mt0, join_mt1 where join_mt1.t2 = join_mt0.t1 and join_mt1.ts=join_mt0.ts; + +# table/super table join +sql_error select count(join_mt0.c1) from join_mt0, join_tb1 where join_mt0.ts=join_tb1.ts + +# multi-condition + + +# self join +sql_error select count(join_mt0.c1), count(join_mt0.c2) from join_mt0, join_mt0 where join_mt0.ts=join_mt0.ts and join_mt0.t1=join_mt0.t1; + +# missing ts equals +sql_error select sum(join_mt1.c2) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1; + +# missing tag equals +sql_error select count(join_mt1.c3) from join_mt0, join_mt1 where join_mt0.ts=join_mt1.ts; + +# tag values are identical error +sql create table m1(ts timestamp, k int) tags(a int); +sql create table m2(ts timestamp, k int) tags(a int); + +sql create table tm1 using m1 tags(1); +sql create table tm2 using m1 tags(1); + +sql insert into tm1 using m1 tags(1) values(1000000, 1)(2000000, 2); +sql insert into tm2 using m1 tags(1) values(1000000, 1)(2000000, 2); + +sql insert into um1 using m2 tags(1) values(1000001, 10)(2000000, 20); +sql insert into um2 using m2 tags(9) values(1000001, 10)(2000000, 20); + +sql_error select count(*) from m1,m2 where m1.a=m2.a and m1.ts=m2.ts; + +print ====> empty table/empty super-table join test, add for no result join test +sql create database ux1; +sql use ux1; +sql create table m1(ts timestamp, k int) tags(a binary(12), b int); +sql create table tm0 using m1 tags('abc', 1); +sql create table m2(ts timestamp, k int) tags(a int, b binary(12)); + +sql select count(*) from m1, m2 where m1.ts=m2.ts and m1.b=m2.a; +if $rows != 0 then + return -1 +endi + +sql create table tm2 using m2 tags(2, 'abc'); +sql select count(*) from tm0, tm2 where tm0.ts=tm2.ts; +if $rows != 0 then + return -1 +endi + +sql select count(*) from m1, m2 where m1.ts=m2.ts and m1.b=m2.a; +if $rows != 0 then + return -1 +endi + +sql drop table tm2; +sql select count(*) from m1, m2 where m1.ts=m2.ts and m1.b=m2.a; +sql drop database ux1; + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/join_manyblocks.sim b/tests/script/general/parser/join_manyblocks.sim new file mode 100644 index 0000000000000000000000000000000000000000..fddd59c0a148975fd1bb6d63dbfb01ab46baa376 --- /dev/null +++ b/tests/script/general/parser/join_manyblocks.sim @@ -0,0 +1,93 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 4 + +system sh/exec.sh -n dnode1 -s start +sql connect +sleep 100 + +$dbPrefix = join_m_db +$tbPrefix = join_tb +$mtPrefix = join_mt +$tbNum = 3 +$rowNum = 20000 +$totalNum = $tbNum * $rowNum + +print =============== join_manyBlocks.sim +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +$tstart = 100000 + +sql drop database if exists $db -x step1 +step1: +sql create database if not exists $db keep 36500 + +sql use $db +sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12)) + +$mt1 = $mtPrefix . 1 . $i +sql create table $mt1 (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12), t3 int) + +$i = 0 +$tbPrefix1 = join_1_tb + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + $tg2 = ' . abc + $tg2 = $tg2 . ' + sql create table $tb using $mt tags( $i , $tg2 ) + + $tb1 = $tbPrefix1 . $i + $c = $i + $t3 = $i + 1 + + $binary = ' . abc + $binary = $binary . $i + $binary = $binary . ' + + print $binary + sql create table $tb1 using $mt1 tags( $i , $binary , $t3 ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + $c = $x / 100 + $c = $c * 100 + $c = $x - $c + + $binary = ' . binary + $binary = $binary . $c + $binary = $binary . ' + + $nchar = ' . nchar + $nchar = $nchar . $c + $nchar = $nchar . ' + + sql insert into $tb values ($tstart , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar ) $tb1 values ($tstart , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar ) + + $tstart = $tstart + 1 + $x = $x + 1 + endw + + $i = $i + 1 + $tstart = 100000 +endw + +sleep 100 + +print ===============join_manyblocks.sim +print ==============> td-3313 +sql select join_mt0.ts,join_mt0.ts,join_mt0.t1 from join_mt0, join_mt1 where join_mt0.ts=join_mt1.ts and join_mt0.t1=join_mt1.t1; + +print $row +if $row != 60000 then + print expect 60000, actual: $row + return -1 +endi + +print ======= second tags join diff --git a/tests/script/general/parser/join_multitables.sim b/tests/script/general/parser/join_multitables.sim new file mode 100644 index 0000000000000000000000000000000000000000..d675499640b890398859243d49cfb04d9e1e7579 --- /dev/null +++ b/tests/script/general/parser/join_multitables.sim @@ -0,0 +1,2315 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 0 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2 +system sh/exec.sh -n dnode1 -s start + +sleep 100 +sql connect +print ======================== dnode1 start + +$db = testdb + +sql create database $db +sql use $db + +sql create stable st0 (ts timestamp, f1 int, f2 double, f3 binary(10)) tags(id1 int, id2 smallint, id3 double, id4 bool, id5 binary(5)); +sql create stable st1 (ts timestamp, f1 int, f2 double, f3 binary(10)) tags(id1 int, id2 smallint, id3 double, id4 bool, id5 binary(5)); +sql create stable st2 (ts timestamp, f1 int, f2 double, f3 binary(10)) tags(id1 int, id2 smallint, id3 double, id4 bool, id5 binary(5)); +sql create stable st3 (ts timestamp, f1 int, f2 double, f3 binary(10)) tags(id1 int, id2 smallint, id3 double, id4 bool, id5 binary(5)); +sql create stable st4 (ts timestamp, f1 int, f2 double, f3 binary(10)) tags(id1 int, id2 smallint, id3 double, id4 bool, id5 binary(5)); +sql create stable st5 (ts timestamp, f1 int, f2 double, f3 binary(10)) tags(id1 int, id2 smallint, id3 double, id4 bool, id5 binary(5)); +sql create stable st6 (ts timestamp, f1 int, f2 double, f3 binary(10)) tags(id1 int, id2 smallint, id3 double, id4 bool, id5 binary(5)); +sql create stable st7 (ts timestamp, f1 int, f2 double, f3 binary(10)) tags(id1 int, id2 smallint, id3 double, id4 bool, id5 binary(5)); +sql create stable st8 (ts timestamp, f1 int, f2 double, f3 binary(10)) tags(id1 int, id2 smallint, id3 double, id4 bool, id5 binary(5)); +sql create stable st9 (ts timestamp, f1 int, f2 double, f3 binary(10)) tags(id1 int, id2 smallint, id3 double, id4 bool, id5 binary(5)); +sql create stable sta (ts timestamp, f1 int, f2 double, f3 binary(10)) tags(id1 int, id2 smallint, id3 double, id4 bool, id5 binary(5)); +sql create stable stb (ts timestamp, f1 int, f2 double, f3 binary(10)) tags(id1 int, id2 smallint, id3 double, id4 bool, id5 binary(5)); + +sql create table tb0_1 using st0 tags(0,1,2.0,true,'3'); +sql create table tb0_2 using st0 tags(1,2,3.0,false,'4'); +sql create table tb0_3 using st0 tags(2,3,4.0,true,'5'); +sql create table tb0_4 using st0 tags(3,4,5.0,false,'6'); +sql create table tb0_5 using st0 tags(4,5,6.0,true,'7'); + +sql create table tb1_1 using st1 tags(0,1,2.0,true,'3'); +sql create table tb1_2 using st1 tags(1,2,3.0,false,'4'); +sql create table tb1_3 using st1 tags(2,3,4.0,true,'5'); +sql create table tb1_4 using st1 tags(3,4,5.0,false,'6'); +sql create table tb1_5 using st1 tags(4,5,6.0,true,'7'); + +sql create table tb2_1 using st2 tags(0,1,2.0,true,'3'); +sql create table tb2_2 using st2 tags(1,2,3.0,false,'4'); +sql create table tb2_3 using st2 tags(2,3,4.0,true,'5'); +sql create table tb2_4 using st2 tags(3,4,5.0,false,'6'); +sql create table tb2_5 using st2 tags(4,5,6.0,true,'7'); + +sql create table tb3_1 using st3 tags(0,1,2.0,true,'3'); +sql create table tb3_2 using st3 tags(1,2,3.0,false,'4'); +sql create table tb3_3 using st3 tags(2,3,4.0,true,'5'); +sql create table tb3_4 using st3 tags(3,4,5.0,false,'6'); +sql create table tb3_5 using st3 tags(4,5,6.0,true,'7'); + +sql create table tb4_1 using st4 tags(0,1,2.0,true,'3'); +sql create table tb4_2 using st4 tags(1,2,3.0,false,'4'); +sql create table tb4_3 using st4 tags(2,3,4.0,true,'5'); +sql create table tb4_4 using st4 tags(3,4,5.0,false,'6'); +sql create table tb4_5 using st4 tags(4,5,6.0,true,'7'); + +sql create table tb5_1 using st5 tags(0,1,2.0,true,'3'); +sql create table tb5_2 using st5 tags(1,2,3.0,false,'4'); +sql create table tb5_3 using st5 tags(2,3,4.0,true,'5'); +sql create table tb5_4 using st5 tags(3,4,5.0,false,'6'); +sql create table tb5_5 using st5 tags(4,5,6.0,true,'7'); + +sql create table tb6_1 using st6 tags(0,1,2.0,true,'3'); +sql create table tb6_2 using st6 tags(1,2,3.0,false,'4'); +sql create table tb6_3 using st6 tags(2,3,4.0,true,'5'); +sql create table tb6_4 using st6 tags(3,4,5.0,false,'6'); +sql create table tb6_5 using st6 tags(4,5,6.0,true,'7'); + +sql create table tb7_1 using st7 tags(0,1,2.0,true,'3'); +sql create table tb7_2 using st7 tags(1,2,3.0,false,'4'); +sql create table tb7_3 using st7 tags(2,3,4.0,true,'5'); +sql create table tb7_4 using st7 tags(3,4,5.0,false,'6'); +sql create table tb7_5 using st7 tags(4,5,6.0,true,'7'); + +sql create table tb8_1 using st8 tags(0,1,2.0,true,'3'); +sql create table tb8_2 using st8 tags(1,2,3.0,false,'4'); +sql create table tb8_3 using st8 tags(2,3,4.0,true,'5'); +sql create table tb8_4 using st8 tags(3,4,5.0,false,'6'); +sql create table tb8_5 using st8 tags(4,5,6.0,true,'7'); + +sql create table tb9_1 using st9 tags(0,1,2.0,true,'3'); +sql create table tb9_2 using st9 tags(1,2,3.0,false,'4'); +sql create table tb9_3 using st9 tags(2,3,4.0,true,'5'); +sql create table tb9_4 using st9 tags(3,4,5.0,false,'6'); +sql create table tb9_5 using st9 tags(4,5,6.0,true,'7'); + +sql create table tba_1 using sta tags(0,1,2.0,true,'3'); +sql create table tba_2 using sta tags(0,1,2.0,true,'3'); +sql create table tba_3 using sta tags(0,1,2.0,true,'3'); +sql create table tba_4 using sta tags(0,1,2.0,true,'3'); +sql create table tba_5 using sta tags(0,1,2.0,true,'3'); + +sql create table tbb_1 using stb tags(0,1,2.0,true,'3'); +sql create table tbb_2 using stb tags(0,1,2.0,true,'3'); +sql create table tbb_3 using stb tags(0,1,2.0,true,'3'); +sql create table tbb_4 using stb tags(0,1,2.0,true,'3'); +sql create table tbb_5 using stb tags(0,1,2.0,true,'3'); + +sql insert into tb0_1 values('2021-03-01 01:00:00.000', 9901,9901.0,'01'); +sql insert into tb0_1 values('2021-03-02 01:00:00.000', 9901,9901.0,'01'); +sql insert into tb0_1 values('2021-03-03 01:00:00.000', 9901,9901.0,'01'); +sql insert into tb0_1 values('2021-03-04 01:00:00.000', 9901,9901.0,'01'); +sql insert into tb0_1 values('2021-03-05 01:00:00.000', 9901,9901.0,'01'); +sql insert into tb0_2 values('2021-03-01 02:00:00.000', 9902,9902.0,'02'); +sql insert into tb0_2 values('2021-03-02 02:00:00.000', 9902,9902.0,'02'); +sql insert into tb0_2 values('2021-03-03 02:00:00.000', 9902,9902.0,'02'); +sql insert into tb0_2 values('2021-03-04 02:00:00.000', 9902,9902.0,'02'); +sql insert into tb0_2 values('2021-03-05 02:00:00.000', 9902,9902.0,'02'); +sql insert into tb0_3 values('2021-03-01 03:00:00.000', 9903,9903.0,'03'); +sql insert into tb0_3 values('2021-03-02 03:00:00.000', 9903,9903.0,'03'); +sql insert into tb0_3 values('2021-03-03 03:00:00.000', 9903,9903.0,'03'); +sql insert into tb0_3 values('2021-03-04 03:00:00.000', 9903,9903.0,'03'); +sql insert into tb0_3 values('2021-03-05 03:00:00.000', 9903,9903.0,'03'); +sql insert into tb0_4 values('2021-03-01 04:00:00.000', 9904,9904.0,'04'); +sql insert into tb0_4 values('2021-03-02 04:00:00.000', 9904,9904.0,'04'); +sql insert into tb0_4 values('2021-03-03 04:00:00.000', 9904,9904.0,'04'); +sql insert into tb0_4 values('2021-03-04 04:00:00.000', 9904,9904.0,'04'); +sql insert into tb0_4 values('2021-03-05 04:00:00.000', 9904,9904.0,'04'); +sql insert into tb0_5 values('2021-03-01 05:00:00.000', 9905,9905.0,'05'); +sql insert into tb0_5 values('2021-03-02 05:00:00.000', 9905,9905.0,'05'); +sql insert into tb0_5 values('2021-03-03 05:00:00.000', 9905,9905.0,'05'); +sql insert into tb0_5 values('2021-03-04 05:00:00.000', 9905,9905.0,'05'); +sql insert into tb0_5 values('2021-03-05 05:00:00.000', 9905,9905.0,'05'); + +sql insert into tb1_1 values('2021-03-01 01:00:00.000', 9911,9911.0,'11'); +sql insert into tb1_1 values('2021-03-02 01:00:00.000', 9911,9911.0,'11'); +sql insert into tb1_1 values('2021-03-03 01:00:00.000', 9911,9911.0,'11'); +sql insert into tb1_1 values('2021-03-04 01:00:00.000', 9911,9911.0,'11'); +sql insert into tb1_1 values('2021-03-05 01:00:00.000', 9911,9911.0,'11'); +sql insert into tb1_2 values('2021-03-01 02:00:00.000', 9912,9912.0,'12'); +sql insert into tb1_2 values('2021-03-02 02:00:00.000', 9912,9912.0,'12'); +sql insert into tb1_2 values('2021-03-03 02:00:00.000', 9912,9912.0,'12'); +sql insert into tb1_2 values('2021-03-04 02:00:00.000', 9912,9912.0,'12'); +sql insert into tb1_2 values('2021-03-05 02:00:00.000', 9912,9912.0,'12'); +sql insert into tb1_3 values('2021-03-01 03:00:00.000', 9913,9913.0,'13'); +sql insert into tb1_3 values('2021-03-02 03:00:00.000', 9913,9913.0,'13'); +sql insert into tb1_3 values('2021-03-03 03:00:00.000', 9913,9913.0,'13'); +sql insert into tb1_3 values('2021-03-04 03:00:00.000', 9913,9913.0,'13'); +sql insert into tb1_3 values('2021-03-05 03:00:00.000', 9913,9913.0,'13'); +sql insert into tb1_4 values('2021-03-01 04:00:00.000', 9914,9914.0,'14'); +sql insert into tb1_4 values('2021-03-02 04:00:00.000', 9914,9914.0,'14'); +sql insert into tb1_4 values('2021-03-03 04:00:00.000', 9914,9914.0,'14'); +sql insert into tb1_4 values('2021-03-04 04:00:00.000', 9914,9914.0,'14'); +sql insert into tb1_4 values('2021-03-05 04:00:00.000', 9914,9914.0,'14'); +sql insert into tb1_5 values('2021-03-01 05:00:00.000', 9915,9915.0,'15'); +sql insert into tb1_5 values('2021-03-02 05:00:00.000', 9915,9915.0,'15'); +sql insert into tb1_5 values('2021-03-03 05:00:00.000', 9915,9915.0,'15'); +sql insert into tb1_5 values('2021-03-04 05:00:00.000', 9915,9915.0,'15'); +sql insert into tb1_5 values('2021-03-05 05:00:00.000', 9915,9915.0,'15'); + +sql insert into tb2_1 values('2021-03-01 01:00:00.000', 9921,9921.0,'21'); +sql insert into tb2_1 values('2021-03-02 01:00:00.000', 9921,9921.0,'21'); +sql insert into tb2_1 values('2021-03-03 01:00:00.000', 9921,9921.0,'21'); +sql insert into tb2_1 values('2021-03-04 01:00:00.000', 9921,9921.0,'21'); +sql insert into tb2_1 values('2021-03-05 01:00:00.000', 9921,9921.0,'21'); +sql insert into tb2_2 values('2021-03-01 02:00:00.000', 9922,9922.0,'22'); +sql insert into tb2_2 values('2021-03-02 02:00:00.000', 9922,9922.0,'22'); +sql insert into tb2_2 values('2021-03-03 02:00:00.000', 9922,9922.0,'22'); +sql insert into tb2_2 values('2021-03-04 02:00:00.000', 9922,9922.0,'22'); +sql insert into tb2_2 values('2021-03-05 02:00:00.000', 9922,9922.0,'22'); +sql insert into tb2_3 values('2021-03-01 03:00:00.000', 9923,9923.0,'23'); +sql insert into tb2_3 values('2021-03-02 03:00:00.000', 9923,9923.0,'23'); +sql insert into tb2_3 values('2021-03-03 03:00:00.000', 9923,9923.0,'23'); +sql insert into tb2_3 values('2021-03-04 03:00:00.000', 9923,9923.0,'23'); +sql insert into tb2_3 values('2021-03-05 03:00:00.000', 9923,9923.0,'23'); +sql insert into tb2_4 values('2021-03-01 04:00:00.000', 9924,9924.0,'24'); +sql insert into tb2_4 values('2021-03-02 04:00:00.000', 9924,9924.0,'24'); +sql insert into tb2_4 values('2021-03-03 04:00:00.000', 9924,9924.0,'24'); +sql insert into tb2_4 values('2021-03-04 04:00:00.000', 9924,9924.0,'24'); +sql insert into tb2_4 values('2021-03-05 04:00:00.000', 9924,9924.0,'24'); +sql insert into tb2_5 values('2021-03-01 05:00:00.000', 9925,9925.0,'25'); +sql insert into tb2_5 values('2021-03-02 05:00:00.000', 9925,9925.0,'25'); +sql insert into tb2_5 values('2021-03-03 05:00:00.000', 9925,9925.0,'25'); +sql insert into tb2_5 values('2021-03-04 05:00:00.000', 9925,9925.0,'25'); +sql insert into tb2_5 values('2021-03-05 05:00:00.000', 9925,9925.0,'25'); + + +sql insert into tb3_1 values('2021-03-01 01:00:00.000', 9931,9931.0,'31'); +sql insert into tb3_1 values('2021-03-02 01:00:00.000', 9931,9931.0,'31'); +sql insert into tb3_1 values('2021-03-03 01:00:00.000', 9931,9931.0,'31'); +sql insert into tb3_1 values('2021-03-04 01:00:00.000', 9931,9931.0,'31'); +sql insert into tb3_1 values('2021-03-05 01:00:00.000', 9931,9931.0,'31'); +sql insert into tb3_2 values('2021-03-01 02:00:00.000', 9932,9932.0,'32'); +sql insert into tb3_2 values('2021-03-02 02:00:00.000', 9932,9932.0,'32'); +sql insert into tb3_2 values('2021-03-03 02:00:00.000', 9932,9932.0,'32'); +sql insert into tb3_2 values('2021-03-04 02:00:00.000', 9932,9932.0,'32'); +sql insert into tb3_2 values('2021-03-05 02:00:00.000', 9932,9932.0,'32'); +sql insert into tb3_3 values('2021-03-01 03:00:00.000', 9933,9933.0,'33'); +sql insert into tb3_3 values('2021-03-02 03:00:00.000', 9933,9933.0,'33'); +sql insert into tb3_3 values('2021-03-03 03:00:00.000', 9933,9933.0,'33'); +sql insert into tb3_3 values('2021-03-04 03:00:00.000', 9933,9933.0,'33'); +sql insert into tb3_3 values('2021-03-05 03:00:00.000', 9933,9933.0,'33'); +sql insert into tb3_4 values('2021-03-01 04:00:00.000', 9934,9934.0,'34'); +sql insert into tb3_4 values('2021-03-02 04:00:00.000', 9934,9934.0,'34'); +sql insert into tb3_4 values('2021-03-03 04:00:00.000', 9934,9934.0,'34'); +sql insert into tb3_4 values('2021-03-04 04:00:00.000', 9934,9934.0,'34'); +sql insert into tb3_4 values('2021-03-05 04:00:00.000', 9934,9934.0,'34'); +sql insert into tb3_5 values('2021-03-01 05:00:00.000', 9935,9935.0,'35'); +sql insert into tb3_5 values('2021-03-02 05:00:00.000', 9935,9935.0,'35'); +sql insert into tb3_5 values('2021-03-03 05:00:00.000', 9935,9935.0,'35'); +sql insert into tb3_5 values('2021-03-04 05:00:00.000', 9935,9935.0,'35'); +sql insert into tb3_5 values('2021-03-05 05:00:00.000', 9935,9935.0,'35'); + + +sql insert into tb4_1 values('2021-03-01 01:00:00.000', 9941,9941.0,'41'); +sql insert into tb4_1 values('2021-03-02 01:00:00.000', 9941,9941.0,'41'); +sql insert into tb4_1 values('2021-03-03 01:00:00.000', 9941,9941.0,'41'); +sql insert into tb4_1 values('2021-03-04 01:00:00.000', 9941,9941.0,'41'); +sql insert into tb4_1 values('2021-03-05 01:00:00.000', 9941,9941.0,'41'); +sql insert into tb4_2 values('2021-03-01 02:00:00.000', 9942,9942.0,'42'); +sql insert into tb4_2 values('2021-03-02 02:00:00.000', 9942,9942.0,'42'); +sql insert into tb4_2 values('2021-03-03 02:00:00.000', 9942,9942.0,'42'); +sql insert into tb4_2 values('2021-03-04 02:00:00.000', 9942,9942.0,'42'); +sql insert into tb4_2 values('2021-03-05 02:00:00.000', 9942,9942.0,'42'); +sql insert into tb4_3 values('2021-03-01 03:00:00.000', 9943,9943.0,'43'); +sql insert into tb4_3 values('2021-03-02 03:00:00.000', 9943,9943.0,'43'); +sql insert into tb4_3 values('2021-03-03 03:00:00.000', 9943,9943.0,'43'); +sql insert into tb4_3 values('2021-03-04 03:00:00.000', 9943,9943.0,'43'); +sql insert into tb4_3 values('2021-03-05 03:00:00.000', 9943,9943.0,'43'); +sql insert into tb4_4 values('2021-03-01 04:00:00.000', 9944,9944.0,'44'); +sql insert into tb4_4 values('2021-03-02 04:00:00.000', 9944,9944.0,'44'); +sql insert into tb4_4 values('2021-03-03 04:00:00.000', 9944,9944.0,'44'); +sql insert into tb4_4 values('2021-03-04 04:00:00.000', 9944,9944.0,'44'); +sql insert into tb4_4 values('2021-03-05 04:00:00.000', 9944,9944.0,'44'); +sql insert into tb4_5 values('2021-03-01 05:00:00.000', 9945,9945.0,'45'); +sql insert into tb4_5 values('2021-03-02 05:00:00.000', 9945,9945.0,'45'); +sql insert into tb4_5 values('2021-03-03 05:00:00.000', 9945,9945.0,'45'); +sql insert into tb4_5 values('2021-03-04 05:00:00.000', 9945,9945.0,'45'); +sql insert into tb4_5 values('2021-03-05 05:00:00.000', 9945,9945.0,'45'); + +sql insert into tb5_1 values('2021-03-01 01:00:00.000', 9951,9951.0,'51'); +sql insert into tb5_1 values('2021-03-02 01:00:00.000', 9951,9951.0,'51'); +sql insert into tb5_1 values('2021-03-03 01:00:00.000', 9951,9951.0,'51'); +sql insert into tb5_1 values('2021-03-04 01:00:00.000', 9951,9951.0,'51'); +sql insert into tb5_1 values('2021-03-05 01:00:00.000', 9951,9951.0,'51'); +sql insert into tb5_2 values('2021-03-01 02:00:00.000', 9952,9952.0,'52'); +sql insert into tb5_2 values('2021-03-02 02:00:00.000', 9952,9952.0,'52'); +sql insert into tb5_2 values('2021-03-03 02:00:00.000', 9952,9952.0,'52'); +sql insert into tb5_2 values('2021-03-04 02:00:00.000', 9952,9952.0,'52'); +sql insert into tb5_2 values('2021-03-05 02:00:00.000', 9952,9952.0,'52'); +sql insert into tb5_3 values('2021-03-01 03:00:00.000', 9953,9953.0,'53'); +sql insert into tb5_3 values('2021-03-02 03:00:00.000', 9953,9953.0,'53'); +sql insert into tb5_3 values('2021-03-03 03:00:00.000', 9953,9953.0,'53'); +sql insert into tb5_3 values('2021-03-04 03:00:00.000', 9953,9953.0,'53'); +sql insert into tb5_3 values('2021-03-05 03:00:00.000', 9953,9953.0,'53'); +sql insert into tb5_4 values('2021-03-01 04:00:00.000', 9954,9954.0,'54'); +sql insert into tb5_4 values('2021-03-02 04:00:00.000', 9954,9954.0,'54'); +sql insert into tb5_4 values('2021-03-03 04:00:00.000', 9954,9954.0,'54'); +sql insert into tb5_4 values('2021-03-04 04:00:00.000', 9954,9954.0,'54'); +sql insert into tb5_4 values('2021-03-05 04:00:00.000', 9954,9954.0,'54'); +sql insert into tb5_5 values('2021-03-01 05:00:00.000', 9955,9955.0,'55'); +sql insert into tb5_5 values('2021-03-02 05:00:00.000', 9955,9955.0,'55'); +sql insert into tb5_5 values('2021-03-03 05:00:00.000', 9955,9955.0,'55'); +sql insert into tb5_5 values('2021-03-04 05:00:00.000', 9955,9955.0,'55'); +sql insert into tb5_5 values('2021-03-05 05:00:00.000', 9955,9955.0,'55'); + +sql insert into tb6_1 values('2021-03-01 01:00:00.000', 9961,9961.0,'61'); +sql insert into tb6_1 values('2021-03-02 01:00:00.000', 9961,9961.0,'61'); +sql insert into tb6_1 values('2021-03-03 01:00:00.000', 9961,9961.0,'61'); +sql insert into tb6_1 values('2021-03-04 01:00:00.000', 9961,9961.0,'61'); +sql insert into tb6_1 values('2021-03-05 01:00:00.000', 9961,9961.0,'61'); +sql insert into tb6_2 values('2021-03-01 02:00:00.000', 9962,9962.0,'62'); +sql insert into tb6_2 values('2021-03-02 02:00:00.000', 9962,9962.0,'62'); +sql insert into tb6_2 values('2021-03-03 02:00:00.000', 9962,9962.0,'62'); +sql insert into tb6_2 values('2021-03-04 02:00:00.000', 9962,9962.0,'62'); +sql insert into tb6_2 values('2021-03-05 02:00:00.000', 9962,9962.0,'62'); +sql insert into tb6_3 values('2021-03-01 03:00:00.000', 9963,9963.0,'63'); +sql insert into tb6_3 values('2021-03-02 03:00:00.000', 9963,9963.0,'63'); +sql insert into tb6_3 values('2021-03-03 03:00:00.000', 9963,9963.0,'63'); +sql insert into tb6_3 values('2021-03-04 03:00:00.000', 9963,9963.0,'63'); +sql insert into tb6_3 values('2021-03-05 03:00:00.000', 9963,9963.0,'63'); +sql insert into tb6_4 values('2021-03-01 04:00:00.000', 9964,9964.0,'64'); +sql insert into tb6_4 values('2021-03-02 04:00:00.000', 9964,9964.0,'64'); +sql insert into tb6_4 values('2021-03-03 04:00:00.000', 9964,9964.0,'64'); +sql insert into tb6_4 values('2021-03-04 04:00:00.000', 9964,9964.0,'64'); +sql insert into tb6_4 values('2021-03-05 04:00:00.000', 9964,9964.0,'64'); +sql insert into tb6_5 values('2021-03-01 05:00:00.000', 9965,9965.0,'65'); +sql insert into tb6_5 values('2021-03-02 05:00:00.000', 9965,9965.0,'65'); +sql insert into tb6_5 values('2021-03-03 05:00:00.000', 9965,9965.0,'65'); +sql insert into tb6_5 values('2021-03-04 05:00:00.000', 9965,9965.0,'65'); +sql insert into tb6_5 values('2021-03-05 05:00:00.000', 9965,9965.0,'65'); + +sql insert into tb7_1 values('2021-03-01 01:00:00.000', 9971,9971.0,'71'); +sql insert into tb7_1 values('2021-03-02 01:00:00.000', 9971,9971.0,'71'); +sql insert into tb7_1 values('2021-03-03 01:00:00.000', 9971,9971.0,'71'); +sql insert into tb7_1 values('2021-03-04 01:00:00.000', 9971,9971.0,'71'); +sql insert into tb7_1 values('2021-03-05 01:00:00.000', 9971,9971.0,'71'); +sql insert into tb7_2 values('2021-03-01 02:00:00.000', 9972,9972.0,'72'); +sql insert into tb7_2 values('2021-03-02 02:00:00.000', 9972,9972.0,'72'); +sql insert into tb7_2 values('2021-03-03 02:00:00.000', 9972,9972.0,'72'); +sql insert into tb7_2 values('2021-03-04 02:00:00.000', 9972,9972.0,'72'); +sql insert into tb7_2 values('2021-03-05 02:00:00.000', 9972,9972.0,'72'); +sql insert into tb7_3 values('2021-03-01 03:00:00.000', 9973,9973.0,'73'); +sql insert into tb7_3 values('2021-03-02 03:00:00.000', 9973,9973.0,'73'); +sql insert into tb7_3 values('2021-03-03 03:00:00.000', 9973,9973.0,'73'); +sql insert into tb7_3 values('2021-03-04 03:00:00.000', 9973,9973.0,'73'); +sql insert into tb7_3 values('2021-03-05 03:00:00.000', 9973,9973.0,'73'); +sql insert into tb7_4 values('2021-03-01 04:00:00.000', 9974,9974.0,'74'); +sql insert into tb7_4 values('2021-03-02 04:00:00.000', 9974,9974.0,'74'); +sql insert into tb7_4 values('2021-03-03 04:00:00.000', 9974,9974.0,'74'); +sql insert into tb7_4 values('2021-03-04 04:00:00.000', 9974,9974.0,'74'); +sql insert into tb7_4 values('2021-03-05 04:00:00.000', 9974,9974.0,'74'); +sql insert into tb7_5 values('2021-03-01 05:00:00.000', 9975,9975.0,'75'); +sql insert into tb7_5 values('2021-03-02 05:00:00.000', 9975,9975.0,'75'); +sql insert into tb7_5 values('2021-03-03 05:00:00.000', 9975,9975.0,'75'); +sql insert into tb7_5 values('2021-03-04 05:00:00.000', 9975,9975.0,'75'); +sql insert into tb7_5 values('2021-03-05 05:00:00.000', 9975,9975.0,'75'); + +sql insert into tb8_1 values('2021-03-01 01:00:00.000', 9981,9981.0,'81'); +sql insert into tb8_1 values('2021-03-02 01:00:00.000', 9981,9981.0,'81'); +sql insert into tb8_1 values('2021-03-03 01:00:00.000', 9981,9981.0,'81'); +sql insert into tb8_1 values('2021-03-04 01:00:00.000', 9981,9981.0,'81'); +sql insert into tb8_1 values('2021-03-05 01:00:00.000', 9981,9981.0,'81'); +sql insert into tb8_2 values('2021-03-01 02:00:00.000', 9982,9982.0,'82'); +sql insert into tb8_2 values('2021-03-02 02:00:00.000', 9982,9982.0,'82'); +sql insert into tb8_2 values('2021-03-03 02:00:00.000', 9982,9982.0,'82'); +sql insert into tb8_2 values('2021-03-04 02:00:00.000', 9982,9982.0,'82'); +sql insert into tb8_2 values('2021-03-05 02:00:00.000', 9982,9982.0,'82'); +sql insert into tb8_3 values('2021-03-01 03:00:00.000', 9983,9983.0,'83'); +sql insert into tb8_3 values('2021-03-02 03:00:00.000', 9983,9983.0,'83'); +sql insert into tb8_3 values('2021-03-03 03:00:00.000', 9983,9983.0,'83'); +sql insert into tb8_3 values('2021-03-04 03:00:00.000', 9983,9983.0,'83'); +sql insert into tb8_3 values('2021-03-05 03:00:00.000', 9983,9983.0,'83'); +sql insert into tb8_4 values('2021-03-01 04:00:00.000', 9984,9984.0,'84'); +sql insert into tb8_4 values('2021-03-02 04:00:00.000', 9984,9984.0,'84'); +sql insert into tb8_4 values('2021-03-03 04:00:00.000', 9984,9984.0,'84'); +sql insert into tb8_4 values('2021-03-04 04:00:00.000', 9984,9984.0,'84'); +sql insert into tb8_4 values('2021-03-05 04:00:00.000', 9984,9984.0,'84'); +sql insert into tb8_5 values('2021-03-01 05:00:00.000', 9985,9985.0,'85'); +sql insert into tb8_5 values('2021-03-02 05:00:00.000', 9985,9985.0,'85'); +sql insert into tb8_5 values('2021-03-03 05:00:00.000', 9985,9985.0,'85'); +sql insert into tb8_5 values('2021-03-04 05:00:00.000', 9985,9985.0,'85'); +sql insert into tb8_5 values('2021-03-05 05:00:00.000', 9985,9985.0,'85'); + +sql insert into tb9_1 values('2021-03-01 01:00:00.000', 9991,9991.0,'91'); +sql insert into tb9_1 values('2021-03-02 01:00:00.000', 9991,9991.0,'91'); +sql insert into tb9_1 values('2021-03-03 01:00:00.000', 9991,9991.0,'91'); +sql insert into tb9_1 values('2021-03-04 01:00:00.000', 9991,9991.0,'91'); +sql insert into tb9_1 values('2021-03-05 01:00:00.000', 9991,9991.0,'91'); +sql insert into tb9_2 values('2021-03-01 02:00:00.000', 9992,9992.0,'92'); +sql insert into tb9_2 values('2021-03-02 02:00:00.000', 9992,9992.0,'92'); +sql insert into tb9_2 values('2021-03-03 02:00:00.000', 9992,9992.0,'92'); +sql insert into tb9_2 values('2021-03-04 02:00:00.000', 9992,9992.0,'92'); +sql insert into tb9_2 values('2021-03-05 02:00:00.000', 9992,9992.0,'92'); +sql insert into tb9_3 values('2021-03-01 03:00:00.000', 9993,9993.0,'93'); +sql insert into tb9_3 values('2021-03-02 03:00:00.000', 9993,9993.0,'93'); +sql insert into tb9_3 values('2021-03-03 03:00:00.000', 9993,9993.0,'93'); +sql insert into tb9_3 values('2021-03-04 03:00:00.000', 9993,9993.0,'93'); +sql insert into tb9_3 values('2021-03-05 03:00:00.000', 9993,9993.0,'93'); +sql insert into tb9_4 values('2021-03-01 04:00:00.000', 9994,9994.0,'94'); +sql insert into tb9_4 values('2021-03-02 04:00:00.000', 9994,9994.0,'94'); +sql insert into tb9_4 values('2021-03-03 04:00:00.000', 9994,9994.0,'94'); +sql insert into tb9_4 values('2021-03-04 04:00:00.000', 9994,9994.0,'94'); +sql insert into tb9_4 values('2021-03-05 04:00:00.000', 9994,9994.0,'94'); +sql insert into tb9_5 values('2021-03-01 05:00:00.000', 9995,9995.0,'95'); +sql insert into tb9_5 values('2021-03-02 05:00:00.000', 9995,9995.0,'95'); +sql insert into tb9_5 values('2021-03-03 05:00:00.000', 9995,9995.0,'95'); +sql insert into tb9_5 values('2021-03-04 05:00:00.000', 9995,9995.0,'95'); +sql insert into tb9_5 values('2021-03-05 05:00:00.000', 9995,9995.0,'95'); + +sql insert into tba_1 values('2021-03-01 01:00:00.000', 99101,99101.0,'a1'); +sql insert into tba_1 values('2021-03-02 01:00:00.000', 99101,99101.0,'a1'); +sql insert into tba_1 values('2021-03-03 01:00:00.000', 99101,99101.0,'a1'); +sql insert into tba_1 values('2021-03-04 01:00:00.000', 99101,99101.0,'a1'); +sql insert into tba_1 values('2021-03-05 01:00:00.000', 99101,99101.0,'a1'); +sql insert into tba_2 values('2021-03-01 02:00:00.000', 99102,99102.0,'a2'); +sql insert into tba_2 values('2021-03-02 02:00:00.000', 99102,99102.0,'a2'); +sql insert into tba_2 values('2021-03-03 02:00:00.000', 99102,99102.0,'a2'); +sql insert into tba_2 values('2021-03-04 02:00:00.000', 99102,99102.0,'a2'); +sql insert into tba_2 values('2021-03-05 02:00:00.000', 99102,99102.0,'a2'); +sql insert into tba_3 values('2021-03-01 03:00:00.000', 99103,99103.0,'a3'); +sql insert into tba_3 values('2021-03-02 03:00:00.000', 99103,99103.0,'a3'); +sql insert into tba_3 values('2021-03-03 03:00:00.000', 99103,99103.0,'a3'); +sql insert into tba_3 values('2021-03-04 03:00:00.000', 99103,99103.0,'a3'); +sql insert into tba_3 values('2021-03-05 03:00:00.000', 99103,99103.0,'a3'); +sql insert into tba_4 values('2021-03-01 04:00:00.000', 99104,99104.0,'a4'); +sql insert into tba_4 values('2021-03-02 04:00:00.000', 99104,99104.0,'a4'); +sql insert into tba_4 values('2021-03-03 04:00:00.000', 99104,99104.0,'a4'); +sql insert into tba_4 values('2021-03-04 04:00:00.000', 99104,99104.0,'a4'); +sql insert into tba_4 values('2021-03-05 04:00:00.000', 99104,99104.0,'a4'); +sql insert into tba_5 values('2021-03-01 05:00:00.000', 99105,99105.0,'a5'); +sql insert into tba_5 values('2021-03-02 05:00:00.000', 99105,99105.0,'a5'); +sql insert into tba_5 values('2021-03-03 05:00:00.000', 99105,99105.0,'a5'); +sql insert into tba_5 values('2021-03-04 05:00:00.000', 99105,99105.0,'a5'); +sql insert into tba_5 values('2021-03-05 05:00:00.000', 99105,99105.0,'a5'); + +sql insert into tbb_1 values('2021-03-01 01:00:00.000', 99111,99111.0,'b1'); +sql insert into tbb_1 values('2021-03-02 01:00:00.000', 99111,99111.0,'b1'); +sql insert into tbb_1 values('2021-03-03 01:00:00.000', 99111,99111.0,'b1'); +sql insert into tbb_1 values('2021-03-04 01:00:00.000', 99111,99111.0,'b1'); +sql insert into tbb_1 values('2021-03-05 01:00:00.000', 99111,99111.0,'b1'); +sql insert into tbb_2 values('2021-03-01 02:00:00.000', 99112,99112.0,'b2'); +sql insert into tbb_2 values('2021-03-02 02:00:00.000', 99112,99112.0,'b2'); +sql insert into tbb_2 values('2021-03-03 02:00:00.000', 99112,99112.0,'b2'); +sql insert into tbb_2 values('2021-03-04 02:00:00.000', 99112,99112.0,'b2'); +sql insert into tbb_2 values('2021-03-05 02:00:00.000', 99112,99112.0,'b2'); +sql insert into tbb_3 values('2021-03-01 03:00:00.000', 99113,99113.0,'b3'); +sql insert into tbb_3 values('2021-03-02 03:00:00.000', 99113,99113.0,'b3'); +sql insert into tbb_3 values('2021-03-03 03:00:00.000', 99113,99113.0,'b3'); +sql insert into tbb_3 values('2021-03-04 03:00:00.000', 99113,99113.0,'b3'); +sql insert into tbb_3 values('2021-03-05 03:00:00.000', 99113,99113.0,'b3'); +sql insert into tbb_4 values('2021-03-01 04:00:00.000', 99114,99114.0,'b4'); +sql insert into tbb_4 values('2021-03-02 04:00:00.000', 99114,99114.0,'b4'); +sql insert into tbb_4 values('2021-03-03 04:00:00.000', 99114,99114.0,'b4'); +sql insert into tbb_4 values('2021-03-04 04:00:00.000', 99114,99114.0,'b4'); +sql insert into tbb_4 values('2021-03-05 04:00:00.000', 99114,99114.0,'b4'); +sql insert into tbb_5 values('2021-03-01 05:00:00.000', 99115,99115.0,'b5'); +sql insert into tbb_5 values('2021-03-02 05:00:00.000', 99115,99115.0,'b5'); +sql insert into tbb_5 values('2021-03-03 05:00:00.000', 99115,99115.0,'b5'); +sql insert into tbb_5 values('2021-03-04 05:00:00.000', 99115,99115.0,'b5'); +sql insert into tbb_5 values('2021-03-05 05:00:00.000', 99115,99115.0,'b5'); + + +sql select * from st0, st1 where st0.ts=st1.ts and st0.id1=st1.id1; + +if $rows != 25 then + return -1 +endi + +if $data00 != @21-03-01 01:00:00.000@ then + return -1 +endi +if $data01 != 9901 then + return -1 +endi +if $data02 != 9901.000000000 then + return -1 +endi +if $data03 != 01 then + return -1 +endi +if $data04 != 0 then + return -1 +endi +if $data05 != 1 then + return -1 +endi +if $data06 != 2.000000000 then + return -1 +endi +if $data07 != 1 then + print $data07 + return -1 +endi +if $data08 != 3 then + return -1 +endi +if $data09 != @21-03-01 01:00:00.000@ then + return -1 +endi + +if $data10 != @21-03-02 01:00:00.000@ then + return -1 +endi +if $data11 != 9901 then + return -1 +endi +if $data12 != 9901.000000000 then + return -1 +endi +if $data13 != 01 then + return -1 +endi +if $data14 != 0 then + return -1 +endi +if $data15 != 1 then + return -1 +endi +if $data16 != 2.000000000 then + return -1 +endi +if $data17 != 1 then + return -1 +endi +if $data18 != 3 then + return -1 +endi +if $data19 != @21-03-02 01:00:00.000@ then + return -1 +endi + + + +if $data20 != @21-03-03 01:00:00.000@ then + return -1 +endi +if $data21 != 9901 then + return -1 +endi +if $data22 != 9901.000000000 then + return -1 +endi +if $data23 != 01 then + return -1 +endi +if $data24 != 0 then + return -1 +endi +if $data25 != 1 then + return -1 +endi +if $data26 != 2.000000000 then + return -1 +endi +if $data27 != 1 then + return -1 +endi +if $data28 != 3 then + return -1 +endi +if $data29 != @21-03-03 01:00:00.000@ then + return -1 +endi + + +if $data30 != @21-03-04 01:00:00.000@ then + return -1 +endi +if $data31 != 9901 then + return -1 +endi +if $data32 != 9901.000000000 then + return -1 +endi +if $data33 != 01 then + return -1 +endi +if $data34 != 0 then + return -1 +endi +if $data35 != 1 then + return -1 +endi +if $data36 != 2.000000000 then + return -1 +endi +if $data37 != 1 then + return -1 +endi +if $data38 != 3 then + return -1 +endi +if $data39 != @21-03-04 01:00:00.000@ then + return -1 +endi + + + + +sql select * from st0, st1 where st0.ts=st1.ts and st0.id2=st1.id2; + +if $rows != 25 then + return -1 +endi + +if $data00 != @21-03-01 01:00:00.000@ then + return -1 +endi +if $data01 != 9901 then + return -1 +endi +if $data02 != 9901.000000000 then + return -1 +endi +if $data03 != 01 then + return -1 +endi +if $data04 != 0 then + return -1 +endi +if $data05 != 1 then + return -1 +endi +if $data06 != 2.000000000 then + return -1 +endi +if $data07 != 1 then + print $data07 + return -1 +endi +if $data08 != 3 then + return -1 +endi +if $data09 != @21-03-01 01:00:00.000@ then + return -1 +endi + +if $data10 != @21-03-02 01:00:00.000@ then + return -1 +endi +if $data11 != 9901 then + return -1 +endi +if $data12 != 9901.000000000 then + return -1 +endi +if $data13 != 01 then + return -1 +endi +if $data14 != 0 then + return -1 +endi +if $data15 != 1 then + return -1 +endi +if $data16 != 2.000000000 then + return -1 +endi +if $data17 != 1 then + return -1 +endi +if $data18 != 3 then + return -1 +endi +if $data19 != @21-03-02 01:00:00.000@ then + return -1 +endi + + + +if $data20 != @21-03-03 01:00:00.000@ then + return -1 +endi +if $data21 != 9901 then + return -1 +endi +if $data22 != 9901.000000000 then + return -1 +endi +if $data23 != 01 then + return -1 +endi +if $data24 != 0 then + return -1 +endi +if $data25 != 1 then + return -1 +endi +if $data26 != 2.000000000 then + return -1 +endi +if $data27 != 1 then + return -1 +endi +if $data28 != 3 then + return -1 +endi +if $data29 != @21-03-03 01:00:00.000@ then + return -1 +endi + + +if $data30 != @21-03-04 01:00:00.000@ then + return -1 +endi +if $data31 != 9901 then + return -1 +endi +if $data32 != 9901.000000000 then + return -1 +endi +if $data33 != 01 then + return -1 +endi +if $data34 != 0 then + return -1 +endi +if $data35 != 1 then + return -1 +endi +if $data36 != 2.000000000 then + return -1 +endi +if $data37 != 1 then + return -1 +endi +if $data38 != 3 then + return -1 +endi +if $data39 != @21-03-04 01:00:00.000@ then + return -1 +endi + + + + +sql select * from st0, st1 where st0.id3=st1.id3 and st1.ts=st0.ts; + +if $rows != 25 then + return -1 +endi + +if $data00 != @21-03-01 01:00:00.000@ then + return -1 +endi +if $data01 != 9901 then + return -1 +endi +if $data02 != 9901.000000000 then + return -1 +endi +if $data03 != 01 then + return -1 +endi +if $data04 != 0 then + return -1 +endi +if $data05 != 1 then + return -1 +endi +if $data06 != 2.000000000 then + return -1 +endi +if $data07 != 1 then + print $data07 + return -1 +endi +if $data08 != 3 then + return -1 +endi +if $data09 != @21-03-01 01:00:00.000@ then + return -1 +endi + +if $data10 != @21-03-02 01:00:00.000@ then + return -1 +endi +if $data11 != 9901 then + return -1 +endi +if $data12 != 9901.000000000 then + return -1 +endi +if $data13 != 01 then + return -1 +endi +if $data14 != 0 then + return -1 +endi +if $data15 != 1 then + return -1 +endi +if $data16 != 2.000000000 then + return -1 +endi +if $data17 != 1 then + return -1 +endi +if $data18 != 3 then + return -1 +endi +if $data19 != @21-03-02 01:00:00.000@ then + return -1 +endi + + + +if $data20 != @21-03-03 01:00:00.000@ then + return -1 +endi +if $data21 != 9901 then + return -1 +endi +if $data22 != 9901.000000000 then + return -1 +endi +if $data23 != 01 then + return -1 +endi +if $data24 != 0 then + return -1 +endi +if $data25 != 1 then + return -1 +endi +if $data26 != 2.000000000 then + return -1 +endi +if $data27 != 1 then + return -1 +endi +if $data28 != 3 then + return -1 +endi +if $data29 != @21-03-03 01:00:00.000@ then + return -1 +endi + + +if $data30 != @21-03-04 01:00:00.000@ then + return -1 +endi +if $data31 != 9901 then + return -1 +endi +if $data32 != 9901.000000000 then + return -1 +endi +if $data33 != 01 then + return -1 +endi +if $data34 != 0 then + return -1 +endi +if $data35 != 1 then + return -1 +endi +if $data36 != 2.000000000 then + return -1 +endi +if $data37 != 1 then + return -1 +endi +if $data38 != 3 then + return -1 +endi +if $data39 != @21-03-04 01:00:00.000@ then + return -1 +endi + + + + + +sql select * from st0, st1 where st1.id5=st0.id5 and st0.ts=st1.ts; + +if $rows != 25 then + return -1 +endi + +if $data00 != @21-03-01 01:00:00.000@ then + return -1 +endi +if $data01 != 9901 then + return -1 +endi +if $data02 != 9901.000000000 then + return -1 +endi +if $data03 != 01 then + return -1 +endi +if $data04 != 0 then + return -1 +endi +if $data05 != 1 then + return -1 +endi +if $data06 != 2.000000000 then + return -1 +endi +if $data07 != 1 then + print $data07 + return -1 +endi +if $data08 != 3 then + return -1 +endi +if $data09 != @21-03-01 01:00:00.000@ then + return -1 +endi + +if $data10 != @21-03-02 01:00:00.000@ then + return -1 +endi +if $data11 != 9901 then + return -1 +endi +if $data12 != 9901.000000000 then + return -1 +endi +if $data13 != 01 then + return -1 +endi +if $data14 != 0 then + return -1 +endi +if $data15 != 1 then + return -1 +endi +if $data16 != 2.000000000 then + return -1 +endi +if $data17 != 1 then + return -1 +endi +if $data18 != 3 then + return -1 +endi +if $data19 != @21-03-02 01:00:00.000@ then + return -1 +endi + + + +if $data20 != @21-03-03 01:00:00.000@ then + return -1 +endi +if $data21 != 9901 then + return -1 +endi +if $data22 != 9901.000000000 then + return -1 +endi +if $data23 != 01 then + return -1 +endi +if $data24 != 0 then + return -1 +endi +if $data25 != 1 then + return -1 +endi +if $data26 != 2.000000000 then + return -1 +endi +if $data27 != 1 then + return -1 +endi +if $data28 != 3 then + return -1 +endi +if $data29 != @21-03-03 01:00:00.000@ then + return -1 +endi + + +if $data30 != @21-03-04 01:00:00.000@ then + return -1 +endi +if $data31 != 9901 then + return -1 +endi +if $data32 != 9901.000000000 then + return -1 +endi +if $data33 != 01 then + return -1 +endi +if $data34 != 0 then + return -1 +endi +if $data35 != 1 then + return -1 +endi +if $data36 != 2.000000000 then + return -1 +endi +if $data37 != 1 then + return -1 +endi +if $data38 != 3 then + return -1 +endi +if $data39 != @21-03-04 01:00:00.000@ then + return -1 +endi + + + + +sql select st0.* from st0, st1 where st0.ts=st1.ts and st0.id1=st1.id1; + +if $rows != 25 then + return -1 +endi + +if $data00 != @21-03-01 01:00:00.000@ then + return -1 +endi +if $data01 != 9901 then + return -1 +endi +if $data02 != 9901.000000000 then + return -1 +endi +if $data03 != 01 then + return -1 +endi +if $data04 != 0 then + return -1 +endi +if $data05 != 1 then + return -1 +endi +if $data06 != 2.000000000 then + return -1 +endi +if $data07 != 1 then + print $data07 + return -1 +endi +if $data08 != 3 then + return -1 +endi + +if $data10 != @21-03-02 01:00:00.000@ then + return -1 +endi +if $data11 != 9901 then + return -1 +endi +if $data12 != 9901.000000000 then + return -1 +endi +if $data13 != 01 then + return -1 +endi +if $data14 != 0 then + return -1 +endi +if $data15 != 1 then + return -1 +endi +if $data16 != 2.000000000 then + return -1 +endi +if $data17 != 1 then + return -1 +endi +if $data18 != 3 then + return -1 +endi + + + +if $data20 != @21-03-03 01:00:00.000@ then + return -1 +endi +if $data21 != 9901 then + return -1 +endi +if $data22 != 9901.000000000 then + return -1 +endi +if $data23 != 01 then + return -1 +endi +if $data24 != 0 then + return -1 +endi +if $data25 != 1 then + return -1 +endi +if $data26 != 2.000000000 then + return -1 +endi +if $data27 != 1 then + return -1 +endi +if $data28 != 3 then + return -1 +endi + + +if $data30 != @21-03-04 01:00:00.000@ then + return -1 +endi +if $data31 != 9901 then + return -1 +endi +if $data32 != 9901.000000000 then + return -1 +endi +if $data33 != 01 then + return -1 +endi +if $data34 != 0 then + return -1 +endi +if $data35 != 1 then + return -1 +endi +if $data36 != 2.000000000 then + return -1 +endi +if $data37 != 1 then + return -1 +endi +if $data38 != 3 then + return -1 +endi + + + + +sql select st0.* from st0, st1 where st0.ts=st1.ts and st1.id2=st0.id2; + +if $rows != 25 then + return -1 +endi + +if $data00 != @21-03-01 01:00:00.000@ then + return -1 +endi +if $data01 != 9901 then + return -1 +endi +if $data02 != 9901.000000000 then + return -1 +endi +if $data03 != 01 then + return -1 +endi +if $data04 != 0 then + return -1 +endi +if $data05 != 1 then + return -1 +endi +if $data06 != 2.000000000 then + return -1 +endi +if $data07 != 1 then + print $data07 + return -1 +endi +if $data08 != 3 then + return -1 +endi + +if $data10 != @21-03-02 01:00:00.000@ then + return -1 +endi +if $data11 != 9901 then + return -1 +endi +if $data12 != 9901.000000000 then + return -1 +endi +if $data13 != 01 then + return -1 +endi +if $data14 != 0 then + return -1 +endi +if $data15 != 1 then + return -1 +endi +if $data16 != 2.000000000 then + return -1 +endi +if $data17 != 1 then + return -1 +endi +if $data18 != 3 then + return -1 +endi + + + +if $data20 != @21-03-03 01:00:00.000@ then + return -1 +endi +if $data21 != 9901 then + return -1 +endi +if $data22 != 9901.000000000 then + return -1 +endi +if $data23 != 01 then + return -1 +endi +if $data24 != 0 then + return -1 +endi +if $data25 != 1 then + return -1 +endi +if $data26 != 2.000000000 then + return -1 +endi +if $data27 != 1 then + return -1 +endi +if $data28 != 3 then + return -1 +endi + + +if $data30 != @21-03-04 01:00:00.000@ then + return -1 +endi +if $data31 != 9901 then + return -1 +endi +if $data32 != 9901.000000000 then + return -1 +endi +if $data33 != 01 then + return -1 +endi +if $data34 != 0 then + return -1 +endi +if $data35 != 1 then + return -1 +endi +if $data36 != 2.000000000 then + return -1 +endi +if $data37 != 1 then + return -1 +endi +if $data38 != 3 then + return -1 +endi + + + + + +sql select st0.* from st0, st1 where st0.id3=st1.id3 and st1.ts=st0.ts; + +if $rows != 25 then + return -1 +endi + +if $data00 != @21-03-01 01:00:00.000@ then + return -1 +endi +if $data01 != 9901 then + return -1 +endi +if $data02 != 9901.000000000 then + return -1 +endi +if $data03 != 01 then + return -1 +endi +if $data04 != 0 then + return -1 +endi +if $data05 != 1 then + return -1 +endi +if $data06 != 2.000000000 then + return -1 +endi +if $data07 != 1 then + print $data07 + return -1 +endi +if $data08 != 3 then + return -1 +endi + +if $data10 != @21-03-02 01:00:00.000@ then + return -1 +endi +if $data11 != 9901 then + return -1 +endi +if $data12 != 9901.000000000 then + return -1 +endi +if $data13 != 01 then + return -1 +endi +if $data14 != 0 then + return -1 +endi +if $data15 != 1 then + return -1 +endi +if $data16 != 2.000000000 then + return -1 +endi +if $data17 != 1 then + return -1 +endi +if $data18 != 3 then + return -1 +endi + + + +if $data20 != @21-03-03 01:00:00.000@ then + return -1 +endi +if $data21 != 9901 then + return -1 +endi +if $data22 != 9901.000000000 then + return -1 +endi +if $data23 != 01 then + return -1 +endi +if $data24 != 0 then + return -1 +endi +if $data25 != 1 then + return -1 +endi +if $data26 != 2.000000000 then + return -1 +endi +if $data27 != 1 then + return -1 +endi +if $data28 != 3 then + return -1 +endi + + +if $data30 != @21-03-04 01:00:00.000@ then + return -1 +endi +if $data31 != 9901 then + return -1 +endi +if $data32 != 9901.000000000 then + return -1 +endi +if $data33 != 01 then + return -1 +endi +if $data34 != 0 then + return -1 +endi +if $data35 != 1 then + return -1 +endi +if $data36 != 2.000000000 then + return -1 +endi +if $data37 != 1 then + return -1 +endi +if $data38 != 3 then + return -1 +endi + + + + +sql select st1.* from st0, st1 where st1.id5=st0.id5 and st0.ts=st1.ts; + +if $rows != 25 then + return -1 +endi + +if $data00 != @21-03-01 01:00:00.000@ then + return -1 +endi +if $data01 != 9911 then + return -1 +endi +if $data02 != 9911.000000000 then + return -1 +endi +if $data03 != 11 then + return -1 +endi +if $data04 != 0 then + return -1 +endi +if $data05 != 1 then + return -1 +endi +if $data06 != 2.000000000 then + return -1 +endi +if $data07 != 1 then + print $data07 + return -1 +endi +if $data08 != 3 then + return -1 +endi + +if $data10 != @21-03-02 01:00:00.000@ then + return -1 +endi +if $data11 != 9911 then + return -1 +endi +if $data12 != 9911.000000000 then + return -1 +endi +if $data13 != 11 then + return -1 +endi +if $data14 != 0 then + return -1 +endi +if $data15 != 1 then + return -1 +endi +if $data16 != 2.000000000 then + return -1 +endi +if $data17 != 1 then + return -1 +endi +if $data18 != 3 then + return -1 +endi + + + +if $data20 != @21-03-03 01:00:00.000@ then + return -1 +endi +if $data21 != 9911 then + return -1 +endi +if $data22 != 9911.000000000 then + return -1 +endi +if $data23 != 11 then + return -1 +endi +if $data24 != 0 then + return -1 +endi +if $data25 != 1 then + return -1 +endi +if $data26 != 2.000000000 then + return -1 +endi +if $data27 != 1 then + return -1 +endi +if $data28 != 3 then + return -1 +endi + + +if $data30 != @21-03-04 01:00:00.000@ then + return -1 +endi +if $data31 != 9911 then + return -1 +endi +if $data32 != 9911.000000000 then + return -1 +endi +if $data33 != 11 then + return -1 +endi +if $data34 != 0 then + return -1 +endi +if $data35 != 1 then + return -1 +endi +if $data36 != 2.000000000 then + return -1 +endi +if $data37 != 1 then + return -1 +endi +if $data38 != 3 then + return -1 +endi + + +sql select st0.f1,st1.f1 from st0, st1 where st0.ts=st1.ts and st0.id1=st1.id1; + +if $rows != 25 then + return -1 +endi + +if $data00 != 9901 then + return -1 +endi +if $data01 != 9911 then + return -1 +endi +if $data10 != 9901 then + return -1 +endi +if $data11 != 9911 then + return -1 +endi +if $data20 != 9901 then + return -1 +endi +if $data21 != 9911 then + return -1 +endi +if $data30 != 9901 then + return -1 +endi +if $data31 != 9911 then + return -1 +endi + + + + +sql select st0.ts,st1.ts from st0, st1 where st0.ts=st1.ts and st1.id2=st0.id2; + + +if $rows != 25 then + return -1 +endi + +if $data00 != @21-03-01 01:00:00.000@ then + return -1 +endi +if $data01 != @21-03-01 01:00:00.000@ then + return -1 +endi +if $data10 != @21-03-02 01:00:00.000@ then + return -1 +endi +if $data11 != @21-03-02 01:00:00.000@ then + return -1 +endi +if $data20 != @21-03-03 01:00:00.000@ then + return -1 +endi +if $data21 != @21-03-03 01:00:00.000@ then + return -1 +endi +if $data30 != @21-03-04 01:00:00.000@ then + return -1 +endi +if $data31 != @21-03-04 01:00:00.000@ then + return -1 +endi + + + +sql select st1.ts,st0.ts,st0.id3,st1.id3,st0.f3,st1.f3 from st0, st1 where st0.id3=st1.id3 and st1.ts=st0.ts; + + +if $rows != 25 then + return -1 +endi + +if $data00 != @21-03-01 01:00:00.000@ then + return -1 +endi +if $data01 != @21-03-01 01:00:00.000@ then + return -1 +endi +if $data02 != 2.000000000 then + return -1 +endi +if $data03 != 2.000000000 then + return -1 +endi +if $data04 != 01 then + return -1 +endi +if $data05 != 11 then + return -1 +endi + +if $data10 != @21-03-02 01:00:00.000@ then + return -1 +endi +if $data11 != @21-03-02 01:00:00.000@ then + return -1 +endi +if $data02 != 2.000000000 then + return -1 +endi +if $data03 != 2.000000000 then + return -1 +endi +if $data04 != 01 then + return -1 +endi +if $data05 != 11 then + return -1 +endi + + + +sql select st0.ts,st0.f2,st1.f3,st1.f2,st0.f3 from st0, st1 where st1.id5=st0.id5 and st0.ts=st1.ts; +if $rows != 25 then + return -1 +endi +if $data00 != @21-03-01 01:00:00.000@ then + return -1 +endi +if $data01 != 9901.000000000 then + return -1 +endi +if $data02 != 11 then + return -1 +endi +if $data03 != 9911.000000000 then + return -1 +endi +if $data04 != 01 then + return -1 +endi +if $data10 != @21-03-02 01:00:00.000@ then + return -1 +endi +if $data11 != 9901.000000000 then + return -1 +endi +if $data12 != 11 then + return -1 +endi +if $data13 != 9911.000000000 then + return -1 +endi +if $data14 != 01 then + return -1 +endi + + + + +sql select last(*) from st0, st1 where st0.ts=st1.ts and st0.id1=st1.id1 interval(10a); +if $rows != 25 then + return -1 +endi +if $data00 != @21-03-01 01:00:00.000@ then + return -1 +endi +if $data01 != @21-03-01 01:00:00.000@ then + return -1 +endi +if $data02 != 9901 then + return -1 +endi +if $data03 != 9901.000000000 then + return -1 +endi +if $data04 != 01 then + return -1 +endi +if $data05 != @21-03-01 01:00:00.000@ then + return -1 +endi +if $data06 != 9911 then + return -1 +endi +if $data07 != 9911.000000000 then + return -1 +endi +if $data08 != 11 then + return -1 +endi +if $data10 != @21-03-01 02:00:00.000@ then + return -1 +endi +if $data11 != @21-03-01 02:00:00.000@ then + return -1 +endi +if $data12 != 9902 then + return -1 +endi +if $data13 != 9902.000000000 then + return -1 +endi +if $data14 != 02 then + return -1 +endi +if $data15 != @21-03-01 02:00:00.000@ then + return -1 +endi +if $data16 != 9912 then + return -1 +endi +if $data17 != 9912.000000000 then + return -1 +endi +if $data18 != 12 then + return -1 +endi + + + +sql select last(*) from st0, st1 where st0.ts=st1.ts and st0.id1=st1.id1 interval(1d) sliding(1d); +if $rows != 5 then + return -1 +endi +if $data00 != @21-03-01 00:00:00.000@ then + return -1 +endi +if $data01 != @21-03-01 05:00:00.000@ then + return -1 +endi +if $data02 != 9905 then + return -1 +endi +if $data03 != 9905.000000000 then + return -1 +endi +if $data04 != 05 then + return -1 +endi +if $data05 != @21-03-01 05:00:00.000@ then + return -1 +endi +if $data06 != 9915 then + return -1 +endi +if $data07 != 9915.000000000 then + return -1 +endi +if $data08 != 15 then + return -1 +endi +if $data10 != @21-03-02 00:00:00.000@ then + return -1 +endi +if $data11 != @21-03-02 05:00:00.000@ then + return -1 +endi +if $data12 != 9905 then + return -1 +endi +if $data13 != 9905.000000000 then + return -1 +endi +if $data14 != 05 then + return -1 +endi +if $data15 != @21-03-02 05:00:00.000@ then + return -1 +endi +if $data16 != 9915 then + return -1 +endi +if $data17 != 9915.000000000 then + return -1 +endi +if $data18 != 15 then + return -1 +endi + + + +sql select st0.*,st1.* from st0, st1 where st1.id1=st0.id1 and st0.ts=st1.ts and st1.ts=st0.ts and st0.id1=st1.id1; +if $rows != 25 then + return -1 +endi +if $data00 != @21-03-01 01:00:00.000@ then + return -1 +endi +if $data01 != 9901 then + return -1 +endi +if $data02 != 9901.000000000 then + return -1 +endi +if $data03 != 01 then + return -1 +endi +if $data04 != 0 then + return -1 +endi +if $data05 != 1 then + return -1 +endi +if $data06 != 2.000000000 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data08 != 3 then + return -1 +endi +if $data09 != @21-03-01 01:00:00.000@ then + return -1 +endi + + + + + +sql select st0.ts,* from st0, st1 where st0.ts=st1.ts and st0.id1=st1.id1 order by st0.ts; + +if $rows != 25 then + return -1 +endi +if $data00 != @21-03-01 01:00:00.000@ then + return -1 +endi +if $data01 != @21-03-01 01:00:00.000@ then + return -1 +endi +if $data02 != 9901 then + return -1 +endi +if $data03 != 9901.000000000 then + return -1 +endi +if $data04 != 01 then + return -1 +endi +if $data05 != 0 then + return -1 +endi +if $data06 != 1 then + return -1 +endi +if $data07 != 2.000000000 then + return -1 +endi +if $data08 != 1 then + return -1 +endi +if $data09 != 3 then + return -1 +endi + +sql select st0.*,st1.* from st0, st1 where st1.id1=st0.id1 and st0.ts=st1.ts and st1.ts=st0.ts and st0.id1=st1.id1 order by st0.ts limit 5 offset 5 +if $rows != 5 then + return -1 +endi +if $data00 != @21-03-01 01:00:00.000@ then + print $data00 + return -1 +endi +if $data01 != 9901 then + return -1 +endi +if $data02 != 9901.000000000 then + return -1 +endi +if $data03 != 01 then + return -1 +endi +if $data04 != 0 then + return -1 +endi +if $data05 != 1 then + return -1 +endi +if $data06 != 2.000000000 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data08 != 3 then + return -1 +endi +if $data09 != @21-03-01 01:00:00.000@ then + return -1 +endi + + + +sql select top(st1.f1, 5) from st0, st1 where st1.id1=st0.id1 and st0.ts=st1.ts and st1.ts=st0.ts and st0.id1=st1.id1; +if $rows != 5 then + return -1 +endi +if $data00 != @21-03-01 05:00:00.000@ then + return -1 +endi +if $data01 != 9915 then + return -1 +endi +if $data10 != @21-03-02 05:00:00.000@ then + return -1 +endi +if $data11 != 9915 then + return -1 +endi +if $data20 != @21-03-03 05:00:00.000@ then + return -1 +endi +if $data21 != 9915 then + return -1 +endi +if $data30 != @21-03-04 05:00:00.000@ then + return -1 +endi +if $data31 != 9915 then + return -1 +endi +if $data40 != @21-03-05 05:00:00.000@ then + return -1 +endi +if $data41 != 9915 then + return -1 +endi + + + + + +sql select top(st0.f1,5) from st0, st1 where st1.id1=st0.id1 and st0.ts=st1.ts and st1.ts=st0.ts and st0.id1=st1.id1; +if $rows != 5 then + return -1 +endi +if $data00 != @21-03-01 05:00:00.000@ then + return -1 +endi +if $data01 != 9905 then + return -1 +endi +if $data10 != @21-03-02 05:00:00.000@ then + return -1 +endi +if $data11 != 9905 then + return -1 +endi +if $data20 != @21-03-03 05:00:00.000@ then + return -1 +endi +if $data21 != 9905 then + return -1 +endi +if $data30 != @21-03-04 05:00:00.000@ then + return -1 +endi +if $data31 != 9905 then + return -1 +endi +if $data40 != @21-03-05 05:00:00.000@ then + return -1 +endi +if $data41 != 9905 then + return -1 +endi + + +#sql select st0.*,st1.*,st2.*,st3.* from st3,st2,st1,st0 where st0.id1=st3.id1 and st3.ts=st2.ts and st2.id1=st1.id1 and st1.ts=st0.ts; +#sql select st0.*,st1.*,st2.*,st3.* from st3,st2,st1,st0 where st0.id1=st3.id1 and st3.ts=st2.ts and st2.id1=st1.id1 and st1.ts=st0.ts and st0.id1=st2.id1 and st1.ts=st2.ts; +#if $rows != 25 then +# print $rows +# return -1 +#endi +#if $data00 != @21-03-01 01:00:00.000@ then +# return -1 +#endi +#if $data01 != 9901 then +# return -1 +#endi +#if $data02 != 9901.000000000 then +# return -1 +#endi +#if $data03 != 01 then +# return -1 +#endi +#if $data04 != 0 then +# return -1 +#endi +#if $data05 != 1 then +# return -1 +#endi +#if $data06 != 2.000000000 then +# return -1 +#endi +#if $data07 != 1 then +# return -1 +#endi +#if $data08 != 3 then +# return -1 +#endi +#if $data09 != @21-03-01 01:00:00.000@ then +# return -1 +#endi + + + +#sql select st0.*,st1.*,st2.*,st3.* from st3,st2,st1,st0 where st0.id1=st1.id1 and st1.ts=st0.ts and st2.id1=st3.id1 and st3.ts=st2.ts; +#sql select st0.*,st1.*,st2.*,st3.* from st3,st2,st1,st0 where st0.id1=st1.id1 and st1.ts=st0.ts and st2.id1=st3.id1 and st3.ts=st2.ts and st0.id1=st2.id1 and st0.ts=st2.ts; +#if $rows != 25 then +# return -1 +#endi +#if $data00 != @21-03-01 01:00:00.000@ then +# return -1 +#endi +#if $data01 != 9901 then +# return -1 +#endi +#if $data02 != 9901.000000000 then +# return -1 +#endi +#if $data03 != 01 then +# return -1 +#endi +#if $data04 != 0 then +# return -1 +#endi +#if $data05 != 1 then +# return -1 +#endi +#if $data06 != 2.000000000 then +# return -1 +#endi +#if $data07 != 1 then +# return -1 +#endi +#if $data08 != 3 then +# return -1 +#endi +#if $data09 != @21-03-01 01:00:00.000@ then +# return -1 +#endi + + + +sql select st0.*,st1.*,st2.*,st3.*,st4.*,st5.*,st6.*,st7.*,st8.*,st9.* from st0,st1,st2,st3,st4,st5,st6,st7,st8,st9 where st0.ts=st2.ts and st0.ts=st4.ts and st0.ts=st6.ts and st0.ts=st8.ts and st1.ts=st3.ts and st3.ts=st5.ts and st5.ts=st7.ts and st7.ts=st9.ts and st0.ts=st1.ts and st0.id1=st2.id1 and st0.id1=st4.id1 and st0.id1=st6.id1 and st0.id1=st8.id1 and st1.id1=st3.id1 and st3.id1=st5.id1 and st5.id1=st7.id1 and st7.id1=st9.id1 and st0.id1=st1.id1; +if $rows != 25 then + return -1 +endi +if $data00 != @21-03-01 01:00:00.000@ then + return -1 +endi +if $data01 != 9901 then + return -1 +endi +if $data02 != 9901.000000000 then + return -1 +endi +if $data03 != 01 then + return -1 +endi +if $data04 != 0 then + return -1 +endi +if $data05 != 1 then + return -1 +endi +if $data06 != 2.000000000 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data08 != 3 then + return -1 +endi +if $data09 != @21-03-01 01:00:00.000@ then + return -1 +endi + + + +sql select tb0_1.*, tb1_1.* from tb0_1, tb1_1 where tb0_1.ts=tb1_1.ts; +if $rows != 5 then + return -1 +endi +if $data00 != @21-03-01 01:00:00.000@ then + return -1 +endi +if $data01 != 9901 then + return -1 +endi +if $data02 != 9901.000000000 then + return -1 +endi +if $data03 != 01 then + return -1 +endi +if $data04 != @21-03-01 01:00:00.000@ then + return -1 +endi +if $data05 != 9911 then + return -1 +endi +if $data06 != 9911.000000000 then + return -1 +endi +if $data07 != 11 then + return -1 +endi +if $data10 != @21-03-02 01:00:00.000@ then + return -1 +endi +if $data11 != 9901 then + return -1 +endi +if $data12 != 9901.000000000 then + return -1 +endi +if $data13 != 01 then + return -1 +endi +if $data14 != @21-03-02 01:00:00.000@ then + return -1 +endi +if $data15 != 9911 then + return -1 +endi +if $data16 != 9911.000000000 then + return -1 +endi +if $data17 != 11 then + return -1 +endi + + + +sql select tb0_1.*, tb1_1.* from tb0_1, tb1_1 where tb0_1.ts=tb1_1.ts and tb0_1.id1=tb1_1.id1; +if $rows != 5 then + return -1 +endi +if $data00 != @21-03-01 01:00:00.000@ then + return -1 +endi +if $data01 != 9901 then + return -1 +endi +if $data02 != 9901.000000000 then + return -1 +endi +if $data03 != 01 then + return -1 +endi +if $data04 != @21-03-01 01:00:00.000@ then + return -1 +endi +if $data05 != 9911 then + return -1 +endi +if $data06 != 9911.000000000 then + return -1 +endi +if $data07 != 11 then + return -1 +endi +if $data10 != @21-03-02 01:00:00.000@ then + return -1 +endi +if $data11 != 9901 then + return -1 +endi +if $data12 != 9901.000000000 then + return -1 +endi +if $data13 != 01 then + return -1 +endi +if $data14 != @21-03-02 01:00:00.000@ then + return -1 +endi +if $data15 != 9911 then + return -1 +endi +if $data16 != 9911.000000000 then + return -1 +endi +if $data17 != 11 then + return -1 +endi + + +sql select tb0_1.*, tb1_2.*,tb2_3.*,tb3_4.*,tb4_5.* from tb0_1, tb1_2, tb2_3, tb3_4, tb4_5 where tb0_1.ts=tb1_2.ts and tb0_1.ts=tb2_3.ts and tb0_1.ts=tb3_4.ts and tb0_1.ts=tb4_5.ts; +if $rows != 0 then + return -1 +endi + + + +sql select tb0_1.*, tb1_1.*,tb2_1.*,tb3_1.*,tb4_1.* from tb0_1, tb1_1, tb2_1, tb3_1, tb4_1 where tb0_1.ts=tb1_1.ts and tb0_1.ts=tb2_1.ts and tb0_1.ts=tb3_1.ts and tb0_1.ts=tb4_1.ts; + +if $rows != 5 then + return -1 +endi + +if $data00 != @21-03-01 01:00:00.000@ then + return -1 +endi +if $data01 != 9901 then + return -1 +endi +if $data02 != 9901.000000000 then + return -1 +endi +if $data03 != 01 then + return -1 +endi +if $data04 != @21-03-01 01:00:00.000@ then + return -1 +endi +if $data05 != 9911 then + return -1 +endi +if $data06 != 9911.000000000 then + return -1 +endi +if $data07 != 11 then + return -1 +endi +if $data08 != @21-03-01 01:00:00.000@ then + return -1 +endi +if $data09 != 9921 then + return -1 +endi +if $data10 != @21-03-02 01:00:00.000@ then + return -1 +endi +if $data11 != 9901 then + return -1 +endi +if $data12 != 9901.000000000 then + return -1 +endi +if $data13 != 01 then + return -1 +endi +if $data14 != @21-03-02 01:00:00.000@ then + return -1 +endi +if $data15 != 9911 then + return -1 +endi +if $data16 != 9911.000000000 then + return -1 +endi +if $data17 != 11 then + return -1 +endi +if $data18 != @21-03-02 01:00:00.000@ then + return -1 +endi +if $data19 != 9921 then + return -1 +endi + + + +sql select tb0_5.*, tb1_5.*,tb2_5.*,tb3_5.*,tb4_5.*,tb5_5.*, tb6_5.*,tb7_5.*,tb8_5.*,tb9_5.* from tb0_5, tb1_5, tb2_5, tb3_5, tb4_5,tb5_5, tb6_5, tb7_5, tb8_5, tb9_5 where tb9_5.ts=tb8_5.ts and tb8_5.ts=tb7_5.ts and tb7_5.ts=tb6_5.ts and tb6_5.ts=tb5_5.ts and tb5_5.ts=tb4_5.ts and tb4_5.ts=tb3_5.ts and tb3_5.ts=tb2_5.ts and tb2_5.ts=tb1_5.ts and tb1_5.ts=tb0_5.ts; + +if $rows != 5 then + return -1 +endi + +if $data00 != @21-03-01 05:00:00.000@ then + return -1 +endi +if $data01 != 9905 then + return -1 +endi +if $data02 != 9905.000000000 then + return -1 +endi +if $data03 != 05 then + return -1 +endi +if $data04 != @21-03-01 05:00:00.000@ then + return -1 +endi +if $data05 != 9915 then + return -1 +endi +if $data06 != 9915.000000000 then + return -1 +endi +if $data07 != 15 then + return -1 +endi +if $data08 != @21-03-01 05:00:00.000@ then + return -1 +endi +if $data09 != 9925 then + return -1 +endi +if $data10 != @21-03-02 05:00:00.000@ then + return -1 +endi +if $data11 != 9905 then + return -1 +endi +if $data12 != 9905.000000000 then + return -1 +endi +if $data13 != 05 then + return -1 +endi +if $data14 != @21-03-02 05:00:00.000@ then + return -1 +endi +if $data15 != 9915 then + return -1 +endi +if $data16 != 9915.000000000 then + return -1 +endi +if $data17 != 15 then + return -1 +endi +if $data18 != @21-03-02 05:00:00.000@ then + return -1 +endi +if $data19 != 9925 then + return -1 +endi + +sql_error select tb0_1.*, tb1_1.* from tb0_1, tb1_1 where tb0_1.f1=tb1_1.f1; +sql_error select tb0_1.*, tb1_1.* from tb0_1, tb1_1 where tb0_1.ts=tb1_1.ts and tb0_1.id1=tb1_1.id2; +sql_error select tb0_5.*, tb1_5.*,tb2_5.*,tb3_5.*,tb4_5.*,tb5_5.*, tb6_5.*,tb7_5.*,tb8_5.*,tb9_5.*,tba_5.* from tb0_5, tb1_5, tb2_5, tb3_5, tb4_5,tb5_5, tb6_5, tb7_5, tb8_5, tb9_5, tba_5 where tb9_5.ts=tb8_5.ts and tb8_5.ts=tb7_5.ts and tb7_5.ts=tb6_5.ts and tb6_5.ts=tb5_5.ts and tb5_5.ts=tb4_5.ts and tb4_5.ts=tb3_5.ts and tb3_5.ts=tb2_5.ts and tb2_5.ts=tb1_5.ts and tb1_5.ts=tb0_5.ts and tb0_5.ts=tba_5.ts; + +sql_error select * from st0, st1 where st0.ts=st1.ts; +sql_error select * from st0, st1 where st0.id1=st1.id1; +sql_error select * from st0, st1 where st0.f1=st1.f1 and st0.id1=st1.id1; +sql_error select * from st0, st1, st2, st3 where st0.id1=st1.id1 and st2.id1=st3.id1 and st0.ts=st1.ts and st1.ts=st2.ts and st2.ts=st3.ts; +sql_error select * from st0, st1, st2 where st0.id1=st1.id1; +sql_error select * from st0, st1 where st0.id1=st1.id1 and st0.id2=st1.id3; +sql_error select * from st0, st1 where st0.id1=st1.id1 or st0.ts=st1.ts; +sql_error select * from st0, st1 where st0.ts=st1.ts and st0.id1=st1.id1 or st0.id2=st1.id2; +sql_error select * from st0, st1, st2 where st0.ts=st1.ts and st0.id1=st1.id1; +sql_error select * from st0, st1 where st0.id1=st1.ts and st0.ts=st1.id1; +sql_error select * from st0, st1 where st0.id1=st1.id2 and st0.ts=st1.ts; +sql_error select * from st0, st1 where st1.id4=st0.id4 and st1.ts=st0.ts; +sql_error select * from st0, st1 where st0.id1=st1.id2 and st1.ts=st0.ts; +sql_error select * from st0, st1 where st0.ts=st1.ts and st0.id1=st1.id1 interval 10a; +sql_error select last(*) from st0, st1 where st0.ts=st1.ts and st0.id1=st1.id1 group by f1; +sql_error select st0.*,st1.*,st2.*,st3.*,st4.*,st5.*,st6.*,st7.*,st8.*,st9.* from st0,st1,st2,st3,st4,st5,st6,st7,st8,st9 where st0.ts=st2.ts and st0.ts=st4.ts and st0.ts=st6.ts and st0.ts=st8.ts and st1.ts=st3.ts and st3.ts=st5.ts and st5.ts=st7.ts and st7.ts=st9.ts and st0.id1=st2.id1 and st0.id1=st4.id1 and st0.id1=st6.id1 and st0.id1=st8.id1 and st1.id1=st3.id1 and st3.id1=st5.id1 and st5.id1=st7.id1 and st7.id1=st9.id1; +sql_error select st0.*,st1.*,st2.*,st3.*,st4.*,st5.*,st6.*,st7.*,st8.*,st9.* from st0,st1,st2,st3,st4,st5,st6,st7,st8,st9,sta where st0.ts=st2.ts and st0.ts=st4.ts and st0.ts=st6.ts and st0.ts=st8.ts and st1.ts=st3.ts and st3.ts=st5.ts and st5.ts=st7.ts and st7.ts=st9.ts and st0.ts=st1.ts and st0.id1=st2.id1 and st0.id1=st4.id1 and st0.id1=st6.id1 and st0.id1=st8.id1 and st1.id1=st3.id1 and st3.id1=st5.id1 and st5.id1=st7.id1 and st7.id1=st9.id1 and st0.id1=st1.id1 and st0.id1=sta.id1 and st0.ts=sta.ts; + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/join_multivnode.sim b/tests/script/general/parser/join_multivnode.sim new file mode 100644 index 0000000000000000000000000000000000000000..61438241b0cb943cf9d1df09799076cf7dbadeab --- /dev/null +++ b/tests/script/general/parser/join_multivnode.sim @@ -0,0 +1,370 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 4 + +system sh/exec.sh -n dnode1 -s start +sql connect +sleep 100 + +$dbPrefix = join_m_db +$tbPrefix = join_tb +$mtPrefix = join_mt +$tbNum = 3 +$rowNum = 1000 +$totalNum = $tbNum * $rowNum + +print =============== join_multivnode.sim +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +$tstart = 100000 + +sql drop database if exists $db -x step1 +step1: +sql create database if not exists $db keep 36500 +sql use $db +sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12)) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + $tg2 = ' . abc + $tg2 = $tg2 . ' + sql create table $tb using $mt tags( $i , $tg2 ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + $c = $x / 100 + $c = $c * 100 + $c = $x - $c + + $binary = ' . binary + $binary = $binary . $c + $binary = $binary . ' + + $nchar = ' . nchar + $nchar = $nchar . $c + $nchar = $nchar . ' + + sql insert into $tb values ($tstart , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar ) + $tstart = $tstart + 1 + $x = $x + 1 + endw + + $i = $i + 1 + $tstart = 100000 +endw + +sleep 100 + +$tstart = 100000 +$mt = $mtPrefix . 1 . $i +sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12), t3 int) + +$i = 0 +$tbPrefix = join_1_tb + +while $i < $tbNum + $tb = $tbPrefix . $i + $c = $i + $t3 = $i + 1 + + $binary = ' . abc + $binary = $binary . $i + $binary = $binary . ' + + print $binary + sql create table $tb using $mt tags( $i , $binary , $t3 ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + $c = $x / 100 + $c = $c * 100 + $c = $x - $c + + $binary = ' . binary + $binary = $binary . $c + $binary = $binary . ' + + $nchar = ' . nchar + $nchar = $nchar . $c + $nchar = $nchar . ' + + sql insert into $tb values ($tstart , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar ) + $tstart = $tstart + 1 + $x = $x + 1 + endw + + $i = $i + 1 + $tstart = 100000 +endw + +print ===============multivnode projection join.sim + +sql select join_mt0.ts,join_mt0.ts,join_mt0.t1 from join_mt0, join_mt1 where join_mt0.ts=join_mt1.ts and join_mt0.t1=join_mt1.t1; + +print $row +if $row != 3000 then + print expect 3000, actual: $row + return -1 +endi + +print ======= second tags join + +sql create table m1(ts timestamp, k int) tags(a binary(12), b int); +sql create table m2(ts timestamp, k int) tags(a binary(12), b int); + +sql insert into tm1 using m1 tags('tm1', 1) values(10000000, 1) tm2 using m2 tags('tm2', 1) values(10000000, 99); + +sql select * from m1,m2 where m1.ts=m2.ts and m1.b=m2.b; +if $row != 1 then + return -1 +endi + +sql select join_mt0.ts, join_mt1.t1 from join_mt0, join_mt1 where join_mt0.ts=join_mt1.ts and join_mt0.t1=join_mt1.t1 + +sql select join_mt0.ts, join_mt1.t1, join_mt0.t1, join_mt1.tbname, join_mt0.tbname from join_mt0, join_mt1 where join_mt0.ts=join_mt1.ts and join_mt0.t1=join_mt1.t1 + +sql select join_mt0.ts, join_mt1.t1, join_mt0.t1, join_mt1.tbname, join_mt0.tbname from join_mt0, join_mt1 where join_mt0.ts=join_mt1.ts and join_mt0.t1=join_mt1.t1 limit 1 + +#1970-01-01 08:01:40.800 | 10 | 45.000000000 | 0 | true | false | 0 | +#1970-01-01 08:01:40.790 | 10 | 945.000000000 | 90 | true | true | 0 | +sql_error select count(join_mt0.c1), sum(join_mt1.c2), first(join_mt0.c5), last(join_mt1.c7), first(join_mt1.c7) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts interval(10a) group by join_mt0.t1 order by join_mt0.ts desc limit 20 offset 19; + +sql select count(join_mt0.c1), sum(join_mt0.c2)/count(*), avg(c2), first(join_mt0.c5), last(c7) from join_mt0 interval(10a) group by join_mt0.t1 order by join_mt0.ts desc; +if $rows != 300 then + return -1 +endi + +if $data00 != @70-01-01 08:01:40.990@ then + print expect 70-01-01 08:01:40.990, actual: $data00 + return -1 +endi + +if $data01 != 10 then + return -1 +endi + +if $data02 != 94.500000000 then + print expect 94.500000000, actual $data02 + return -1 +endi + +if $data03 != 94.500000000 then + return -1 +endi + +if $data04 != 90 then + return -1 +endi + +if $data05 != 1 then + return -1 +endi + +if $data06 != 0 then + return -1 +endi + +if $data10 != @70-01-01 08:01:40.980@ then + print expect 70-01-01 08:01:40.980, actual: $data10 + return -1 +endi + +if $data11 != 10 then + return -1 +endi + +if $data12 != 84.500000000 then + print expect 84.500000000, actual $data12 + return -1 +endi + +if $data13 != 84.500000000 then + return -1 +endi + +if $data14 != 80 then + return -1 +endi + +if $data15 != 1 then + return -1 +endi + +if $data16 != 0 then + return -1 +endi + +# this function will cause shell crash +sql_error select count(join_mt0.c1), first(join_mt0.c1) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts interval(10a) group by join_mt0.t1 order by join_mt0.ts desc; +sql_error select last(join_mt1.c7), first(join_mt1.c7) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts interval(10m) group by join_mt0.t1 order by join_mt0.ts asc; +sql_error select count(join_mt0.c1), first(join_mt0.c1)-last(join_mt1.c1), first(join_mt1.c9) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts;", NULL); + +print ================================> TD-2152 +sql_error select join_mt1.c1,join_mt0.c1 from join_mt1,join_mt0 where join_mt1.ts = join_mt0.ts and join_mt1.t1 = join_mt0.t1 order by t; + +print =================================> add result check +sql select count(join_mt0.c1), first(join_mt0.c1)/count(*), first(join_mt1.c9) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts;", NULL); +sql select count(join_mt0.c1), first(join_mt0.c1)-last(join_mt0.c1), first(join_mt1.c9) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts;", NULL); +sql select last(join_mt0.c1) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts;", NULL); + +sql create database disorder_db; +sql use disorder_db; +sql create table m1(ts timestamp, k int) tags(a int); +sql create table tm0 using m1 tags(0); +sql create table tm1 using m1 tags(1); +sql create table tm2 using m1 tags(2); +sql create table tm3 using m1 tags(3); +sql create table tm4 using m1 tags(4); +sql create table tm5 using m1 tags(5); +sql create table tm6 using m1 tags(6); +sql create table tm7 using m1 tags(7); + +sql show vgroups +if $rows != 2 then + print maxTablesPerVnode set to 4 is not active. + return -1 +endi + +sql insert into tm0 values('2020-1-1 1:1:1', 0); +sql insert into tm1 values('2020-1-1 1:1:1', 1); +sql insert into tm2 values('2020-1-1 1:1:1', 2); +sql insert into tm3 values('2020-1-1 1:1:1', 3); +sql insert into tm4 values('2020-1-1 1:1:1', 4); +sql insert into tm5 values('2020-1-1 1:1:1', 5); +sql insert into tm6 values('2020-1-1 1:1:1', 6); +sql insert into tm7 values('2020-1-1 1:1:1', 7); + +sql create table m2(ts timestamp, k int) tags(b int); +sql create table t0 using m2 tags(0); +sql create table t1 using m2 tags(4); +sql create table t2 using m2 tags(92); +sql create table t3 using m2 tags(93); +sql create table t4 using m2 tags(1); +sql create table t5 using m2 tags(5); +sql create table t6 using m2 tags(96); +sql create table t7 using m2 tags(97); + +sql show vgroups +if $rows != 4 then + return -1 +endi + +sql insert into t0 values('2020-1-1 1:1:1', 10); +sql insert into t1 values('2020-1-1 1:1:1', 11); +sql insert into t2 values('2020-1-1 1:1:1', 12); +sql insert into t3 values('2020-1-1 1:1:1', 13); +sql insert into t4 values('2020-1-1 1:1:1', 14); +sql insert into t5 values('2020-1-1 1:1:1', 15); +sql insert into t6 values('2020-1-1 1:1:1', 16); +sql insert into t7 values('2020-1-1 1:1:1', 17); + +sql select m1.ts,m1.tbname,m1.a, m2.ts,m2.tbname,m2.b from m1,m2 where m1.a=m2.b and m1.ts=m2.ts; +if $rows != 4 then + return -1 +endi + +if $data00 != @20-01-01 01:01:01.000@ then + print expect 20-01-01 01:01:01.000, actual:$data00 + return -1 +endi + +if $data01 != @tm0@ then + return -1 +endi + +if $data02 != 0 then + return -1 +endi + +if $data03 != @20-01-01 01:01:01.000@ then + return -1 +endi + +if $data04 != @t0@ then + return -1 +endi + +if $data05 != 0 then + return -1 +endi + +if $data10 != @20-01-01 01:01:01.000@ then + return -1 +endi + +if $data11 != @tm1@ then + return -1 +endi + +if $data12 != 1 then + return -1 +endi + +if $data13 != @20-01-01 01:01:01.000@ then + return -1 +endi + +if $data14 != @t4@ then + return -1 +endi + +if $data15 != 1 then + return -1 +endi + +if $data20 != @20-01-01 01:01:01.000@ then + return -1 +endi + +if $data21 != @tm4@ then + return -1 +endi + +if $data22 != 4 then + return -1 +endi + +if $data23 != @20-01-01 01:01:01.000@ then + return -1 +endi + +if $data24 != @t1@ then + return -1 +endi + +if $data25 != 4 then + return -1 +endi + +if $data30 != @20-01-01 01:01:01.000@ then + return -1 +endi + +if $data31 != @tm5@ then + return -1 +endi + +if $data32 != 5 then + return -1 +endi + +if $data33 != @20-01-01 01:01:01.000@ then + return -1 +endi + +if $data34 != @t5@ then + return -1 +endi + +if $data35 != 5 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/last_cache.sim b/tests/script/general/parser/last_cache.sim new file mode 100644 index 0000000000000000000000000000000000000000..9c414263ecc65cc11327bbcfc7a79131984393b9 --- /dev/null +++ b/tests/script/general/parser/last_cache.sim @@ -0,0 +1,71 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sleep 100 +sql connect +print ======================== dnode1 start + +$db = testdb +sql drop database if exists $db +sql create database $db cachelast 2 +sql use $db + +sql create stable st2 (ts timestamp, f1 int, f2 double, f3 binary(10), f4 timestamp) tags (id int) + +sql create table tb1 using st2 tags (1); +sql create table tb2 using st2 tags (2); +sql create table tb3 using st2 tags (3); +sql create table tb4 using st2 tags (4); +sql create table tb5 using st2 tags (1); +sql create table tb6 using st2 tags (2); +sql create table tb7 using st2 tags (3); +sql create table tb8 using st2 tags (4); +sql create table tb9 using st2 tags (5); +sql create table tba using st2 tags (5); +sql create table tbb using st2 tags (5); +sql create table tbc using st2 tags (5); +sql create table tbd using st2 tags (5); +sql create table tbe using st2 tags (5); + +sql insert into tb1 values ("2021-05-09 10:10:10", 1, 2.0, '3', -1000) +sql insert into tb1 values ("2021-05-10 10:10:11", 4, 5.0, NULL, -2000) +sql insert into tb1 values ("2021-05-12 10:10:12", 6,NULL, NULL, -3000) + +sql insert into tb2 values ("2021-05-09 10:11:13",-1,-2.0,'-3', -1001) +sql insert into tb2 values ("2021-05-10 10:11:14",-4,-5.0, NULL, -2001) +sql insert into tb2 values ("2021-05-11 10:11:15",-6, -7, '-8', -3001) + +sql insert into tb3 values ("2021-05-09 10:12:17", 7, 8.0, '9' , -1002) +sql insert into tb3 values ("2021-05-09 10:12:17",10,11.0, NULL, -2002) +sql insert into tb3 values ("2021-05-09 10:12:18",12,NULL, NULL, -3002) + +sql insert into tb4 values ("2021-05-09 10:12:19",13,14.0,'15' , -1003) +sql insert into tb4 values ("2021-05-10 10:12:20",16,17.0, NULL, -2003) +sql insert into tb4 values ("2021-05-11 10:12:21",18,NULL, NULL, -3003) + +sql insert into tb5 values ("2021-05-09 10:12:22",19, 20, '21', -1004) +sql insert into tb6 values ("2021-05-11 10:12:23",22, 23, NULL, -2004) +sql insert into tb7 values ("2021-05-10 10:12:24",24,NULL, '25', -3004) +sql insert into tb8 values ("2021-05-11 10:12:25",26,NULL, '27', -4004) + +sql insert into tb9 values ("2021-05-09 10:12:26",28, 29, '30', -1005) +sql insert into tba values ("2021-05-10 10:12:27",31, 32, NULL, -2005) +sql insert into tbb values ("2021-05-10 10:12:28",33,NULL, '35', -3005) +sql insert into tbc values ("2021-05-11 10:12:29",36, 37, NULL, -4005) +sql insert into tbd values ("2021-05-11 10:12:29",NULL,NULL,NULL,NULL ) + +run general/parser/last_cache_query.sim + +system sh/exec.sh -n dnode1 -s stop -x SIGINT + +system sh/exec.sh -n dnode1 -s start + +run general/parser/last_cache_query.sim + +system sh/exec.sh -n dnode1 -s stop -x SIGINT + + + diff --git a/tests/script/general/parser/last_cache_query.sim b/tests/script/general/parser/last_cache_query.sim new file mode 100644 index 0000000000000000000000000000000000000000..2acd00058592c3d4f70600aad1b2ee41a688f1e1 --- /dev/null +++ b/tests/script/general/parser/last_cache_query.sim @@ -0,0 +1,416 @@ + +sleep 100 +sql connect + +$db = testdb + +sql use $db + +print "test tb1" + +sql select last(ts) from tb1 +if $rows != 1 then + return -1 +endi +if $data00 != @21-05-12 10:10:12.000@ then + print $data00 + return -1 +endi + + +sql select last(f1) from tb1 +if $rows != 1 then + return -1 +endi +if $data00 != 6 then + print $data00 + return -1 +endi + +sql select last(*) from tb1 +if $rows != 1 then + return -1 +endi +if $data00 != @21-05-12 10:10:12.000@ then + print $data00 + return -1 +endi +if $data01 != 6 then + return -1 +endi +if $data02 != 5.000000000 then + print $data02 + return -1 +endi +if $data03 != 3 then + return -1 +endi +if $data04 != @70-01-01 07:59:57.000@ then + return -1 +endi + + +sql select last(tb1.*,ts,f4) from tb1 +if $rows != 1 then + return -1 +endi +if $data00 != @21-05-12 10:10:12.000@ then + print $data00 + return -1 +endi +if $data01 != 6 then + return -1 +endi +if $data02 != 5.000000000 then + print $data02 + return -1 +endi +if $data03 != 3 then + return -1 +endi +if $data04 != @70-01-01 07:59:57.000@ then + return -1 +endi +if $data05 != @21-05-12 10:10:12.000@ then + print $data00 + return -1 +endi +if $data06 != @70-01-01 07:59:57.000@ then + return -1 +endi + + + + +print "test tb2" + +sql select last(ts) from tb2 +if $rows != 1 then + return -1 +endi +if $data00 != @21-05-11 10:11:15.000@ then + print $data00 + return -1 +endi + + +sql select last(f1) from tb2 +if $rows != 1 then + return -1 +endi +if $data00 != -6 then + print $data00 + return -1 +endi + +sql select last(*) from tb2 +if $rows != 1 then + return -1 +endi +if $data00 != @21-05-11 10:11:15.000@ then + print $data00 + return -1 +endi +if $data01 != -6 then + return -1 +endi +if $data02 != -7.000000000 then + print $data02 + return -1 +endi +if $data03 != -8 then + return -1 +endi +if $data04 != @70-01-01 07:59:56.999@ then + if $data04 != @70-01-01 07:59:57.-01@ then + return -1 + endi +endi + + +sql select last(tb2.*,ts,f4) from tb2 +if $rows != 1 then + return -1 +endi +if $data00 != @21-05-11 10:11:15.000@ then + print $data00 + return -1 +endi +if $data01 != -6 then + return -1 +endi +if $data02 != -7.000000000 then + print $data02 + return -1 +endi +if $data03 != -8 then + return -1 +endi +if $data04 != @70-01-01 07:59:56.999@ then + if $data04 != @70-01-01 07:59:57.-01@ then + return -1 + endi +endi +if $data05 != @21-05-11 10:11:15.000@ then + print $data00 + return -1 +endi +if $data06 != @70-01-01 07:59:56.999@ then + if $data04 != @70-01-01 07:59:57.-01@ then + return -1 + endi +endi + + + + + + + +print "test tbd" +sql select last(*) from tbd +if $rows != 1 then + return -1 +endi +if $data00 != @21-05-11 10:12:29.000@ then + print $data00 + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data02 != NULL then + print $data02 + return -1 +endi +if $data03 != NULL then + return -1 +endi +if $data04 != NULL then + return -1 +endi + + + +print "test tbe" +sql select last(*) from tbe +if $rows != 0 then + return -1 +endi + + + + + +print "test stable" +sql select last(ts) from st2 +if $rows != 1 then + return -1 +endi +if $data00 != @21-05-12 10:10:12.000@ then + print $data00 + return -1 +endi + + +sql select last(f1) from st2 +if $rows != 1 then + return -1 +endi +if $data00 != 6 then + print $data00 + return -1 +endi + +sql select last(*) from st2 +if $rows != 1 then + return -1 +endi +if $data00 != @21-05-12 10:10:12.000@ then + print $data00 + return -1 +endi +if $data01 != 6 then + return -1 +endi +if $data02 != 37.000000000 then + print $data02 + return -1 +endi +if $data03 != 27 then + return -1 +endi +if $data04 != @70-01-01 07:59:57.000@ then + return -1 +endi + + +sql select last(st2.*,ts,f4) from st2 +if $rows != 1 then + return -1 +endi +if $data00 != @21-05-12 10:10:12.000@ then + print $data00 + return -1 +endi +if $data01 != 6 then + return -1 +endi +if $data02 != 37.000000000 then + print $data02 + return -1 +endi +if $data03 != 27 then + return -1 +endi +if $data04 != @70-01-01 07:59:57.000@ then + return -1 +endi +if $data05 != @21-05-12 10:10:12.000@ then + print $data00 + return -1 +endi +if $data06 != @70-01-01 07:59:57.000@ then + return -1 +endi + + +sql select last(*) from st2 group by id +if $rows != 5 then + return -1 +endi +if $data00 != @21-05-12 10:10:12.000@ then + return -1 +endi +if $data01 != 6 then + return -1 +endi +if $data02 != 5.000000000 then + print $data02 + return -1 +endi +if $data03 != 21 then + return -1 +endi +if $data04 != @70-01-01 07:59:57.000@ then + return -1 +endi +if $data05 != 1 then + return -1 +endi +if $data10 != @21-05-11 10:12:23.000@ then + return -1 +endi +if $data11 != 22 then + return -1 +endi +if $data12 != 23.000000000 then + print $data02 + return -1 +endi +if $data13 != -8 then + return -1 +endi +if $data14 != @70-01-01 07:59:57.996@ then +if $data14 != @70-01-01 07:59:58.-04@ then + print $data14 + return -1 +endi +endi +if $data15 != 2 then + return -1 +endi +if $data20 != @21-05-10 10:12:24.000@ then + return -1 +endi +if $data21 != 24 then + return -1 +endi +if $data22 != 8.000000000 then + print $data02 + return -1 +endi +if $data23 != 25 then + return -1 +endi +if $data24 != @70-01-01 07:59:56.996@ then +if $data24 != @70-01-01 07:59:57.-04@ then + return -1 +endi +endi +if $data25 != 3 then + return -1 +endi +if $data30 != @21-05-11 10:12:25.000@ then + return -1 +endi +if $data31 != 26 then + return -1 +endi +if $data32 != 17.000000000 then + print $data02 + return -1 +endi +if $data33 != 27 then + return -1 +endi +if $data34 != @70-01-01 07:59:55.996@ then +if $data34 != @70-01-01 07:59:56.-04@ then + return -1 +endi +endi +if $data35 != 4 then + return -1 +endi +if $data40 != @21-05-11 10:12:29.000@ then + return -1 +endi +if $data41 != 36 then + return -1 +endi +if $data42 != 37.000000000 then + print $data02 + return -1 +endi +if $data43 != 35 then + return -1 +endi +if $data44 != @70-01-01 07:59:55.995@ then +if $data44 != @70-01-01 07:59:56.-05@ then + return -1 +endi +endi +if $data45 != 5 then + return -1 +endi + + +print "test tbn" +sql create table tbn (ts timestamp, f1 int, f2 double, f3 binary(10), f4 timestamp) +sql insert into tbn values ("2021-05-09 10:10:10", 1, 2.0, '3', -1000) +sql insert into tbn values ("2021-05-10 10:10:11", 4, 5.0, NULL, -2000) +sql insert into tbn values ("2021-05-12 10:10:12", 6,NULL, NULL, -3000) +sql insert into tbn values ("2021-05-13 10:10:12", NULL,NULL, NULL,NULL) + +sql select last(*) from tbn; +if $rows != 1 then + return -1 +endi +if $data00 != @21-05-13 10:10:12.000@ then + print $data00 + return -1 +endi +if $data01 != 6 then + return -1 +endi +if $data02 != 5.000000000 then + print $data02 + return -1 +endi +if $data03 != 3 then + return -1 +endi +if $data04 != @70-01-01 07:59:57.000@ then + return -1 +endi + diff --git a/tests/script/general/parser/last_groupby.sim b/tests/script/general/parser/last_groupby.sim new file mode 100644 index 0000000000000000000000000000000000000000..f993324cd1ccb6e1d74f71b3a0d9b47cf3452b48 --- /dev/null +++ b/tests/script/general/parser/last_groupby.sim @@ -0,0 +1,99 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 0 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2 +system sh/exec.sh -n dnode1 -s start + +sleep 100 +sql connect +print ======================== dnode1 start + +$db = testdb + +sql create database $db +sql use $db + +sql create stable st2 (ts timestamp, f1 int, f2 float, f3 double, f4 bigint, f5 smallint, f6 tinyint, f7 bool, f8 binary(10), f9 nchar(10)) tags (id1 int, id2 float, id3 nchar(10), id4 double, id5 smallint, id6 bigint, id7 binary(10)) + +sql create table tb1 using st2 tags (1,1.0,"1",1.0,1,1,"1"); + +sql insert into tb1 values (now-200s,1,1.0,1.0,1,1,1,true,"1","1") +sql insert into tb1 values (now-100s,2,2.0,2.0,2,2,2,true,"2","2") +sql insert into tb1 values (now,3,3.0,3.0,3,3,3,true,"3","3") +sql insert into tb1 values (now+100s,4,4.0,4.0,4,4,4,true,"4","4") +sql insert into tb1 values (now+200s,4,4.0,4.0,4,4,4,true,"4","4") +sql insert into tb1 values (now+300s,4,4.0,4.0,4,4,4,true,"4","4") +sql insert into tb1 values (now+400s,4,4.0,4.0,4,4,4,true,"4","4") +sql insert into tb1 values (now+500s,4,4.0,4.0,4,4,4,true,"4","4") + +sql select f1,last(*) from st2 group by f1; + +if $rows != 4 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + +if $data02 != 1 then + print $data02 + return -1 +endi +if $data03 != 1.00000 then + return -1 +endi +if $data04 != 1.000000000 then + return -1 +endi +if $data05 != 1 then + return -1 +endi +if $data06 != 1 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data08 != 1 then + return -1 +endi +if $data09 != 1 then + return -1 +endi + +sql select f1,last(f1,st2.*) from st2 group by f1; +if $rows != 4 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + +if $data01 != 1 then + return -1 +endi +if $data03 != 1 then + return -1 +endi +if $data04 != 1.00000 then + return -1 +endi +if $data05 != 1.000000000 then + return -1 +endi +if $data06 != 1 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data08 != 1 then + return -1 +endi +if $data09 != 1 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/lastrow.sim b/tests/script/general/parser/lastrow.sim new file mode 100644 index 0000000000000000000000000000000000000000..7cdd04e2ccdb93c7e1f84298101d74e7c3af061f --- /dev/null +++ b/tests/script/general/parser/lastrow.sim @@ -0,0 +1,90 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 4 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = lr_db +$tbPrefix = lr_tb +$stbPrefix = lr_stb +$tbNum = 8 +$rowNum = 60 * 24 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 60000 +print ========== lastrow.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int) + +$i = $tbNum +while $i > 0 + $tb = $tbPrefix . $i + sql create table $tb using $stb tags( $i ) + $i = $i - 1 +endw + +$ts = $ts0 +$i = 1 +while $i <= $tbNum + $x = 0 + $tb = $tbPrefix . $i + while $x < $rowNum + $ts = $ts + $delta + $c6 = $x / 128 + $c6 = $c6 * 128 + $c6 = $x - $c6 + $c3 = NULL + $xr = $x / 10 + $xr = $xr * 10 + $xr = $x - $xr + if $xr = 0 then + $c3 = $x + endi + sql insert into $tb values ( $ts , $x , NULL , $x , $x , $x , $c6 , true, 'BINARY', 'NCHAR' ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print ====== test data created + +run general/parser/lastrow_query.sim + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 500 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed +sql connect +sleep 100 + +run general/parser/lastrow_query.sim + +print =================== last_row + nested query +sql use $db +sql create table lr_nested(ts timestamp, f int) +sql insert into lr_nested values(now, 1) +sql insert into lr_nested values(now+1s, null) +sql select last_row(*) from (select * from lr_nested) +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql select last_row(*) from (select f from lr_nested) +if $rows != 1 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/lastrow_query.sim b/tests/script/general/parser/lastrow_query.sim new file mode 100644 index 0000000000000000000000000000000000000000..3fd88cfc1bb4e651ae16801c249aa88f0a3797ba --- /dev/null +++ b/tests/script/general/parser/lastrow_query.sim @@ -0,0 +1,230 @@ +sleep 100 +sql connect + +$dbPrefix = lr_db +$tbPrefix = lr_tb +$stbPrefix = lr_stb +$tbNum = 8 +$rowNum = 60 * 24 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 60000 +print ========== lastrow_query.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql use $db + +print ========>TD-3231 last_row with group by column error +sql_error select last_row(c1) from $stb group by c1; + +##### select lastrow from STable with two vnodes, timestamp decreases from tables in vnode0 to tables in vnode1 +sql select last_row(*) from $stb +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-25 09:00:00.000@ then + return -1 +endi +if $data01 != 1439 then + return -1 +endi +if $data02 != NULL then + return -1 +endi +if $data03 != 1439.00000 then + return -1 +endi +if $data04 != 1439.000000000 then + return -1 +endi +if $data06 != 31 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data08 != BINARY then + print expect BINARY actual: $data08 + return -1 +endi +if $data09 != NCHAR then + print expect NCHAR actual: $data09 + return -1 +endi + +# regression test case 1 +sql select count(*) from lr_tb1 where ts>'2018-09-18 08:45:00.1' and ts<'2018-09-18 08:45:00.2' +if $row != 0 then + return -1 +endi + +# regression test case 2 +sql select count(*) from lr_db0.lr_stb0 where ts>'2018-9-18 8:00:00' and ts<'2018-9-18 14:00:00' interval(1s) fill(NULL); +if $row != 21600 then + return -1 +endi + +#regression test case 3 +sql select t1,t1,count(*),t1,t1 from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' interval(1h) fill(NULL) group by t1 limit 1 +if $row != 2 then + return -1 +endi + +if $data01 != 7 then + return -1 +endi + +if $data02 != 7 then + return -1 +endi + +if $data03 != 59 then + print expect 59, actual: $data03 + return -1 +endi + +if $data04 != 7 then + return -1 +endi + +if $data11 != 8 then + return -1 +endi + +if $data12 != 8 then + return -1 +endi + +if $data13 != NULL then + return -1 +endi + +sql select t1,t1,count(*),t1,t1 from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' interval(1h) fill(NULL) group by t1 limit 9 +if $rows != 18 then + return -1 +endi + +sql select t1,t1,count(*),t1,t1 from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' interval(1h) fill(NULL) group by t1 limit 12 +if $rows != 24 then + return -1 +endi + +sql select t1,t1,count(*),t1,t1 from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' interval(1h) fill(NULL) group by t1 limit 25 +if $rows != 48 then + return -1 +endi + +sql select t1,t1,count(*),t1,t1 from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' interval(1h) fill(NULL) group by t1 limit 25 offset 1 +if $rows != 46 then + return -1 +endi + +sql select t1,t1,count(*),tbname,t1,t1,tbname from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' interval(1s) fill(NULL) group by tbname, t1 slimit 2 soffset 0 limit 250000 offset 1 +if $rows != 172798 then + return -1 +endi + +sql select t1,t1,count(*),tbname,t1,t1,tbname from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' interval(1s) fill(NULL) group by tbname, t1 slimit 1 soffset 1 limit 250000 offset 1 +if $rows != 86399 then + return -1 +endi + +sql select t1,t1,count(*),t1,t1 from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' interval(1h) fill(NULL) group by t1 order by ts DESC limit 30 +if $rows != 48 then + return -1 +endi + +sql select t1,t1,count(*),t1,t1 from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' interval(1h) fill(NULL) group by t1 order by ts DESC limit 2 +if $rows != 4 then + return -1 +endi + +sql select t1,t1,count(*),tbname,t1,t1,tbname from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' interval(1s) fill(NULL) group by tbname, t1 order by ts desc slimit 1 soffset 1 limit 250000 offset 1 +if $rows != 86399 then + return -1 +endi + +sql select t1,t1,count(*),t1,t1 from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' interval(1h) fill(NULL) group by t1 order by ts desc limit 1 +if $rows != 2 then + return -1 +endi + +sql select t1,t1,count(*),t1,t1 from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' interval(1h) fill(NULL) group by t1 order by ts desc limit 25 offset 1 +if $rows != 46 then + return -1 +endi + +print ========>td-1317, empty table last_row query crashed +sql drop table if exists m1; +sql create table m1(ts timestamp, k int) tags (a int); +sql create table t1 using m1 tags(1); +sql create table t2 using m1 tags(2); + +sql select last_row(*) from t1 +if $rows != 0 then + return -1 +endi + +sql select last_row(*) from m1 +if $rows != 0 then + return -1 +endi + +sql select last_row(*) from m1 where tbname in ('t1') +if $rows != 0 then + return -1 +endi + +sql insert into t1 values('2019-1-1 1:1:1', 1); +print ===================> last_row query against normal table along with ts/tbname +sql select last_row(*),ts,'k' from t1; +if $rows != 1 then + return -1 +endi + +print ===================> last_row + user-defined column + normal tables +sql select last_row(ts), 'abc', 1234.9384, ts from t1 +if $rows != 1 then + return -1 +endi + +if $data01 != @abc@ then + print expect abc, actual $data02 + return -1 +endi + +if $data02 != 1234.938400000 then + return -1 +endi + +if $data03 != @19-01-01 01:01:01.000@ then + print expect 19-01-01 01:01:01.000, actual:$data03 + return -1 +endi + +print ===================> last_row + stable + ts/tag column + condition + udf +sql select last_row(*), ts, 'abc', 123.981, tbname from m1 +if $rows != 1 then + return -1 +endi + +if $data02 != @19-01-01 01:01:01.000@ then + return -1 +endi + +if $data03 != @abc@ then + return -1 +endi + +if $data04 != 123.981000000 then + print expect 123.981000000, actual: $data04 + return -1 +endi + +sql create table tu(ts timestamp, k int) +sql select last_row(*) from tu +if $row != 0 then + return -1 +endi diff --git a/tests/script/general/parser/like.sim b/tests/script/general/parser/like.sim new file mode 100644 index 0000000000000000000000000000000000000000..3b1fbbf83e7ca0d08bb324a72dd7046463d8fe61 --- /dev/null +++ b/tests/script/general/parser/like.sim @@ -0,0 +1,100 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sleep 10 +sql connect +print ======================== dnode1 start + + +$db = testdb +sql drop database if exists $db +sql create database $db cachelast 2 +sql use $db + +$table1 = table_name +$table2 = tablexname + +sql create table $table1 (ts timestamp, b binary(20)) +sql create table $table2 (ts timestamp, b binary(20)) + +sql insert into $table1 values(now, "table_name") +sql insert into $table1 values(now-1m, "tablexname") +sql insert into $table1 values(now-2m, "tablexxx") +sql insert into $table1 values(now-3m, "table") + +sql select b from $table1 +if $rows != 4 then + return -1 +endi + +sql select b from $table1 where b like 'table_name' +if $rows != 2 then + return -1 +endi + + +sql select b from $table1 where b like 'table\_name' +if $rows != 1 then + return -1 +endi + +sql show tables; +if $rows != 2 then + return -1 +endi + +sql show tables like 'table_name' +if $rows != 2 then + return -1 +endi + +sql show tables like 'table\_name' +if $rows != 1 then + return -1 +endi + +sql create database escape_percentage; +sql use escape_percentage; +$table1 = tablename +$table2 = table2 + +sql create table $table1 (ts timestamp, b binary(20)) +sql create table $table2 (ts timestamp, b binary(20)) + +sql insert into $table1 values(now, "table%name") +sql insert into $table1 values(now-1m, "table%") +sql insert into $table1 values(now-2m, "table%%%") +sql insert into $table1 values(now-3m, "table") + +sql select b from $table1 where b like 'table\%' +print $rows +if $rows != 1 then + return -1 +endi +sql select b from $table1 where b like 'table\%\%\%' +print $rows +if $rows != 1 then + return -1 +endi +sql select b from $table1 where b like 'table%' +print $rows +if $rows != 4 then + return -1 +endi +sql show tables like 'table\%' +print $rows +if $rows != 0 then + return -1 +endi +sql show tables like 'table%' +print $rows +if $rows != 2 then + return -1 +endi +sql drop database escape_percentage +system sh/exec.sh -n dnode1 -s stop -x SIGINT + + diff --git a/tests/script/general/parser/limit.sim b/tests/script/general/parser/limit.sim new file mode 100644 index 0000000000000000000000000000000000000000..3af2cb301854b27bc1b9c33bf8b06cbd17e87fd3 --- /dev/null +++ b/tests/script/general/parser/limit.sim @@ -0,0 +1,83 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = lm_db +$tbPrefix = lm_tb +$stbPrefix = lm_stb +$tbNum = 10 +$rowNum = 10 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== limit.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +print ====== create tables +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int) + +$i = 0 +$ts = $ts0 +$halfNum = $tbNum / 2 +while $i < $halfNum + $tbId = $i + $halfNum + $tb = $tbPrefix . $i + $tb1 = $tbPrefix . $tbId + sql create table $tb using $stb tags( $i ) + sql create table $tb1 using $stb tags( $tbId ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + + $ts = $ts + $i + sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) + + $ts = $ts + $halfNum + sql insert into $tb1 values ( $ts , $c , NULL , $c , NULL , $c , $c , true, $binary , $nchar ) + $x = $x + 1 + endw + + $i = $i + 1 +endw +print ====== tables created + +run general/parser/limit_tb.sim +run general/parser/limit_stb.sim + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 500 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed +sql connect +sleep 100 + +run general/parser/limit_tb.sim +run general/parser/limit_stb.sim + +print ========> TD-6017 +sql use $db +sql select * from (select ts, top(c1, 5) from $tb where ts >= $ts0 order by ts desc limit 3 offset 1) +sql select * from (select ts, top(c1, 5) from $stb where ts >= $ts0 order by ts desc limit 3 offset 1) + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/parser/limit1.sim b/tests/script/general/parser/limit1.sim new file mode 100644 index 0000000000000000000000000000000000000000..e37bea92207d5a3da34033bbe135570344751375 --- /dev/null +++ b/tests/script/general/parser/limit1.sim @@ -0,0 +1,71 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = lm1_db +$tbPrefix = lm1_tb +$stbPrefix = lm1_stb +$tbNum = 10 +$rowNum = 10000 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== limit1.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +print ====== create tables +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int) + +$i = 0 +$ts = $ts0 +$halfNum = $tbNum / 2 +while $i < $halfNum + $tbId = $i + $halfNum + $tb = $tbPrefix . $i + $tb1 = $tbPrefix . $tbId + sql create table $tb using $stb tags( $i ) + sql create table $tb1 using $stb tags( $tbId ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) $tb1 values ( $ts , $c , NULL , $c , NULL , $c , $c , true, $binary , $nchar ) + $x = $x + 1 + endw + + $i = $i + 1 +endw +print ====== tables created + +run general/parser/limit1_tb.sim +run general/parser/limit1_stb.sim + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 500 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed + +run general/parser/limit1_tb.sim +run general/parser/limit1_stb.sim + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/parser/limit1_stb.sim b/tests/script/general/parser/limit1_stb.sim new file mode 100644 index 0000000000000000000000000000000000000000..513e2fac026c0d1d617ba4126d22c01f82527ca0 --- /dev/null +++ b/tests/script/general/parser/limit1_stb.sim @@ -0,0 +1,696 @@ +sleep 100 +sql connect + +$dbPrefix = lm1_db +$tbPrefix = lm1_tb +$stbPrefix = lm1_stb +$tbNum = 10 +$rowNum = 10000 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== limit1.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i +$tsu = $rowNum * $delta +$tsu = $tsu - $delta +$tsu = $tsu + $ts0 + +print ====== use db +sql use $db + +#### select from supertable + +### select from stb + limit offset +sql select * from $stb limit 5 +if $rows != 5 then + return -1 +endi +sql select * from $stb limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data41 != 5 then + return -1 +endi +$val = $totalNum - 1 +sql select * from $stb limit $totalNum offset 1 +if $rows != $val then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data41 != 5 then + return -1 +endi + +##TBASE-352 +$offset = $tbNum * $rowNum +$offset = $offset - 1 +sql select * from $stb limit 2 offset $offset +if $rows != 1 then + return -1 +endi +if $data00 != @18-11-25 19:30:00.000@ then + return -1 +endi +if $data01 != 9 then + return -1 +endi +if $data02 != NULL then + return -1 +endi +if $data03 != 9.00000 then + return -1 +endi +if $data04 != NULL then + return -1 +endi +if $data05 != 9 then + return -1 +endi +if $data06 != 9 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data08 != binary9 then + return -1 +endi +if $data09 != nchar9 then + return -1 +endi + +$offset = $tbNum * $rowNum +$offset = $offset / 2 +$offset = $offset - 1 +sql select * from $stb limit 2 offset $offset +if $rows != 2 then + return -1 +endi +#if $data00 != @18-11-25 19:30:00.000@ then +# return -1 +#endi +#if $data01 != 9 then +# return -1 +#endi +#if $data02 != 9 then +# return -1 +#endi +#if $data03 != 9.00000 then +# return -1 +#endi +#if $data04 != 9.000000000 then +# return -1 +#endi +#if $data05 != 9 then +# return -1 +#endi +#if $data06 != 9 then +# return -1 +#endi +#if $data07 != 1 then +# return -1 +#endi +#if $data08 != binary9 then +# return -1 +#endi +#if $data09 != nchar9 then +# return -1 +#endi +#if $data10 != @18-09-17 09:00:00.000@ then +# return -1 +#endi +#if $data11 != 0 then +# return -1 +#endi +#if $data12 != NULL then +# return -1 +#endi +#if $data13 != 0.00000 then +# return -1 +#endi +#if $data14 != NULL then +# return -1 +#endi +#if $data15 != 0 then +# return -1 +#endi +#if $data16 != 0 then +# return -1 +#endi +#if $data17 != 1 then +# return -1 +#endi +#if $data18 != binary0 then +# return -1 +#endi +#if $data19 != nchar0 then +# return -1 +#endi + +### offset >= rowsInFileBlock +##TBASE-352 +$limit = $totalNum / 2 +$offset = $totalNum +sql select * from $stb limit $limit offset $offset +if $rows != 0 then + return -1 +endi + +$offset = $offset - 1 +sql select * from $stb limit $limit offset $offset +if $rows != 1 then + return -1 +endi +$limit = $totalNum / 2 +$offset = $totalNum / 2 +$offset = $offset - 1 +sql select * from $stb limit $limit offset $offset +if $rows != $limit then + return -1 +endi +$offset = $totalNum / 2 +$offset = $offset + 1 +sql select * from $stb limit $limit offset $offset +$val = $limit - 1 +if $rows != $val then + return -1 +endi + +sql select ts, c1, c2, c3, c4, c5, c6, c7, c8, c9 from $stb limit 1 offset 0; +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +sql select ts, c1, c2, c3, c4, c5, c6, c7, c8, c9 from $stb limit 1 offset 1; +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select ts, c1, c2, c3, c4, c5, c6, c7, c8, c9 from $stb limit 1 offset 4; +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:40:00.000@ then + return -1 +endi +if $data01 != 4 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data03 != 4.00000 then + return -1 +endi +if $data04 != 4.000000000 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 4 then + return -1 +endi +if $data08 != binary4 then + return -1 +endi +if $data09 != nchar4 then + return -1 +endi + +### select from supertable + where + limit offset +sql select * from $stb where ts > '2018-09-17 09:30:00.000' and ts < '2018-09-17 10:30:00.000' limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data11 != 6 then + return -1 +endi +if $data21 != 7 then + return -1 +endi +if $data31 != 8 then + return -1 +endi +if $data41 != 4 then + return -1 +endi + +$offset = $totalNum / 2 +sql select * from $stb where ts >= $ts0 and ts <= $tsu limit 5 offset $offset +if $rows != 5 then + return -1 +endi +#if $data00 != @18-09-17 09:00:00.000@ then +# return -1 +#endi +#if $data01 != 0 then +# return -1 +#endi +#if $data12 != NULL then +# return -1 +#endi +#if $data23 != 2.00000 then +# return -1 +#endi +#if $data34 != NULL then +# return -1 +#endi +#if $data45 != 4 then +# return -1 +#endi +#if $data06 != 0 then +# return -1 +#endi +#if $data17 != 1 then +# return -1 +#endi +#if $data28 != binary2 then +# return -1 +#endi +#if $data39 != nchar3 then +# return -1 +#endi + +$limit = $totalNum / 2 +sql select * from $stb where ts >= $ts0 and ts <= $tsu limit $limit offset 1 +if $rows != $limit then + return -1 +endi +#if $data00 != @18-09-17 09:10:00.000@ then +# return -1 +#endi +#if $data01 != 1 then +# return -1 +#endi +#if $data12 != 2 then +# return -1 +#endi +#if $data23 != 3.00000 then +# return -1 +#endi +#if $data34 != 4.000000000 then +# return -1 +#endi +#if $data45 != 5 then +# return -1 +#endi +#if $data06 != 1 then +# return -1 +#endi +#if $data17 != 1 then +# return -1 +#endi +#if $data28 != binary3 then +# return -1 +#endi +#if $data39 != nchar4 then +# return -1 +#endi + +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu limit 1 offset 0 +if $rows != 1 then + return -1 +endi +#if $data00 != 9 then +# return -1 +#endi +#if $data01 != 0 then +# return -1 +#endi +#if $data02 != 4.500000000 then +# return -1 +#endi +#$val = 45 * $rowNum +#if $data03 != $val then +# return -1 +#endi +#if $data04 != 9.000000000 then +# return -1 +#endi +#if $data05 != 1 then +# return -1 +#endi +#if $data06 != binary9 then +# return -1 +#endi +#if $data07 != nchar0 then +# return -1 +#endi + +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and c1 > 1 and c2 < 9 and c3 > 2 and c4 < 8 and c5 > 3 and c6 < 7 and c7 != 0 and c8 like '%5' and t1 > 3 and t1 < 6 limit 1 offset 0; +if $rows != 1 then + return -1 +endi +if $data00 != 5 then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data02 != 5.000000000 then + return -1 +endi +$val = 5 * $rowNum +$val = $val / 10 +if $data03 != $val then + return -1 +endi +if $data04 != 0.000000000 then + return -1 +endi +if $data05 != 1 then + return -1 +endi +if $data06 != binary5 then + return -1 +endi +if $data07 != nchar5 then + return -1 +endi + +$limit = $totalNum +$offset = $totalNum +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 3 and t1 < 6 limit $limit offset $offset +if $rows != 0 then + return -1 +endi + +## TBASE-353 +$limit = $totalNum / 2 +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 group by t1 order by t1 asc limit $limit offset 1 +if $rows != 0 then + return -1 +endi + +$limit = $totalNum / 2 +sql select max(c1), min(c2), avg(c3), count(c4), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 group by t1 order by t1 asc limit $limit offset 0 +if $rows != 6 then + print expect 6, actual:$rows + return -1 +endi +if $data00 != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data03 != $rowNum then + return -1 +endi +if $data09 != 2 then + return -1 +endi +$val = 9 * $rowNum +$val = $val / 2 +if $data14 != $val then + return -1 +endi +if $data19 != 3 then + return -1 +endi +if $data25 != 9.000000000 then + return -1 +endi +if $data26 != 1 then + return -1 +endi +if $data31 != NULL then + return -1 +endi +if $data42 != 4.500000000 then + return -1 +endi +if $data33 != 0 then + return -1 +endi +if $data43 != 0 then + return -1 +endi +if $data59 != 7 then + return -1 +endi + +$limit = $totalNum / 2 +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 group by t1 order by t1 desc limit $limit offset 1 +if $rows != 0 then + return -1 +endi + +$limit = $totalNum / 2 +sql select max(c1), min(c2), avg(c3), count(c4), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 group by t1 order by t1 desc limit $limit offset 0 +if $rows != 6 then + return -1 +endi +if $data00 != 9 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data12 != 4.500000000 then + return -1 +endi +if $data23 != 0 then + return -1 +endi +if $data09 != 7 then + return -1 +endi +$val = 9 * $rowNum +$val = $val / 2 +if $data14 != $val then + return -1 +endi +if $data19 != 6 then + return -1 +endi +if $data25 != 9.000000000 then + return -1 +endi +if $data26 != 1 then + return -1 +endi +if $data31 != 0 then + return -1 +endi +if $data32 != 4.500000000 then + return -1 +endi +if $data33 != $rowNum then + return -1 +endi +$val = 9 * $rowNum +$val = $val / 2 +if $data44 != $val then + return -1 +endi +if $data59 != 2 then + return -1 +endi + +### supertable aggregation + where + interval + limit offset +## TBASE-355 +sql select max(c1), min(c2), avg(c3), count(c4), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 interval(5m) limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data00 != @18-09-17 09:10:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data15 != 12 then + return -1 +endi +if $data40 != @18-09-17 09:50:00.000@ then + return -1 +endi +if $data41 != 5 then + return -1 +endi + +### [TBASE-361] +$offset = $rowNum / 2 +$offset = $offset + 1 +sql select max(c1), min(c2), avg(c3), count(c4), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 interval(5m) limit $offset offset $offset +$val = $rowNum - $offset +if $rows != $val then + print expect $val, actual:$rows + return -1 +endi +if $data00 != @18-10-22 02:30:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data05 != 6 then + return -1 +endi +if $data30 != @18-10-22 03:00:00.000@ then + return -1 +endi +if $data31 != 4 then + return -1 +endi +if $data42 != 5 then + return -1 +endi +if $data53 != 6.000000000 then + return -1 +endi +if $data54 != 3 then + return -1 +endi +if $data55 != 36 then + return -1 +endi + +## supertable aggregation + where + interval + group by order by tag + limit offset +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 5 and c1 > 0 and c2 < 9 and c3 > 1 and c4 < 7 and c5 > 4 interval(5m) group by t1 order by t1 desc limit 2 offset 0 +if $rows != 6 then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data09 != 4 then + return -1 +endi +if $data11 != 6 then + return -1 +endi +if $data19 != 4 then + return -1 +endi +if $data22 != 5 then + return -1 +endi +if $data29 != 3 then + return -1 +endi +if $data33 != 6.000000000 then + return -1 +endi +if $data39 != 3 then + return -1 +endi +if $data44 != 5 then + return -1 +endi +if $data49 != 2 then + return -1 +endi +if $data58 != nchar6 then + return -1 +endi +if $data59 != 2 then + return -1 +endi + +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 5 and c1 > 0 and c2 < 9 and c3 > 1 and c4 < 7 and c5 > 4 interval(5m) group by t1 order by t1 desc limit 2 offset 1 +if $rows != 6 then + return -1 +endi +if $data01 != 6 then + return -1 +endi +if $data09 != 4 then + return -1 +endi +if $data13 != 5.000000000 then + return -1 +endi +if $data19 != 4 then + return -1 +endi +if $data28 != nchar6 then + return -1 +endi +if $data29 != 3 then + return -1 +endi +if $data46 != 1 then + return -1 +endi +if $data59 != 2 then + return -1 +endi + +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 5 and c1 > 0 and c2 < 9 and c3 > 1 and c4 < 7 and c5 > 4 interval(5m) group by t1 order by t1 desc limit 1 offset 0 +if $rows != 3 then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data09 != 4 then + return -1 +endi +if $data13 != 5.000000000 then + return -1 +endi +if $data19 != 3 then + return -1 +endi +if $data28 != nchar5 then + return -1 +endi +if $data29 != 2 then + return -1 +endi + +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 and c1 > 0 and c2 < 9 and c3 > 4 and c4 < 7 and c5 > 4 interval(5m) group by t1 order by t1 desc limit 2 offset 0 +if $rows != 6 then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data09 != 4 then + return -1 +endi +if $data19 != 4 then + return -1 +endi +if $data23 != 5.000000000 then + return -1 +endi +if $data29 != 3 then + return -1 +endi +if $data39 != 3 then + return -1 +endi +if $data48 != nchar5 then + return -1 +endi +if $data49 != 2 then + return -1 +endi +if $data59 != 2 then + return -1 +endi diff --git a/tests/script/general/parser/limit1_tb.sim b/tests/script/general/parser/limit1_tb.sim new file mode 100644 index 0000000000000000000000000000000000000000..300af7ac7b669088094c0ba72288f42d34ca374d --- /dev/null +++ b/tests/script/general/parser/limit1_tb.sim @@ -0,0 +1,1155 @@ +sleep 100 +sql connect + +$dbPrefix = lm1_db +$tbPrefix = lm1_tb +$stbPrefix = lm1_stb +$tbNum = 10 +$rowNum = 10000 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== limit1_tb.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +print ====== use db +sql use $db + +##### select from table +print ====== select from table with limit offset +$tb = $tbPrefix . 0 +sql select * from $tb order by ts desc limit 5 +if $rows != 5 then + return -1 +endi +if $data01 != 9 then + return -1 +endi +if $data41 != 5 then + return -1 +endi + +sql select * from $tb order by ts desc limit 5 offset 5 +if $rows != 5 then + return -1 +endi +if $data01 != 4 then + return -1 +endi +if $data41 != 0 then + return -1 +endi + +$offset = $rowNum - 1 +sql select * from $tb order by ts desc limit 5 offset $offset +if $rows != 1 then + return -1 +endi + +sql select ts, c1, c2, c3, c4, c5, c6, c7, c8, c9 from $tb order by ts desc limit 5 offset 5 +if $rows != 5 then + return -1 +endi +if $data01 != 4 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data03 != 4.00000 then + return -1 +endi +if $data04 != 4.000000000 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 4 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data08 != binary4 then + return -1 +endi +if $data09 != nchar4 then + return -1 +endi + +sql select ts, c1, c2, c3, c4, c5, c6, c7, c8, c9 from $tb order by ts desc limit 5 offset $offset +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 0.00000 then + return -1 +endi +if $data04 != 0.000000000 then + return -1 +endi +if $data05 != 0 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data08 != binary0 then + return -1 +endi +if $data09 != nchar0 then + return -1 +endi +if $data11 != null then + return -1 +endi +if $data12 != null then + return -1 +endi +if $data13 != null then + return -1 +endi +if $data14 != null then + return -1 +endi + +## TBASE-329 +sql select * from $tb where c1 < 9 order by ts desc limit 1 offset 1 +if $rows != 1 then + return -1 +endi +if $data01 != 7 then + return -1 +endi + +sql select * from $tb where c1 < 9 order by ts desc limit 2 offset 1 +if $rows != 2 then + return -1 +endi +if $data01 != 7 then + return -1 +endi +if $data11 != 6 then + return -1 +endi + +sql select * from $tb where c1 < 9 order by ts desc limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data01 != 7 then + return -1 +endi +if $data11 != 6 then + return -1 +endi +if $data21 != 5 then + return -1 +endi + +sql select * from $tb where c1 < 0 order by ts desc limit 3 offset 1 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where c1 > 0 order by ts desc limit 1 offset 1 +if $rows != 1 then + return -1 +endi +if $data01 != 8 then + return -1 +endi + +sql select * from $tb where c1 > 0 order by ts desc limit 2 offset 1 +if $rows != 2 then + return -1 +endi +if $data01 != 8 then + return -1 +endi +if $data11 != 7 then + return -1 +endi + + +sql_error select * from $tb limit +sql_error select * from $tb offset +sql_error select * from $tb offset 1 +sql_error select * from $tb offset 1 limit 5 +sql_error select * from $tb offset 1 limit -1 + +#### aggregation function + limit offset +$tsu = $rowNum * $delta +$tsu = $tsu - $delta +$tsu = $tsu + $ts0 + +### aggregation function + limit offset (non-interval case) +sql select max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 +if $rows != 1 then + return -1 +endi +sql select max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 0 +if $rows != 0 then + return -1 +endi +sql select max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu and c1 < 9 and c2 < 8 and c3 >0 and c4 <= 7 and c5 <7 limit 5 offset 0 +if $rows != 1 then + return -1 +endi + +sql select max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi + +sql select min(c1), min(c2), min(c3), min(c4), min(c5), min(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 +if $rows != 1 then + return -1 +endi +sql select min(c1), min(c2), min(c3), min(c4), min(c5), min(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 0 offset 0 +if $rows != 0 then + return -1 +endi +sql select min(c1), min(c2), min(c3), min(c4), min(c5), min(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi + +sql select sum(c1), avg(c2), stddev(c3), max(c4), min(c5), count(c6), first(c7), last(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu limit 5 +if $rows != 1 then + return -1 +endi +$val = 45 * $rowNum +$val = $val / 10 +if $data00 != $val then + return -1 +endi +if $data01 != 4.500000000 then + return -1 +endi +if $data02 != 2.872281323 then + return -1 +endi +if $data03 != 9.000000000 then + return -1 +endi +if $data04 != 0 then + return -1 +endi +if $data05 != $rowNum then + return -1 +endi +if $data06 != 1 then + return -1 +endi +if $data07 != binary9 then + return -1 +endi +if $data08 != nchar9 then + return -1 +endi + +sql select sum(c1), avg(c2), stddev(c3), max(c4), min(c5), count(c6), first(c7), last(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu limit 0 +if $rows != 0 then + return -1 +endi +sql select sum(c1), avg(c2), stddev(c3), max(c4), min(c5), count(c6), first(c7), last(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1>1 and c2<9 and c3>2 and c4<8 and c5>4 and c6<6 limit 1 offset 0 +if $rows != 1 then + return -1 +endi +$val = $rowNum / 10 +$val = $val * 5 +if $data00 != $val then + return -1 +endi +if $data01 != 5.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 5.000000000 then + return -1 +endi +if $data04 != 5 then + return -1 +endi +$val = $rowNum / 10 +if $data05 != $val then + return -1 +endi +if $data06 != 1 then + return -1 +endi +if $data07 != binary5 then + return -1 +endi +if $data08 != nchar5 then + return -1 +endi + +sql select sum(c1), avg(c2), stddev(c3), max(c4), min(c5), count(c6), first(c7), last(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu limit 3 offset 1 +if $rows != 0 then + return -1 +endi + +sql select spread(ts), spread(c1), spread(c2), spread(c3), spread(c4), spread(c5), spread(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 0 +if $rows != 1 then + return -1 +endi +$val = $rowNum - 1 +$val = $val * 600000.000000000 +$val = $data00 - $val +if $val != 0 then + return -1 +endi +if $data01 != 9.000000000 then + return -1 +endi +if $data02 != 9.000000000 then + return -1 +endi +if $data03 != 9.000000000 then + return -1 +endi +if $data04 != 9.000000000 then + return -1 +endi +if $data05 != 9.000000000 then + return -1 +endi +if $data06 != 9.000000000 then + return -1 +endi +sql select spread(ts), spread(c1), spread(c2), spread(c3), spread(c4), spread(c5), spread(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi + +$val = $tsu + $delta +sql select twa(c1), twa(c2), twa(c3), twa(c4), twa(c5), twa(c6) from $tb where ts >= $ts0 and ts <= $val limit 5 offset 0 +if $rows != 1 then + return -1 +endi +if $data00 != 4.500000000 then + return -1 +endi +if $data01 != 4.500000000 then + return -1 +endi +if $data02 != 4.500000000 then + return -1 +endi +if $data03 != 4.500000000 then + return -1 +endi +if $data04 != 4.500000000 then + return -1 +endi +if $data05 != 4.500000000 then + return -1 +endi + +sql select twa(c1), twa(c2), twa(c3), twa(c4), twa(c5), twa(c6) from $tb where ts >= $ts0 and ts <= $val limit 5 offset 1 +if $rows != 0 then + return -1 +endi + +## TBASE-354 +sql select top(c1, 1) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi +sql select top(c1, 5) from $tb where ts >= $ts0 and ts <= $tsu limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data00 != @18-09-17 12:10:00.000@ then + return -1 +endi +if $data01 != 9 then + return -1 +endi +if $data10 != @18-09-17 13:50:00.000@ then + return -1 +endi +if $data11 != 9 then + return -1 +endi +if $data20 != @18-09-17 15:30:00.000@ then + return -1 +endi +if $data21 != 9 then + return -1 +endi +sql select top(c1, 5) from $tb where ts >= $ts0 and ts <= $tsu limit 3 offset 5 +if $rows != 0 then + return -1 +endi + +sql select bottom(c1, 1) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi +sql select bottom(c1, 5) from $tb where ts >= $ts0 and ts <= $tsu limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data00 != @18-09-17 10:40:00.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data10 != @18-09-17 12:20:00.000@ then + return -1 +endi +if $data11 != 0 then + return -1 +endi +if $data20 != @18-09-17 14:00:00.000@ then + return -1 +endi +if $data21 != 0 then + return -1 +endi +sql select bottom(c1, 5) from $tb where ts >= $ts0 and ts <= $tsu limit 3 offset 5 +if $rows != 0 then + return -1 +endi + +sql select diff(c1) from $tb +$res = $rowNum - 1 +if $rows != $res then + return -1 +endi + +sql select diff(c1) from $tb where c1 > 5 limit 2 offset 1 +if $rows != 2 then + return -1 +endi +if $data00 != @18-09-17 10:20:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != @18-09-17 10:30:00.000@ then + return -1 +endi +if $data11 != 1 then + return -1 +endi +$limit = $rowNum / 2 +$offset = $limit - 1 +sql select diff(c1) from $tb where c1 >= 0 limit $limit offset $offset +if $rows != $limit then + return -1 +endi +$limit = $rowNum / 2 +$offset = $limit + 1 +$val = $limit - 2 +sql select diff(c1) from $tb where c1 >= 0 limit $limit offset $offset +if $rows != $val then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data81 != -9 then + return -1 +endi + +### aggregation + limit offset (with interval) +sql select max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) limit 5 +if $rows != 5 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != 1 then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data31 != 3 then + return -1 +endi +if $data41 != 4 then + return -1 +endi +sql select max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 1.00000 then + return -1 +endi +if $data04 != 1.000000000 then + return -1 +endi +if $data05 != 1 then + return -1 +endi +if $data06 != 1 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data21 != 3 then + return -1 +endi +if $data31 != 4 then + return -1 +endi +if $data41 != 5 then + return -1 +endi + +## TBASE-334 +sql select max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 2 offset 1 +if $rows != 2 then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data04 != 5.000000000 then + return -1 +endi +if $data11 != 8 then + return -1 +endi +if $data14 != 8.000000000 then + return -1 +endi +if $data21 != null then + return -1 +endi + +sql select min(c1), min(c2), min(c3), min(c4), min(c5), min(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data01 != 3 then + return -1 +endi +if $data11 != 6 then + return -1 +endi +if $data21 != 0 then + return -1 +endi + +sql select sum(c1), sum(c2), sum(c3), sum(c4), sum(c5), sum(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 5 +if $rows != 5 then + return -1 +endi +if $data01 != 3 then + return -1 +endi +if $data11 != 12 then + return -1 +endi +if $data21 != 21 then + return -1 +endi +if $data31 != 10 then + return -1 +endi +if $data41 != 9 then + return -1 +endi +sql select sum(c1), sum(c2), sum(c3), sum(c4), sum(c5), sum(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data01 != 12 then + return -1 +endi +if $data11 != 21 then + return -1 +endi +if $data21 != 10 then + return -1 +endi +if $data31 != 9 then + return -1 +endi +if $data41 != 18 then + return -1 +endi + +sql select avg(c1), avg(c2), avg(c3), avg(c4), avg(c5), avg(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 0 +if $rows != 3 then + return -1 +endi +if $data01 != 1.000000000 then + return -1 +endi +if $data11 != 4.000000000 then + return -1 +endi +if $data21 != 7.000000000 then + return -1 +endi +if $data31 != null then + return -1 +endi +sql select avg(c1), avg(c2), avg(c3), avg(c4), avg(c5), avg(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data01 != 4.000000000 then + return -1 +endi +if $data11 != 7.000000000 then + return -1 +endi +if $data21 != 3.333333333 then + return -1 +endi + +sql select stddev(c1), stddev(c2), stddev(c3), stddev(c4), stddev(c5), stddev(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi +sql select stddev(c1), stddev(c2), stddev(c3), stddev(c4), stddev(c5), stddev(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) limit 0 +if $rows != 0 then + return -1 +endi +sql select stddev(c1), stddev(c2), stddev(c3), stddev(c4), stddev(c5), stddev(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data00 != @18-09-17 09:30:00.000@ then + return -1 +endi +if $data01 != 0.816496581 then + return -1 +endi +if $data10 != @18-09-17 10:00:00.000@ then + return -1 +endi +if $data20 != @18-09-17 10:30:00.000@ then + return -1 +endi +if $data21 != 4.027681991 then + return -1 +endi + +sql select count(c1), count(c2), count(c3), count(c4), count(c5), count(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(27m) +if $rows != 3704 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data21 != 3 then + return -1 +endi +if $data31 != 3 then + return -1 +endi +sql select count(c1), count(c2), count(c3), count(c4), count(c5), count(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(27m) limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data11 != 3 then + return -1 +endi +if $data21 != 3 then + return -1 +endi +if $data31 != 2 then + return -1 +endi +if $data41 != 3 then + return -1 +endi + +sql select twa(c1), twa(c2), twa(c3), twa(c4), twa(c5), twa(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 3 offset 1 +if $rows != 0 then + return -1 +endi + +sql select twa(c1), twa(c2), twa(c3), twa(c4), twa(c5), twa(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 3 offset 0 +if $rows != 1 then + return -1 +endi +if $data00 != 4.500000000 then + return -1 +endi +if $data02 != 4.500000000 then + return -1 +endi +if $data05 != 4.500000000 then + return -1 +endi + +sql select first(c1), first(c2), first(c3), first(c4), first(c5), first(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi + +sql select first(c1), first(c2), first(c3), first(c4), first(c5), first(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1 +if $rows != 3 then + return -1 +endi + +if $data01 != 3 then + return -1 +endi +if $data12 != 6 then + return -1 +endi +if $data23 != 9.00000 then + return -1 +endi + +sql select last(c1), last(c2), last(c3), last(c4), last(c5), last(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi +sql select last(c1), last(c2), last(c3), last(c4), last(c5), last(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data12 != 8 then + return -1 +endi +if $data23 != 1.00000 then + return -1 +endi + +sql select first(ts), first(c1), last(c2), first(c3), last(c4), first(c5), last(c6), first(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 > 0 interval(30m) limit 3 offset 0 +if $rows != 3 then + return -1 +endi +if $data01 != @18-09-17 09:10:00.000@ then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data12 != 3 then + return -1 +endi +if $data13 != 5 then + return -1 +endi +if $data14 != 3.00000 then + return -1 +endi +if $data22 != 6 then + return -1 +endi +if $data23 != 8 then + return -1 +endi +if $data28 != binary6 then + return -1 +endi +if $data29 != nchar8 then + return -1 +endi + +sql select first(ts), first(c1), last(c2), first(c3), last(c4), first(c5), last(c6), first(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 > 0 interval(30m) limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data01 != @18-09-17 09:30:00.000@ then + return -1 +endi +if $data02 != 3 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 3.00000 then + return -1 +endi +if $data05 != 5.000000000 then + return -1 +endi +if $data08 != binary3 then + return -1 +endi +if $data09 != nchar5 then + return -1 +endi +if $data12 != 6 then + return -1 +endi +if $data13 != 8 then + return -1 +endi +if $data14 != 6.00000 then + return -1 +endi +if $data15 != 8.000000000 then + return -1 +endi +if $data22 != 9 then + return -1 +endi +if $data23 != 1 then + return -1 +endi +if $data24 != 9.00000 then + return -1 +endi +if $data25 != 1.000000000 then + return -1 +endi +if $data26 != 9 then + return -1 +endi +if $data27 != 1 then + return -1 +endi +if $data28 != binary9 then + return -1 +endi +if $data29 != nchar1 then + return -1 +endi + +### order by ts + limit offset + +sql select * from $tb order by ts asc limit 5 +if $rows != 5 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data10 != @18-09-17 09:10:00.000@ then + return -1 +endi +if $data12 != 1 then + return -1 +endi +if $data20 != @18-09-17 09:20:00.000@ then + return -1 +endi +if $data23 != 2.00000 then + return -1 +endi +if $data34 != 3.000000000 then + return -1 +endi +if $data45 != 4 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data17 != 1 then + return -1 +endi +if $data28 != binary2 then + return -1 +endi +if $data39 != nchar3 then + return -1 +endi +if $data40 != @18-09-17 09:40:00.000@ then + return -1 +endi + +sql select * from $tb order by ts asc limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data00 != @18-09-17 09:10:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != @18-09-17 09:20:00.000@ then + return -1 +endi +if $data12 != 2 then + return -1 +endi +if $data20 != @18-09-17 09:30:00.000@ then + return -1 +endi +if $data23 != 3.00000 then + return -1 +endi +if $data34 != 4.000000000 then + return -1 +endi +if $data45 != 5 then + return -1 +endi +if $data06 != 1 then + return -1 +endi +if $data17 != 1 then + return -1 +endi +if $data28 != binary3 then + return -1 +endi +if $data39 != nchar4 then + return -1 +endi +if $data40 != @18-09-17 09:50:00.000@ then + return -1 +endi + +sql select * from $tb order by ts asc limit 5 offset 8 +if $rows != 5 then + return -1 +endi +if $data00 != @18-09-17 10:20:00.000@ then + return -1 +endi +if $data01 != 8 then + return -1 +endi +if $data10 != @18-09-17 10:30:00.000@ then + return -1 +endi +if $data12 != 9 then + return -1 +endi + +sql select * from $tb where c1 > 1 order by ts asc limit 3 offset 2 +if $rows != 3 then + return -1 +endi +if $data00 != @18-09-17 09:40:00.000@ then + return -1 +endi +if $data01 != 4 then + return -1 +endi +if $data10 != @18-09-17 09:50:00.000@ then + return -1 +endi +if $data20 != @18-09-17 10:00:00.000@ then + return -1 +endi +if $data12 != 5 then + return -1 +endi +if $data23 != 6.00000 then + return -1 +endi + +$offset = $rowNum / 10 +sql select * from $tb where c1 < 3 and c1 > 1 order by ts asc limit 3 offset $offset +if $rows != 0 then + return -1 +endi + +$offset = $rowNum / 10 +$offset = $offset * 3 +$offset = $offset - 1 +sql select * from $tb where c1 < 5 and c1 > 1 order by ts asc limit 3 offset $offset +if $rows != 1 then + return -1 +endi +if $data00 != @18-11-25 18:40:00.000@ then + return -1 +endi +if $data01 != 4 then + return -1 +endi +if $data04 != 4.000000000 then + return -1 +endi + +sql select * from $tb order by ts desc limit 5 +if $rows != 5 then + return -1 +endi +if $data00 != @18-11-25 19:30:00.000@ then + return -1 +endi +if $data01 != 9 then + return -1 +endi +if $data10 != @18-11-25 19:20:00.000@ then + return -1 +endi +if $data12 != 8 then + return -1 +endi +if $data20 != @18-11-25 19:10:00.000@ then + return -1 +endi +if $data23 != 7.00000 then + return -1 +endi +if $data34 != 6.000000000 then + return -1 +endi +if $data45 != 5 then + return -1 +endi +if $data06 != 9 then + return -1 +endi +if $data17 != 1 then + return -1 +endi +if $data28 != binary7 then + return -1 +endi +if $data39 != nchar6 then + return -1 +endi +if $data40 != @18-11-25 18:50:00.000@ then + return -1 +endi + +sql select * from $tb order by ts desc limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data00 != @18-11-25 19:20:00.000@ then + return -1 +endi +if $data01 != 8 then + return -1 +endi +if $data10 != @18-11-25 19:10:00.000@ then + return -1 +endi +if $data12 != 7 then + return -1 +endi +if $data20 != @18-11-25 19:00:00.000@ then + return -1 +endi +if $data23 != 6.00000 then + return -1 +endi +if $data34 != 5.000000000 then + return -1 +endi +if $data45 != 4 then + return -1 +endi +if $data06 != 8 then + return -1 +endi +if $data17 != 1 then + return -1 +endi +if $data28 != binary6 then + return -1 +endi +if $data39 != nchar5 then + return -1 +endi +if $data40 != @18-11-25 18:40:00.000@ then + return -1 +endi + +$offset = $rowNum +$offset = $offset - 2 +sql select * from $tb order by ts desc limit 5 offset $offset +if $rows != 2 then + return -1 +endi +if $data00 != @18-09-17 09:10:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data12 != 0 then + return -1 +endi + +sql select * from $tb where c1 < 8 order by ts desc limit 3 offset 2 +if $rows != 3 then + return -1 +endi +if $data00 != @18-11-25 18:50:00.000@ then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data10 != @18-11-25 18:40:00.000@ then + return -1 +endi +if $data20 != @18-11-25 18:30:00.000@ then + return -1 +endi +if $data12 != 4 then + return -1 +endi +if $data23 != 3.00000 then + return -1 +endi + +$offset = $rowNum / 10 +sql select * from $tb where c1 < 8 and c1 > 6 order by ts desc limit 3 offset $offset +if $rows != 0 then + return -1 +endi + +$limit = $rowNum / 10 +$limit = $limit * 3 +$offset = $limit - 1 +sql select * from $tb where c1 < 8 and c1 > 4 order by ts desc limit $limit offset $offset +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:50:00.000@ then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data04 != 5.000000000 then + return -1 +endi diff --git a/tests/script/general/parser/limit1_tblocks100.sim b/tests/script/general/parser/limit1_tblocks100.sim new file mode 100644 index 0000000000000000000000000000000000000000..4546ffdb7910a7dd999a119743fa36682fe0eade --- /dev/null +++ b/tests/script/general/parser/limit1_tblocks100.sim @@ -0,0 +1,71 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = lm1_db +$tbPrefix = lm1_tb +$stbPrefix = lm1_stb +$tbNum = 10 +$rowNum = 10000 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== limit1.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db cache 16 +print ====== create tables +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int) + +$i = 0 +$ts = $ts0 +$halfNum = $tbNum / 2 +while $i < $halfNum + $tbId = $i + $halfNum + $tb = $tbPrefix . $i + $tb1 = $tbPrefix . $tbId + sql create table $tb using $stb tags( $i ) + sql create table $tb1 using $stb tags( $tbId ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) $tb1 values ( $ts , $c , NULL , $c , NULL , $c , $c , true, $binary , $nchar ) + $x = $x + 1 + endw + + $i = $i + 1 +endw +print ====== tables created + +run general/parser/limit1_tb.sim +run general/parser/limit1_stb.sim + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 500 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed + +run general/parser/limit1_tb.sim +run general/parser/limit1_stb.sim + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/limit2.sim b/tests/script/general/parser/limit2.sim new file mode 100644 index 0000000000000000000000000000000000000000..336f9234c82ab51b1ff478e21f99e058074a2818 --- /dev/null +++ b/tests/script/general/parser/limit2.sim @@ -0,0 +1,78 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c rowsInFileBlock -v 255 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = lm2_db +$tbPrefix = lm2_tb +$stbPrefix = lm2_stb +$tbNum = 10 +$rowNum = 10000 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +$tsu = $rowNum * $delta +$tsu = $tsu - $delta +$tsu = $tsu + $ts0 + +print ========== limit2.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +print ====== create tables +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int, t2 nchar(20), t3 binary(20), t4 bigint, t5 smallint, t6 double) + +$i = 0 +$ts = $ts0 +$halfNum = $tbNum / 2 +while $i < $halfNum + $i1 = $i + $halfNum + $tb = $tbPrefix . $i + $tb1 = $tbPrefix . $i1 + $tgstr = 'tb . $i + $tgstr = $tgstr . ' + $tgstr1 = 'tb . $i1 + $tgstr1 = $tgstr1 . ' + sql create table $tb using $stb tags( $i , $tgstr , $tgstr , $i , $i , $i ) + sql create table $tb1 using $stb tags( $i1 , $tgstr1 , $tgstr1 , $i , $i , $i ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) + sql insert into $tb1 values ( $ts , $c , NULL , $c , NULL , $c , $c , true, $binary , $nchar ) + $x = $x + 1 + endw + + $i = $i + 1 +endw +print ====== tables created + +#run general/parser/limit2_query.sim + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 500 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed + +run general/parser/limit2_query.sim + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/parser/limit2_query.sim b/tests/script/general/parser/limit2_query.sim new file mode 100644 index 0000000000000000000000000000000000000000..c35fd369ca33eb7158ed3223a40f37c522702bc5 --- /dev/null +++ b/tests/script/general/parser/limit2_query.sim @@ -0,0 +1,427 @@ +sleep 100 +sql connect + +$dbPrefix = lm2_db +$tbPrefix = lm2_tb +$stbPrefix = lm2_stb +$tbNum = 10 +$rowNum = 10000 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +$tsu = $rowNum * $delta +$tsu = $tsu - $delta +$tsu = $tsu + $ts0 + +print ========== limit2.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i +$tb = $tbPrefix . 0 +print ====== use db +sql use $db + +##### aggregation on stb with 6 tags + where + group by + limit offset +$val1 = 1 +$val2 = $tbNum - 1 +sql select count(*) from $stb where t1 > $val1 and t1 < $val2 group by t1, t2, t3, t4, t5, t6 order by t1 asc limit 1 offset 0 +$val = $tbNum - 3 +if $rows != $val then + return -1 +endi +if $data00 != $rowNum then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != tb2 then + print expect tb2, actual: $data02 + return -1 +endi +if $data03 != tb2 then + return -1 +endi +if $data04 != 2 then + return -1 +endi +if $data05 != 2 then + return -1 +endi + +sql select count(*) from $stb where t2 like '%' and t1 > 2 and t1 < 5 group by t3, t4 order by t3 desc limit 1 offset 0 +if $rows != 2 then + return -1 +endi +if $data00 != $rowNum then + return -1 +endi +if $data01 != tb4 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data11 != tb3 then + return -1 +endi +if $data12 != 3 then + return -1 +endi +sql select count(*) from $stb where t2 like '%' and t1 > 2 and t1 < 5 group by t3, t4 order by t3 desc limit 1 offset 1 +if $rows != 0 then + return -1 +endi +## TBASE-348 +sql_error select count(*) from $stb where t1 like 1 + +##### aggregation on tb + where + fill + limit offset +sql select max(c1) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, -1, -2) limit 10 offset 1 +if $rows != 10 then + return -1 +endi +if $data00 != @18-09-17 09:05:00.000@ then + return -1 +endi +if $data01 != -1 then + return -1 +endi +if $data11 != 1 then + return -1 +endi +if $data90 != @18-09-17 09:50:00.000@ then + return -1 +endi +if $data91 != 5 then + return -1 +endi + +$tb5 = $tbPrefix . 5 +sql select max(c1), min(c2) from $tb5 where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, -1, -2, -3, -4) limit 10 offset 1 +if $rows != 10 then + return -1 +endi +if $data00 != @18-09-17 09:05:00.000@ then + return -1 +endi +if $data01 != -1 then + return -1 +endi +if $data02 != -2 then + return -1 +endi +if $data11 != 1 then + return -1 +endi +if $data12 != -2 then + return -1 +endi +if $data90 != @18-09-17 09:50:00.000@ then + return -1 +endi +if $data91 != 5 then + return -1 +endi +if $data92 != -2 then + return -1 +endi + +### [TBASE-350] +## tb + interval + fill(value) + limit offset +$tb = $tbPrefix . 0 +$limit = $rowNum +$offset = $limit / 2 +sql select max(c1), min(c2), sum(c3), avg(c4), stddev(c5), spread(c6), first(c7), last(c8), first(c9) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, -1, -2) limit $limit offset $offset +if $rows != $limit then + print expect $limit, actual $rows + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != -1 then + return -1 +endi + +sql select max(c1) from lm2_tb0 where ts >= 1537146000000 and ts <= 1543145400000 interval(5m) fill(value, -1000, -2) limit 8200 +if $rows != 8200 then + return -1 +endi + +sql select max(c1) from lm2_tb0 where ts >= 1537146000000 and ts <= 1543145400000 interval(5m) fill(value, -1000) limit 100000; + + +sql select max(c1) from lm2_tb0 where ts >= 1537146000000 and ts <= 1543145400000 interval(5m) fill(value, -1000, -2) limit 10 offset 8190; +if $rows != 10 then + return -1 +endi + +if $data00 != @18-10-15 19:30:00.000@ then + return -1 +endi + +if $data01 != 5 then + return -1 +endi + +if $data10 != @18-10-15 19:35:00.000@ then + return -1 +endi + +if $data11 != -1000 then + return -1 +endi + +if $data20 != @18-10-15 19:40:00.000@ then + return -1 +endi + +if $data21 != 6 then + return -1 +endi + +if $data30 != @18-10-15 19:45:00.000@ then + return -1 +endi + +if $data31 != -1000 then + return -1 +endi + +sql select max(c1) from lm2_tb0 where ts >= 1537146000000 and ts <= 1543145400000 interval(5m) fill(value, -1000, -2) limit 10 offset 10001; +if $rows != 10 then + return -1 +endi + +if $data00 != @18-10-22 02:25:00.000@ then + return -1 +endi + +if $data01 != -1000 then + return -1 +endi + +if $data10 != @18-10-22 02:30:00.000@ then + return -1 +endi + +if $data11 != 1 then + return -1 +endi + +if $data20 != @18-10-22 02:35:00.000@ then + return -1 +endi + +if $data21 != -1000 then + return -1 +endi + +if $data30 != @18-10-22 02:40:00.000@ then + return -1 +endi + +if $data31 != 2 then + return -1 +endi + +sql select max(c1) from lm2_tb0 where ts >= 1537146000000 and ts <= 1543145400000 interval(5m) fill(value, -1000, -2) limit 10000 offset 10001; +print ====> needs to validate the last row result +if $rows != 9998 then + return -1 +endi + + +sql select max(c1) from lm2_tb0 where ts >= 1537146000000 and ts <= 1543145400000 interval(5m) fill(value, -1000, -2) limit 100 offset 20001; +if $rows != 0 then + return -1 +endi + +# tb + interval + fill(linear) + limit offset +$limit = $rowNum +$offset = $limit / 2 +sql select max(c1), min(c2), sum(c3), avg(c4), stddev(c5), spread(c6), first(c7), last(c8), first(c9) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(linear) limit $limit offset $offset +if $rows != $limit then + print expect $limit, actual $rows + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != 0 then + return -1 +endi +if $data13 != 0.500000000 then + return -1 +endi +if $data35 != 0.000000000 then + return -1 +endi +if $data46 != 0.000000000 then + return -1 +endi +if $data47 != 1 then + return -1 +endi +if $data57 != NULL then + return -1 +endi +if $data68 != binary3 then + return -1 +endi +if $data79 != NULL then + return -1 +endi + +## tb + interval + fill(prev) + limit offset +$limit = $rowNum +$offset = $limit / 2 +sql select max(c1), min(c2), sum(c3), avg(c4), stddev(c5), spread(c6), first(c7), last(c8), first(c9) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(prev) limit $limit offset $offset +if $rows != $limit then + print expect $limit, actual: $rows + return -1 +endi + + +$limit = $rowNum +$offset = $limit / 2 +$offset = $offset + 10 +sql select max(c1), min(c2), sum(c3), avg(c4), stddev(c5), spread(c6), first(c7), last(c8), first(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 = 5 interval(5m) fill(value, -1, -2) limit $limit offset $offset +if $rows != $limit then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data02 != 5 then + return -1 +endi +if $data03 != 5.000000000 then + return -1 +endi +if $data04 != 5.000000000 then + return -1 +endi +if $data05 != 0.000000000 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data08 != binary5 then + return -1 +endi +if $data09 != nchar5 then + return -1 +endi +if $data18 != NULL then + return -1 +endi +if $data19 != NULL then + return -1 +endi +if $data16 != -2.000000000 then + return -1 +endi +if $data17 != 1 then + return -1 +endi +if $data11 != -1 then + return -1 +endi + +$limit = $rowNum +$offset = $limit * 2 +$offset = $offset - 11 +sql select max(c1), min(c2), sum(c3), avg(c4), stddev(c5), spread(c6), first(c7), last(c8), first(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 = 5 interval(5m) fill(value, -1, -2) limit $limit offset $offset +if $rows != 10 then + return -1 +endi +if $data01 != -1 then + return -1 +endi +if $data02 != -2 then + return -1 +endi +if $data11 != 5 then + return -1 +endi +if $data12 != 5 then + return -1 +endi +if $data13 != 5.000000000 then + return -1 +endi +if $data15 != 0.000000000 then + return -1 +endi +if $data16 != 0.000000000 then + return -1 +endi +if $data18 != binary5 then + return -1 +endi +if $data19 != nchar5 then + return -1 +endi +if $data27 != 1 then + return -1 +endi +if $data38 != NULL then + return -1 +endi +if $data49 != NULL then + return -1 +endi + +### [TBASE-350] +## stb + interval + fill + group by + limit offset +sql select max(c1), min(c2), sum(c3), avg(c4), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, -1, -2) group by t1 limit 2 offset 10 +if $rows != 20 then + return -1 +endi + +$limit = 5 +$offset = $rowNum * 2 +$offset = $offset - 2 +sql select max(c1), min(c2), sum(c3), avg(c4), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, -1, -2) group by t1 order by t1 limit $limit offset $offset +if $rows != $tbNum then + return -1 +endi +if $data00 != @18-11-25 19:30:00.000@ then + return -1 +endi +if $data01 != 9 then + return -1 +endi +if $data12 != 9 then + return -1 +endi +if $data23 != 9.000000000 then + return -1 +endi +if $data34 != 9.000000000 then + return -1 +endi +if $data45 != 1 then + return -1 +endi +if $data56 != binary9 then + return -1 +endi +if $data68 != 6 then + return -1 +endi +if $data72 != -2 then + return -1 +endi +if $data84 != -2.000000000 then + return -1 +endi +if $data98 != 9 then + return -1 +endi + +#add one more test case +sql select max(c1), last(c8) from lm2_db0.lm2_tb0 where ts >= 1537146000000 and ts <= 1543145400000 interval(5m) fill(linear) limit 10 offset 4089;" + diff --git a/tests/script/general/parser/limit2_tblocks100.sim b/tests/script/general/parser/limit2_tblocks100.sim new file mode 100644 index 0000000000000000000000000000000000000000..11f7a15eb06a3de4bc5ab2eda6acade17abe5000 --- /dev/null +++ b/tests/script/general/parser/limit2_tblocks100.sim @@ -0,0 +1,76 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c rowsInFileBlock -v 255 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = lm2_db +$tbPrefix = lm2_tb +$stbPrefix = lm2_stb +$tbNum = 10 +$rowNum = 10000 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +$tsu = $rowNum * $delta +$tsu = $tsu - $delta +$tsu = $tsu + $ts0 + +print ========== limit2.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db tblocks 100 +print ====== create tables +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int, t2 nchar(20), t3 binary(20), t4 bigint, t5 smallint, t6 double) + +$i = 0 +$ts = $ts0 +$halfNum = $tbNum / 2 +while $i < $halfNum + $i1 = $i + $halfNum + $tb = $tbPrefix . $i + $tb1 = $tbPrefix . $i1 + $tgstr = 'tb . $i + $tgstr = $tgstr . ' + $tgstr1 = 'tb . $i1 + $tgstr1 = $tgstr1 . ' + sql create table $tb using $stb tags( $i , $tgstr , $tgstr , $i , $i , $i ) + sql create table $tb1 using $stb tags( $i1 , $tgstr1 , $tgstr1 , $i , $i , $i ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) + sql insert into $tb1 values ( $ts , $c , NULL , $c , NULL , $c , $c , true, $binary , $nchar ) + $x = $x + 1 + endw + + $i = $i + 1 +endw +print ====== tables created + +#run general/parser/limit2_query.sim + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 100 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed + +run general/parser/limit2_query.sim diff --git a/tests/script/general/parser/limit_stb.sim b/tests/script/general/parser/limit_stb.sim new file mode 100644 index 0000000000000000000000000000000000000000..ec7c0e0f138e677c7da95c20af4bd13908aa1a0c --- /dev/null +++ b/tests/script/general/parser/limit_stb.sim @@ -0,0 +1,1252 @@ +sleep 100 +sql connect + +$dbPrefix = lm_db +$tbPrefix = lm_tb +$stbPrefix = lm_stb +$tbNum = 10 +$rowNum = 10 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== limit_stb.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +print ====== use db +sql use $db + +$tsu = $rowNum * $delta +$tsu = $tsu - $delta +$tsu = $tsu + $ts0 +$tsu = $tsu + 9 + +##### select from supertable + +# illegal operations +#sql_error select top(c1, 1) from $stb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +#sql_error select bottom(c1, 1) from $stb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 + +### select from stb + limit offset +sql select * from $stb limit 5 +if $rows != 5 then + return -1 +endi +sql select * from $stb limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data41 != 5 then + return -1 +endi + +sql select * from $stb order by ts desc limit 5 +if $rows != 5 then + return -1 +endi + +sql select * from $stb order by ts desc limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data01 != 9 then + return -1 +endi +if $data11 != 9 then + return -1 +endi +if $data41 != 9 then + return -1 +endi + +sql select * from $stb order by ts asc limit 5 +print select * from $stb order by ts asc limit 5 +print $data00 $data01 +print $data10 $data11 +print $data20 $data21 + +if $rows != 5 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi + +if $data40 != @18-09-17 09:00:00.004@ then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +print data12 = $data12 +if $data12 != 0 then + return -1 +endi + +if $data24 != 0.000000000 then + return -1 +endi + +if $data35 != 0 then + return -1 +endi +if $data49 != nchar0 then + return -1 +endi + +sql select * from $stb order by ts asc limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data41 != 0 then + return -1 +endi + +if $data40 != @18-09-17 09:00:00.005@ then + return -1 +endi + +if $data00 != @18-09-17 09:00:00.001@ then + return -1 +endi + +sql select * from $stb limit 500 offset 1 +if $rows != 99 then + return -1 +endi + +$offset = $tbNum * $rowNum +$offset = $offset - 1 +sql select * from $stb limit 2 offset $offset +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 10:30:00.009@ then + return -1 +endi +if $data01 != 9 then + return -1 +endi +if $data02 != NULL then + return -1 +endi +if $data03 != 9.00000 then + return -1 +endi +if $data04 != NULL then + return -1 +endi +if $data05 != 9 then + return -1 +endi +if $data06 != 9 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data08 != binary9 then + return -1 +endi +if $data09 != nchar9 then + return -1 +endi + +$offset = $tbNum * $rowNum +$offset = $offset / 2 +$offset = $offset - 1 +sql select * from $stb limit 2 offset $offset +if $rows != 2 then + return -1 +endi +if $data00 != @18-09-17 10:30:00.002@ then + return -1 +endi +if $data01 != 9 then + return -1 +endi +if $data02 != 9 then + return -1 +endi +if $data03 != 9.00000 then + return -1 +endi +if $data04 != 9.000000000 then + return -1 +endi +if $data05 != 9 then + return -1 +endi +if $data06 != 9 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data08 != binary9 then + return -1 +endi +if $data09 != nchar9 then + return -1 +endi +#if $data10 != @18-09-17 09:00:00.000@ then +# return -1 +#endi +#if $data11 != 0 then +# return -1 +#endi +#if $data12 != NULL then +# return -1 +#endi +#if $data13 != 0.00000 then +# return -1 +#endi +#if $data14 != NULL then +# return -1 +#endi +#if $data15 != 0 then +# return -1 +#endi +#if $data16 != 0 then +# return -1 +#endi +#if $data17 != 1 then +# return -1 +#endi +#if $data18 != binary0 then +# return -1 +#endi +#if $data19 != nchar0 then +# return -1 +#endi + +$offset = $rowNum * $tbNum +sql select * from lm_stb0 limit 2 offset $offset +if $rows != 0 then + return -1 +endi + +sql select ts, c1, c2, c3, c4, c5, c6, c7, c8, c9 from $stb limit 1 offset 0; +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + return -1 +endi + +sql select ts, c1, c2, c3, c4, c5, c6, c7, c8, c9 from $stb limit 1 offset 1; +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select ts, c1, c2, c3, c4, c5, c6, c7, c8, c9 from $stb limit 1 offset 4; +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:40:00.000@ then + return -1 +endi +if $data01 != 4 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data03 != 4.00000 then + return -1 +endi +if $data04 != 4.000000000 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 4 then + return -1 +endi +if $data08 != binary4 then + return -1 +endi +if $data09 != nchar4 then + return -1 +endi + +### select from supertable + where + limit offset +sql select * from $stb where ts > '2018-09-17 09:30:00.000' and ts < '2018-09-17 10:30:00.000' order by ts asc limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data01 != 3 then + return -1 +endi +if $data11 != 3 then + return -1 +endi +if $data21 != 3 then + return -1 +endi +if $data31 != 3 then + return -1 +endi +if $data41 != 3 then + return -1 +endi + +sql select * from $stb where ts > '2018-09-17 09:30:00.000' and ts < '2018-09-17 10:10:00.000' order by ts asc limit 5 offset 50 +if $rows != 0 then + return -1 +endi + +sql select * from $stb where ts > '2018-09-17 09:30:00.000' and ts < '2018-09-17 10:30:00.000' order by ts asc limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data01 != 3 then + return -1 +endi +if $data11 != 3 then + return -1 +endi +if $data21 != 3 then + return -1 +endi +if $data31 != 3 then + return -1 +endi +if $data41 != 3 then + return -1 +endi + +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from lm_stb0 where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-09-17 10:30:00.009' order by ts asc limit 1 offset 0; +if $rows != 1 then + return -1 +endi +if $data00 != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != 4.500000000 then + return -1 +endi +$val = 45 * $rowNum +if $data03 != $val then + return -1 +endi +if $data04 != 9.000000000 then + return -1 +endi +if $data05 != 1 then + return -1 +endi +if $data06 != binary9 then + return -1 +endi +if $data07 != nchar0 then + return -1 +endi + +#sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from lm_stb0 where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-09-17 10:30:00.000' and c1 > 1 and c2 < 9 and c3 > 2 and c4 < 8 and c5 > 3 and c6 < 7 and c7 > 0 and c8 like '%5' and t1 > 3 and t1 < 6 limit 1 offset 0; +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from lm_stb0 where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-09-17 10:30:00.000' and c1 > 1 and c2 < 9 and c3 > 2 and c4 < 8 and c5 > 3 and c6 < 7 and c7 = 'true' and c8 like '%5' and t1 > 3 and t1 < 6 limit 1 offset 0; +if $rows != 1 then + return -1 +endi +if $data00 != 5 then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data02 != 5.000000000 then + return -1 +endi +$val = 5 * $rowNum +$val = $val / 10 +if $data03 != $val then + return -1 +endi +if $data04 != 0.000000000 then + return -1 +endi +if $data05 != 1 then + return -1 +endi +if $data06 != binary5 then + return -1 +endi +if $data07 != nchar5 then + return -1 +endi + +sql select c1, tbname, t1 from lm_stb0 where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-09-17 10:30:00.000' and c1 > 1 and c2 < 9 and c3 > 2 and c4 < 8 and c5 > 3 and c6 < 7 and c7 = 'true' and c8 like '%5' and t1 > 3 and t1 < 6; + +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 3 and t1 < 6 limit 10 offset 10 +if $rows != 0 then + return -1 +endi + +## TBASE-345 +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 group by t1 order by t1 asc limit 5 offset 1 +if $rows != 0 then + return -1 +endi + +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 group by t1 order by t1 asc limit 5 offset 0 +if $rows != 6 then + return -1 +endi +if $data00 != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != 4.500000000 then + return -1 +endi +if $data08 != 2 then + return -1 +endi +if $data18 != 3 then + return -1 +endi +if $data28 != 4 then + return -1 +endi +if $data31 != NULL then + return -1 +endi +if $data47 != nchar0 then + return -1 +endi +if $data58 != 7 then + return -1 +endi + +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 group by t1 order by t1 desc limit 5 offset 1 +if $rows != 0 then + return -1 +endi + +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 group by t1 order by t1 desc limit 5 offset 0 +if $rows != 6 then + return -1 +endi +if $data00 != 9 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data02 != 4.500000000 then + return -1 +endi +if $data32 != 4.500000000 then + return -1 +endi +if $data31 != 0 then + return -1 +endi +if $data47 != nchar0 then + return -1 +endi +if $data08 != 7 then + return -1 +endi +if $data18 != 6 then + return -1 +endi +if $data24 != 9.000000000 then + return -1 +endi +if $data53 != 45 then + return -1 +endi +if $data58 != 2 then + return -1 +endi + +### supertable aggregation + where + interval + limit offset +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 interval(5m) limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data00 != @18-09-17 09:10:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data40 != @18-09-17 09:50:00.000@ then + return -1 +endi +if $data41 != 5 then + return -1 +endi +$offset = $rowNum / 2 +$offset = $offset + 1 +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 interval(5m) limit $offset offset $offset +$val = $rowNum - $offset +if $rows != $val then + return -1 +endi +if $data00 != @18-09-17 10:00:00.000@ then + return -1 +endi +if $data01 != 6 then + return -1 +endi +if $data30 != @18-09-17 10:30:00.000@ then + return -1 +endi +if $data31 != 9 then + return -1 +endi + +### supertable aggregation + where + interval + group by order by tag + limit offset +## TBASE-345 +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 5 and c1 > 0 and c2 < 9 and c3 > 1 and c4 < 7 and c5 > 4 interval(5m) group by t1 order by t1 desc limit 3 offset 0 +if $rows != 6 then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data09 != 4 then + return -1 +endi +if $data11 != 6 then + return -1 +endi +if $data19 != 4 then + return -1 +endi +if $data22 != 5 then + return -1 +endi +if $data29 != 3 then + return -1 +endi +if $data33 != 6.000000000 then + return -1 +endi +if $data39 != 3 then + return -1 +endi +if $data44 != 5 then + return -1 +endi +if $data49 != 2 then + return -1 +endi +if $data58 != nchar6 then + return -1 +endi +if $data59 != 2 then + return -1 +endi + +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 5 and c1 > 0 and c2 < 9 and c3 > 1 and c4 < 7 and c5 > 4 interval(5m) group by t1 order by t1 desc limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data01 != 6 then + return -1 +endi +if $data09 != 4 then + return -1 +endi +if $data13 != 6.000000000 then + return -1 +endi +if $data19 != 3 then + return -1 +endi +if $data28 != nchar6 then + return -1 +endi +if $data29 != 2 then + return -1 +endi + +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 5 and c1 > 0 and c2 < 9 and c3 > 1 and c4 < 7 and c5 > 4 interval(5m) group by t1 order by t1 desc limit 1 offset 0 +if $rows != 3 then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data09 != 4 then + return -1 +endi +if $data13 != 5.000000000 then + return -1 +endi +if $data19 != 3 then + return -1 +endi +if $data28 != nchar5 then + return -1 +endi +if $data29 != 2 then + return -1 +endi + +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 and c1 > 0 and c2 < 9 and c3 > 4 and c4 < 7 and c5 > 4 interval(5m) group by t1 order by t1 desc limit 3 offset 0 +if $rows != 6 then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data09 != 4 then + return -1 +endi +if $data19 != 4 then + return -1 +endi +if $data23 != 5.000000000 then + return -1 +endi +if $data29 != 3 then + return -1 +endi +if $data39 != 3 then + return -1 +endi +if $data48 != nchar5 then + return -1 +endi +if $data49 != 2 then + return -1 +endi +if $data59 != 2 then + return -1 +endi + +sql select max(c1), min(c1), avg(c1), count(c1), sum(c1), spread(c1), first(c1), last(c1) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 interval(5m) group by t1 order by t1 desc limit 1 offset 0 +if $rows != 6 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data09 != 7 then + return -1 +endi +print $data13 +if $data13 != 0.000000000 then + return -1 +endi +if $data19 != 6 then + return -1 +endi +if $data24 != 1 then + return -1 +endi +if $data29 != 5 then + return -1 +endi +if $data31 != 0 then + return -1 +endi +if $data32 != 0 then + return -1 +endi +if $data33 != 0.000000000 then + return -1 +endi +if $data34 != 1 then + return -1 +endi +if $data35 != 0 then + return -1 +endi + +print $data36 +if $data36 != 0.000000000 then + return -1 +endi +if $data37 != 0 then + return -1 +endi +if $data38 != 0 then + return -1 +endi +if $data39 != 4 then + return -1 +endi +if $data49 != 3 then + return -1 +endi +if $data59 != 2 then + return -1 +endi + +#sql select max(c2), min(c2), avg(c2), count(c2), sum(c2), spread(c2), first(c2), last(c2) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 3 and t1 < 6 interval(5m) group by t1 order by t1 desc limit 3 offset 1 +#if $rows != 3 then +# return -1 +#endi +#if $data00 != @18-09-17 09:20:00.000@ then +# return -1 +#endi +#if $data01 != 2 then +# return -1 +#endi +#if $data02 != 2 then +# return -1 +#endi +#if $data09 != 4 then +# return -1 +#endi +#if $data13 != 3.000000000 then +# return -1 +#endi +#if $data19 != 4 then +# return -1 +#endi +#if $data20 != @18-09-17 09:40:00.000@ then +# return -1 +#endi +#if $data24 != 1 then +# return -1 +#endi +#if $data25 != 4 then +# return -1 +#endi +#if $data26 != 0.000000000 then +# return -1 +#endi +#if $data27 != 4 then +# return -1 +#endi +#if $data28 != 4 then +# return -1 +#endi +#if $data29 != 4 then +# return -1 +#endi + +sql select max(c2), min(c2), avg(c2), count(c2), spread(c2), first(c2), last(c2), count(ts) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 3 and t1 < 6 interval(5m) group by t1 order by t1 desc limit 3 offset 1 +if $rows != 6 then + return -1 +endi +if $data00 != @18-09-17 09:10:00.000@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data02 != NULL then + return -1 +endi +if $data09 != 5 then + return -1 +endi +if $data13 != NULL then + return -1 +endi +if $data19 != 5 then + return -1 +endi +if $data20 != @18-09-17 09:30:00.000@ then + return -1 +endi +if $data24 != 0 then + return -1 +endi +if $data25 != NULL then + return -1 +endi +if $data26 != NULL then + return -1 +endi +if $data27 != NULL then + return -1 +endi +if $data28 != 1 then + return -1 +endi +if $data29 != 5 then + return -1 +endi +if $data30 != @18-09-17 09:10:00.000@ then + return -1 +endi +if $data31 != 1 then + return -1 +endi +if $data32 != 1 then + return -1 +endi +if $data33 != 1.000000000 then + return -1 +endi +if $data34 != 1 then + return -1 +endi +if $data35 != 0.000000000 then + return -1 +endi +if $data36 != 1 then + return -1 +endi +if $data37 != 1 then + return -1 +endi +if $data38 != 1 then + return -1 +endi +if $data39 != 4 then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data49 != 4 then + return -1 +endi +if $data51 != 3 then + return -1 +endi +if $data59 != 4 then + return -1 +endi + +sql select top(c1, 1) from $stb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi + +sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts desc limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data01 != 9 then + return -1 +endi + +sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts asc limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data01 != 9 then + return -1 +endi + +sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 order by t1 desc slimit 2 soffset 1 limit 3 offset 1 +if $rows != 6 then + return -1 +endi +if $data00 != @18-09-17 10:00:00.008@ then + return -1 +endi +if $data01 != 6 then + return -1 +endi +if $data02 != 8 then + return -1 +endi +if $data10 != @18-09-17 10:10:00.008@ then + return -1 +endi +if $data11 != 7 then + return -1 +endi +if $data12 != 8 then + return -1 +endi +if $data20 != @18-09-17 10:20:00.008@ then + return -1 +endi +if $data21 != 8 then + return -1 +endi +if $data22 != 8 then + return -1 +endi +if $data30 != @18-09-17 10:00:00.007@ then + return -1 +endi +if $data31 != 6 then + return -1 +endi +if $data32 != 7 then + return -1 +endi +if $data40 != @18-09-17 10:10:00.007@ then + return -1 +endi +if $data41 != 7 then + return -1 +endi +if $data42 != 7 then + return -1 +endi +if $data50 != @18-09-17 10:20:00.007@ then + return -1 +endi +if $data51 != 8 then + return -1 +endi +if $data52 != 7 then + return -1 +endi + +sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 order by t1 asc slimit 2 soffset 1 limit 3 offset 1 +if $rows != 6 then + return -1 +endi +if $data00 != @18-09-17 10:00:00.001@ then + return -1 +endi +if $data01 != 6 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data10 != @18-09-17 10:10:00.001@ then + return -1 +endi +if $data11 != 7 then + return -1 +endi +if $data12 != 1 then + return -1 +endi +if $data20 != @18-09-17 10:20:00.001@ then + return -1 +endi +if $data21 != 8 then + return -1 +endi +if $data22 != 1 then + return -1 +endi +if $data30 != @18-09-17 10:00:00.002@ then + return -1 +endi +if $data31 != 6 then + return -1 +endi +if $data32 != 2 then + return -1 +endi +if $data40 != @18-09-17 10:10:00.002@ then + return -1 +endi +if $data41 != 7 then + return -1 +endi +if $data42 != 2 then + return -1 +endi +if $data50 != @18-09-17 10:20:00.002@ then + return -1 +endi +if $data51 != 8 then + return -1 +endi +if $data52 != 2 then + return -1 +endi + +sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 order by ts desc slimit 2 soffset 1 limit 3 offset 1 +if $rows != 6 then + return -1 +endi +if $data00 != @18-09-17 10:20:00.001@ then + return -1 +endi +if $data01 != 8 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data10 != @18-09-17 10:10:00.001@ then + return -1 +endi +if $data11 != 7 then + return -1 +endi +if $data12 != 1 then + return -1 +endi +if $data20 != @18-09-17 10:00:00.001@ then + return -1 +endi +if $data21 != 6 then + return -1 +endi +if $data22 != 1 then + return -1 +endi +if $data30 != @18-09-17 10:20:00.002@ then + return -1 +endi +if $data31 != 8 then + return -1 +endi +if $data32 != 2 then + return -1 +endi +if $data40 != @18-09-17 10:10:00.002@ then + return -1 +endi +if $data41 != 7 then + return -1 +endi +if $data42 != 2 then + return -1 +endi +if $data50 != @18-09-17 10:00:00.002@ then + return -1 +endi +if $data51 != 6 then + return -1 +endi +if $data52 != 2 then + return -1 +endi + +sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts asc limit 3 offset 5 +if $rows != 0 then + return -1 +endi +sql_error select top(c1, 101) from $stb where ts >= $ts0 and ts <= $tsu order by ts asc limit 3 offset 98 + +sql select bottom(c1, 1) from $stb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi + +sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts desc limit 3 offset 1 +if $rows != 3 then + return -1 +endi +#if $data00 != @18-09-17 09:00:00.000@ then +# return -1 +#endi +if $data01 != 0 then + return -1 +endi + +sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts asc limit 3 offset 1 +if $rows != 3 then + return -1 +endi +#if $data00 != @18-09-17 09:00:00.000@ then +# return -1 +#endi +if $data01 != 0 then + return -1 +endi + +sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 order by t1 desc,ts desc slimit 2 soffset 1 limit 3 offset 1 +if $rows != 6 then + return -1 +endi +#if $data00 != @18-09-17 09:30:00.000@ then +# return -1 +#endi +if $data01 != 3 then + return -1 +endi +if $data02 != 8 then + return -1 +endi +#if $data10 != @18-09-17 09:20:00.000@ then +# return -1 +#endi +if $data11 != 2 then + return -1 +endi +if $data12 != 8 then + return -1 +endi +#if $data20 != @18-09-17 09:10:00.000@ then +# return -1 +#endi +if $data21 != 1 then + return -1 +endi +if $data22 != 8 then + return -1 +endi +#if $data30 != @18-09-17 09:30:00.000@ then +# return -1 +#endi +if $data31 != 3 then + return -1 +endi +if $data32 != 7 then + return -1 +endi +#if $data40 != @18-09-17 09:20:00.000@ then +# return -1 +#endi +if $data41 != 2 then + return -1 +endi +if $data42 != 7 then + return -1 +endi +#if $data50 != @18-09-17 09:10:00.000@ then +# return -1 +#endi +if $data51 != 1 then + return -1 +endi +if $data52 != 7 then + return -1 +endi + +sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 order by t1 asc,ts desc slimit 2 soffset 1 limit 3 offset 1 +if $rows != 6 then + return -1 +endi +#if $data00 != @18-09-17 09:30:00.000@ then +# return -1 +#endi +if $data01 != 3 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +#if $data10 != @18-09-17 09:20:00.000@ then +# return -1 +#endi +if $data11 != 2 then + return -1 +endi +if $data12 != 1 then + return -1 +endi +#if $data20 != @18-09-17 09:10:00.000@ then +# return -1 +#endi +if $data21 != 1 then + return -1 +endi +if $data22 != 1 then + return -1 +endi +#if $data30 != @18-09-17 09:30:00.000@ then +# return -1 +#endi +if $data31 != 3 then + return -1 +endi +if $data32 != 2 then + return -1 +endi +#if $data40 != @18-09-17 09:20:00.000@ then +# return -1 +#endi +if $data41 != 2 then + return -1 +endi +if $data42 != 2 then + return -1 +endi +#if $data50 != @18-09-17 09:10:00.000@ then +# return -1 +#endi +if $data51 != 1 then + return -1 +endi +if $data52 != 2 then + return -1 +endi + +sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 order by ts desc slimit 2 soffset 1 limit 3 offset 1 +if $rows != 6 then + return -1 +endi +#if $data00 != @18-09-17 09:30:00.000@ then +# return -1 +#endi +if $data01 != 3 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +#if $data10 != @18-09-17 09:20:00.000@ then +# return -1 +#endi +if $data11 != 2 then + return -1 +endi +if $data12 != 1 then + return -1 +endi +#if $data20 != @18-09-17 09:10:00.000@ then +# return -1 +#endi +if $data21 != 1 then + return -1 +endi +if $data22 != 1 then + return -1 +endi +#if $data30 != @18-09-17 09:30:00.000@ then +# return -1 +#endi +if $data31 != 3 then + return -1 +endi +if $data32 != 2 then + return -1 +endi +#if $data40 != @18-09-17 09:20:00.000@ then +# return -1 +#endi +if $data41 != 2 then + return -1 +endi +if $data42 != 2 then + return -1 +endi +#if $data50 != @18-09-17 09:10:00.000@ then +# return -1 +#endi +if $data51 != 1 then + return -1 +endi +if $data52 != 2 then + return -1 +endi + +sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts asc limit 3 offset 5 +if $rows != 0 then + return -1 +endi +sql_error select bottom(c1, 101) from $stb where ts >= $ts0 and ts <= $tsu order by ts asc limit 3 offset 98 + +sql select bottom(c1, 1) from $stb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi +sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu limit 3 offset 5 +if $rows != 0 then + return -1 +endi diff --git a/tests/script/general/parser/limit_tb.sim b/tests/script/general/parser/limit_tb.sim new file mode 100644 index 0000000000000000000000000000000000000000..4a93797d40fb65a7df9ad8d18c60292bed83dfe4 --- /dev/null +++ b/tests/script/general/parser/limit_tb.sim @@ -0,0 +1,1136 @@ +sleep 100 +sql connect + +$dbPrefix = lm_db +$tbPrefix = lm_tb +$stbPrefix = lm_stb +$tbNum = 10 +$rowNum = 10 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== limit_tb.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +print ====== use db +sql use $db + +##### select from table +print ====== select from table with limit offset +$tb = $tbPrefix . 0 +sql select * from $tb order by ts desc limit 5 +if $rows != 5 then + return -1 +endi +if $data01 != 9 then + return -1 +endi +if $data41 != 5 then + return -1 +endi + +sql select * from $tb order by ts desc limit 5 offset 5 +if $rows != 5 then + return -1 +endi +if $data01 != 4 then + return -1 +endi +if $data41 != 0 then + return -1 +endi + +$offset = $rowNum - 1 +sql select * from $tb order by ts desc limit 5 offset $offset +if $rows != 1 then + return -1 +endi + +sql select ts, c1, c2, c3, c4, c5, c6, c7, c8, c9 from $tb order by ts desc limit 5 offset 5 +if $rows != 5 then + return -1 +endi +if $data01 != 4 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data03 != 4.00000 then + return -1 +endi +if $data04 != 4.000000000 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 4 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data08 != binary4 then + return -1 +endi +if $data09 != nchar4 then + return -1 +endi + +sql select ts, c1, c2, c3, c4, c5, c6, c7, c8, c9 from $tb order by ts desc limit 5 offset $offset +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 0.00000 then + return -1 +endi +if $data04 != 0.000000000 then + return -1 +endi +if $data05 != 0 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data08 != binary0 then + return -1 +endi +if $data09 != nchar0 then + return -1 +endi + + +## TBASE-329 +sql select * from $tb where c1 < 9 order by ts desc limit 1 offset 1 +if $rows != 1 then + return -1 +endi +if $data01 != 7 then + return -1 +endi + +sql select * from $tb where c1 < 9 order by ts desc limit 2 offset 1 +if $rows != 2 then + return -1 +endi +if $data01 != 7 then + return -1 +endi +if $data11 != 6 then + return -1 +endi + +sql select * from $tb where c1 < 9 order by ts desc limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data01 != 7 then + return -1 +endi +if $data11 != 6 then + return -1 +endi +if $data21 != 5 then + return -1 +endi + +sql select * from $tb where c1 < 0 order by ts desc limit 3 offset 1 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where c1 > 0 order by ts desc limit 1 offset 1 +if $rows != 1 then + return -1 +endi +if $data01 != 8 then + return -1 +endi + +sql select * from $tb where c1 > 0 order by ts desc limit 2 offset 1 +if $rows != 2 then + return -1 +endi +if $data01 != 8 then + return -1 +endi +if $data11 != 7 then + return -1 +endi + + +sql_error select * from $tb limit +sql_error select * from $tb offset +sql_error select * from $tb offset 1 +sql_error select * from $tb offset 1 limit 5 +sql_error select * from $tb offset 1 limit -1 + +#### aggregation function + limit offset +$tsu = $rowNum * $delta +$tsu = $tsu - $delta +$tsu = $tsu + $ts0 + +### aggregation function + limit offset (non-interval case) +sql select max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 +if $rows != 1 then + return -1 +endi +sql select max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 0 +if $rows != 0 then + return -1 +endi +sql select max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu and c1 < 9 and c2 < 8 and c3 >0 and c4 <= 7 and c5 <7 limit 5 offset 0 +if $rows != 1 then + return -1 +endi + +sql select max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi + +sql select min(c1), min(c2), min(c3), min(c4), min(c5), min(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 +if $rows != 1 then + return -1 +endi +sql select min(c1), min(c2), min(c3), min(c4), min(c5), min(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 0 offset 0 +if $rows != 0 then + return -1 +endi +sql select min(c1), min(c2), min(c3), min(c4), min(c5), min(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi + +sql select sum(c1), avg(c2), stddev(c3), max(c4), min(c5), count(c6), first(c7), last(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu limit 5 +if $rows != 1 then + return -1 +endi +$val = 45 * $rowNum +$val = $val / 10 +print $data05 +print $rowNum +#print $val +if $data00 != $val then + return -1 +endi +if $data01 != 4.500000000 then + return -1 +endi +if $data02 != 2.872281323 then + return -1 +endi +if $data03 != 9.000000000 then + return -1 +endi +if $data04 != 0 then + return -1 +endi +if $data05 != $rowNum then + return -1 +endi +if $data06 != 1 then + return -1 +endi +if $data07 != binary9 then + return -1 +endi +if $data08 != nchar9 then + return -1 +endi + +sql select sum(c1), avg(c2), stddev(c3), max(c4), min(c5), count(c6), first(c7), last(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu limit 0 +if $rows != 0 then + return -1 +endi +sql select sum(c1), avg(c2), stddev(c3), max(c4), min(c5), count(c6), first(c7), last(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1>1 and c2<9 and c3>2 and c4<8 and c5>4 and c6<6 limit 1 offset 0 +if $rows != 1 then + return -1 +endi +if $data00 != 5 then + return -1 +endi +if $data01 != 5.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 5.000000000 then + return -1 +endi +if $data04 != 5 then + return -1 +endi +if $data05 != 1 then + return -1 +endi +if $data06 != 1 then + return -1 +endi +if $data07 != binary5 then + return -1 +endi +if $data08 != nchar5 then + return -1 +endi + +sql select sum(c1), avg(c2), stddev(c3), max(c4), min(c5), count(c6), first(c7), last(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu limit 3 offset 1 +if $rows != 0 then + return -1 +endi + +sql select spread(ts), spread(c1), spread(c2), spread(c3), spread(c4), spread(c5), spread(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 0 +if $rows != 1 then + return -1 +endi +if $data00 != 5400000.000000000 then + return -1 +endi +if $data01 != 9.000000000 then + return -1 +endi +if $data02 != 9.000000000 then + return -1 +endi +if $data03 != 9.000000000 then + return -1 +endi +if $data04 != 9.000000000 then + return -1 +endi +if $data05 != 9.000000000 then + return -1 +endi +if $data06 != 9.000000000 then + return -1 +endi +sql select spread(ts), spread(c1), spread(c2), spread(c3), spread(c4), spread(c5), spread(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi + +sql select twa(c1), twa(c2), twa(c3), twa(c4), twa(c5), twa(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 0 +if $rows != 1 then + return -1 +endi +if $data00 != 4.500000000 then + return -1 +endi +if $data01 != 4.500000000 then + return -1 +endi +if $data02 != 4.500000000 then + return -1 +endi +if $data03 != 4.500000000 then + return -1 +endi +if $data04 != 4.500000000 then + return -1 +endi +if $data05 != 4.500000000 then + return -1 +endi + +sql select twa(c1), twa(c2), twa(c3), twa(c4), twa(c5), twa(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi + +sql select top(c1, 1) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi + +print ========> TD-6017 +sql select * from (select ts, top(c1, 5) from $tb where ts >= $ts0 and ts <= $tsu order by ts desc limit 3 offset 1) + +sql select top(c1, 5) from $tb where ts >= $ts0 and ts <= $tsu order by ts desc limit 3 offset 1 +print select top(c1, 5) from $tb where ts >= $ts0 and ts <= $tsu order by ts desc limit 3 offset 1 +print $data00 $data01 +print $data10 $data11 +print $data20 $data21 + +if $rows != 3 then + return -1 +endi +if $data00 != @18-09-17 10:20:00.000@ then + return -1 +endi +if $data01 != 8 then + return -1 +endi +if $data10 != @18-09-17 10:10:00.000@ then + return -1 +endi +if $data11 != 7 then + return -1 +endi +if $data20 != @18-09-17 10:00:00.000@ then + return -1 +endi +if $data21 != 6 then + return -1 +endi + +sql select top(c1, 5) from $tb where ts >= $ts0 and ts <= $tsu order by ts asc limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data00 != @18-09-17 10:00:00.000@ then + return -1 +endi +if $data01 != 6 then + return -1 +endi +if $data10 != @18-09-17 10:10:00.000@ then + return -1 +endi +if $data11 != 7 then + return -1 +endi +if $data20 != @18-09-17 10:20:00.000@ then + return -1 +endi +if $data21 != 8 then + return -1 +endi +sql select top(c1, 5) from $tb where ts >= $ts0 and ts <= $tsu order by ts asc limit 3 offset 5 +if $rows != 0 then + return -1 +endi +sql_error select top(c1, 101) from $tb where ts >= $ts0 and ts <= $tsu order by ts asc limit 3 offset 98 + +sql select bottom(c1, 1) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi +sql select bottom(c1, 5) from $tb where ts >= $ts0 and ts <= $tsu limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data00 != @18-09-17 09:10:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != @18-09-17 09:20:00.000@ then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data20 != @18-09-17 09:30:00.000@ then + return -1 +endi +if $data21 != 3 then + return -1 +endi +sql select bottom(c1, 5) from $tb where ts >= $ts0 and ts <= $tsu limit 3 offset 5 +if $rows != 0 then + return -1 +endi + +sql select diff(c1) from $tb where c1 > 5 limit 2 offset 1 +if $rows != 2 then + return -1 +endi +if $data00 != @18-09-17 10:20:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != @18-09-17 10:30:00.000@ then + return -1 +endi +if $data11 != 1 then + return -1 +endi + +### aggregation + limit offset (with interval) +sql select max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) limit 5 +if $rows != 5 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != 1 then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data31 != 3 then + return -1 +endi +if $data41 != 4 then + return -1 +endi +sql select max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 1.00000 then + return -1 +endi +if $data04 != 1.000000000 then + return -1 +endi +if $data05 != 1 then + return -1 +endi +if $data06 != 1 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data21 != 3 then + return -1 +endi +if $data31 != 4 then + return -1 +endi +if $data41 != 5 then + return -1 +endi + +## TBASE-334 +sql select max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 2 offset 1 +if $rows != 2 then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data04 != 5.000000000 then + return -1 +endi +if $data11 != 8 then + return -1 +endi +if $data14 != 8.000000000 then + return -1 +endi +if $data21 != null then + print expect null, actual: $data21 + return -1 +endi + +sql select min(c1), min(c2), min(c3), min(c4), min(c5), min(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data01 != 3 then + return -1 +endi +if $data11 != 6 then + return -1 +endi +if $data21 != 9 then + return -1 +endi +if $data31 != null then + return -1 +endi + +sql select sum(c1), sum(c2), sum(c3), sum(c4), sum(c5), sum(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 5 +if $rows != 4 then + return -1 +endi +if $data01 != 3 then + return -1 +endi +if $data11 != 12 then + return -1 +endi +if $data21 != 21 then + return -1 +endi +if $data31 != 9 then + return -1 +endi +if $data41 != null then + return -1 +endi +sql select sum(c1), sum(c2), sum(c3), sum(c4), sum(c5), sum(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 5 offset 1 +if $rows != 3 then + return -1 +endi +if $data01 != 12 then + return -1 +endi +if $data11 != 21 then + return -1 +endi +if $data21 != 9 then + return -1 +endi +if $data31 != null then + return -1 +endi + +sql select avg(c1), avg(c2), avg(c3), avg(c4), avg(c5), avg(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 0 +if $rows != 3 then + return -1 +endi +if $data01 != 1.000000000 then + return -1 +endi +if $data11 != 4.000000000 then + return -1 +endi +if $data21 != 7.000000000 then + return -1 +endi +if $data31 != null then + return -1 +endi +sql select avg(c1), avg(c2), avg(c3), avg(c4), avg(c5), avg(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data01 != 4.000000000 then + return -1 +endi +if $data11 != 7.000000000 then + return -1 +endi +if $data21 != 9.000000000 then + return -1 +endi +if $data31 != null then + return -1 +endi + + +sql select stddev(c1), stddev(c2), stddev(c3), stddev(c4), stddev(c5), stddev(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi +sql select stddev(c1), stddev(c2), stddev(c3), stddev(c4), stddev(c5), stddev(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) limit 0 +if $rows != 0 then + return -1 +endi +sql select stddev(c1), stddev(c2), stddev(c3), stddev(c4), stddev(c5), stddev(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 5 offset 1 +if $rows != 3 then + return -1 +endi +if $data00 != @18-09-17 09:30:00.000@ then + return -1 +endi +if $data01 != 0.816496581 then + return -1 +endi +if $data10 != @18-09-17 10:00:00.000@ then + return -1 +endi +if $data20 != @18-09-17 10:30:00.000@ then + return -1 +endi +if $data21 != 0.000000000 then + return -1 +endi + +sql select count(c1), count(c2), count(c3), count(c4), count(c5), count(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(27m) +if $rows != 4 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data21 != 3 then + return -1 +endi +if $data31 != 3 then + return -1 +endi +sql select count(c1), count(c2), count(c3), count(c4), count(c5), count(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(27m) limit 5 offset 1 +if $rows != 3 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data11 != 3 then + return -1 +endi +if $data21 != 3 then + return -1 +endi + +sql select twa(c1), twa(c2), twa(c3), twa(c4), twa(c5), twa(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 3 offset 1 +if $rows != 0 then + return -1 +endi + +sql select twa(c1), twa(c2), twa(c3), twa(c4), twa(c5), twa(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 3 offset 0 +if $rows != 1 then + return -1 +endi +if $data00 != 4.500000000 then + return -1 +endi +if $data02 != 4.500000000 then + return -1 +endi +if $data05 != 4.500000000 then + return -1 +endi + +sql select first(c1), first(c2), first(c3), first(c4), first(c5), first(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi +sql select first(c1), first(c2), first(c3), first(c4), first(c5), first(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data01 != 3 then + return -1 +endi +if $data12 != 6 then + return -1 +endi +if $data23 != 9.00000 then + return -1 +endi + + +sql select last(c1), last(c2), last(c3), last(c4), last(c5), last(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi +sql select last(c1), last(c2), last(c3), last(c4), last(c5), last(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data12 != 8 then + return -1 +endi +if $data23 != 9.00000 then + return -1 +endi + +sql select first(ts), first(c1), last(c2), first(c3), last(c4), first(c5), last(c6), first(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 > 0 interval(30m) limit 3 offset 0 +if $rows != 3 then + return -1 +endi +if $data01 != @18-09-17 09:10:00.000@ then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data12 != 3 then + return -1 +endi +if $data13 != 5 then + return -1 +endi +if $data14 != 3.00000 then + return -1 +endi +if $data22 != 6 then + return -1 +endi +if $data23 != 8 then + return -1 +endi +if $data28 != binary6 then + return -1 +endi +if $data29 != nchar8 then + return -1 +endi + +sql select first(ts), first(c1), last(c2), first(c3), last(c4), first(c5), last(c6), first(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 > 0 interval(30m) limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data01 != @18-09-17 09:30:00.000@ then + return -1 +endi +if $data02 != 3 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 3.00000 then + return -1 +endi +if $data05 != 5.000000000 then + return -1 +endi +if $data08 != binary3 then + return -1 +endi +if $data09 != nchar5 then + return -1 +endi +if $data12 != 6 then + return -1 +endi +if $data13 != 8 then + return -1 +endi +if $data14 != 6.00000 then + return -1 +endi +if $data15 != 8.000000000 then + return -1 +endi +if $data22 != 9 then + return -1 +endi +if $data23 != 9 then + return -1 +endi +if $data24 != 9.00000 then + return -1 +endi +if $data25 != 9.000000000 then + return -1 +endi +if $data26 != 9 then + return -1 +endi +if $data27 != 9 then + return -1 +endi +if $data28 != binary9 then + return -1 +endi +if $data29 != nchar9 then + return -1 +endi + +### order by ts + limit offset + +sql select * from $tb order by ts asc limit 5 +if $rows != 5 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data10 != @18-09-17 09:10:00.000@ then + return -1 +endi +if $data12 != 1 then + return -1 +endi +if $data20 != @18-09-17 09:20:00.000@ then + return -1 +endi +if $data23 != 2.00000 then + return -1 +endi +if $data34 != 3.000000000 then + return -1 +endi +if $data45 != 4 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data17 != 1 then + return -1 +endi +if $data28 != binary2 then + return -1 +endi +if $data39 != nchar3 then + return -1 +endi +if $data40 != @18-09-17 09:40:00.000@ then + return -1 +endi + +sql select * from $tb order by ts asc limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data00 != @18-09-17 09:10:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != @18-09-17 09:20:00.000@ then + return -1 +endi +if $data12 != 2 then + return -1 +endi +if $data20 != @18-09-17 09:30:00.000@ then + return -1 +endi +if $data23 != 3.00000 then + return -1 +endi +if $data34 != 4.000000000 then + return -1 +endi +if $data45 != 5 then + return -1 +endi +if $data06 != 1 then + return -1 +endi +if $data17 != 1 then + return -1 +endi +if $data28 != binary3 then + return -1 +endi +if $data39 != nchar4 then + return -1 +endi +if $data40 != @18-09-17 09:50:00.000@ then + return -1 +endi + +sql select * from $tb order by ts asc limit 5 offset 8 +if $rows != 2 then + return -1 +endi +if $data00 != @18-09-17 10:20:00.000@ then + return -1 +endi +if $data01 != 8 then + return -1 +endi +if $data10 != @18-09-17 10:30:00.000@ then + return -1 +endi +if $data12 != 9 then + return -1 +endi + +sql select * from $tb where c1 > 1 order by ts asc limit 3 offset 2 +if $rows != 3 then + return -1 +endi +if $data00 != @18-09-17 09:40:00.000@ then + return -1 +endi +if $data01 != 4 then + return -1 +endi +if $data10 != @18-09-17 09:50:00.000@ then + return -1 +endi +if $data20 != @18-09-17 10:00:00.000@ then + return -1 +endi +if $data12 != 5 then + return -1 +endi +if $data23 != 6.00000 then + return -1 +endi + +sql select * from $tb where c1 < 3 and c1 > 1 order by ts asc limit 3 offset 2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where c1 < 5 and c1 > 1 order by ts asc limit 3 offset 2 +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:40:00.000@ then + return -1 +endi +if $data01 != 4 then + return -1 +endi +if $data04 != 4.000000000 then + return -1 +endi + +sql select * from $tb order by ts desc limit 5 +if $rows != 5 then + return -1 +endi +if $data00 != @18-09-17 10:30:00.000@ then + return -1 +endi +if $data01 != 9 then + return -1 +endi +if $data10 != @18-09-17 10:20:00.000@ then + return -1 +endi +if $data12 != 8 then + return -1 +endi +if $data20 != @18-09-17 10:10:00.000@ then + return -1 +endi +if $data23 != 7.00000 then + return -1 +endi +if $data34 != 6.000000000 then + return -1 +endi +if $data45 != 5 then + return -1 +endi +if $data06 != 9 then + return -1 +endi +if $data17 != 1 then + return -1 +endi +if $data28 != binary7 then + return -1 +endi +if $data39 != nchar6 then + return -1 +endi +if $data40 != @18-09-17 09:50:00.000@ then + return -1 +endi + +sql select * from $tb order by ts desc limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data00 != @18-09-17 10:20:00.000@ then + return -1 +endi +if $data01 != 8 then + return -1 +endi +if $data10 != @18-09-17 10:10:00.000@ then + return -1 +endi +if $data12 != 7 then + return -1 +endi +if $data20 != @18-09-17 10:00:00.000@ then + return -1 +endi +if $data23 != 6.00000 then + return -1 +endi +if $data34 != 5.000000000 then + return -1 +endi +if $data45 != 4 then + return -1 +endi +if $data06 != 8 then + return -1 +endi +if $data17 != 1 then + return -1 +endi +if $data28 != binary6 then + return -1 +endi +if $data39 != nchar5 then + return -1 +endi +if $data40 != @18-09-17 09:40:00.000@ then + return -1 +endi + +sql select * from $tb order by ts desc limit 5 offset 8 +if $rows != 2 then + return -1 +endi +if $data00 != @18-09-17 09:10:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data12 != 0 then + return -1 +endi + +sql select * from $tb where c1 < 8 order by ts desc limit 3 offset 2 +if $rows != 3 then + return -1 +endi +if $data00 != @18-09-17 09:50:00.000@ then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data10 != @18-09-17 09:40:00.000@ then + return -1 +endi +if $data20 != @18-09-17 09:30:00.000@ then + return -1 +endi +if $data12 != 4 then + return -1 +endi +if $data23 != 3.00000 then + return -1 +endi + +sql select * from $tb where c1 < 8 and c1 > 6 order by ts desc limit 3 offset 2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where c1 < 8 and c1 > 4 order by ts desc limit 3 offset 2 +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:50:00.000@ then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data04 != 5.000000000 then + return -1 +endi + diff --git a/tests/script/general/parser/line_insert.sim b/tests/script/general/parser/line_insert.sim new file mode 100644 index 0000000000000000000000000000000000000000..85f2714ad3100766557797d2158d9d3e181b0f0b --- /dev/null +++ b/tests/script/general/parser/line_insert.sim @@ -0,0 +1,53 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print =============== step1 +$db = testlp +$mte = ste +$mt = st +sql drop database $db -x step1 +step1: +sql create database $db precision 'us' +sql use $db +sql create stable $mte (ts timestamp, f int) TAGS(t1 bigint) + +line_insert st,t1=3i64,t2=4f64,t3="t3" c1=3i64,c3=L"passit",c2=false,c4=4f64 1626006833639000000ns +line_insert st,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin",c2=true,c4=5f64,c5=5f64 1626006833640000000ns +line_insert ste,t2=5f64,t3=L"ste" c1=true,c2=4i64,c3="iam" 1626056811823316532ns +line_insert stf,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000ns +sql select * from st +if $rows != 2 then + return -1 +endi + +if $data00 != @21-07-11 20:33:53.639000@ then + return -1 +endi + +if $data02 != @passit@ then + return -1 +endi + +sql select * from stf +if $rows != 1 then + return -1 +endi + +sql select * from ste +if $rows != 1 then + return -1 +endi + +#print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/mixed_blocks.sim b/tests/script/general/parser/mixed_blocks.sim new file mode 100644 index 0000000000000000000000000000000000000000..c20cf9a915e49d014e29ce4bb817802f22346f9e --- /dev/null +++ b/tests/script/general/parser/mixed_blocks.sim @@ -0,0 +1,163 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sleep 100 +sql connect + +$dbPrefix = mb_db +$tbPrefix = mb_tb +$stbPrefix = mb_stb +$tbNum = 10 +$ts0 = 1537146000000 +$delta = 1000 +print ========== mixed_blocks.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database if exists $db +$paramRows = 200 +$rowNum = $paramRows * 4 +$rowNum = $rowNum / 5 +sql create database $db maxrows $paramRows +print ====== create tables +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 bool, c6 binary(10), c7 nchar(10)) tags(t1 int) + +$i = 0 +$ts = $ts0 +$tb1 = $tbPrefix . 1 +$tb2 = $tbPrefix . 2 +sql create table $tb1 using $stb tags( 1 ) +sql create table $tb2 using $stb tags( 2 ) + +$tb1 = $tbPrefix . 1 +$tb2 = $tbPrefix . 2 +$x = 0 +print rowNum = $rowNum +while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + $c = 0 - $x + sql insert into $tb1 values ( $ts , $x , $x , $x , $x , true, $binary , $nchar ) + sql insert into $tb2 values ( $ts , $c , $c , $c , $c , true, $binary , $nchar ) + $x = $x + 1 +endw +print ====== tables created +sql show databases + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 500 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed + +$rowNum = $rowNum * 2 +while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + $c = 0 - $x + sql insert into $tb1 values ( $ts , $x , $x , $x , $x , true, $binary , $nchar ) + sql insert into $tb2 values ( $ts , $c , $c , $c , $c , true, $binary , $nchar ) + $x = $x + 1 +endw + +#### query a STable and using where clause to filter out all the data from tb2 and make the query only return first/last of tb1 +sql select first(ts,c1), last(ts,c1), spread(c1) from $stb where c1 > 0 group by t1 +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:01.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != @18-09-17 09:05:19.000@ then + return -1 +endi +if $data03 != 319 then + return -1 +endi +if $data04 != 318.000000000 then + return -1 +endi +if $data05 != 1 then + return -1 +endi + +sql select max(c1), min(c1), sum(c1), avg(c1), count(c1) from $stb where c1 > 0 group by t1 +if $rows != 1 then + return -1 +endi +if $data00 != 319 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 51040 then + return -1 +endi +if $data03 != 160.000000000 then + return -1 +endi +if $data04 != 319 then + return -1 +endi +if $data05 != 1 then + return -1 +endi + +sql select first(ts,c1), last(ts,c1) from $tb1 where c1 > 0 +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:01.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != @18-09-17 09:05:19.000@ then + return -1 +endi +if $data03 != 319 then + return -1 +endi + +print ===================> TD-2488 +sql create table m1(ts timestamp, k int) tags(a int); +sql create table t1 using m1 tags(1); +sql create table t2 using m1 tags(2); +sql insert into t1 values('2020-1-1 1:1:1', 1); +sql insert into t1 values('2020-1-1 1:10:1', 2); +sql insert into t2 values('2020-1-1 1:5:1', 99); + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 500 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed +sql select ts from m1 where ts='2020-1-1 1:5:1' +if $rows != 1 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/parser/nchar.sim b/tests/script/general/parser/nchar.sim new file mode 100644 index 0000000000000000000000000000000000000000..84719efcab9a18e6f554cdfb84942adf1de5add9 --- /dev/null +++ b/tests/script/general/parser/nchar.sim @@ -0,0 +1,314 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 100 +sql connect + +print ======================== dnode1 start + +$dbPrefix = nchar_db +$tbPrefix = nchar_tb +$mtPrefix = nchar_stb +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 +$col = NCHAR + +print =============== set up +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create database $db +sql use $db + +# case1: create_metric_with_nchar_data +print ========== nchar.sim case1: create_table_with_nchar_data test + +# unspecified nchar length +sql_error create table $mt (ts timestamp, col nchar) +sql_error create table $mt (ts timestamp, col int) tags (tg nchar) +# nchar as column or tag names +sql_error create table $mt (ts timestamp, nchar int) +sql_error create table $mt (ts timestamp, col int) tags (nchar int) +sql create table $mt (ts timestamp, col nchar(60)) tags (tg nchar(60)) +sql show stables +if $rows != 1 then + return -1 +endi +if $data00 != $mt then + return -1 +endi +sql describe $mt +if $rows != 3 then + return -1 +endi +if $data11 != NCHAR then + return -1 +endi +sql create table $tb using $mt tags ('tag1') +sql describe $tb +if $data11 != NCHAR then + return -1 +endi +if $data21 != NCHAR then + return -1 +endi +sql drop table $tb +sql drop table $mt +print create_metric_with_nchar_data test passed + +# case2 : insert_nchar_data +#print ========== nchar.sim case2: insert_nchar_data +sql create table $mt (ts timestamp, col nchar(10)) tags(tg nchar(10)) +sql create table $tb using $mt tags ('tag1') +sql describe $mt +#print expected: NCHAR +#print returned: $data11 +if $data11 != NCHAR then + return -1 +endi + +# insert nchar data with a pair of single quotes +$col = 'NCHAR' +$col_ = NCHAR +sql insert into $tb values (now+1s, $col ) +sql select * from $tb order by ts desc +print expected: $col_ +print returned: $data01 +if $data01 != $col_ then + return -1 +endi + +# insert nchar data with a pair of double quotes +$col = "NCHAR" +$col_ = NCHAR +sql insert into $tb values (now+2s, $col ) +sql select * from $tb order by ts desc +print expected: $col_ +print returned: $data01 +if $data01 != $col_ then + return -1 +endi + +# insert nchar data without quotes +$col = NCHAR +$col_ = nchar +sql_error insert into $tb values (now+3s, $col ) +sql select * from $tb order by ts desc +#print expected: $col_ +#print returned: $data01 +#if $data01 != $col_ then +# return -1 +#endi + +# insert nchar data with space and no quotes +sql_error insert into $tb values (now+4s, n char ) + +# insert nchar data with space and a pair of single quotes +sql insert into $tb values (now+5s, 'NCHAR' ) +sql select * from $tb order by ts desc +print expected: NCHAR +print returned: $data01 +$quote = ' +$ret1 = $quote . $data01 +$ret2 = $ret1 . $quote +print $ret2 + +if $ret2 != 'NCHAR' then + return -1 +endi + +label1: + +# insert nchar data with space and a pair of double quotes +sql insert into $tb values (now+6s, "NCHAR" ) +sql select * from $tb order by ts desc +print expected: N CHAR +print returned: $data01 +$quote = " +$ret1 = $quote . $data01 +$ret2 = $ret1 . $quote +print $ret2 +if $ret2 = "NCHAR" then + goto label2 +else + return -1 +endi +label2: + +sql insert into $tb values (now+7s, "涛思" ) +sql select * from $tb order by ts desc +print expected: 涛思 +print returned: $data01 +if $data01 != 涛思 then + return -1 +endi + +# insert nchar data with a single quote and a double quote +#sql insert into $tb values (now+8s, 'NCHAR") +sql_error insert into $tb values (now+9s, 'NCHAR") +sql_error insert into $tb values (now+10s, 'NCHAR]) + +sql drop table $tb +sql drop table $mt +sql reset query cache +# create multiple metrics and tables and insert nchar type data +sql create table $mt (ts timestamp, tbcol nchar(10), tbcol1 int) TAGS(tgcol nchar(10)) +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '0' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , '0', $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '1' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , '1', $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +# case5: query_with_tag_filtering +print ========== nchar.sim case5: query test +# simple query with nchar tag filtering +sql select * from $mt where tgcol = '1' -x step1 + goto step2 +step1: +print reset query cache +sql reset query cache +sql select * from $mt where tgcol = '1' +step2: +if $rows != 100 then + print expect 100, actual: $rows + return -1 +endi + +#sql select * from $mt where tgcol > '0' +##print rows = $rows +#if $rows != 100 then +# return -1 +#endi +##print $data03 +#if $data03 != 1 then +# return -1 +#endi + +# cumulative query with nchar tag filtering +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tgcol = '1' +if $rows != 1 then + return -1 +endi +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 group by tgcol +if $rows != 2 then + return -1 +endi +sql select count(tbcol) from $mt where tbcol1 = 1 group by tgcol +if $rows != 2 then + return -1 +endi +print data00 = $data00 +if $data00 != 5 then + print expect 5, actual: $data00 + return -1 +endi +if $data10 != 5 then + return -1 +endi +sql_error select avg(tbcol) from $mt where tbcol1 = 1 group by tgcol +sql_error select sum(tbcol) from $mt where tbcol1 = 1 group by tgcol +sql_error select min(tbcol) from $mt where tbcol1 = 1 group by tgcol +sql_error select max(tbcol) from $mt where tbcol1 = 1 group by tgcol +sql select first(tbcol) from $mt where tbcol1 = 1 group by tgcol +if $rows != 2 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data11 != 1 then + return -1 +endi +sql select last(tbcol) from $mt where tbcol1 = 1 group by tgcol +if $rows != 2 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data11 != 1 then + return -1 +endi + +sql create table stbb (ts timestamp, c1 nchar(5)) tags (t1 int) +sql create table tbb1 using stbb tags(1) +sql insert into tbb1 values ('2018-09-17 09:00:00', '涛思') +sql insert into tbb1 values ('2018-09-17 09:00:01', 'insrt') +sql select * from tbb1 order by ts asc +if $rows != 2 then + return -1 +endi +print data11 = $data11 +if $data11 != insrt then + return -1 +endi + +sql select * from stbb +if $rows != 2 then + return -1 +endi +if $data11 != insrt then + return -1 +endi + +# nchar data column currently does not support filtering, 2018/09/27 +# sql select * from $mt where tbcol = '0' +# if $rows != 100 then +# return -1 +# endi +# +# sql select * from $mt where ts > now + 4m and tbcol = '1' +# if $rows != 75 then +# return -1 +# endi +# +# sql_error select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = '1' group by tgcol +# +# sql_error select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = '1' group by tgcol +# +# sql_error select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = '1' interval(1d) group by tgcol +# +# case: query_with_wildcard +# print =============== clear +# sql drop database $db +# sql show databases +# if $rows != 0 then +# return -1 +# endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/parser/nestquery.sim b/tests/script/general/parser/nestquery.sim new file mode 100644 index 0000000000000000000000000000000000000000..5bbdace4da0cb65b4573e2f9cd93b53ac28f6c2f --- /dev/null +++ b/tests/script/general/parser/nestquery.sim @@ -0,0 +1,903 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 100 +sql connect + +print ======================== dnode1 start + +$dbPrefix = nest_db +$tbPrefix = nest_tb +$mtPrefix = nest_mt +$tbNum = 10 +$rowNum = 10000 +$totalNum = $tbNum * $rowNum + +print =============== nestquery.sim +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database if exists $db +sql create database if not exists $db + +sql use $db +sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int) + +$half = $tbNum / 2 + +$i = 0 +while $i < $half + $tb = $tbPrefix . $i + + $nextSuffix = $i + $half + $tb1 = $tbPrefix . $nextSuffix + + sql create table $tb using $mt tags( $i ) + sql create table $tb1 using $mt tags( $nextSuffix ) + + $x = 0 + while $x < $rowNum + $y = $x * 60000 + $ms = 1600099200000 + $y + $c = $x / 100 + $c = $c * 100 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + sql insert into $tb values ($ms , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar ) $tb1 values ($ms , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +$i = 1 +$tb = $tbPrefix . $i + +print ==============> simple nest query test +sql select count(*) from (select count(*) from nest_mt0) +if $rows != 1 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + +sql select count(*) from (select count(*) from nest_mt0 group by tbname) +if $rows != 1 then + return -1 +endi + +if $data00 != 10 then + return -1 +endi + +sql select count(*) from (select count(*) from nest_mt0 interval(10h) group by tbname) +if $rows != 1 then + return -1 +endi + +if $data00 != 170 then + return -1 +endi + +sql select sum(a) from (select count(*) a from nest_mt0 interval(10h) group by tbname) +if $rows != 1 then + return -1 +endi + +if $data00 != 100000 then + return -1 +endi + +print =================> alias name test +sql select ts from (select count(*) a from nest_tb0 interval(1h)) +if $rows != 167 then + return -1 +endi + +if $data00 != @20-09-15 00:00:00.000@ then + return -1 +endi + +sql select count(a) from (select count(*) a from nest_tb0 interval(1h)) +if $rows != 1 then + return -1 +endi + +if $data00 != 167 then + return -1 +endi + +print ================>master query + filter +sql select t.* from (select count(*) a from nest_tb0 interval(10h)) t where t.a <= 520; +if $rows != 2 then + return -1 +endi + +sql select * from (select count(*) a, tbname f1 from nest_mt0 group by tbname) t where t.a<0 and f1 = 'nest_tb0'; +if $rows != 0 then + return -1 +endi + +sql select * from (select count(*) a, tbname f1 from nest_mt0 group by tbname) t where t.a>0 and f1 = 'nest_tb0'; +if $rows != 1 then + return -1 +endi + +if $data00 != 10000 then + return -1 +endi + +if $data01 != @nest_tb0@ then + return -1 +endi + +if $data02 != @nest_tb0@ then + return -1 +endi + +print ===================> nest query interval +sql_error select ts, avg(c1) from (select ts, c1 from nest_tb0); + +sql select avg(c1) from (select * from nest_tb0) interval(3d) +if $rows != 3 then + return -1 +endi + +if $data00 != @20-09-14 00:00:00.000@ then + return -1 +endi + +if $data01 != 49.222222222 then + return -1 +endi + +if $data10 != @20-09-17 00:00:00.000@ then + print expect 20-09-17 00:00:00.000, actual: $data10 + return -1 +endi + +if $data11 != 49.685185185 then + return -1 +endi + +if $data20 != @20-09-20 00:00:00.000@ then + return -1 +endi + +if $data21 != 49.500000000 then + return -1 +endi + +sql_error select stddev(c1) from (select c1 from nest_tb0); +sql_error select percentile(c1, 20) from (select * from nest_tb0); +sql_error select interp(c1) from (select * from nest_tb0); +sql_error select derivative(val, 1s, 0) from (select c1 val from nest_tb0); +sql_error select twa(c1) from (select c1 from nest_tb0); +sql_error select irate(c1) from (select c1 from nest_tb0); +sql_error select diff(c1), twa(c1) from (select * from nest_tb0); +sql_error select irate(c1), interp(c1), twa(c1) from (select * from nest_tb0); + +sql select apercentile(c1, 50) from (select * from nest_tb0) interval(1d) +if $rows != 7 then + return -1 +endi + +if $data00 != @20-09-15 00:00:00.000@ then + return -1 +endi + +if $data01 != 47.571428571 then + return -1 +endi + +if $data10 != @20-09-16 00:00:00.000@ then + return -1 +endi + +if $data11 != 49.666666667 then + return -1 +endi + +if $data20 != @20-09-17 00:00:00.000@ then + return -1 +endi + +if $data21 != 49.000000000 then + return -1 +endi + +if $data30 != @20-09-18 00:00:00.000@ then + return -1 +endi + +if $data31 != 48.333333333 then + return -1 +endi + +sql select twa(c1) from (select * from nest_tb0); +if $rows != 1 then + return -1 +endi + +if $data00 != 49.500000000 then + return -1 +endi + +sql select leastsquares(c1, 1, 1) from (select * from nest_tb0); +if $rows != 1 then + return -1 +endi + +if $data00 != @{slop:0.000100, intercept:49.000000}@ then + return -1 +endi + +sql select irate(c1) from (select * from nest_tb0); +if $data00 != 0.016666667 then + return -1 +endi + +sql select derivative(c1, 1s, 0) from (select * from nest_tb0); +if $rows != 9999 then + return -1 +endi + +if $data00 != @20-09-15 00:01:00.000@ then + return -1 +endi + +if $data01 != 0.016666667 then + return -1 +endi + +if $data10 != @20-09-15 00:02:00.000@ then + return -1 +endi + +if $data11 != 0.016666667 then + return -1 +endi + +sql select diff(c1) from (select * from nest_tb0); +if $rows != 9999 then + return -1 +endi + +sql select avg(c1),sum(c2), max(c3), min(c4), count(*), first(c7), last(c7),spread(c6) from (select * from nest_tb0) interval(1d); +if $rows != 7 then + return -1 +endi + +if $data00 != @20-09-15 00:00:00.000@ then + return -1 +endi + +if $data01 != 48.666666667 then + print expect 48.666666667, actual: $data01 + return -1 +endi + +if $data02 != 70080.000000000 then + return -1 +endi + +if $data03 != 99 then + return -1 +endi + +if $data04 != 0 then + return -1 +endi + +if $data05 != 1440 then + return -1 +endi + +if $data06 != 0 then + print $data06 + return -1 +endi + +if $data07 != 1 then + return -1 +endi + +if $data08 != 99.000000000 then + print expect 99.000000000, actual: $data08 + return -1 +endi + +if $data10 != @20-09-16 00:00:00.000@ then + return -1 +endi + +if $data11 != 49.777777778 then + return -1 +endi + +if $data12 != 71680.000000000 then + return -1 +endi + +sql select top(x, 20) from (select ts,c1 x from nest_tb0); + +sql select bottom(x, 20) from (select ts,c1 x from nest_tb0) + +print ===================> group by + having + + + +print =========================> ascending order/descending order + + + + +print =========================> nest query join +sql select a.ts,a.k,b.ts from (select count(*) k from nest_tb0 interval(30a)) a, (select count(*) f from nest_tb1 interval(30a)) b where a.ts = b.ts ; +if $rows != 10000 then + return -1 +endi + +if $data00 != @20-09-15 00:00:00.000@ then + return -1 +endi + +if $data01 != 1 then + return -1 +endi + +if $data02 != @20-09-15 00:00:00.000@ then + return -1 +endi + +if $data10 != @20-09-15 00:01:00.000@ then + return -1 +endi + +if $data11 != 1 then + return -1 +endi + +if $data12 != @20-09-15 00:01:00.000@ then + return -1 +endi + +sql select sum(a.k), sum(b.f) from (select count(*) k from nest_tb0 interval(30a)) a, (select count(*) f from nest_tb1 interval(30a)) b where a.ts = b.ts ; +if $rows != 1 then + return -1 +endi + +if $data00 != 10000 then + return -1 +endi + +if $data01 != 10000 then + return -1 +endi + +sql select a.ts,a.k,b.ts,c.ts,c.ts,c.x from (select count(*) k from nest_tb0 interval(30a)) a, (select count(*) f from nest_tb1 interval(30a)) b, (select count(*) x from nest_tb2 interval(30a)) c where a.ts = b.ts and a.ts = c.ts +if $rows != 10000 then + return -1 +endi + +if $data00 != @20-09-15 00:00:00.000@ then + return -1 +endi + +if $data01 != 1 then + return -1 +endi + +if $data02 != @20-09-15 00:00:00.000@ then + return -1 +endi + +if $data03 != @20-09-15 00:00:00.000@ then + return -1 +endi + +sql_error select diff(val) from (select c1 val from nest_tb0); + +sql select diff(val) from (select ts,c1 val from nest_tb0); +if $rows != 9999 then + return -1 +endi + +if $data00 != @20-09-15 00:01:00.000@ then + return -1 +endi + +if $data01 != 1 then + return -1 +endi + +sql_error select last_row(*) from (select * from nest_tb0) having c1 > 0 + +print ===========>td-4805 +sql_error select tbname, i from (select * from nest_tb0) group by i; + +sql select count(*),c1 from (select * from nest_tb0) where c1 < 2 group by c1; +if $rows != 2 then + return -1 +endi + +if $data00 != 100 then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +if $data10 != 100 then + return -1 +endi + +if $data11 != 1 then + return -1 +endi + +print =====================>TD-5157 +sql select twa(c1) from nest_tb1 interval(19a); +if $rows != 10000 then + return -1 +endi + +if $data00 != @20-09-14 23:59:59.992@ then + return -1 +endi + +if $data01 != 0.000083333 then + return -1 +endi + +print ======================>TD-5271 +sql select min(val),max(val),first(val),last(val),count(val),sum(val),avg(val) from (select count(*) val from nest_mt0 group by tbname) +if $rows != 1 then + return -1 +endi + +if $data00 != 10000 then + return -1 +endi + +if $data01 != 10000 then + return -1 +endi + +if $data04 != 10 then + return -1 +endi + +if $data05 != 100000 then + return -1 +endi + +print =================>us database interval query, TD-5039 +sql create database test precision 'us'; +sql use test; +sql create table t1(ts timestamp, k int); +sql insert into t1 values('2020-01-01 01:01:01.000', 1) ('2020-01-01 01:02:00.000', 2); +sql select avg(k) from (select avg(k) k from t1 interval(1s)) interval(1m); +if $rows != 2 then + return -1 +endi + +if $data00 != @20-01-01 01:01:00.000000@ then + return -1 +endi + +if $data01 != 1.000000000 then + return -1 +endi + +if $data10 != @20-01-01 01:02:00.000000@ then + return -1 +endi + +if $data11 != 2.000000000 then + return -1 +endi + +sql create database test2; +sql use test2; +sql create table meters (ts TIMESTAMP,a INT,b INT) TAGS (area INT); +sql CREATE TABLE t0 USING meters TAGS (0); +sql CREATE TABLE t1 USING meters TAGS (1); +sql CREATE TABLE t2 USING meters TAGS (1); +sql CREATE TABLE t3 USING meters TAGS (0); +sql insert into t0 values ('2021-09-30 15:00:00.00',0,0); +sql insert into t0 values ('2021-09-30 15:00:01.00',1,1); +sql insert into t0 values ('2021-09-30 15:00:03.00',3,3); +sql insert into t0 values ('2021-09-30 15:00:05.00',5,5); +sql insert into t0 values ('2021-09-30 15:00:07.00',7,7); +sql insert into t0 values ('2021-09-30 15:00:09.00',9,9); + +sql insert into t1 values ('2021-09-30 15:00:00.00',0,0); +sql insert into t1 values ('2021-09-30 15:00:02.00',2,2); +sql insert into t1 values ('2021-09-30 15:00:04.00',4,4); +sql insert into t1 values ('2021-09-30 15:00:06.00',6,6); +sql insert into t1 values ('2021-09-30 15:00:08.00',8,8); +sql insert into t1 values ('2021-09-30 15:00:10.00',10,10); + +sql insert into t2 values ('2021-09-30 15:00:00.00',0,0); +sql insert into t2 values ('2021-09-30 15:00:01.00',11,11); +sql insert into t2 values ('2021-09-30 15:00:02.00',22,22); +sql insert into t2 values ('2021-09-30 15:00:03.00',33,33); +sql insert into t2 values ('2021-09-30 15:00:04.00',44,44); +sql insert into t2 values ('2021-09-30 15:00:05.00',55,55); + +sql insert into t3 values ('2021-09-30 15:00:00.00',0,0); +sql insert into t3 values ('2021-09-30 15:00:01.00',11,11); +sql insert into t3 values ('2021-09-30 15:00:02.00',22,22); +sql insert into t3 values ('2021-09-30 15:00:03.00',33,33); +sql insert into t3 values ('2021-09-30 15:00:04.00',44,44); +sql insert into t3 values ('2021-09-30 15:00:05.00',55,55); + +sql select count(*) from meters interval(1s) group by tbname; +if $rows != 24 then + return -1 +endi + +sql select count(*) from (select count(*) from meters interval(1s) group by tbname) interval(1s); +if $rows != 11 then + return -1 +endi +if $data00 != @21-09-30 15:00:00.000@ then + return -1 +endi +if $data01 != 4 then + return -1 +endi +if $data10 != @21-09-30 15:00:01.000@ then + return -1 +endi +if $data11 != 3 then + return -1 +endi +if $data20 != @21-09-30 15:00:02.000@ then + return -1 +endi +if $data21 != 3 then + return -1 +endi +if $data30 != @21-09-30 15:00:03.000@ then + return -1 +endi +if $data31 != 3 then + return -1 +endi +if $data40 != @21-09-30 15:00:04.000@ then + return -1 +endi +if $data41 != 3 then + return -1 +endi +if $data50 != @21-09-30 15:00:05.000@ then + return -1 +endi +if $data51 != 3 then + return -1 +endi +if $data60 != @21-09-30 15:00:06.000@ then + return -1 +endi +if $data61 != 1 then + return -1 +endi +if $data70 != @21-09-30 15:00:07.000@ then + return -1 +endi +if $data71 != 1 then + return -1 +endi +if $data80 != @21-09-30 15:00:08.000@ then + return -1 +endi +if $data81 != 1 then + return -1 +endi +if $data90 != @21-09-30 15:00:09.000@ then + return -1 +endi +if $data91 != 1 then + return -1 +endi + +sql select count(*) from (select count(*) from meters interval(1s) group by area) interval(1s); +if $rows != 11 then + return -1 +endi +if $data00 != @21-09-30 15:00:00.000@ then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data10 != @21-09-30 15:00:01.000@ then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data20 != @21-09-30 15:00:02.000@ then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data30 != @21-09-30 15:00:03.000@ then + return -1 +endi +if $data31 != 2 then + return -1 +endi +if $data40 != @21-09-30 15:00:04.000@ then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data50 != @21-09-30 15:00:05.000@ then + return -1 +endi +if $data51 != 2 then + return -1 +endi +if $data60 != @21-09-30 15:00:06.000@ then + return -1 +endi +if $data61 != 1 then + return -1 +endi +if $data70 != @21-09-30 15:00:07.000@ then + return -1 +endi +if $data71 != 1 then + return -1 +endi +if $data80 != @21-09-30 15:00:08.000@ then + return -1 +endi +if $data81 != 1 then + return -1 +endi +if $data90 != @21-09-30 15:00:09.000@ then + return -1 +endi +if $data91 != 1 then + return -1 +endi + + +sql select sum(sa) from (select sum(a) as sa from meters interval(1s) group by tbname) interval(1s); +if $rows != 11 then + return -1 +endi +if $data00 != @21-09-30 15:00:00.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data10 != @21-09-30 15:00:01.000@ then + return -1 +endi +if $data11 != 23 then + return -1 +endi +if $data20 != @21-09-30 15:00:02.000@ then + return -1 +endi +if $data21 != 46 then + return -1 +endi +if $data30 != @21-09-30 15:00:03.000@ then + return -1 +endi +if $data31 != 69 then + return -1 +endi +if $data40 != @21-09-30 15:00:04.000@ then + return -1 +endi +if $data41 != 92 then + return -1 +endi +if $data50 != @21-09-30 15:00:05.000@ then + return -1 +endi +if $data51 != 115 then + return -1 +endi +if $data60 != @21-09-30 15:00:06.000@ then + return -1 +endi +if $data61 != 6 then + return -1 +endi +if $data70 != @21-09-30 15:00:07.000@ then + return -1 +endi +if $data71 != 7 then + return -1 +endi +if $data80 != @21-09-30 15:00:08.000@ then + return -1 +endi +if $data81 != 8 then + return -1 +endi +if $data90 != @21-09-30 15:00:09.000@ then + return -1 +endi +if $data91 != 9 then + return -1 +endi + +sql select sum(sa) from (select sum(a) as sa from meters interval(1s) group by area) interval(1s); +if $rows != 11 then + return -1 +endi +if $data00 != @21-09-30 15:00:00.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data10 != @21-09-30 15:00:01.000@ then + return -1 +endi +if $data11 != 23 then + return -1 +endi +if $data20 != @21-09-30 15:00:02.000@ then + return -1 +endi +if $data21 != 46 then + return -1 +endi +if $data30 != @21-09-30 15:00:03.000@ then + return -1 +endi +if $data31 != 69 then + return -1 +endi +if $data40 != @21-09-30 15:00:04.000@ then + return -1 +endi +if $data41 != 92 then + return -1 +endi +if $data50 != @21-09-30 15:00:05.000@ then + return -1 +endi +if $data51 != 115 then + return -1 +endi +if $data60 != @21-09-30 15:00:06.000@ then + return -1 +endi +if $data61 != 6 then + return -1 +endi +if $data70 != @21-09-30 15:00:07.000@ then + return -1 +endi +if $data71 != 7 then + return -1 +endi +if $data80 != @21-09-30 15:00:08.000@ then + return -1 +endi +if $data81 != 8 then + return -1 +endi +if $data90 != @21-09-30 15:00:09.000@ then + return -1 +endi +if $data91 != 9 then + return -1 +endi + + + +sql select count(*) from (select count(*) from meters interval(1s)) interval(1s); +if $rows != 11 then + return -1 +endi +if $data00 != @21-09-30 15:00:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != @21-09-30 15:00:01.000@ then + return -1 +endi +if $data11 != 1 then + return -1 +endi +if $data20 != @21-09-30 15:00:02.000@ then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data30 != @21-09-30 15:00:03.000@ then + return -1 +endi +if $data31 != 1 then + return -1 +endi +if $data40 != @21-09-30 15:00:04.000@ then + return -1 +endi +if $data41 != 1 then + return -1 +endi +if $data50 != @21-09-30 15:00:05.000@ then + return -1 +endi +if $data51 != 1 then + return -1 +endi +if $data60 != @21-09-30 15:00:06.000@ then + return -1 +endi +if $data61 != 1 then + return -1 +endi +if $data70 != @21-09-30 15:00:07.000@ then + return -1 +endi +if $data71 != 1 then + return -1 +endi +if $data80 != @21-09-30 15:00:08.000@ then + return -1 +endi +if $data81 != 1 then + return -1 +endi +if $data90 != @21-09-30 15:00:09.000@ then + return -1 +endi +if $data91 != 1 then + return -1 +endi + +sql select count(*) from (select count(*) from meters interval(1s) group by tbname); +if $rows != 1 then + return -1 +endi +if $data00 != 24 then + return -1 +endi + +sql select sum(a)/sum(b) from meters where ts >= '2021-09-30 15:00:00.000' and ts <= '2021-09-30 15:00:05.000' interval(1s) fill(null) group by area order by area; +if $rows != 12 then + return -1 +endi +if $data00 != @21-09-30 15:00:00.000@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data02 != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/null_char.sim b/tests/script/general/parser/null_char.sim new file mode 100644 index 0000000000000000000000000000000000000000..cb65290d2548c4ca6e7377d18b33d5c1768e818e --- /dev/null +++ b/tests/script/general/parser/null_char.sim @@ -0,0 +1,511 @@ +#### TBASE-679 +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 100 +sql connect + +print ========== NULL_char.sim + +$db = db +sql drop database if exists $db +sql create database $db +sql use $db + +#### case 0: field NULL, or 'NULL' +sql create table mt1 (ts timestamp, col1 int, col2 bigint, col3 float, col4 double, col5 binary(8), col6 bool, col7 smallint, col8 tinyint, col9 nchar(8)) tags (tag1 binary(8), tag2 nchar(8), tag3 int, tag4 bigint, tag5 bool, tag6 float) +sql create table st1 using mt1 tags (NULL, 'NULL', 100, 1000, 'false', 9.123) +sql insert into st1 values ('2019-01-01 09:00:00.000', 123, -123, 3.0, 4.0, 'binary', true, 1000, 121, 'nchar') +sql insert into st1 values ('2019-01-01 09:00:01.000', '456', '456', '3.33', '4.444', 'binary', 'true', '1001', '122', 'nchar') +sql insert into st1 values ('2019-01-01 09:00:02.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) +sql insert into st1 values ('2019-01-01 09:00:03.000', NULL, NULL, NULL, NULL, 'NULL', 'NULL', 2002, 127, 'NULL') + +sql select * from mt1 +if $rows != 4 then + return -1 +endi +if $data21 != NULL then + return -1 +endi +if $data22 != NULL then + return -1 +endi +if $data23 != NULL then + return -1 +endi +if $data24 != NULL then + return -1 +endi +if $data25 != NULL then + return -1 +endi +if $data26 != NULL then + return -1 +endi +if $data27 != NULL then + return -1 +endi +if $data28 != NULL then + return -1 +endi +if $data29 != NULL then + return -1 +endi + +if $data31 != NULL then + return -1 +endi +if $data32 != NULL then + return -1 +endi +#if $data33 != 0.00000 then +# print === expect 0.00000, actually $data33 +# return -1 +#endi +#if $data34 != 0.000000000 then +# print === expect 0.00000, actually $data34 +# return -1 +#endi +if $data35 != NULL then + return -1 +endi +if $data36 != NULL then + return -1 +endi +if $data39 != NULL then + return -1 +endi + + +#### case 1: tag NULL, or 'NULL' +sql create table mt2 (ts timestamp, col1 int, col3 float, col5 binary(8), col6 bool, col9 nchar(8)) tags (tag1 binary(8), tag2 nchar(8), tag3 int, tag5 bool) +sql create table st2 using mt2 tags (NULL, 'NULL', 102, 'true') +sql select tag1, tag2, tag3, tag5 from st2 +if $rows != 1 then + return -1 +endi +if $data00 != NULL then + print ==1== expect: NULL, actually: $data00 + return -1 +endi +if $data01 != NULL then + print ==2== expect: NULL, actually: $data01 + return -1 +endi +if $data02 != 102 then + print ==3== expect: NULL, actually: $data02 + return -1 +endi +if $data03 != 1 then + print ==4== expect: 1, actually: $data03 + return -1 +endi + +sql select tag1 from st2 limit 20 offset 1 +if $rows != 0 then + return -1 +endi + +sql select tag1 from st2 limit 10 offset 2 +if $rows != 0 then + return -1 +endi + +sql select tag1 from st2 limit 0 offset 0 +if $rows != 0 then + return -1 +endi + +sql create table st3 using mt2 tags (NULL, 'ABC', 103, 'FALSE') +sql select tag1, tag2, tag3, tag5 from st3 +if $rows != 1 then + return -1 +endi +if $data00 != NULL then + print ==5== expect: NULL, actually: $data00 + return -1 +endi +if $data01 != ABC then + return -1 +endi +if $data02 != 103 then + return -1 +endi +if $data03 != 0 then + return -1 +endi + +### bool: +sql_error create table stx using mt2 tags ('NULL', '123aBc', 104, '123') +sql_error create table sty using mt2 tags ('NULL', '123aBc', 104, 'xtz') +sql create table st4 using mt2 tags ('NULL', '123aBc', 104, 'NULL') +sql select tag1,tag2,tag3,tag5 from st4 +if $rows != 1 then + return -1 +endi +if $data00 != NULL then + return -1 +endi +if $data01 != 123aBc then + return -1 +endi +if $data02 != 104 then + return -1 +endi +if $data03 != NULL then + print ==6== expect: NULL, actually: $data03 + return -1 +endi + +sql create table st5 using mt2 tags ('NULL', '123aBc', 105, NULL) +sql select tag1,tag2,tag3,tag5 from st5 +if $rows != 1 then + return -1 +endi +if $data00 != NULL then + return -1 +endi +if $data01 != 123aBc then + return -1 +endi +if $data02 != 105 then + return -1 +endi +if $data03 != NULL then + return -1 +endi + + + +#### case 2: dynamic create table using super table when insert into +sql create table mt3 (ts timestamp, col1 int, col3 float, col5 binary(8), col6 bool, col9 nchar(8)) tags (tag1 binary(8), tag2 nchar(8), tag3 int, tag5 bool) +sql_error insert into st31 using mt3 tags (NULL, 'NULL', 102, 'true') values (now+1s, 31, 31, 'bin_31', '123', 'nchar_31') +sql_error insert into st32 using mt3 tags (NULL, 'ABC', 103, 'FALSE') values (now+2s, 32, 32.12345, 'bin_32', 'abc', 'nchar_32') +sql_error insert into st33 using mt3 tags ('NULL', '123aBc', 104, 'NULL') values (now+3s, 33, 33, 'bin_33', 'false123', 'nchar_33') +sql_error insert into st34 using mt3 tags ('NULL', '123aBc', 105, NULL) values (now+4s, 34, 34.12345, 'bin_34', 'true123', 'nchar_34') + + +#### case 3: set tag value +sql create table mt4 (ts timestamp, c1 int) tags (tag_binary binary(16), tag_nchar nchar(16), tag_int int, tag_bool bool, tag_float float, tag_double double) +sql create table st41 using mt4 tags ("beijing", 'nchar_tag', 100, false, 9.12345, 7.123456789) +sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 +if $rows != 1 then + return -1 +endi +if $data00 != beijing then + return -1 +endi +if $data01 != nchar_tag then + return -1 +endi +if $data02 != 100 then + return -1 +endi +if $data03 != 0 then + return -1 +endi + +if $data04 != 9.12345 then + print expect 9.12345 , actual: $data04 + return -1 +endi + +if $data05 != 7.123456789 then + print expect 7.123456789 , actual: $data05 + return -1 +endi + +################# binary +sql alter table st41 set tag tag_binary = "shanghai" +sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 +if $data00 != shanghai then + return -1 +endi + +##### test 'space' case +system_content echo ' ' | sed 's/ //g' | tr -d '\n' # Construct an empty result for later result checking +sql alter table st41 set tag tag_binary = "" +sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 +if $data00 != $system_content then + print expect [ $system_content ], actual [ $data00 ] + return -1 +endi + +sql alter table st41 set tag tag_binary = "NULL" +sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 +if $data00 != NULL then + return -1 +endi + +sql alter table st41 set tag tag_binary = NULL +sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 +if $data00 != NULL then + print ==8== expect: NULL, actually: $data23 + return -1 +endi + +################### nchar +sql alter table st41 set tag tag_nchar = "��˼����" +sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 +#sleep 100 +#if $data01 != ��˼���� then +# print ==== expect ��˼����, actually $data01 +# return -1 +#endi +##### test 'space' case +#$tagvalue = ' +#$tagvalue = $tagvalue ' +sql alter table st41 set tag tag_nchar = '' +#sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 +#if $data01 != $tagvalue then +# return -1 +#endi +sql alter table st41 set tag tag_nchar = "NULL" +sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 +if $data01 != NULL then + return -1 +endi +sql alter table st41 set tag tag_nchar = NULL +#sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 +#if $data01 != then +# print ==9== expect , actually $data01 +# return -1 +#endi + +################### int +sql alter table st41 set tag tag_int = -2147483647 +sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 +if $data02 != -2147483647 then + return -1 +endi +sql alter table st41 set tag tag_int = 2147483647 +sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 +if $data02 != 2147483647 then + return -1 +endi + +sql_error alter table st41 set tag tag_int = -2147483648 +sql_error alter table st41 set tag tag_int = 2147483648 + +sql alter table st41 set tag tag_int = '-379' +sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 +if $data02 != -379 then + return -1 +endi +sql alter table st41 set tag tag_int = -2000 +sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 +if $data02 != -2000 then + return -1 +endi +sql alter table st41 set tag tag_int = NULL +sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 +if $data02 != NULL then + print ==10== expect: NULL, actually: $data02 + return -1 +endi +sql alter table st41 set tag tag_int = 'NULL' +sql_error alter table st41 set tag tag_int = '' +sql_error alter table st41 set tag tag_int = abc379 + +################### bool +sql alter table st41 set tag tag_bool = 'true' +sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 +if $data03 != 1 then + return -1 +endi +sql alter table st41 set tag tag_bool = 'false' +sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 +if $data03 != 0 then + return -1 +endi +sql alter table st41 set tag tag_bool = 0 +sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 +if $data03 != 0 then + return -1 +endi +sql alter table st41 set tag tag_bool = 123 +sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 +if $data03 != 1 then + return -1 +endi +sql alter table st41 set tag tag_bool = 'NULL' +sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 +if $data03 != NULL then + print ==14== expect: NULL, actually: $data03 + return -1 +endi +sql alter table st41 set tag tag_bool = NULL +sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 +if $data03 != NULL then + return -1 +endi + +sql_error alter table st41 set tag tag_bool = '123' +sql_error alter table st41 set tag tag_bool = '' +sql_error alter table st41 set tag tag_bool = abc379 + +################### float +sql alter table st41 set tag tag_float = -32 +sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 +if $data04 != -32.00000 then + print expect -32.00000 actual $data04 + return -1 +endi +sql alter table st41 set tag tag_float = 54.123456 +sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 +if $data04 != 54.123455 then + print ==15== expect: 54.123455, actually: $data04 +# return -1 +endi +sql alter table st41 set tag tag_float = 54.12345 +sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 +if $data04 != 54.12345 then + print ==16== expect: 54.12345, actually: $data04 + return -1 +endi +sql alter table st41 set tag tag_float = 54.12345678 +sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 +if $data04 != 54.12346 then + print ==11== expect: 54.12346, actually : $data04 + return -1 +endi +sql alter table st41 set tag tag_float = NULL +sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 +if $data04 != NULL then + print ==12== expect: NULL, actually : $data04 + return -1 +endi +sql alter table st41 set tag tag_float = 'NULL' +sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 +if $data04 != NULL then + print ==17== expect: NULL, actually : $data04 + return -1 +endi +sql alter table st41 set tag tag_float = '54.123456' +sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 +if $data04 != 54.12346 then + print ==18== expect: 54.12346, actually : $data04 + return -1 +endi +sql alter table st41 set tag tag_float = '-54.123456' +sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 +if $data04 != -54.12346 then + print ==19== expect: -54.12346, actually : $data04 + return -1 +endi +sql_error alter table st41 set tag tag_float = '' + +sql_error alter table st41 set tag tag_float = 'abc' +sql_error alter table st41 set tag tag_float = '123abc' +sql_error alter table st41 set tag tag_float = abc + +################### double +sql alter table st41 set tag tag_double = -92 +sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 +if $data05 != -92.000000000 then + print expect -92.000000000 actual $data05 + return -1 +endi +sql alter table st41 set tag tag_double = 184 +sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 +if $data05 != 184.000000000 then + print expect 184.000000000 actual $data05 + return -1 +endi +sql alter table st41 set tag tag_double = '-2456' +sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 +if $data05 != -2456.000000000 then + return -1 +endi +sql alter table st41 set tag tag_double = NULL +sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 +if $data05 != NULL then + print ==13== expect: NULL, actually : $data05 + return -1 +endi +sql alter table st41 set tag tag_double = 'NULL' +sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 +if $data05 != NULL then + print ==20== expect: NULL, actually : $data05 + return -1 +endi +sql_error alter table st41 set tag tag_double = '' + + +sql_error alter table st41 set tag tag_double = 'abc' +sql_error alter table st41 set tag tag_double = '123abc' +sql_error alter table st41 set tag tag_double = abc + +################### bigint smallint tinyint +sql create table mt5 (ts timestamp, c1 int) tags (tag_bigint bigint, tag_smallint smallint, tag_tinyint tinyint) +sql create table st51 using mt5 tags (1, 2, 3) +sql alter table st51 set tag tag_bigint = '-379' +sql alter table st51 set tag tag_bigint = -2000 +sql alter table st51 set tag tag_bigint = NULL +sql alter table st51 set tag tag_bigint = 9223372036854775807 +sql select tag_bigint, tag_smallint, tag_tinyint from st51 +if $data00 != 9223372036854775807 then + return -1 +endi +sql_error alter table st51 set tag tag_bigint = 9223372036854775808 + +sql alter table st51 set tag tag_bigint = -9223372036854775807 +sql select tag_bigint, tag_smallint, tag_tinyint from st51 +if $data00 != -9223372036854775807 then + return -1 +endi +sql_error alter table st51 set tag tag_bigint = -9223372036854775808 + +sql alter table st51 set tag tag_bigint = 'NULL' +sql_error alter table st51 set tag tag_bigint = '' +sql_error alter table st51 set tag tag_bigint = abc379 + +#### +sql alter table st51 set tag tag_smallint = -2000 +sql alter table st51 set tag tag_smallint = NULL +sql alter table st51 set tag tag_smallint = 32767 +sql select tag_bigint, tag_smallint, tag_tinyint from st51 +if $data01 != 32767 then + return -1 +endi +sql_error alter table st51 set tag tag_smallint = 32768 + +sql alter table st51 set tag tag_smallint = -32767 +sql select tag_bigint, tag_smallint, tag_tinyint from st51 +if $data01 != -32767 then + return -1 +endi +sql_error alter table st51 set tag tag_smallint = -32768 + +sql alter table st51 set tag tag_smallint = 'NULL' +sql_error alter table st51 set tag tag_smallint = '' +sql_error alter table st51 set tag tag_smallint = abc379 + +#### +sql alter table st51 set tag tag_tinyint = -127 +sql alter table st51 set tag tag_tinyint = NULL +sql alter table st51 set tag tag_tinyint = 127 +sql select tag_bigint, tag_smallint, tag_tinyint from st51 +if $data02 != 127 then + return -1 +endi +sql alter table st51 set tag tag_tinyint = -127 +sql select tag_bigint, tag_smallint, tag_tinyint from st51 +if $data02 != -127 then + return -1 +endi +sql_error alter table st51 set tag tag_tinyint = '-128' +sql_error alter table st51 set tag tag_tinyint = 128 +sql alter table st51 set tag tag_tinyint = 'NULL' +sql_error alter table st51 set tag tag_tinyint = '' +sql_error alter table st51 set tag tag_tinyint = abc379 + + +# test end +#sql drop database $db + + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/precision_ns.sim b/tests/script/general/parser/precision_ns.sim new file mode 100644 index 0000000000000000000000000000000000000000..3e9a2dd3ffdcd1f15e05c28273af9484e33840d4 --- /dev/null +++ b/tests/script/general/parser/precision_ns.sim @@ -0,0 +1,113 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 1000 +sql connect + +$dbPrefix = m_di_db_ns +$tbPrefix = m_di_tb +$mtPrefix = m_di_mt +$ntPrefix = m_di_nt +$tbNum = 2 +$rowNum = 200 +$futureTs = 300000000000 + +print =============== step1: create database and tables and insert data +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$nt = $ntPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db precision 'ns' +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $cc = $futureTs + $x * 100 + 43 + $ns = $cc . b + sql insert into $tb values (now + $ns , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sql create table $nt (ts timestamp, tbcol int) +$x = 0 +while $x < $rowNum + $cc = $futureTs + $x * 100 + 43 + $ns = $cc . b + sql insert into $nt values (now + $ns , $x ) + $x = $x + 1 +endw + +sleep 100 + +print =============== step2: select count(*) from tables +$i = 0 +$tb = $tbPrefix . $i + +sql select count(*) from $tb + +if $data00 != $rowNum then + print expect $rowNum, actual:$data00 + return -1 +endi + +$i = 0 +$mt = $mtPrefix . $i +sql select count(*) from $mt + +$mtRowNum = $tbNum * $rowNum +if $data00 != $mtRowNum then + print expect $mtRowNum, actual:$data00 + return -1 +endi + +$i = 0 +$nt = $ntPrefix . $i + +sql select count(*) from $nt + +if $data00 != $rowNum then + print expect $rowNum, actual:$data00 + return -1 +endi + +print =============== step3: check nano second timestamp +$i = 0 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql insert into $tb values (now-43b , $x ) +sql select count(*) from $tb where ts='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' limit 8000 offset 0; +if $rows != 4008 then + print expect 4008, actual:$rows + return -1 +endi + +sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' limit 8000 offset 1; +if $rows != 4007 then + return -1 +endi + +sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' limit 8000 offset 101; +print $rows +if $rows != 3907 then + return -1 +endi + +if $data00 != @70-01-01 08:01:43.101@ then + return -1 +endi + +sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' limit 8000 offset 902; +if $rows != 3106 then + return -1 +endi + +sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' limit 8000 offset 400; +if $rows != 3608 then + return -1 +endi + +sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' limit 8000 offset 4007; +if $rows != 1 then + return -1 +endi + +sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' limit 2000 offset 4008; +if $rows != 0 then + return -1 +endi + +#==================================order by desc, multi vnode, limit/offset=================================== +sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' order by ts desc limit 8000 offset 0; +if $rows != 4008 then + return -1 +endi + +if $data00 != @70-01-01 08:01:43.500@ then + return -1 +endi + +sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' order by ts desc limit 8000 offset 1; +if $rows != 4007 then + return -1 +endi + +if $data00 != @70-01-01 08:01:43.500@ then + return -1 +endi + +sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' order by ts desc limit 8000 offset 101; +print $rows +if $rows != 3907 then + return -1 +endi + +if $data00 != @70-01-01 08:01:43.488@ then + return -1 +endi + +sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' order by ts desc limit 8000 offset 902; +if $rows != 3106 then + return -1 +endi + +if $data00 != @70-01-01 08:01:43.388@ then + return -1 +endi + +sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' order by ts desc limit 8000 offset 400; +if $rows != 3608 then + return -1 +endi + +if $data00 != @70-01-01 08:01:43.450@ then + return -1 +endi + +sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' order by ts desc limit 8000 offset 4007; +if $rows != 1 then + return -1 +endi + +if $data00 != @70-01-01 08:01:43.000@ then + return -1 +endi + +sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' order by ts desc limit 2000 offset 4008; +if $rows != 0 then + return -1 +endi + +#=================================single value filter====================================== +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts asc limit 10 offset 0; +if $row != 8 then + return -1 +endi + +if $data00 != @70-01-01 08:01:43.000@ then + return -1 +endi + +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts asc limit 10 offset 1; +if $row != 7 then + return -1 +endi + +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts asc limit 10 offset 2; +if $row != 6 then + return -1 +endi + +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts asc limit 10 offset 4; +if $row != 4 then + return -1 +endi + +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts asc limit 10 offset 7; +if $row != 1 then + return -1 +endi + +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts asc limit 10 offset 8; +if $row != 0 then + return -1 +endi + +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts asc limit 10 offset 9; +if $row != 0 then + return -1 +endi + +#===============================single value filter, order by desc============================ +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts desc limit 10 offset 0; +if $row != 8 then + return -1 +endi + +if $data00 != @70-01-01 08:01:43.000@ then + return -1 +endi + +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts desc limit 10 offset 1; +if $row != 7 then + return -1 +endi + +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts desc limit 10 offset 2; +if $row != 6 then + return -1 +endi + +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts desc limit 10 offset 4; +if $row != 4 then + return -1 +endi + +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts desc limit 10 offset 7; +if $row != 1 then + return -1 +endi + +if $data00 != @70-01-01 08:01:43.000@ then + return -1 +endi + +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts desc limit 10 offset 8; +if $row != 0 then + return -1 +endi + +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts desc limit 10 offset 9; +if $row != 0 then + return -1 +endi + +#[tbase-695] +sql select ts,tbname from group_mt0 where ts>='1970-01-01 8:1:40' and ts<'1970-1-1 8:1:45' and c1<99999999 limit 100000 offset 5000 +if $row != 35000 then + return -1 +endi + +if $data00 != @70-01-01 08:01:40.000@ then + return -1 +endi + +#=================================parse error sql========================================== +sql_error select ts,tbname from group_mt0 order by ts desc limit 100 offset -1; +sql_error select ts,tbname from group_mt0 order by c1 asc limit 100 offset -1; +sql_error select ts,tbname from group_mt0 order by ts desc limit -1, 100; +sql_error select ts,tbname from group_mt0 order by ts desc slimit -1, 100; +sql_error select ts,tbname from group_mt0 order by ts desc slimit 1 soffset 1; + +#================================functions applys to sql=================================== +sql_error select first(t1) from group_mt0; +sql_error select last(t1) from group_mt0; +sql_error select min(t1) from group_mt0; +sql_error select max(t1) from group_mt0; +sql_error select top(t1, 20) from group_mt0; +sql_error select bottom(t1, 20) from group_mt0; +sql_error select avg(t1) from group_mt0; +sql_error select percentile(t1, 50) from group_mt0; +sql_error select percentile(t1, 50) from group_mt0; +sql_error select percentile(t1, 50) from group_mt0; + +#====================================tbase-722============================================== +print tbase-722 +sql select spread(ts) from group_tb0; +print $data00 + +if $data00 != 9999.000000000 then + return -1 +endi + +#====================================tbase-716============================================== +print tbase-716 +sql_error select count(*) from group_tb0 where ts in ('2016-1-1 12:12:12'); +sql_error select count(*) from group_tb0 where ts < '12:12:12'; + +#===============================sql for twa========================================== +sql_error select twa(c1) from group_stb0; +sql_error select twa(c2) from group_stb0 where tsnow-1h group by t1; +sql_error select twa(c2) from group_stb0 where tsnow-1h group by tbname,t1; +sql_error select twa(c2) from group_stb0 group by tbname,t1; +sql_error select twa(c2) from group_stb0 group by tbname; +sql_error select twa(c2) from group_stb0 group by t1; +sql_error select twa(c2) from group_stb0 where tsnow-1h group by t1,tbname; + +#================================first/last error check================================ +sql create table m1 (ts timestamp, k int) tags(a int); +sql create table tm0 using m1 tags(1); +sql create table tm1 using m1 tags(2); + +sql insert into tm0 values(10000, 1) (20000, 2)(30000, 3) (40000, NULL) (50000, 2) tm1 values(10001, 2)(20000,4)(90000,9); + +#=============================tbase-1205 +sql select count(*) from tm1 where ts= now -1d interval(1h) fill(NULL); +if $rows != 0 then + return -1 +endi + +print ===================>TD-1834 +sql select * from tm0 where ts>11000 and ts< 20000 order by ts asc +if $rows != 0 then + return -1 +endi + +sql select * from tm0 where ts>11000 and ts< 20000 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select count(*),first(k),last(k) from m1 where tbname in ('tm0') interval(1s) order by ts desc; +if $row != 5 then + return -1 +endi + +if $data00 != @70-01-01 08:00:50.000@ then + return -1 +endi + +if $data01 != 1 then + return -1 +endi + +if $data02 != 2 then + return -1 +endi + +if $data11 != 1 then + return -1 +endi + +if $data12 != NULL then + return -1 +endi + +if $data13 != NULL then + return -1 +endi + +print =============tbase-1324 +sql select a, k-k from m1 +if $row != 8 then + return -1 +endi + +sql select diff(k) from tm0 +if $row != 3 then + return -1 +endi + +if $data21 != -1 then + return -1 +endi + +#error sql +sql_error select * from 1; +#sql_error select 1; // equals to select server_status(); +sql_error select k+k; +sql_error select k+1; +sql_error select abc(); +sql_error select 1 where 1=2; +sql_error select 1 limit 1; +sql_error select 1 slimit 1; +sql_error select 1 interval(1h); +sql_error select count(*); +sql_error select sum(k); +sql_error select 'abc'; +sql_error select k+1,sum(k) from tm0; +sql_error select k, sum(k) from tm0; +sql_error select k, sum(k)+1 from tm0; + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 500 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed + +#=============================tbase-1205 +sql select count(*) from tm1 where ts= now -1d interval(1h) fill(NULL); + +print ===================>TD-1834 +sql select * from tm0 where ts>11000 and ts< 20000 order by ts asc +if $rows != 0 then + return -1 +endi + +sql select * from tm0 where ts>11000 and ts< 20000 order by ts desc +if $rows != 0 then + return -1 +endi + + + diff --git a/tests/script/general/parser/repeatAlter.sim b/tests/script/general/parser/repeatAlter.sim new file mode 100644 index 0000000000000000000000000000000000000000..3695206f908391c80ef451ebad66e3b069b21a74 --- /dev/null +++ b/tests/script/general/parser/repeatAlter.sim @@ -0,0 +1,9 @@ +$i = 1 +$loops = 10 +while $i <= $loops + print ====== repeat: $i + run general/parser/alter.sim + $i = $i + 1 +endw + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/parser/selectResNum.sim b/tests/script/general/parser/selectResNum.sim new file mode 100644 index 0000000000000000000000000000000000000000..dfd204e15240c93c1f9bcde32b8eb65c0918604a --- /dev/null +++ b/tests/script/general/parser/selectResNum.sim @@ -0,0 +1,187 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 200 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = sc_db +$tbPrefix = sc_tb +$stbPrefix = sc_stb +$tbNum = 10 +$rowNum = 10000 +$totalNum = $tbNum * $rowNum +$loops = 200000 +$log = 10000 +$ts0 = 1537146000000 +$delta = 600000 +print ========== selectResNum.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db cache 16 +print ====== create tables +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int) + +$i = 0 +$ts = $ts0 +$halfNum = $tbNum / 2 +while $i < $halfNum + $tbId = $i + $halfNum + $tb = $tbPrefix . $i + $tb1 = $tbPrefix . $tbId + sql create table $tb using $stb tags( $i ) + sql create table $tb1 using $stb tags( $tbId ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) $tb1 values ( $ts , $c , NULL , $c , NULL , $c , $c , true, $binary , $nchar ) + $x = $x + 1 + endw + + $i = $i + 1 +endw +print ====== tables created + +sql use $db +##### select from table +print ====== select from table and check num of rows returned +$loop = 1 +$i = 0 +while $loop <= $loops + $remainder = $loop / $log + $remainder = $remainder * $log + $remainder = $loop - $remainder + if $remainder == 0 then + print loop: $loop + endi + while $i < 10 + sql select ts from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + sql select c1 from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + sql select c2 from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + sql select c3 from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + sql select c4 from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + sql select c5 from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + sql select c6 from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + sql select c7 from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + sql select c8 from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + sql select c9 from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + $i = $i + 1 + endw + $loop = $loop + 1 +endw + +print ====== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 500 +system sh/exec.sh -n dnode1 -s start +print ====== server restart completed +sleep 100 +sql connect +sleep 100 +sql use $db + +##### repeat test after server restart +print ====== repeat test after restarting server +$loop = 1 +$i = 0 +while $loop <= $loops + $remainder = $loop / $log + $remainder = $remainder * $log + $remainder = $loop - $remainder + if $remainder == 0 then + print loop: $loop + endi + while $i < 10 + sql select ts from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + sql select c1 from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + sql select c2 from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + sql select c3 from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + sql select c4 from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + sql select c5 from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + sql select c6 from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + sql select c7 from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + sql select c8 from $stb where t1 = $i + if $rows != $rowNum then + print expect $rowNum, actual: $rows + return -1 + endi + sql select c9 from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + $i = $i + 1 + endw + $loop = $loop + 1 +endw + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/parser/select_across_vnodes.sim b/tests/script/general/parser/select_across_vnodes.sim new file mode 100644 index 0000000000000000000000000000000000000000..9bf61ee61d16a5220b6ae501b8c9d345f9131c1e --- /dev/null +++ b/tests/script/general/parser/select_across_vnodes.sim @@ -0,0 +1,83 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 5 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = sav_db +$tbPrefix = sav_tb +$stbPrefix = sav_stb +$tbNum = 20 +$rowNum = 10 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== alter.sim +$i = 0 +$db = $dbPrefix +$stb = $stbPrefix + +sql drop database if exists $db +sql create database $db +sql use $db +print ====== create tables +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int) + +$i = 0 +$ts = $ts0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = '涛思 . $c + $nchar = $nchar . ' + sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) + $x = $x + 1 + endw + + $i = $i + 1 +endw +print ====== tables created + +##### select * from stb +sql select * from $stb +if $rows != $totalNum then + return -1 +endi + +##### select * from $stb with limit +sql select * from $stb limit 1 +if $rows != 1 then + return -1 +endi + +$limit = $rowNum / 2 +sql select * from $stb limit $limit +if $rows != $limit then + return -1 +endi + +sql select last(*) from $stb where t1 >= 0 group by t1 limit 5 +if $rows != $tbNum then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/parser/select_distinct_tag.sim b/tests/script/general/parser/select_distinct_tag.sim new file mode 100644 index 0000000000000000000000000000000000000000..d8e92d4bc5ed3e3a1def0b33faf23ec66047227d --- /dev/null +++ b/tests/script/general/parser/select_distinct_tag.sim @@ -0,0 +1,61 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 5 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = sav_db +$tbPrefix = sav_tb +$stbPrefix = sav_stb +$tbNum = 20 +$rowNum = 10 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== alter.sim +$i = 0 +$db = $dbPrefix +$stb = $stbPrefix + +sql drop database if exists $db +sql create database $db +sql use $db +print ====== create tables +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int, t2 int) + +$i = 0 +$ts = $ts0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $stb tags( $i , 0 ) + $i = $i + 1 +endw + +print ====== table created + +#### select distinct tag +sql select distinct t1 from $stb +if $rows != $tbNum then + return -1 +endi + +#### select distinct tag +sql select distinct t2 from $stb +if $rows != 1 then + print $rows + return -1 +endi + +#### unsupport sql +sql_error select distinct t1, t2 from &stb + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/select_from_cache_disk.sim b/tests/script/general/parser/select_from_cache_disk.sim new file mode 100644 index 0000000000000000000000000000000000000000..7f8af52c6bd395416f982554083a81ee1939f059 --- /dev/null +++ b/tests/script/general/parser/select_from_cache_disk.sim @@ -0,0 +1,71 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = scd_db +$tbPrefix = scd_tb +$stbPrefix = scd_stb +$tbNum = 20 +$rowNum = 10 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== select_from_cache_disk.sim +$i = 0 +$db = $dbPrefix +$stb = $stbPrefix +$tb = $tbPrefix + +sql drop database if exists $db +sql create database $db +sql use $db +print ====== create tables +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +sql create table $tb using $stb tags( 1 ) +# generate some data on disk +sql insert into $tb values ('2018-09-17 09:00:00.000', 0) +sql insert into $tb values ('2018-09-17 09:00:00.010', 1) +sql insert into $tb values ('2018-09-17 09:00:00.020', 2) +sql insert into $tb values ('2018-09-17 09:00:00.030', 3) + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 500 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed +sql connect +sleep 100 +sql use $db + +# generate some data in cache +sql insert into $tb values ('2018-09-17 09:00:04.000', 4) +sql insert into $tb values ('2018-09-17 09:00:04.010', 5) +sql select count(*) from $stb interval(1s) group by t1 +if $rows != 2 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 4 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data10 != @18-09-17 09:00:04.000@ then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 1 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/parser/select_with_tags.sim b/tests/script/general/parser/select_with_tags.sim new file mode 100644 index 0000000000000000000000000000000000000000..eb6cd75d2104f7ff61b5f5e5bccc12fdd239d3d5 --- /dev/null +++ b/tests/script/general/parser/select_with_tags.sim @@ -0,0 +1,926 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 4 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = select_tags_db +$tbPrefix = select_tags_tb +$mtPrefix = select_tags_mt + +$tbNum = 16 +$rowNum = 800 +$totalNum = $tbNum * $rowNum + +print =============== select_with_tags.sim +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +$tstart = 100000 + +sql drop database if exists $db -x step1 +step1: +sql create database if not exists $db keep 36500 +sql use $db +sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12), t3 int) + +$i = 0 +$j = 1 + +while $i < $tbNum + $tb = $tbPrefix . $i + $tg2 = ' . abc + $tg2 = $tg2 . $i + $tg2 = $tg2 . ' + sql create table $tb using $mt tags( $i , $tg2 , 123 ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + $c = $x / 100 + $c = $c * 100 + $c = $x - $c + + $c1 = $c + $i + + $binary = ' . binary + $binary = $binary . $c + $binary = $binary . ' + + $nchar = ' . nchar + $nchar = $nchar . $c + $nchar = $nchar . ' + + sql insert into $tb values ($tstart , $c1 , $c , $c , $c , $c , $c , $c , $binary , $nchar ) + $tstart = $tstart + 1 + $x = $x + 1 + endw + + $i = $i + 1 + $j = $j + 10000 + $tstart = 100000 + $j + +endw + +sleep 100 + + +#======================= only check first table tag, TD-4827 +sql select count(*) from $mt where t1 in (0) +if $rows != 1 then + return -1 +endi +if $data00 != $rowNum then + return -1; +endi + +$secTag = ' . abc +$secTag = $secTag . 0 +$secTag = $secTag . ' +sql select count(*) from $mt where t2 =$secTag and t1 in (0) +if $rows != 1 then + return -1 +endi +if $data00 != $rowNum then + return -1; +endi + +#================================ +sql select ts from select_tags_mt0 +print $rows +if $rows != 12800 then + return -1 +endi + +sql select first(ts), tbname, t1, t2 from select_tags_mt0; +if $rows != 1 then + return -1 +endi + +if $data00 != @70-01-01 08:01:40.000@ then + return -1 +endi + +if $data01 != @select_tags_tb0@ then + print expect: select_tags_tb0, actual: $data01 + return -1 +endi + +if $data02 != 0 then + return -1 +endi + +if $data03 != @abc0@ then + return -1 +endi + +sql select last(ts), tbname, t1, t2 from select_tags_mt0; +if $rows != 1 then + return -1 +endi + +if $data00 != @70-01-01 08:04:10.800@ then + return -1 +endi + +if $data01 != @select_tags_tb15@ then + return -1 +endi + +if $data02 != 15 then + return -1 +endi + +if $data03 != @abc15@ then + return -1 +endi + +sql select min(c1), tbname, t1, t2 from select_tags_mt0; +if $rows != 1 then + return -1 +endi + +if $data00 != 0 then + return -1 +endi + +if $data01 != @select_tags_tb0@ then + return -1 +endi + +if $data02 != 0 then + return -1 +endi + +if $data03 != @abc0@ then + return -1 +endi + +sql select max(c1), tbname, t1, t2 from select_tags_mt0; +if $rows != 1 then + return -1 +endi + +if $data00 != 114 then + return -1 +endi + +if $data01 != @select_tags_tb15@ then + return -1 +endi + +if $data02 != 15 then + return -1 +endi + +if $data03 != @abc15@ then + return -1 +endi + +sql select top(c6, 3) from select_tags_mt0 interval(10a) +sql select top(c3,10) from select_tags_mt0 interval(10a) group by tbname,t1,t2 +sql select top(c6, 3) from select_tags_mt0 interval(10a) group by tbname; + +sql select top(c6, 10) from select_tags_mt0 interval(10a); +if $rows != 12800 then + return -1 +endi + +sql select top(c1, 80), tbname, t1, t2 from select_tags_mt0; +if $rows != 80 then + return -1 +endi + +if $data00 != @70-01-01 08:03:40.100@ then + return -1 +endi + +if $data10 != @70-01-01 08:03:40.200@ then + return -1 +endi + +if $data01 != 111 then + return -1 +endi + +if $data02 != @select_tags_tb12@ then + return -1 +endi + +if $data03 != 12 then + return -1 +endi + +if $data04 != @abc12@ then + return -1 +endi + +sql select top(c1, 80), tbname, t1, t2 from select_tags_mt0; +if $rows != 80 then + return -1 +endi + +if $data00 != @70-01-01 08:03:40.100@ then + return -1 +endi + +if $data10 != @70-01-01 08:03:40.200@ then + return -1 +endi + +if $data01 != 111 then + return -1 +endi + +if $data02 != @select_tags_tb12@ then + return -1 +endi + +if $data03 != 12 then + return -1 +endi + +if $data04 != @abc12@ then + return -1 +endi + +sql select bottom(c1, 72), tbname, t1, t2 from select_tags_mt0; +if $rows != 72 then + return -1 +endi + +if $data00 != @70-01-01 08:01:40.000@ then + return -1 +endi + +if $data10 != @70-01-01 08:01:40.001@ then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +if $data02 != @select_tags_tb0@ then + return -1 +endi + +if $data03 != 0 then + return -1 +endi + +if $data04 != @abc0@ then + return -1 +endi + +sql select last_row(c1, c2), tbname, t1, t2 from select_tags_mt0; +if $rows != 1 then + return -1 +endi + +if $data00 != 114 then + return -1 +endi + +print $data01 +if $data01 != 99.00000 then + return -1 +endi + +if $data02 != @select_tags_tb15@ then + return -1 +endi + +if $data03 != 15 then + return -1 +endi + +print ====== selectivity+tags+group by tags======================= +sql select first(c1), tbname, t1, t2 from select_tags_mt0 group by tbname; +if $rows != 16 then + return -1 +endi + +if $data00 != 0 then + return -1 +endi + +if $data10 != 1 then + return -1 +endi + +print $data01 +if $data01 != @select_tags_tb0@ then + return -1 +endi + +if $data11 != @select_tags_tb1@ then + return -1 +endi + +if $data02 != 0 then + return -1 +endi + +if $data03 != @abc0@ then + return -1 +endi + +if $data04 != @select_tags_tb0@ then + return -1 +endi + +sql select last_row(ts,c1), tbname, t1, t2 from select_tags_mt0 group by tbname; +if $rows != 16 then + return -1 +endi + +if $data00 != @70-01-01 08:01:40.799@ then + return -1 +endi + +if $data10 != @70-01-01 08:01:50.800@ then + return -1 +endi + +print $data01 +if $data01 != 99 then + return -1 +endi + +if $data11 != 100 then + return -1 +endi + +if $data02 != @select_tags_tb0@ then + return -1 +endi + +if $data03 != 0 then + return -1 +endi + +if $data04 != @abc0@ then + return -1 +endi + +sql select tbname,t1,t2 from select_tags_mt0; +if $row != 16 then + return -1 +endi + +if $data00 != @select_tags_tb0@ then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +if $data02 != @abc0@ then + return -1 +endi + +if $data10 != @select_tags_tb1@ then + return -1 +endi + +if $data11 != 1 then + return -1 +endi + +if $data12 != @abc1@ then + return -1 +endi + +sql select tbname,ts from select_tags_mt0; +if $row != 12800 then + return -1 +endi + +if $data00 != @select_tags_tb0@ then + return -1 +endi + +if $data10 != @select_tags_tb0@ then + return -1 +endi + +if $data01 != @70-01-01 08:01:40.000@ then + return -1 +endi + +if $data11 != @70-01-01 08:01:40.001@ then + return -1 +endi + +sql select top(c1, 100), tbname, t1, t2 from select_tags_mt0 where tbname in ('select_tags_tb0', 'select_tags_tb1') group by tbname; +if $row != 200 then + return -1 +endi + +if $data00 != @70-01-01 08:01:40.087@ then + return -1 +endi + +if $data10 != @70-01-01 08:01:40.088@ then + return -1 +endi + +if $data20 != @70-01-01 08:01:40.089@ then + return -1 +endi + +if $data90 != @70-01-01 08:01:40.096@ then + return -1 +endi + +if $data01 != 87 then + return -1 +endi + +if $data02 != @select_tags_tb0@ then + return -1 +endi + +if $data03 != 0 then + return -1 +endi + +if $data04 != @abc0@ then + return -1 +endi + +sql select top(c1, 2), t2 from select_tags_mt0 where tbname in ('select_tags_tb0', 'select_tags_tb1') group by tbname,t2; +if $row != 4 then + return -1 +endi + +if $data00 != @70-01-01 08:01:40.099@ then + return -1 +endi + +if $data01 != 99 then + return -1 +endi + +if $data02 != @abc0@ then + return -1 +endi + +if $data03 != @select_tags_tb0@ then + return -1 +endi + +if $data04 != @abc0@ then + return -1 +endi + +if $data10 != @70-01-01 08:01:40.199@ then + return -1 +endi + +if $data11 != 99 then + return -1 +endi + +if $data12 != @abc0@ then + return -1 +endi + +if $data13 != @select_tags_tb0@ then + return -1 +endi + +if $data14 != @abc0@ then + return -1 +endi + +if $data20 != @70-01-01 08:01:50.100@ then + return -1 +endi + +if $data21 != 100 then + return -1 +endi + +if $data22 != @abc1@ then + return -1 +endi + +if $data23 != @select_tags_tb1@ then + return -1 +endi + +if $data24 != @abc1@ then + return -1 +endi + +if $data30 != @70-01-01 08:01:50.200@ then + return -1 +endi + +if $data31 != 100 then + return -1 +endi + +if $data32 != @abc1@ then + return -1 +endi + +if $data33 != @select_tags_tb1@ then + return -1 +endi + +if $data34 != @abc1@ then + return -1 +endi + + +# slimit /limit +sql select top(c1, 2), t2 from select_tags_mt0 where tbname in ('select_tags_tb0', 'select_tags_tb1') group by tbname,t2 limit 2 offset 1; +if $row != 2 then + return -1 +endi + +if $data00 != @70-01-01 08:01:40.199@ then + return -1 +endi + +if $data01 != 99 then + return -1 +endi + +if $data02 != @abc0@ then + return -1 +endi + +if $data03 != @select_tags_tb0@ then + return -1 +endi + +if $data04 != @abc0@ then + return -1 +endi + +print ======= selectivity + tags + group by + tags + filter =========================== +sql select first(c1), t1 from select_tags_mt0 where c1<=2 group by tbname; +if $row != 3 then + return -1 +endi + +if $data00 != 0 then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +if $data02 != @select_tags_tb0@ then + return -1 +endi + +if $data10 != 1 then + return -1 +endi + +if $data11 != 1 then + return -1 +endi + +if $data12 != @select_tags_tb1@ then + return -1 +endi + +if $data20 != 2 then + return -1 +endi + +if $data21 != 2 then + return -1 +endi + +if $data22 != @select_tags_tb2@ then + return -1 +endi + +sql select first(c1), tbname from select_tags_mt0 where c1<=2 interval(1s); +if $row != 3 then + return -1 +endi + +if $data00 != @70-01-01 08:01:40.000@ then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +if $data02 != @select_tags_tb0@ then + return -1 +endi + +if $data10 != @70-01-01 08:01:50.000@ then + return -1 +endi + +if $data11 != 1 then + return -1 +endi + +if $data12 != @select_tags_tb1@ then + return -1 +endi + +if $data20 != @70-01-01 08:02:00.000@ then + return -1 +endi + +if $data21 != 2 then + return -1 +endi + +if $data22 != @select_tags_tb2@ then + return -1 +endi + +sql select first(ts),ts from select_tags_tb0 where c1<3 +if $row != 1 then + return -1 +endi + +if $data00 != $data01 then + return -1 +endi + +sql select last(ts),ts from select_tags_tb0 where c1<3 +if $row != 1 then + return -1 +endi + +if $data00 != $data01 then + return -1 +endi + +sql select first(ts), ts from select_tags_tb1 +if $row != 1 then + return -1 +endi + +if $data01 != @70-01-01 08:01:50.001@ then + return -1 +endi + +print ======= selectivity + tags + group by + tags + filter + interval ================ +sql select first(c1), t2, t1, tbname from select_tags_mt0 where c1<=2 interval(1d) group by tbname; +if $row != 3 then + return -1 +endi + +if $data00 != @70-01-01 00:00:00.000@ then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +if $data02 != @abc0@ then + return -1 +endi + +if $data03 != 0 then + return -1 +endi + +if $data04 != @select_tags_tb0@ then + return -1 +endi + +if $data05 != @select_tags_tb0@ then + return -1 +endi + +if $data15 != @select_tags_tb1@ then + return -1 +endi + +if $data25 != @select_tags_tb2@ then + return -1 +endi + +sql select top(c1, 5), t2 from select_tags_mt0 where c1<=2 interval(1d) group by tbname; +if $row != 15 then + return -1 +endi + +if $data00 != @70-01-01 08:01:40.002@ then + return -1 +endi + +if $data01 != 2 then + return -1 +endi + +if $data02 != @abc0@ then + return -1 +endi + +if $data03 != @select_tags_tb0@ then + return -1 +endi + +if $data90 != @70-01-01 08:01:50.402@ then + return -1 +endi + +if $data91 != 2 then + return -1 +endi + +if $data92 != @abc1@ then + return -1 +endi + +if $data93 != @select_tags_tb1@ then + return -1 +endi + +#if data +sql select top(c1, 50), t2, t1, tbname from select_tags_mt0 where c1<=2 interval(1d) group by tbname; +if $row != 48 then + return -1 +endi + +if $data00 != @70-01-01 08:01:40.000@ then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +if $data02 != @abc0@ then + return -1 +endi + +if $data03 != 0 then + return -1 +endi + +if $data04 != @select_tags_tb0@ then + return -1 +endi + +if $data05 != @select_tags_tb0@ then + return -1 +endi + +if $data10 != @70-01-01 08:01:40.001@ then + return -1 +endi + +if $data11 != 1 then + return -1 +endi + +if $data12 != @abc0@ then + return -1 +endi + +if $data13 != 0 then + return -1 +endi + +if $data14 != @select_tags_tb0@ then + return -1 +endi + +if $data15 != @select_tags_tb0@ then + return -1 +endi + +if $data90 != @70-01-01 08:01:40.300@ then + return -1 +endi + +if $data91 != 0 then + return -1 +endi + +if $data92 != @abc0@ then + return -1 +endi + +if $data93 != 0 then + return -1 +endi + +if $data94 != @select_tags_tb0@ then + return -1 +endi + +if $data95 != @select_tags_tb0@ then + return -1 +endi + +sql select last(ts),TBNAME from select_tags_mt0 interval(1y) +if $row != 1 then + return -1 +endi + +print TODO ======= selectivity + tags+ group by + tags + filter + interval + join=========== + +print ==========================mix tag columns and group by columns====================== +sql select top(c1, 100), tbname from select_tags_mt0 where tbname in ('select_tags_tb0', 'select_tags_tb1') group by t3 +if $rows != 100 then + return -1 +endi + +if $data00 != @70-01-01 08:01:40.094@ then + print expect: 70-01-01 08:01:40.094, actual: $data00 + return -1 +endi + +if $data01 != 94 then + return -1 +endi + +if $data02 != @select_tags_tb0@ then + return -1 +endi + +if $data03 != 123 then + return -1 +endi + +if $data10 != @70-01-01 08:01:40.095@ then + return -1 +endi + +if $data11 != 95 then + return -1 +endi + +if $data12 != @select_tags_tb0@ then + return -1 +endi + +if $data13 != 123 then + return -1 +endi + + +print ======error sql============================================= +sql_error select first(*), tbname from select_tags_mt0; +sql_error select first(ts), first(c1),tbname from select_tags_mt0; +sql_error select first(ts), last(ts), tbname from select_tags_mt0; +sql_error select last_row(*), first(ts), tbname, t1, t2 from select_tags_mt0; +sql_error select tbname, last_row(*), t1, first(ts) from select_tags_mt0; +sql_error select count(*), tbname from select_tags_mt0; +sql_error select sum(c2), tbname from select_tags_mt0; +sql_error select avg(c3), tbname from select_tags_mt0; +sql_error select percentile(c3, 50), tbname from select_tags_mt0; +sql_error select apercentile(c4, 50), tbname from select_tags_mt0; +sql_error select spread(c2), tbname, t1 from select_tags_mt0; +sql_error select stddev(c2), tbname from select_tags_mt0; +sql_error select twa(c2), tbname from select_tags_mt0; +sql_error select interp(c2), tbname from select_tags_mt0 where ts=100001; + +sql_error select t1,t2,tbname from select_tags_mt0 group by tbname; +sql_error select count(tbname) from select_tags_mt0 interval(1d); +sql_error select count(tbname) from select_tags_mt0 group by t1; +sql_error select count(tbname),SUM(T1) from select_tags_mt0 interval(1d); +sql_error select first(c1), count(*), t2, t1, tbname from select_tags_mt0 where c1<=2 interval(1d) group by tbname; +sql_error select ts from select_tags_mt0 interval(1y); +sql_error select count(*), tbname from select_tags_mt0 interval(1y); +sql_error select tbname, t1 from select_tags_mt0 interval(1y); + +#===error sql + group by =============================================== +#valid sql: select first(c1), last(c2), tbname from select_tags_mt0 group by tbname; +#valid sql: select first(c1), last(c2), count(*), tbname from select_tags_mt0 group by tbname; +#valid sql: select first(c1), last(c2), count(*) from select_tags_mt0 group by tbname, t1; +#valid sql: select first(c1), tbname, t1 from select_tags_mt0 group by t2; + +print ==================================>TD-4231 +sql_error select t1,tbname from select_tags_mt0 where c1<0 +sql_error select t1,tbname from select_tags_mt0 where c1<0 and tbname in ('select_tags_tb12') + +sql select tbname from select_tags_mt0 where tbname in ('select_tags_tb12'); + +sql_error select first(c1), last(c2), t1 from select_tags_mt0 group by tbname; +sql_error select first(c1), last(c2), tbname, t2 from select_tags_mt0 group by tbname; +sql_error select first(c1), count(*), t2, t1, tbname from select_tags_mt0 group by tbname; +#valid sql: select first(c1), t2 from select_tags_mt0 group by tbname; + +#sql select first(ts), tbname from select_tags_mt0 group by tbname; +#sql select count(c1) from select_tags_mt0 where c1=99 group by tbname; +#sql select count(*),tbname from select_tags_mt0 group by tbname + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/set_tag_vals.sim b/tests/script/general/parser/set_tag_vals.sim new file mode 100644 index 0000000000000000000000000000000000000000..74184f94d47b07684a233ef692769094141a3f56 --- /dev/null +++ b/tests/script/general/parser/set_tag_vals.sim @@ -0,0 +1,230 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = db +$tbPrefix = tb +$stbPrefix = stb +$tbNum = 100 +$rowNum = 100 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +$tsu = $rowNum * $delta +$tsu = $tsu - $delta +$tsu = $tsu + $ts0 + +print ========== alter_tg.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +print ====== create $tbNum tables +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 binary(9), t2 binary(8)) + +$i = 0 +$ts = $ts0 +$halfNum = $tbNum / 2 +while $i < $tbNum + $tb = $tbPrefix . $i + $tgstr = 'tb . $i + $tgstr = $tgstr . ' + $tgstr1 = 'usr . $i1 + $tgstr1 = $tgstr1 . ' + sql create table $tb using $stb tags( $tgstr , $tgstr1 ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) + $x = $x + 1 + endw + + $i = $i + 1 +endw +print ====== tables created + +sleep 500 + +sql show tables +if $rows != $tbNum then + return -1 +endi + +print ================== alter table add tags +sql alter table $stb add tag t3 int +sql alter table $stb add tag t4 binary(60) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql insert into $tb (ts, c1) values (now-100a, $i ) + sql alter table $tb set tag t3 = $i + sql insert into $tb (ts, c1) values (now, $i ) + sql alter table $tb set tag t4 = $i + $i = $i + 1 +endw + +print ================== all tags have been changed! +sql select tbname from $stb where t3 = 'NULL' +if $rows != 0 then + return -1 +endi + +print ================== set tag to NULL +sql create table stb1_tg (ts timestamp, c1 int) tags(t1 int,t2 bigint,t3 double,t4 float,t5 smallint,t6 tinyint) +sql create table stb2_tg (ts timestamp, c1 int) tags(t1 bool,t2 binary(10), t3 nchar(10)) +sql create table tb1_tg1 using stb1_tg tags(1,2,3,4,5,6) +sql create table tb1_tg2 using stb2_tg tags(true, 'tb1_tg2', '表1标签2') +sql insert into tb1_tg1 values (now,1) +sql insert into tb1_tg2 values (now,1) + +sql select * from stb1_tg +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3.000000000 then + return -1 +endi +if $data05 != 4.00000 then + return -1 +endi +if $data06 != 5 then + return -1 +endi +if $data07 != 6 then + return -1 +endi + +sql select * from stb2_tg +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != tb1_tg2 then + return -1 +endi +if $data04 != 表1标签2 then + return -1 +endi + +sql alter table tb1_tg1 set tag t1 = -1 +sql alter table tb1_tg1 set tag t2 = -2 +sql alter table tb1_tg1 set tag t3 = -3 +sql alter table tb1_tg1 set tag t4 = -4 +sql alter table tb1_tg1 set tag t5 = -5 +sql alter table tb1_tg1 set tag t6 = -6 +sql alter table tb1_tg2 set tag t1 = false +sql alter table tb1_tg2 set tag t2 = 'binary2' +sql alter table tb1_tg2 set tag t3 = '涛思' +sql reset query cache +sql select * from stb1_tg +if $rows != 1 then + return -1 +endi +if $data02 != -1 then + return -1 +endi +if $data03 != -2 then + return -1 +endi +if $data04 != -3.000000000 then + return -1 +endi +if $data05 != -4.00000 then + return -1 +endi +if $data06 != -5 then + return -1 +endi +if $data07 != -6 then + return -1 +endi +sql select * from stb2_tg +if $data02 != 0 then + return -1 +endi +if $data03 != binary2 then + return -1 +endi +if $data04 != 涛思 then + return -1 +endi + +sql alter table tb1_tg1 set tag t1 = NULL +sql alter table tb1_tg1 set tag t2 = NULL +sql alter table tb1_tg1 set tag t3 = NULL +sql alter table tb1_tg1 set tag t4 = NULL +sql alter table tb1_tg1 set tag t5 = NULL +sql alter table tb1_tg1 set tag t6 = NULL +sql alter table tb1_tg2 set tag t1 = NULL +sql alter table tb1_tg2 set tag t2 = NULL +sql alter table tb1_tg2 set tag t3 = NULL +sql reset query cache +sql select * from stb1_tg +if $rows != 1 then + return -1 +endi +if $data02 != NULL then + return -1 +endi +if $data03 != NULL then + return -1 +endi +if $data04 != NULL then + return -1 +endi +if $data05 != NULL then + return -1 +endi +if $data06 != NULL then + return -1 +endi +if $data07 != NULL then + return -1 +endi +sql select * from stb2_tg +if $data02 != NULL then + return -1 +endi + +print $data03 +if $data03 != NULL then + return -1 +endi +if $data04 != NULL then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/parser/single_row_in_tb.sim b/tests/script/general/parser/single_row_in_tb.sim new file mode 100644 index 0000000000000000000000000000000000000000..5de2a51f0f81d9286184c11e97d682a2b82ebdcd --- /dev/null +++ b/tests/script/general/parser/single_row_in_tb.sim @@ -0,0 +1,41 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 4 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = sr_db +$tbPrefix = sr_tb +$stbPrefix = sr_stb +$ts0 = 1537146000000 +print ========== single_row_in_tb.sim +$db = $dbPrefix +$stb = $stbPrefix + +sql drop database if exists $db +sql create database $db maxrows 200 +print ====== create tables +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 bool, c6 binary(10), c7 nchar(10)) tags(t1 int) + +$i = 0 +$ts = $ts0 +$tb1 = $tbPrefix . 1 +sql create table $tb1 using $stb tags( 1 ) +sql insert into $tb1 values ( $ts0 , 1, 2, 3, 4, true, 'binay10', '涛思nchar10' ) +print ====== tables created + +run general/parser/single_row_in_tb_query.sim + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 500 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed + +run general/parser/single_row_in_tb_query.sim + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/parser/single_row_in_tb_query.sim b/tests/script/general/parser/single_row_in_tb_query.sim new file mode 100644 index 0000000000000000000000000000000000000000..acf85ea6922048e10ce8bd93c9eadb799649750f --- /dev/null +++ b/tests/script/general/parser/single_row_in_tb_query.sim @@ -0,0 +1,199 @@ +sleep 100 +sql connect + +$dbPrefix = sr_db +$tbPrefix = sr_tb +$stbPrefix = sr_stb +$ts0 = 1537146000000 +print ========== single_row_in_tb_query.sim +$db = $dbPrefix +$stb = $stbPrefix + +sql use $db +$tb1 = $tbPrefix . 1 + +sql select first(ts, c1) from $stb where ts >= $ts0 and ts < now group by t1 +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +sql select last(ts, c1) from $stb where ts >= $ts0 and ts < now group by t1 +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +sql select first(ts, c1), last(c1) from $stb where ts >= $ts0 and ts < now group by t1 +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi + +sql select first(ts, c1), last(c2) from $stb where ts >= $ts0 and ts < now group by t1 +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 2 then + return -1 +endi + +sql select first(ts, c1) from $tb1 where ts >= $ts0 and ts < now +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +sql select last(ts, c1) from $tb1 where ts >= $ts0 and ts < now +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +sql select first(ts, c1), last(c1) from $tb1 where ts >= $ts0 and ts < now +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi + +sql select first(ts, c1), last(c2) from $tb1 where ts >= $ts0 and ts < now +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 2 then + return -1 +endi + +#### query a STable and using where clause +sql select first(ts,c1), last(ts,c1), spread(c1) from $stb where ts >= $ts0 and ts < '2018-09-20 00:00:00.000' group by t1 +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data03 != 1 then + return -1 +endi +if $data04 != 0.000000000 then + print expect: 0.00000000 , actual: $data04 + return -1 +endi +if $data05 != 1 then + return -1 +endi + +sql select first(c1), last(c1) from $stb where ts >= $ts0 and ts < '2018-09-20 00:00:00.000' interval(1d) group by t1 +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 00:00:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi + +sql select max(c1), min(c1), sum(c1), avg(c1), count(c1) from $stb where c1 > 0 group by t1 +if $rows != 1 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 1.000000000 then + return -1 +endi +if $data04 != 1 then + return -1 +endi +if $data05 != 1 then + return -1 +endi + +sql select first(ts,c1), last(ts,c1) from $tb1 where ts >= $ts0 and ts < '2018-09-20 00:00:00.000' interval(1d) +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 00:00:00.000@ then + return -1 +endi +if $data01 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data04 != 1 then + return -1 +endi + +print ===============>safty check TD-4927 +sql select first(ts, c1) from sr_stb where ts<1 group by t1; +sql select first(ts, c1) from sr_stb where ts>0 and ts<1; \ No newline at end of file diff --git a/tests/script/general/parser/sliding.sim b/tests/script/general/parser/sliding.sim new file mode 100644 index 0000000000000000000000000000000000000000..b2695ff95f27c5fe6ba27c9b977c96b48a5e5801 --- /dev/null +++ b/tests/script/general/parser/sliding.sim @@ -0,0 +1,532 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c debugFlag -v 135 +system sh/cfg.sh -n dnode1 -c rpcDebugFlag -v 135 +system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 4 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = sliding_db +$tbPrefix = sliding_tb +$mtPrefix = sliding_mt +$tbNum = 8 +$rowNum = 10000 +$totalNum = $tbNum * $rowNum + +print =============== sliding.sim +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +$tstart = 946656000000 + +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database if exists $db -x step1 +step1: +sql create database if not exists $db keep 36500 +sql use $db +sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12)) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + $tg2 = ' . abc + $tg2 = $tg2 . ' + sql create table $tb using $mt tags( $i , $tg2 ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + $c = $x / 100 + $c = $c * 100 + $c = $x - $c + + $binary = ' . binary + $binary = $binary . $c + $binary = $binary . ' + + $nchar = ' . nchar + $nchar = $nchar . $c + $nchar = $nchar . ' + + sql insert into $tb values ($tstart , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar ) + $tstart = $tstart + 30 + $x = $x + 1 + endw + + $i = $i + 1 + $tstart = 946656000000 +endw + +sleep 100 + +$i1 = 1 +$i2 = 0 + +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +$dbPrefix = sliding_db +$tbPrefix = sliding_tb +$mtPrefix = sliding_mt + +$tb1 = $tbPrefix . $i1 +$tb2 = $tbPrefix . $i2 +$ts1 = $tb1 . .ts +$ts2 = $tb2 . .ts + +print ===============================interval_sliding query +sql select count(*) from sliding_tb0 interval(30s) sliding(30s); +if $row != 10 then + return -1 +endi + +if $data00 != @00-01-01 00:00:00.000@ then + return -1 +endi + +if $data01 != 1000 then + return -1 +endi + +if $data10 != @00-01-01 00:00:30.000@ then + return -1 +endi + +if $data11 != 1000 then + return -1 +endi + +sql select stddev(c1) from sliding_tb0 interval(10a) sliding(10a) +if $row != 10000 then + return -1 +endi + +if $data00 != @00-01-01 00:00:00.000@ then + return -1 +endi + +if $data01 != 0.000000000 then + return -1 +endi + +if $data90 != @00-01-01 00:00:00.270@ then + return -1 +endi + +if $data91 != 0.000000000 then + return -1 +endi + +sql select stddev(c1),count(c2),first(c3),last(c4) from sliding_tb0 interval(10a) sliding(10a) order by ts desc; +if $row != 10000 then + return -1 +endi + +if $data00 != @00-01-01 00:04:59.970@ then + return -1 +endi + +if $data01 != 0.000000000 then + return -1 +endi + +if $data02 != 1 then + return -1 +endi + +if $data03 != 99 then + return -1 +endi + +if $data04 != 99 then + return -1 +endi + +if $data90 != @00-01-01 00:04:59.700@ then + return -1 +endi + +if $data91 != 0.000000000 then + return -1 +endi + +if $data92 != 1 then + return -1 +endi + +if $data93 != 90 then + return -1 +endi + +if $data94 != 90 then + return -1 +endi + +sql select count(c2),last(c4) from sliding_tb0 interval(30s) sliding(10s) order by ts asc; +if $row != 32 then + return -1 +endi + +if $data00 != @99-12-31 23:59:40.000@ then + print expect 12-31 23:59:40.000, actual: $data00 + return -1 +endi + +if $data01 != 334 then + return -1 +endi + +if $data02 != 33 then + return -1 +endi + +sql select count(c2),stddev(c3),first(c4),last(c4) from sliding_tb0 where ts>'2000-01-01 0:0:0' and ts<'2000-1-1 0:0:31' interval(30s) sliding(30s) order by ts asc; +if $row != 2 then + return -1 +endi + +if $data04 != 99 then + return -1 +endi + +if $data01 != 999 then + return -1 +endi + +if $data02 != 28.837977152 then + return -1 +endi + +#interval offset + limit +sql select count(c2), first(c3),stddev(c4) from sliding_tb0 interval(10a) sliding(10a) order by ts desc limit 10 offset 990; +if $row != 10 then + return -1 +endi + +if $data00 != @00-01-01 00:04:30.270@ then + return -1 +endi + +if $data01 != 1 then + return -1 +endi + +if $data02 != 9 then + return -1 +endi + +if $data03 != 0.000000000 then + return -1 +endi + +if $data90 != @00-01-01 00:04:30.000@ then + return -1 +endi + +if $data91 != 1 then + return -1 +endi + +if $data92 != 0 then + return -1 +endi + +if $data93 != 0.000000000 then + return -1 +endi + +#interval offset test +sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(30s) sliding(30s) order by ts asc limit 1000 offset 1; +if $row != 9 then + return -1 +endi + +if $data00 != @00-01-01 00:00:30.000@ then + return -1 +endi + +if $data01 != 1000 then + return -1 +endi + +if $data02 != 99 then + return -1 +endi + +if $data80 != @00-01-01 00:04:30.000@ then + return -1 +endi + +if $data81 != 1000 then + return -1 +endi + +sql select count(c2),last(c4),stddev(c3) from sliding_tb0 where ts>'2000-1-1 0:0:0' and ts<'2000-1-1 0:0:31' interval(30s) sliding(30s) order by ts asc limit 1000 offset 0; +if $row != 2 then + return -1 +endi + +if $data00 != @00-01-01 00:00:00.000@ then + return -1 +endi + +if $data01 != 999 then + return -1 +endi + +if $data02 != 99 then + return -1 +endi + +if $data03 != 28.837977152 then + return -1 +endi + +if $data10 != @00-01-01 00:00:30.000@ then + return -1 +endi + +if $data11 != 34 then + return -1 +endi + +if $data12 != 33 then + return -1 +endi + +if $data13 != 9.810708435 then + return -1 +endi + +sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(30s) sliding(20s) order by ts asc limit 100 offset 1; +if $row != 15 then + return -1 +endi + +if $data00 != @00-01-01 00:00:00.000@ then + return -1 +endi + +if $data01 != 1000 then + return -1 +endi + +if $data02 != 99 then + return -1 +endi + +if $data03 != 28.866070048 then + return -1 +endi + +if $data90 != @00-01-01 00:03:00.000@ then + return -1 +endi + +if $data91 != 1000 then + return -1 +endi + +if $data92 != 99 then + return -1 +endi + +sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(30s) sliding(20s) order by ts asc limit 100 offset 5; +if $row != 11 then + return -1 +endi + +sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(30s) sliding(20s) order by ts asc limit 100 offset 6; +if $row != 10 then + return -1 +endi + +sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(30s) sliding(20s) order by ts asc limit 100 offset 7; +if $row != 9 then + return -1 +endi + +sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(30s) sliding(20s) order by ts asc limit 100 offset 8; +if $row != 8 then + return -1 +endi + +sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(30s) sliding(20s) order by ts asc limit 100 offset 9; +if $row != 7 then + return -1 +endi + +sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(30s) sliding(20s) order by ts asc limit 100 offset 10; +if $row != 6 then + return -1 +endi + +sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(30s) sliding(20s) order by ts asc limit 100 offset 11; +if $row != 5 then + return -1 +endi + +sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(30s) sliding(20s) order by ts asc limit 100 offset 12; +if $row != 4 then + return -1 +endi + +sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(30s) sliding(20s) order by ts asc limit 100 offset 13; +if $row != 3 then + return -1 +endi + +sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(30s) sliding(20s) order by ts asc limit 100 offset 14; +if $row != 2 then + return -1 +endi + +sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(30s) sliding(20s) order by ts asc limit 100 offset 15; +if $row != 1 then + return -1 +endi + +sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(30s) sliding(20s) order by ts asc limit 100 offset 16; +if $row != 0 then + return -1 +endi + +sql select count(c2),last(c4),stddev(c3),spread(c3) from sliding_tb0 where c2 = 0 interval(30s) order by ts desc; +if $row != 10 then + return -1 +endi + +#00-01-01 00:04:30.000| 10| 0| 0.000000000| 0.000000000| +if $data00 != @00-01-01 00:04:30.000@ then + return -1 +endi + +if $data01 != 10 then + return -1 +endi + +if $data02 != 0 then + return -1 +endi + +if $data03 != 0.000000000 then + return -1 +endi + +sql select count(c2),last(c4),stddev(c3),spread(c3) from sliding_tb0 where c2 = 0 interval(30s) sliding(20s) order by ts desc limit 1 offset 15; +if $row != 1 then + return -1 +endi + +sql select count(c2),last(c4),stddev(c3),spread(c3) from sliding_tb0 where c2 = 0 interval(30s) sliding(20s) order by ts desc limit 1 offset 16; +if $row != 0 then + return -1 +endi + +sql select count(c2), first(c3),stddev(c4) from sliding_tb0 interval(10a) order by ts desc limit 10 offset 2; +if $data00 != @00-01-01 00:04:59.910@ then + return -1 +endi + +sql select count(*),stddev(c1),count(c1),first(c2),last(c3) from sliding_tb0 where ts>'2000-1-1 00:00:00' and ts<'2000-1-1 00:00:01.002' and c2 >= 0 interval(30s) sliding(10s) order by ts asc limit 1000; +if $row != 3 then + return -1 +endi + +if $data00 != @99-12-31 23:59:40.000@ then + return -1 +endi + +if $data02 != 9.521904571 then + return -1 +endi + +if $data05 != 33 then + return -1 +endi + +if $data10 != @99-12-31 23:59:50.000@ then + return -1 +endi + +if $data12 != 9.521904571 then + return -1 +endi + +if $data15 != 33 then + return -1 +endi + +if $data25 != 33 then + return -1 +endi + +sql select count(*),stddev(c1),count(c1),first(c2),last(c3) from sliding_tb0 where ts>'2000-1-1 00:00:00' and ts<'2000-1-1 00:00:01.002' and c2 >= 0 interval(30s) sliding(10s) order by ts desc limit 1000; +if $row != 3 then + return -1 +endi + +if $data00 != @00-01-01 00:00:00.000@ then + print expect 00-01-01 00:00:00.000, actual: $data00 + return -1 +endi + +if $data01 != 33 then + return -1 +endi + +if $data02 != 9.521904571 then + return -1 +endi + +if $data03 != 33 then + return -1 +endi + +if $data10 != @99-12-31 23:59:50.000@ then + return -1 +endi + +if $data11 != 33 then + return -1 +endi +if $data12 != 9.521904571 then + return -1 +endi + +if $data20 != @99-12-31 23:59:40.000@ then + return -1 +endi +if $data21 != 33 then + return -1 +endi +if $data22 != 9.521904571 then + return -1 +endi + +print ====================>check boundary check crash at client side +sql select count(*) from sliding_mt0 where ts>now and ts < now-1h; + +print ========================query on super table + +print ========================error case +sql_error select sum(c1) from sliding_tb0 interval(1a) sliding(1a); +sql_error select sum(c1) from sliding_tb0 interval(10a) sliding(12a); +sql_error select sum(c1) from sliding_tb0 sliding(1n) interval(1y); +sql_error select sum(c1) from sliding_tb0 interval(-1y) sliding(1n); +sql_error select sum(c1) from sliding_tb0 interval(1y) sliding(-1n); +sql_error select sum(c1) from sliding_tb0 interval(0) sliding(0); +sql_error select sum(c1) from sliding_tb0 interval(0m) sliding(0m); +sql_error select sum(c1) from sliding_tb0 interval(m) sliding(m); +sql_error select sum(c1) from sliding_tb0 sliding(4m); +sql_error select count(*) from sliding_tb0 interval(1s) sliding(10s); +sql_error select count(*) from sliding_tb0 interval(10s) sliding(10a); + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/slimit.sim b/tests/script/general/parser/slimit.sim new file mode 100644 index 0000000000000000000000000000000000000000..0af31f982604a3b6c6e0901cd94795fc503edd4b --- /dev/null +++ b/tests/script/general/parser/slimit.sim @@ -0,0 +1,108 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = slm_db +$tbPrefix = slm_tb +$stbPrefix = slm_stb +$tbNum = 10 +$rowNum = 300 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== slimit.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database if exists $db +sql create database $db maxrows 200 cache 16 +print ====== create tables +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 binary(15), t2 int, t3 bigint, t4 nchar(10), t5 double, t6 bool) + +$i = 0 +$ts = $ts0 +$halfNum = $tbNum / 2 +while $i < $tbNum + $tb = $tbPrefix . $i + $t1 = ' . $tb + $t1 = $t1 . ' + $t2 = $i + $t3 = $i + $t4 = '涛思 . $tb + $t4 = $t4 . ' + $t5 = $i + $t6 = true + sql create table $tb using $stb tags( $t1 , $t2 , $t3 , $t4 , $t5 , $t6 ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = '涛思nchar . $c + $nchar = $nchar . ' + sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) + $x = $x + 1 + endw + $ts = $ts + $delta + sql insert into $tb values ( $ts , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + $i = $i + 1 +endw +print ====== $db tables created + +$db = $dbPrefix . 1 +sql drop database if exists $db +sql create database $db maxrows 200 cache 16 +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 binary(15), t2 int, t3 bigint, t4 nchar(10), t5 double, t6 bool) + +$i = 0 +$ts = $ts0 +$halfNum = $tbNum / 2 +while $i < $tbNum + $tb = $tbPrefix . $i + $t1 = ' . $tb + $t1 = $t1 . ' + $t2 = $i + $t3 = $i + $t4 = '涛思 . $tb + $t4 = $t4 . ' + $t5 = $i + $t6 = true + sql create table $tb using $stb tags( $t1 , $t2 , $t3 , $t4 , $t5 , $t6 ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + sql insert into $tb values ( $ts , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL ) + $x = $x + 1 + endw + $i = $i + 1 +endw +print ====== $db tables created + +run general/parser/slimit_query.sim + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 500 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed +sql connect +sleep 100 + +run general/parser/slimit_query.sim + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/parser/slimit1.sim b/tests/script/general/parser/slimit1.sim new file mode 100644 index 0000000000000000000000000000000000000000..2dede439ec38c862afcce5e1658fa02824282087 --- /dev/null +++ b/tests/script/general/parser/slimit1.sim @@ -0,0 +1,67 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = slm_alt_tg_db + +print ========== slimit_alter_tag.sim +# make sure the data in each table crosses a file block boundary +$rowNum = 300 +$ts0 = 1537146000000 +$delta = 600000 +$db = $dbPrefix + +sql drop database if exists $db +sql create database $db maxrows 200 +sql use $db + +sql create table stb (ts timestamp, c1 int, c2 bigint, c3 double) tags(t1 int, t2 int) +# If grouped by t2, some groups should have tables from different vnodes +sql create table tb0 using stb tags (0, 0) +sql create table tb1 using stb tags (1, 0) +sql create table tb2 using stb tags (2, 0) +sql create table tb3 using stb tags (3, 1) +sql create table tb4 using stb tags (4, 1) +sql create table tb5 using stb tags (5, 1) +sql create table tb6 using stb tags (6, 2) +sql create table tb7 using stb tags (7, 2) +sql create table tb8 using stb tags (8, 2) +# tb9 is intentionally set the same tags with tb8 +sql create table tb9 using stb tags (8, 2) + +$i = 0 +$tbNum = 10 +while $i < $tbNum + $tb = tb . $i + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c1 = $x * 10 + $c1 = $c1 + $i + sql insert into $tb values ( $ts , $c1 , $c1 , $c1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print ================== tables and data created + +run general/parser/slimit1_query.sim + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 500 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed +sql connect +sleep 100 + +run general/parser/slimit1_query.sim + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/parser/slimit1_query.sim b/tests/script/general/parser/slimit1_query.sim new file mode 100644 index 0000000000000000000000000000000000000000..8e3a61bee6e025b39f784c5189be4c0d72c05833 --- /dev/null +++ b/tests/script/general/parser/slimit1_query.sim @@ -0,0 +1,184 @@ +sleep 100 +sql connect + +$dbPrefix = slm_alt_tg_db + +print ========== slimit1_query.sim +# make sure the data in each table crosses a file block boundary +$rowNum = 300 +$ts0 = 1537146000000 +$delta = 600000 +$db = $dbPrefix + +sql use $db + +#### group by t2,t1 + slimit +sql select count(*) from stb group by t2,t1 order by t2 asc slimit 5 soffset 6 +if $rows != 3 then + return -1 +endi +if $data00 != $rowNum then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 6 then + return -1 +endi +if $data10 != $rowNum then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 7 then + return -1 +endi +$res = 2 * $rowNum +if $data20 != $res then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data22 != 8 then + return -1 +endi +## desc +sql select count(*) from stb group by t2,t1 order by t2 desc slimit 5 soffset 0 +if $rows != 5 then + return -1 +endi +$res = 2 * $rowNum +if $data00 != $res then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 8 then + return -1 +endi +if $data10 != $rowNum then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 7 then + return -1 +endi +if $data20 != $rowNum then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data22 != 6 then + return -1 +endi +if $data30 != $rowNum then + return -1 +endi +if $data31 != 1 then + return -1 +endi +if $data32 != 5 then + return -1 +endi +if $data40 != $rowNum then + return -1 +endi +if $data41 != 1 then + return -1 +endi +if $data42 != 4 then + return -1 +endi + +### empty result set +#sql select count(*) from stb group by t2,t1 order by t2 asc slimit 0 soffset 0 +#if $rows != 0 then +# return -1 +#endi +#sql select count(*) from stb group by t2,t1 order by t2 asc slimit 5 soffset 10 +#if $rows != 0 then +# return -1 +#endi + +#### group by t2 + slimit +sql select count(*) from stb group by t2 order by t2 asc slimit 2 soffset 0 +if $rows != 2 then + return -1 +endi +$res = 3 * $rowNum +if $data00 != $res then + return -1 +endi +if $data10 != $res then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != 1 then + return -1 +endi + +sql select count(*) from stb group by t2 order by t2 desc slimit 2 soffset 0 +if $rows != 2 then + return -1 +endi +$res = 4 * $rowNum +if $data00 != $res then + return -1 +endi +$res = 3 * $rowNum +if $data10 != $res then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data11 != 1 then + return -1 +endi + +sql select count(*) from stb group by t2 order by t2 asc slimit 2 soffset 1 +if $rows != 2 then + return -1 +endi +$res = 3 * $rowNum +if $data00 != $res then + return -1 +endi +$res = 4 * $rowNum +if $data10 != $res then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data11 != 2 then + return -1 +endi + +sql select count(*) from stb group by t2 order by t2 desc slimit 2 soffset 1 +if $rows != 2 then + return -1 +endi +$res = 3 * $rowNum +if $data00 != $res then + return -1 +endi +if $data10 != $res then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data11 != 0 then + return -1 +endi + diff --git a/tests/script/general/parser/slimit_alter_tags.sim b/tests/script/general/parser/slimit_alter_tags.sim new file mode 100644 index 0000000000000000000000000000000000000000..53af0f3e8470b0708f2193b09ed1797c8abc9a52 --- /dev/null +++ b/tests/script/general/parser/slimit_alter_tags.sim @@ -0,0 +1,260 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = slm_alt_tg_db + +print ========== slimit_alter_tag.sim +# make sure the data in each table crosses a file block boundary +$rowNum = 300 +$ts0 = 1537146000000 +$delta = 600000 +$db = $dbPrefix + +sql drop database if exists $db +sql create database $db maxrows 200 +sql use $db + +sql create table stb (ts timestamp, c1 int, c2 bigint, c3 double) tags(t1 int, t2 int) +# If grouped by t2, some groups should have tables from different vnodes +sql create table tb0 using stb tags (0, 0) +sql create table tb1 using stb tags (1, 0) +sql create table tb2 using stb tags (2, 0) +sql create table tb3 using stb tags (3, 1) +sql create table tb4 using stb tags (4, 1) +sql create table tb5 using stb tags (5, 1) +sql create table tb6 using stb tags (6, 2) +sql create table tb7 using stb tags (7, 2) +sql create table tb8 using stb tags (8, 2) +# tb9 is intentionally set the same tags with tb8 +sql create table tb9 using stb tags (8, 2) + +$i = 0 +$tbNum = 10 +while $i < $tbNum + $tb = tb . $i + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c1 = $x * 10 + $c1 = $c1 + $i + sql insert into $tb values ( $ts , $c1 , $c1 , $c1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print ================== tables and data created + +print ================== add a tag +sql alter table stb add tag tg_added binary(15) +sql describe stb +if $rows != 7 then + return -1 +endi +if $data60 != tg_added then + return -1 +endi + +sql select count(*) from stb group by tg_added order by tg_added asc +if $rows != 1 then + return -1 +endi +$res = $rowNum * 10 +if $data00 != $res then + return -1 +endi +#if $data01 != NULL then +# return -1 +#endi + +print ================== change tag values +$i = 0 +while $i < 10 + $tb = tb . $i + $tg_added = ' . $tb + $tg_added = $tg_added . ' + sql alter table $tb set tag tg_added = $tg_added + $i = $i + 1 +endw + +sql select t1,t2,tg_added from tb0 +if $rows != 1 then + return -1 +endi + +if $data02 != tb0 then + return -1 +endi + +sleep 500 +sql reset query cache +sql select count(*), first(ts) from stb group by tg_added order by tg_added asc slimit 5 soffset 3 +if $rows != 5 then + print ===== result: $rows + return -1 +endi +if $data00 != $rowNum then + return -1 +endi +if $data10 != $rowNum then + return -1 +endi +if $data20 != $rowNum then + return -1 +endi +if $data30 != $rowNum then + return -1 +endi +if $data40 != $rowNum then + return -1 +endi +if $data02 != tb3 then + return -1 +endi +if $data12 != tb4 then + return -1 +endi +if $data22 != tb5 then + return -1 +endi +if $data32 != tb6 then + return -1 +endi +if $data42 != tb7 then + return -1 +endi + +sql alter table tb9 set tag t2 = 3 +sql select count(*), first(*) from stb group by t2 order by t2 slimit 6 soffset 1 +if $rows != 3 then + return -1 +endi +$res = 3 * $rowNum +if $data00 != $res then + return -1 +endi +#if $data01 != @18-09-17 09:00:00.000@ then +# return -1 +#endi +if $data02 != 3 then + return -1 +endi +if $data05 != 1 then + return -1 +endi +$res = 3 * $rowNum +if $data10 != $res then + return -1 +endi +#if $data11 != @18-09-17 09:00:00.000@ then +# return -1 +#endi +if $data15 != 2 then + return -1 +endi +if $data20 != $rowNum then + return -1 +endi +if $data24 != 9.000000000 then + return -1 +endi +if $data25 != 3 then + return -1 +endi + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 500 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed +sql connect +sleep 100 + +sql use $db +### repeat above queries +sql select count(*), first(ts) from stb group by tg_added order by tg_added asc slimit 5 soffset 3; +if $rows != 5 then + return -1 +endi +if $data00 != $rowNum then + return -1 +endi +if $data10 != $rowNum then + return -1 +endi +if $data20 != $rowNum then + return -1 +endi +if $data30 != $rowNum then + return -1 +endi +if $data40 != $rowNum then + return -1 +endi +if $data02 != tb3 then + return -1 +endi +if $data12 != tb4 then + return -1 +endi +if $data22 != tb5 then + return -1 +endi +if $data32 != tb6 then + return -1 +endi +if $data42 != tb7 then + return -1 +endi + +sql select count(*), first(*) from stb group by t2 order by t2 slimit 6 soffset 1 +if $rows != 3 then + return -1 +endi +$res = 3 * $rowNum +if $data00 != $res then + return -1 +endi +#if $data01 != @18-09-17 09:00:00.000@ then +# return -1 +#endi +if $data02 != 3 then + return -1 +endi +if $data05 != 1 then + return -1 +endi +$res = 3 * $rowNum +if $data10 != $res then + return -1 +endi +#if $data11 != @18-09-17 09:00:00.000@ then +# return -1 +#endi +if $data15 != 2 then + return -1 +endi +if $data20 != $rowNum then + return -1 +endi +if $data24 != 9.000000000 then + return -1 +endi +if $data25 != 3 then + return -1 +endi + +#sql drop database $db +#sql show databases +#if $rows != 0 then +# return -1 +#endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/parser/slimit_query.sim b/tests/script/general/parser/slimit_query.sim new file mode 100644 index 0000000000000000000000000000000000000000..0dbcffa0a43b596d542c8799a9a94170e6f71f5a --- /dev/null +++ b/tests/script/general/parser/slimit_query.sim @@ -0,0 +1,574 @@ +sleep 100 +sql connect + +$dbPrefix = slm_db +$tbPrefix = slm_tb +$stbPrefix = slm_stb +$tbNum = 10 +$rowNum = 300 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== slimit_stb.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +print ====== use db +sql use $db + +$tsu = $rowNum * $delta +$tsu = $tsu - $delta +$tsu = $tsu + $ts0 + +##### select from supertable + +### illegal operations +#sql_error select max(c1) from $stb where ts >= $ts0 and ts <= $tsu slimit 5 limit 1 +#sql_error select max(c1) from $stb where ts >= $ts0 and ts <= $tsu soffset 5 +#sql_error select max(c1) from $stb where ts >= $ts0 and ts <= $tsu limit 5 soffset 1 +#sql_error select max(c1) from $stb where ts >= $ts0 and ts <= $tsu slimit 5 offset 1 +#sql_error select top(c1, 1) from $stb where ts >= $ts0 and ts <= $tsu slimit 5 offset 1 +#sql_error select bottom(c1, 1) from $stb where ts >= $ts0 and ts <= $tsu slimit 5 offset 1 + +sql_error select t1 from $stb slimit 5 offset 1; + +### select from stb + group by + slimit offset +sql select max(c1), min(c2), avg(c3), sum(c4), spread(c5), sum(c6), count(c7), first(c8), last(c9) from $stb group by t1 slimit 5 soffset 0 +if $rows != 5 then + return -1 +endi +#if $data08 != NULL then +#if $data08 != 涛思nchar9 then +# return -1 +#endi +$res = $tbPrefix . 0 +if $data09 != $res then + return -1 +endi +$res = $tbPrefix . 1 +if $data19 != $res then + return -1 +endi +$res = $tbPrefix . 4 +if $data49 != $res then + return -1 +endi + +#sql reset query cache +sql select max(c1), min(c2), avg(c3), sum(c4), spread(c5), sum(c6), count(c7), first(c8), last(c9) from $stb group by t1 order by t1 asc slimit 5 +if $rows != 5 then + return -1 +endi +if $data00 != 9 then + return -1 +endi +$res = $tbPrefix . 0 +print res = $res +if $data09 != $res then + return -1 +endi +$res = $tbPrefix . 4 +if $data49 != $res then + return -1 +endi + +## asc +sql select max(c1), min(c2), avg(c3), sum(c4), spread(c5), sum(c6), count(c7), first(c8), last(c9) from $stb group by t1 order by t1 asc slimit 4 soffset 1 +if $rows != 4 then + return -1 +endi +if $data00 != 9 then + return -1 +endi +$res = $tbPrefix . 1 +if $data09 != $res then + return -1 +endi +$res = $tbPrefix . 4 +if $data39 != $res then + return -1 +endi +## desc +sql select max(c1), min(c2), avg(c3), sum(c4), spread(c5), sum(c6), count(c7), first(c8), last(c9) from $stb group by t1 order by t1 desc slimit 4 soffset 1 +if $rows != 4 then + return -1 +endi +if $data00 != 9 then + return -1 +endi +$res = $tbPrefix . 8 +if $data09 != $res then + return -1 +endi +$res = $tbPrefix . 5 +if $data39 != $res then + return -1 +endi + +### limit + slimit +sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb group by t1 order by t1 asc slimit 4 soffset 1 limit 0 +if $rows != 0 then + return -1 +endi + +sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb group by t1 order by t1 asc slimit 4 soffset 1 limit 2 offset 1 +if $rows != 0 then + return -1 +endi + +sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb group by t1,t2 order by t1 asc slimit 4 soffset 1 limit 1 offset 0 +if $rows != 4 then + return -1 +endi +if $data00 != 9 then + return -1 +endi +$res = $tbPrefix . 1 +if $data08 != $res then + return -1 +endi +print data09 = $data09 +if $data09 != 1 then + return -1 +endi +$res = $tbPrefix . 4 +if $data38 != $res then + return -1 +endi +if $data39 != 4 then + return -1 +endi + +sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb group by t1,t2 order by t1 desc slimit 4 soffset 1 limit 1 offset 0 +if $rows != 4 then + return -1 +endi +$res = $tbPrefix . 8 +if $data08 != $res then + return -1 +endi +if $data09 != 8 then + return -1 +endi +$res = $tbPrefix . 5 +if $data38 != $res then + return -1 +endi +if $data39 != 5 then + return -1 +endi + +sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 5 group by t1,t2,t3 order by t1 asc slimit 3 soffset 1 limit 1 offset 0 +if $rows != 3 then + return -1 +endi +if $data00 != 9 then + return -1 +endi +$res = $tbPrefix . 3 +if $data08 != $res then + return -1 +endi +if $data09 != 3 then + return -1 +endi +$res = $tbPrefix . 4 +if $data18 != $res then + return -1 +endi +if $data19 != 4 then + return -1 +endi +$res = $tbPrefix . 5 +if $data28 != $res then + return -1 +endi +if $data29 != 5 then + return -1 +endi + +### slimit + fill +sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 5 interval(5m) fill(value, -1, -2) group by t1 slimit 4 soffset 4 limit 0 offset 0 +if $rows != 0 then + return -1 +endi + +sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 9 interval(5m) fill(value, -1, -2) group by t1 slimit 4 soffset 4 limit 2 offset 0 +print select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 9 interval(5m) fill(value, -1, -2) group by t1 slimit 4 soffset 4 limit 2 offset 0 +print $rows $data00 $data01 $data02 $data03 +if $rows != 8 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data09 != slm_tb6 then + return -1 +endi +if $data10 != @18-09-17 09:05:00.000@ then + return -1 +endi +if $data11 != -1 then + return -1 +endi +if $data12 != -2 then + return -1 +endi +if $data13 != -2.000000000 then + return -1 +endi +if $data17 != NULL then + return -1 +endi +if $data18 != NULL then + return -1 +endi +if $data19 != slm_tb6 then + return -1 +endi +if $data20 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data21 != 0 then + return -1 +endi +if $data29 != slm_tb7 then + return -1 +endi +if $data30 != @18-09-17 09:05:00.000@ then + return -1 +endi +if $data31 != -1 then + return -1 +endi +if $data36 != -2 then + return -1 +endi +if $data39 != slm_tb7 then + return -1 +endi +if $data40 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data49 != slm_tb8 then + return -1 +endi +if $data50 != @18-09-17 09:05:00.000@ then + return -1 +endi +if $data59 != slm_tb8 then + return -1 +endi +if $data69 != slm_tb9 then + return -1 +endi +if $data79 != slm_tb9 then + return -1 +endi +# desc +sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 9 interval(5m) fill(value, -1, -2) group by t1 order by t1 desc slimit 4 soffset 4 limit 2 offset 0 +if $rows != 8 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data09 != slm_tb5 then + return -1 +endi +if $data10 != @18-09-17 09:05:00.000@ then + return -1 +endi +if $data11 != -1 then + return -1 +endi +if $data12 != -2 then + return -1 +endi +if $data13 != -2.000000000 then + return -1 +endi +if $data17 != NULL then + return -1 +endi +if $data18 != NULL then + return -1 +endi +if $data19 != slm_tb5 then + return -1 +endi +if $data20 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data21 != 0 then + return -1 +endi +if $data29 != slm_tb4 then + return -1 +endi +if $data30 != @18-09-17 09:05:00.000@ then + return -1 +endi +if $data31 != -1 then + return -1 +endi +if $data36 != -2 then + return -1 +endi +if $data39 != slm_tb4 then + return -1 +endi +if $data40 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data49 != slm_tb3 then + return -1 +endi +if $data50 != @18-09-17 09:05:00.000@ then + return -1 +endi +if $data59 != slm_tb3 then + return -1 +endi +if $data69 != slm_tb2 then + return -1 +endi +if $data79 != slm_tb2 then + return -1 +endi + +sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 9 interval(5m) fill(value, -1, -2) group by t1 order by t1 asc slimit 4 soffset 4 limit 2 offset 598 +if $rows != 4 then + return -1 +endi +if $data00 != @18-09-19 10:50:00.000@ then + return -1 +endi +if $data01 != 9 then + return -1 +endi +if $data09 != slm_tb6 then + return -1 +endi +if $data10 != @18-09-19 10:50:00.000@ then + return -1 +endi +if $data12 != 9 then + return -1 +endi +if $data13 != 9.000000000 then + return -1 +endi +if $data19 != slm_tb7 then + return -1 +endi +if $data20 != @18-09-19 10:50:00.000@ then + return -1 +endi +if $data24 != 9.000000000 then + return -1 +endi +if $data29 != slm_tb8 then + return -1 +endi +if $data30 != @18-09-19 10:50:00.000@ then + return -1 +endi +if $data35 != 9 then + return -1 +endi +if $data36 != 1 then + return -1 +endi +if $data37 != binary9 then + return -1 +endi +if $data38 != 涛思nchar9 then + return -1 +endi +if $data39 != slm_tb9 then + return -1 +endi + +sql select count(ts) from $stb group by t1,t2,t3,t4,t5,t6 order by t1 desc +if $rows != $tbNum then + return -1 +endi +$res = $rowNum + 1 +if $data00 != $res then + return -1 +endi +if $data90 != $res then + return -1 +endi +if $data01 != slm_tb9 then + return -1 +endi +if $data12 != 8 then + return -1 +endi +if $data23 != 7 then + return -1 +endi +if $data34 != 涛思slm_tb6 then + return -1 +endi +if $data45 != 5.000000000 then + return -1 +endi +if $data56 != 1 then + return -1 +endi +$res = $rowNum + 1 +if $data60 != $res then + return -1 +endi +if $data71 != slm_tb2 then + return -1 +endi + +sql select count(c1) from $stb group by t1,t2,t3,t4,t5,t6 order by t1 desc +if $rows != 10 then + return -1 +endi +if $data00 != $rowNum then + return -1 +endi +if $data90 != $rowNum then + return -1 +endi +if $data01 != slm_tb9 then + return -1 +endi +if $data12 != 8 then + return -1 +endi +if $data23 != 7 then + return -1 +endi +if $data34 != 涛思slm_tb6 then + return -1 +endi +if $data45 != 5.000000000 then + return -1 +endi +if $data56 != 1 then + return -1 +endi +if $data60 != $rowNum then + return -1 +endi +if $data71 != slm_tb2 then + return -1 +endi + +## [TBASE-604] +#sql_error select count(tbname) from slm_stb0 group by t1 +#sql show databases + +## [TBASE-605] +sql_error select * from slm_stb0 where t2 >= 2 and t3 <= 9 group by tbname slimit 40 limit 1; + + +################################################## +# slm_db1 is a database that contains the exactly the same +# schema as slm_db0, but all records in slm_db1 contains +# only NULL values. +$db = $dbPrefix . 1 +sql use $db + +### +sql select count(*) from $stb +if $rows != 1 then + return -1 +endi +if $data00 != $totalNum then + return -1 +endi + +sql select count(c1) from $stb +if $rows != 0 then + return -1 +endi + +sql select count(ts) from $stb group by t1,t2,t3,t4,t5,t6 order by t1 asc +if $rows != $tbNum then + return -1 +endi +if $data00 != $rowNum then + return -1 +endi +if $data90 != $rowNum then + return -1 +endi +if $data01 != slm_tb0 then + return -1 +endi +if $data12 != 1 then + return -1 +endi +if $data23 != 2 then + return -1 +endi +if $data34 != 涛思slm_tb3 then + return -1 +endi +if $data45 != 4.000000000 then + return -1 +endi +if $data56 != 1 then + return -1 +endi +if $data60 != $rowNum then + return -1 +endi +if $data71 != slm_tb7 then + return -1 +endi +sql select count(ts) from $stb group by t1,t2,t3,t4,t5,t6 order by t1 desc +if $rows != $tbNum then + return -1 +endi +if $data00 != $rowNum then + return -1 +endi +if $data90 != $rowNum then + return -1 +endi +if $data01 != slm_tb9 then + return -1 +endi +if $data12 != 8 then + return -1 +endi +if $data23 != 7 then + return -1 +endi +if $data34 != 涛思slm_tb6 then + return -1 +endi +if $data45 != 5.000000000 then + return -1 +endi +if $data56 != 1 then + return -1 +endi +if $data60 != $rowNum then + return -1 +endi +if $data71 != slm_tb2 then + return -1 +endi + +sql select count(c1) from $stb group by t1,t2,t3,t4,t5,t6 order by t1 desc +if $rows != 0 then + return -1 +endi + diff --git a/tests/script/general/parser/stableOp.sim b/tests/script/general/parser/stableOp.sim new file mode 100644 index 0000000000000000000000000000000000000000..8647657e7bee1ea73dcdbdc6f346e2279dd58cd5 --- /dev/null +++ b/tests/script/general/parser/stableOp.sim @@ -0,0 +1,95 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 100 +sql connect +print ======================== dnode1 start + +$dbPrefix = fi_in_db +$tbPrefix = fi_in_tb +$stbPrefix = fi_in_stb +$mtPrefix = fi_in_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print create_tb test +print =============== set up +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +$stb = $stbPrefix . $i + +sql create database $db +sql use $db + +# case1: create stable test +print =========== stableOp.sim case1: create/alter/drop stable test +sql CREATE STABLE $stb (TS TIMESTAMP, COL1 INT) TAGS (ID INT); +sql show stables + +if $rows != 1 then + return -1 +endi +print data00 = $data00 +if $data00 != $stb then + return -1 +endi + +sql_error CREATE STABLE $tb using $stb tags (1); + +sql create table $tb using $stb tags (2); +sql show tables + +if $rows != 1 then + return -1 +endi + +sql alter stable $stb add column COL2 DOUBLE; + +sql insert into $tb values (now, 1, 2.0); + +sql select * from $tb ; + +if $rows != 1 then + return -1 +endi + +sql alter stable $stb drop column COL2; + +sql_error insert into $tb values (now, 1, 2.0); + +sql alter stable $stb add tag tag2 int; + +sql alter stable $stb change tag tag2 tag3; + +sql_error drop stable $tb + +sql drop table $tb ; + +sql show tables + +if $rows != 0 then + return -1 +endi + +sql DROP STABLE $stb +sql show stables + +if $rows != 0 then + return -1 +endi + +print create/alter/drop stable test passed + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/tags_dynamically_specifiy.sim b/tests/script/general/parser/tags_dynamically_specifiy.sim new file mode 100644 index 0000000000000000000000000000000000000000..f6b3dabf153e502b598d1bea8545db3232ceef2d --- /dev/null +++ b/tests/script/general/parser/tags_dynamically_specifiy.sim @@ -0,0 +1,105 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect +sleep 100 + +$db = dytag_db +$tbNum = 10 +$rowNum = 5 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== tags_dynamically_specify.sim +$i = 0 + +sql drop database if exists $db +sql create database $db +sql use $db + +sql create table stb (ts timestamp, c1 binary(10), c2 int, c3 float) tags (t1 binary(10), t2 int, t3 float) + +sql insert into tb1 using stb (t1) tags ('tag1') values ( now + 1s, 'binary1', 1, 1.1) +sql insert into tb2 using stb (t2) tags (2) values ( now + 2s, 'binary2', 2, 2.2) +sql insert into tb3 using stb (t3) tags (3.3) values ( now + 3s, 'binary3', 3, 3.3) + +sql insert into tb4 (ts, c1, c2) using stb (t1, t2) tags ('tag4', 4) values ( now + 4s, 'binary4', 4) +sql insert into tb5 (ts, c1, c3) using stb (t1, t3) tags ('tag5', 11.11) values ( now + 5s, 'binary5', 5.5) +sql insert into tb6 (ts, c1, c3) using stb tags ('tag5', 6, 11.11) values ( now + 5s, 'binary6', 6.6) +sql insert into tb7 (ts, c1, c2, c3) using stb tags ('tag5', 7, 11.11) values ( now + 5s, 'binary7', 7, 7.7) +sql select * from stb order by ts asc +if $rows != 7 then + return -1 +endi + +sql_error insert into tb11 using stb (t1) tags () values ( now + 1s, 'binary1', 1, 1.1) +sql_error insert into tb12 using stb (t1, t3) tags () values ( now + 1s, 'binary1', 1, 1.1) +sql_error insert into tb13 using stb (t1, t2, t3) tags (8, 9.13, 'ac') values ( now + 1s, 'binary1', 1, 1.1) +sql_error insert into tb14 using stb () tags (2) values ( now + 2s, 'binary2', 2, 2.2) +sql_error insert into tb15 using stb (t2, t3) tags (3.3) values ( now + 3s, 'binary3', 3, 3.3) +sql_error insert into tb16 (ts, c1, c2) using stb (t1, t2) tags ('tag4', 4) values ( now + 4s, 'binary4') +sql_error insert into tb17 (ts, c1, c3) using stb (t1, t3) tags ('tag5', 11.11, 5) values ( now + 5s, 'binary5', 5.5) +sql_error insert into tb18 (ts, c1, c3) using stb tags ('tag5', 16) values ( now + 5s, 'binary6', 6.6) +sql_error insert into tb19 (ts, c1, c2, c3) using stb tags (19, 'tag5', 91.11) values ( now + 5s, 'binary7', 7, 7.7) + + + +sql create table stbx (ts timestamp, c1 binary(10), c2 int, c3 float) tags (t1 binary(10), t2 int, t3 float) +sql insert into tb100 (ts, c1, c2, c3) using stbx (t1, t2, t3) tags ('tag100', 100, 100.123456) values ( now + 10s, 'binary100', 100, 100.9) tb101 (ts, c1, c2, c3) using stbx (t1, t2, t3) tags ('tag101', 101, 101.9) values ( now + 10s, 'binary101', 101, 101.9) tb102 (ts, c1, c2, c3) using stbx (t1, t2, t3) tags ('tag102', 102, 102.9) values ( now + 10s, 'binary102', 102, 102.9) + +sql select * from stbx +if $rows != 3 then + return -1 +endi + +if $data04 != tag100 then + return -1 +endi + +if $data05 != 100 then + return -1 +endi + +if $data06 != 100.12346 then + print "expect: 100.12346, act: $data06" + return -1 +endi + +sql create table stby (ts timestamp, c1 binary(10), c2 int, c3 float) tags (t1 binary(10), t2 int, t3 float) +sql reset query cache +sql insert into tby1 using stby (t1) tags ('tag1') values ( now + 1s, 'binary1', 1, 1.1) +sql insert into tby2 using stby (t2) tags (2) values ( now + 2s, 'binary2', 2, 2.2) +sql insert into tby3 using stby (t3) tags (3.3) values ( now + 3s, 'binary3', 3, 3.3) +sql insert into tby4 (ts, c1, c2) using stby (t1, t2) tags ('tag4', 4) values ( now + 4s, 'binary4', 4) +sql insert into tby5 (ts, c1, c3) using stby (t1, t3) tags ('tag5', 11.11) values ( now + 5s, 'binary5', 5.5) +sql insert into tby6 (ts, c1, c3) using stby tags ('tag5', 6, 11.11) values ( now + 5s, 'binary6', 6.6) +sql insert into tby7 (ts, c1, c2, c3) using stby tags ('tag5', 7, 11.11) values ( now + 5s, 'binary7', 7, 7.7) +sql select * from stby order by ts asc +if $rows != 7 then + return -1 +endi + +sql reset query cache +sql insert into tby1 using stby (t1) tags ('tag1') values ( now + 1s, 'binary1y', 1, 1.1) +sql insert into tby2 using stby (t2) tags (2) values ( now + 2s, 'binary2y', 2, 2.2) +sql insert into tby3 using stby (t3) tags (3.3) values ( now + 3s, 'binary3y', 3, 3.3) +sql insert into tby4 (ts, c1, c2) using stby (t1, t2) tags ('tag4', 4) values ( now + 4s, 'binary4y', 4) +sql insert into tby5 (ts, c1, c3) using stby (t1, t3) tags ('tag5', 11.11) values ( now + 5s, 'binary5y', 5.5) +sql insert into tby6 (ts, c1, c3) using stby tags ('tag5', 6, 11.11) values ( now + 5s, 'binary6y', 6.6) +sql insert into tby7 (ts, c1, c2, c3) using stby tags ('tag5', 7, 11.11) values ( now + 5s, 'binary7y', 7, 7.7) + +sql select * from stby order by ts asc +if $rows != 14 then + return -1 +endi + +print ===============================> td-1765 +sql create table m1(ts timestamp, k int) tags(a binary(4), b nchar(4)); +sql create table tm0 using m1 tags('abcd', 'abcd'); +sql_error alter table tm0 set tag b = 'abcd1'; +sql_error alter table tm0 set tag a = 'abcd1'; + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/parser/tags_filter.sim b/tests/script/general/parser/tags_filter.sim new file mode 100644 index 0000000000000000000000000000000000000000..3d3e79b6f52928af9d3333810f57300e52e0ebb0 --- /dev/null +++ b/tests/script/general/parser/tags_filter.sim @@ -0,0 +1,208 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$db = tf_db +$tbNum = 10 +$rowNum = 5 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== tags_filter.sim +$i = 0 + +sql drop database if exists $db +sql create database $db +sql use $db +##### filter tags that contains special characters +sql create table stb (ts timestamp, c1 int) tags (t1 binary(10)) +sql create table tb1 using stb tags('*') +sql create table tb2 using stb tags('%') +sql create table tb3 using stb tags('') +sql create table tb4 using stb tags('\'') + +sql insert into tb1 values ( $ts0 , 1) +sql insert into tb2 values ( $ts0 , 2) +sql insert into tb3 values ( $ts0 , 3) +sql insert into tb4 values ( $ts0 , 4) + +sql select * from stb where t1 = '*' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +sql select * from stb where t1 = '%' +if $rows != 1 then + return -1 +endi +if $data01 != 2 then + return -1 +endi + +sql select * from stb where t1 = '' +if $rows != 1 then + return -1 +endi +if $data01 != 3 then + return -1 +endi + +sql select * from stb where t1 = '\'' +if $rows != 1 then + return -1 +endi +if $data01 != 4 then + return -1 +endi + +sql select * from stb where t1 like '*' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +sql select * from stb where t1 > '1' +sql select * from stb where t1 > 'a' + +print =====================> TD-2685 +sql_error select t1, count(t1) from stb; + +## wildcard '%' +#sql select * from stb where t1 like '%' +#if $rows != 1 then +# return -1 +#endi +#if $data01 != 2 then +# return -1 +#endi + +sql select * from stb where t1 like '' +if $rows != 1 then + return -1 +endi +if $data01 != 3 then + return -1 +endi + +sql select * from stb where t1 like '\'' +if $rows != 1 then + return -1 +endi +if $data01 != 4 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +print ============tbase-1328 + +sql drop database if exists testselectwheretags; +sql CREATE DATABASE IF NOT EXISTS testselectwheretags; +sql USE testselectwheretags; +sql CREATE TABLE IF NOT EXISTS st1 (ts TIMESTAMP, v1 INT, v2 FLOAT, v3 BOOL) TAGS (farm NCHAR(2), period NCHAR(2), line NCHAR(2), unit INT); +sql CREATE TABLE IF NOT EXISTS a01 USING st1 TAGS ('2', 'c', '2', 2); +sql CREATE TABLE IF NOT EXISTS a02 USING st1 TAGS ('1', 'c', 'a', 1); +sql CREATE TABLE IF NOT EXISTS a03 USING st1 TAGS ('1', 'c', '02', 1); +sql INSERT INTO a01 VALUES (1574872693209, 3, 3.000000, 1); +sql INSERT INTO a02 VALUES (1574872683933, 2, 2.000000, 1); +sql INSERT INTO a03 VALUES (1574872683933, 2, 2.000000, 1); + +sql select * from st1 where line='02'; +if $rows != 1 then + return -1 +endi + +sql CREATE TABLE IF NOT EXISTS st2 (ts TIMESTAMP, v1 INT, v2 FLOAT) TAGS (farm BINARY(2), period BINARY(2), line BINARY(2)); + +sql CREATE TABLE IF NOT EXISTS b01 USING st2 TAGS ('01', '01', '01'); +sql CREATE TABLE IF NOT EXISTS b02 USING st2 TAGS ('01', '01', '01'); +sql CREATE TABLE IF NOT EXISTS b03 USING st2 TAGS ('01', '02', '01'); +sql CREATE TABLE IF NOT EXISTS b04 USING st2 TAGS ('01', '01', '02'); + +sql INSERT INTO b03 VALUES (1576043322749, 3, 3.000000); +sql INSERT INTO b03 VALUES (1576043323596, 3, 3.000000); + +sql INSERT INTO b02 VALUES (1576043315169, 2, 2.000000); +sql INSERT INTO b02 VALUES (1576043316295, 2, 2.000000); +sql INSERT INTO b02 VALUES (1576043317167, 2, 2.000000); + +sql INSERT INTO b01 VALUES (1576043305972, 1, 1.000000); +sql INSERT INTO b01 VALUES (1576043308513, 1, 1.000000); + +sql select * from st2 where period='02'; +if $rows != 2 then + return -1 +endi + +sql select sum(v2) from st2 group by farm,period,line; +if $rows != 2 then + return -1 +endi + +print ==================>td-2424 +sql create table t1(ts timestamp, k float) +sql insert into t1 values(now, 8.001) +sql select * from t1 where k=8.001 +if $rows != 1 then + return -1 +endi + +sql select * from t1 where k<8.001 +if $rows != 0 then + return -1 +endi + +sql select * from t1 where k<=8.001 +if $rows != 1 then + return -1 +endi + +sql select * from t1 where k>8.001 +if $rows != 0 then + return -1 +endi + +sql select * from t1 where k>=8.001 +if $rows != 1 then + return -1 +endi + +sql select * from t1 where k<>8.001 +if $rows != 0 then + return -1 +endi + +sql select * from t1 where k>=8.001 and k<=8.001 +if $rows != 1 then + return -1 +endi + +sql select * from t1 where k>=8.0009999 and k<=8.001 +if $rows != 1 then + return -1 +endi + +sql select * from t1 where k>8.001 and k<=8.001 +if $rows != 0 then + return -1 +endi + +sql select * from t1 where k>=8.001 and k<8.001 +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/parser/tbnameIn.sim b/tests/script/general/parser/tbnameIn.sim new file mode 100644 index 0000000000000000000000000000000000000000..003a86f90b2f36602b4e999aee2974ef259d3670 --- /dev/null +++ b/tests/script/general/parser/tbnameIn.sim @@ -0,0 +1,76 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = ti_db +$tbPrefix = ti_tb +$stbPrefix = ti_stb +$tbNum = 2000 +$rowNum = 10 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +$tsu = $rowNum * $delta +$tsu = $tsu - $delta +$tsu = $tsu + $ts0 + +print ========== tbnameIn.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +print ====== create tables +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int, t2 nchar(20), t3 binary(20), t4 bigint, t5 smallint, t6 double) + +$i = 0 +$ts = $ts0 +$halfNum = $tbNum / 2 +while $i < $halfNum + $i1 = $i + $halfNum + $tb = $tbPrefix . $i + $tb1 = $tbPrefix . $i1 + $tgstr = 'tb . $i + $tgstr = $tgstr . ' + $tgstr1 = 'tb . $i1 + $tgstr1 = $tgstr1 . ' + sql create table $tb using $stb tags( $i , $tgstr , $tgstr , $i , $i , $i ) + sql create table $tb1 using $stb tags( $i1 , $tgstr1 , $tgstr1 , $i , $i , $i ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) $tb1 values ( $ts , $c , NULL , $c , NULL , $c , $c , true, $binary , $nchar ) + $x = $x + 1 + endw + + $i = $i + 1 +endw +print ====== tables created + +run general/parser/tbnameIn_query.sim + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 500 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed + +run general/parser/tbnameIn_query.sim + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/parser/tbnameIn_query.sim b/tests/script/general/parser/tbnameIn_query.sim new file mode 100644 index 0000000000000000000000000000000000000000..db27886bbfde744910068b702199e2079d24c7d2 --- /dev/null +++ b/tests/script/general/parser/tbnameIn_query.sim @@ -0,0 +1,457 @@ +sleep 100 +sql connect + +$dbPrefix = ti_db +$tbPrefix = ti_tb +$stbPrefix = ti_stb +$tbNum = 2000 +$rowNum = 10 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +$tsu = $rowNum * $delta +$tsu = $tsu - $delta +$tsu = $tsu + $ts0 + +print ========== tbnameIn_query.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i +$tb = $tbPrefix . 0 +print ====== use db +sql use $db + +#### tbname in + other tag filtering +## [TBASE-362] +# tbname in + tag filtering is allowed now!!! +sql select count(*) from $stb where tbname in ('ti_tb1', 'ti_tb300') and t1 > 2 + +# tbname in used on meter +sql_error select count(*) from $tb where tbname in ('ti_tb1', 'ti_tb300') + +## tbname in + group by tag +sql select count(*) from $stb where tbname in ('ti_tb1', 'ti_tb300') group by t1 order by t1 asc +if $rows != 2 then + return -1 +endi +if $data00 != $rowNum then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != $rowNum then + return -1 +endi +if $data11 != 300 then + return -1 +endi + +## duplicated tbnames +sql select count(*) from $stb where tbname in ('ti_tb1', 'ti_tb1', 'ti_tb1', 'ti_tb2', 'ti_tb2', 'ti_tb3') group by t1 order by t1 asc +if $rows != 3 then + return -1 +endi +if $data00 != $rowNum then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != $rowNum then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data20 != $rowNum then + return -1 +endi +if $data21 != 3 then + return -1 +endi + +## wrong tbnames +sql select count(*) from $stb where tbname in ('tbname in', 'ti_tb1', 'ti_stb0') group by t1 order by t1 +if $rows != 1 then + return -1 +endi +if $data00 != 10 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +## tbname in + colummn filtering +sql select count(*) from $stb where tbname in ('tbname in', 'ti_tb1', 'ti_stb0', 'ti_tb2') and c8 like 'binary%' group by t1 order by t1 asc +if $rows != 2 then + return -1 +endi +if $data00 != 10 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != 10 then + return -1 +endi +if $data11 != 2 then + return -1 +endi + +## tbname in can accpet Upper case table name +sql select count(*) from $stb where tbname in ('ti_tb0', 'TI_tb1', 'TI_TB2') group by t1 order by t1 +if $rows != 3 then + return -1 +endi +if $data00 != 10 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data10 != 10 then + return -1 +endi +if $data11 != 1 then + return -1 +endi +if $data20 != 10 then + return -1 +endi +if $data21 != 2 then + return -1 +endi + +# multiple tbname in is not allowed NOW +sql_error select count(*) from $stb where tbname in ('ti_tb1', 'ti_tb300') and tbname in ('ti_tb5', 'ti_tb1000') group by t1 order by t1 asc +#if $rows != 4 then +# return -1 +#endi +#if $data00 != $rowNum then +# return -1 +#endi +#if $data01 != 1 then +# return -1 +#endi +#if $data10 != $rowNum then +# return -1 +#endi +#if $data11 != 5 then +# return -1 +#endi +#if $data20 != $rowNum then +# return -1 +#endi +#if $data21 != 300 then +# return -1 +#endi +#if $data30 != $rowNum then +# return -1 +#endi +#if $data31 != 1000 then +# return -1 +#endi + +#### aggregation on stb with 6 tags + where + group by + limit offset +#$val1 = 1 +#$val2 = $tbNum - 1 +#sql select count(*) from $stb where t1 > $val1 and t1 < $val2 group by t1, t2, t3, t4, t5, t6 order by t1 asc limit 1 offset 0 +#$val = $tbNum - 3 +#if $rows != $val then +# return -1 +#endi +#if $data00 != $rowNum then +# return -1 +#endi +#if $data01 != 2 then +# return -1 +#endi +#if $data02 != tb2 then +# return -1 +#endi +#if $data03 != tb2 then +# return -1 +#endi +#if $data04 != 2 then +# return -1 +#endi +#if $data05 != 2 then +# return -1 +#endi +# +#sql select count(*) from $stb where t2 like '%' and t1 > 2 and t1 < 5 group by t3, t4 order by t3 desc limit 1 offset 0 +#if $rows != 2 then +# return -1 +#endi +#if $data00 != $rowNum then +# return -1 +#endi +#if $data01 != tb4 then +# return -1 +#endi +#if $data02 != 4 then +# return -1 +#endi +#if $data11 != tb3 then +# return -1 +#endi +#if $data12 != 3 then +# return -1 +#endi +#sql select count(*) from $stb where t2 like '%' and t1 > 2 and t1 < 5 group by t3, t4 order by t3 desc limit 1 offset 1 +#if $rows != 0 then +# return -1 +#sql_error select count(*) from $stb where t1 like 1 +# +###### aggregation on tb + where + fill + limit offset +#sql select max(c1) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, -1, -2) limit 10 offset 1 +#if $rows != 10 then +# return -1 +#endi +#if $data00 != @18-09-17 09:05:00.000@ then +# return -1 +#endi +#if $data01 != -1 then +# return -1 +#endi +#if $data11 != 1 then +# return -1 +#endi +#if $data90 != @18-09-17 09:50:00.000@ then +# return -1 +#endi +#if $data91 != 5 then +# return -1 +#endi +# +#$tb5 = $tbPrefix . 5 +#sql select max(c1), min(c2) from $tb5 where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, -1, -2, -3, -4) limit 10 offset 1 +#if $rows != 10 then +# return -1 +#endi +#if $data00 != @18-09-17 09:05:00.000@ then +# return -1 +#endi +#if $data01 != -1 then +# return -1 +#endi +#if $data02 != -2 then +# return -1 +#endi +#if $data11 != 1 then +# return -1 +#endi +#if $data12 != -2 then +# return -1 +#endi +#if $data90 != @18-09-17 09:50:00.000@ then +# return -1 +#endi +#if $data91 != 5 then +# return -1 +#endi +#if $data92 != -2 then +# return -1 +#endi +# +#### [TBASE-350] +### tb + interval + fill(value) + limit offset +#$tb = $tbPrefix . 0 +#$limit = $rowNum +#$offset = $limit / 2 +#sql select max(c1), min(c2), sum(c3), avg(c4), stddev(c5), spread(c6), first(c7), last(c8), first(c9) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, -1, -2) limit $limit offset $offset +#if $rows != $limit then +# return -1 +#endi +#if $data01 != 0 then +# return -1 +#endi +#if $data11 != -1 then +# return -1 +#endi +# +## tb + interval + fill(linear) + limit offset +#$limit = $rowNum +#$offset = $limit / 2 +#sql select max(c1), min(c2), sum(c3), avg(c4), stddev(c5), spread(c6), first(c7), last(c8), first(c9) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(linear) limit $limit offset $offset +#if $rows != $limit then +# return -1 +#endi +#if $data01 != 0 then +# return -1 +#endi +#if $data11 != 0 then +# return -1 +#endi +#if $data13 != 0.500000000 then +# return -1 +#endi +#if $data35 != 0.000000000 then +# return -1 +#endi +#if $data46 != 0.000000000 then +# return -1 +#endi +#if $data47 != true then +# return -1 +#endi +#if $data57 != NULL then +# return -1 +#endi +#if $data68 != binary3 then +# return -1 +#endi +#if $data79 != NULL then +# return -1 +#endi +# +### tb + interval + fill(prev) + limit offset +#$limit = $rowNum +#$offset = $limit / 2 +#sql select max(c1), min(c2), sum(c3), avg(c4), stddev(c5), spread(c6), first(c7), last(c8), first(c9) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(prev) limit $limit offset $offset +#if $rows != $limit then +# return -1 +#endi +# +# +#$limit = $rowNum +#$offset = $limit / 2 +#$offset = $offset + 10 +#sql select max(c1), min(c2), sum(c3), avg(c4), stddev(c5), spread(c6), first(c7), last(c8), first(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 = 5 interval(5m) fill(value, -1, -2) limit $limit offset $offset +#if $rows != $limit then +# return -1 +#endi +#if $data01 != 5 then +# return -1 +#endi +#if $data02 != 5 then +# return -1 +#endi +#if $data03 != 5.000000000 then +# return -1 +#endi +#if $data04 != 5.000000000 then +# return -1 +#endi +#if $data05 != 0.000000000 then +# return -1 +#endi +#if $data07 != true then +# return -1 +#endi +#if $data08 != binary5 then +# return -1 +#endi +#if $data09 != nchar5 then +# return -1 +#endi +#if $data18 != NULL then +# return -1 +#endi +#if $data19 != NULL then +# return -1 +#endi +#if $data16 != -2.000000000 then +# return -1 +#endi +#if $data17 != true then +# return -1 +#endi +#if $data11 != -1 then +# return -1 +#endi +# +#$limit = $rowNum +#$offset = $limit * 2 +#$offset = $offset - 11 +#sql select max(c1), min(c2), sum(c3), avg(c4), stddev(c5), spread(c6), first(c7), last(c8), first(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 = 5 interval(5m) fill(value, -1, -2) limit $limit offset $offset +#if $rows != 10 then +# return -1 +#endi +#if $data01 != -1 then +# return -1 +#endi +#if $data02 != -2 then +# return -1 +#endi +#if $data11 != 5 then +# return -1 +#endi +#if $data12 != 5 then +# return -1 +#endi +#if $data13 != 5.000000000 then +# return -1 +#endi +#if $data15 != 0.000000000 then +# return -1 +#endi +#if $data16 != 0.000000000 then +# return -1 +#endi +#if $data18 != binary5 then +# return -1 +#endi +#if $data19 != nchar5 then +# return -1 +#endi +#if $data27 != true then +# return -1 +#endi +#if $data38 != NULL then +# return -1 +#endi +#if $data49 != NULL then +# return -1 +#endi +# +#### [TBASE-350] +### stb + interval + fill + group by + limit offset +#sql select max(c1), min(c2), sum(c3), avg(c4), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, -1, -2) group by t1 limit 2 offset 10 +#if $rows != 20 then +# return -1 +#endi +# +#$limit = 5 +#$offset = $rowNum * 2 +#$offset = $offset - 2 +#sql select max(c1), min(c2), sum(c3), avg(c4), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, -1, -2) group by t1 order by t1 limit $limit offset $offset +#if $rows != $tbNum then +# return -1 +#endi +#if $data00 != @18-11-25 19:30:00.000@ then +# return -1 +#endi +#if $data01 != 9 then +# return -1 +#endi +#if $data12 != -2 then +# return -1 +#endi +#if $data23 != 9.000000000 then +# return -1 +#endi +#if $data34 != -2.000000000 then +# return -1 +#endi +#if $data45 != true then +# return -1 +#endi +#if $data56 != binary9 then +# return -1 +#endi +#if $data68 != 3 then +# return -1 +#endi +#if $data72 != 9 then +# return -1 +#endi +#if $data84 != 9.000000000 then +# return -1 +#endi +#if $data98 != 0 then +# return -1 +#endi diff --git a/tests/script/general/parser/testSuite.sim b/tests/script/general/parser/testSuite.sim new file mode 100644 index 0000000000000000000000000000000000000000..fcd9d49fe555ae749da0fcd799e1866a8a05f656 --- /dev/null +++ b/tests/script/general/parser/testSuite.sim @@ -0,0 +1,68 @@ +run general/parser/alter.sim +run general/parser/alter1.sim +run general/parser/alter_stable.sim +run general/parser/auto_create_tb.sim +run general/parser/auto_create_tb_drop_tb.sim +run general/parser/col_arithmetic_operation.sim +run general/parser/columnValue.sim +run general/parser/commit.sim +run general/parser/create_db.sim +run general/parser/create_mt.sim +run general/parser/create_tb.sim +run general/parser/dbtbnameValidate.sim +run general/parser/fill.sim +run general/parser/fill_stb.sim +#run general/parser/fill_us.sim # +run general/parser/first_last.sim +run general/parser/import_commit1.sim +run general/parser/import_commit2.sim +run general/parser/import_commit3.sim +run general/parser/import_file.sim +run general/parser/insert_tb.sim +run general/parser/tags_dynamically_specifiy.sim +run general/parser/interp.sim +run general/parser/lastrow.sim +run general/parser/limit.sim +run general/parser/limit1.sim +run general/parser/limit1_tblocks100.sim +run general/parser/limit2.sim +run general/parser/mixed_blocks.sim +run general/parser/nchar.sim +run general/parser/null_char.sim +run general/parser/selectResNum.sim +run general/parser/select_across_vnodes.sim +run general/parser/select_from_cache_disk.sim +run general/parser/set_tag_vals.sim +run general/parser/single_row_in_tb.sim +run general/parser/slimit.sim +run general/parser/slimit1.sim +run general/parser/slimit_alter_tags.sim +run general/parser/tbnameIn.sim +run general/parser/join.sim +run general/parser/join_multivnode.sim +run general/parser/join_manyblocks.sim +run general/parser/projection_limit_offset.sim +run general/parser/select_with_tags.sim +run general/parser/select_distinct_tag.sim +run general/parser/groupby.sim +run general/parser/tags_filter.sim +run general/parser/topbot.sim +run general/parser/union.sim +run general/parser/constCol.sim +run general/parser/where.sim +run general/parser/timestamp.sim +run general/parser/sliding.sim +run general/parser/function.sim +run general/parser/stableOp.sim +run general/parser/having.sim +run general/parser/having_child.sim +run general/parser/slimit_alter_tags.sim +run general/parser/binary_escapeCharacter.sim +run general/parser/between_and.sim +run general/parser/last_cache.sim +run general/parser/slimit_alter_tags.sim +run general/parser/udf.sim +run general/parser/udf_dll.sim +run general/parser/udf_dll_stable.sim +run general/parser/nestquery.sim +run general/parser/precision_ns.sim diff --git a/tests/script/general/parser/timestamp.sim b/tests/script/general/parser/timestamp.sim new file mode 100644 index 0000000000000000000000000000000000000000..0a87bce51dedecf0c39179ffc7b1aa864b5e7823 --- /dev/null +++ b/tests/script/general/parser/timestamp.sim @@ -0,0 +1,68 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 4 + +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = ts_db +$tbPrefix = ts_tb +$stbPrefix = ts_stb +$tbNum = 10 +$rowNum = 300 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== timestamp.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database if exists $db +sql create database $db maxrows 200 +print ====== create tables +sql use $db +sql create table $stb (ts timestamp, c1 timestamp, c2 int) tags(t1 binary(20)) + +$i = 0 +$ts = $ts0 +$halfNum = $tbNum / 2 +while $i < $tbNum + $tb = $tbPrefix . $i + $t1 = ' . $tb + $t1 = $t1 . ' + sql create table $tb using $stb tags( $t1 ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = binary . $c + $nchar = '涛思nchar . $c + $nchar = $nchar . ' + sql insert into $tb values ( $ts , $ts , $c ) + $x = $x + 1 + endw + $ts = $ts + $delta + sql insert into $tb values ( $ts , NULL, NULL ) + $i = $i + 1 +endw +print ====== $db tables created + +run general/parser/timestamp_query.sim + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 100 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed +sql connect +sleep 100 + +run general/parser/timestamp_query.sim diff --git a/tests/script/general/parser/timestamp_query.sim b/tests/script/general/parser/timestamp_query.sim new file mode 100644 index 0000000000000000000000000000000000000000..3f6a1af4bc552d0bb54aedcb086e035c3b73bfd2 --- /dev/null +++ b/tests/script/general/parser/timestamp_query.sim @@ -0,0 +1,56 @@ +sleep 100 +sql connect + +$dbPrefix = ts_db +$tbPrefix = ts_tb +$stbPrefix = ts_stb +$tbNum = 10 +$rowNum = 300 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== timestamp_query.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +print ====== use db +sql use $db + +$tsu = $rowNum * $delta +$tsu = $tsu - $delta +$tsu = $tsu + $ts0 + +print ==================>issue #3481, normal column not allowed, +sql_error select ts,c1,min(c2) from ts_stb0 + +print ==================>issue #4681, not equal operator on primary timestamp not allowed +sql_error select * from ts_stb0 where ts <> $ts0 + +##### select from supertable +$tb = $tbPrefix . 0 +sql select first(c1), last(c1), (1537325400 - 1537146000)/(5*60) v from $tb where ts >= $ts0 and ts < $tsu interval(5m) fill(value, -1) +$res = $rowNum * 2 +$n = $res - 2 +print ============>$n +if $rows != $n then + print expect $n, actual $rows + return -1 +endi + +if $data03 != 598.000000000 then + print expect 598.000000000, actual $data03 + return -1 +endi + + +if $data13 != 598.000000000 then + print expect 598.000000000, actual $data03 + return -1 +endi + +sql select first(c1), last(c1), (1537325400 - 1537146000)/(5*60) v from $tb where ts >= $ts0 and ts < $tsu interval(5m) fill(value, NULL) +if $data13 != 598.000000000 then + print expect 598.000000000, actual $data03 + return -1 +endi diff --git a/tests/script/general/parser/top_groupby.sim b/tests/script/general/parser/top_groupby.sim new file mode 100644 index 0000000000000000000000000000000000000000..5709f4d1d7210761292d59aefa8984dad2fd2f23 --- /dev/null +++ b/tests/script/general/parser/top_groupby.sim @@ -0,0 +1,52 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 0 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2 +system sh/exec.sh -n dnode1 -s start + +sleep 100 +sql connect +print ======================== dnode1 start + +$db = testdb + +sql create database $db +sql use $db + +sql create stable st2 (ts timestamp, f1 int, f2 float, f3 double, f4 bigint, f5 smallint, f6 tinyint, f7 bool, f8 binary(10), f9 nchar(10)) tags (id1 int, id2 float, id3 nchar(10), id4 double, id5 smallint, id6 bigint, id7 binary(10)) + +sql create table tb1 using st2 tags (1,1.0,"1",1.0,1,1,"1"); + +sql insert into tb1 values (now-200s,1,1.0,1.0,1,1,1,true,"1","1") +sql insert into tb1 values (now-100s,2,2.0,2.0,2,2,2,true,"2","2") +sql insert into tb1 values (now,3,3.0,3.0,3,3,3,true,"3","3") +sql insert into tb1 values (now+100s,4,4.0,4.0,4,4,4,true,"4","4") +sql insert into tb1 values (now+200s,4,4.0,4.0,4,4,4,true,"4","4") +sql insert into tb1 values (now+300s,4,4.0,4.0,4,4,4,true,"4","4") +sql insert into tb1 values (now+400s,4,4.0,4.0,4,4,4,true,"4","4") +sql insert into tb1 values (now+500s,4,4.0,4.0,4,4,4,true,"4","4") + +sql select top(f1, 2) from tb1 group by f1; + +if $rows != 5 then + return -1 +endi + +sql select bottom(f1, 2) from tb1 group by f1; + +if $rows != 5 then + return -1 +endi + +sql select top(f1, 100) from tb1 group by f1; + +if $rows != 8 then + return -1 +endi + +sql select bottom(f1, 100) from tb1 group by f1; + +if $rows != 8 then + return -1 +endi + diff --git a/tests/script/general/parser/topbot.sim b/tests/script/general/parser/topbot.sim new file mode 100644 index 0000000000000000000000000000000000000000..ddab1b3f83acfc4fc454740093c3e4e003bab3d4 --- /dev/null +++ b/tests/script/general/parser/topbot.sim @@ -0,0 +1,380 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 200 + +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = tb_db +$tbPrefix = tb_tb +$stbPrefix = tb_stb +$tbNum = 10 +$rowNum = 1000 +$totalNum = $tbNum * $rowNum +$loops = 200000 +$log = 10000 +$ts0 = 1537146000000 +$delta = 600000 +print ========== topbot.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db cache 16 maxrows 4096 keep 36500 +print ====== create tables +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int) + +$i = 0 +$ts = $ts0 +$halfNum = $tbNum / 2 +while $i < $halfNum + $tbId = $i + $halfNum + $tb = $tbPrefix . $i + $tb1 = $tbPrefix . $tbId + sql create table $tb using $stb tags( $i ) + sql create table $tb1 using $stb tags( $tbId ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) + sql insert into $tb1 values ( $ts , $c , NULL , $c , NULL , $c , $c , true, $binary , $nchar ) + $x = $x + 1 + endw + + $i = $i + 1 +endw +print ====== tables created + +sql use $db +##### select from table +print ====== select top/bot from table and check num of rows returned +sql select top(c1, 100) from tb_stb0 +if $row != 100 then + return -1 +endi + +sql select bottom(c1, 100) from tb_stb0 +if $row != 100 then + return -1 +endi + +sql select bottom(c3, 5) from tb_tb1 interval(1y); +if $rows != 5 then + return -1 +endi + +if $data01 != 0.00000 then + print expect 0.00000, actual:$data01 + return -1 +endi + +if $data11 != 0.00000 then + return -1 +endi + +if $data21 != 0.00000 then + return -1 +endi + +if $data31 != 0.00000 then + return -1 +endi + +sql select top(c4, 5) from tb_tb1 interval(1y); +if $rows != 5 then + return -1 +endi + +if $data01 != 9.000000000 then + print expect 9.000000000, acutal:$data01 + return -1 +endi + +if $data11 != 9.000000000 then + return -1 +endi + +if $data21 != 9.000000000 then + return -1 +endi + +if $data31 != 9.000000000 then + return -1 +endi + +sql select top(c3, 5) from tb_tb1 interval(40h) +if $rows != 25 then + return -1 +endi + +if $data01 != 9.00000 then + print expect 9.00000, actual:$data01 + return -1 +endi + +sql select last(*) from tb_tb9 +if $row != 1 then + return -1 +endi + +sql select last(c2) from tb_tb9 +if $row != 0 then + return -1 +endi + +sql select first(c2), last(c2) from tb_tb9 +if $row != 0 then + return -1 +endi + +sql create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20)); +sql create table test1 using test tags('beijing'); +sql insert into test1 values(1537146000000, 1, 1, 1, 1, 0.100000, 0.100000, 0, 'taosdata1', '涛思数据1'); +sql insert into test1 values(1537146000001, 2, 2, 2, 2, 1.100000, 1.100000, 1, 'taosdata2', '涛思数据2'); +sql insert into test1 values(1537146000002, 3, 3, 3, 3, 2.100000, 2.100000, 0, 'taosdata3', '涛思数据3'); +sql insert into test1 values(1537146000003, 4, 4, 4, 4, 3.100000, 3.100000, 1, 'taosdata4', '涛思数据4'); +sql insert into test1 values(1537146000004, 5, 5, 5, 5, 4.100000, 4.100000, 0, 'taosdata5', '涛思数据5'); +sql insert into test1 values(1537146000005, 6, 6, 6, 6, 5.100000, 5.100000, 1, 'taosdata6', '涛思数据6'); +sql insert into test1 values(1537146000006, 7, 7, 7, 7, 6.100000, 6.100000, 0, 'taosdata7', '涛思数据7'); +sql insert into test1 values(1537146000007, 8, 8, 8, 8, 7.100000, 7.100000, 1, 'taosdata8', '涛思数据8'); +sql insert into test1 values(1537146000008, 9, 9, 9, 9, 8.100000, 8.100000, 0, 'taosdata9', '涛思数据9'); +sql insert into test1 values(1537146000009, 10, 10, 10, 10, 9.100000, 9.100000, 1, 'taosdata10', '涛思数据10'); +sql select bottom(col5, 10) from test +if $rows != 10 then + return -1 +endi + +if $data01 != 0.10000 then + print expect 0.10000 actual: $data01 + return -1 +endi + +if $data11 != 1.10000 then + print expect 1.10000 actual: $data11 + return -1 +endi + +if $data21 != 2.10000 then + print expect 2.10000 actual: $data21 + return -1 +endi + +print =====================td-1302 case +sql create database t1 keep 36500 +sql use t1; +sql create table test(ts timestamp, k int); +sql insert into test values(29999, 1)(70000, 2)(80000, 3) + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 500 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed +sql connect +sleep 100 + +sql select count(*) from t1.test where ts>10000 and ts<90000 interval(5000a) +if $rows != 3 then + return -1 +endi + +print ==============>td-1308 +sql create database db keep 36500 +sql use db; + +sql create table stb (ts timestamp, c1 int, c2 binary(10)) tags(t1 binary(10)); +sql create table tb1 using stb tags('a1'); + +sql insert into tb1 values('2020-09-03 15:30:48.812', 0, 'tb1'); +sql select count(*) from stb where ts > '2020-09-03 15:30:44' interval(4s); +if $rows != 1 then + return -1 +endi + +sql create table tb4 using stb tags('a4'); +sql select count(*) from stb where ts > '2020-09-03 15:30:44' interval(4s); +if $rows != 1 then + return -1 +endi + +print =======================>td-1446 +sql create table t(ts timestamp, k int) +$ts = 6000 +while $ts < 7000 + sql insert into t values ( $ts , $ts ) + $ts = $ts + 1 +endw + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s start +sql connect +sleep 100 +sql use db; + +$ts = 1000 +while $ts < 5096 + sql insert into t values ( $ts , $ts ) + $ts = $ts + 1 +endw + +sql select * from t where ts < 6500 +if $rows != 4596 then + print expect 4596, actual: $rows + return -1 +endi + +sql select * from t where ts < 7000 +if $rows != 5096 then + return -1 +endi + +sql select * from t where ts <= 6000 +if $rows != 4097 then + return -1 +endi + +sql select * from t where ts <= 6001 +if $rows != 4098 then + return -1 +endi + +print ======================>td-1454 +sql select count(*)/10, count(*)+99 from t +if $rows != 1 then + return -1 +endi + +if $data00 != 509.600000000 then + return -1 +endi + +if $data01 != 5195.000000000 then + return -1 +endi + +print =======================>td-1596 +sql create table t2(ts timestamp, k int) +sql insert into t2 values('2020-1-2 1:1:1', 1); +sql insert into t2 values('2020-2-2 1:1:1', 1); + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s start +sql connect +sleep 100 + +sql use db +sql select count(*), first(ts), last(ts) from t2 interval(1d); +if $rows != 2 then + return -1 +endi + +if $data00 != @20-01-02 00:00:00.000@ then + print expect 20-01-02 00:00:00.000, actual: $data00 + return -1 +endi + +if $data10 != @20-02-02 00:00:00.000@ then + return -1 +endi + +if $data01 != 1 then + return -1 +endi + +if $data11 != 1 then + return -1 +endi + +if $data02 != @20-01-02 01:01:01.000@ then + return -1 +endi + +if $data12 != @20-02-02 01:01:01.000@ then + return -1 +endi + +if $data03 != @20-01-02 01:01:01.000@ then + return -1 +endi + +if $data13 != @20-02-02 01:01:01.000@ then + return -1 +endi + +print ===============================>td-3361 +sql create table ttm1(ts timestamp, k int) tags(a nchar(12)); +sql create table ttm1_t1 using ttm1 tags('abcdef') +sql insert into ttm1_t1 values(now, 1) +sql select * from ttm1 where a=123456789012 +if $row != 0 then + return -1 +endi + +print ===============================>td-3621 +sql create table ttm2(ts timestamp, k bool); +sql insert into ttm2 values('2021-1-1 1:1:1', true) +sql insert into ttm2 values('2021-1-1 1:1:2', NULL) +sql insert into ttm2 values('2021-1-1 1:1:3', false) +sql select * from ttm2 where k is not null +if $row != 2 then + return -1 +endi + +if $data00 != @21-01-01 01:01:01.000@ then + print expect 21-01-01 01:01:01.000, actual $data00 + return -1 +endi + +sql select * from ttm2 where k is null +if $row != 1 then + return -1 +endi + +if $data00 != @21-01-01 01:01:02.000@ then + return -1 +endi + +sql select * from ttm2 where k=true +if $row != 1 then + return -1 +endi + +if $data00 != @21-01-01 01:01:01.000@ then + return -1 +endi + +sql select * from ttm2 where k=false +if $row != 1 then + return -1 +endi + +if $data00 != @21-01-01 01:01:03.000@ then + return -1 +endi + +sql select * from ttm2 where k<>false +if $row != 1 then + return -1 +endi + +sql_error select * from ttm2 where k=null +sql_error select * from ttm2 where k<>null +sql_error select * from ttm2 where k like null +sql_error select * from ttm2 where k="2021-03-23 17:00:00.000" and ts<="2021-03-24 20:00:00.000"; +if $rows != 6 then + return -1 +endi + +if $data00 != @21-03-23 17:17:19.660@ then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data10 != @21-03-23 19:23:28.595@ then + return -1 +endi +if $data11 != 3 then + return -1 +endi +if $data20 != @21-03-23 19:33:39.070@ then + return -1 +endi +if $data21 != 4 then + return -1 +endi +if $data30 != @21-03-23 19:34:37.670@ then + return -1 +endi +if $data31 != 5 then + return -1 +endi +if $data40 != @21-03-24 19:08:06.609@ then + return -1 +endi +if $data41 != 6 then + return -1 +endi +if $data50 != @21-03-24 19:26:38.231@ then + return -1 +endi +if $data51 != 7 then + return -1 +endi + +sql select sum_double(f1) from tb1 where ts>="2021-03-23 17:00:00.000" and ts<="2021-03-24 20:00:00.000" interval (1h); +if $rows != 3 then + return -1 +endi + +if $data00 != @21-03-23 17:00:00.000@ then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data10 != @21-03-23 19:00:00.000@ then + return -1 +endi +if $data11 != 18 then + return -1 +endi +if $data20 != @21-03-24 19:00:00.000@ then + return -1 +endi +if $data21 != 22 then + return -1 +endi + + +sql select sum_double(f1) from tb1 where ts>="2021-03-23 17:00:00.000" and ts<="2021-03-24 20:00:00.000" interval (1h) fill(value,999); +if $rows != 28 then + return -1 +endi + +sql_error select add_one(f1) from tb1 group by f1; + +sql select sum_double(f1) from tb1 group by f1; +if $rows != 7 then + return -1 +endi + +if $data00 != 2 then + return -1 +endi +if $data10 != 4 then + return -1 +endi +if $data20 != 6 then + return -1 +endi +if $data30 != 8 then + return -1 +endi +if $data40 != 10 then + return -1 +endi +if $data50 != 12 then + return -1 +endi +if $data60 != 14 then + return -1 +endi + +sql select sum_double(f1) from tb1 interval (1h) order by ts desc; +if $rows != 4 then + return -1 +endi + +if $data00 != @21-03-25 10:00:00.000@ then + return -1 +endi +if $data01 != 14 then + return -1 +endi +if $data10 != @21-03-24 19:00:00.000@ then + return -1 +endi +if $data11 != 22 then + return -1 +endi +if $data20 != @21-03-23 19:00:00.000@ then + return -1 +endi +if $data21 != 18 then + return -1 +endi +if $data30 != @21-03-23 17:00:00.000@ then + return -1 +endi +if $data31 != 2 then + return -1 +endi + +sql_error select add_one(f1) from tb1 order by ts desc; + +sql select add_one(f1) from tb1 limit 2; +if $rows != 2 then + return -1 +endi + +if $data00 != 2 then + return -1 +endi +if $data10 != 3 then + return -1 +endi + + +sql select sum_double(f1) from tb1 interval (1d) limit 2; +if $rows != 2 then + return -1 +endi + +if $data00 != @21-03-23 00:00:00.000@ then + return -1 +endi +if $data01 != 20 then + return -1 +endi +if $data10 != @21-03-24 00:00:00.000@ then + return -1 +endi +if $data11 != 22 then + return -1 +endi + + +sql_error select ts,sum_double(f1),f1 from tb1; +sql_error select add_one(f1),count(f1) from tb1; +sql_error select sum_double(f1),count(f1) from tb1; +sql_error select add_one(f1),top(f1,3) from tb1; +sql_error select add_one(f1) from tb1 interval(10a); + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/udf_dll_stable.sim b/tests/script/general/parser/udf_dll_stable.sim new file mode 100644 index 0000000000000000000000000000000000000000..07784d794d2fbdf7203045e688db27735c590af3 --- /dev/null +++ b/tests/script/general/parser/udf_dll_stable.sim @@ -0,0 +1,1250 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 1 +system sh/exec.sh -n dnode1 -s start +system sh/prepare_udf.sh + +sleep 100 +sql connect +print ======================== dnode1 start + +sql create function add_one as '/tmp/add_one.so' outputtype int; +sql create function add_one_64232 as '/tmp/add_one_64232.so' outputtype int; +sql create aggregate function sum_double as '/tmp/sum_double.so' outputtype bigint; +sql show functions; +if $rows != 3 then + return -1 +endi + +sql create database db; +sql use db; +sql create stable stb1 (ts timestamp, f1 int, f2 bool, f3 binary(10)) tags(id1 int); +sql create table tb1 using stb1 tags(1); +sql insert into tb1 values ('2021-03-23 17:17:19.660', 1, true, 'tb1-1'); +sql insert into tb1 values ('2021-03-23 19:23:28.595', 2, false, 'tb1-2'); +sql insert into tb1 values ('2021-03-23 19:33:39.070', 3, true, 'tb1-3'); +sql insert into tb1 values ('2021-03-23 19:34:37.670', 4, false, 'tb1-4'); +sql insert into tb1 values ('2021-03-24 19:08:06.609', 5, true, 'tb1-5'); +sql insert into tb1 values ('2021-03-24 19:26:38.231', 6, false, 'tb1-6'); +sql insert into tb1 values ('2021-03-25 10:03:17.688', 7, true, 'tb1-7'); +sql create table tb2 using stb1 tags(2); +sql create table tb3 using stb1 tags(3); +sql create table tb4 using stb1 tags(4); +sql create table tb5 using stb1 tags(5); +sql create table tb6 using stb1 tags(6); +sql create table tb7 using stb1 tags(7); +sql create table tb8 using stb1 tags(8); +sql create table tb9 using stb1 tags(9); +sql insert into tb2 values ('2021-03-03 17:17:19.660', 1, true, 'tb2-1'); +sql insert into tb2 values ('2021-03-13 19:23:28.595', 2, false, 'tb2-2'); +sql insert into tb3 values ('2021-03-23 19:33:39.070', 3, true, 'tb3-1'); +sql insert into tb3 values ('2021-03-24 19:34:37.670', 4, false, 'tb3-2'); +sql insert into tb5 values ('2021-03-25 19:08:06.609', 1, true, 'tb5-1'); +sql insert into tb5 values ('2021-04-01 19:26:38.231', 2, false, 'tb5-2'); +sql insert into tb5 values ('2021-04-08 10:03:17.688', 3, true, 'tb5-3'); +sql insert into tb6 values ('2021-04-08 11:03:17.688', 1, true, 'tb6-1'); +sql insert into tb6 values ('2021-04-08 12:03:17.688', 2, true, 'tb6-2'); +sql insert into tb9 values ('2021-04-08 16:03:17.688', 4, true, 'tb9-1'); + +sql select add_one(f1) from tb1; +if $rows != 7 then + return -1 +endi + +if $data00 != 2 then + return -1 +endi +if $data10 != 3 then + return -1 +endi +if $data20 != 4 then + return -1 +endi +if $data30 != 5 then + return -1 +endi +if $data40 != 6 then + return -1 +endi +if $data50 != 7 then + return -1 +endi +if $data60 != 8 then + return -1 +endi + + +sql select sum_double(f1) from tb1; +if $rows != 1 then + return -1 +endi + +if $data00 != 56 then + return -1 +endi + + +sql select ts,add_one(f1),f1 from tb1; +if $rows != 7 then + return -1 +endi + +if $data00 != @21-03-23 17:17:19.660@ then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data10 != @21-03-23 19:23:28.595@ then + return -1 +endi +if $data11 != 3 then + return -1 +endi +if $data12 != 2 then + return -1 +endi +if $data20 != @21-03-23 19:33:39.070@ then + return -1 +endi +if $data21 != 4 then + return -1 +endi +if $data22 != 3 then + return -1 +endi +if $data30 != @21-03-23 19:34:37.670@ then + return -1 +endi +if $data31 != 5 then + return -1 +endi +if $data32 != 4 then + return -1 +endi +if $data40 != @21-03-24 19:08:06.609@ then + return -1 +endi +if $data41 != 6 then + return -1 +endi +if $data42 != 5 then + return -1 +endi +if $data50 != @21-03-24 19:26:38.231@ then + return -1 +endi +if $data51 != 7 then + return -1 +endi +if $data52 != 6 then + return -1 +endi +if $data60 != @21-03-25 10:03:17.688@ then + return -1 +endi +if $data61 != 8 then + return -1 +endi +if $data62 != 7 then + return -1 +endi + + + + +sql select add_one(f1),add_one(f1) from tb1; +if $rows != 7 then + return -1 +endi + +if $data00 != 2 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data10 != 3 then + return -1 +endi +if $data11 != 3 then + return -1 +endi +if $data20 != 4 then + return -1 +endi +if $data21 != 4 then + return -1 +endi +if $data30 != 5 then + return -1 +endi +if $data31 != 5 then + return -1 +endi +if $data40 != 6 then + return -1 +endi +if $data41 != 6 then + return -1 +endi +if $data50 != 7 then + return -1 +endi +if $data51 != 7 then + return -1 +endi +if $data60 != 8 then + return -1 +endi +if $data61 != 8 then + return -1 +endi + + +sql select add_one(f1)+1 from tb1; +if $rows != 7 then + return -1 +endi + +if $data00 != 3.000000000 then + return -1 +endi +if $data10 != 4.000000000 then + return -1 +endi +if $data20 != 5.000000000 then + return -1 +endi +if $data30 != 6.000000000 then + return -1 +endi +if $data40 != 7.000000000 then + return -1 +endi +if $data50 != 8.000000000 then + return -1 +endi +if $data60 != 9.000000000 then + return -1 +endi + + +sql select sum_double(f1)+1 from tb1; +if $rows != 1 then + return -1 +endi + +if $data00 != 57.000000000 then + return -1 +endi + + +sql select add_one(f1)+1,f1 from tb1; +if $rows != 7 then + return -1 +endi + +if $data00 != 3.000000000 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != 4.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data20 != 5.000000000 then + return -1 +endi +if $data21 != 3 then + return -1 +endi +if $data30 != 6.000000000 then + return -1 +endi +if $data31 != 4 then + return -1 +endi +if $data40 != 7.000000000 then + return -1 +endi +if $data41 != 5 then + return -1 +endi +if $data50 != 8.000000000 then + return -1 +endi +if $data51 != 6 then + return -1 +endi +if $data60 != 9.000000000 then + return -1 +endi +if $data61 != 7 then + return -1 +endi + + +sql select sum_double(f1) from tb1 interval (10a); +if $rows != 7 then + return -1 +endi + +if $data00 != @21-03-23 17:17:19.660@ then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data10 != @21-03-23 19:23:28.590@ then + return -1 +endi +if $data11 != 4 then + return -1 +endi +if $data20 != @21-03-23 19:33:39.070@ then + return -1 +endi +if $data21 != 6 then + return -1 +endi +if $data30 != @21-03-23 19:34:37.670@ then + return -1 +endi +if $data31 != 8 then + return -1 +endi +if $data40 != @21-03-24 19:08:06.600@ then + return -1 +endi +if $data41 != 10 then + return -1 +endi +if $data50 != @21-03-24 19:26:38.230@ then + return -1 +endi +if $data51 != 12 then + return -1 +endi +if $data60 != @21-03-25 10:03:17.680@ then + return -1 +endi +if $data61 != 14 then + return -1 +endi + +sql select ts,add_one(f1) from tb1 where ts>="2021-03-23 17:00:00.000" and ts<="2021-03-24 20:00:00.000"; +if $rows != 6 then + return -1 +endi + +if $data00 != @21-03-23 17:17:19.660@ then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data10 != @21-03-23 19:23:28.595@ then + return -1 +endi +if $data11 != 3 then + return -1 +endi +if $data20 != @21-03-23 19:33:39.070@ then + return -1 +endi +if $data21 != 4 then + return -1 +endi +if $data30 != @21-03-23 19:34:37.670@ then + return -1 +endi +if $data31 != 5 then + return -1 +endi +if $data40 != @21-03-24 19:08:06.609@ then + return -1 +endi +if $data41 != 6 then + return -1 +endi +if $data50 != @21-03-24 19:26:38.231@ then + return -1 +endi +if $data51 != 7 then + return -1 +endi + +sql select sum_double(f1) from tb1 where ts>="2021-03-23 17:00:00.000" and ts<="2021-03-24 20:00:00.000" interval (1h); +if $rows != 3 then + return -1 +endi + +if $data00 != @21-03-23 17:00:00.000@ then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data10 != @21-03-23 19:00:00.000@ then + return -1 +endi +if $data11 != 18 then + return -1 +endi +if $data20 != @21-03-24 19:00:00.000@ then + return -1 +endi +if $data21 != 22 then + return -1 +endi + + +sql select sum_double(f1) from tb1 where ts>="2021-03-23 17:00:00.000" and ts<="2021-03-24 20:00:00.000" interval (1h) fill(value,999); +if $rows != 28 then + return -1 +endi + +sql_error select add_one(f1) from tb1 group by f1; + +sql select sum_double(f1) from tb1 group by f1; +if $rows != 7 then + return -1 +endi + +if $data00 != 2 then + return -1 +endi +if $data10 != 4 then + return -1 +endi +if $data20 != 6 then + return -1 +endi +if $data30 != 8 then + return -1 +endi +if $data40 != 10 then + return -1 +endi +if $data50 != 12 then + return -1 +endi +if $data60 != 14 then + return -1 +endi + +sql select sum_double(f1) from tb1 interval (1h) order by ts desc; +if $rows != 4 then + return -1 +endi + +if $data00 != @21-03-25 10:00:00.000@ then + return -1 +endi +if $data01 != 14 then + return -1 +endi +if $data10 != @21-03-24 19:00:00.000@ then + return -1 +endi +if $data11 != 22 then + return -1 +endi +if $data20 != @21-03-23 19:00:00.000@ then + return -1 +endi +if $data21 != 18 then + return -1 +endi +if $data30 != @21-03-23 17:00:00.000@ then + return -1 +endi +if $data31 != 2 then + return -1 +endi + + +sql select add_one(f1) from tb1 limit 2; +if $rows != 2 then + return -1 +endi + +if $data00 != 2 then + return -1 +endi +if $data10 != 3 then + return -1 +endi + + +sql select sum_double(f1) from tb1 interval (1d) limit 2; +if $rows != 2 then + return -1 +endi + +if $data00 != @21-03-23 00:00:00.000@ then + return -1 +endi +if $data01 != 20 then + return -1 +endi +if $data10 != @21-03-24 00:00:00.000@ then + return -1 +endi +if $data11 != 22 then + return -1 +endi + + +sql_error select ts,sum_double(f1),f1 from tb1; +sql_error select add_one(f1),count(f1) from tb1; +sql_error select sum_double(f1),count(f1) from tb1; +sql_error select add_one(f1),top(f1,3) from tb1; +sql_error select add_one(f1) from tb1 interval(10a); + + +sql select add_one(f1) from stb1; +if $rows != 17 then + return -1 +endi + +if $data00 != 2 then + return -1 +endi +if $data10 != 3 then + return -1 +endi +if $data20 != 4 then + return -1 +endi +if $data30 != 5 then + return -1 +endi +if $data40 != 6 then + return -1 +endi +if $data50 != 7 then + return -1 +endi +if $data60 != 8 then + return -1 +endi +if $data70 != 2 then + return -1 +endi +if $data80 != 3 then + return -1 +endi +if $data90 != 4 then + return -1 +endi + + +sql select sum_double(f1) from stb1; +if $rows != 1 then + return -1 +endi + +if $data00 != 102 then + return -1 +endi + + +sql select ts,add_one(f1),f1 from stb1; +if $rows != 17 then + return -1 +endi + +if $data00 != @21-03-23 17:17:19.660@ then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data10 != @21-03-23 19:23:28.595@ then + return -1 +endi +if $data11 != 3 then + return -1 +endi +if $data12 != 2 then + return -1 +endi +if $data20 != @21-03-23 19:33:39.070@ then + return -1 +endi +if $data21 != 4 then + return -1 +endi +if $data22 != 3 then + return -1 +endi +if $data30 != @21-03-23 19:34:37.670@ then + return -1 +endi +if $data31 != 5 then + return -1 +endi +if $data32 != 4 then + return -1 +endi +if $data40 != @21-03-24 19:08:06.609@ then + return -1 +endi +if $data41 != 6 then + return -1 +endi +if $data42 != 5 then + return -1 +endi +if $data50 != @21-03-24 19:26:38.231@ then + return -1 +endi +if $data51 != 7 then + return -1 +endi +if $data52 != 6 then + return -1 +endi +if $data60 != @21-03-25 10:03:17.688@ then + return -1 +endi +if $data61 != 8 then + return -1 +endi +if $data62 != 7 then + return -1 +endi + + + + +sql select add_one(f1),add_one(f1) from stb1; +if $rows != 17 then + return -1 +endi + +if $data00 != 2 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data10 != 3 then + return -1 +endi +if $data11 != 3 then + return -1 +endi +if $data20 != 4 then + return -1 +endi +if $data21 != 4 then + return -1 +endi +if $data30 != 5 then + return -1 +endi +if $data31 != 5 then + return -1 +endi +if $data40 != 6 then + return -1 +endi +if $data41 != 6 then + return -1 +endi +if $data50 != 7 then + return -1 +endi +if $data51 != 7 then + return -1 +endi +if $data60 != 8 then + return -1 +endi +if $data61 != 8 then + return -1 +endi + +sql select add_one(f1)+1 from stb1; +if $rows != 17 then + return -1 +endi + +if $data00 != 3.000000000 then + return -1 +endi +if $data10 != 4.000000000 then + return -1 +endi +if $data20 != 5.000000000 then + return -1 +endi +if $data30 != 6.000000000 then + return -1 +endi +if $data40 != 7.000000000 then + return -1 +endi +if $data50 != 8.000000000 then + return -1 +endi +if $data60 != 9.000000000 then + return -1 +endi + + +sql select sum_double(f1)+1 from stb1; +if $rows != 1 then + return -1 +endi + +if $data00 != 103.000000000 then + return -1 +endi + + +sql select add_one(f1)+1,f1 from stb1; +if $rows != 17 then + return -1 +endi + +if $data00 != 3.000000000 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != 4.000000000 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data20 != 5.000000000 then + return -1 +endi +if $data21 != 3 then + return -1 +endi +if $data30 != 6.000000000 then + return -1 +endi +if $data31 != 4 then + return -1 +endi +if $data40 != 7.000000000 then + return -1 +endi +if $data41 != 5 then + return -1 +endi +if $data50 != 8.000000000 then + return -1 +endi +if $data51 != 6 then + return -1 +endi +if $data60 != 9.000000000 then + return -1 +endi +if $data61 != 7 then + return -1 +endi + + +sql select sum_double(f1) from stb1 interval (10a); +if $rows != 16 then + return -1 +endi + +if $data00 != @21-03-03 17:17:19.660@ then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data10 != @21-03-13 19:23:28.590@ then + return -1 +endi +if $data11 != 4 then + return -1 +endi +if $data20 != @21-03-23 17:17:19.660@ then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data30 != @21-03-23 19:23:28.590@ then + return -1 +endi +if $data31 != 4 then + return -1 +endi +if $data40 != @21-03-23 19:33:39.070@ then + return -1 +endi +if $data41 != 12 then + return -1 +endi +if $data50 != @21-03-23 19:34:37.670@ then + return -1 +endi +if $data51 != 8 then + return -1 +endi +if $data60 != @21-03-24 19:08:06.600@ then + return -1 +endi +if $data61 != 10 then + return -1 +endi +if $data70 != @21-03-24 19:26:38.230@ then + return -1 +endi +if $data71 != 12 then + return -1 +endi +if $data80 != @21-03-24 19:34:37.670@ then + return -1 +endi +if $data81 != 8 then + return -1 +endi +if $data90 != @21-03-25 10:03:17.680@ then + return -1 +endi +if $data91 != 14 then + return -1 +endi + + +sql select ts,add_one(f1) from stb1 where ts>="2021-03-23 17:00:00.000" and ts<="2021-03-24 20:00:00.000"; +if $rows != 8 then + return -1 +endi + +if $data00 != @21-03-23 17:17:19.660@ then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data10 != @21-03-23 19:23:28.595@ then + return -1 +endi +if $data11 != 3 then + return -1 +endi +if $data20 != @21-03-23 19:33:39.070@ then + return -1 +endi +if $data21 != 4 then + return -1 +endi +if $data30 != @21-03-23 19:34:37.670@ then + return -1 +endi +if $data31 != 5 then + return -1 +endi +if $data40 != @21-03-24 19:08:06.609@ then + return -1 +endi +if $data41 != 6 then + return -1 +endi +if $data50 != @21-03-24 19:26:38.231@ then + return -1 +endi +if $data51 != 7 then + return -1 +endi +if $data60 != @21-03-23 19:33:39.070@ then + return -1 +endi +if $data61 != 4 then + return -1 +endi +if $data70 != @21-03-24 19:34:37.670@ then + return -1 +endi +if $data71 != 5 then + return -1 +endi + +sql select sum_double(f1) from stb1 where ts>="2021-03-23 17:00:00.000" and ts<="2021-03-24 20:00:00.000" interval (1h); +if $rows != 3 then + return -1 +endi + +if $data00 != @21-03-23 17:00:00.000@ then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data10 != @21-03-23 19:00:00.000@ then + return -1 +endi +if $data11 != 24 then + return -1 +endi +if $data20 != @21-03-24 19:00:00.000@ then + return -1 +endi +if $data21 != 30 then + return -1 +endi + + +sql select sum_double(f1) from stb1 where ts>="2021-03-23 17:00:00.000" and ts<="2021-03-24 20:00:00.000" interval (1h) fill(value,999); +if $rows != 28 then + return -1 +endi +if $data00 != @21-03-23 17:00:00.000@ then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data10 != @21-03-23 18:00:00.000@ then + return -1 +endi +if $data11 != 999 then + return -1 +endi +if $data20 != @21-03-23 19:00:00.000@ then + return -1 +endi +if $data21 != 24 then + return -1 +endi + +sql_error select add_one(f1) from stb1 group by f1; + +sql select sum_double(f1) from stb1 group by f1; +if $rows != 7 then + return -1 +endi + +if $data00 != 8 then + return -1 +endi +if $data10 != 16 then + return -1 +endi +if $data20 != 18 then + return -1 +endi +if $data30 != 24 then + return -1 +endi +if $data40 != 10 then + return -1 +endi +if $data50 != 12 then + return -1 +endi +if $data60 != 14 then + return -1 +endi + +sql select sum_double(f1) from stb1 interval (1h) order by ts desc; +if $rows != 12 then + return -1 +endi + +if $data00 != @21-04-08 16:00:00.000@ then + return -1 +endi +if $data01 != 8 then + return -1 +endi +if $data10 != @21-04-08 12:00:00.000@ then + return -1 +endi +if $data11 != 4 then + return -1 +endi +if $data20 != @21-04-08 11:00:00.000@ then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data30 != @21-04-08 10:00:00.000@ then + return -1 +endi +if $data31 != 6 then + return -1 +endi +if $data40 != @21-04-01 19:00:00.000@ then + return -1 +endi +if $data41 != 4 then + return -1 +endi +if $data50 != @21-03-25 19:00:00.000@ then + return -1 +endi +if $data51 != 2 then + return -1 +endi +if $data60 != @21-03-25 10:00:00.000@ then + return -1 +endi +if $data61 != 14 then + return -1 +endi +if $data70 != @21-03-24 19:00:00.000@ then + return -1 +endi +if $data71 != 30 then + return -1 +endi +if $data80 != @21-03-23 19:00:00.000@ then + return -1 +endi +if $data81 != 24 then + return -1 +endi +if $data90 != @21-03-23 17:00:00.000@ then + return -1 +endi +if $data91 != 2 then + return -1 +endi + + +sql select add_one(f1) from stb1 limit 2; +if $rows != 2 then + return -1 +endi + +if $data00 != 2 then + return -1 +endi +if $data10 != 3 then + return -1 +endi + + +sql select sum_double(f1) from stb1 interval (1d) limit 2; +if $rows != 2 then + return -1 +endi + +if $data00 != @21-03-03 00:00:00.000@ then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data10 != @21-03-13 00:00:00.000@ then + return -1 +endi +if $data11 != 4 then + return -1 +endi + +sql select sum_double(f1) from stb1 group by id1; + +if $rows != 6 then + return -1 +endi + +if $data00 != 56 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != 6 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data20 != 14 then + return -1 +endi +if $data21 != 3 then + return -1 +endi +if $data30 != 12 then + return -1 +endi +if $data31 != 5 then + return -1 +endi +if $data40 != 6 then + return -1 +endi +if $data41 != 6 then + return -1 +endi +if $data50 != 8 then + return -1 +endi +if $data51 != 9 then + return -1 +endi + + +sql select sum_double(f1) from tb1 where ts>="2021-03-23 17:00:00.000" and ts<="2021-03-24 20:00:00.000" interval (1h) sliding (30m); +if $rows != 7 then + return -1 +endi + +if $data00 != @21-03-23 16:30:00.000@ then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data10 != @21-03-23 17:00:00.000@ then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data20 != @21-03-23 18:30:00.000@ then + return -1 +endi +if $data21 != 4 then + return -1 +endi +if $data30 != @21-03-23 19:00:00.000@ then + return -1 +endi +if $data31 != 18 then + return -1 +endi +if $data40 != @21-03-23 19:30:00.000@ then + return -1 +endi +if $data41 != 14 then + return -1 +endi +if $data50 != @21-03-24 18:30:00.000@ then + return -1 +endi +if $data51 != 22 then + return -1 +endi +if $data60 != @21-03-24 19:00:00.000@ then + return -1 +endi +if $data61 != 22 then + return -1 +endi + +sql_error select sum_double(f1),add_one(f1) from tb1 where ts>="2021-03-23 17:00:00.000" and ts<="2021-03-24 20:00:00.000" interval (1h) sliding (30m); + +sql select add_one(f1) from (select * from tb1); +if $rows != 7 then + return -1 +endi + +if $data00 != 2 then + return -1 +endi +if $data10 != 3 then + return -1 +endi +if $data20 != 4 then + return -1 +endi +if $data30 != 5 then + return -1 +endi +if $data40 != 6 then + return -1 +endi +if $data50 != 7 then + return -1 +endi +if $data60 != 8 then + return -1 +endi + +sql select add_one(ff1) from (select add_one(f1) as ff1 from tb1); +if $rows != 7 then + return -1 +endi + +if $data00 != 3 then + return -1 +endi +if $data10 != 4 then + return -1 +endi +if $data20 != 5 then + return -1 +endi +if $data30 != 6 then + return -1 +endi +if $data40 != 7 then + return -1 +endi +if $data50 != 8 then + return -1 +endi +if $data60 != 9 then + return -1 +endi + +sql_error select add_one(f1),sub_one(f1) from tb1; + + +sql create table taaa (ts timestamp, f1 bigint); +sql insert into taaa values (now, 1); +sleep 100 +sql insert into taaa values (now, 10); +sleep 100 +sql insert into taaa values (now, 1000); +sleep 100 +sql insert into taaa values (now, 100); + +sql select add_one_64232(f1) from taaa; +if $rows != 4 then + return -1 +endi + +if $data00 != 2 then + return -1 +endi +if $data10 != 11 then + return -1 +endi +if $data20 != 1001 then + return -1 +endi +if $data30 != 101 then + return -1 +endi + + +system sh/exec.sh -n dnode1 -s stop -x SIGINT + + + + + + diff --git a/tests/script/general/parser/union.sim b/tests/script/general/parser/union.sim new file mode 100644 index 0000000000000000000000000000000000000000..0cd3cba84d5843a423440e55db2bb6f1df946e06 --- /dev/null +++ b/tests/script/general/parser/union.sim @@ -0,0 +1,466 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c debugFlag -v 135 +system sh/cfg.sh -n dnode1 -c rpcDebugFlag -v 135 +system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 4 + +system sh/exec.sh -n dnode1 -s start +sleep 100 +sql connect + +$dbPrefix = union_db +$tbPrefix = union_tb +$tbPrefix1 = union_tb_ +$mtPrefix = union_mt +$tbNum = 10 +$rowNum = 10000 +$totalNum = $tbNum * $rowNum + +print =============== union.sim +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +$j = 1 + +$mt1 = $mtPrefix . $j + +sql drop database if exists $db -x step1 +step1: +sql create database if not exists $db +sql use $db +sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int) + +$i = 0 +$t = 1578203484000 + +$half = $tbNum / 2 + +while $i < $half + $tb = $tbPrefix . $i + + $nextSuffix = $i + $half + $tb1 = $tbPrefix . $nextSuffix + + sql create table $tb using $mt tags( $i ) + sql create table $tb1 using $mt tags( $nextSuffix ) + + $x = 0 + while $x < $rowNum + $ms = $x * 1000 + $ms = $ms * 60 + + $c = $x / 100 + $c = $c * 100 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + + $t1 = $t + $ms + sql insert into $tb values ($t1 , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar ) $tb1 values ($t1 , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sql create table $mt1 (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int) + +$j = 0 +$t = 1578203484000 +$rowNum = 1000 +$tbNum = 5 +$i = 0 + +while $i < $tbNum + $tb1 = $tbPrefix1 . $j + sql create table $tb1 using $mt1 tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x * 1000 + $ms = $ms * 60 + + $c = $x / 100 + $c = $c * 100 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + + $t1 = $t + $ms + sql insert into $tb1 values ($t1 , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar ) + $x = $x + 1 + endw + + $i = $i + 1 + $j = $j + 1 +endw + +print sleep 1sec. +sleep 100 + +$i = 1 +$tb = $tbPrefix . $i + +## column type not identical +sql_error select count(*) as a from union_mt0 union all select avg(c1) as a from union_mt0 +sql_error select count(*) as a from union_mt0 union all select spread(c1) as a from union_mt0; + +## union not supported +sql_error (select count(*) from union_mt0) union (select count(*) from union_mt0); + +## column type not identical +sql_error select c1 from union_mt0 limit 10 union all select c2 from union_tb1 limit 20; + +## union not support recursively union +sql_error select c1 from union_tb0 limit 2 union all (select c1 from union_tb1 limit 1 union all select c1 from union_tb3 limit 2); +sql_error (select c1 from union_tb0 limit 1 union all select c1 from union_tb1 limit 1) union all (select c1 from union_tb0 limit 10 union all select c1 from union_tb1 limit 10); + +# union as subclause +sql_error (select c1 from union_tb0 limit 1 union all select c1 from union_tb1 limit 1) limit 1 + +# sql with parenthese +sql (((select c1 from union_tb0))) +if $rows != 10000 then + return -1 +endi + +if $data00 != 0 then + return -1 +endi + +if $data10 != 1 then + return -1 +endi + +sql select 'ab' as options from union_tb1 limit 1 union all select 'dd' as options from union_tb0 limit 1; +if $rows != 2 then + return -1 +endi + +if $data00 != @ab@ then + return -1 +endi + +if $data10 != @dd@ then + return -1 +endi + + +sql select 'ab' as options from union_tb1 limit 1 union all select '1234567' as options from union_tb0 limit 1; +if $rows != 2 then + return -1 +endi + +if $data00 != @ab@ then + return -1 +endi + +if $data10 != @1234567@ then + return -1 +endi + + +# mixed order +sql select ts, c1 from union_tb1 order by ts asc limit 10 union all select ts, c1 from union_tb0 order by ts desc limit 2 union all select ts, c1 from union_tb2 order by ts asc limit 10 +if $rows != 22 then + return -1 +endi + +if $data00 != @20-01-05 13:51:24.000@ then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +if $data10 != @20-01-05 13:52:24.000@ then + return -1 +endi + +if $data11 != 1 then + return -1 +endi + +if $data90 != @20-01-05 14:00:24.000@ then + return -1 +endi + +if $data91 != 9 then + return -1 +endi + +# different sort order + +# super table & normal table mixed up +sql select c3 from union_tb0 limit 2 union all select sum(c1) as c3 from union_mt0; +if $rows != 3 then + return -1 +endi + +if $data00 != 0 then + return -1 +endi + +if $data10 != 1 then + return -1 +endi + +if $data20 != 4950000 then + return -1 +endi + +# type compatible +sql select c3 from union_tb0 limit 2 union all select sum(c1) as c3 from union_tb1; +if $rows != 3 then + return -1 +endi + +if $data00 != 0 then + return -1 +endi + +if $data10 != 1 then + return -1 +endi + +if $data20 != 495000 then + return -1 +endi + +# two join subclause +sql select count(*) as c from union_tb0, union_tb1 where union_tb0.ts=union_tb1.ts union all select union_tb0.c3 as c from union_tb0, union_tb1 where union_tb0.ts=union_tb1.ts limit 10 +if $rows != 11 then + return -1 +endi + +if $data00 != 10000 then + return -1 +endi + +if $data10 != 0 then + return -1 +endi + +if $data20 != 1 then + return -1 +endi + +if $data90 != 8 then + return -1 +endi + +print ===========================================tags union +# two super table tag union, limit is not active during retrieve tags query +sql select t1 from union_mt0 union all select t1 from union_mt0 +if $rows != 20 then + return -1 +endi + +if $data00 != 0 then + return -1 +endi + +if $data90 != 9 then + return -1 +endi + +#sql select t1 from union_mt0 union all select t1 from union_mt0 limit 1 +#if $row != 11 then +# return -1 +#endi +#========================================== two super table join subclause +print ================two super table join subclause +sql select avg(union_mt0.c1) as c from union_mt0 interval(1h) limit 10 union all select union_mt1.ts, union_mt1.c1/1.0 as c from union_mt0, union_mt1 where union_mt1.ts=union_mt0.ts and union_mt1.t1=union_mt0.t1 limit 5; +print the rows value is: $rows + +if $rows != 15 then + return -1 +endi + +# first subclause are empty +sql select count(*) as c from union_tb0 where ts > now + 3650d union all select sum(c1) as c from union_tb1; +if $rows != 1 then + return -1 +endi + +if $data00 != 495000 then + return -1 +endi + +# all subclause are empty +sql select c1 from union_tb0 limit 0 union all select c1 from union_tb1 where ts>'2021-1-1 0:0:0' +if $rows != 0 then + return -1 +endi + +# middle subclause empty +sql select c1 from union_tb0 limit 1 union all select c1 from union_tb1 where ts>'2030-1-1 0:0:0' union all select last(c1) as c1 from union_tb1; +if $rows != 2 then + return -1 +endi + +if $data00 != 0 then + return -1 +endi + +if $data10 != 99 then + return -1 +endi + +# multi-vnode projection query +sql (select c1 from union_mt0) union all select c1 from union_mt0; +if $rows != 200000 then + return -1 +endi + +# multi-vnode projection query + limit +sql (select ts, c1 from union_mt0 limit 1) union all (select ts, c1 from union_mt0 limit 1); +if $rows != 2 then + return -1 +endi + +if $data00 != @20-01-05 13:51:24.000@ then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +if $data10 != @20-01-05 13:51:24.000@ then + return -1 +endi + +if $data11 != 0 then + return -1 +endi + +# two aggregated functions for super tables +sql select sum(c1) as a from union_mt0 interval(1s) limit 9 union all select ts, max(c3) as a from union_mt0 limit 2; +if $rows != 10 then + return -1 +endi + +if $data00 != @20-01-05 13:51:24.000@ then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +if $data10 != @20-01-05 13:52:24.000@ then + return -1 +endi + +if $data11 != 10 then + return -1 +endi + +if $data20 != @20-01-05 13:53:24.000@ then + return -1 +endi + +if $data21 != 20 then + return -1 +endi + +if $data90 != @20-01-05 15:30:24.000@ then + return -1 +endi + +if $data91 != 99 then + return -1 +endi + +#================================================================================================= +# two aggregated functions for normal tables +sql select sum(c1) as a from union_tb0 limit 1 union all select sum(c3) as a from union_tb1 limit 2; +if $rows != 2 then + return -1 +endi + +if $data00 != 495000 then + return -1 +endi + +if $data10 != 495000 then + return -1 +endi + +# two super table query + interval + limit +sql select ts, first(c3) as a from union_mt0 limit 1 union all select sum(c3) as a from union_mt0 interval(1h) limit 1; +if $rows != 2 then + return -1 +endi + +if $data00 != @20-01-05 13:51:24.000@ then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +if $data10 != @20-01-05 13:00:00.000@ then + return -1 +endi + +if $data11 != 360 then + return -1 +endi + +sql select server_status() union all select server_status() +if $rows != 2 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + +if $data10 != 1 then + return -1 +endi + +sql select client_version() union all select server_version() +if $rows != 2 then + return -1 +endi + +sql select database() union all select database() +if $rows != 2 then + return -1 +endi + +if $data00 != @union_db0@ then + return -1 +endi + +if $data10 != @union_db0@ then + return -1 +endi + +sql select 'aaa' as option from union_tb1 where c1 < 0 limit 1 union all select 'bbb' as option from union_tb0 limit 1 +if $rows != 1 then + return -1 +endi + +if $data00 != @bbb@ then + return -1 +endi + + +sql_error show tables union all show tables +sql_error show stables union all show stables +sql_error show databases union all show databases + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/where.sim b/tests/script/general/parser/where.sim new file mode 100644 index 0000000000000000000000000000000000000000..781b2725b5ff8d55e9cb1dd2f5de0d4a77275725 --- /dev/null +++ b/tests/script/general/parser/where.sim @@ -0,0 +1,375 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sleep 100 +sql connect + +$dbPrefix = wh_db +$tbPrefix = wh_tb +$mtPrefix = wh_mt +$tbNum = 10 +$rowNum = 10000 +$totalNum = $tbNum * $rowNum + +print =============== where.sim +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database if exists $db -x step1 +step1: +sql create database if not exists $db +sql use $db +sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int) + +$half = $tbNum / 2 + +$i = 0 +while $i < $half + $tb = $tbPrefix . $i + + $nextSuffix = $i + $half + $tb1 = $tbPrefix . $nextSuffix + + sql create table $tb using $mt tags( $i ) + sql create table $tb1 using $mt tags( $nextSuffix ) + + $x = 0 + while $x < $rowNum + $y = $x * 60000 + $ms = 1600099200000 + $y + $c = $x / 100 + $c = $c * 100 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + sql insert into $tb values ($ms , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar ) $tb1 values ($ms , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +$i = 1 +$tb = $tbPrefix . $i + +## +sql_error select * from $tb where c7 + +# TBASE-654 : invalid filter expression cause server crashed +sql_error select count(*) from $tb where c1<10 and c1<>2 + +sql select * from $tb where c7 = false +$val = $rowNum / 100 +if $rows != $val then + return -1 +endi +sql select * from $mt where c7 = false +$val = $totalNum / 100 +if $rows != $val then + return -1 +endi + +sql select tbname from $mt +if $rows != $tbNum then + return -1 +endi + +sql select tbname from $mt where t1 < 2 +if $rows != 2 then + return -1 +endi + +print $tbPrefix +$tb = $tbPrefix . 0 +if $data00 != wh_tb1 then + print expect wh_tb1, actual:$data00 + return -1 +endi +$tb = $tbPrefix . 1 +if $data10 != wh_tb0 then + print expect wh_tb0, actual:$data00 + return -1 +endi + +## select specified columns + +print select c1 from $mt +sql select c1 from $mt + +print rows $rows +print totalNum $totalNum +if $rows != $totalNum then + return -1 +endi +sql select count(c1) from $mt +if $data00 != $totalNum then + return -1 +endi + +sql select c1 from $mt where c1 >= 0 +if $rows != $totalNum then + return -1 +endi +sql select count(c1) from $mt where c1 <> -1 +if $data00 != $totalNum then + return -1 +endi +sql select count(c1) from $mt where c1 <> -1 group by t1 +if $rows != $tbNum then + return -1 +endi +if $data00 != $rowNum then + return -1 +endi + +## like +sql_error select * from $mt where c1 like 1 +#sql_error select * from $mt where t1 like 1 + +## [TBASE-593] +sql create table wh_mt1 (ts timestamp, c1 smallint, c2 int, c3 bigint, c4 float, c5 double, c6 tinyint, c7 binary(10), c8 nchar(10), c9 bool, c10 timestamp) tags (t1 binary(10), t2 smallint, t3 int, t4 bigint, t5 float, t6 double) +sql create table wh_mt1_tb1 using wh_mt1 tags ('tb11', 1, 1, 1, 1, 1) +sql insert into wh_mt1_tb1 values (now, 1, 1, 1, 1, 1, 1, 'binary', 'nchar', true, '2019-01-01 00:00:00.000') +#sql_error select last(*) from wh_mt1 where c1 in ('1') +#sql_error select last(*) from wh_mt1_tb1 where c1 in ('1') +#sql_error select last(*) from wh_mt1 where c2 in ('1') +#sql_error select last(*) from wh_mt1_tb1 where c2 in ('1') +#sql_error select last(*) from wh_mt1 where c3 in ('1') +#sql_error select last(*) from wh_mt1_tb1 where c3 in ('1') +#sql_error select last(*) from wh_mt1 where c4 in ('1') +#sql_error select last(*) from wh_mt1_tb1 where c4 in ('1') +#sql_error select last(*) from wh_mt1 where c5 in ('1') +#sql_error select last(*) from wh_mt1_tb1 where c5 in ('1') +#sql_error select last(*) from wh_mt1 where c6 in ('1') +#sql_error select last(*) from wh_mt1_tb1 where c6 in ('1') +#sql_error select last(*) from wh_mt1 where c7 in ('binary') +#sql_error select last(*) from wh_mt1_tb1 where c7 in ('binary') +#sql_error select last(*) from wh_mt1 where c8 in ('nchar') +#sql_error select last(*) from wh_mt1_tb1 where c9 in (true, false) +#sql_error select last(*) from wh_mt1 where c10 in ('2019-01-01 00:00:00.000') +#sql_error select last(*) from wh_mt1_tb1 where c10 in ('2019-01-01 00:00:00.000') +sql select last(*) from wh_mt1 where c1 = 1 +if $rows != 1 then + return -1 +endi + +## [TBASE-597] +sql create table wh_mt2 (ts timestamp, c1 timestamp, c2 binary(10), c3 nchar(10)) tags (t1 binary(10)) +sql create table wh_mt2_tb1 using wh_mt2 tags ('wh_mt2_tb1') + +# 2019-01-01 00:00:00.000 1546272000000 +# 2019-01-01 00:10:00.000 1546272600000 +# 2019-01-01 09:00:00.000 1546304400000 +# 2019-01-01 09:10:00.000 1546305000000 +sql insert into wh_mt2_tb1 values ('2019-01-01 00:00:00.000', '2019-01-01 09:00:00.000', 'binary10', 'nchar10') +sql insert into wh_mt2_tb1 values ('2019-01-01 00:10:00.000', '2019-01-01 09:10:00.000', 'binary10', 'nchar10') + +sql select * from wh_mt2_tb1 where c1 > 1546304400000 +if $rows != 1 then + return -1 +endi +if $data00 != @19-01-01 00:10:00.000@ then + return -1 +endi +if $data01 != @19-01-01 09:10:00.000@ then + return -1 +endi + +sql select * from wh_mt2_tb1 where c1 > '2019-01-01 09:00:00.000' +if $rows != 1 then + return -1 +endi +if $data00 != @19-01-01 00:10:00.000@ then + return -1 +endi +if $data01 != @19-01-01 09:10:00.000@ then + return -1 +endi + +sql select * from wh_mt2_tb1 where c1 > 1546304400000 and ts < '2019-01-01 00:10:00.000' +if $rows != 0 then + return -1 +endi + +sql select * from wh_mt2_tb1 where c1 > '2019-01-01 09:00:00.000' and ts < '2019-01-01 00:10:00.000' +if $rows != 0 then + return -1 +endi + +sql select * from wh_mt2_tb1 where c1 >= 1546304400000 and c1 <= '2019-01-01 09:10:00.000' +if $rows != 2 then + return -1 +endi +if $data00 != @19-01-01 00:00:00.000@ then + return -1 +endi +if $data01 != @19-01-01 09:00:00.000@ then + return -1 +endi +if $data10 != @19-01-01 00:10:00.000@ then + return -1 +endi +if $data11 != @19-01-01 09:10:00.000@ then + return -1 +endi + +sql select * from wh_mt2_tb1 where c1 >= '2019-01-01 09:00:00.000' and c1 <= '2019-01-01 09:10:00.000' +if $rows != 2 then + return -1 +endi +if $data00 != @19-01-01 00:00:00.000@ then + return -1 +endi +if $data01 != @19-01-01 09:00:00.000@ then + return -1 +endi +if $data10 != @19-01-01 00:10:00.000@ then + return -1 +endi +if $data11 != @19-01-01 09:10:00.000@ then + return -1 +endi + +sql create table tb_where_NULL (ts timestamp, c1 float, c2 binary(10)) + +print ===================>td-1604 +sql_error insert into tb_where_NULL values(?, ?, ?) +sql_error insert into tb_where_NULL values(now, 1, ?) +sql_error insert into tb_where_NULL values(?, 1, '') +sql_error insert into tb_where_NULL values(now, ?, '12') + +sql insert into tb_where_NULL values ('2019-01-01 09:00:00.000', 1, 'val1') +sql insert into tb_where_NULL values ('2019-01-01 09:00:01.000', NULL, NULL) +sql insert into tb_where_NULL values ('2019-01-01 09:00:02.000', 2, 'val2') +sql_error select * from tb_where_NULL where c1 = NULL +sql_error select * from tb_where_NULL where c1 <> NULL +sql_error select * from tb_where_NULL where c1 < NULL +sql select * from tb_where_NULL where c1 = "NULL" +if $rows != 0 then + return -1 +endi + +sql select * from tb_where_NULL where c1 <> "NULL" +if $rows != 2 then + return -1 +endi +sql select * from tb_where_NULL where c1 <> "nulL" +if $rows != 2 then + return -1 +endi + +sql select * from tb_where_NULL where c1 > "NULL" +if $rows != 0 then + return -1 +endi + +sql select * from tb_where_NULL where c1 >= "NULL" +if $rows != 0 then + return -1 +endi + +sql select * from tb_where_NULL where c2 = "NULL" +if $rows != 0 then + return -1 +endi + +sql select * from tb_where_NULL where c2 <> "NULL" +if $rows != 2 then + return -1 +endi +sql select * from tb_where_NULL where c2 <> "nUll" +if $rows != 2 then + return -1 +endi + +print ==========tbase-1363 +#sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int) + +$i = 0 +while $i < 1 + $tb = test_null_filter + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < 10000 + $y = $x * 60000 + $ms = 1601481600000 + $y + $c = $x / 100 + $c = $c * 100 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + sql insert into $tb values ($ms , null , null , null , null , null , null , null , null , null ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 500 + +system sh/exec.sh -n dnode1 -s start + +sql_error select * from wh_mt0 where c3 = 'abc' and tbname in ('test_null_filter'); + +sql select * from wh_mt0 where c3 = '1' and tbname in ('test_null_filter'); +if $row != 0 then + return -1 +endi + +sql select * from wh_mt0 where c3 = '1'; +if $row == 0 then + return -1 +endi + +sql select * from wh_mt0 where c3 is null and tbname in ('test_null_filter'); +if $rows != 10000 then + return -1 +endi + +sql select * from wh_mt0 where c3 is not null and tbname in ('test_null_filter'); +if $rows != 0 then + return -1 +endi + +print ==========================>td-3318 +sql create table tu(ts timestamp, k int, b binary(12)) +sql insert into tu values(now, 1, 'abc') +sql select stddev(k) from tu where b <>'abc' interval(1s) +if $rows != 0 then + return -1 +endi + +print ==========================> td-4783,td-4792 +sql create table where_ts(ts timestamp, f int) +sql insert into where_ts values('2021-06-19 16:22:00', 1); +sql insert into where_ts values('2021-06-19 16:23:00', 2); +sql insert into where_ts values('2021-06-19 16:24:00', 3); +sql insert into where_ts values('2021-06-19 16:25:00', 1); +sql select * from (select * from where_ts) where ts<'2021-06-19 16:25:00' and ts>'2021-06-19 16:22:00' +if $rows != 2 then + return -1 +endi +print $data00, $data01 +if $data01 != 2 then + return -1 +endi +sql insert into where_ts values(now, 5); +sleep 10 +sql select * from (select * from where_ts) where ts now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = false +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> false +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where tgcol3 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step6 +sql select * from $mt where ts > now + 4m and tgcol1 = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> false and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step9 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 and tgcol1 = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 and tgcol1 <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 and tgcol1 = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 and tgcol1 <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 and tgcol1 = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 and tgcol1 <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol1 <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> false +if $rows != 5 then + return -1 +endi + +print =============== step10 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol1 = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol1 <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol1 = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol1 <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol1 = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol1 <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol1 <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> false +if $rows != 5 then + return -1 +endi + +print =============== step11 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step12 +sql select * from $mt where ts > now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step13 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step14 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step15 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = true +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = true and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step16 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step17 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step18 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = true group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = true and tgcol2 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step19 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/rm_bak/tag/4.sim b/tests/script/general/rm_bak/tag/4.sim new file mode 100644 index 0000000000000000000000000000000000000000..ee3c8efa6c47be1fc91b1114294b6ebf832eabdc --- /dev/null +++ b/tests/script/general/rm_bak/tag/4.sim @@ -0,0 +1,715 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect +sql reset query cache + +print ======================== dnode1 start + +$dbPrefix = ta_4_db +$tbPrefix = ta_4_tb +$mtPrefix = ta_4_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 bigint, tgcol3 float, tgcol4 double) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0, 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1, 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where tgcol3 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step6 +sql select * from $mt where tgcol4 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > now + 4m and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step9 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step10 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step11 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step12 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step13 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step14 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step15 +sql select * from $mt where ts > now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step16 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step17 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step18 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step19 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step20 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step21 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step22 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step23 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step24 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 interval(1d) group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/rm_bak/tag/5.sim b/tests/script/general/rm_bak/tag/5.sim new file mode 100644 index 0000000000000000000000000000000000000000..895b1a9492644290e5c30abc901849e1adf33e6c --- /dev/null +++ b/tests/script/general/rm_bak/tag/5.sim @@ -0,0 +1,838 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect +sql reset query cache + +print ======================== dnode1 start + +$dbPrefix = ta_5_db +$tbPrefix = ta_5_tb +$mtPrefix = ta_5_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 tinyint, tgcol2 int, tgcol3 bigint, tgcol4 double, tgcol5 binary(20)) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0, 0, 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1, 1, 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where tgcol3 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step6 +sql select * from $mt where tgcol4 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step7 +sql select * from $mt where tgcol5 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol5 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol5 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol5 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step8 +sql select * from $mt where ts > now + 4m and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step9 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step10 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step11 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step12 +sql select * from $mt where ts > now + 4m and tgcol5 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol5 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step13 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step14 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step15 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step16 +sql select * from $mt where ts > now + 4m and tgcol5 = 1 and tgcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 1 and tgcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol5 <> 0 and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 0 and ts < now + 5m and ts < now + 5m and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step17 +sql select * from $mt where ts > now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step18 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step19 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step20 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 and tgcol5 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 and tgcol5 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step21 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step22 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step23 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step24 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol5 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step25 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step26 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step27 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 interval(1d) group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 interval(1d) group by tgcol5 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/rm_bak/tag/6.sim b/tests/script/general/rm_bak/tag/6.sim new file mode 100644 index 0000000000000000000000000000000000000000..9190998bb316bc63fd47022029b4c8deb61c0727 --- /dev/null +++ b/tests/script/general/rm_bak/tag/6.sim @@ -0,0 +1,993 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect +sql reset query cache + +print ======================== dnode1 start + +$dbPrefix = ta_6_db +$tbPrefix = ta_6_tb +$mtPrefix = ta_6_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 bigint, tgcol3 smallint, tgcol4 bigint, tgcol5 binary(30), tgcol6 binary(20)) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '0', 0, 0, 0, '0', '0' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '1', 1, 1, 1, '1', '1' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where tgcol3 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step6 +sql select * from $mt where tgcol4 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step7 +sql select * from $mt where tgcol5 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol5 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol5 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol5 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step8 +sql select * from $mt where tgcol6 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol6 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol6 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol6 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step9 +sql select * from $mt where ts > now + 4m and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step10 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step11 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step12 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step13 +sql select * from $mt where ts > now + 4m and tgcol5 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol5 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step14 +sql select * from $mt where ts > now + 4m and tgcol6 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol6 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol6 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol6 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step15 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step16 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step17 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step18 +sql select * from $mt where ts > now + 4m and tgcol5 = 1 and tgcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 1 and tgcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol5 <> 0 and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 0 and ts < now + 5m and ts < now + 5m and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step19 +sql select * from $mt where ts > now + 4m and tgcol5 = 1 and tgcol6 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 1 and tgcol6 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 = 0 and tgcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 <> 0 and tgcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 = 0 and tgcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 <> 0 and tgcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol5 <> 0 and tgcol6 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 0 and ts < now + 5m and ts < now + 5m and tgcol6 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step20 +sql select * from $mt where ts > now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step21 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step22 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step23 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 and tgcol5 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 and tgcol5 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step24 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 and tgcol5 = 1 and tgcol6 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 and tgcol5 <> 1 and tgcol6 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 and tgcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and tgcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 and tgcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and tgcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and tgcol6 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and tgcol6 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step25 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step26 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step27 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step28 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol5 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol6 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step29 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step30 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step31 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 interval(1d) group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 interval(1d) group by tgcol5 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 interval(1d) group by tgcol6 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/rm_bak/tag/add.sim b/tests/script/general/rm_bak/tag/add.sim new file mode 100644 index 0000000000000000000000000000000000000000..4a3871235ecfbd1546cbab1ba4ab90de33ac7ed8 --- /dev/null +++ b/tests/script/general/rm_bak/tag/add.sim @@ -0,0 +1,856 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_ad_db +$tbPrefix = ta_ad_tb +$mtPrefix = ta_ad_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i + +sql create database $db +sql use $db + +print =============== step2 +$i = 2 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt add tag tgcol4 int +sql reset query cache +sql alter table $tb set tag tgcol4 =4 +sql reset query cache + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step2 + return -1 +step2: + +print =============== step3 +$i = 3 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt add tag tgcol4 tinyint +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql reset query cache + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step3 + return -1 +step3: + +print =============== step4 +$i = 4 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.00000 then + return -1 +endi + +sql describe $tb +print sql describe $tb +if $data21 != BIGINT then + return -1 +endi +if $data31 != FLOAT then + return -1 +endi +if $data23 != TAG then + return -1 +endi +if $data33 != TAG then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt add tag tgcol4 float +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql reset query cache + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4.00000 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step4 + return -1 +step4: + +print =============== step5 +$i = 5 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10)) +sql create table $tb using $mt tags( 1, '2' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = '2' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt add tag tgcol4 smallint +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql reset query cache + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol3 = '1' -x step5 + return -1 +step5: + +print =============== step6 +$i = 6 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 tinyint) +sql create table $tb using $mt tags( 1, 2, 3 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt add tag tgcol5 binary(10) +sql alter table $mt add tag tgcol6 binary(10) + +sql reset query cache +sql alter table $tb set tag tgcol4=false +sql alter table $tb set tag tgcol5=5 +sql alter table $tb set tag tgcol6=6 +sql reset query cache + +sql select * from $mt where tgcol5 = '5' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 6 then + return -1 +endi + +sql select * from $mt where tgcol6 = '6' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 6 then + return -1 +endi + +sql select * from $mt where tgcol4 = 1 +if $rows != 0 then + return -1 +endi +sql select * from $mt where tgcol3 = 1 -x step52 + return -1 +step52: + +print =============== step7 +$i = 7 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint, tgcol3 binary(10)) +sql create table $tb using $mt tags( 1, 2, '3' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol3 = '3' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt add tag tgcol5 bigint +sql alter table $mt add tag tgcol6 tinyint + +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql alter table $tb set tag tgcol5=5 +sql alter table $tb set tag tgcol6=6 +sql reset query cache + +sql select * from $mt where tgcol6 = 6 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 6 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step71 + return -1 +step71: +sql select * from $mt where tgcol3 = 1 -x step72 + return -1 +step72: + +print =============== step8 +$i = 8 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float, tgcol3 binary(10)) +sql create table $tb using $mt tags( 1, 2, '3' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol3 = '3' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.00000 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt add tag tgcol5 binary(17) +sql alter table $mt add tag tgcol6 bool +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql alter table $tb set tag tgcol5=5 +sql alter table $tb set tag tgcol6=1 +sql reset query cache + +sql select * from $mt where tgcol5 = '5' +print select * from $mt where tgcol5 = 5 +print $data01 $data02 $data03 $data04 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 1 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step81 + return -1 +step81: +sql select * from $mt where tgcol3 = 1 -x step82 + return -1 +step82: + +print =============== step9 +$i = 9 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10), tgcol3 binary(10)) +sql create table $tb using $mt tags( 1, 2, '3' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = '2' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt add tag tgcol5 bool +sql alter table $mt add tag tgcol6 float + +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql alter table $tb set tag tgcol5=1 +sql alter table $tb set tag tgcol6=6 +sql reset query cache + +sql select * from $mt where tgcol5 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 4.000000000 then + return -1 +endi +if $data03 != 1 then + return -1 +endi +if $data04 != 6.00000 then + return -1 +endi + +sql select * from $mt where tgcol3 = 1 -x step91 + return -1 +step91: +sql select * from $mt where tgcol2 = 1 -x step92 + return -1 +step92: + +print =============== step10 +$i = 10 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10)) +sql create table $tb using $mt tags( '1', '2', '3', '4' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol4 = '4' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 -x step103 + return -1 +step103: + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol4 +sql reset query cache +sql alter table $mt add tag tgcol4 binary(10) +sql alter table $mt add tag tgcol5 bool + +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql alter table $tb set tag tgcol5=false +sql reset query cache + +sql select * from $mt where tgcol4 = '4' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4 then + return -1 +endi +if $data04 != 0 then + return -1 +endi +if $data05 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step101 + return -1 +step101: +sql select * from $mt where tgcol3 = 1 -x step102 + return -1 +step102: + +print =============== step11 +$i = 11 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 smallint, tgcol4 float, tgcol5 binary(10)) +sql create table $tb using $mt tags( 1, 2, 3, 4, '5' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4.00000 then + return -1 +endi +if $data06 != 5 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 -x step114 + return -1 +step114: + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol4 +sql alter table $mt drop tag tgcol5 +sql reset query cache +sql alter table $mt add tag tgcol4 binary(10) +sql alter table $mt add tag tgcol5 int +sql alter table $mt add tag tgcol6 binary(10) +sql alter table $mt add tag tgcol7 bigint +sql alter table $mt add tag tgcol8 smallint + +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql alter table $tb set tag tgcol5=5 +sql alter table $tb set tag tgcol6=6 +sql alter table $tb set tag tgcol7=7 +sql alter table $tb set tag tgcol8=8 +sql reset query cache + +sql select * from $mt where tgcol5 =5 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4 then + return -1 +endi +if $data04 != 5 then + return -1 +endi +if $data05 != 6 then + return -1 +endi +if $data06 != 7 then + return -1 +endi +if $data07 != 8 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step111 + return -1 +step111: +sql select * from $mt where tgcol3 = 1 -x step112 + return -1 +step112: +sql select * from $mt where tgcol9 = 1 -x step113 + return -1 +step113: + +print =============== step12 +$i = 12 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 smallint, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 binary(20)) +sql create table $tb using $mt tags( 1, 2, 3, 4, '5', '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3.00000 then + return -1 +endi +if $data05 != 4.000000000 then + return -1 +endi +if $data06 != 5 then + return -1 +endi +if $data07 != 6 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol4 +sql alter table $mt drop tag tgcol5 +sql reset query cache +sql alter table $mt add tag tgcol2 binary(10) +sql alter table $mt add tag tgcol3 int +sql alter table $mt add tag tgcol4 binary(10) +sql alter table $mt add tag tgcol5 bigint + +sql reset query cache +sql alter table $tb set tag tgcol1=false +sql alter table $tb set tag tgcol2=5 +sql alter table $tb set tag tgcol3=4 +sql alter table $tb set tag tgcol4=3 +sql alter table $tb set tag tgcol5=2 +sql alter table $tb set tag tgcol6=1 +sql reset query cache + +sql select * from $mt where tgcol4 = '3' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 1 then + return -1 +endi +if $data04 != 5 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 3 then + return -1 +endi +if $data07 != 2 then + return -1 +endi + +sql select * from $mt where tgcol2 = '5' +if $rows != 1 then + return -1 +endi + +sql select * from $mt where tgcol3 = 4 +if $rows != 1 then + return -1 +endi + +sql select * from $mt where tgcol5 = 2 +if $rows != 1 then + return -1 +endi + +sql select * from $mt where tgcol6 = '1' +if $rows != 1 then + return -1 +endi + +print =============== step13 +$i = 13 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20)) +sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = '1' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 5.000000000 then + return -1 +endi +if $data07 != 6 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol4 +sql alter table $mt drop tag tgcol6 +sql reset query cache +sql alter table $mt add tag tgcol2 binary(10) +sql alter table $mt add tag tgcol4 int +sql alter table $mt add tag tgcol6 bigint + +sql reset query cache +sql alter table $tb set tag tgcol1=7 +sql alter table $tb set tag tgcol2=8 +sql alter table $tb set tag tgcol3=9 +sql alter table $tb set tag tgcol4=10 +sql alter table $tb set tag tgcol5=11 +sql alter table $tb set tag tgcol6=12 +sql reset query cache + +sql select * from $mt where tgcol2 = '8' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 7 then + return -1 +endi +if $data03 != 9 then + return -1 +endi +if $data04 != 11.000000000 then + return -1 +endi +if $data05 != 8 then + return -1 +endi +if $data06 != 10 then + return -1 +endi +if $data07 != 12 then + return -1 +endi + +print =============== step14 +$i = 14 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 bigint) +sql create table $tb using $mt tags( 1, 1 ) +sql insert into $tb values(now, 1) + +sql alter table $mt add tag tgcol3 binary(10) +sql alter table $mt add tag tgcol4 int +sql alter table $mt add tag tgcol5 bigint +sql alter table $mt add tag tgcol6 bigint + +return +sql alter table $mt add tag tgcol7 bigint -x step141 + return -1 +step141: +sql reset query cache +sql alter table $mt drop tag tgcol6 +sql alter table $mt add tag tgcol7 bigint +sql alter table $mt add tag tgcol8 bigint -x step142 + return -1 +step142: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/rm_bak/tag/bigint.sim b/tests/script/general/rm_bak/tag/bigint.sim new file mode 100644 index 0000000000000000000000000000000000000000..3e5d528980e3f8716ae5dea0c1d4090e02d0420a --- /dev/null +++ b/tests/script/general/rm_bak/tag/bigint.sim @@ -0,0 +1,244 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_bi_db +$tbPrefix = ta_bi_tb +$mtPrefix = ta_bi_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bigint) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sleep 100 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi +sql select * from $tb where ts < now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts <= now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts > now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts >= now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 5m +if $rows != 1 then + return -1 +endi +sql select * from $tb where ts < now + 4m and ts > now + 5m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > 100000 and ts < 100000 +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 3m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/rm_bak/tag/binary.sim b/tests/script/general/rm_bak/tag/binary.sim new file mode 100644 index 0000000000000000000000000000000000000000..960f45675d28349d170544729055ca3b815a2ccb --- /dev/null +++ b/tests/script/general/rm_bak/tag/binary.sim @@ -0,0 +1,244 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_by_db +$tbPrefix = ta_by_tb +$mtPrefix = ta_by_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(10)) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '0' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '1' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sleep 100 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi +sql select * from $tb where ts < now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts <= now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts > now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts >= now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 5m +if $rows != 1 then + return -1 +endi +sql select * from $tb where ts < now + 4m and ts > now + 5m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > 100000 and ts < 100000 +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 3m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol = '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> '0' +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> '0' +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> '0' and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/rm_bak/tag/binary_binary.sim b/tests/script/general/rm_bak/tag/binary_binary.sim new file mode 100644 index 0000000000000000000000000000000000000000..3a0fb568482fa19a142f4b9019bd09c5208b4252 --- /dev/null +++ b/tests/script/general/rm_bak/tag/binary_binary.sim @@ -0,0 +1,311 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_bib_db +$tbPrefix = ta_bib_tb +$mtPrefix = ta_bib_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(5), tgcol2 binary(5)) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '0', '0' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '1', '1' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol = '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> '0' +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 = '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> '1' +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> '0' +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> '0' and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select * from $mt where ts > now + 4m and tgcol2 = '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> '0' +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > now + 4m and tgcol2 = '1' and tgcol = '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '1' and tgcol <> '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = '0' and tgcol = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> '0' and tgcol <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = '0' and tgcol = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' and tgcol <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> '0' and tgcol <> '0' +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and ts < now + 5m and ts < now + 5m and tgcol <> '0' +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' and tgcol2 = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' and tgcol2 = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + + +print =============== step13 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step14 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/rm_bak/tag/bool.sim b/tests/script/general/rm_bak/tag/bool.sim new file mode 100644 index 0000000000000000000000000000000000000000..e37cba669ba27ec4046e8483938763b90360de31 --- /dev/null +++ b/tests/script/general/rm_bak/tag/bool.sim @@ -0,0 +1,242 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_bo_db +$tbPrefix = ta_bo_tb +$mtPrefix = ta_bo_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sleep 100 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi +sql select * from $tb where ts < now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts <= now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts > now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts >= now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 5m +if $rows != 1 then + return -1 +endi +sql select * from $tb where ts < now + 4m and ts > now + 5m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 3m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + print expect 100, actual:$rows + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = false +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> false +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> false and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/rm_bak/tag/bool_binary.sim b/tests/script/general/rm_bak/tag/bool_binary.sim new file mode 100644 index 0000000000000000000000000000000000000000..9f6e4f734432bd39c6250adbc0fe26883f104267 --- /dev/null +++ b/tests/script/general/rm_bak/tag/bool_binary.sim @@ -0,0 +1,311 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_bob_db +$tbPrefix = ta_bob_tb +$mtPrefix = ta_bob_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 binary(5)) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, '0' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, '1' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = false +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> false +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 = '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> '1' +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> false and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select * from $mt where ts > now + 4m and tgcol2 = '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> '0' +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > now + 4m and tgcol2 = '1' and tgcol = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '1' and tgcol <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = '0' and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> '0' and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = '0' and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> '0' and tgcol <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and ts < now + 5m and ts < now + 5m and tgcol <> false +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true and tgcol2 = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true and tgcol2 = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + + +print =============== step13 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step14 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/rm_bak/tag/bool_int.sim b/tests/script/general/rm_bak/tag/bool_int.sim new file mode 100644 index 0000000000000000000000000000000000000000..60345c2d68b9216acc78e8bb8617c698013f4402 --- /dev/null +++ b/tests/script/general/rm_bak/tag/bool_int.sim @@ -0,0 +1,327 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_boi_db +$tbPrefix = ta_boi_tb +$mtPrefix = ta_boi_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 int) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = false +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> false +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = false +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> false +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> false and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 and tgcol = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 and tgcol <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol <> false +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true and tgcol2 = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + + +print =============== step13 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step14 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/rm_bak/tag/change.sim b/tests/script/general/rm_bak/tag/change.sim new file mode 100644 index 0000000000000000000000000000000000000000..6f294c0f48fb18d232a5e78f9fbec084e8dc699d --- /dev/null +++ b/tests/script/general/rm_bak/tag/change.sim @@ -0,0 +1,515 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_ch_db +$tbPrefix = ta_ch_tb +$mtPrefix = ta_ch_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i + +sql create database $db +sql use $db + +print =============== step2 +$i = 2 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt change tag tagcx tgcol3 -x step21 + return -1 +step21: +sql alter table $mt change tag tgcol1 tgcol2 -x step22 + return -1 +step22: +#sql alter table $mt change tag tgcol1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -x step20 +# return -1 +#step20: + +sql alter table $mt change tag tgcol1 tgcol3 +sql alter table $mt change tag tgcol2 tgcol4 +sql alter table $mt change tag tgcol4 tgcol3 -x step23 + return -1 +step23: + +print =============== step3 +$i = 3 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol3 +sql alter table $mt change tag tgcol2 tgcol4 + +print =============== step4 +$i = 4 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.00000 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol3 +sql alter table $mt change tag tgcol2 tgcol4 + +print =============== step5 +$i = 5 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10)) +sql create table $tb using $mt tags( 1, '2' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = '2' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol3 +sql alter table $mt change tag tgcol2 tgcol4 + +print =============== step6 +$i = 6 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20)) +sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = '1' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 5.000000000 then + return -1 +endi +if $data07 != 6 then + return -1 +endi + +sql alter table $mt drop tag tgcol3 +sql reset query cache +sql alter table $mt change tag tgcol4 tgcol3 +sql alter table $mt change tag tgcol1 tgcol7 +sql alter table $mt change tag tgcol2 tgcol8 +sql reset query cache +sql alter table $mt change tag tgcol3 tgcol9 +sql alter table $mt change tag tgcol5 tgcol10 +sql alter table $mt change tag tgcol6 tgcol11 + +sleep 3000 +sql reset query cache + +print =============== step2 +$i = 2 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 -x step24 + return -1 +step24: +sql select * from $mt where tgcol2 = 1 -x step25 + return -1 +step25: + +sql select * from $mt where tgcol3 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql select * from $mt where tgcol4 = 2 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +print =============== step3 +$i = 3 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 -x step31 + return -1 +step31: +sql select * from $mt where tgcol2 = 1 -x step32 + return -1 +step32: + +sql select * from $mt where tgcol3 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql select * from $mt where tgcol4 = 2 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +print =============== step4 +$i = 4 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 -x step41 + return -1 +step41: +sql select * from $mt where tgcol2 = 1 -x step42 + return -1 +step42: + +sql select * from $mt where tgcol3 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.00000 then + return -1 +endi + +sql select * from $mt where tgcol4 = 2 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.00000 then + return -1 +endi + +print =============== step5 +$i = 5 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 -x step51 + return -1 +step51: +sql select * from $mt where tgcol2 = 1 -x step52 + return -1 +step52: + +sql select * from $mt where tgcol3 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql select * from $mt where tgcol4 = '2' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +print =============== step6 +$i = 6 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 -x step61 + return -1 +step61: +sql select * from $mt where tgcol2 = 1 -x step62 + return -1 +step62: +sql select * from $mt where tgcol3 = 1 -x step63 + return -1 +step63: +sql select * from $mt where tgcol4 = 1 -x step64 + return -1 +step64: +sql select * from $mt where tgcol5 = 1 -x step65 + return -1 +step65: +sql select * from $mt where tgcol6 = 1 -x step66 + return -1 +step66: + +sql select * from $mt where tgcol7 = '1' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 4 then + return -1 +endi +if $data05 != 5.000000000 then + return -1 +endi +if $data06 != 6 then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol8 = 2 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 4 then + return -1 +endi +if $data05 != 5.000000000 then + return -1 +endi +if $data06 != 6 then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol9 = '4' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 4 then + return -1 +endi +if $data05 != 5.000000000 then + return -1 +endi +if $data06 != 6 then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol10 = 5 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 4 then + return -1 +endi +if $data05 != 5.000000000 then + return -1 +endi +if $data06 != 6 then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol11 = '6' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 4 then + return -1 +endi +if $data05 != 5.000000000 then + return -1 +endi +if $data06 != 6 then + return -1 +endi +if $data07 != null then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/rm_bak/tag/column.sim b/tests/script/general/rm_bak/tag/column.sim new file mode 100644 index 0000000000000000000000000000000000000000..5a0cd169c5a77f0dfd6f81b615bbd09bb8e5a629 --- /dev/null +++ b/tests/script/general/rm_bak/tag/column.sim @@ -0,0 +1,96 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_co_db +$tbPrefix = ta_co_tb +$mtPrefix = ta_co_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db + +$i = 0 +sql create table $mt (ts timestamp, tbcol int, tbcol2 binary(10)) TAGS(tgcol int, tgcol2 binary(10)) + +print =============== step2 + +$i = 0 +$tb = $tbPrefix . $i +sql create table $tb using $mt tags( 0, '0' ) + +$i = 1 +$tb = $tbPrefix . $i +sql create table $tb using $mt tags( 1, 1 ) + +$i = 2 +$tb = $tbPrefix . $i +sql create table $tb using $mt tags( '2', '2' ) + +$i = 3 +$tb = $tbPrefix . $i +sql create table $tb using $mt tags( '3', 3 ) + +sql show tables +if $rows != 4 then + return -1 +endi + +print =============== step3 + +$i = 0 +$tb = $tbPrefix . $i +sql insert into $tb values(now, 0, '0') + +$i = 1 +$tb = $tbPrefix . $i +sql insert into $tb values(now, 1, 1 ) + +$i = 2 +$tb = $tbPrefix . $i +sql insert into $tb values(now, '2', '2') + +$i = 3 +$tb = $tbPrefix . $i +sql insert into $tb values(now, '3', 3) + +print =============== step4 +sql select * from $mt where tgcol2 = '1' +if $rows != 1 then + return -1 +endi + +print =============== step5 +sql select * from $mt +if $rows != 4 then + return -1 +endi + +sql select * from $mt where tgcol = 1 +if $rows != 1 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/rm_bak/tag/commit.sim b/tests/script/general/rm_bak/tag/commit.sim new file mode 100644 index 0000000000000000000000000000000000000000..bcd9d7c618f68eb356813224a7b75f6e649a2e12 --- /dev/null +++ b/tests/script/general/rm_bak/tag/commit.sim @@ -0,0 +1,1184 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i + +sql create database $db +sql use $db + +print =============== step2 +$i = 2 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt add tag tgcol4 int +sql reset query cache +sql alter table $tb set tag tgcol4 =4 +sql reset query cache + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step2 + return -1 +step2: + +print =============== step3 +$i = 3 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt add tag tgcol4 tinyint +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql reset query cache + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step3 + return -1 +step3: + +print =============== step4 +$i = 4 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.00000 then + return -1 +endi + +sql describe $tb +if $data21 != BIGINT then + return -1 +endi +if $data31 != FLOAT then + return -1 +endi +if $data23 != TAG then + return -1 +endi +if $data33 != TAG then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt add tag tgcol4 float +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql reset query cache + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4.00000 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step4 + return -1 +step4: + +print =============== step5 +$i = 5 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10)) +sql create table $tb using $mt tags( 1, '2' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = '2' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt add tag tgcol4 smallint +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql reset query cache + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol3 = '1' -x step5 + return -1 +step5: + +print =============== step6 +$i = 6 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 tinyint) +sql create table $tb using $mt tags( 1, 2, 3 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt add tag tgcol5 binary(10) +sql alter table $mt add tag tgcol6 binary(10) + +sql reset query cache +sql alter table $tb set tag tgcol4=false +sql alter table $tb set tag tgcol5=5 +sql alter table $tb set tag tgcol6=6 +sql reset query cache + +sql select * from $mt where tgcol5 = '5' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 6 then + return -1 +endi + +sql select * from $mt where tgcol6 = '6' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 6 then + return -1 +endi + +sql select * from $mt where tgcol4 = 1 +if $rows != 0 then + return -1 +endi +sql select * from $mt where tgcol3 = 1 -x step52 + return -1 +step52: + +print =============== step7 +$i = 7 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint, tgcol3 binary(10)) +sql create table $tb using $mt tags( 1, 2, '3' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol3 = '3' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt add tag tgcol5 bigint +sql alter table $mt add tag tgcol6 tinyint + +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql alter table $tb set tag tgcol5=5 +sql alter table $tb set tag tgcol6=6 +sql reset query cache + +sql select * from $mt where tgcol6 = 6 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 6 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step71 + return -1 +step71: +sql select * from $mt where tgcol3 = 1 -x step72 + return -1 +step72: + +print =============== step8 +$i = 8 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float, tgcol3 binary(10)) +sql create table $tb using $mt tags( 1, 2, '3' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol3 = '3' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.00000 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt add tag tgcol5 binary(17) +sql alter table $mt add tag tgcol6 bool +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql alter table $tb set tag tgcol5=5 +sql alter table $tb set tag tgcol6=1 +sql reset query cache + +sql select * from $mt where tgcol5 = '5' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 1 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step81 + return -1 +step81: +sql select * from $mt where tgcol3 = 1 -x step82 + return -1 +step82: + +print =============== step9 +$i = 9 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10), tgcol3 binary(10)) +sql create table $tb using $mt tags( 1, 2, '3' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = '2' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt add tag tgcol5 bool +sql alter table $mt add tag tgcol6 float + +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql alter table $tb set tag tgcol5=1 +sql alter table $tb set tag tgcol6=6 +sql reset query cache + +sql select * from $mt where tgcol5 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 4.000000000 then + return -1 +endi +if $data03 != 1 then + return -1 +endi +if $data04 != 6.00000 then + return -1 +endi + +sql select * from $mt where tgcol3 = 1 -x step91 + return -1 +step91: +sql select * from $mt where tgcol2 = 1 -x step92 + return -1 +step92: + +print =============== step10 +$i = 10 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10)) +sql create table $tb using $mt tags( '1', '2', '3', '4' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol4 = '4' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 -x step103 + return -1 +step103: + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol4 +sql reset query cache +sql alter table $mt add tag tgcol4 binary(10) +sql alter table $mt add tag tgcol5 bool + +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql alter table $tb set tag tgcol5=false +sql reset query cache + +sql select * from $mt where tgcol4 = '4' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4 then + return -1 +endi +if $data04 != 0 then + return -1 +endi +if $data05 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step101 + return -1 +step101: +sql select * from $mt where tgcol3 = 1 -x step102 + return -1 +step102: + +print =============== step11 +$i = 11 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 smallint, tgcol4 float, tgcol5 binary(10)) +sql create table $tb using $mt tags( 1, 2, 3, 4, '5' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4.00000 then + return -1 +endi +if $data06 != 5 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 -x step114 + return -1 +step114: + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol4 +sql alter table $mt drop tag tgcol5 +sql reset query cache +sql alter table $mt add tag tgcol4 binary(10) +sql alter table $mt add tag tgcol5 int +sql alter table $mt add tag tgcol6 binary(10) +sql alter table $mt add tag tgcol7 bigint +sql alter table $mt add tag tgcol8 smallint + +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql alter table $tb set tag tgcol5=5 +sql alter table $tb set tag tgcol6=6 +sql alter table $tb set tag tgcol7=7 +sql alter table $tb set tag tgcol8=8 +sql reset query cache + +sql select * from $mt where tgcol5 =5 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4 then + return -1 +endi +if $data04 != 5 then + return -1 +endi +if $data05 != 6 then + return -1 +endi +if $data06 != 7 then + return -1 +endi +if $data07 != 8 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step111 + return -1 +step111: +sql select * from $mt where tgcol3 = 1 -x step112 + return -1 +step112: +sql select * from $mt where tgcol9 = 1 -x step113 + return -1 +step113: + +print =============== step12 +$i = 12 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 smallint, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 binary(20)) +sql create table $tb using $mt tags( 1, 2, 3, 4, '5', '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3.00000 then + return -1 +endi +if $data05 != 4.000000000 then + return -1 +endi +if $data06 != 5 then + return -1 +endi +if $data07 != 6 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol4 +sql alter table $mt drop tag tgcol5 +sql reset query cache +sql alter table $mt add tag tgcol2 binary(10) +sql alter table $mt add tag tgcol3 int +sql alter table $mt add tag tgcol4 binary(10) +sql alter table $mt add tag tgcol5 bigint + +sql reset query cache +sql alter table $tb set tag tgcol1=false +sql alter table $tb set tag tgcol2=5 +sql alter table $tb set tag tgcol3=4 +sql alter table $tb set tag tgcol4=3 +sql alter table $tb set tag tgcol5=2 +sql alter table $tb set tag tgcol6=1 +sql reset query cache + +sql select * from $mt where tgcol4 = '3' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 1 then + return -1 +endi +if $data04 != 5 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 3 then + return -1 +endi +if $data07 != 2 then + return -1 +endi + +sql select * from $mt where tgcol2 = '5' +if $rows != 1 then + return -1 +endi + +sql select * from $mt where tgcol3 = 4 +if $rows != 1 then + return -1 +endi + +sql select * from $mt where tgcol5 = 2 +if $rows != 1 then + return -1 +endi + +sql select * from $mt where tgcol6 = '1' +if $rows != 1 then + return -1 +endi + +print =============== step13 +$i = 13 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20)) +sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = '1' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 5.000000000 then + return -1 +endi +if $data07 != 6 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol4 +sql alter table $mt drop tag tgcol6 +sql reset query cache +sql alter table $mt add tag tgcol2 binary(10) +sql alter table $mt add tag tgcol4 int +sql alter table $mt add tag tgcol6 bigint + +sql reset query cache +sql alter table $tb set tag tgcol1=7 +sql alter table $tb set tag tgcol2=8 +sql alter table $tb set tag tgcol3=9 +sql alter table $tb set tag tgcol4=10 +sql alter table $tb set tag tgcol5=11 +sql alter table $tb set tag tgcol6=12 +sql reset query cache + +sql select * from $mt where tgcol2 = '8' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 7 then + return -1 +endi +if $data03 != 9 then + return -1 +endi +if $data04 != 11.000000000 then + return -1 +endi +if $data05 != 8 then + return -1 +endi +if $data06 != 10 then + return -1 +endi +if $data07 != 12 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i + +sql use $db + +print =============== step2 +$i = 2 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +print =============== step3 +$i = 3 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +print =============== step4 +$i = 4 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4.00000 then + return -1 +endi + + +print =============== step5 +$i = 5 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + + +print =============== step6 +$i = 6 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol5 = '5' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 6 then + return -1 +endi + +sql select * from $mt where tgcol6 = '6' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 6 then + return -1 +endi + +sql select * from $mt where tgcol4 = 1 +if $rows != 0 then + return -1 +endi + +print =============== step7 +$i = 7 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol6 = 6 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 6 then + return -1 +endi + + +print =============== step8 +$i = 8 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol5 = '5' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 1 then + return -1 +endi + + +print =============== step9 +$i = 9 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol5 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 4.000000000 then + return -1 +endi +if $data03 != 1 then + return -1 +endi +if $data04 != 6.00000 then + return -1 +endi + + +print =============== step10 +$i = 10 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol4 = '4' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4 then + return -1 +endi +if $data04 != 0 then + return -1 +endi +if $data05 != null then + return -1 +endi + +print =============== step11 +$i = 11 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol5 =5 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4 then + return -1 +endi +if $data04 != 5 then + return -1 +endi +if $data05 != 6 then + return -1 +endi +if $data06 != 7 then + return -1 +endi +if $data07 != 8 then + return -1 +endi + +print =============== step12 +$i = 12 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + + +sql select * from $mt where tgcol4 = '3' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 1 then + return -1 +endi +if $data04 != 5 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 3 then + return -1 +endi +if $data07 != 2 then + return -1 +endi + +sql select * from $mt where tgcol2 = '5' +if $rows != 1 then + return -1 +endi + +sql select * from $mt where tgcol3 = 4 +if $rows != 1 then + return -1 +endi + +sql select * from $mt where tgcol5 = 2 +if $rows != 1 then + return -1 +endi + +sql select * from $mt where tgcol6 = '1' +if $rows != 1 then + return -1 +endi + +print =============== step13 +$i = 13 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol2 = '8' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 7 then + return -1 +endi +if $data03 != 9 then + return -1 +endi +if $data04 != 11.000000000 then + return -1 +endi +if $data05 != 8 then + return -1 +endi +if $data06 != 10 then + return -1 +endi +if $data07 != 12 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/rm_bak/tag/create.sim b/tests/script/general/rm_bak/tag/create.sim new file mode 100644 index 0000000000000000000000000000000000000000..95b416654394946287cc8f9cdb95b984edbf3a88 --- /dev/null +++ b/tests/script/general/rm_bak/tag/create.sim @@ -0,0 +1,604 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_cr_db +$tbPrefix = ta_cr_tb +$mtPrefix = ta_cr_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i + +sql create database $db +sql use $db + +print =============== step2 +$i = 2 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool) +sql create table $tb using $mt tags( 1 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 0 then + return -1 +endi + +print =============== step3 +$i = 3 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol smallint) +sql create table $tb using $mt tags( 1 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 0 then + return -1 +endi + +print =============== step4 +$i = 4 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol tinyint) +sql create table $tb using $mt tags( 1 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 0 then + return -1 +endi + +print =============== step5 +$i = 5 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) +sql create table $tb using $mt tags( 1 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 0 then + return -1 +endi + +print =============== step6 +$i = 6 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bigint) +sql create table $tb using $mt tags( 1 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 0 then + return -1 +endi + +print =============== step7 +$i = 7 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol float) +sql create table $tb using $mt tags( 1 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 0 then + print expect 0, actual: $rows + return -1 +endi + +print =============== step8 +$i = 8 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol double) +sql create table $tb using $mt tags( 1 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 0 then + return -1 +endi + +print =============== step9 +$i = 9 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(10)) +sql create table $tb using $mt tags( '1') +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = '1' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol = '0' +if $rows != 0 then + return -1 +endi + +print =============== step10 +$i = 10 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 bool) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + print expect 1, actual: $rows + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step11 +$i = 11 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 smallint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step12 +$i = 12 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 tinyint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step13 +$i = 13 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 int) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step14 +$i = 14 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 bigint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi +print =============== step15 +$i = 15 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 float) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step16 +$i = 16 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 double) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step17 +$i = 17 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 binary(10)) +sql create table $tb using $mt tags( 1, '2' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = true +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step18 +$i = 18 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol smallint, tgcol2 tinyint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step19 +$i = 19 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol tinyint, tgcol2 int) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step20 +$i = 20 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int, tgcol2 bigint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step21 +$i = 21 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bigint, tgcol2 float) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step22 +$i = 22 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol float, tgcol2 double) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step23 +$i = 23 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol double, tgcol2 binary(10)) +sql create table $tb using $mt tags( 1, '2' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = '2' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step24 +$i = 24 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 bool, tgcol3 int, tgcol4 float, tgcol5 double, tgcol6 binary(10)) +sql create table $tb using $mt tags( 1, 2, 3, 4, 5, '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol3 = 3 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol4 = 4 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol5 = 5 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol6 = '6' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol6 = '0' +if $rows != 0 then + return -1 +endi + +print =============== step25 +$i = 25 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 int, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 binary(10)) +sql create table $tb using $mt tags( 1, 2, 3, 4, '5', '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol6 = '6' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol6 = '0' +if $rows != 0 then + return -1 +endi + +print =============== step26 +$i = 26 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10), tgcol5 binary(10), tgcol6 binary(10)) +sql create table $tb using $mt tags( '1', '2', '3', '4', '5', '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol3 = '3' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol3 = '0' +if $rows != 0 then + return -1 +endi + +print =============== step27 +$i = 27 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 bool, tgcol3 int, tgcol4 float, tgcol5 double, tgcol6 binary(10), tgcol7) -x step27 + return -1 +step27: + +print =============== step28 +$i = 28 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(250), tgcol2 binary(250)) +sql create table $tb using $mt tags('1', '1') +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = '1' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +print =============== step29 +$i = 29 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(25), tgcol2 binary(250)) +sql create table $tb using $mt tags('1', '1') +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = '1' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +print =============== step30 +$i = 30 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(250), tgcol2 binary(250), tgcol3 binary(30)) -x step30 +# return -1 +step30: + +print =============== step31 +$i = 31 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(5)) +sql_error create table $tb using $mt tags('1234567') +sql create table $tb using $mt tags('12345') +sql insert into $tb values(now, 1) +sql select * from $mt +print sql select * from $mt +if $rows != 1 then + return -1 +endi + +print $data00 $data01 $data02 +if $data02 != 12345 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/rm_bak/tag/delete.sim b/tests/script/general/rm_bak/tag/delete.sim new file mode 100644 index 0000000000000000000000000000000000000000..2a0aa27bde6ef70e5354695a83dfc2d3853e1463 --- /dev/null +++ b/tests/script/general/rm_bak/tag/delete.sim @@ -0,0 +1,827 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_de_db +$tbPrefix = ta_de_tb +$mtPrefix = ta_de_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i + +sql create database $db +sql use $db + +print =============== step2 +$i = 2 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 + +print =============== step3 +$i = 3 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 + +print =============== step4 +$i = 4 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 < 3 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.00000 then + return -1 +endi + +sql describe $tb +if $data21 != BIGINT then + return -1 +endi +if $data31 != FLOAT then + return -1 +endi +if $data23 != TAG then + return -1 +endi + +sql alter table $mt drop tag tgcol1 -x step40 + return -1 +step40: +sql alter table $mt drop tag tgcol2 + +print =============== step5 +$i = 5 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10)) +sql create table $tb using $mt tags( 1, '2' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = '2' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt drop tag tgcol1 -x step50 + return -1 +step50: +sql alter table $mt drop tag tgcol2 + +print =============== step6 +$i = 6 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 tinyint) +sql create table $tb using $mt tags( 1, 2, 3 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 + +print =============== step7 +$i = 7 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint, tgcol3 binary(10)) +sql create table $tb using $mt tags( 1, 2, '3' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol3 = '3' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql describe $tb +if $data21 != SMALLINT then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data41 != BINARY then + return -1 +endi +if $data22 != 2 then + return -1 +endi +if $data32 != 1 then + return -1 +endi +if $data42 != 10 then + return -1 +endi +if $data23 != TAG then + return -1 +endi +if $data33 != TAG then + return -1 +endi +if $data43 != TAG then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 + +print =============== step8 +$i = 8 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float, tgcol3 binary(10)) +sql create table $tb using $mt tags( 1, 2, '3' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol3 = '3' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.00000 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 + +print =============== step9 +$i = 9 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10), tgcol3 binary(10)) +sql create table $tb using $mt tags( 1, '2', '3' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol2 + +print =============== step10 +$i = 10 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10)) +sql create table $tb using $mt tags( '1', '2', '3', '4' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol4 = '4' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4 then + return -1 +endi + +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol4 + +print =============== step11 +$i = 11 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 smallint, tgcol4 float, tgcol5 binary(10)) +sql create table $tb using $mt tags( 1, 2, 3, 4, '5' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4.00000 then + return -1 +endi +if $data06 != 5 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol5 + +print =============== step12 +$i = 12 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 smallint, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 binary(20)) +sql create table $tb using $mt tags( 1, 2, 3, 4, '5', '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3.00000 then + return -1 +endi +if $data05 != 4.000000000 then + return -1 +endi +if $data06 != 5 then + return -1 +endi +if $data07 != 6 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol5 +sql alter table $mt drop tag tgcol6 + +print =============== step13 +$i = 13 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20)) +sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = '1' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 5.000000000 then + return -1 +endi +if $data07 != 6 then + return -1 +endi + +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol4 +sql alter table $mt drop tag tgcol6 + +sleep 3000 + +print =============== step2 +$i = 2 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step2 + return -1 +step2: + +print =============== step3 +$i = 3 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step3 + return -1 +step3: + +print =============== step4 +$i = 4 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step4 + return -1 +step4: + +print =============== step5 +$i = 5 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = '1' -x step5 + return -1 +step5: + +print =============== step6 +$i = 6 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data04 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step51 + return -1 +step51: +sql select * from $mt where tgcol3 = 1 -x step52 + return -1 +step52: + +print =============== step7 +$i = 7 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data04 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step71 + return -1 +step71: +sql select * from $mt where tgcol3 = 1 -x step72 + return -1 +step72: + +print =============== step8 +$i = 8 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data04 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step81 + return -1 +step81: +sql select * from $mt where tgcol3 = 1 -x step82 + return -1 +step82: + +print =============== step9 +$i = 9 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data04 != null then + return -1 +endi + +sql select * from $mt where tgcol3 = 1 -x step91 + return -1 +step91: +sql select * from $mt where tgcol2 = 1 -x step92 + return -1 +step92: + +print =============== step10 +$i = 10 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = '1' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data04 != null then + return -1 +endi +if $data05 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step101 + return -1 +step101: +sql select * from $mt where tgcol3 = 1 -x step102 + return -1 +step102: +sql select * from $mt where tgcol4 = 1 -x step103 + return -1 +step103: + +print =============== step11 +$i = 11 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol4=4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4.00000 then + return -1 +endi +if $data04 != null then + return -1 +endi +if $data05 != null then + return -1 +endi +if $data06 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step111 + return -1 +step111: +sql select * from $mt where tgcol3 = 1 -x step112 + return -1 +step112: +sql select * from $mt where tgcol5 = 1 -x step113 + return -1 +step113: + +print =============== step12 +$i = 12 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4.000000000 then + return -1 +endi +if $data04 != null then + return -1 +endi +if $data05 != null then + return -1 +endi +if $data06 != null then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step120 + return -1 +step120: +sql select * from $mt where tgcol3 = 1 -x step121 + return -1 +step121: +sql select * from $mt where tgcol5 = 1 -x step122 + return -1 +step122: +sql select * from $mt where tgcol6 = 1 -x step123 + return -1 +step123: + +print =============== step13 +$i = 13 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql reset query cache +sql select * from $mt where tgcol2 = 2 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 5.000000000 then + return -1 +endi +if $data05 != null then + return -1 +endi +if $data06 != null then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol3 = 1 -x step130 + return -1 +step130: +sql select * from $mt where tgcol4 = 1 -x step131 + return -1 +step131: +sql select * from $mt where tgcol6 = 1 -x step133 + return -1 +step133: + +print =============== step14 +$i = 14 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 bigint) +sql create table $tb using $mt tags( 1, 1 ) +sql insert into $tb values(now, 1) + +sql alter table xxmt drop tag tag1 -x step141 + return -1 +step141: +sql alter table $tb drop tag tag1 -x step142 + return -1 +step142: +sql alter table $mt drop tag tag1 -x step143 + return -1 +step143: + +sql alter table $mt drop tag tagcol1 -x step144 + return -1 +step144: + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol1 -x step145 + return -1 +step145: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/rm_bak/tag/double.sim b/tests/script/general/rm_bak/tag/double.sim new file mode 100644 index 0000000000000000000000000000000000000000..f17043393ffe51f7cdce4fb053168746430ab498 --- /dev/null +++ b/tests/script/general/rm_bak/tag/double.sim @@ -0,0 +1,244 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_do_db +$tbPrefix = ta_do_tb +$mtPrefix = ta_do_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol double) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sleep 100 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi +sql select * from $tb where ts < now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts <= now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts > now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts >= now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 5m +if $rows != 1 then + return -1 +endi +sql select * from $tb where ts < now + 4m and ts > now + 5m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > 100000 and ts < 100000 +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 3m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/rm_bak/tag/filter.sim b/tests/script/general/rm_bak/tag/filter.sim new file mode 100644 index 0000000000000000000000000000000000000000..7a899a7e67d9261ea2a68c5ad1ee311f03278cb9 --- /dev/null +++ b/tests/script/general/rm_bak/tag/filter.sim @@ -0,0 +1,149 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_fi_db +$tbPrefix = ta_fi_tb +$mtPrefix = ta_fi_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(10)) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '0' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '1' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tg = '1' -x step2 + return -1 +step2: + +print =============== step3 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where noexist = '1' -x step3 + return -1 +step3: + +print =============== step4 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = '1' +if $rows != 1 then + return -1 +endi +if $data00 != 10 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(cc), sum(xx), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt -x step6 + return -1 +step6: + +print =============== step7 +sql select count(tgcol), avg(tgcol), sum(tgcol), min(tgcol), max(tgcol), first(tgcol), last(tgcol) from $mt -x step7 + return -1 +step7: + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tbcol + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by noexist -x step9 + return -1 +step9: + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol) as c from $mt group by tbcol + +print =============== step12 +sql select count(tbcol) as c from $mt group by noexist -x step12 + return -1 +step12: + +print =============== step13 +sql select count(tbcol) as c from $mt group by tgcol +print $data00 +if $data00 != 100 then + return -1 +endi + +print =============== step14 +sql select count(tbcol) as c from $mt where ts > 1000 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + print expect 100, actual $data00 + return -1 +endi + +print =============== step15 +sql select count(tbcol) as c from $mt where noexist < 1 group by tgcol -x step15 + return -1 +step15: + +print =============== step16 +sql select count(tbcol) as c from $mt where tgcol = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/rm_bak/tag/float.sim b/tests/script/general/rm_bak/tag/float.sim new file mode 100644 index 0000000000000000000000000000000000000000..35bf7d6090140ba73cb0c63efd57d828fb6b21bb --- /dev/null +++ b/tests/script/general/rm_bak/tag/float.sim @@ -0,0 +1,244 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_fl_db +$tbPrefix = ta_fl_tb +$mtPrefix = ta_fl_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol float) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sleep 100 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi +sql select * from $tb where ts < now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts <= now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts > now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts >= now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 5m +if $rows != 1 then + return -1 +endi +sql select * from $tb where ts < now + 4m and ts > now + 5m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > 100000 and ts < 100000 +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 3m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/rm_bak/tag/int.sim b/tests/script/general/rm_bak/tag/int.sim new file mode 100644 index 0000000000000000000000000000000000000000..4eea02c9cd4438f16cdf759fef0ade88eaabc8b1 --- /dev/null +++ b/tests/script/general/rm_bak/tag/int.sim @@ -0,0 +1,244 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_in_db +$tbPrefix = ta_in_tb +$mtPrefix = ta_in_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sleep 100 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi +sql select * from $tb where ts < now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts <= now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts > now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts >= now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 5m +if $rows != 1 then + return -1 +endi +sql select * from $tb where ts < now + 4m and ts > now + 5m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > 100000 and ts < 100000 +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 3m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/rm_bak/tag/int_binary.sim b/tests/script/general/rm_bak/tag/int_binary.sim new file mode 100644 index 0000000000000000000000000000000000000000..9a756976769c6294f65f61c5318033274b1145f2 --- /dev/null +++ b/tests/script/general/rm_bak/tag/int_binary.sim @@ -0,0 +1,311 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_inb_db +$tbPrefix = ta_inb_tb +$mtPrefix = ta_inb_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int, tgcol2 binary(5)) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, '0' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, '1' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 = '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> '1' +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select * from $mt where ts > now + 4m and tgcol2 = '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> '0' +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > now + 4m and tgcol2 = '1' and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '1' and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = '0' and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> '0' and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = '0' and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> '0' and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and ts < now + 5m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 and tgcol2 = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 and tgcol2 = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + + +print =============== step13 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step14 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/rm_bak/tag/int_float.sim b/tests/script/general/rm_bak/tag/int_float.sim new file mode 100644 index 0000000000000000000000000000000000000000..a03c4b7148ab14c9c0b1e28d3fc28dc86df0c2d9 --- /dev/null +++ b/tests/script/general/rm_bak/tag/int_float.sim @@ -0,0 +1,327 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_inf_db +$tbPrefix = ta_inf_tb +$mtPrefix = ta_inf_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int, tgcol2 float) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 > 0.5 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 < 0.5 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 > 0.5 and tgcol2 < 1.5 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 and tgcol2 = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + + +print =============== step13 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step14 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/rm_bak/tag/set.sim b/tests/script/general/rm_bak/tag/set.sim new file mode 100644 index 0000000000000000000000000000000000000000..cbc964fad7d73b9ba6fee5128e50bb4b9dfa433b --- /dev/null +++ b/tests/script/general/rm_bak/tag/set.sim @@ -0,0 +1,459 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_se_db +$tbPrefix = ta_se_tb +$mtPrefix = ta_se_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i + +sql create database $db +sql use $db + +print =============== step2 +$i = 2 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $tb set tag tagcx 1 -x step21 + return -1 +step21: +sql alter table $tb set tag tgcol1=false +sql alter table $tb set tag tgcol2=4 + +sql reset query cache + +sql select * from $mt where tgcol1 = false +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol2 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql describe $tb +print $data21 $data23 $data32 $data33 +if $data21 != BOOL then + return -1 +endi +if $data31 != INT then + return -1 +endi +if $data23 != TAG then + return -1 +endi +if $data33 != TAG then + return -1 +endi + +print =============== step3 +$i = 3 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $tb set tag tgcol1=3 +sql alter table $tb set tag tgcol2=4 + +sql reset query cache + +sql select * from $mt where tgcol1 = 3 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 3 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol2 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 3 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol2 = 2 +if $rows != 0 then + return -1 +endi + + +print =============== step4 +$i = 4 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.00000 then + return -1 +endi + +sql alter table $tb set tag tgcol1=3 +sql alter table $tb set tag tgcol2=4 + +sql reset query cache + +sql select * from $mt where tgcol1 = 3 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 3 then + return -1 +endi +if $data03 != 4.00000 then + return -1 +endi + +sql select * from $mt where tgcol2 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 3 then + return -1 +endi +if $data03 != 4.00000 then + return -1 +endi + + +print =============== step5 +$i = 5 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10)) +sql create table $tb using $mt tags( 1, '2' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = '2' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $tb set tag tgcol1=3 +sql alter table $tb set tag tgcol2='4' + +sql reset query cache + +sql select * from $mt where tgcol1 = 3 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 3.000000000 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol2 = '4' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 3.000000000 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +print =============== step6 +$i = 6 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20)) +sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = '1' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 5.000000000 then + return -1 +endi +if $data07 != 6 then + return -1 +endi + +sql alter table $mt drop tag tgcol3 +sql alter table $tb set tag tgcol1='7' +sql alter table $tb set tag tgcol2=8 +sql alter table $tb set tag tgcol4='9' +sql alter table $tb set tag tgcol5=10 +sql alter table $tb set tag tgcol6='11' + +sql reset query cache + +sql select * from $mt where tgcol1 = '7' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 7 then + return -1 +endi +if $data03 != 8 then + return -1 +endi +if $data04 != 9 then + return -1 +endi +if $data05 != 10.000000000 then + return -1 +endi +if $data06 != 11 then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 8 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 7 then + return -1 +endi +if $data03 != 8 then + return -1 +endi +if $data04 != 9 then + return -1 +endi +if $data05 != 10.000000000 then + return -1 +endi +if $data06 != 11 then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol4 = '9' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 7 then + return -1 +endi +if $data03 != 8 then + return -1 +endi +if $data04 != 9 then + return -1 +endi +if $data05 != 10.000000000 then + return -1 +endi +if $data06 != 11 then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol5 = 10 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 7 then + return -1 +endi +if $data03 != 8 then + return -1 +endi +if $data04 != 9 then + return -1 +endi +if $data05 != 10.000000000 then + return -1 +endi +if $data06 != 11 then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol6 = '11' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 7 then + return -1 +endi +if $data03 != 8 then + return -1 +endi +if $data04 != 9 then + return -1 +endi +if $data05 != 10.000000000 then + return -1 +endi +if $data06 != 11 then + return -1 +endi +if $data07 != null then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/rm_bak/tag/smallint.sim b/tests/script/general/rm_bak/tag/smallint.sim new file mode 100644 index 0000000000000000000000000000000000000000..e69eef05f274175b55ba78e4c9f69a5e102eb6f8 --- /dev/null +++ b/tests/script/general/rm_bak/tag/smallint.sim @@ -0,0 +1,244 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_sm_db +$tbPrefix = ta_sm_tb +$mtPrefix = ta_sm_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol smallint) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sleep 100 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi +sql select * from $tb where ts < now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts <= now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts > now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts >= now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 5m +if $rows != 1 then + return -1 +endi +sql select * from $tb where ts < now + 4m and ts > now + 5m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > 100000 and ts < 100000 +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 3m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/rm_bak/tag/testSuite.sim b/tests/script/general/rm_bak/tag/testSuite.sim new file mode 100644 index 0000000000000000000000000000000000000000..45356efac1daa4f8f5fae06b8aad8c7b139bc9a0 --- /dev/null +++ b/tests/script/general/rm_bak/tag/testSuite.sim @@ -0,0 +1,25 @@ +run general/tag/3.sim +run general/tag/4.sim +run general/tag/5.sim +run general/tag/6.sim +run general/tag/add.sim +run general/tag/bigint.sim +run general/tag/binary_binary.sim +run general/tag/binary.sim +run general/tag/bool_binary.sim +run general/tag/bool_int.sim +run general/tag/bool.sim +run general/tag/change.sim +run general/tag/column.sim +run general/tag/commit.sim +run general/tag/create.sim +run general/tag/delete.sim +run general/tag/double.sim +run general/tag/filter.sim +run general/tag/float.sim +run general/tag/int_binary.sim +run general/tag/int_float.sim +run general/tag/int.sim +run general/tag/set.sim +run general/tag/smallint.sim +run general/tag/tinyint.sim diff --git a/tests/script/general/rm_bak/tag/tinyint.sim b/tests/script/general/rm_bak/tag/tinyint.sim new file mode 100644 index 0000000000000000000000000000000000000000..2d70dc7d4880d4b1540da557f779fe06b877dabc --- /dev/null +++ b/tests/script/general/rm_bak/tag/tinyint.sim @@ -0,0 +1,244 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_ti_db +$tbPrefix = ta_ti_tb +$mtPrefix = ta_ti_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol tinyint) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sleep 100 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi +sql select * from $tb where ts < now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts <= now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts > now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts >= now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 5m +if $rows != 1 then + return -1 +endi +sql select * from $tb where ts < now + 4m and ts > now + 5m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > 100000 and ts < 100000 +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 3m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/stable/disk.sim b/tests/script/general/stable/disk.sim new file mode 100644 index 0000000000000000000000000000000000000000..1faae78e898107af6d3a1140413ffe16b0680e26 --- /dev/null +++ b/tests/script/general/stable/disk.sim @@ -0,0 +1,199 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = d_db +$tbPrefix = d_tb +$mtPrefix = d_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $val = $x * 60000 + $ms = 1519833600000 + $val + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sql show vgroups +print vgroups ==> $rows +if $rows != 3 then + return -1 +endi + +sql select count(*) from $mt +print select count(*) from $mt ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +sleep 1000 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +sleep 6000 + +sql use $db +sql show vgroups +print vgroups ==> $rows +if $rows != 3 then + return -1 +endi + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +sql select count(tbcol) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step3 +sql select count(tbcol) from $tb where ts <= 1519833840000 +print ===> $data00 +if $data00 != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol) as b from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step5 +sql select count(tbcol) as b from $tb interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi + +sql select count(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != $rowNum then + return -1 +endi + +print =============== step6 +sql select count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select count(*) from $mt +print select count(*) from $mt ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +sql select count(tbcol) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +print =============== step8 +sql select count(tbcol) as c from $mt where ts <= 1519833840000 +print ===> $data00 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 and ts <= 1519833840000 +print ===> $data00 +if $data00 != 25 then + return -1 +endi + +print =============== step9 +sql select count(tbcol) as b from $mt interval(1m) +print select count(tbcol) as b from $mt interval(1m) ===> $data01 +if $data01 != 10 then + return -1 +endi + +sql select count(tbcol) as b from $mt interval(1d) +print ===> $data02 +if $data01 != 200 then + return -1 +endi + +print =============== step10 +print select count(tbcol) as b from $mt group by tgcol +sql select count(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select count(tbcol) as b from $mt where ts <= 1519833840000 interval(1m) group by tgcol +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/stable/dnode3.sim b/tests/script/general/stable/dnode3.sim new file mode 100644 index 0000000000000000000000000000000000000000..872cfb8d2e5022872e30eaabd7db67a4546a0204 --- /dev/null +++ b/tests/script/general/stable/dnode3.sim @@ -0,0 +1,212 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode3 -c walLevel -v 1 +system sh/cfg.sh -n dnode4 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sql connect + +sql create dnode $hostname2 +sql create dnode $hostname3 +sql create dnode $hostname4 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_2 == offline then + goto createDnode +endi +if $data4_3 == offline then + goto createDnode +endi +if $data4_4 == offline then + goto createDnode +endi + +print ======================== dnode1 start + +$dbPrefix = r3v3_db +$tbPrefix = r3v3_tb +$mtPrefix = r3v3_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $val = $x * 60000 + $ms = 1519833600000 + $val + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sql show vgroups +print vgroups ==> $rows +if $rows != 3 then + return -1 +endi + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +sql select count(tbcol) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step3 +sql select count(tbcol) from $tb where ts <= 1519833840000 +print ===> $data00 +if $data00 != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol) as b from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step5 +sql select count(tbcol) as b from $tb interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi + +sql select count(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != $rowNum then + return -1 +endi + +print =============== step6 +sql select count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +print select count(*) from $mt +sql select count(*) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +sql select count(tbcol) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +print =============== step8 +sql select count(tbcol) as c from $mt where ts <= 1519833840000 +print ===> $data00 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 and ts <= 1519833840000 +print ===> $data00 +if $data00 != 25 then + return -1 +endi + +print =============== step9 +sql select count(tbcol) as b from $mt interval(1m) +print ===> $data01 +if $data01 != 10 then + return -1 +endi + +sql select count(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 200 then + return -1 +endi + +print =============== step10 +sql select count(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select count(tbcol) as b from $mt where ts <= 1519833840000 interval(1m) group by tgcol +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/stable/metrics.sim b/tests/script/general/stable/metrics.sim new file mode 100644 index 0000000000000000000000000000000000000000..a3dca3f1a5a5f2234520e987ab356f6ed68f0afc --- /dev/null +++ b/tests/script/general/stable/metrics.sim @@ -0,0 +1,136 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$dbPrefix = m_me_db +$tbPrefix = m_me_tb +$mtPrefix = m_me_mt + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db + +sql create table $mt (ts timestamp, speed int) TAGS(sp int) +sql show stables +if $rows != 1 then + return -1 +endi + +print =============== step2 +sql drop table $mt +sql show stables +if $rows != 0 then + return -1 +endi + +print =============== step3 +sql create table $mt (ts timestamp, speed int) TAGS(sp int) + +sql show stables +if $rows != 1 then + return -1 +endi +if $data00 != $mt then + return -1 +endi +if $data04 != 0 then + return -1 +endi +sql select * from $mt +if $rows != 0 then + return -1 +endi + +print =============== step4 +$i = 0 +$tb = $tbPrefix . $i +sql create table $tb using $mt tags(1) +$i = 1 +$tb = $tbPrefix . $i +sql create table $tb using $mt tags(2) +$i = 2 +$tb = $tbPrefix . $i +sql create table $tb using $mt tags(3) + +sql show tables +if $rows != 3 then + return -1 +endi +if $data03 != $mt then + return -1 +endi + +sql show stables +if $rows != 1 then + return -1 +endi +if $data00 != $mt then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +print =============== step5 +$i = 0 +$tb = $tbPrefix . $i +sql insert into $tb values (now + 1m , 1 ) +$i = 1 +$tb = $tbPrefix . $i +sql insert into $tb values (now + 1m , 1 ) +$i = 2 +$tb = $tbPrefix . $i +sql insert into $tb values (now + 1m , 1 ) + +print sleep 8000 +sleep 8000 + +print =============== step6 + +sql select * from $mt +print select * from $mt ==> $rows $data00 +if $rows != 3 then + return -1 +endi + +print =============== step7 +sql select * from $mt where sp = 1 +print select * from $mt where sp = 1 ==> $rows $data00 +if $rows != 1 then + return -1 +endi + +print =============== step8 +sql drop table $mt + +print =============== step9 + +sql show tables +if $rows != 0 then + return -1 +endi + +sql show stables +if $rows != 0 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/stable/refcount.sim b/tests/script/general/stable/refcount.sim new file mode 100644 index 0000000000000000000000000000000000000000..6629dc1177c6021fce45f135f153475f6cb858a3 --- /dev/null +++ b/tests/script/general/stable/refcount.sim @@ -0,0 +1,131 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print =============== step1 +sql create database d1; +sql use d1; +sql create table d1.t1 (ts timestamp, i int); +sql create table d1.t2 (ts timestamp, i int); +sql create table d1.t3 (ts timestamp, i int); +sql insert into d1.t1 values(now, 1); +sql insert into d1.t2 values(now, 1); +sql drop table d1.t1; +sql drop database d1; + +sql show databases; +if $rows != 0 then + return -1 +endi + +print =============== step2 +sql create database d2; +sql use d2; +sql create table d2.t1 (ts timestamp, i int); +sql create table d2.t2 (ts timestamp, i int); +sql create table d2.t3 (ts timestamp, i int); +sql insert into d2.t1 values(now, 1); +sql insert into d2.t2 values(now, 1); +sql drop table d2.t1; +sql drop table d2.t2; +sql drop table d2.t3; + +sql show d2.tables; +if $rows != 0 then + return -1 +endi + +sql show d2.vgroups; +if $rows != 0 then + return -1 +endi + +sql drop database d2; + +sql show databases; +if $rows != 0 then + return -1 +endi + +print =============== step3 +sql create database d3; +sql use d3; +sql create table d3.st (ts timestamp, i int) tags (j int); +sql create table d3.t1 using d3.st tags(1); +sql create table d3.t2 using d3.st tags(1); +sql create table d3.t3 using d3.st tags(1); +sql insert into d3.t1 values(now, 1); +sql drop table d3.t1; +sql drop table d3.t2; +sql drop table d3.t3; + +sql show d3.tables; +if $rows != 0 then + return -1 +endi + +sql show d3.vgroups; +if $rows != 0 then + return -1 +endi + +sql drop database d3; + +sql show databases; +if $rows != 0 then + return -1 +endi + +print =============== step4 +sql create database d4; +sql use d4; +sql create table d4.st (ts timestamp, i int) tags (j int); +sql create table d4.t1 using d4.st tags(1); +sql create table d4.t2 using d4.st tags(1); +sql create table d4.t3 using d4.st tags(1); +sql insert into d4.t1 values(now, 1); +sql drop table d4.t1; +sql drop table d4.st; + +sql show d4.tables; +if $rows != 0 then + return -1 +endi + +sql show d4.stables; +if $rows != 0 then + return -1 +endi + +sql drop database d4; + +sql show databases; +if $rows != 0 then + return -1 +endi + +print =============== step5 +sql create database d5; +sql use d5; +sql create table d5.st (ts timestamp, i int) tags (j int); +sql create table d5.t1 using d5.st tags(1); +sql create table d5.t2 using d5.st tags(1); +sql create table d5.t3 using d5.st tags(1); +sql insert into d5.t1 values(now, 1); +sql drop table d5.t1; + +sql drop database d5; + +sql show databases; +if $rows != 0 then + return -1 +endi + +print =============== step6 +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/stable/show.sim b/tests/script/general/stable/show.sim new file mode 100644 index 0000000000000000000000000000000000000000..5fe05b41eb8fb6f0080eeea35cc63506faf55e5c --- /dev/null +++ b/tests/script/general/stable/show.sim @@ -0,0 +1,48 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== create stable + +sql create database d1 + +$x = 0 +while $x < 128 + $tb = d1.s . $x + sql create table $tb (ts timestamp, i int) tags (j int) + $x = $x + 1 +endw + +print ======================== show stables + +sql show d1.stables + +print num of stables is $rows +if $rows != 128 then + return -1 +endi + +print ======================== create table + +$x = 0 +while $x < 424 + $tb = d1.t . $x + sql create table $tb using d1.s0 tags( $x ) + $x = $x + 1 +endw + +print ======================== show stables + +sql show d1.tables + +print num of tables is $rows +if $rows != 424 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/stable/testSuite.sim b/tests/script/general/stable/testSuite.sim new file mode 100644 index 0000000000000000000000000000000000000000..e786ac9ca4d1b3e8aea7cec9625fe2fd1481377b --- /dev/null +++ b/tests/script/general/stable/testSuite.sim @@ -0,0 +1,5 @@ +run general/stable/disk.sim +run general/stable/dnode3.sim +run general/stable/metrics.sim +run general/stable/values.sim +run general/stable/vnode3.sim diff --git a/tests/script/general/stable/values.sim b/tests/script/general/stable/values.sim new file mode 100644 index 0000000000000000000000000000000000000000..fb2c908da269872ddd85489d9d98510e1bb58749 --- /dev/null +++ b/tests/script/general/stable/values.sim @@ -0,0 +1,113 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== dnode1 start + +sql create database vdb0 +sql create table vdb0.mt (ts timestamp, tbcol int) TAGS(tgcol int) + +sql create table vdb0.vtb00 using vdb0.mt tags( 0 ) +sql create table vdb0.vtb01 using vdb0.mt tags( 0 ) + +sql create database vdb1 +sql create table vdb1.mt (ts timestamp, tbcol int) TAGS(tgcol int) +sql_error create table vdb1.vtb10 using vdb0.mt tags( 1 ) +sql_error create table vdb1.vtb11 using vdb0.mt tags( 1 ) +sql create table vdb1.vtb10 using vdb1.mt tags( 1 ) +sql create table vdb1.vtb11 using vdb1.mt tags( 1 ) + +sql create database vdb2 +sql create table vdb2.mt (ts timestamp, tbcol int) TAGS(tgcol int) +sql_error create table vdb2.vtb20 using vdb0.mt tags( 2 ) +sql_error create table vdb2.vtb21 using vdb0.mt tags( 2 ) +sql create table vdb2.vtb20 using vdb2.mt tags( 2 ) +sql create table vdb2.vtb21 using vdb2.mt tags( 2 ) + +sql create database vdb3 +sql create table vdb3.mt (ts timestamp, tbcol int) TAGS(tgcol int) +sql_error create table vdb3.vtb20 using vdb0.mt tags( 2 ) +sql_error create table vdb3.vtb21 using vdb0.mt tags( 2 ) +sql create table vdb3.vtb30 using vdb3.mt tags( 3 ) +sql create table vdb3.vtb31 using vdb3.mt tags( 3 ) + +print =============== step2 +sql insert into vdb0.vtb00 values (1519833600000 , 10) (1519833600001, 20) (1519833600002, 30) +sql insert into vdb0.vtb01 values (1519833600000 , 10) (1519833600001, 20) (1519833600002, 30) +sql insert into vdb1.vtb10 values (1519833600000 , 11) (1519833600001, 21) (1519833600002, 31) +sql insert into vdb1.vtb11 values (1519833600000 , 11) (1519833600001, 21) (1519833600002, 31) +sql insert into vdb2.vtb20 values (1519833600000 , 12) (1519833600001, 22) (1519833600002, 32) +sql insert into vdb2.vtb21 values (1519833600000 , 12) (1519833600001, 22) (1519833600002, 32) +sql insert into vdb3.vtb30 values (1519833600000 , 13) (1519833600001, 23) (1519833600002, 33) +sql insert into vdb3.vtb31 values (1519833600000 , 13) (1519833600001, 23) (1519833600002, 33) +sql select * from vdb0.mt + +if $rows != 6 then + return -1 +endi + +print =============== step3 +sql insert into vdb0.vtb00 values (1519833600003 , 40) (1519833600005, 50) (1519833600004, 60) +sql insert into vdb0.vtb01 values (1519833600003 , 40) (1519833600005, 50) (1519833600004, 60) +sql insert into vdb1.vtb10 values (1519833600003 , 41) (1519833600005, 51) (1519833600004, 61) +sql insert into vdb1.vtb11 values (1519833600003 , 41) (1519833600005, 51) (1519833600004, 61) +sql insert into vdb2.vtb20 values (1519833600003 , 42) (1519833600005, 52) (1519833600004, 62) +sql insert into vdb2.vtb21 values (1519833600003 , 42) (1519833600005, 52) (1519833600004, 62) +sql insert into vdb3.vtb30 values (1519833600003 , 43) (1519833600005, 53) (1519833600004, 63) +sql insert into vdb3.vtb31 values (1519833600003 , 43) (1519833600005, 53) (1519833600004, 63) +sql select * from vdb0.mt + +if $rows != 12 then + return -1 +endi + +print =============== step4 +sql insert into vdb0.vtb00 values(1519833600006, 60) (1519833600007, 70) vdb0.vtb01 values(1519833600006, 60) (1519833600007, 70) +sql insert into vdb1.vtb10 values(1519833600006, 61) (1519833600007, 71) vdb1.vtb11 values(1519833600006, 61) (1519833600007, 71) +sql insert into vdb2.vtb20 values(1519833600006, 62) (1519833600007, 72) vdb2.vtb21 values(1519833600006, 62) (1519833600007, 72) +sql insert into vdb3.vtb30 values(1519833600006, 63) (1519833600007, 73) vdb3.vtb31 values(1519833600006, 63) (1519833600007, 73) +sql select * from vdb0.mt + +if $rows != 16 then + return -1 +endi + +print =============== step5 +sql insert into vdb0.vtb00 values(1519833600008, 80) (1519833600007, 70) vdb0.vtb01 values(1519833600006, 80) (1519833600007, 70) +sql insert into vdb1.vtb10 values(1519833600008, 81) (1519833600007, 71) vdb1.vtb11 values(1519833600006, 81) (1519833600007, 71) +sql insert into vdb2.vtb20 values(1519833600008, 82) (1519833600007, 72) vdb2.vtb21 values(1519833600006, 82) (1519833600007, 72) +sql insert into vdb3.vtb30 values(1519833600008, 83) (1519833600007, 73) vdb3.vtb31 values(1519833600006, 83) (1519833600007, 73) +sql select * from vdb0.mt + +if $rows != 17 then + return -1 +endi + +print =============== step6 +sql insert into vdb0.vtb00 values(1519833600009, 90) (1519833600010, 100) vdb1.vtb10 values(1519833600009, 90) (1519833600010, 100) vdb2.vtb20 values(1519833600009, 90) (1519833600010, 100) vdb3.vtb30 values(1519833600009, 90) (1519833600010, 100) +sql insert into vdb0.vtb01 values(1519833600009, 90) (1519833600010, 100) vdb1.vtb11 values(1519833600009, 90) (1519833600010, 100) vdb2.vtb21 values(1519833600009, 90) (1519833600010, 100) vdb3.vtb31 values(1519833600009, 90) (1519833600010, 100) + +sql select * from vdb0.mt + +if $rows != 21 then + return -1 +endi + +print =============== step7 +sql insert into vdb0.vtb00 values(1519833600012, 120) (1519833600011, 110) vdb1.vtb10 values(1519833600012, 120) (1519833600011, 110) vdb2.vtb20 values(1519833600012, 120) (1519833600011, 110) vdb3.vtb30 values(1519833600012, 120) (1519833600011, 110) +sql insert into vdb0.vtb01 values(1519833600012, 120) (1519833600011, 110) vdb1.vtb11 values(1519833600012, 120) (1519833600011, 110) vdb2.vtb21 values(1519833600012, 120) (1519833600011, 110) vdb3.vtb31 values(1519833600012, 120) (1519833600011, 110) + +sql select * from vdb0.mt + +if $rows != 25 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/stable/vnode3.sim b/tests/script/general/stable/vnode3.sim new file mode 100644 index 0000000000000000000000000000000000000000..61948b506302f803aee2f73eb5e528e14f1174db --- /dev/null +++ b/tests/script/general/stable/vnode3.sim @@ -0,0 +1,179 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = v3_db +$tbPrefix = v3_tb +$mtPrefix = v3_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $val = $x * 60000 + $ms = 1519833600000 + $val + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sql show vgroups +print vgroups ==> $rows +if $rows != 3 then + return -1 +endi + + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +sql select count(tbcol) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step3 +sql select count(tbcol) from $tb where ts <= 1519833840000 +print ===> $data00 +if $data00 != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol) as b from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step5 +sql select count(tbcol) as b from $tb interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi + +sql select count(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != $rowNum then + return -1 +endi + +print =============== step6 +sql select count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select count(*) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +sql select count(tbcol) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +print =============== step8 +sql select count(tbcol) as c from $mt where ts <= 1519833840000 +print ===> $data00 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 and ts <= 1519833840000 +print ===> $data00 +if $data00 != 25 then + return -1 +endi + +print =============== step9 +sql select count(tbcol) as b from $mt interval(1m) +print ===> $data01 +if $data01 != 10 then + return -1 +endi + +sql select count(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 200 then + return -1 +endi + +print =============== step10 +sql select count(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select count(tbcol) as b from $mt where ts <= 1519833840000 interval(1m) group by tgcol +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/stream/agg_stream.sim b/tests/script/general/stream/agg_stream.sim new file mode 100644 index 0000000000000000000000000000000000000000..548f59cab7e6b3a81c5b01a62e02456f3c209720 --- /dev/null +++ b/tests/script/general/stream/agg_stream.sim @@ -0,0 +1,316 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 0 + +print ========== step1 +system sh/cfg.sh -n dnode1 -c monitor -v 1 +system sh/cfg.sh -n dnode1 -c monitorInterval -v 1 +system sh/cfg.sh -n dnode1 -c maxVnodeConnections -v 30000 +system sh/cfg.sh -n dnode1 -c maxMgmtConnections -v 30000 +system sh/cfg.sh -n dnode1 -c maxMeterConnections -v 30000 +system sh/cfg.sh -n dnode1 -c maxShellConns -v 30000 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print =============== step2 +sql create database d4 precision 'us' +sql use d4 +sql create table t1 (ts timestamp, i int) +sql insert into d4.t1 values(1626739200000, 1) + +sql create table d4.s001 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s002 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s003 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s004 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s005 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s006 as select count(req_http), count(req_insert), avg(req_select), sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s007 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s008 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s009 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s000 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s011 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s012 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s013 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s014 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s015 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s016 as select count(req_http), count(req_insert), avg(req_select), sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s017 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s018 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s019 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s010 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s021 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s022 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s023 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s024 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s025 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s026 as select count(req_http), count(req_insert), avg(req_select), sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s027 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s028 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s029 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s020 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s031 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s032 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s033 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s034 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s035 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s036 as select count(req_http), count(req_insert), avg(req_select), sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s037 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s038 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s039 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s030 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s041 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s042 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s043 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s044 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s045 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s046 as select count(req_http), count(req_insert), avg(req_select), sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s047 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s048 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s049 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s040 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s051 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s052 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s053 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s054 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s055 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s056 as select count(req_http), count(req_insert), avg(req_select), sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s057 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s058 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s059 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s050 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s061 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s062 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s063 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s064 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s065 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s066 as select count(req_http), count(req_insert), avg(req_select), sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s067 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s068 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s069 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s060 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s071 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s072 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s073 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s074 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s075 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s076 as select count(req_http), count(req_insert), avg(req_select), sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s077 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s078 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s079 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s070 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s081 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s082 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s083 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s084 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s085 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s086 as select count(req_http), count(req_insert), avg(req_select), sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s087 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s088 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s089 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s080 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s091 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s092 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s093 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s094 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s095 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s096 as select count(req_http), count(req_insert) , sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s097 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s098 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s099 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s090 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +print =============== step21 + +sql create table d4.s101 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s102 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s103 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s104 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s105 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s106 as select count(req_http), count(req_insert) , sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s107 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s108 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s109 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s100 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s111 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s112 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s113 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s114 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s115 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s116 as select count(req_http), count(req_insert) , sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s117 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s118 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s119 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s110 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s121 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s122 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s123 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s124 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s125 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s126 as select count(req_http), count(req_insert) , sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s127 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s128 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s129 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s120 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s131 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s132 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s133 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s134 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s135 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s136 as select count(req_http), count(req_insert) , sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s137 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s138 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s139 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s130 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s141 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s142 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s143 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s144 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s145 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s146 as select count(req_http), count(req_insert) , sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s147 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s148 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s149 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s140 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s151 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s152 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s153 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s154 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s155 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s156 as select count(req_http), count(req_insert) , sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s157 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s158 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s159 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s150 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s161 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s162 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s163 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s164 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s165 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s166 as select count(req_http), count(req_insert) , sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s167 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s168 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s169 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s160 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s171 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s172 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s173 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s174 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s175 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s176 as select count(req_http), count(req_insert) , sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s177 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s178 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s179 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s170 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s181 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s182 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s183 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s184 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s185 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s186 as select count(req_http), count(req_insert) , sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s187 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s188 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s189 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s180 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s191 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s192 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s193 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s194 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s195 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s196 as select count(req_http), count(req_insert) , sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s197 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s198 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s199 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s190 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + + +print =============== step3 +print sleep 22 seconds +sleep 50000 + +sql select * from d4.s001 +$s1 = $rows +print select * from d4.s001 ==> $s1 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s002 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s003 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s004 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s005 +$s5 = $rows +print select * from d4.s005 ==> $s5 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s006 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s007 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s008 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s009 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s010 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s101 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s102 +$s12 = $rows +print select * from d4.s102 ==> $s12 +if $rows <= 0 then + return -1 +endi diff --git a/tests/script/general/stream/column_stream.sim b/tests/script/general/stream/column_stream.sim new file mode 100644 index 0000000000000000000000000000000000000000..59a65f0969ebc6e2fd6d62c5b3fcc1bf66c420b7 --- /dev/null +++ b/tests/script/general/stream/column_stream.sim @@ -0,0 +1,200 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 0 + +print ========== step1 +system sh/cfg.sh -n dnode1 -c monitor -v 1 +system sh/cfg.sh -n dnode1 -c monitorInterval -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print =============== step1 +sleep 2000 +sql select * from log.dn +if $rows == 0 then + return -1 +endi + +print =============== step2 +sql create database d4 precision 'us' +sql use d4 +sql create table t1 (ts timestamp, i int) +sql insert into d4.t1 values(1626739200000, 1) + +sql create table d4.s1 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd), stddev(cpu_taosd), count(*) as c1, count(*) as c2, count(*) as c3, count(*) as c4, count(*) as c5, count(*) as c6, count(*) as c7, count(*) as c8, count(*) as c9, count(*) as c10, count(*) as c11, count(*) as c12, count(*) as c13, count(*) as c14, count(*) as c15, count(*) as c16, count(*) as c17, count(*) as c18, count(*) as c19, count(*) as c20, count(*) as c21, count(*) as c22, count(*) as c23, count(*) as c24, count(*) as c25, count(*) as c26, count(*) as c27, count(*) as c28, count(*) as c29, count(*) as c30 from log.dn_192_168_0_1 interval(5s) + +sql create table d4.s2 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd), stddev(cpu_taosd), count(*) as c1, count(*) as c2, count(*) as c3, count(*) as c4, count(*) as c5, count(*) as c6, count(*) as c7, count(*) as c8, count(*) as c9, count(*) as c10, count(*) as c11, count(*) as c12, count(*) as c13, count(*) as c14, count(*) as c15, count(*) as c16, count(*) as c17, count(*) as c18, count(*) as c19, count(*) as c20, count(*) as c21, count(*) as c22, count(*) as c23, count(*) as c24, count(*) as c25, count(*) as c26, count(*) as c27, count(*) as c28, count(*) as c29, count(*) as c30 from log.dn_192_168_0_1 interval(5s) + +sql create table d4.s3 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used), stddev(disk_used), count(*) as c1, count(*) as c2, count(*) as c3, count(*) as c4, count(*) as c5, count(*) as c6, count(*) as c7, count(*) as c8, count(*) as c9, count(*) as c10, count(*) as c11, count(*) as c12, count(*) as c13, count(*) as c14, count(*) as c15, count(*) as c16, count(*) as c17, count(*) as c18, count(*) as c19, count(*) as c20, count(*) as c21, count(*) as c22, count(*) as c23, count(*) as c24, count(*) as c25, count(*) as c26, count(*) as c27, count(*) as c28, count(*) as c29, count(*) as c30 from log.dn_192_168_0_1 interval(5s) + +sql create table d4.s4 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read), stddev(io_write), count(*) as c1, count(*) as c2, count(*) as c3, count(*) as c4, count(*) as c5, count(*) as c6, count(*) as c7, count(*) as c8, count(*) as c9, count(*) as c10, count(*) as c11, count(*) as c12, count(*) as c13, count(*) as c14, count(*) as c15, count(*) as c16, count(*) as c17, count(*) as c18, count(*) as c19, count(*) as c20, count(*) as c21, count(*) as c22, count(*) as c23, count(*) as c24, count(*) as c25, count(*) as c26, count(*) as c27, count(*) as c28, count(*) as c29, count(*) as c30 from log.dn_192_168_0_1 interval(5s) + +sql create table d4.s5 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed), stddev(band_speed), count(*) as c1, count(*) as c2, count(*) as c3, count(*) as c4, count(*) as c5, count(*) as c6, count(*) as c7, count(*) as c8, count(*) as c9, count(*) as c10, count(*) as c11, count(*) as c12, count(*) as c13, count(*) as c14, count(*) as c15, count(*) as c16, count(*) as c17, count(*) as c18, count(*) as c19, count(*) as c20, count(*) as c21, count(*) as c22, count(*) as c23, count(*) as c24, count(*) as c25, count(*) as c26, count(*) as c27, count(*) as c28, count(*) as c29, count(*) as c30 from log.dn_192_168_0_1 interval(5s) + +sql create table d4.s6 as select count(req_http), count(req_insert), avg(req_http), avg(req_select), sum(req_insert), max(req_select), min(req_insert), stddev(req_select), count(*) as c1, count(*) as c2, count(*) as c3, count(*) as c4, count(*) as c5, count(*) as c6, count(*) as c7, count(*) as c8, count(*) as c9, count(*) as c10, count(*) as c11, count(*) as c12, count(*) as c13, count(*) as c14, count(*) as c15, count(*) as c16, count(*) as c17, count(*) as c18, count(*) as c19, count(*) as c20, count(*) as c21, count(*) as c22, count(*) as c23, count(*) as c24, count(*) as c25, count(*) as c26, count(*) as c27, count(*) as c28, count(*) as c29, count(*) as c30 from log.dn_192_168_0_1 interval(5s) + +sql create table d4.s7 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd), count(*) as c1, count(*) as c2, count(*) as c3, count(*) as c4, count(*) as c5, count(*) as c6, count(*) as c7, count(*) as c8, count(*) as c9, count(*) as c10, count(*) as c11, count(*) as c12, count(*) as c13, count(*) as c14, count(*) as c15, count(*) as c16, count(*) as c17, count(*) as c18, count(*) as c19, count(*) as c20, count(*) as c21, count(*) as c22, count(*) as c23, count(*) as c24, count(*) as c25, count(*) as c26, count(*) as c27, count(*) as c28, count(*) as c29, count(*) as c30 from log.dn interval(5s) + +sql create table d4.s8 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd), count(*) as c1, count(*) as c2, count(*) as c3, count(*) as c4, count(*) as c5, count(*) as c6, count(*) as c7, count(*) as c8, count(*) as c9, count(*) as c10, count(*) as c11, count(*) as c12, count(*) as c13, count(*) as c14, count(*) as c15, count(*) as c16, count(*) as c17, count(*) as c18, count(*) as c19, count(*) as c20, count(*) as c21, count(*) as c22, count(*) as c23, count(*) as c24, count(*) as c25, count(*) as c26, count(*) as c27, count(*) as c28, count(*) as c29, count(*) as c30 from log.dn interval(5s) + +sql create table d4.s9 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used), count(*) as c1, count(*) as c2, count(*) as c3, count(*) as c4, count(*) as c5, count(*) as c6, count(*) as c7, count(*) as c8, count(*) as c9, count(*) as c10, count(*) as c11, count(*) as c12, count(*) as c13, count(*) as c14, count(*) as c15, count(*) as c16, count(*) as c17, count(*) as c18, count(*) as c19, count(*) as c20, count(*) as c21, count(*) as c22, count(*) as c23, count(*) as c24, count(*) as c25, count(*) as c26, count(*) as c27, count(*) as c28, count(*) as c29, count(*) as c30 from log.dn interval(5s) + +sql create table d4.s10 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read), count(*) as c1, count(*) as c2, count(*) as c3, count(*) as c4, count(*) as c5, count(*) as c6, count(*) as c7, count(*) as c8, count(*) as c9, count(*) as c10, count(*) as c11, count(*) as c12, count(*) as c13, count(*) as c14, count(*) as c15, count(*) as c16, count(*) as c17, count(*) as c18, count(*) as c19, count(*) as c20, count(*) as c21, count(*) as c22, count(*) as c23, count(*) as c24, count(*) as c25, count(*) as c26, count(*) as c27, count(*) as c28, count(*) as c29, count(*) as c30 from log.dn interval(5s) + +sql create table d4.s11 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed), count(*) as c1, count(*) as c2, count(*) as c3, count(*) as c4, count(*) as c5, count(*) as c6, count(*) as c7, count(*) as c8, count(*) as c9, count(*) as c10, count(*) as c11, count(*) as c12, count(*) as c13, count(*) as c14, count(*) as c15, count(*) as c16, count(*) as c17, count(*) as c18, count(*) as c19, count(*) as c20, count(*) as c21, count(*) as c22, count(*) as c23, count(*) as c24, count(*) as c25, count(*) as c26, count(*) as c27, count(*) as c28, count(*) as c29, count(*) as c30 from log.dn interval(5s) + +sql create table d4.s12 as select count(req_http), count(req_insert), avg(req_select), avg(req_insert), sum(req_insert), max(req_select), min(req_insert), count(*) as c1, count(*) as c2, count(*) as c3, count(*) as c4, count(*) as c5, count(*) as c6, count(*) as c7, count(*) as c8, count(*) as c9, count(*) as c10, count(*) as c11, count(*) as c12, count(*) as c13, count(*) as c14, count(*) as c15, count(*) as c16, count(*) as c17, count(*) as c18, count(*) as c19, count(*) as c20, count(*) as c21, count(*) as c22, count(*) as c23, count(*) as c24, count(*) as c25, count(*) as c26, count(*) as c27, count(*) as c28, count(*) as c29, count(*) as c30 from log.dn interval(5s) + +print =============== step3 +print sleep 22 seconds +sleep 22000 + +sql select * from d4.s1 +$s1 = $rows +print select * from d4.s1 ==> $s1 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s2 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s3 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s4 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s5 +$s5 = $rows +print select * from d4.s5 ==> $s5 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s6 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s7 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s8 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s9 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s10 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s11 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s12 +$s12 = $rows +print select * from d4.s12 ==> $s12 +if $rows <= 0 then + return -1 +endi + +print =============== step4 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +print sleep 22 seconds +sleep 22000 + +sql select * from d4.s1 +print select * from d4.s1 ==> $rows $s1 +if $rows <= 0 then + return -1 +endi +if $rows <= $s1 then + return -1 +endi + +sql select * from d4.s2 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s3 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s4 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s5 +print select * from d4.s5 ==> $rows $s5 +if $rows <= 0 then + return -1 +endi +if $rows <= $s5 then + return -1 +endi + + +sql select * from d4.s6 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s7 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s8 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s9 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s10 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s11 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s12 +print select * from d4.s12 ==> $rows $s12 +if $rows <= 0 then + return -1 +endi +if $rows <= $s12 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/stream/metrics_del.sim b/tests/script/general/stream/metrics_del.sim new file mode 100644 index 0000000000000000000000000000000000000000..6cc3da71e9a5c34f83a74be5e4fe0345e94beadf --- /dev/null +++ b/tests/script/general/stream/metrics_del.sim @@ -0,0 +1,95 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = md_db +$tbPrefix = md_tb +$mtPrefix = md_mt +$stPrefix = md_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + $y = 0 + while $y < $rowNum + $ts = 1626710400000 + $x + sql insert into $tb values ($ts , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c3 + +sql select count(*), count(tbcol), count(tbcol2) from $mt interval(1d) +print select count(*), count(tbcol), count(tbcol2) from $mt interval(1d) ===> $data00 $data01 $data02, $data03 +if $data01 != 200 then + return -1 +endi +if $data02 != 200 then + return -1 +endi +if $data03 != 200 then + return -1 +endi + +$st = $stPrefix . c3 +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $mt interval(1d) + +print =============== step3 + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql drop table $tb + $i = $i + 1 +endw +sql drop table $mt + +print =============== step4 +print sleep 120 seconds +sleep 120000 + +print =============== step5 +$st = $stPrefix . c3 +sql select * from $st +print ===> select * from $st +print ===> $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data01 != null then + return -1 +endi +if $data02 != null then + return -1 +endi +if $data03 != null then + return -1 +endi diff --git a/tests/script/general/stream/metrics_replica1_vnoden.sim b/tests/script/general/stream/metrics_replica1_vnoden.sim new file mode 100644 index 0000000000000000000000000000000000000000..db1044a597510048c4b812d8a3a16d53ff4e5ac0 --- /dev/null +++ b/tests/script/general/stream/metrics_replica1_vnoden.sim @@ -0,0 +1,245 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 1000 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 3 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = m1v_db +$tbPrefix = m1v_tb +$mtPrefix = m1v_mt +$stPrefix = m1v_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -400 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c1 + +sql select count(*) from $mt interval(1d) +print select count(*) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c1 +sql create table $st as select count(*) from $mt interval(1d) + +print =============== step3 c2 +sql select count(tbcol) from $mt interval(1d) +print select count(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c2 +sql create table $st as select count(tbcol) from $mt interval(1d) + +print =============== step4 c3 +sql select count(tbcol2) from $mt interval(1d) +print select count(tbcol2) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c3 +sql create table $st as select count(tbcol2) from $mt interval(1d) + +print =============== step5 avg +sql select avg(tbcol) from $mt interval(1d) +print select avg(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . av +sql create table $st as select avg(tbcol) from $mt interval(1d) + +print =============== step6 su +sql select sum(tbcol) from $mt interval(1d) +print select sum(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 1900 then + return -1 +endi + +$st = $stPrefix . su +sql create table $st as select sum(tbcol) from $mt interval(1d) + +print =============== step7 mi +sql select min(tbcol) from $mt interval(1d) +print select min(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . mi +sql create table $st as select min(tbcol) from $mt interval(1d) + +print =============== step8 ma +sql select max(tbcol) from $mt interval(1d) +print select max(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . ma +sql create table $st as select max(tbcol) from $mt interval(1d) + +print =============== step9 fi +sql select first(tbcol) from $mt interval(1d) +print select first(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . fi +sql create table $st as select first(tbcol) from $mt interval(1d) + +print =============== step10 la +sql select last(tbcol) from $mt interval(1d) +print select last(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . la +sql create table $st as select last(tbcol) from $mt interval(1d) + +print =============== step11 wh +sql select count(tbcol) from $mt where ts < 1626739440001 interval(1d) +print select count(tbcol) from $mt where ts < 1626739440000 interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . wh +#sql create table $st as select count(tbcol) from $mt where ts < 1626739200000 + 4m interval(1d) + +print =============== step12 as +sql select count(tbcol) from $mt interval(1d) +print select count(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . as +sql create table $st as select count(tbcol) as c from $mt interval(1d) + +print =============== step13 +print sleep 120 seconds +sleep 120000 + +print =============== step14 +$st = $stPrefix . c1 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c2 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c3 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . av +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . su +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 1900 then + return -1 +endi + +$st = $stPrefix . mi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . ma +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . fi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . la +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . wh +#sql select * from $st +#print ===> select * from $st ===> $data00 $data01 +#if $data01 != 200 then +# return -1 +#endi + +$st = $stPrefix . as +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi diff --git a/tests/script/general/stream/restart_stream.sim b/tests/script/general/stream/restart_stream.sim new file mode 100644 index 0000000000000000000000000000000000000000..62e47f9b3a6c12668409293769ee7c5a12a718ac --- /dev/null +++ b/tests/script/general/stream/restart_stream.sim @@ -0,0 +1,176 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect +print ======================== dnode1 start + +$i = 0 +$dbPrefix = rs_db +$tbPrefix = rs_tb +$mtPrefix = rs_mt +$stPrefix = rs_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +$db = $dbPrefix +$tb = $tbPrefix . $i +$mt = $mtPrefix +$stm = $stPrefix . m +$stt = $stPrefix . t + +print =============== step1 +sql create database $db +sql use $db + +sql create table $mt (ts timestamp, tbcol int, tbcol2 int ) TAGS(tgcol bool) +$i = 0 +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + + $x = -400 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +print =============== step2 +$i = 0 +$tb = $tbPrefix . $i + +sql select count(*) from $tb interval(1d) +print ===>rows $rows, data $data01 +if $rows != 1 then + return -1 +endi +if $data01 != 20 then + return -1 +endi + +sql select count(*) from $mt interval(1d) +print ===>rows $rows, data $data01 +if $rows != 1 then + return -1 +endi +if $data01 != 200 then + return -1 +endi + +print =============== step3 +sql create table $stt as select count(*) from $tb interval(1d) +sql create table $stm as select count(*) from $mt interval(1d) + +print sleep 120 seconds +sleep 120000 + +sql select * from $stt +print select count(*) from $stt ===> $data00 $data01 +if $rows != 1 then + return -1 +endi +if $data01 != 20 then + return -1 +endi + +sql select * from $stm +print select * from $stm ===> $data00 $data01 +if $rows != 1 then + return -1 +endi +if $data01 != 200 then + return -1 +endi + +print =============== step4 +system sh/exec.sh -n dnode1 -s stop +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +print =============== step5 +print ==> renew cache +sql reset query cache +sleep 1000 + + +print =============== step6 +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol bigint, tbcol2 bigint ) TAGS(tgcol int) +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + + $x = -400 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + + +print =============== step7 + +sql select count(*) from $tb interval(1d) +print ===>rows $rows, data $data01 +if $rows != 1 then + return -1 +endi +if $data01 != 20 then + return -1 +endi + +sql select count(*) from $mt interval(1d) +print ===>rows $rows, data $data01 +if $rows != 1 then + return -1 +endi +if $data01 != 100 then + return -1 +endi + +print =============== step8 +sql create table $stt as select count(*) from $tb interval(1d) +sql create table $stm as select count(*) from $mt interval(1d) + +print sleep 120 seconds +sleep 120000 + +sql select * from $stt +sleep 1000 +print ===>rows $rows, data $data01 +if $rows != 1 then + return -1 +endi +if $data01 != 20 then + return -1 +endi + +sql select * from $stm +print ===>rows $rows, data $data01 +if $rows != 1 then + return -1 +endi +if $data01 != 100 then + return -1 +endi + + diff --git a/tests/script/general/stream/stream_1970.sim b/tests/script/general/stream/stream_1970.sim new file mode 100644 index 0000000000000000000000000000000000000000..30a733c08ff37d193df688ee956f3c5911671ddf --- /dev/null +++ b/tests/script/general/stream/stream_1970.sim @@ -0,0 +1,73 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = s3_db +$tbPrefix = s3_tb +$mtPrefix = s3_mt +$stPrefix = s3_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db keep 36500 +sql use $db +sql create stable $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +sql create table cq1 as select count(*) from $mt interval(10s); + +sleep 1000 + +sql create table $st using $mt tags(1); + +sql insert into $st values (-50000, 1, 1.0); +sql insert into $st values (-10000, 1, 1.0); +sql insert into $st values (10000, 1, 1.0); + + +$i = 0 +while $i < 12 + sql select * from cq1; + + if $rows != 3 then + sleep 10000 + else + if $data00 != @70-01-01 07:59:10.000@ then + return -1 + endi + if $data01 != 1 then + return -1 + endi + if $data10 != @70-01-01 07:59:50.000@ then + return -1 + endi + if $data11 != 1 then + return -1 + endi + if $data20 != @70-01-01 08:00:10.000@ then + return -1 + endi + if $data21 != 1 then + return -1 + endi + $i = 12 + endi + + $i = $i + 1 +endw + diff --git a/tests/script/general/stream/stream_3.sim b/tests/script/general/stream/stream_3.sim new file mode 100644 index 0000000000000000000000000000000000000000..b043993814db2ea5bf8c6a3513317efca50b51d3 --- /dev/null +++ b/tests/script/general/stream/stream_3.sim @@ -0,0 +1,201 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = s3_db +$tbPrefix = s3_tb +$mtPrefix = s3_mt +$stPrefix = s3_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -400 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c1 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb interval(1d) +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c1 +sql create table $st as select count(*) from $tb interval(1d) + +print =============== step3 c2 +sql select count(tbcol) from $tb interval(1d) +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c2 +sql create table $st as select count(tbcol) from $tb interval(1d) + +print =============== step4 c3 +sql select count(tbcol2) from $tb interval(1d) +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c3 +sql create table $st as select count(tbcol2) from $tb interval(1d) + +print =============== step5 +print sleep 120 seconds +sleep 120000 + +print =============== step6 +$st = $stPrefix . c1 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c2 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c3 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +print =============== step7 + +system sh/exec.sh -n dnode1 -s stop +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 4000 +print ======================== dnode1 start + +$dbPrefix = stst3db +$tbPrefix = stst3tb +$mtPrefix = stst3mt +$stPrefix = stst3st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step8 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step8 +step8: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -400 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step9 c3 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) +print select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) ===> $data00 $data01 $data02, $data03 +if $data01 != $rowNum then + return -1 +endi +if $data02 != $rowNum then + return -1 +endi +if $data03 != $rowNum then + return -1 +endi + +$st = $stPrefix . c3 +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) + +print =============== step10 +print sleep 120 seconds +sleep 120000 + +print =============== step11 +#$st = $stPrefix . c3 +#sql select * from $st -x step11 +# print ===> select * from $st first time should be error +# return -1 +#step11: + +print =============== step12 +$st = $stPrefix . c3 +sql select * from $st +print ===> select * from $st +print ===> $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data01 != $rowNum then + return -1 +endi +if $data02 != $rowNum then + return -1 +endi +if $data03 != $rowNum then + return -1 +endi + + diff --git a/tests/script/general/stream/stream_restart.sim b/tests/script/general/stream/stream_restart.sim new file mode 100644 index 0000000000000000000000000000000000000000..54a60a00811de0253d1ad1110b69f2587f707aa1 --- /dev/null +++ b/tests/script/general/stream/stream_restart.sim @@ -0,0 +1,142 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = sr_db +$tbPrefix = sr_tb +$mtPrefix = sr_mt +$stPrefix = sr_st +$tbNum = 10 +$rowNum = 200 +$totalNum = 200 + +print =============== step1 + +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + $y = 0 + while $y < $rowNum + $ms = $x . s + sql insert into $tb values (1626739200000 + $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 + +$i = 1 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(10s) + +$i = 5 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(10s) + +$i = 8 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(10s) + +sql show tables +if $rows != 13 then + return -1 +endi + +print =============== step3 +sleep 2000 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 1000 +system sh/exec.sh -n dnode1 -s start + +print =============== step4 +print sleep 120 seconds +sleep 120000 + +print =============== step5 +$i = 1 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $tb +print $tb ==> $rows $data00 $data01 +if $rows != $rowNum then + return -1 +endi + +$i = 5 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $tb +print $tb ==> $rows $data00 $data01 +if $rows != $rowNum then + return -1 +endi + +$i = 8 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $tb +print $tb ==> $rows $data00 $data01 +if $rows != $rowNum then + return -1 +endi + +print =============== step6 + +$i = 1 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $st +print $st ==> $rows $data00 $data01 +if $rows <= 1 then + return -1 +endi + +$i = 5 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $st +print $st ==> $rows $data00 $data01 +if $rows <= 1 then + return -1 +endi + +$i = 8 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $st +print $st ==> $rows $data00 $data01 +if $rows <= 1 then + return -1 +endi + + diff --git a/tests/script/general/stream/table_del.sim b/tests/script/general/stream/table_del.sim new file mode 100644 index 0000000000000000000000000000000000000000..34673605d63b39b9fd809aaedd94f4e6ef80f5b7 --- /dev/null +++ b/tests/script/general/stream/table_del.sim @@ -0,0 +1,90 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = td_db +$tbPrefix = td_tb +$mtPrefix = td_mt +$stPrefix = td_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -400 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c3 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) +print select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) ===> $data00 $data01 $data02, $data03 +if $data01 != $rowNum then + return -1 +endi +if $data02 != $rowNum then + return -1 +endi +if $data03 != $rowNum then + return -1 +endi + +$st = $stPrefix . c3 +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) + +print =============== step3 +sql drop table $tb + +print =============== step4 +print sleep 120 seconds +sleep 120000 + +print =============== step5 +$st = $stPrefix . c3 +sql select * from $st +print ===> select * from $st +print ===> $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data01 != null then + return -1 +endi +if $data02 != null then + return -1 +endi +if $data03 != null then + return -1 +endi diff --git a/tests/script/general/stream/table_replica1_vnoden.sim b/tests/script/general/stream/table_replica1_vnoden.sim new file mode 100644 index 0000000000000000000000000000000000000000..4a6c4fe0462fc675e13785905ff1b707815fd168 --- /dev/null +++ b/tests/script/general/stream/table_replica1_vnoden.sim @@ -0,0 +1,299 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 1000 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 3 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = t1v_db +$tbPrefix = t1v_tb +$mtPrefix = t1v_mt +$stPrefix = t1v_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -400 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (1626739200000 $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c1 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb interval(1d) +print select count(*) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c1 +sql create table $st as select count(*) from $tb interval(1d) + +print =============== step3 c2 +sql select count(tbcol) from $tb interval(1d) +print select count(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c2 +sql create table $st as select count(tbcol) from $tb interval(1d) + +print =============== step4 c3 +sql select count(tbcol2) from $tb interval(1d) +print select count(tbcol2) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c3 +sql create table $st as select count(tbcol2) from $tb interval(1d) + +print =============== step5 avg +sql select avg(tbcol) from $tb interval(1d) +print select avg(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . av +sql create table $st as select avg(tbcol) from $tb interval(1d) + +print =============== step6 su +sql select sum(tbcol) from $tb interval(1d) +print select sum(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 190 then + return -1 +endi + +$st = $stPrefix . su +sql create table $st as select sum(tbcol) from $tb interval(1d) + +print =============== step7 mi +sql select min(tbcol) from $tb interval(1d) +print select min(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . mi +sql create table $st as select min(tbcol) from $tb interval(1d) + +print =============== step8 ma +sql select max(tbcol) from $tb interval(1d) +print select max(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . ma +sql create table $st as select max(tbcol) from $tb interval(1d) + +print =============== step9 fi +sql select first(tbcol) from $tb interval(1d) +print select first(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . fi +sql create table $st as select first(tbcol) from $tb interval(1d) + +print =============== step10 la +sql select last(tbcol) from $tb interval(1d) +print select last(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . la +sql create table $st as select last(tbcol) from $tb interval(1d) + +print =============== step11 st +sql select stddev(tbcol) from $tb interval(1d) +print select stddev(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 5.766281297 then + return -1 +endi + +$st = $stPrefix . st +sql create table $st as select stddev(tbcol) from $tb interval(1d) + +print =============== step12 le +sql select leastsquares(tbcol, 1, 1) from $tb interval(1d) +print select leastsquares(tbcol, 1, 1) from $tb interval(1d) ===> $data00 $data01 +#if $data01 != @(0.000017, -25362055.126740)@ then +# return -1 +#endi + +$st = $stPrefix . le +sql create table $st as select leastsquares(tbcol, 1, 1) from $tb interval(1d) + +print =============== step13 pe + +sql select percentile(tbcol, 1) from $tb interval(1d) +print select percentile(tbcol, 1) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 0.190000000 then + return -1 +endi + +$st = $stPrefix . pe +sql create table $st as select percentile(tbcol, 1) from $tb interval(1d) + +print =============== step14 wh +sql select count(tbcol) from $tb where ts < 1626739440001 interval(1d) +print select count(tbcol) from $tb where ts < 1626739440001 interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . wh +#sql create table $st as select count(tbcol) from $tb where ts < 1626739200000 + 4m interval(1d) + +print =============== step15 as +sql select count(tbcol) from $tb interval(1d) +print select count(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . as +sql create table $st as select count(tbcol) as c from $tb interval(1d) + +print =============== step16 +print sleep 120 seconds +sleep 120000 + +print =============== step17 +$st = $stPrefix . c1 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c2 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c3 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . av +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . su +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 190 then + return -1 +endi + +$st = $stPrefix . mi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . ma +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . fi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . la +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . st +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 5.766281297 then + return -1 +endi + +$st = $stPrefix . le +sql select * from $st +#print ===> select * from $st ===> $data00 $data01 +#if $data01 != @(0.000017, -25270086.331047)@ then +# return -1 +#endi + +$st = $stPrefix . pe +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0.190000000 then + return -1 +endi + +$st = $stPrefix . wh +#sql select * from $st +#print ===> select * from $st ===> $data00 $data01 +#if $data01 != $rowNum then +# return -1 +#endi + +$st = $stPrefix . as +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi diff --git a/tests/script/general/stream/testSuite.sim b/tests/script/general/stream/testSuite.sim new file mode 100644 index 0000000000000000000000000000000000000000..4a9912b848f1976903199ad314352e70db0ca059 --- /dev/null +++ b/tests/script/general/stream/testSuite.sim @@ -0,0 +1,6 @@ +run general/stream/stream_3.sim +run general/stream/stream_restart.sim +run general/stream/table_del.sim +run general/stream/metrics_del.sim +run general/stream/table_replica1_vnoden.sim +run general/stream/metrics_replica1_vnoden.sim \ No newline at end of file diff --git a/tests/script/general/table/autocreate.sim b/tests/script/general/table/autocreate.sim new file mode 100644 index 0000000000000000000000000000000000000000..404c714ab4cfa85593d191fcd528f7b902e4cea9 --- /dev/null +++ b/tests/script/general/table/autocreate.sim @@ -0,0 +1,105 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print =============== create database +sql create database db +sql show databases +if $rows != 1 then + return -1 +endi + +print $data00 $data01 $data02 + +print =============== create super table +sql create table db.st1 (ts timestamp, i int) tags (j int) +sql create table db.st2 (ts timestamp, i int, j int) tags (t1 int, t2 int, t3 int) +sql show db.stables +if $rows != 2 then + return -1 +endi + +print $data00 $data01 $data02 + +print =============== create child table +sql insert into db.c1 using db.st1 tags(1) values(now, 1); +sql insert into db.c2 using db.st1 tags(2) values(now, 2); +sql insert into db.c3 using db.st1 tags(3) values(now, 3); +sql insert into db.c4 using db.st1 tags(4) values(now, 4); +sql insert into db.c1 using db.st1 tags(1) values(now+1s, 1); +sql insert into db.c2 using db.st1 tags(2) values(now+1s, 2); +sql insert into db.c3 using db.st1 tags(3) values(now+1s, 3); +sql insert into db.c4 using db.st1 tags(4) values(now+1s, 4); + +sql show db.tables +if $rows != 4 then + return -1 +endi + +sql select * from db.c1 +if $rows != 2 then + return -1 +endi + +sql select * from db.c2 +if $rows != 2 then + return -1 +endi + +sql select * from db.c3 +if $rows != 2 then + return -1 +endi + +sql select * from db.c4 +if $rows != 2 then + return -1 +endi + +sql select * from db.st1 +if $rows != 8 then + return -1 +endi + +print =============== insert data +sql insert into db.s1 using db.st2 tags(1, 1, 1) values(now, 1, 2); +sql insert into db.s2 using db.st2 tags(2, 2, 2) values(now, 2, 3); +sql insert into db.s3 using db.st2 tags(3, 3, 3) values(now, 3, 4); +sql insert into db.s4 using db.st2 tags(4, 4, 4) values(now, 4, 5); +sql insert into db.s1 using db.st2 tags(1, 1, 1) values(now+1s, 1, 2); +sql insert into db.s2 using db.st2 tags(2, 2, 2) values(now+1s, 2, 3); +sql insert into db.s3 using db.st2 tags(3, 3, 3) values(now+1s, 3, 4); +sql insert into db.s4 using db.st2 tags(4, 4, 4) values(now+1s, 4, 5); +sql insert into db.s1 using db.st2 tags(1, 1, 1) values(now+2s, 1, 2); +sql insert into db.s2 using db.st2 tags(2, 2, 2) values(now+2s, 2, 3); +sql insert into db.s3 using db.st2 tags(3, 3, 3) values(now+2s, 3, 4); +sql insert into db.s4 using db.st2 tags(4, 4, 4) values(now+2s, 4, 5); + +sql show db.tables +if $rows != 8 then + return -1 +endi + +sql select * from db.s1 +if $rows != 3 then + return -1 +endi + +sql select * from db.s2 +if $rows != 3 then + return -1 +endi + +sql select * from db.s3 +if $rows != 3 then + return -1 +endi + +sql select * from db.s4 +if $rows != 3 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/table/back_insert.sim b/tests/script/general/table/back_insert.sim new file mode 100644 index 0000000000000000000000000000000000000000..43831cca95b49218719c5172c3d2d96ad3500896 --- /dev/null +++ b/tests/script/general/table/back_insert.sim @@ -0,0 +1,7 @@ +sql connect +$x = 1 +begin: + sql insert into db.tb values(now, $x ) -x begin + #print ===> insert successed $x + $x = $x + 1 +goto begin \ No newline at end of file diff --git a/tests/script/general/table/basic1.sim b/tests/script/general/table/basic1.sim new file mode 100644 index 0000000000000000000000000000000000000000..c26c3c33e4102723805925cccb61c63d01c866b8 --- /dev/null +++ b/tests/script/general/table/basic1.sim @@ -0,0 +1,73 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print =============== create database +sql create database d1 +sql show databases +if $rows != 1 then + return -1 +endi + +print $data00 $data01 $data02 + +print =============== create normal table +sql create table d1.n1 (ts timestamp, i int) +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print $data00 $data01 $data02 + +print =============== create super table +sql create table d1.st (ts timestamp, i int) tags (j int) +sql show d1.stables +if $rows != 1 then + return -1 +endi + +print $data00 $data01 $data02 + +print =============== create child table +sql create table d1.c1 using d1.st tags(1) +sql create table d1.c2 using d1.st tags(2) +sql show d1.tables +if $rows != 3 then + return -1 +endi + +print $data00 $data01 $data02 +print $data10 $data11 $data22 +print $data20 $data11 $data22 + +print =============== insert data +sql insert into d1.n1 values(now+1s, 1) +sql insert into d1.n1 values(now+2s, 2) +sql insert into d1.n1 values(now+3s, 3) + +print =============== query data +sql select * from d1.n1 +if $rows != 3 then + return -1 +endi + +print $data00 $data01 +print $data10 $data11 +print $data20 $data11 + +if $data01 != 1 then + return -1 +endi + +if $data11 != 2 then + return -1 +endi + +if $data21 != 3 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/table/basic2.sim b/tests/script/general/table/basic2.sim new file mode 100644 index 0000000000000000000000000000000000000000..4286f9ee4a5fce5ae98956d8f2e4d143000cbdbf --- /dev/null +++ b/tests/script/general/table/basic2.sim @@ -0,0 +1,69 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print =============== one table +sql create database d1 +sql create table d1.n1 (ts timestamp, i int) +sql create table d1.n2 (ts timestamp, i int) +sql create table d1.n3 (ts timestamp, i int) +sql create table d1.n4 (ts timestamp, i int) + +sql drop table d1.n1 +sql drop table d1.n2 + +sql show d1.tables +if $rows != 2 then + return -1 +endi + +print =============== show +sql show databases +if $data02 != 2 then + return -1 +endi + +if $data03 != 1 then + return -1 +endi + +sql show d1.vgroups +if $data00 != 2 then + return -1 +endi + +if $data01 != 2 then + return -1 +endi + +print =============== insert data1 +sql_error insert into d1.n1 values(now, 1) +sql_error insert into d1.n2 values(now, 1) + +print =============== insert data2 +sql insert into d1.n3 values(now, 1) +sql insert into d1.n3 values(now+1s, 2) +sql insert into d1.n3 values(now+2s, 3) + +print =============== query data +sql select * from d1.n3 +print $rows +if $rows != 3 then + return -1 +endi + +if $data01 != 1 then + return -1 +endi + +if $data11 != 2 then + return -1 +endi + +if $data21 != 3 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/table/basic3.sim b/tests/script/general/table/basic3.sim new file mode 100644 index 0000000000000000000000000000000000000000..41c276ae984c73672c439f39ba7c54f94f375ef4 --- /dev/null +++ b/tests/script/general/table/basic3.sim @@ -0,0 +1,80 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print =============== create database +sql create database db +sql show databases +if $rows != 1 then + return -1 +endi + +print $data00 $data01 $data02 + +print =============== create normal table +sql create table db.n1 (ts timestamp, i int) +sql show db.tables +if $rows != 1 then + return -1 +endi + +print $data00 $data01 $data02 + +print =============== create super table +sql create table db.st (ts timestamp, i int) tags (j int) +sql show db.stables +if $rows != 1 then + return -1 +endi + +print $data00 $data01 $data02 + +print =============== create child table +sql create table db.c1 using db.st tags(1) +sql create table db.c2 using db.st tags(2) +sql show db.tables +if $rows != 3 then + return -1 +endi + +print $data00 $data01 $data02 +print $data10 $data11 $data22 +print $data20 $data11 $data22 + +print =============== insert data +sql insert into db.n1 values(now+1s, 1) +sql insert into db.n1 values(now+2s, 2) +sql insert into db.n1 values(now+3s, 3) + +print =============== query data +sql select * from db.n1 +if $rows != 3 then + return -1 +endi + +print $data00 $data01 +print $data10 $data11 +print $data20 $data11 + +if $data01 != 1 then + return -1 +endi + +if $data11 != 2 then + return -1 +endi + +if $data21 != 3 then + return -1 +endi + +print =============== drop stable +sql drop table db.st +sql show db.stables +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/table/bigint.sim b/tests/script/general/table/bigint.sim new file mode 100644 index 0000000000000000000000000000000000000000..d75f406d77688374d75fd317508dd114f965f73a --- /dev/null +++ b/tests/script/general/table/bigint.sim @@ -0,0 +1,73 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$i = 0 +$dbPrefix = lm_bi_db +$tbPrefix = lm_bi_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed bigint) + +#sql insert into $tb values (now, -9223372036854775809) +sql insert into $tb values (now, -9223372036854770000) +sql select * from $tb +if $rows != 1 then + return -1 +endi +#if $data01 != -9223372036854775808 then +if $data01 != -9223372036854770000 then + return -1 +endi + +print =============== step2 +#sql insert into $tb values (now+1a, -9223372036854775808) +sql insert into $tb values (now+1a, -9223372036854770000) +sql select * from $tb +if $rows != 2 then + return -1 +endi +#if $data01 != -9223372036854775808 then +if $data01 != -9223372036854770000 then + return -1 +endi + +print =============== step3 +#sql insert into $tb values (now+1a, 9223372036854775807) +sql insert into $tb values (now+2a, 9223372036854770000) +sql select * from $tb order by ts desc +if $rows != 3 then + return -1 +endi +#if $data01 != 9223372036854775807 then +if $data01 != 9223372036854770000 then + return -1 +endi + +print =============== step4 +#sql insert into $tb values (now+1a, 9223372036854775808) +sql insert into $tb values (now+3a, 9223372036854770000) +sql select * from $tb order by ts desc +if $rows != 4 then + return -1 +endi +#if $data01 != 9223372036854775807 then +if $data01 != 9223372036854770000 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/table/binary.sim b/tests/script/general/table/binary.sim new file mode 100644 index 0000000000000000000000000000000000000000..47915530efc618f959c4f4ce17ea130aaa6ddf30 --- /dev/null +++ b/tests/script/general/table/binary.sim @@ -0,0 +1,63 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$i = 0 +$dbPrefix = lm_bn_db +$tbPrefix = lm_bn_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed binary(5)) + +sql insert into $tb values (now, ) -x step1 + return -1 +step1: + +print =============== step2 +sql insert into $tb values (now+1a, '1234') +sql select speed from $tb order by ts desc +if $rows != 1 then + return -1 +endi +if $data00 != 1234 then + return -1 +endi + +print =============== step3 +sql insert into $tb values (now+2a, '23456') +sql select speed from $tb order by ts desc +if $rows != 2 then + return -1 +endi +print ==> $data00 +if $data00 != 23456 then + return -1 +endi + +print =============== step4 +sql_error insert into $tb values (now+3a, '345678') +sql insert into $tb values (now+3a, '34567') +sql select speed from $tb order by ts desc +if $rows != 3 then + return -1 +endi +print ==> $data00 +if $data00 != 34567 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/table/bool.sim b/tests/script/general/table/bool.sim new file mode 100644 index 0000000000000000000000000000000000000000..e49637448f8f6afea890e58da47b81db20b35768 --- /dev/null +++ b/tests/script/general/table/bool.sim @@ -0,0 +1,92 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$i = 0 +$dbPrefix = lm_bo_db +$tbPrefix = lm_bo_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db +$x = 0 +sql create table $tb (ts timestamp, speed bool) + +sql insert into $tb values (now, true) +sql select * from $tb +if $rows != 1 then + return -1 +endi + +if $data01 != 1 then + return -1 +endi + +print =============== step2 +sql insert into $tb values (now+1m, 1) +sql select * from $tb order by ts desc +if $rows != 2 then + return -1 +endi + +if $data01 != 1 then + return -1 +endi + +print =============== step3 +sql insert into $tb values (now+2m, 2) +sql select * from $tb order by ts desc +if $rows != 3 then + return -1 +endi + +if $data01 != 1 then + return -1 +endi + +print =============== step4 +sql insert into $tb values (now+3m, 0) +sql select * from $tb order by ts desc +if $rows != 4 then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +print =============== step5 +sql insert into $tb values (now+4m, -1) +sql select * from $tb order by ts desc +if $rows != 5 then + return -1 +endi + +if $data01 != 1 then + return -1 +endi + +print =============== step6 +sql insert into $tb values (now+5m, false) +sql select * from $tb order by ts desc +if $rows != 6 then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/table/column2.sim b/tests/script/general/table/column2.sim new file mode 100644 index 0000000000000000000000000000000000000000..441766f2d4e6a2ff565b56f10b623e35b7c4c2ad --- /dev/null +++ b/tests/script/general/table/column2.sim @@ -0,0 +1,26 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print =============== step1 +sql create database db +sql use db +sql create table tt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g timestamp, h binary(10), i bool); +sql insert into tt values (now + 1m , 1 , 1 , 1 , 1 , 1 , 10, 150000000 , '11' , true ) + +sql select * from tt +if $rows != 1 then + return -1 +endi + +sql drop database db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/table/column_name.sim b/tests/script/general/table/column_name.sim new file mode 100644 index 0000000000000000000000000000000000000000..47fcfab5a8979bfb91290429a0a6490368371685 --- /dev/null +++ b/tests/script/general/table/column_name.sim @@ -0,0 +1,86 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$i = 0 +$dbPrefix = lm_cm_db +$tbPrefix = lm_cm_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db + +sql drop table dd -x step0 + return -1 +step0: + +sql create table $tb(ts timestamp, int) -x step1 + return -1 +step1: + +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step2 +sql create table $tb (ts timestamp, s int) +sql show tables +if $rows != 1 then + return -1 +endi + +sql drop table $tb +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step3 +sql create table $tb (ts timestamp, a0123456789 int) +sql show tables +if $rows != 1 then + return -1 +endi + +sql drop table $tb +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step4 +sql create table $tb (ts timestamp, a0123456789012345678901234567890123456789 int) +sql drop table $tb + +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step5 +sql create table $tb (ts timestamp, a0123456789 int) +sql show tables +if $rows != 1 then + return -1 +endi + +sql insert into $tb values (now , 1) +sql select * from $tb +if $rows != 1 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/table/column_num.sim b/tests/script/general/table/column_num.sim new file mode 100644 index 0000000000000000000000000000000000000000..a18173bc8f866fc984a1b10879990d69eaf0a311 --- /dev/null +++ b/tests/script/general/table/column_num.sim @@ -0,0 +1,85 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$i = 0 +$dbPrefix = lm_cn_db +$tbPrefix = lm_cn_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db + +sql create table $tb() -x step1 + return -1 +step1: + +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step2 +sql create table $tb (ts timestamp) -x step2 + return -1 +step2: + +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step3 +sql create table $tb (ts int) -x step3 + return -1 +step3: + +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step4 +sql create table $tb (ts timestamp, a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, a10 int, a11 int, a12 int, a13 int, a14 int, a15 int, a16 int, a17 int, a18 int, a19 int, a20 int, a21 int, a22 int, a23 int, a24 int, a25 int, a26 int, a27 int, a28 int,a29 int,a30 int,a31 int,a32 int, b1 int, b2 int, b3 int, b4 int, b5 int, b6 int, b7 int, b8 int, b9 int, b10 int, b11 int, b12 int, b13 int, b14 int, b15 int, b16 int, b17 int, b18 int, b19 int, b20 int, b21 int, b22 int, b23 int, b24 int, b25 int, b26 int, b27 int, b28 int,b29 int,b30 int,b31 int,b32 int) + +sql show tables +if $rows != 1 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb = $tbPrefix . $i + +sql create table $tb (ts timestamp, a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, a10 int, a11 int, a12 int, a13 int, a14 int, a15 int, a16 int, a17 int, a18 int, a19 int, a20 int, a21 int, a22 int, a23 int, a24 int, a25 int, a26 int, a27 int, a28 int,a29 int,a30 int,a31 int,a32 int, b1 int, b2 int, b3 int, b4 int, b5 int) + +sql show tables +if $rows != 2 then + return -1 +endi + +sql insert into $tb values (now, 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 , 25 ,26 , 27 ,28 ,29,30,31, 32, 33, 34, 35, 36, 37) +sql select * from $tb +if $rows != 1 then + return -1 +endi + +sql drop table $tb +sql show tables +if $rows != 1 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/table/column_value.sim b/tests/script/general/table/column_value.sim new file mode 100644 index 0000000000000000000000000000000000000000..1edf8c2992c4e5fb3dacdbac627a8687e1fc549f --- /dev/null +++ b/tests/script/general/table/column_value.sim @@ -0,0 +1,75 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$i = 0 +$dbPrefix = lm_cv_db +$tbPrefix = lm_cv_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db + +sql create table $tb (ts timestamp, speed int, v1 binary(100), v2 binary(100), v3 binary(100), v4 binary(100), v5 binary(100)) +sql show tables +if $rows != 1 then + return -1 +endi +sql insert into $tb values(now, 1, '1', '2', '3', '4', '5') +sql insert into $tb values(now+1a, 1, '1', '2', '3', '4', '5') +sql select * from $tb +if $rows != 2 then + return -1 +endi +sql drop table $tb +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step2 +sql create table $tb (ts timestamp, speed bigint, v1 binary(1500), v2 binary(1500), v3 binary(1500), v4 binary(500), v5 binary(500)) +sql show tables +if $rows != 1 then + return -1 +endi +sql drop table $tb + +print =============== step3 +sql create table $tb (ts timestamp, speed float, v1 binary(100), v2 binary(100), v3 binary(100), v4 binary(100), v5 binary(100)) +sql show tables +if $rows != 1 then + return -1 +endi +sql insert into $tb values(now+2a, 1, '1', '2', '3', '4', '5') +sql insert into $tb values(now+3a, 1, '1', '2', '3', '4', '5') +sql select * from $tb +if $rows != 2 then + return -1 +endi +sql drop table $tb +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step4 +sql create table $tb (ts timestamp, speed double, v1 binary(1500), v2 binary(1500), v3 binary(1500), v4 binary(500), v5 binary(500)) +sql show tables +if $rows != 1 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/table/createmulti.sim b/tests/script/general/table/createmulti.sim new file mode 100644 index 0000000000000000000000000000000000000000..0da1ce96a759551936eb00b00d6915b01682a64c --- /dev/null +++ b/tests/script/general/table/createmulti.sim @@ -0,0 +1,46 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +print =============== create database +sql create database db +sql show databases +if $rows != 1 then + return -1 +endi + +print $data00 $data01 $data02 + +print =============== create super table +sql create table db.st1 (ts timestamp, i int) tags (j int) +sql create table db.st2 (ts timestamp, i int, j int) tags (t1 int, t2 int, t3 int) +sql show db.stables +if $rows != 2 then + return -1 +endi + +print $data00 $data01 $data02 + +print =============== create multiple child tables +sql create table db.ct1 using db.st1 tags(1) db.ct2 using db.st1 tags(2); + +sql show db.tables +if $rows != 2 then + return -1 +endi + +sql create table db.ct3 using db.st2 tags(1, 1, 1) db.ct4 using db.st2 tags(2, 2, 2); +sql show db.tables +if $rows != 4 then + return -1 +endi + +sql create table db.ct5 using db.st1 tags(3) db.ct6 using db.st2 tags(3, 3, 3); +sql show db.tables +if $rows != 6 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/table/date.sim b/tests/script/general/table/date.sim new file mode 100644 index 0000000000000000000000000000000000000000..23188e12e0a9b148877c87b67079c5429455eece --- /dev/null +++ b/tests/script/general/table/date.sim @@ -0,0 +1,90 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$i = 0 +$dbPrefix = lm_da_db +$tbPrefix = lm_da_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db + +sql create table $tb (ts timestamp, speed int) +sql insert into $tb values ('2017-01-01 08:00:00.001', 1) +sql select ts from $tb +if $rows != 1 then + return -1 +endi +if $data00 != @17-01-01 08:00:00.001@ then + return -1 +endi + +print =============== step2 +sql insert into $tb values ('2017-08-28 00:23:46.429+ 1a', 2) +#sql insert into $tb values ('2017-08-28 00:23:46cd .429', 2) +sql select ts from $tb +if $rows != 2 then + return -1 +endi + +print =============== step3 +#sql insert into $tb values ('1970-01-01 08:00:00.000', 3) +#sql insert into $tb values ('1970-01-01 08:00:00.000', 3) +sql select ts from $tb +if $rows != 2 then + return -1 +endi + +print =============== step4 +sql insert into $tb values(now, 4); +sql insert into $tb values(now+1a, 5); +sql insert into $tb values(now+1s, 6); +sql insert into $tb values(now+1m, 7); +sql insert into $tb values(now+1h, 8); +sql insert into $tb values(now+1d, 9); +sql_error insert into $tb values(now+3w, 10); +sql_error insert into $tb values(now+1n, 11); +sql_error insert into $tb values(now+1y, 12); + +print =============== step5 +sql_error insert into $tb values ('9999-12-31 213:59:59.999', 13) +sql select ts from $tb +print $rows +if $rows != 8 then + return -1 +endi + +print =============== step6 +sql_error insert into $tb values ('9999-12-99 23:59:59.999', 13) + +sql select ts from $tb +if $rows != 8 then + return -1 +endi + +print =============== step7 +$i = 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, ts2 timestamp) + +print =============== step8 +sql insert into $tb values (now, now) +sql select * from $tb +if $rows != 1 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/table/db.table.sim b/tests/script/general/table/db.table.sim new file mode 100644 index 0000000000000000000000000000000000000000..906396402a1abad594e08387878bf7c3674f55ad --- /dev/null +++ b/tests/script/general/table/db.table.sim @@ -0,0 +1,47 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$i = 0 +$dbPrefix = lm_dt_db +$tbPrefix = lm_dt_tb +$db = $dbPrefix +$tb = $tbPrefix + +print =============== step1 +sql create database $db +$table = lm_dt_db.lm_dt_tb + +print =============== step2 +sql create table $table (ts timestamp, speed int) + +print =============== step3 +sql insert into $table values (now, 1) + +print =============== step4 +sql select * from $table +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +print =============== step5 +sql describe $table + +print =============== step6 +sql drop table $table + + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/table/delete_reuse1.sim b/tests/script/general/table/delete_reuse1.sim new file mode 100644 index 0000000000000000000000000000000000000000..db594254873d47564e94927b04765c32798866bd --- /dev/null +++ b/tests/script/general/table/delete_reuse1.sim @@ -0,0 +1,81 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode3 -c walLevel -v 1 +system sh/cfg.sh -n dnode4 -c walLevel -v 1 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======== step1 +sql create database d1 replica 1 +sql create table d1.t1 (ts timestamp, i int) +sql insert into d1.t1 values(now, 1) + +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi + +print ======== step2 +sql drop table d1.t1 +sleep 1000 +sql insert into d1.t1 values(now, 2) -x step2 + return -1 +step2: + +print ========= step3 +sql create table d1.t1 (ts timestamp, i int) +sql insert into d1.t1 values(now, 2) +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi +if $data01 != 2 then + return -1 +endi + +print ========= step4 +$x = 0 +while $x < 20 + + sql drop table d1.t1 + sleep 1000 + sql insert into d1.t1 values(now, -1) -x step4 + return -1 + step4: + + sql create table d1.t1 (ts timestamp, i int) + sql insert into d1.t1 values(now, $x ) + sql select * from d1.t1 + if $rows != 1 then + return -1 + endi + if $data01 != $x then + return -1 + endi + + $x = $x + 1 + + print ===> loop times: $x +endw + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/table/delete_reuse2.sim b/tests/script/general/table/delete_reuse2.sim new file mode 100644 index 0000000000000000000000000000000000000000..f2784a3f5f2b3cb9ae9729b8ed254502eec7766a --- /dev/null +++ b/tests/script/general/table/delete_reuse2.sim @@ -0,0 +1,83 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode3 -c walLevel -v 1 +system sh/cfg.sh -n dnode4 -c walLevel -v 1 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======== step1 +sql create database db1 replica 1 +sql create table db1.t1 (ts timestamp, i int) +sql insert into db1.t1 values(now, 1) + +sql select * from db1.t1 +if $rows != 1 then + return -1 +endi + +print ======== step2 +sql drop table db1.t1 +sleep 1000 +sql_error insert into db1.t1 values(now, 2) + +print ========= step3 +sql create table db1.tb1 (ts timestamp, i int) +sql insert into db1.tb1 values(now, 2) +sql select * from db1.tb1 +if $rows != 1 then + return -1 +endi +if $data01 != 2 then + return -1 +endi + +sql use db1 +print ========= step4 +$x = 1 +while $x < 20 + + $tb = tb . $x + sql drop table $tb + + sleep 1000 + sql_error insert into $tb values(now, -1) + + step4: + + $x = $x + 1 + $tb = tb . $x + + sql create table $tb (ts timestamp, i int) + sql insert into $tb values(now, $x ) + sql select * from $tb + if $rows != 1 then + return -1 + endi + if $data01 != $x then + return -1 + endi + + print ===> loop times: $x +endw + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/table/delete_writing.sim b/tests/script/general/table/delete_writing.sim new file mode 100644 index 0000000000000000000000000000000000000000..5351d13d80ad732b2a58953f72b3c62086b1090b --- /dev/null +++ b/tests/script/general/table/delete_writing.sim @@ -0,0 +1,49 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode3 -c walLevel -v 1 +system sh/cfg.sh -n dnode4 -c walLevel -v 1 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create database db +sql create table db.tb (ts timestamp, i int) +sql insert into db.tb values(now, 1) + +print ======== start back +run_back general/table/back_insert.sim +sleep 1000 + +print ======== step1 +$x = 1 +while $x < 15 + + print drop table times $x + sql drop table db.tb -x step1 + step1: + + sql create table db.tb (ts timestamp, i int) + + sleep 1000 + + $x = $x + 1 +endw + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/table/describe.sim b/tests/script/general/table/describe.sim new file mode 100644 index 0000000000000000000000000000000000000000..e59371e530a51a171efa64393925e6d311230432 --- /dev/null +++ b/tests/script/general/table/describe.sim @@ -0,0 +1,49 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$i = 0 +$dbPrefix = de_in_db +$tbPrefix = de_in_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed int) + +sql describe $tb +if $rows != 2 then + return -1 +endi +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data02 != 8 then + return -1 +endi +if $data10 != speed then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data12 != 4 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/table/double.sim b/tests/script/general/table/double.sim new file mode 100644 index 0000000000000000000000000000000000000000..ab3f2428bde489b3024e332861bad1d38cb99179 --- /dev/null +++ b/tests/script/general/table/double.sim @@ -0,0 +1,98 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$i = 0 +$dbPrefix = lm_do_db +$tbPrefix = lm_do_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed double) +#sql insert into $tb values (now, -1.79E+308) -x step1 +# return -1 +#step1: + +print =============== step2 +#sql insert into $tb values (now+1a, 1.79E+308) -x step2 +# return -1 +#step2: + +sql select * from $tb order by ts desc +if $rows != 0 then + return -1 +endi + +print =============== step3 +sql insert into $tb values (now+2a, 2.85) +sql select * from $tb order by ts desc +if $rows != 1 then + return -1 +endi +if $data01 != 2.850000000 then + return -1 +endi + +print =============== step4 +sql insert into $tb values (now+3a, 3.4) +sql select * from $tb order by ts desc +if $rows != 2 then + return -1 +endi +if $data01 != 3.400000000 then + return -1 +endi + +print =============== step5 +sql insert into $tb values (now+4a, a2) -x step51 + return -1 +step51: +sql insert into $tb values (now+4a, 0) +sql select * from $tb order by ts desc +if $rows != 3 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi + +print =============== step6 +sql insert into $tb values (now+5a, 2a) -x step6 + return -1 +step6: +sql insert into $tb values(now+5a, 2) +sql select * from $tb order by ts desc +if $rows != 4 then + return -1 +endi +if $data01 != 2.000000000 then + return -1 +endi + +print =============== step7 +sql insert into $tb values (now+6a, 2a'1) -x step7 + return -1 +step7: +sql insert into $tb values(now+6a, 2) +sql select * from $tb order by ts desc +if $rows != 5 then + return -1 +endi +if $data01 != 2.000000000 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/table/float.sim b/tests/script/general/table/float.sim new file mode 100644 index 0000000000000000000000000000000000000000..2d0ea0e5eab06ad127ef445d140c0cd52a50532e --- /dev/null +++ b/tests/script/general/table/float.sim @@ -0,0 +1,98 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$i = 0 +$dbPrefix = lm_fl_db +$tbPrefix = lm_fl_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed float) +#sql insert into $tb values (now, -3.40E+38) -x step1 +# return -1 +#step1: + +print =============== step2 +#sql insert into $tb values (now+1a, 3.40E+308) -x step2 +# return -1 +#step2: + +sql select * from $tb order by ts desc +if $rows != 0 then + return -1 +endi + +print =============== step3 +sql insert into $tb values (now+2a, 2.85) +sql select * from $tb order by ts desc +if $rows != 1 then + return -1 +endi +if $data01 != 2.85000 then + return -1 +endi + +print =============== step4 +sql insert into $tb values (now+3a, 3.4) +sql select * from $tb order by ts desc +if $rows != 2 then + return -1 +endi +if $data01 != 3.40000 then + return -1 +endi + +print =============== step5 +sql insert into $tb values (now+4a, a2) -x step5 + return -1 +step5: +sql insert into $tb values (now+4a, 0) +sql select * from $tb order by ts desc +if $rows != 3 then + return -1 +endi +if $data01 != 0.00000 then + return -1 +endi + +print =============== step6 +sql insert into $tb values (now+5a, 2a) -x step6 + return -1 +step6: +sql insert into $tb values (now+5a, 2) +sql select * from $tb order by ts desc +if $rows != 4 then + return -1 +endi +if $data01 != 2.00000 then + return -1 +endi + +print =============== step7 +sql insert into $tb values (now+6a, 2a'1) -x step7 + return -1 +step7: +sql insert into $tb values (now+6a, 2) +sql select * from $tb order by ts desc +if $rows != 5 then + return -1 +endi +if $data01 != 2.00000 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/table/int.sim b/tests/script/general/table/int.sim new file mode 100644 index 0000000000000000000000000000000000000000..f30b5b28f5457ccfbf83d48816f2417cbd3e3d46 --- /dev/null +++ b/tests/script/general/table/int.sim @@ -0,0 +1,134 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$i = 0 +$dbPrefix = lm_in_db +$tbPrefix = lm_in_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed int) + +sql insert into $tb values (now, NULL) +sql select * from $tb order by ts desc +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi + +print =============== step2 +sql insert into $tb values (now+1m, -2147483648) -x step2 + return -1 +step2: +sql insert into $tb values (now+1m, NULL) +sql select * from $tb order by ts desc +if $rows != 2 then + return -1 +endi +if $data01 != NULL then + return -1 +endi + +print =============== step3 +sql insert into $tb values (now+2m, 2147483647) +sql select * from $tb order by ts desc +if $rows != 3 then + return -1 +endi +if $data01 != 2147483647 then + return -1 +endi + +print =============== step4 +sql insert into $tb values (now+3m, 2147483648) -x step4 + return -1 +step4: +sql insert into $tb values (now+3m, NULL) +sql select * from $tb order by ts desc +if $rows != 4 then + return -1 +endi +if $data01 != NULL then + return -1 +endi + +print =============== step5 +sql_error insert into $tb values (now+4m, a2) +sql insert into $tb values (now+4m, 0) +sql select * from $tb order by ts desc +if $rows != 5 then + return -1 +endi +if $data01 != 0 then + return -1 +endi + +print =============== step6 +sql_error insert into $tb values (now+5m, 2a) +sql insert into $tb values (now+5m, 2) +sql select * from $tb order by ts desc +if $rows != 6 then + return -1 +endi +if $data01 != 2 then + return -1 +endi + +print =============== step7 +sql_error insert into $tb values (now+6m, 2a'1) +sql insert into $tb values (now+6m, 2) +sql select * from $tb order by ts desc +if $rows != 7 then + return -1 +endi +if $data01 != 2 then + return -1 +endi + +print =============== step8 +sql insert into $tb values (now+8m, "NULL") +sql select * from $tb order by ts desc +if $rows != 8 then + return -1 +endi +if $data01 != NULL then + return -1 +endi + +print =============== step9 +sql insert into $tb values (now+9m, 'NULL') +sql select * from $tb order by ts desc +if $rows != 9 then + return -1 +endi +if $data01 != NULL then + return -1 +endi + +print =============== step10 +sql insert into $tb values (now+10m, -123) +sql select * from $tb order by ts desc +if $rows != 10 then + return -1 +endi +if $data01 != -123 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/table/limit.sim b/tests/script/general/table/limit.sim new file mode 100644 index 0000000000000000000000000000000000000000..dd38453d0cb0580e446992ae36f022e5e2ac1185 --- /dev/null +++ b/tests/script/general/table/limit.sim @@ -0,0 +1,94 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 129 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 8 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ============================ dnode1 start + +$i = 0 +$dbPrefix = ob_tl_db +$tbPrefix = ob_tl_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =================== step 0 +sql create database $db +sql use $db +sql show vgroups +if $rows != 0 then + return -1 +endi + +$N = 256 + +print =================== step 1 +$x = $N +$y = 0 +while $x > $y + $table = a . $x + sql create table $table (ts timestamp, speed int, i float, d double, b bigint, c binary(20)) + $x = $x - 1 +endw + +sql show vgroups +if $rows != 8 then + return -1 +endi + +print =================== step 2 + +$x = $N +$y = 0 +while $x > $y + $table = b . $x + sql create table $table (ts timestamp, speed int, i float, d double, b bigint, c binary(20)) + $x = $x - 1 +endw + +sql show vgroups +if $rows != 8 then + return -1 +endi + +print =================== step 3 + +$x = $N +$y = 0 +while $x > $y + $table = c . $x + sql create table $table (ts timestamp, speed int, i float, d double, b bigint, c binary(20)) + $x = $x - 1 +endw + +sql show vgroups +if $rows != 8 then + return -1 +endi + +print =================== step 4 + +$x = $N +$y = 0 +while $x > $y + $table = d . $x + sql create table $table (ts timestamp, speed int, i float, d double, b bigint, c binary(20)) + $x = $x - 1 +endw + +sql show vgroups +if $rows != 8 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/table/smallint.sim b/tests/script/general/table/smallint.sim new file mode 100644 index 0000000000000000000000000000000000000000..f622ce7853062edb15dca4344101cd6a96299225 --- /dev/null +++ b/tests/script/general/table/smallint.sim @@ -0,0 +1,105 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$i = 0 +$dbPrefix = lm_sm_db +$tbPrefix = lm_sm_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed smallint) + +sql insert into $tb values (now, NULL) +sql select * from $tb order by ts desc +if $rows != 1 then + return -1 +endi +print $data01 +if $data01 != NULL then + return -1 +endi + +print =============== step2 +sql insert into $tb values (now+1m, -32768) -x step2 + return -1 +step2: +sql insert into $tb values (now+1m, NULL) +sql select * from $tb order by ts desc +if $rows != 2 then + return -1 +endi +if $data01 != NULL then + return -1 +endi + +print =============== step3 +sql insert into $tb values (now+2m, 32767) +sql select * from $tb order by ts desc +if $rows != 3 then + return -1 +endi +if $data01 != 32767 then + return -1 +endi + +print =============== step4 +sql insert into $tb values (now+3m, 32768) -x step4 + return -1 +step4: +sql insert into $tb values (now+3m, NULL) +sql select * from $tb order by ts desc +if $rows != 4 then + return -1 +endi +if $data01 != NULL then + return -1 +endi + +print =============== step5 +sql_error insert into $tb values (now+4m, a2) +sql insert into $tb values (now+4m, 0) +sql select * from $tb order by ts desc +if $rows != 5 then + return -1 +endi +if $data01 != 0 then + return -1 +endi + +print =============== step6 +sql_error insert into $tb values (now+5m, 2a) +sql insert into $tb values (now+5m, 2) +sql select * from $tb order by ts desc +if $rows != 6 then + return -1 +endi +if $data01 != 2 then + return -1 +endi + +print =============== step7 +sql_error insert into $tb values (now+6m, 2a'1) +sql insert into $tb values (now+6m, 2) +sql select * from $tb order by ts desc +if $rows != 7 then + return -1 +endi +if $data01 != 2 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/table/table.sim b/tests/script/general/table/table.sim new file mode 100644 index 0000000000000000000000000000000000000000..c9806c40c649695a489bdcc659e085b03f7d674b --- /dev/null +++ b/tests/script/general/table/table.sim @@ -0,0 +1,224 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ============================ dnode1 start + +$i = 0 +$dbPrefix = ob_tb_db +$tbPrefix = ob_tb_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop database $db -x step1 +step1: +sql create database $db + +print =============== step2-3-4 +sql use $db + +$i = 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val tinyint, val2 tinyint) +sql insert into $tb values(now, 1, 1) +sql select * from $tb +if $data01 != 1 then + return -1 +endi + +$i = 2 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val smallint, val2 smallint) +sql insert into $tb values(now, 2, 2) +sql select * from $tb +if $data01 != 2 then + return -1 +endi + +$i = 3 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val int, val2 int) +sql insert into $tb values(now, 3, 3) +sql select * from $tb +if $data01 != 3 then + return -1 +endi + +$i = 4 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val bigint, val2 bigint) +sql insert into $tb values(now, 4, 4) +sql select * from $tb +if $data01 != 4 then + return -1 +endi + +$i = 5 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val float, val2 float) +sql insert into $tb values(now, 5, 5) +sql select * from $tb +print ==> $data01 $data02 +if $data01 != 5.00000 then + return -1 +endi + +$i = 6 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val double, val2 double) +sql insert into $tb values(now, 6, 6) +sql select * from $tb +print ==> $data01 $data02 +if $data01 != 6.000000000 then + return -1 +endi + +$i = 7 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val binary(20), val2 binary(20)) +sql insert into $tb values(now, '7', '7') +sql select * from $tb +if $data01 != 7 then + return -1 +endi + +print =============== step5 +sql show tables +if $rows != 7 then + return -1 +endi + +$i = 1 +while $i < 8 + $tb = $tbPrefix . $i + sql drop table $tb + $i = $i + 1 +endw + +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step6-9 +$i = 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val tinyint, val2 tinyint) +sql select * from $tb +if $rows != 0 then + return -1 +endi +sql insert into $tb values(now, 1, 1) +sql select * from $tb +if $data01 != 1 then + return -1 +endi + +$i = 2 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val smallint, val2 smallint) +sql select * from $tb +if $rows != 0 then + return -1 +endi +sql insert into $tb values(now, 2, 2) +sql select * from $tb +if $data01 != 2 then + return -1 +endi + +$i = 3 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val int, val2 int) +sql select * from $tb +if $rows != 0 then + return -1 +endi +sql insert into $tb values(now, 3, 3) +sql select * from $tb +if $data01 != 3 then + return -1 +endi + +$i = 4 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val bigint, val2 bigint) +sql select * from $tb +if $rows != 0 then + return -1 +endi +sql insert into $tb values(now, 4, 4) +sql select * from $tb +if $data01 != 4 then + return -1 +endi + +$i = 5 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val float, val2 float) +sql select * from $tb +if $rows != 0 then + return -1 +endi +sql insert into $tb values(now, 5, 5) +sql select * from $tb +print ==> $data01 $data02 +if $data01 != 5.00000 then + return -1 +endi + +$i = 6 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val double, val2 double) +sql select * from $tb +if $rows != 0 then + return -1 +endi +sql insert into $tb values(now, 6, 6) +sql select * from $tb +print ==> $data01 $data02 +if $data01 != 6.000000000 then + return -1 +endi + +$i = 7 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val binary(20), val2 binary(20)) +sql select * from $tb +if $rows != 0 then + return -1 +endi +sql insert into $tb values(now, '7', '7') +sql select * from $tb +if $data01 != 7 then + return -1 +endi + +print =============== step10 +$i = 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val tinyint, val2 tinyint) +sql show tables +if $rows != 7 then + return -1 +endi + +print =============== step11 +sql create table $tb (ts timestamp, val float, val2 double) +sql show tables +if $rows != 7 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/table/table_len.sim b/tests/script/general/table/table_len.sim new file mode 100644 index 0000000000000000000000000000000000000000..d95c9ab0aa9cdc4db66d65d2334088550c05bfa9 --- /dev/null +++ b/tests/script/general/table/table_len.sim @@ -0,0 +1,105 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$i = 0 +$dbPrefix = lm_tb_db +$tbPrefix = lm_tb_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db + +sql drop table dd -x step0 + return -1 +step0: + +sql create table (ts timestamp, speed int) -x step1 + return -1 +step1: + +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step2 +sql create table a (ts timestamp, speed int) +sql show tables +if $rows != 1 then + return -1 +endi + +sql drop table a +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step3 +sql create table a0123456789 (ts timestamp, speed int) +sql show tables +if $rows != 1 then + return -1 +endi + +sql drop table a0123456789 +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step4 +sql create table ab01234567890123456789a0123456789a0123456789ab01234567890123456789a0123456789a0123456789ab01234567890123456789a0123456789a0123456789ab01234567890123456789a0123456789a0123456789ab01234567890123456789a0123456789a0123456789ab01234567890123456789a0123456789a0123456789 (ts timestamp, speed int) -x step4 + return -1 +step4: +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step5 +sql create table a;1 (ts timestamp, speed int) -x step5 + return -1 +step5: +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step6 +sql create table a'1 (ts timestamp, speed int) -x step6 + return -1 +step6: +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step7 +sql create table (a) (ts timestamp, speed int) -x step7 + return -1 +step7: +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step8 +sql create table a.1 (ts timestamp, speed int) -x step8 + return -1 +step8: + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/table/testSuite.sim b/tests/script/general/table/testSuite.sim new file mode 100644 index 0000000000000000000000000000000000000000..d6cc88b36a6bb695a34eab889f52bdcb525017fb --- /dev/null +++ b/tests/script/general/table/testSuite.sim @@ -0,0 +1,27 @@ +run general/table/autocreate.sim +run general/table/basic1.sim +run general/table/basic2.sim +run general/table/basic3.sim +run general/table/bigint.sim +run general/table/binary.sim +run general/table/bool.sim +run general/table/column_name.sim +run general/table/column_num.sim +run general/table/column_value.sim +run general/table/column2.sim +run general/table/date.sim +run general/table/db.table.sim +run general/table/delete_reuse1.sim +run general/table/delete_reuse2.sim +run general/table/delete_writing.sim +run general/table/describe.sim +run general/table/double.sim +run general/table/fill.sim +run general/table/float.sim +run general/table/int.sim +run general/table/limit.sim +run general/table/smallint.sim +run general/table/table_len.sim +run general/table/table.sim +run general/table/tinyint.sim +run general/table/vgroup.sim diff --git a/tests/script/general/table/tinyint.sim b/tests/script/general/table/tinyint.sim new file mode 100644 index 0000000000000000000000000000000000000000..afa931fc79802e5790f90492576c90acb51e06dc --- /dev/null +++ b/tests/script/general/table/tinyint.sim @@ -0,0 +1,104 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$i = 0 +$dbPrefix = lm_ti_db +$tbPrefix = lm_ti_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed tinyint) + +sql insert into $tb values (now, NULL) +sql select * from $tb order by ts desc +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi + +print =============== step2 +sql insert into $tb values (now+1m, -128) -x step2 + return -1 +step2: +sql insert into $tb values (now+1m, NULL) +sql select * from $tb order by ts desc +if $rows != 2 then + return -1 +endi +if $data01 != NULL then + return -1 +endi + +print =============== step3 +sql insert into $tb values (now+2m, 127) +sql select * from $tb order by ts desc +if $rows != 3 then + return -1 +endi +if $data01 != 127 then + return -1 +endi + +print =============== step4 +sql insert into $tb values (now+3m, 128) -x step4 + return -1 +step4: +sql insert into $tb values (now+3m, NULL) +sql select * from $tb +if $rows != 4 then + return -1 +endi +if $data01 != NULL then + return -1 +endi + +print =============== step5 +sql_error insert into $tb values (now+4m, a2) +sql insert into $tb values (now+4m, 0) +sql select * from $tb order by ts desc +if $rows != 5 then + return -1 +endi +if $data01 != 0 then + return -1 +endi + +print =============== step6 +sql_error insert into $tb values (now+5m, 2a) +sql insert into $tb values (now+5m, 2) +sql select * from $tb order by ts desc +if $rows != 6 then + return -1 +endi +if $data01 != 2 then + return -1 +endi + +print =============== step7 +sql_error insert into $tb values (now+6m, 2a'1) +sql insert into $tb values (now+6m, 2) +sql select * from $tb order by ts desc +if $rows != 7 then + return -1 +endi +if $data01 != 2 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/table/vgroup.sim b/tests/script/general/table/vgroup.sim new file mode 100644 index 0000000000000000000000000000000000000000..d306a4731db2023e87ac0e69378e448bbd555c56 --- /dev/null +++ b/tests/script/general/table/vgroup.sim @@ -0,0 +1,151 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 4 +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect +print ============================ dnode1 start + +$i = 0 +$dbPrefix = ob_vg_db +$tbPrefix = ob_vg_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =================== step 1 +sql create database $db +sql use $db +sql show vgroups +if $rows != 0 then + return -1 +endi + +sql create table table1 (ts timestamp, speed int) +sql create table table2 (ts timestamp, speed int) +sql create table table3 (ts timestamp, speed int) +sql create table table4 (ts timestamp, speed int) +sql show vgroups +if $rows != 1 then + return -1 +endi + +sql create table table5 (ts timestamp, speed int) +sql create table table6 (ts timestamp, speed int) +sql create table table7 (ts timestamp, speed int) +sql create table table8 (ts timestamp, speed int) +sql show vgroups +if $rows != 2 then + return -1 +endi + +sql create table table9 (ts timestamp, speed int) +sql create table table10 (ts timestamp, speed int) +sql create table table11 (ts timestamp, speed int) +sql create table table12 (ts timestamp, speed int) +sql show vgroups +if $rows != 3 then + return -1 +endi + +sql create table table13 (ts timestamp, speed int) +sql show vgroups +if $rows != 4 then + return -1 +endi + +sql drop table table13 +sql show vgroups +if $rows != 3 then + return -1 +endi + +sql create table table13 (ts timestamp, speed int) +sql show vgroups +if $rows != 4 then + return -1 +endi + +print =================== step 2 +$i = 1 +$db = $dbPrefix . $i + +sql create database $db +sql use $db +sql show vgroups +if $rows != 0 then + return -1 +endi + +$i = 0 +$db = $dbPrefix . $i +sql drop database $db + +$i = 1 +$db = $dbPrefix . $i +sql use $db +sql create table table2 (ts timestamp, speed int) +sql show vgroups +if $rows != 1 then + return -1 +endi + +sql drop table table2 +sql show vgroups +if $rows != 0 then + return -1 +endi + +sql create table table1 (ts timestamp, speed int) +sql create table table2 (ts timestamp, speed int) +sql create table table3 (ts timestamp, speed int) +sql create table table4 (ts timestamp, speed int) +sql drop table table1 +sql show vgroups +if $rows != 1 then + return -1 +endi + +print =================== step 3 +$i = 0 +$db = $dbPrefix . $i +sql create database $db +sql use $db +sql create table table1 (ts timestamp, speed int) + +$i = 2 +$db = $dbPrefix . $i +sql create database $db +sql use $db +sql create table table3 (ts timestamp, speed int) + +$i = 3 +$db = $dbPrefix . $i +sql create database $db +sql use $db +sql create table table4 (ts timestamp, speed int) + +$i = 4 +$db = $dbPrefix . $i +sql create database $db +sql use $db + +sql show databases +if $rows != 5 then + return -1 +endi + +$i = 0 +while $i < 5 + $db = $dbPrefix . $i + sql drop database $db + $i = $i + 1 +endw +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/user/authority.sim b/tests/script/general/user/authority.sim new file mode 100644 index 0000000000000000000000000000000000000000..45230e3e8af59dcac57ff71a7802ba6a637cc8d7 --- /dev/null +++ b/tests/script/general/user/authority.sim @@ -0,0 +1,66 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect +sleep 2000 + +print ============= step1 +sql create user read pass 'taosdata' +sql create user write pass 'taosdata' +sql show users +if $rows != 5 then + return -1 +endi + +print ============= step2 +sql close +sql connect read +sleep 2000 + +sql create database dread +sql show databases +if $rows != 1 then + return -1 +endi + +print ============= step3 +sql close +sql connect write +sleep 2000 + +sql create database dwrite +sql show databases +if $rows != 2 then + return -1 +endi + +print ============ step4 +sql close +sql connect +sleep 2000 + +sql show databases +if $row != 2 then + return -1 +endi + +print ============ step5 +sql close +sql connect read +sleep 2000 +sql drop database dread +sql drop database dwrite + + +sql close +sql connect +sql show databases +if $rows != 0 then + return -1 +endi + +sql close +sql connect +sleep 2000 + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/user/basic1.sim b/tests/script/general/user/basic1.sim new file mode 100644 index 0000000000000000000000000000000000000000..3670c1ddb097146f97135b2cab0022c9531d89e0 --- /dev/null +++ b/tests/script/general/user/basic1.sim @@ -0,0 +1,74 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +print =============== show users +sql show users +if $rows != 3 then + return -1 +endi + +print $data00 $data01 $data02 +print $data10 $data11 $data22 +print $data20 $data11 $data22 + +sql_error show accounts; +sql_error create account a pass "a" +sql_error drop account a +sql_error drop account root + +print =============== create user1 +sql create user user1 PASS 'user1' +sql show users +if $rows != 4 then + return -1 +endi + +print $data00 $data01 $data02 +print $data10 $data11 $data22 +print $data20 $data11 $data22 +print $data30 $data31 $data32 + +print =============== create user2 +sql create user user2 PASS 'user2' +sql show users +if $rows != 5 then + return -1 +endi + +print $data00 $data01 $data02 +print $data10 $data11 $data22 +print $data20 $data11 $data22 +print $data30 $data31 $data32 +print $data40 $data41 $data42 + +print =============== drop user1 +sql drop user user1 +sql show users +if $rows != 4 then + return -1 +endi + +print $data00 $data01 $data02 +print $data10 $data11 $data22 +print $data20 $data11 $data22 +print $data30 $data31 $data32 + +print =============== restart taosd +system sh/exec.sh -n dnode1 -s stop +sleep 1000 +system sh/exec.sh -n dnode1 -s start + +print =============== show users +sql show users +if $rows != 4 then + return -1 +endi + +print $data00 $data01 $data02 +print $data10 $data11 $data22 +print $data20 $data11 $data22 +print $data30 $data31 $data32 + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/user/monitor.sim b/tests/script/general/user/monitor.sim new file mode 100644 index 0000000000000000000000000000000000000000..90aad59932115e04263da8cc1e8b91effb09eb07 --- /dev/null +++ b/tests/script/general/user/monitor.sim @@ -0,0 +1,32 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 + +print ========== step1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c monitor -v 1 +system sh/cfg.sh -n dnode1 -c monitorInterval -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ========== step2 +#sql drop database log -x step21 +# return -1 +#step21: +sql drop table log.dn -x step22 +# return -1 +step22: +sql drop user log -x step23 +# return -1 +step23: + +print ========== step3 + +sleep 2000 +#sql select * from log.dn +#if $rows == 0 then +# return -1 +#endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/user/pass_alter.sim b/tests/script/general/user/pass_alter.sim new file mode 100644 index 0000000000000000000000000000000000000000..964e311ec0b17eb99d8cbfd745cc4510b9a94252 --- /dev/null +++ b/tests/script/general/user/pass_alter.sim @@ -0,0 +1,68 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============= step1 +sql create user read pass 'taosdata1' +sql create user write pass 'taosdata1' + +sql alter user read pass 'taosdata' +sql alter user write pass 'taosdata' + +sql show users +if $rows != 5 then + return -1 +endi + +print ============= step2 +sql close +sleep 2500 +print user read login +sql connect read +sql alter user read pass 'taosdata' +sql alter user write pass 'taosdata1' -x step2 + return -1 +step2: + +sql_error create user read pass 'taosdata1' +sql_error create user write pass 'taosdata1' + +sql show users +if $rows != 5 then + return -1 +endi + +print ============= step3 +sql close +sleep 2500 +print user write login +sql connect write + +sql_error create user read pass 'taosdata1' +sql_error create user write pass 'taosdata1' +sql alter user write pass 'taosdata' +sql alter user read pass 'taosdata' -x step3 + return -1 +step3: + +sql show users +if $rows != 5 then + return -1 +endi + +print ============= step4 +sql close +sleep 2500 +print root write login +sql connect +sql create user oroot pass 'taosdata' + +sql show users +if $rows != 6 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/user/pass_len.sim b/tests/script/general/user/pass_len.sim new file mode 100644 index 0000000000000000000000000000000000000000..5eb200b51f9ac28b19ea095be6530dbada9be894 --- /dev/null +++ b/tests/script/general/user/pass_len.sim @@ -0,0 +1,82 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$i = 0 +$dbPrefix = apdb +$tbPrefix = aptb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +$userPrefix = apusr + +print =============== step1 +$i = 0 +$user = $userPrefix . $i + +sql drop user $user -x step11 + return -1 +step11: + +sql create user $user PASS -x step12 + return -1 +step12: + +sql create user $user PASS 'taosdata' + +sql show users +if $rows != 4 then + return -1 +endi + +print =============== step2 +$i = 1 +$user = $userPrefix . $i +sql drop user $user -x step2 +step2: +sql create user $user PASS '1' +sql show users +if $rows != 5 then + return -1 +endi + +print =============== step3 +$i = 2 +$user = $userPrefix . $i +sql drop user $user -x step3 +step3: + +sql create user $user PASS 'abc0123456789' +sql show users +if $rows != 6 then + return -1 +endi + +print =============== step4 +$i = 3 +$user = $userPrefix . $i +sql create user $user PASS 'abcd012345678901234567891234567890' -x step4 + return -1 +step4: +sql show users +if $rows != 6 then + return -1 +endi + +$i = 0 +while $i < 3 + $user = $userPrefix . $i + sql drop user $user + $i = $i + 1 +endw + +sql show users +if $rows != 3 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/user/testSuite.sim b/tests/script/general/user/testSuite.sim new file mode 100644 index 0000000000000000000000000000000000000000..b4bf52cfd1dfd13e99306110a63a19e6dc8bb230 --- /dev/null +++ b/tests/script/general/user/testSuite.sim @@ -0,0 +1,6 @@ +run general/user/basic1.sim +run general/user/monitor.sim +run general/user/pass_alter.sim +run general/user/pass_len.sim +run general/user/user_create.sim +run general/user/user_len.sim \ No newline at end of file diff --git a/tests/script/general/user/user_create.sim b/tests/script/general/user/user_create.sim new file mode 100644 index 0000000000000000000000000000000000000000..34934d09e6bb6c26a2ac228f722d841aba82fba6 --- /dev/null +++ b/tests/script/general/user/user_create.sim @@ -0,0 +1,84 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 0 +system sh/exec.sh -n dnode1 -s start +sql connect + +print =============== step1 +sql show users +if $rows != 3 then + return -1 +endi + +sql create user read PASS 'pass123' +sql create user read PASS 'pass123' -x step1 + return -1 +step1: + +sql show users +if $rows != 4 then + return -1 +endi + +sql alter user read PASS 'taosdata' + +print =============== step2 +sql close +sql connect read +sleep 2000 + +sql alter user read PASS 'taosdata' + +print =============== step3 +sql drop user read -x step31 + return -1 +step31: +sql drop user _root -x step32 + return -1 +step32: +sql drop user monitor -x step33 + return -1 +step33: + +print =============== step4 +sql close +sql connect +sleep 2000 + +sql alter user read privilege read +sql show users +print $data1_read +if $data1_read != readable then + return -1 +endi + +sql_error alter user read privilege super +sql show users +print $data1_read +if $data1_read != readable then + return -1 +endi + +sql alter user read privilege write +sql show users +print $data1_read +if $data1_read != writable then + return -1 +endi + +sql alter user read privilege 1 -x step43 + return -1 +step43: + +sql drop user _root -x step41 + return -1 +step41: + +sql drop user monitor -x step42 + return -1 +step42: + +sql drop user read + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/user/user_len.sim b/tests/script/general/user/user_len.sim new file mode 100644 index 0000000000000000000000000000000000000000..55e5eb19ef476691882e7c9ba589697aef8190da --- /dev/null +++ b/tests/script/general/user/user_len.sim @@ -0,0 +1,90 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$i = 0 +$dbPrefix = lm_us_db +$tbPrefix = lm_us_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop user ac -x step0 + return -1 +step0: + +sql create user PASS '123' -x step1 + return -1 +step1: + +sql show users +if $rows != 3 then + return -1 +endi + +print =============== step2 +sql drop user a -x step2 +step2: +sql create user a PASS '123' +sql show users +if $rows != 4 then + return -1 +endi + +sql drop user a +sql show users +if $rows != 3 then + return -1 +endi + +print =============== step3 +sql drop user abc01234567890123456789 -x step3 +step3: + +sql create user abc01234567890123456789 PASS '123' +sql show users +if $rows != 4 then + return -1 +endi + +sql drop user abc01234567890123456789 +sql show users +if $rows != 3 then + return -1 +endi + +print =============== step4 +sql create user abcd0123456789012345678901234567890111 PASS '123' -x step4 + return -1 +step4: +sql show users +if $rows != 3 then + return -1 +endi + +print =============== step5 +sql drop user 123 -x step5 +step5: +sql create user 123 PASS '123' -x step61 + return -1 +step61: + +sql create user a123 PASS '123' +sql show users +if $rows != 4 then + return -1 +endi + +sql drop user a123 +sql show users +if $rows != 3 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/vector/metrics_field.sim b/tests/script/general/vector/metrics_field.sim new file mode 100644 index 0000000000000000000000000000000000000000..2719805c63af87d4088a9b1fd87249f09e51b957 --- /dev/null +++ b/tests/script/general/vector/metrics_field.sim @@ -0,0 +1,623 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$dbPrefix = m_mf_db +$tbPrefix = m_mf_tb +$mtPrefix = m_mf_mt + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - f from $mt where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - a from $mt where a = 5 +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select b - f from $mt where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - b from $mt where a = 5 +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select c - f from $mt where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select d - f from $mt where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select e - f from $mt where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - f from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $mt where a = 5 -x step21 + return -1 +step21: + +sql select h - f from $mt where a = 5 -x step22 + return -1 +step22: + +sql select ts - f from $mt where a = 5 -x step23 + return -1 +step23: + +sql select a - e from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a + f from $mt where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + a from $mt where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select b + f from $mt where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + b from $mt where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select c + f from $mt where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select d + f from $mt where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select e + f from $mt where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + f from $mt where a = 5 +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + e from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + e from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d + e from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + d from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + d from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + d from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + c from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + c from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + b from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + a from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a * f from $mt where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * a from $mt where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select b * f from $mt where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * b from $mt where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select c * f from $mt where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select d * f from $mt where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select e * f from $mt where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * f from $mt where a = 5 +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * e from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * e from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select d * e from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * d from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * d from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * d from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * c from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * c from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * b from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * a from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a / f from $mt where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / a from $mt where a = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b / f from $mt where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / b from $mt where a = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c / f from $mt where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select d / f from $mt where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select e / f from $mt where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / f from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $mt where a = 5 +print ===> $data00 +if $data00 != 2.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $mt where a = 5 +print ===> $data00 +if $data00 != 0.400000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $mt where a = 5 +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $mt where a = 5 +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $mt where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $mt where a = 5 +print ===> $data00 +if $data00 != -15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $mt where a = 5 +print ===> $data00 +if $data00 != -1.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $mt where a = 5 +print ===> $data00 +if $data00 != -150.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $mt where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $mt where a = 5 +print ===> $data00 +if $data00 != -25.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $mt where a = 5 +print ===> $data00 +if $data00 != -1300.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $mt where a = 5 -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $mt where a = 5 -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $mt where a = 5 -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/vector/metrics_mix.sim b/tests/script/general/vector/metrics_mix.sim new file mode 100644 index 0000000000000000000000000000000000000000..7c9bb3b668c67fbc75cffc9b15bad1b276142917 --- /dev/null +++ b/tests/script/general/vector/metrics_mix.sim @@ -0,0 +1,623 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$dbPrefix = m_mx_db +$tbPrefix = m_mx_tb +$mtPrefix = m_mx_mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - ffrom $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -x step020 + return -1 +step020: + +sql select a -f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select b - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select c - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select d - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select e - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -x step21 + return -1 +step21: + +sql select h - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -x step22 + return -1 +step22: + +sql select ts - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -x step23 + return -1 +step23: + +sql select a - e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a + f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select b + f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select c + f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select d + f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select e + f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d + e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select b * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select c * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select d * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select e * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select d * e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select d / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select e / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.400000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -1.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -150.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -25.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -1300.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/vector/metrics_query.sim b/tests/script/general/vector/metrics_query.sim new file mode 100644 index 0000000000000000000000000000000000000000..fd635a3104f70f4fcbcd71914b476dfc3fb69ea8 --- /dev/null +++ b/tests/script/general/vector/metrics_query.sim @@ -0,0 +1,619 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$dbPrefix = m_mq_db +$tbPrefix = m_mq_tb +$mtPrefix = m_mq_mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - f from $mt +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - a from $mt +print ===> $data00 +if $data00 != 9.000000000 then + return -1 +endi + +sql select b - f from $mt +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - b from $mt +print ===> $data00 +if $data00 != 9.000000000 then + return -1 +endi + +sql select c - f from $mt +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select d - f from $mt +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select e - f from $mt +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - f from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $mt -x step21 + return -1 +step21: + +sql select h - f from $mt -x step22 + return -1 +step22: + +sql select ts - f from $mt -x step23 + return -1 +step23: + +sql select a - e from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb = $tbPrefix . $i + +sql select a + f from $mt +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + a from $mt +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select b + f from $mt +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + b from $mt +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select c + f from $mt +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select d + f from $mt +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select e + f from $mt +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + f from $mt +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + e from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c + e from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select d + e from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + d from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + d from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c + d from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + c from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + c from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + b from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + a from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb = $tbPrefix . $i + +sql select a * f from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * a from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b * f from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * b from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c * f from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d * f from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select e * f from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * f from $mt +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * e from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c * e from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d * e from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * d from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * d from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c * d from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * c from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * c from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * b from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * a from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb = $tbPrefix . $i + +sql select a / f from $mt +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / a from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b / f from $mt +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / b from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c / f from $mt +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select d / f from $mt +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select e / f from $mt +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / f from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $mt +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $mt +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $mt +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $mt +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $mt +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $mt +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $mt +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $mt +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $mt +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $mt +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $mt -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $mt -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $mt -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/vector/metrics_tag.sim b/tests/script/general/vector/metrics_tag.sim new file mode 100644 index 0000000000000000000000000000000000000000..1d412d35d3669ced6437e6025f8415ddd3a1cf1e --- /dev/null +++ b/tests/script/general/vector/metrics_tag.sim @@ -0,0 +1,619 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$dbPrefix = m_mtg_db +$tbPrefix = m_mtg_tb +$mtPrefix = m_mtg_mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - f from $mt +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - a from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 9.000000000 then + return -1 +endi + +sql select b - f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - b from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 9.000000000 then + return -1 +endi + +sql select c - f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select d - f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select e - f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $mt where tgcol = 5 -x step21 + return -1 +step21: + +sql select h - f from $mt where tgcol = 5 -x step22 + return -1 +step22: + +sql select ts - f from $mt where tgcol = 5 -x step23 + return -1 +step23: + +sql select a - e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb = $tbPrefix . $i + +sql select a + f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + a from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select b + f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + b from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select c + f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select d + f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select e + f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c + e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select d + e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c + d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + c from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + c from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + b from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + a from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb = $tbPrefix . $i + +sql select a * f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * a from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b * f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * b from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c * f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d * f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select e * f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c * e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d * e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c * d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * c from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * c from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * b from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * a from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb = $tbPrefix . $i + +sql select a / f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / a from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b / f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / b from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c / f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select d / f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select e / f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $mt where tgcol = 5 -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $mt where tgcol = 5 -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $mt where tgcol = 5 -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/vector/metrics_time.sim b/tests/script/general/vector/metrics_time.sim new file mode 100644 index 0000000000000000000000000000000000000000..d0152439bff2c9ab5450d870b2238d0b137a2fa4 --- /dev/null +++ b/tests/script/general/vector/metrics_time.sim @@ -0,0 +1,619 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$dbPrefix = m_mt_db +$tbPrefix = m_mt_tb +$mtPrefix = m_mt_mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select b - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select c - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select d - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select e - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -x step21 + return -1 +step21: + +sql select h - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -x step22 + return -1 +step22: + +sql select ts - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -x step23 + return -1 +step23: + +sql select a - e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select b + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select c + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select d + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select e + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d + e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select b * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select c * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select d * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select e * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select d * e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select d / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select e / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.400000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -1.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -150.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -25.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -1300.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/vector/multi.sim b/tests/script/general/vector/multi.sim new file mode 100644 index 0000000000000000000000000000000000000000..1101b0b0dbc4484e8ccef3aaab5ce8fe54b03d0b --- /dev/null +++ b/tests/script/general/vector/multi.sim @@ -0,0 +1,216 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$dbPrefix = m_mu_db +$tbPrefix = m_mu_tb +$mtPrefix = m_mu_mt + +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f binary(10), g bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a + b from $tb +print ===> $data00 $data10 $data20 $data30 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + c from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + d from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + e from $tb where ts < now + 4m order by ts desc + +sql select a + a from $tb where ts > now + 4m order by ts desc + +sql select a + c from $tb where ts < now + 4m order by ts asc + +sql select a + f from $tb where ts > now + 4m order by ts asc -x step24 + return -1 +step24: + +print =============== step3 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - e from $tb +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select a - b from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - e from $tb where ts > now + 4m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb = $tbPrefix . $i + +sql select a * b + e from $tb +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select a * b + c from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a * b -d from $tb where ts > now + 4m +print ===> $data20 +if $data20 != 42.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb = $tbPrefix . $i + +sql select a / 2 + e from $tb +print ===> $data00 +if $data00 != 10.500000000 then + return -1 +endi + +sql select a / 2 from $tb where ts < now + 4m +print ===> $data10 +if $data10 != 1.000000000 then + return -1 +endi + +sql select a / 2 * e from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a / e from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb = $tbPrefix . $i +sql select a + ts from $tb -x step61 + return -1 +step61: + +sql select a + f from $tb -x step62 + return -1 +step62: + +sql select a + g from $tb -x step63 + return -1 +step63: + +print =============== step7 +$i = 1 +$tb = $tbPrefix . $i + +sql select a + b from $tb where a = 2 +print ===> $data00 +if $data00 != 4.000000000 then + return -1 +endi + +sql select * from $tb where b < 2 +print ===> $rows +if $rows != 1 then + return -1 +endi + +sql select * from $tb where b > 2 +print ===> $rows +if $rows != 17 then + return -1 +endi + +sql select a + c from $tb where b = 2 and ts < now + 4m +print ===> $data00 +if $data00 != 4.000000000 then + return -1 +endi + +sql select a + d from $tb where c = 10 and ts > now + 4m +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $tb where d = 2 and ts < now + 4m order by ts desc + +sql select a + a from $tb where e = 2 and ts > now + 4m order by ts desc + +sql select a + c from $tb where f = 2 and ts < now + 4m order by ts asc + +sql select a + f from $tb where g = 2 and ts > now + 4m order by ts asc -x step74 + return -1 +step74: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/vector/single.sim b/tests/script/general/vector/single.sim new file mode 100644 index 0000000000000000000000000000000000000000..e979a0ffb71e78ed2a3a79cb32e5b34ab98fd21a --- /dev/null +++ b/tests/script/general/vector/single.sim @@ -0,0 +1,303 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$dbPrefix = m_si_db +$tbPrefix = m_si_tb +$mtPrefix = m_si_mt + +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select tbcol + 1 from $tb +print ===> $data00 $data10 $data20 $data30 +if $data00 != 1.000000000 then + return -1 +endi + +sql select tbcol + 1 from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select tbcol + 1 from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 6.000000000 then + return -1 +endi + +sql select tbcol + 1 from $tb where ts < now + 4m order by ts desc + +sql select tbcol + 1 from $tb where ts > now + 4m order by ts desc + +sql select tbcol + 1 from $tb where ts < now + 4m order by ts asc + +sql select tbcol + 1 from $tb where ts > now + 4m order by ts asc + +print =============== step3 +$i = 1 +$tb = $tbPrefix . $i + +sql select tbcol - 1 from $tb +print ===> $data00 +if $data00 != -1.000000000 then + return -1 +endi + +sql select tbcol - 1 from $tb where ts < now + 4m +print ===> $data00 +if $data00 != -1.000000000 then + return -1 +endi + +sql select tbcol - 1 from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 4.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb = $tbPrefix . $i + +sql select tbcol * 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select tbcol * 2 from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select tbcol * 2 from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb = $tbPrefix . $i + +sql select tbcol / 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select tbcol / 2 from $tb where ts < now + 4m +print ===> $data10 +if $data10 != 0.500000000 then + return -1 +endi + +sql select tbcol / 2 from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 2.500000000 then + return -1 +endi + +sql select tbcol / 0 from $tb where ts > now + 4m +print ===> $data00 +#if $data00 != 0.000000000 then +# return -1 +#endi + +print =============== step6 +$i = 11 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, tbcol bool) +sql insert into $tb values(now, 0) +sql select tbcol + 2 from $tb -x step6 + return -1 +step6: + +print =============== step7 +$i = $i + 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, tbcol tinyint) +sql insert into $tb values(now, 0); +sql select tbcol + 2 from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi +sql select tbcol - 2 from $tb +print ===> $data00 +if $data00 != -2.000000000 then + return -1 +endi +sql select tbcol * 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi +sql select tbcol / 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step8 +$i = $i + 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, tbcol smallint) +sql insert into $tb values(now, 0); +sql select tbcol + 2 from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi +sql select tbcol - 2 from $tb +print ===> $data00 +if $data00 != -2.000000000 then + return -1 +endi +sql select tbcol * 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi +sql select tbcol / 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step9 +$i = $i + 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, tbcol bigint) +sql insert into $tb values(now, 0); +sql select tbcol + 2 from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi +sql select tbcol - 2 from $tb +print ===> $data00 +if $data00 != -2.000000000 then + return -1 +endi +sql select tbcol * 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi +sql select tbcol / 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step10 +$i = $i + 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, tbcol float) +sql insert into $tb values(now, 0); +sql select tbcol + 2 from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi +sql select tbcol - 2 from $tb +print ===> $data00 +if $data00 != -2.000000000 then + return -1 +endi +sql select tbcol * 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi +sql select tbcol / 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step11 +$i = $i + 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, tbcol double) +sql insert into $tb values(now, 0); +sql select tbcol + 2 from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi +sql select tbcol - 2 from $tb +print ===> $data00 +if $data00 != -2.000000000 then + return -1 +endi +sql select tbcol * 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi +sql select tbcol / 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step12 +$i = $i + 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, tbcol binary(100)) +sql insert into $tb values(now, '0'); +sql select tbcol + 2 from $tb -x step12 + return -1 +step12: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/vector/table_field.sim b/tests/script/general/vector/table_field.sim new file mode 100644 index 0000000000000000000000000000000000000000..d86eb99331f9c65c013d4d9bdd5798672629eab9 --- /dev/null +++ b/tests/script/general/vector/table_field.sim @@ -0,0 +1,619 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$dbPrefix = m_tf_db +$tbPrefix = m_tf_tb +$mtPrefix = m_tf_mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - f from $tb where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - a from $tb where a = 5 +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select b - f from $tb where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - b from $tb where a = 5 +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select c - f from $tb where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select d - f from $tb where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select e - f from $tb where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - f from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $tb where a = 5 -x step21 + return -1 +step21: + +sql select h - f from $tb where a = 5 -x step22 + return -1 +step22: + +sql select ts - f from $tb where a = 5 -x step23 + return -1 +step23: + +sql select a - e from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb where a = 5 = $tbPrefix . $i + +sql select a + f from $tb where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + a from $tb where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select b + f from $tb where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + b from $tb where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select c + f from $tb where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select d + f from $tb where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select e + f from $tb where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + f from $tb where a = 5 +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + e from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + e from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d + e from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + d from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + d from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + d from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + c from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + c from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + b from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + a from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb where a = 5 = $tbPrefix . $i + +sql select a * f from $tb where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * a from $tb where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select b * f from $tb where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * b from $tb where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select c * f from $tb where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select d * f from $tb where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select e * f from $tb where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * f from $tb where a = 5 +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * e from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * e from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select d * e from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * d from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * d from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * d from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * c from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * c from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * b from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * a from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb where a = 5 = $tbPrefix . $i + +sql select a / f from $tb where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / a from $tb where a = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b / f from $tb where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / b from $tb where a = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c / f from $tb where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select d / f from $tb where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select e / f from $tb where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / f from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb where a = 5 = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $tb where a = 5 +print ===> $data00 +if $data00 != 2.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $tb where a = 5 +print ===> $data00 +if $data00 != 0.400000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $tb where a = 5 +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $tb where a = 5 +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $tb where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $tb where a = 5 +print ===> $data00 +if $data00 != -15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $tb where a = 5 +print ===> $data00 +if $data00 != -1.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $tb where a = 5 +print ===> $data00 +if $data00 != -150.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $tb where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $tb where a = 5 +print ===> $data00 +if $data00 != -25.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $tb where a = 5 +print ===> $data00 +if $data00 != -1300.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $tb where a = 5 -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $tb where a = 5 -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $tb where a = 5 -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/vector/table_mix.sim b/tests/script/general/vector/table_mix.sim new file mode 100644 index 0000000000000000000000000000000000000000..5c4fb52888d3a02608bdc90d4c213c3a4f4ac0ff --- /dev/null +++ b/tests/script/general/vector/table_mix.sim @@ -0,0 +1,619 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$dbPrefix = m_tm_db +$tbPrefix = m_tm_tb +$mtPrefix = m_tm_mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - f from $tb where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - a from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select b - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - b from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select c - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select d - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select e - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -x step21 + return -1 +step21: + +sql select h - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -x step22 + return -1 +step22: + +sql select ts - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -x step23 + return -1 +step23: + +sql select a - e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb where a = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a + f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + a from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select b + f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + b from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select c + f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select d + f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select e + f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d + e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + c from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + c from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + b from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + a from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb where a = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * a from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select b * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * b from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select c * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select d * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select e * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select d * e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * c from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * c from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * b from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * a from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb where a = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / a from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / b from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select d / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select e / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb where a = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.400000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -1.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -150.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -25.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -1300.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $tb where a = 5 and ts > now + 4m and ts < now + 6m -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $tb where a = 5 and ts > now + 4m and ts < now + 6m -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $tb where a = 5 and ts > now + 4m and ts < now + 6m -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/vector/table_query.sim b/tests/script/general/vector/table_query.sim new file mode 100644 index 0000000000000000000000000000000000000000..9ef18255a9582982cddcd8c8c699adeb6f01f1b6 --- /dev/null +++ b/tests/script/general/vector/table_query.sim @@ -0,0 +1,619 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$dbPrefix = m_tq_db +$tbPrefix = m_tq_tb +$mtPrefix = m_tq_mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - f from $tb +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - a from $tb +print ===> $data00 +if $data00 != 9.000000000 then + return -1 +endi + +sql select b - f from $tb +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - b from $tb +print ===> $data00 +if $data00 != 9.000000000 then + return -1 +endi + +sql select c - f from $tb +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select d - f from $tb +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select e - f from $tb +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - f from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $tb -x step21 + return -1 +step21: + +sql select h - f from $tb -x step22 + return -1 +step22: + +sql select ts - f from $tb -x step23 + return -1 +step23: + +sql select a - e from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb = $tbPrefix . $i + +sql select a + f from $tb +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + a from $tb +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select b + f from $tb +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + b from $tb +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select c + f from $tb +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select d + f from $tb +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select e + f from $tb +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + f from $tb +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + e from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c + e from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select d + e from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + d from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + d from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c + d from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + c from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + c from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + b from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + a from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb = $tbPrefix . $i + +sql select a * f from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * a from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b * f from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * b from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c * f from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d * f from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select e * f from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * f from $tb +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * e from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c * e from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d * e from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * d from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * d from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c * d from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * c from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * c from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * b from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * a from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb = $tbPrefix . $i + +sql select a / f from $tb +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / a from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b / f from $tb +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / b from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c / f from $tb +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select d / f from $tb +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select e / f from $tb +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / f from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $tb +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $tb +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $tb +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $tb +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $tb +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $tb +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $tb +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $tb +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $tb +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $tb +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $tb -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $tb -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $tb -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/vector/table_time.sim b/tests/script/general/vector/table_time.sim new file mode 100644 index 0000000000000000000000000000000000000000..c38546b1170fdbe5249a4220fbf112ea8eb25b18 --- /dev/null +++ b/tests/script/general/vector/table_time.sim @@ -0,0 +1,619 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$dbPrefix = m_tt_db +$tbPrefix = m_tt_tb +$mtPrefix = m_tt_mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - a from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select b - f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - b from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select c - f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select d - f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select e - f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $tb where ts > now + 4m and ts < now + 6m -x step21 + return -1 +step21: + +sql select h - f from $tb where ts > now + 4m and ts < now + 6m -x step22 + return -1 +step22: + +sql select ts - f from $tb where ts > now + 4m and ts < now + 6m -x step23 + return -1 +step23: + +sql select a - e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb where ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a + f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + a from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select b + f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + b from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select c + f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select d + f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select e + f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d + e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + c from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + c from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + b from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + a from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb where ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a * f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * a from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select b * f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * b from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select c * f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select d * f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select e * f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select d * e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * c from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * c from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * b from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * a from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb where ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a / f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / a from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b / f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / b from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c / f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select d / f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select e / f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb where ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.400000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -1.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -150.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -25.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -1300.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $tb where ts > now + 4m and ts < now + 6m -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $tb where ts > now + 4m and ts < now + 6m -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $tb where ts > now + 4m and ts < now + 6m -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/vector/testSuite.sim b/tests/script/general/vector/testSuite.sim new file mode 100644 index 0000000000000000000000000000000000000000..f0b9fef9912699f5e8ed86b322c30db2d4210c83 --- /dev/null +++ b/tests/script/general/vector/testSuite.sim @@ -0,0 +1,11 @@ +run general/vector/metrics_field.sim +run general/vector/metrics_mix.sim +run general/vector/metrics_query.sim +run general/vector/metrics_tag.sim +run general/vector/metrics_time.sim +run general/vector/multi.sim +run general/vector/single.sim +run general/vector/table_field.sim +run general/vector/table_mix.sim +run general/vector/table_query.sim +run general/vector/table_time.sim diff --git a/tests/script/general/wal/kill.sim b/tests/script/general/wal/kill.sim new file mode 100644 index 0000000000000000000000000000000000000000..94a35b636e7915842787ed982590b39a93e1f408 --- /dev/null +++ b/tests/script/general/wal/kill.sim @@ -0,0 +1,77 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 + +print ============== deploy +system sh/exec.sh -n dnode1 -s start +sleep 3001 +sql connect + +sql create database d1 +sql use d1 + +sql create table t1 (ts timestamp, i int) +sql insert into t1 values(now, 1); + +print =============== step3 +sleep 2000 +sql select * from t1; +print rows: $rows +if $rows != 1 then + return -1 +endi +system sh/exec.sh -n dnode1 -s stop -x SIGKILL +sleep 2000 + +print =============== step4 +system sh/exec.sh -n dnode1 -s start -x SIGKILL +sleep 2000 +sql select * from t1; +print rows: $rows +if $rows != 1 then + return -1 +endi +system sh/exec.sh -n dnode1 -s stop -x SIGKILL +sleep 2000 + +print =============== step5 +system sh/exec.sh -n dnode1 -s start -x SIGKILL +sleep 2000 +sql select * from t1; +print rows: $rows +if $rows != 1 then + return -1 +endi +system sh/exec.sh -n dnode1 -s stop -x SIGKILL +sleep 2000 + +print =============== step6 +system sh/exec.sh -n dnode1 -s start -x SIGKILL +sleep 2000 +sql select * from t1; +print rows: $rows +if $rows != 1 then + return -1 +endi +system sh/exec.sh -n dnode1 -s stop -x SIGKILL +sleep 2000 + +print =============== step7 +system sh/exec.sh -n dnode1 -s start -x SIGKILL +sleep 2000 +sql select * from t1; +print rows: $rows +if $rows != 1 then + return -1 +endi +system sh/exec.sh -n dnode1 -s stop -x SIGKILL +sleep 2000 + +print =============== step8 +system sh/exec.sh -n dnode1 -s start -x SIGKILL +sleep 2000 +sql select * from t1; +print rows: $rows +if $rows != 1 then + return -1 +endi +system sh/exec.sh -n dnode1 -s stop -x SIGKILL diff --git a/tests/script/general/wal/maxtables.sim b/tests/script/general/wal/maxtables.sim new file mode 100644 index 0000000000000000000000000000000000000000..acd6af1d1a1dbb02a3aef35fe2d9c07cae74b529 --- /dev/null +++ b/tests/script/general/wal/maxtables.sim @@ -0,0 +1,46 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 100 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode1 -c tableIncStepPerVnode -v 2 + + +print ============== deploy +system sh/exec.sh -n dnode1 -s start +sleep 3001 +sql connect + +sql create database d1 +sql use d1 +sql create table st (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < 100 + $tb = t . $i + sql create table $tb using st tags( $i ) + sql insert into $tb values (now , $i ) + $i = $i + 1 +endw + +sql_error sql create table tt (ts timestamp, i int) + +print =============== step3 +sql select * from st; +if $rows != 100 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 +sleep 2000 + +print =============== step4 +system sh/exec.sh -n dnode1 -s start +sleep 2000 + +sql select * from st; +if $rows != 100 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/wal/sync.sim b/tests/script/general/wal/sync.sim new file mode 100644 index 0000000000000000000000000000000000000000..3a8952391818bc02244f7455f694b6c1fe834288 --- /dev/null +++ b/tests/script/general/wal/sync.sim @@ -0,0 +1,146 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c http -v 1 +system sh/cfg.sh -n dnode2 -c http -v 1 +system sh/cfg.sh -n dnode3 -c http -v 1 + +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 20000 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 20000 +system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 20000 + +system sh/cfg.sh -n dnode1 -c replica -v 3 +system sh/cfg.sh -n dnode2 -c replica -v 3 +system sh/cfg.sh -n dnode3 -c replica -v 3 + +system sh/cfg.sh -n dnode1 -c maxSQLLength -v 940032 +system sh/cfg.sh -n dnode2 -c maxSQLLength -v 940032 +system sh/cfg.sh -n dnode3 -c maxSQLLength -v 940032 + +print ============== deploy + +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create dnode $hostname2 +sql create dnode $hostname3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start + +print =============== step1 +$x = 0 +show1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi +sql show mnodes -x show1 +$mnode1Role = $data2_1 +print mnode1Role $mnode1Role +$mnode2Role = $data2_2 +print mnode2Role $mnode2Role +$mnode3Role = $data2_3 +print mnode3Role $mnode3Role + +if $mnode1Role != master then + goto show1 +endi +if $mnode2Role != slave then + goto show1 +endi +if $mnode3Role != slave then + goto show1 +endi + +print =============== step2 +sql create database d1 replica 3 +sql use d1 + +sql create table table_rest (ts timestamp, i int) +print sql length is 870KB +restful d1 table_rest 1591072800 30000 +restful d1 table_rest 1591172800 30000 +restful d1 table_rest 1591272800 30000 +restful d1 table_rest 1591372800 30000 +restful d1 table_rest 1591472800 30000 +restful d1 table_rest 1591572800 30000 +restful d1 table_rest 1591672800 30000 +restful d1 table_rest 1591772800 30000 +restful d1 table_rest 1591872800 30000 +restful d1 table_rest 1591972800 30000 + +sleep 100 +sql select * from table_rest; +print rows: $rows +if $rows != 300000 then + return -1 +endi + +print =============== step3 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sql select * from table_rest; +print rows: $rows +if $rows != 300000 then + return -1 +endi +system sh/exec.sh -n dnode1 -s start -x SIGINT + +$x = 0 +a1: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show vgroups +print online vnodes $data03 +if $data03 != 3 then + goto a1 +endi + +print =============== step4 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sql select * from table_rest; +print rows: $rows +if $rows != 300000 then + return -1 +endi +system sh/exec.sh -n dnode2 -s start -x SIGINT +$x = 0 +a2: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show vgroups +print online vnodes $data03 +if $data03 != 3 then + goto a2 +endi + +print =============== step5 +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sql select * from table_rest; +print rows: $rows +if $rows != 300000 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/issue/TD-2677.sim b/tests/script/issue/TD-2677.sim new file mode 100644 index 0000000000000000000000000000000000000000..8d2058a3851e456dd85f8d6a295ce45b7a6fd3bd --- /dev/null +++ b/tests/script/issue/TD-2677.sim @@ -0,0 +1,111 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 + +print ============== deploy + +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create dnode $hostname2 +sql create dnode $hostname3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start + +print =============== step1 +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 + +if $data4_1 != ready then + goto step1 +endi +if $data4_2 != ready then + goto step1 +endi +if $data4_3 != ready then + goto step1 +endi + +sql show mnodes +$mnode1Role = $data2_1 +print mnode1Role $mnode1Role +$mnode2Role = $data2_2 +print mnode2Role $mnode2Role +$mnode3Role = $data2_3 +print mnode3Role $mnode3Role + +if $mnode1Role != master then + goto step1 +endi +if $mnode2Role != slave then + goto step1 +endi +if $mnode3Role != slave then + goto step1 +endi + +$x = 1 +show2: + +print =============== step1 +sql create database d1 replica 2 quorum 2 +sql create table d1.t1 (ts timestamp, i int) +sql_error create table d1.t1 (ts timestamp, i int) +sql insert into d1.t1 values(now, 1) +sql select * from d1.t1; +if $rows != 1 then + return -1 +endi + +print =============== step2 +sql create database d2 replica 3 quorum 2 +sql create table d2.t1 (ts timestamp, i int) +sql_error create table d2.t1 (ts timestamp, i int) +sql insert into d2.t1 values(now, 1) +sql select * from d2.t1; +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql create database d4 replica 1 quorum 1 +sql_error create database d5 replica 1 quorum 2 +sql_error create database d6 replica 1 quorum 3 +sql_error create database d7 replica 1 quorum 4 +sql_error create database d8 replica 1 quorum 0 +sql create database d9 replica 2 quorum 1 +sql create database d10 replica 2 quorum 2 +sql_error create database d11 replica 2 quorum 3 +sql_error create database d12 replica 2 quorum 4 +sql_error create database d12 replica 2 quorum 0 +sql create database d13 replica 3 quorum 1 +sql create database d14 replica 3 quorum 2 +sql_error create database d15 replica 3 quorum 3 +sql_error create database d16 replica 3 quorum 4 +sql_error create database d17 replica 3 quorum 0 + + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT diff --git a/tests/script/issue/TD-2680.sim b/tests/script/issue/TD-2680.sim new file mode 100644 index 0000000000000000000000000000000000000000..631332160fe1ede876ef2b966dfb1963ac7351ca --- /dev/null +++ b/tests/script/issue/TD-2680.sim @@ -0,0 +1,202 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0 +system sh/exec_tarbitrator.sh -s start + +print ============== step1 +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode $hostname2 +sql create dnode $hostname3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 + +if $data4_1 != ready then + goto step1 +endi +if $data4_2 != ready then + goto step1 +endi +if $data4_3 != ready then + goto step1 +endi + +sql show mnodes +print mnode1 $data2_1 +print mnode1 $data2_2 +print mnode1 $data2_3 +if $data2_1 != master then + goto step1 +endi + +print ============== step2 +sql show dnodes +if $rows != 4 then + return -1 +endi + +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 +print $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 +print $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 + +if $data30 != 0 then + return -1 +endi + +if $data32 != 0 then + return -1 +endi + +if $data33 != 0 then + return -1 +endi + +if $data34 != ready then + return -1 +endi + +if $data35 != arb then + return -1 +endi + +if $data37 != - then + return -1 +endi + +print ============== step4 +system sh/exec_tarbitrator.sh -s stop + +$x = 0 +step4: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show dnodes +if $rows != 4 then + return -1 +endi + +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 +print $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 +print $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 + +if $data30 != 0 then + return -1 +endi + +if $data32 != 0 then + return -1 +endi + +if $data33 != 0 then + return -1 +endi + +if $data34 != offline then + goto step4 +endi + +if $data35 != arb then + return -1 +endi + +if $data37 != - then + return -1 +endi + +print ============== step5 +system sh/exec_tarbitrator.sh -s start + +$x = 0 +step5: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show dnodes +if $rows != 4 then + return -1 +endi + +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 +print $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 +print $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 + +if $data30 != 0 then + return -1 +endi + +if $data32 != 0 then + return -1 +endi + +if $data33 != 0 then + return -1 +endi + +if $data34 != ready then + goto step5 +endi + +if $data35 != arb then + return -1 +endi + +if $data37 != - then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT diff --git a/tests/script/issue/TD-2713.sim b/tests/script/issue/TD-2713.sim new file mode 100644 index 0000000000000000000000000000000000000000..b66c55b9b95f67eb2478791e8ee45ffd503b12be --- /dev/null +++ b/tests/script/issue/TD-2713.sim @@ -0,0 +1,145 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/cfg.sh -n dnode2 -c wallevel -v 2 +system sh/cfg.sh -n dnode3 -c wallevel -v 2 +system sh/cfg.sh -n dnode4 -c wallevel -v 2 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 3 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c slaveQuery -v 1 +system sh/cfg.sh -n dnode2 -c slaveQuery -v 1 +system sh/cfg.sh -n dnode3 -c slaveQuery -v 1 +system sh/cfg.sh -n dnode4 -c slaveQuery -v 1 + +print ========= step1 +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode $hostname2 +sql create dnode $hostname3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 + +if $data4_1 != ready then + goto step1 +endi +if $data4_2 != ready then + goto step1 +endi +if $data4_3 != ready then + goto step1 +endi + +sql show mnodes +print mnode1 $data2_1 +print mnode1 $data2_2 +print mnode1 $data2_3 +if $data2_1 != master then + goto step1 +endi +if $data2_2 != slave then + goto step1 +endi +if $data2_3 != slave then + goto step1 +endi + +print ========= step2 +sql create database d1 replica 3 +sql create table d1.t1 (ts timestamp, i int) +sql insert into d1.t1 values(now, 1) + +$x = 0 +step2: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show d1.vgroups +print online vgroups: $data03 +if $data03 != 3 then + goto step2 +endi +sleep 1000 + +print ========= step3 +$i = 0 +while $i < 100 + $i = $i + 1 + sql select * from d1.t1 + print d1.t1 rows: $rows + if $rows != 1 then + return -1 + endi +endw + +print ========= step4 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT + +system rm -rf ../../../sim/dnode3/data/vnode/vnode2/tsdb/data/* +system rm -rf ../../../sim/dnode3/data/vnode/vnode2/version.json + +system sh/exec.sh -n dnode1 -s start -x SIGINT +system sh/exec.sh -n dnode2 -s start -x SIGINT +system sh/exec.sh -n dnode3 -s start -x SIGINT + +$x = 0 +step4: + $x = $x + 1 + sleep 1000 + if $x == 30 then + return -1 + endi + +sql show d1.vgroups +print online vgroups: $data03 +if $data03 != 3 then + goto step4 +endi +sleep 1000 + +print ========= step5 +$i = 0 +while $i < 100 + $i = $i + 1 + sql select * from d1.t1 + if $rows != 1 then + return -1 + endi + print d1.t1 rows: $rows +endw + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT diff --git a/tests/script/issue/TD-3300.sim b/tests/script/issue/TD-3300.sim new file mode 100644 index 0000000000000000000000000000000000000000..0745ceb8490567b508397b3e99d4748dc41c8971 --- /dev/null +++ b/tests/script/issue/TD-3300.sim @@ -0,0 +1,556 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sql connect + +print ============== step2: start dnode2/dnode3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 + +$x = 0 +step2: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 + +if $data4_1 != ready then + goto step2 +endi +if $data4_2 != ready then + goto step2 +endi +if $data4_3 != ready then + goto step2 +endi + +sleep 1000 + +print ============== step3 +sql create database db replica 2 +sql use db + +sql create table stb (ts timestamp, c1 int, c2 int) tags(t1 int) +sql create table t1 using stb tags(1) +sql insert into t1 values(1577980800000, 1, 5) +sql insert into t1 values(1577980800001, 2, 4) +sql insert into t1 values(1577980800002, 3, 3) +sql insert into t1 values(1577980800003, 4, 2) +sql insert into t1 values(1577980800004, 5, 1) + +sql show db.vgroups +if $data04 != 3 then + return -1 +endi +if $data06 != 2 then + return -1 +endi +if $data05 != master then + return -1 +endi +if $data07 != slave then + return -1 +endi + +sql select * from t1 +if $rows != 5 then + return -1 +endi + +system sh/exec.sh -n dnode2 -s stop -x SIGKILL +system sh/exec.sh -n dnode3 -s stop -x SIGKILL + +print ============== step4 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start + +$x = 0 +step4: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 + +if $data4_1 != ready then + goto step4 +endi +if $data4_2 != ready then + goto step4 +endi +if $data4_3 != ready then + goto step4 +endi + +sql show db.vgroups +if $data04 != 3 then + goto step4 +endi +if $data06 != 2 then + goto step4 +endi +if $data05 != master then + goto step4 +endi +if $data07 != slave then + goto step4 +endi + +sql create table t2 using stb tags(1) +sql insert into t2 values(1577980800000, 1, 5) +sql insert into t2 values(1577980800001, 2, 4) +sql insert into t2 values(1577980800002, 3, 3) +sql insert into t2 values(1577980800003, 4, 2) +sql insert into t2 values(1577980800004, 5, 1) + +sql select * from t2 +if $rows != 5 then + return -1 +endi + +print ============== step5 +system sh/exec.sh -n dnode3 -s stop -x SIGKILL + +$x = 0 +step5: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 + +if $data4_1 != ready then + goto step5 +endi +if $data4_2 != ready then + goto step5 +endi +if $data4_3 != offline then + goto step5 +endi + +sql select * from t1 +if $rows != 5 then + return -1 +endi +sql select * from t2 +if $rows != 5 then + return -1 +endi + +sql show db.vgroups +if $data04 != 3 then + goto step5 +endi +if $data06 != 2 then + goto step5 +endi +if $data05 != offline then + goto step5 +endi +if $data07 != master then + goto step5 +endi + +print ============== step6 +sql create table t3 using stb tags(1) +sql insert into t3 values(1577980800000, 1, 5) +sql insert into t3 values(1577980800001, 2, 4) +sql insert into t3 values(1577980800002, 3, 3) +sql insert into t3 values(1577980800003, 4, 2) +sql insert into t3 values(1577980800004, 5, 1) +sql insert into t3 values(1577980800010, 11, 5) +sql insert into t3 values(1577980800011, 12, 4) +sql insert into t3 values(1577980800012, 13, 3) +sql insert into t3 values(1577980800013, 14, 2) +sql insert into t3 values(1577980800014, 15, 1) + +sql select * from t1 +if $rows != 5 then + return -1 +endi +sql select * from t2 +if $rows != 5 then + return -1 +endi +sql select * from t3 +if $rows != 10 then + return -1 +endi + +system sh/exec.sh -n dnode3 -s start + +$x = 0 +step6: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 + +if $data4_1 != ready then + goto step6 +endi +if $data4_2 != ready then + goto step6 +endi +if $data4_3 != ready then + goto step6 +endi + +sql show db.vgroups +if $data04 != 3 then + goto step6 +endi +if $data06 != 2 then + goto step6 +endi +if $data05 != slave then + goto step6 +endi +if $data07 != master then + goto step6 +endi + +sql select * from t1 +if $rows != 5 then + return -1 +endi +sql select * from t2 +if $rows != 5 then + return -1 +endi +sql select * from t3 +if $rows != 10 then + return -1 +endi + +print ============== step7 +sql create table t4 using stb tags(1) +sql insert into t4 values(1577980800000, 1, 5) +sql insert into t4 values(1577980800001, 2, 4) +sql insert into t4 values(1577980800002, 3, 3) +sql insert into t4 values(1577980800003, 4, 2) +sql insert into t4 values(1577980800004, 5, 1) +sql insert into t4 values(1577980800010, 11, 5) +sql insert into t4 values(1577980800011, 12, 4) +sql insert into t4 values(1577980800012, 13, 3) +sql insert into t4 values(1577980800013, 14, 2) +sql insert into t4 values(1577980800014, 15, 1) +sql insert into t4 values(1577980800020, 21, 5) +sql insert into t4 values(1577980800021, 22, 4) +sql insert into t4 values(1577980800022, 23, 3) +sql insert into t4 values(1577980800023, 24, 2) +sql insert into t4 values(1577980800024, 25, 1) + +sql select * from t1 +if $rows != 5 then + return -1 +endi +sql select * from t2 +if $rows != 5 then + return -1 +endi +sql select * from t3 +if $rows != 10 then + return -1 +endi +sql select * from t4 +if $rows != 15 then + return -1 +endi + +system sh/exec.sh -n dnode2 -s stop -x SIGKILL +$x = 0 +step7: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 + +if $data4_1 != ready then + goto step7 +endi +if $data4_2 != offline then + goto step7 +endi +if $data4_3 != ready then + goto step7 +endi + +sql show db.vgroups +if $data04 != 3 then + goto step7 +endi +if $data06 != 2 then + goto step7 +endi +if $data05 != master then + goto step7 +endi +if $data07 != offline then + goto step7 +endi + +sql select * from t1 +if $rows != 5 then + return -1 +endi +sql select * from t2 +if $rows != 5 then + return -1 +endi +sql select * from t3 +if $rows != 10 then + return -1 +endi +sql select * from t4 +if $rows != 15 then + return -1 +endi + +print ============== step8 +sql create table t5 using stb tags(1) +sql insert into t5 values(1577980800000, 1, 5) +sql insert into t5 values(1577980800001, 2, 4) +sql insert into t5 values(1577980800002, 3, 3) +sql insert into t5 values(1577980800003, 4, 2) +sql insert into t5 values(1577980800004, 5, 1) +sql insert into t5 values(1577980800010, 11, 5) + +sql select * from t1 +if $rows != 5 then + return -1 +endi +sql select * from t2 +if $rows != 5 then + return -1 +endi +sql select * from t3 +if $rows != 10 then + return -1 +endi +sql select * from t4 +if $rows != 15 then + return -1 +endi +sql select * from t5 +if $rows != 6 then + return -1 +endi + +system sh/exec.sh -n dnode2 -s start +$x = 0 +step8: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 + +if $data4_1 != ready then + goto step8 +endi +if $data4_2 != ready then + goto step8 +endi +if $data4_3 != ready then + goto step8 +endi + +sql show db.vgroups +if $data04 != 3 then + goto step8 +endi +if $data06 != 2 then + goto step8 +endi +if $data05 != master then + goto step8 +endi +if $data07 != slave then + goto step8 +endi + +sql select * from t1 +if $rows != 5 then + return -1 +endi +sql select * from t2 +if $rows != 5 then + return -1 +endi +sql select * from t3 +if $rows != 10 then + return -1 +endi +sql select * from t4 +if $rows != 15 then + return -1 +endi +sql select * from t5 +if $rows != 6 then + return -1 +endi + +print ============== step9 +sql create table t6 using stb tags(1) +sql insert into t6 values(1577980800000, 1, 5) +sql insert into t6 values(1577980800001, 2, 4) +sql insert into t6 values(1577980800002, 3, 3) +sql insert into t6 values(1577980800003, 4, 2) +sql insert into t6 values(1577980800004, 5, 1) +sql insert into t6 values(1577980800010, 11, 5) +sql insert into t6 values(1577980800011, 12, 4) + +sql select * from t1 +if $rows != 5 then + return -1 +endi +sql select * from t2 +if $rows != 5 then + return -1 +endi +sql select * from t3 +if $rows != 10 then + return -1 +endi +sql select * from t4 +if $rows != 15 then + return -1 +endi +sql select * from t5 +if $rows != 6 then + return -1 +endi +sql select * from t6 +if $rows != 7 then + return -1 +endi + +system sh/exec.sh -n dnode3 -s stop -x SIGKILL +$x = 0 +step9: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 + +if $data4_1 != ready then + goto step9 +endi +if $data4_2 != ready then + goto step9 +endi +if $data4_3 != offline then + goto step9 +endi + +print ============== 2 +sql show db.vgroups + +if $data04 != 3 then + goto step7 +endi +if $data06 != 2 then + goto step7 +endi +if $data05 != offline then + goto step7 +endi +if $data07 != master then + goto step7 +endi + +print ============== 3 +sql select * from t1 +if $rows != 5 then + return -1 +endi +sql select * from t2 +if $rows != 5 then + return -1 +endi +sql select * from t3 +if $rows != 10 then + return -1 +endi +sql select * from t4 +if $rows != 15 then + return -1 +endi +sql select * from t5 +if $rows != 6 then + return -1 +endi +sql select * from t6 +if $rows != 7 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop +system sh/exec.sh -n dnode2 -s stop +system sh/exec.sh -n dnode3 -s stop diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt new file mode 100644 index 0000000000000000000000000000000000000000..2709c3cddab543714dd77c91aa116c50d8cba713 --- /dev/null +++ b/tests/script/jenkins/basic.txt @@ -0,0 +1,414 @@ +cd ../../../debug; cmake .. +cd ../../../debug; make + +#======================b1-start=============== + +./test.sh -f general/field/2.sim +./test.sh -f general/field/3.sim +./test.sh -f general/field/4.sim +./test.sh -f general/field/5.sim +./test.sh -f general/field/6.sim +./test.sh -f general/field/bigint.sim +./test.sh -f general/field/binary.sim +./test.sh -f general/field/bool.sim +./test.sh -f general/field/single.sim +./test.sh -f general/field/smallint.sim +./test.sh -f general/field/tinyint.sim + +./test.sh -f general/http/autocreate.sim +./test.sh -f general/http/chunked.sim +./test.sh -f general/http/gzip.sim +./test.sh -f general/http/restful.sim +./test.sh -f general/http/restful_insert.sim +./test.sh -f general/http/restful_limit.sim +./test.sh -f general/http/restful_full.sim +./test.sh -f general/http/prepare.sim +./test.sh -f general/http/telegraf.sim +./test.sh -f general/http/grafana_bug.sim +./test.sh -f general/http/grafana.sim + +./test.sh -f general/insert/basic.sim +./test.sh -f general/insert/insert_drop.sim +./test.sh -f general/insert/query_block1_memory.sim +./test.sh -f general/insert/query_block2_memory.sim +./test.sh -f general/insert/query_block1_file.sim +./test.sh -f general/insert/query_block2_file.sim +./test.sh -f general/insert/query_file_memory.sim +./test.sh -f general/insert/query_multi_file.sim +./test.sh -f general/insert/tcp.sim + +./test.sh -f general/parser/alter.sim +./test.sh -f general/parser/alter1.sim +./test.sh -f general/parser/alter_stable.sim +./test.sh -f general/parser/auto_create_tb.sim +./test.sh -f general/parser/auto_create_tb_drop_tb.sim +./test.sh -f general/parser/col_arithmetic_operation.sim +./test.sh -f general/parser/columnValue.sim +./test.sh -f general/parser/commit.sim +./test.sh -f general/parser/create_db.sim +./test.sh -f general/parser/create_mt.sim +./test.sh -f general/parser/create_tb.sim +./test.sh -f general/parser/dbtbnameValidate.sim +./test.sh -f general/parser/import_commit1.sim +./test.sh -f general/parser/import_commit2.sim +./test.sh -f general/parser/import_commit3.sim +./test.sh -f general/parser/insert_tb.sim +./test.sh -f general/parser/first_last.sim +./test.sh -f general/parser/lastrow.sim +./test.sh -f general/parser/nchar.sim +./test.sh -f general/parser/null_char.sim +./test.sh -f general/parser/single_row_in_tb.sim +./test.sh -f general/parser/select_from_cache_disk.sim +./test.sh -f general/parser/mixed_blocks.sim +./test.sh -f general/parser/selectResNum.sim +./test.sh -f general/parser/limit.sim +./test.sh -f general/parser/limit1.sim +./test.sh -f general/parser/limit1_tblocks100.sim +./test.sh -f general/parser/select_across_vnodes.sim +./test.sh -f general/parser/slimit1.sim +./test.sh -f general/parser/tbnameIn.sim +./test.sh -f general/parser/projection_limit_offset.sim +./test.sh -f general/parser/limit2.sim +./test.sh -f general/parser/fill.sim +./test.sh -f general/parser/fill_stb.sim +./test.sh -f general/parser/where.sim +./test.sh -f general/parser/slimit.sim +./test.sh -f general/parser/select_with_tags.sim +./test.sh -f general/parser/interp.sim +./test.sh -f general/parser/tags_dynamically_specifiy.sim +./test.sh -f general/parser/groupby.sim +./test.sh -f general/parser/set_tag_vals.sim +./test.sh -f general/parser/tags_filter.sim +./test.sh -f general/parser/slimit_alter_tags.sim +./test.sh -f general/parser/join.sim +./test.sh -f general/parser/join_multivnode.sim +./test.sh -f general/parser/binary_escapeCharacter.sim +./test.sh -f general/parser/repeatAlter.sim +./test.sh -f general/parser/union.sim +./test.sh -f general/parser/topbot.sim +./test.sh -f general/db/nosuchfile.sim +./test.sh -f general/parser/function.sim +./test.sh -f unique/cluster/vgroup100.sim + +./test.sh -f unique/http/admin.sim +./test.sh -f unique/http/opentsdb.sim + +./test.sh -f unique/import/replica2.sim +./test.sh -f unique/import/replica3.sim + +./test.sh -f general/alter/cached_schema_after_alter.sim + +#======================b1-end=============== +#======================b2-start=============== + + +./test.sh -f general/wal/sync.sim +./test.sh -f general/wal/kill.sim +./test.sh -f general/wal/maxtables.sim + +./test.sh -f general/user/authority.sim +./test.sh -f general/user/monitor.sim +./test.sh -f general/user/pass_alter.sim +./test.sh -f general/user/pass_len.sim +./test.sh -f general/user/user_create.sim +./test.sh -f general/user/user_len.sim + +./test.sh -f general/vector/metrics_field.sim +./test.sh -f general/vector/metrics_mix.sim +./test.sh -f general/vector/metrics_query.sim +./test.sh -f general/vector/metrics_tag.sim +./test.sh -f general/vector/metrics_time.sim +./test.sh -f general/vector/multi.sim +./test.sh -f general/vector/single.sim +./test.sh -f general/vector/table_field.sim +./test.sh -f general/vector/table_mix.sim +./test.sh -f general/vector/table_query.sim +./test.sh -f general/vector/table_time.sim + +./test.sh -f unique/account/account_create.sim +./test.sh -f unique/account/account_delete.sim +./test.sh -f unique/account/account_len.sim +./test.sh -f unique/account/authority.sim +./test.sh -f unique/account/basic.sim +./test.sh -f unique/account/paras.sim +./test.sh -f unique/account/pass_alter.sim +./test.sh -f unique/account/pass_len.sim +./test.sh -f unique/account/usage.sim +./test.sh -f unique/account/user_create.sim +./test.sh -f unique/account/user_len.sim + +./test.sh -f unique/big/maxvnodes.sim +./test.sh -f unique/big/tcp.sim + +./test.sh -f unique/cluster/alter.sim +./test.sh -f unique/cluster/cache.sim + + +#======================b2-end=============== +#======================b3-start=============== + +./test.sh -f unique/arbitrator/check_cluster_cfg_para.sim +#./test.sh -f unique/arbitrator/dn2_mn1_cache_file_sync.sim +./test.sh -f unique/arbitrator/dn3_mn1_full_createTableFail.sim +./test.sh -f unique/arbitrator/dn3_mn1_multiCreateDropTable.sim +#./test.sh -f unique/arbitrator/dn3_mn1_nw_disable_timeout_autoDropDnode.sim +#./test.sh -f unique/arbitrator/dn3_mn1_replica2_wal1_AddDelDnode.sim +./test.sh -f unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim +./test.sh -f unique/arbitrator/dn3_mn1_replica_change.sim +#./test.sh -f unique/arbitrator/dn3_mn1_stopDnode_timeout.sim +# lower the priority while file corruption +#./test.sh -f unique/arbitrator/dn3_mn1_vnode_change.sim +#./test.sh -f unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim +#./test.sh -f unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim +#./test.sh -f unique/arbitrator/dn3_mn1_vnode_createErrData_online.sim +./test.sh -f unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim +./test.sh -f unique/arbitrator/dn3_mn1_vnode_delDir.sim +./test.sh -f unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim +./test.sh -f unique/arbitrator/dn3_mn1_r3_vnode_delDir.sim +./test.sh -f unique/arbitrator/dn3_mn1_vnode_nomaster.sim +./test.sh -f unique/arbitrator/dn3_mn2_killDnode.sim + +./test.sh -f unique/arbitrator/offline_replica2_alterTable_online.sim +./test.sh -f unique/arbitrator/offline_replica2_alterTag_online.sim +./test.sh -f unique/arbitrator/offline_replica2_createTable_online.sim +./test.sh -f unique/arbitrator/offline_replica2_dropDb_online.sim +./test.sh -f unique/arbitrator/offline_replica2_dropTable_online.sim +./test.sh -f unique/arbitrator/offline_replica3_alterTable_online.sim +./test.sh -f unique/arbitrator/offline_replica3_alterTag_online.sim +./test.sh -f unique/arbitrator/offline_replica3_createTable_online.sim +./test.sh -f unique/arbitrator/offline_replica3_dropDb_online.sim +./test.sh -f unique/arbitrator/offline_replica3_dropTable_online.sim +./test.sh -f unique/arbitrator/replica_changeWithArbitrator.sim +./test.sh -f unique/arbitrator/sync_replica2_alterTable_add.sim +./test.sh -f unique/arbitrator/sync_replica2_alterTable_drop.sim + +./test.sh -f unique/arbitrator/sync_replica2_dropDb.sim +./test.sh -f unique/arbitrator/sync_replica2_dropTable.sim +./test.sh -f unique/arbitrator/sync_replica3_alterTable_add.sim +./test.sh -f unique/arbitrator/sync_replica3_alterTable_drop.sim +./test.sh -f unique/arbitrator/sync_replica3_dropDb.sim +./test.sh -f unique/arbitrator/sync_replica3_dropTable.sim + +./test.sh -f unique/migrate/mn2_vn2_repl2_rmMnodeDir.sim +./test.sh -f unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir.sim +./test.sh -f unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir_stopAll_starAll.sim +./test.sh -f unique/migrate/mn2_vn2_repl2_rmVnodeDir.sim + +./test.sh -f unique/stable/balance_replica1.sim +./test.sh -f unique/stable/dnode2_stop.sim +./test.sh -f unique/stable/dnode2.sim +./test.sh -f unique/stable/dnode3.sim +./test.sh -f unique/stable/replica2_dnode4.sim +./test.sh -f unique/stable/replica2_vnode3.sim +./test.sh -f unique/stable/replica3_dnode6.sim +./test.sh -f unique/stable/replica3_vnode3.sim + +#======================b3-end=============== +#======================b4-start=============== + + +./test.sh -f general/alter/count.sim +./test.sh -f general/alter/dnode.sim +./test.sh -f general/alter/import.sim +./test.sh -f general/alter/insert1.sim +./test.sh -f general/alter/insert2.sim +./test.sh -f general/alter/metrics.sim +./test.sh -f general/alter/table.sim + +./test.sh -f general/cache/new_metrics.sim +./test.sh -f general/cache/restart_metrics.sim +./test.sh -f general/cache/restart_table.sim + +./test.sh -f general/connection/connection.sim + +./test.sh -f general/column/commit.sim +./test.sh -f general/column/metrics.sim +./test.sh -f general/column/table.sim + +./test.sh -f general/compress/commitlog.sim +./test.sh -f general/compress/compress.sim +./test.sh -f general/compress/compress2.sim +./test.sh -f general/compress/uncompress.sim + +./test.sh -f general/stable/disk.sim +./test.sh -f general/stable/dnode3.sim +./test.sh -f general/stable/metrics.sim +./test.sh -f general/stable/refcount.sim +./test.sh -f general/stable/show.sim +./test.sh -f general/stable/values.sim +./test.sh -f general/stable/vnode3.sim + +./test.sh -f unique/column/replica3.sim +./test.sh -f issue/TD-2713.sim +./test.sh -f general/parser/select_distinct_tag.sim +./test.sh -f unique/mnode/mgmt30.sim +./test.sh -f issue/TD-2677.sim +./test.sh -f issue/TD-2680.sim +./test.sh -f unique/dnode/lossdata.sim + +#======================b4-end=============== +#======================b5-start=============== + +./test.sh -f unique/dnode/alternativeRole.sim +./test.sh -f unique/dnode/balance1.sim +./test.sh -f unique/dnode/balance2.sim +./test.sh -f unique/dnode/balance3.sim +./test.sh -f unique/dnode/balancex.sim +./test.sh -f unique/dnode/offline1.sim +./test.sh -f unique/dnode/offline2.sim + +./test.sh -f general/stream/metrics_del.sim +./test.sh -f general/stream/metrics_replica1_vnoden.sim +./test.sh -f general/stream/restart_stream.sim +./test.sh -f general/stream/stream_3.sim +./test.sh -f general/stream/stream_restart.sim +./test.sh -f general/stream/table_del.sim +./test.sh -f general/stream/table_replica1_vnoden.sim + +./test.sh -f general/connection/test_old_data.sim +./test.sh -f unique/dnode/datatrans_3node.sim +./test.sh -f unique/dnode/datatrans_3node_2.sim +./test.sh -f general/db/alter_tables_d2.sim +./test.sh -f general/db/alter_tables_v1.sim +./test.sh -f general/db/alter_tables_v4.sim + +#======================b5-end=============== +#======================b6-start=============== + +./test.sh -f unique/dnode/reason.sim +./test.sh -f unique/dnode/remove1.sim +./test.sh -f unique/dnode/remove2.sim +./test.sh -f unique/dnode/vnode_clean.sim + +./test.sh -f unique/db/commit.sim +./test.sh -f unique/db/delete.sim +./test.sh -f unique/db/delete_part.sim +./test.sh -f unique/db/replica_add12.sim +./test.sh -f unique/db/replica_add13.sim +./test.sh -f unique/db/replica_add23.sim +./test.sh -f unique/db/replica_reduce21.sim +./test.sh -f unique/db/replica_reduce32.sim +./test.sh -f unique/db/replica_reduce31.sim +./test.sh -f unique/db/replica_part.sim + +./test.sh -f unique/vnode/many.sim +./test.sh -f unique/vnode/replica2_basic2.sim +./test.sh -f unique/vnode/replica2_repeat.sim +./test.sh -f unique/vnode/replica3_basic.sim +./test.sh -f unique/vnode/replica3_repeat.sim +./test.sh -f unique/vnode/replica3_vgroup.sim + +./test.sh -f unique/dnode/monitor.sim +./test.sh -f unique/dnode/monitor_bug.sim +./test.sh -f unique/dnode/simple.sim +./test.sh -f unique/dnode/data1.sim +./test.sh -f unique/dnode/m2.sim +./test.sh -f unique/dnode/m3.sim +./test.sh -f unique/dnode/offline3.sim +./test.sh -f general/wal/kill.sim +./test.sh -f general/wal/maxtables.sim + +./test.sh -f general/import/basic.sim +./test.sh -f general/import/commit.sim +./test.sh -f general/import/large.sim +./test.sh -f general/import/replica1.sim +./test.sh -f unique/cluster/balance1.sim +./test.sh -f unique/cluster/balance2.sim +./test.sh -f unique/cluster/balance3.sim + +#======================b6-end=============== +#======================b7-start=============== + +./test.sh -f general/compute/avg.sim +./test.sh -f general/compute/bottom.sim +./test.sh -f general/compute/count.sim +./test.sh -f general/compute/diff.sim +./test.sh -f general/compute/diff2.sim +./test.sh -f general/compute/first.sim +./test.sh -f general/compute/interval.sim +./test.sh -f general/compute/last.sim +./test.sh -f general/compute/leastsquare.sim +./test.sh -f general/compute/max.sim +./test.sh -f general/compute/min.sim +./test.sh -f general/compute/null.sim +./test.sh -f general/compute/percentile.sim +./test.sh -f general/compute/stddev.sim +./test.sh -f general/compute/sum.sim +./test.sh -f general/compute/top.sim + +./test.sh -f general/db/alter_option.sim +./test.sh -f general/db/alter_vgroups.sim +./test.sh -f general/db/basic.sim +./test.sh -f general/db/basic1.sim +./test.sh -f general/db/basic2.sim +./test.sh -f general/db/basic3.sim +./test.sh -f general/db/basic4.sim +./test.sh -f general/db/basic5.sim +./test.sh -f general/db/delete_reuse1.sim +./test.sh -f general/db/delete_reuse2.sim +./test.sh -f general/db/delete_reusevnode.sim +./test.sh -f general/db/delete_reusevnode2.sim +./test.sh -f general/db/delete_writing1.sim +./test.sh -f general/db/delete_writing2.sim +./test.sh -f general/db/delete.sim +./test.sh -f general/db/len.sim +./test.sh -f general/db/repeat.sim +./test.sh -f general/db/tables.sim +./test.sh -f general/db/vnodes.sim +./test.sh -f general/db/topic1.sim +./test.sh -f general/db/topic2.sim +./test.sh -f general/table/autocreate.sim +./test.sh -f general/table/basic1.sim +./test.sh -f general/table/basic2.sim +./test.sh -f general/table/basic3.sim +./test.sh -f general/table/bigint.sim +./test.sh -f general/table/binary.sim +./test.sh -f general/table/bool.sim +./test.sh -f general/table/column_name.sim +./test.sh -f general/table/column_num.sim +./test.sh -f general/table/column_value.sim +./test.sh -f general/table/column2.sim +./test.sh -f general/table/date.sim +./test.sh -f general/table/db.table.sim +./test.sh -f general/table/delete_reuse1.sim +./test.sh -f general/table/delete_reuse2.sim +./test.sh -f general/table/delete_writing.sim +./test.sh -f general/table/describe.sim +./test.sh -f general/table/double.sim +./test.sh -f general/table/float.sim +./test.sh -f general/table/int.sim +./test.sh -f general/table/limit.sim +./test.sh -f general/table/smallint.sim +./test.sh -f general/table/table_len.sim +./test.sh -f general/table/table.sim +./test.sh -f general/table/tinyint.sim +./test.sh -f general/table/vgroup.sim +./test.sh -f general/table/createmulti.sim + +./test.sh -f unique/mnode/mgmt20.sim +./test.sh -f unique/mnode/mgmt21.sim +./test.sh -f unique/mnode/mgmt22.sim +./test.sh -f unique/mnode/mgmt23.sim +./test.sh -f unique/mnode/mgmt24.sim +./test.sh -f unique/mnode/mgmt25.sim +./test.sh -f unique/mnode/mgmt26.sim +./test.sh -f unique/mnode/mgmt33.sim +./test.sh -f unique/mnode/mgmt34.sim +./test.sh -f unique/mnode/mgmtr2.sim + +#./test.sh -f unique/arbitrator/insert_duplicationTs.sim +./test.sh -f general/parser/join_manyblocks.sim +./test.sh -f general/parser/stableOp.sim +./test.sh -f general/parser/timestamp.sim +./test.sh -f general/parser/sliding.sim +./test.sh -f general/parser/having.sim +./test.sh -f general/parser/having_child.sim +./test.sh -f general/parser/between_and.sim +./test.sh -f general/parser/last_cache.sim +./test.sh -f unique/big/balance.sim + +./test.sh -f general/parser/udf.sim +./test.sh -f general/parser/udf_dll.sim +./test.sh -f general/parser/udf_dll_stable.sim + +#======================b7-end=============== diff --git a/tests/script/jenkins/simple.txt b/tests/script/jenkins/simple.txt new file mode 100644 index 0000000000000000000000000000000000000000..88ff4d660131bea5dee2f5ccd0dad9d81c7bed5f --- /dev/null +++ b/tests/script/jenkins/simple.txt @@ -0,0 +1,231 @@ +cd ../../../debug; cmake .. +cd ../../../debug; make + +#./test.sh -f general/alter/cached_schema_after_alter.sim +./test.sh -f general/alter/count.sim +./test.sh -f general/alter/import.sim +#./test.sh -f general/alter/insert1.sim +./test.sh -f general/alter/insert2.sim +./test.sh -f general/alter/metrics.sim +./test.sh -f general/alter/table.sim + +./test.sh -f general/cache/new_metrics.sim +./test.sh -f general/cache/restart_metrics.sim +./test.sh -f general/cache/restart_table.sim + +./test.sh -f general/connection/connection.sim + +./test.sh -f general/column/commit.sim +./test.sh -f general/column/metrics.sim +./test.sh -f general/column/table.sim + +./test.sh -f general/compress/commitlog.sim +./test.sh -f general/compress/compress.sim +./test.sh -f general/compress/compress2.sim +./test.sh -f general/compress/uncompress.sim + +./test.sh -f general/compute/avg.sim +./test.sh -f general/compute/bottom.sim +./test.sh -f general/compute/count.sim +./test.sh -f general/compute/diff.sim +./test.sh -f general/compute/diff2.sim +./test.sh -f general/compute/first.sim +./test.sh -f general/compute/interval.sim +./test.sh -f general/compute/last.sim +./test.sh -f general/compute/leastsquare.sim +./test.sh -f general/compute/max.sim +./test.sh -f general/compute/min.sim +./test.sh -f general/compute/null.sim +./test.sh -f general/compute/percentile.sim +./test.sh -f general/compute/stddev.sim +./test.sh -f general/compute/sum.sim +./test.sh -f general/compute/top.sim + +./test.sh -f general/db/alter_option.sim +./test.sh -f general/db/alter_tables_d2.sim +./test.sh -f general/db/alter_tables_v1.sim +./test.sh -f general/db/alter_tables_v4.sim +./test.sh -f general/db/alter_vgroups.sim +./test.sh -f general/db/basic.sim +./test.sh -f general/db/basic1.sim +./test.sh -f general/db/basic2.sim +./test.sh -f general/db/basic3.sim +./test.sh -f general/db/basic4.sim +./test.sh -f general/db/basic5.sim +./test.sh -f general/db/delete_reuse1.sim +./test.sh -f general/db/delete_reuse2.sim +./test.sh -f general/db/delete_reusevnode.sim +./test.sh -f general/db/delete_reusevnode2.sim +./test.sh -f general/db/delete_writing1.sim +./test.sh -f general/db/delete_writing2.sim +./test.sh -f general/db/delete.sim +./test.sh -f general/db/len.sim +./test.sh -f general/db/repeat.sim +./test.sh -f general/db/tables.sim +./test.sh -f general/db/vnodes.sim + +./test.sh -f general/field/2.sim +./test.sh -f general/field/3.sim +./test.sh -f general/field/4.sim +./test.sh -f general/field/5.sim +./test.sh -f general/field/6.sim +./test.sh -f general/field/bigint.sim +./test.sh -f general/field/binary.sim +./test.sh -f general/field/bool.sim +./test.sh -f general/field/single.sim +./test.sh -f general/field/smallint.sim +./test.sh -f general/field/tinyint.sim + +./test.sh -f general/http/restful.sim +./test.sh -f general/http/restful_insert.sim +./test.sh -f general/http/restful_limit.sim +./test.sh -f general/http/restful_full.sim +./test.sh -f general/http/prepare.sim +./test.sh -f general/http/telegraf.sim +./test.sh -f general/http/grafana_bug.sim +./test.sh -f general/http/grafana.sim + +./test.sh -f general/import/basic.sim +./test.sh -f general/import/commit.sim +./test.sh -f general/import/large.sim +./test.sh -f general/import/replica1.sim + +./test.sh -f general/insert/basic.sim +./test.sh -f general/insert/insert_drop.sim +./test.sh -f general/insert/query_block1_memory.sim +./test.sh -f general/insert/query_block2_memory.sim +./test.sh -f general/insert/query_block1_file.sim +./test.sh -f general/insert/query_block2_file.sim +./test.sh -f general/insert/query_file_memory.sim +./test.sh -f general/insert/query_multi_file.sim +./test.sh -f general/insert/tcp.sim + +./test.sh -f general/parser/alter.sim +./test.sh -f general/parser/alter1.sim +./test.sh -f general/parser/alter_stable.sim +./test.sh -f general/parser/auto_create_tb.sim +./test.sh -f general/parser/auto_create_tb_drop_tb.sim +./test.sh -f general/parser/col_arithmetic_operation.sim +./test.sh -f general/parser/columnValue.sim +./test.sh -f general/parser/commit.sim +./test.sh -f general/parser/create_db.sim +./test.sh -f general/parser/create_mt.sim +./test.sh -f general/parser/create_tb.sim +./test.sh -f general/parser/dbtbnameValidate.sim +./test.sh -f general/parser/import_commit1.sim +./test.sh -f general/parser/import_commit2.sim +./test.sh -f general/parser/import_commit3.sim +./test.sh -f general/parser/insert_tb.sim +./test.sh -f general/parser/first_last.sim +#./test.sh -f general/parser/import_file.sim +./test.sh -f general/parser/lastrow.sim +./test.sh -f general/parser/nchar.sim +./test.sh -f general/parser/null_char.sim +./test.sh -f general/parser/single_row_in_tb.sim +./test.sh -f general/parser/select_from_cache_disk.sim +./test.sh -f general/parser/mixed_blocks.sim +./test.sh -f general/parser/selectResNum.sim +./test.sh -f general/parser/limit.sim +./test.sh -f general/parser/limit1.sim +./test.sh -f general/parser/limit1_tblocks100.sim +./test.sh -f general/parser/select_across_vnodes.sim +./test.sh -f general/parser/slimit1.sim +./test.sh -f general/parser/tbnameIn.sim +./test.sh -f general/parser/projection_limit_offset.sim +./test.sh -f general/parser/limit2.sim +./test.sh -f general/parser/fill.sim +./test.sh -f general/parser/fill_stb.sim +./test.sh -f general/parser/where.sim +./test.sh -f general/parser/slimit.sim +./test.sh -f general/parser/select_with_tags.sim +./test.sh -f general/parser/interp.sim +./test.sh -f general/parser/tags_dynamically_specifiy.sim +./test.sh -f general/parser/groupby.sim +./test.sh -f general/parser/set_tag_vals.sim +#./test.sh -f general/parser/slimit_alter_tags.sim +./test.sh -f general/parser/join.sim +./test.sh -f general/parser/join_multivnode.sim +./test.sh -f general/parser/binary_escapeCharacter.sim +./test.sh -f general/parser/bug.sim +./test.sh -f general/parser/repeatAlter.sim + +./test.sh -f general/stable/disk.sim +./test.sh -f general/stable/dnode3.sim +./test.sh -f general/stable/metrics.sim +./test.sh -f general/stable/refcount.sim +./test.sh -f general/stable/show.sim +./test.sh -f general/stable/values.sim +./test.sh -f general/stable/vnode3.sim + +./test.sh -f general/table/autocreate.sim +./test.sh -f general/table/basic1.sim +./test.sh -f general/table/basic2.sim +./test.sh -f general/table/basic3.sim +./test.sh -f general/table/bigint.sim +./test.sh -f general/table/binary.sim +./test.sh -f general/table/bool.sim +./test.sh -f general/table/column_name.sim +./test.sh -f general/table/column_num.sim +./test.sh -f general/table/column_value.sim +./test.sh -f general/table/column2.sim +./test.sh -f general/table/date.sim +./test.sh -f general/table/db.table.sim +./test.sh -f general/table/delete_reuse1.sim +./test.sh -f general/table/delete_reuse2.sim +./test.sh -f general/table/delete_writing.sim +./test.sh -f general/table/describe.sim +./test.sh -f general/table/double.sim +./test.sh -f general/table/fill.sim +./test.sh -f general/table/float.sim +./test.sh -f general/table/int.sim +./test.sh -f general/table/limit.sim +./test.sh -f general/table/smallint.sim +./test.sh -f general/table/table_len.sim +./test.sh -f general/table/table.sim +./test.sh -f general/table/tinyint.sim +./test.sh -f general/table/vgroup.sim + +./test.sh -f general/tag/3.sim +./test.sh -f general/tag/4.sim +./test.sh -f general/tag/5.sim +./test.sh -f general/tag/6.sim +./test.sh -f general/tag/add.sim +./test.sh -f general/tag/bigint.sim +./test.sh -f general/tag/binary_binary.sim +./test.sh -f general/tag/binary.sim +./test.sh -f general/tag/bool_binary.sim +./test.sh -f general/tag/bool_int.sim +./test.sh -f general/tag/bool.sim +./test.sh -f general/tag/change.sim +./test.sh -f general/tag/column.sim +#./test.sh -f general/tag/commit.sim +./test.sh -f general/tag/create.sim +./test.sh -f general/tag/delete.sim +./test.sh -f general/tag/double.sim +./test.sh -f general/tag/filter.sim +./test.sh -f general/tag/float.sim +./test.sh -f general/tag/int_binary.sim +./test.sh -f general/tag/int_float.sim +./test.sh -f general/tag/int.sim +./test.sh -f general/tag/set.sim +./test.sh -f general/tag/smallint.sim +./test.sh -f general/tag/tinyint.sim + +./test.sh -f general/user/authority.sim +./test.sh -f general/user/monitor.sim +./test.sh -f general/user/pass_alter.sim +./test.sh -f general/user/pass_len.sim +./test.sh -f general/user/user_create.sim +./test.sh -f general/user/user_len.sim + +./test.sh -f general/vector/metrics_field.sim +./test.sh -f general/vector/metrics_mix.sim +./test.sh -f general/vector/metrics_query.sim +./test.sh -f general/vector/metrics_tag.sim +./test.sh -f general/vector/metrics_time.sim +./test.sh -f general/vector/multi.sim +./test.sh -f general/vector/single.sim +./test.sh -f general/vector/table_field.sim +./test.sh -f general/vector/table_mix.sim +./test.sh -f general/vector/table_query.sim +./test.sh -f general/vector/table_time.sim diff --git a/tests/script/jenkins/unique.txt b/tests/script/jenkins/unique.txt new file mode 100644 index 0000000000000000000000000000000000000000..372bdc9d9d55635de6f36a0629b2f9c2aca5df07 --- /dev/null +++ b/tests/script/jenkins/unique.txt @@ -0,0 +1,127 @@ +cd ../../../debug; cmake .. +cd ../../../debug; make + +./test.sh -f unique/big/balance.sim +./test.sh -f unique/big/maxvnodes.sim +./test.sh -f unique/big/tcp.sim + +./test.sh -f unique/cluster/alter.sim +./test.sh -f unique/cluster/balance1.sim +./test.sh -f unique/cluster/balance2.sim +./test.sh -f unique/cluster/balance3.sim +./test.sh -f unique/cluster/cache.sim +./test.sh -f unique/cluster/vgroup100.sim + +./test.sh -f unique/column/replica3.sim + +./test.sh -f unique/db/commit.sim +./test.sh -f unique/db/delete.sim +./test.sh -f unique/db/delete_part.sim +./test.sh -f unique/db/replica_add12.sim +./test.sh -f unique/db/replica_add13.sim +./test.sh -f unique/db/replica_add23.sim +./test.sh -f unique/db/replica_reduce21.sim +./test.sh -f unique/db/replica_reduce32.sim +./test.sh -f unique/db/replica_reduce31.sim +./test.sh -f unique/db/replica_part.sim + +./test.sh -f unique/dnode/alternativeRole.sim +./test.sh -f unique/dnode/monitor.sim +./test.sh -f unique/dnode/monitor_bug.sim +./test.sh -f unique/dnode/simple.sim +./test.sh -f unique/dnode/balance1.sim +./test.sh -f unique/dnode/balance2.sim +./test.sh -f unique/dnode/balance3.sim +./test.sh -f unique/dnode/balancex.sim +./test.sh -f unique/dnode/data1.sim +./test.sh -f unique/dnode/m2.sim +./test.sh -f unique/dnode/m3.sim +./test.sh -f unique/dnode/lossdata.sim +./test.sh -f unique/dnode/offline1.sim +./test.sh -f unique/dnode/offline2.sim +./test.sh -f unique/dnode/offline3.sim +./test.sh -f unique/dnode/reason.sim +./test.sh -f unique/dnode/remove1.sim +./test.sh -f unique/dnode/remove2.sim +./test.sh -f unique/dnode/vnode_clean.sim + +./test.sh -f unique/http/admin.sim +./test.sh -f unique/http/opentsdb.sim + +./test.sh -f unique/import/replica2.sim +./test.sh -f unique/import/replica3.sim + +./test.sh -f unique/stable/balance_replica1.sim +./test.sh -f unique/stable/dnode2_stop.sim +./test.sh -f unique/stable/dnode2.sim +./test.sh -f unique/stable/dnode3.sim +./test.sh -f unique/stable/replica2_dnode4.sim +./test.sh -f unique/stable/replica2_vnode3.sim +./test.sh -f unique/stable/replica3_dnode6.sim +./test.sh -f unique/stable/replica3_vnode3.sim + +./test.sh -f unique/mnode/mgmt20.sim +./test.sh -f unique/mnode/mgmt21.sim +./test.sh -f unique/mnode/mgmt22.sim +./test.sh -f unique/mnode/mgmt23.sim +./test.sh -f unique/mnode/mgmt24.sim +./test.sh -f unique/mnode/mgmt25.sim +./test.sh -f unique/mnode/mgmt26.sim +./test.sh -f unique/mnode/mgmt30.sim +./test.sh -f unique/mnode/mgmt33.sim +./test.sh -f unique/mnode/mgmt34.sim +./test.sh -f unique/mnode/mgmtr2.sim + +./test.sh -f unique/vnode/many.sim +./test.sh -f unique/vnode/replica2_basic2.sim +./test.sh -f unique/vnode/replica2_repeat.sim +./test.sh -f unique/vnode/replica3_basic.sim +./test.sh -f unique/vnode/replica3_repeat.sim +./test.sh -f unique/vnode/replica3_vgroup.sim + +./test.sh -f unique/arbitrator/check_cluster_cfg_para.sim +#./test.sh -f unique/arbitrator/dn2_mn1_cache_file_sync.sim +./test.sh -f unique/arbitrator/dn3_mn1_full_createTableFail.sim +./test.sh -f unique/arbitrator/dn3_mn1_multiCreateDropTable.sim +#./test.sh -f unique/arbitrator/dn3_mn1_nw_disable_timeout_autoDropDnode.sim +#./test.sh -f unique/arbitrator/dn3_mn1_replica2_wal1_AddDelDnode.sim +./test.sh -f unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim +./test.sh -f unique/arbitrator/dn3_mn1_replica_change.sim +#./test.sh -f unique/arbitrator/dn3_mn1_stopDnode_timeout.sim +# lower the priority while file corruption +#./test.sh -f unique/arbitrator/dn3_mn1_vnode_change.sim +#./test.sh -f unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim +#./test.sh -f unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim +#./test.sh -f unique/arbitrator/dn3_mn1_vnode_createErrData_online.sim +./test.sh -f unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim +./test.sh -f unique/arbitrator/dn3_mn1_vnode_delDir.sim +./test.sh -f unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim +./test.sh -f unique/arbitrator/dn3_mn1_r3_vnode_delDir.sim +./test.sh -f unique/arbitrator/dn3_mn1_vnode_nomaster.sim +./test.sh -f unique/arbitrator/dn3_mn2_killDnode.sim +./test.sh -f unique/arbitrator/insert_duplicationTs.sim +./test.sh -f unique/arbitrator/offline_replica2_alterTable_online.sim +./test.sh -f unique/arbitrator/offline_replica2_alterTag_online.sim +./test.sh -f unique/arbitrator/offline_replica2_createTable_online.sim +./test.sh -f unique/arbitrator/offline_replica2_dropDb_online.sim +./test.sh -f unique/arbitrator/offline_replica2_dropTable_online.sim +./test.sh -f unique/arbitrator/offline_replica3_alterTable_online.sim +./test.sh -f unique/arbitrator/offline_replica3_alterTag_online.sim +./test.sh -f unique/arbitrator/offline_replica3_createTable_online.sim +./test.sh -f unique/arbitrator/offline_replica3_dropDb_online.sim +./test.sh -f unique/arbitrator/offline_replica3_dropTable_online.sim +./test.sh -f unique/arbitrator/replica_changeWithArbitrator.sim +./test.sh -f unique/arbitrator/sync_replica2_alterTable_add.sim +./test.sh -f unique/arbitrator/sync_replica2_alterTable_drop.sim + +./test.sh -f unique/arbitrator/sync_replica2_dropDb.sim +./test.sh -f unique/arbitrator/sync_replica2_dropTable.sim +./test.sh -f unique/arbitrator/sync_replica3_alterTable_add.sim +./test.sh -f unique/arbitrator/sync_replica3_alterTable_drop.sim +./test.sh -f unique/arbitrator/sync_replica3_dropDb.sim +./test.sh -f unique/arbitrator/sync_replica3_dropTable.sim + +./test.sh -f unique/migrate/mn2_vn2_repl2_rmMnodeDir.sim +./test.sh -f unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir.sim +./test.sh -f unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir_stopAll_starAll.sim +./test.sh -f unique/migrate/mn2_vn2_repl2_rmVnodeDir.sim diff --git a/tests/script/jenkins/wbasic.txt b/tests/script/jenkins/wbasic.txt new file mode 100644 index 0000000000000000000000000000000000000000..984b15fc5a4e49a5e730667782b41afb8bdb6bb8 --- /dev/null +++ b/tests/script/jenkins/wbasic.txt @@ -0,0 +1,393 @@ +wtest.bat -f issue/TD-2677.sim +wtest.bat -f issue/TD-2680.sim +wtest.bat -f issue/TD-2713.sim + +wtest.bat -f general/alter/cached_schema_after_alter.sim +wtest.bat -f general/alter/count.sim +wtest.bat -f general/alter/dnode.sim +wtest.bat -f general/alter/import.sim +wtest.bat -f general/alter/insert1.sim +wtest.bat -f general/alter/insert2.sim +wtest.bat -f general/alter/metrics.sim +wtest.bat -f general/alter/table.sim + +wtest.bat -f general/cache/new_metrics.sim +wtest.bat -f general/cache/restart_metrics.sim +wtest.bat -f general/cache/restart_table.sim + +wtest.bat -f general/connection/connection.sim + +wtest.bat -f general/column/commit.sim +wtest.bat -f general/column/metrics.sim +wtest.bat -f general/column/table.sim + +wtest.bat -f general/compress/commitlog.sim +wtest.bat -f general/compress/compress.sim +wtest.bat -f general/compress/compress2.sim +wtest.bat -f general/compress/uncompress.sim + +wtest.bat -f general/compute/avg.sim +wtest.bat -f general/compute/bottom.sim +wtest.bat -f general/compute/count.sim +wtest.bat -f general/compute/diff.sim +wtest.bat -f general/compute/diff2.sim +wtest.bat -f general/compute/first.sim +wtest.bat -f general/compute/interval.sim +wtest.bat -f general/compute/last.sim +wtest.bat -f general/compute/leastsquare.sim +wtest.bat -f general/compute/max.sim +wtest.bat -f general/compute/min.sim +wtest.bat -f general/compute/null.sim +wtest.bat -f general/compute/percentile.sim +wtest.bat -f general/compute/stddev.sim +wtest.bat -f general/compute/sum.sim +wtest.bat -f general/compute/top.sim + +wtest.bat -f general/db/alter_option.sim +wtest.bat -f general/db/alter_tables_d2.sim +wtest.bat -f general/db/alter_tables_v1.sim +wtest.bat -f general/db/alter_tables_v4.sim +wtest.bat -f general/db/alter_vgroups.sim +wtest.bat -f general/db/basic.sim +wtest.bat -f general/db/basic1.sim +wtest.bat -f general/db/basic2.sim +wtest.bat -f general/db/basic3.sim +wtest.bat -f general/db/basic4.sim +wtest.bat -f general/db/basic5.sim +wtest.bat -f general/db/delete_reuse1.sim +wtest.bat -f general/db/delete_reuse2.sim +wtest.bat -f general/db/delete_reusevnode.sim +wtest.bat -f general/db/delete_reusevnode2.sim +wtest.bat -f general/db/delete_writing1.sim +wtest.bat -f general/db/delete_writing2.sim +wtest.bat -f general/db/delete.sim +wtest.bat -f general/db/len.sim +wtest.bat -f general/db/repeat.sim +wtest.bat -f general/db/tables.sim +wtest.bat -f general/db/vnodes.sim +wtest.bat -f general/db/nosuchfile.sim + +wtest.bat -f general/field/2.sim +wtest.bat -f general/field/3.sim +wtest.bat -f general/field/4.sim +wtest.bat -f general/field/5.sim +wtest.bat -f general/field/6.sim +wtest.bat -f general/field/bigint.sim +wtest.bat -f general/field/binary.sim +wtest.bat -f general/field/bool.sim +wtest.bat -f general/field/single.sim +wtest.bat -f general/field/smallint.sim +wtest.bat -f general/field/tinyint.sim + +wtest.bat -f general/http/autocreate.sim +wtest.bat -f general/http/chunked.sim +wtest.bat -f general/http/gzip.sim +wtest.bat -f general/http/restful.sim +wtest.bat -f general/http/restful_insert.sim +wtest.bat -f general/http/restful_limit.sim +wtest.bat -f general/http/restful_full.sim +wtest.bat -f general/http/prepare.sim +wtest.bat -f general/http/telegraf.sim +wtest.bat -f general/http/grafana_bug.sim +wtest.bat -f general/http/grafana.sim + +wtest.bat -f general/import/basic.sim +wtest.bat -f general/import/commit.sim +wtest.bat -f general/import/large.sim +wtest.bat -f general/import/replica1.sim + +wtest.bat -f general/insert/basic.sim +wtest.bat -f general/insert/insert_drop.sim +wtest.bat -f general/insert/query_block1_memory.sim +wtest.bat -f general/insert/query_block2_memory.sim +wtest.bat -f general/insert/query_block1_file.sim +wtest.bat -f general/insert/query_block2_file.sim +wtest.bat -f general/insert/query_file_memory.sim +wtest.bat -f general/insert/query_multi_file.sim +wtest.bat -f general/insert/tcp.sim + +wtest.bat -f general/parser/alter.sim +wtest.bat -f general/parser/alter1.sim +wtest.bat -f general/parser/alter_stable.sim +wtest.bat -f general/parser/auto_create_tb.sim +wtest.bat -f general/parser/auto_create_tb_drop_tb.sim +wtest.bat -f general/parser/col_arithmetic_operation.sim +wtest.bat -f general/parser/columnValue.sim +wtest.bat -f general/parser/commit.sim +wtest.bat -f general/parser/create_db.sim +wtest.bat -f general/parser/create_mt.sim +wtest.bat -f general/parser/create_tb.sim +wtest.bat -f general/parser/dbtbnameValidate.sim +wtest.bat -f general/parser/import_commit1.sim +wtest.bat -f general/parser/import_commit2.sim +wtest.bat -f general/parser/import_commit3.sim +wtest.bat -f general/parser/insert_tb.sim +wtest.bat -f general/parser/first_last.sim +wtest.bat -f general/parser/lastrow.sim +wtest.bat -f general/parser/nchar.sim +wtest.bat -f general/parser/null_char.sim +wtest.bat -f general/parser/single_row_in_tb.sim +wtest.bat -f general/parser/select_from_cache_disk.sim +wtest.bat -f general/parser/mixed_blocks.sim +wtest.bat -f general/parser/selectResNum.sim +wtest.bat -f general/parser/limit.sim +wtest.bat -f general/parser/limit1.sim +wtest.bat -f general/parser/limit1_tblocks100.sim +wtest.bat -f general/parser/select_across_vnodes.sim +wtest.bat -f general/parser/slimit1.sim +wtest.bat -f general/parser/tbnameIn.sim +wtest.bat -f general/parser/projection_limit_offset.sim +wtest.bat -f general/parser/limit2.sim +wtest.bat -f general/parser/fill.sim +wtest.bat -f general/parser/fill_stb.sim +wtest.bat -f general/parser/where.sim +wtest.bat -f general/parser/slimit.sim +wtest.bat -f general/parser/select_with_tags.sim +wtest.bat -f general/parser/interp.sim +wtest.bat -f general/parser/tags_dynamically_specifiy.sim +wtest.bat -f general/parser/groupby.sim +wtest.bat -f general/parser/set_tag_vals.sim +wtest.bat -f general/parser/tags_filter.sim +wtest.bat -f general/parser/slimit_alter_tags.sim +wtest.bat -f general/parser/join.sim +wtest.bat -f general/parser/join_multivnode.sim +wtest.bat -f general/parser/binary_escapeCharacter.sim +wtest.bat -f general/parser/repeatAlter.sim +wtest.bat -f general/parser/union.sim +wtest.bat -f general/parser/topbot.sim +wtest.bat -f general/parser/function.sim + +wtest.bat -f general/stable/disk.sim +wtest.bat -f general/stable/dnode3.sim +wtest.bat -f general/stable/metrics.sim +wtest.bat -f general/stable/refcount.sim +wtest.bat -f general/stable/show.sim +wtest.bat -f general/stable/values.sim +wtest.bat -f general/stable/vnode3.sim + +wtest.bat -f general/table/autocreate.sim +wtest.bat -f general/table/basic1.sim +wtest.bat -f general/table/basic2.sim +wtest.bat -f general/table/basic3.sim +wtest.bat -f general/table/bigint.sim +wtest.bat -f general/table/binary.sim +wtest.bat -f general/table/bool.sim +wtest.bat -f general/table/column_name.sim +wtest.bat -f general/table/column_num.sim +wtest.bat -f general/table/column_value.sim +wtest.bat -f general/table/column2.sim +wtest.bat -f general/table/date.sim +wtest.bat -f general/table/db.table.sim +wtest.bat -f general/table/delete_reuse1.sim +wtest.bat -f general/table/delete_reuse2.sim +wtest.bat -f general/table/delete_writing.sim +wtest.bat -f general/table/describe.sim +wtest.bat -f general/table/double.sim +wtest.bat -f general/table/fill.sim +wtest.bat -f general/table/float.sim +wtest.bat -f general/table/int.sim +wtest.bat -f general/table/limit.sim +wtest.bat -f general/table/smallint.sim +wtest.bat -f general/table/table_len.sim +wtest.bat -f general/table/table.sim +wtest.bat -f general/table/tinyint.sim +wtest.bat -f general/table/vgroup.sim + +wtest.bat -f general/tag/3.sim +wtest.bat -f general/tag/4.sim +wtest.bat -f general/tag/5.sim +wtest.bat -f general/tag/6.sim +wtest.bat -f general/tag/add.sim +wtest.bat -f general/tag/bigint.sim +wtest.bat -f general/tag/binary_binary.sim +wtest.bat -f general/tag/binary.sim +wtest.bat -f general/tag/bool_binary.sim +wtest.bat -f general/tag/bool_int.sim +wtest.bat -f general/tag/bool.sim +wtest.bat -f general/tag/change.sim +wtest.bat -f general/tag/column.sim +wtest.bat -f general/tag/commit.sim +wtest.bat -f general/tag/create.sim +wtest.bat -f general/tag/delete.sim +wtest.bat -f general/tag/double.sim +wtest.bat -f general/tag/filter.sim +wtest.bat -f general/tag/float.sim +wtest.bat -f general/tag/int_binary.sim +wtest.bat -f general/tag/int_float.sim +wtest.bat -f general/tag/int.sim +wtest.bat -f general/tag/set.sim +wtest.bat -f general/tag/smallint.sim +wtest.bat -f general/tag/tinyint.sim + +wtest.bat -f general/user/authority.sim +wtest.bat -f general/user/monitor.sim +wtest.bat -f general/user/pass_alter.sim +wtest.bat -f general/user/pass_len.sim +wtest.bat -f general/user/user_create.sim +wtest.bat -f general/user/user_len.sim + +wtest.bat -f general/vector/metrics_field.sim +wtest.bat -f general/vector/metrics_mix.sim +wtest.bat -f general/vector/metrics_query.sim +wtest.bat -f general/vector/metrics_tag.sim +wtest.bat -f general/vector/metrics_time.sim +wtest.bat -f general/vector/multi.sim +wtest.bat -f general/vector/single.sim +wtest.bat -f general/vector/table_field.sim +wtest.bat -f general/vector/table_mix.sim +wtest.bat -f general/vector/table_query.sim +wtest.bat -f general/vector/table_time.sim + +wtest.bat -f general/wal/sync.sim +wtest.bat -f general/wal/kill.sim +wtest.bat -f general/wal/maxtables.sim + +wtest.bat -f unique/account/account_create.sim +wtest.bat -f unique/account/account_delete.sim +wtest.bat -f unique/account/account_len.sim +wtest.bat -f unique/account/authority.sim +wtest.bat -f unique/account/basic.sim +wtest.bat -f unique/account/paras.sim +wtest.bat -f unique/account/pass_alter.sim +wtest.bat -f unique/account/pass_len.sim +wtest.bat -f unique/account/usage.sim +wtest.bat -f unique/account/user_create.sim +wtest.bat -f unique/account/user_len.sim + +wtest.bat -f unique/big/balance.sim +wtest.bat -f unique/big/maxvnodes.sim +wtest.bat -f unique/big/tcp.sim + +wtest.bat -f unique/cluster/alter.sim +wtest.bat -f unique/cluster/balance1.sim +wtest.bat -f unique/cluster/balance2.sim +wtest.bat -f unique/cluster/balance3.sim +wtest.bat -f unique/cluster/cache.sim +wtest.bat -f unique/cluster/vgroup100.sim + +wtest.bat -f unique/column/replica3.sim + +wtest.bat -f unique/db/commit.sim +wtest.bat -f unique/db/delete.sim +wtest.bat -f unique/db/delete_part.sim +wtest.bat -f unique/db/replica_add12.sim +wtest.bat -f unique/db/replica_add13.sim +wtest.bat -f unique/db/replica_add23.sim +wtest.bat -f unique/db/replica_reduce21.sim +wtest.bat -f unique/db/replica_reduce32.sim +wtest.bat -f unique/db/replica_reduce31.sim +wtest.bat -f unique/db/replica_part.sim + +wtest.bat -f unique/dnode/alternativeRole.sim +wtest.bat -f unique/dnode/monitor.sim +wtest.bat -f unique/dnode/monitor_bug.sim +wtest.bat -f unique/dnode/simple.sim +wtest.bat -f unique/dnode/balance1.sim +wtest.bat -f unique/dnode/balance2.sim +wtest.bat -f unique/dnode/balance3.sim +wtest.bat -f unique/dnode/balancex.sim +wtest.bat -f unique/dnode/data1.sim +wtest.bat -f unique/dnode/m2.sim +wtest.bat -f unique/dnode/m3.sim +wtest.bat -f unique/dnode/lossdata.sim +wtest.bat -f unique/dnode/offline1.sim +wtest.bat -f unique/dnode/offline2.sim +wtest.bat -f unique/dnode/offline3.sim +wtest.bat -f unique/dnode/reason.sim +wtest.bat -f unique/dnode/remove1.sim +wtest.bat -f unique/dnode/remove2.sim +wtest.bat -f unique/dnode/vnode_clean.sim + +wtest.bat -f unique/http/admin.sim +wtest.bat -f unique/http/opentsdb.sim + +wtest.bat -f unique/import/replica2.sim +wtest.bat -f unique/import/replica3.sim + +wtest.bat -f unique/stable/balance_replica1.sim +wtest.bat -f unique/stable/dnode2_stop.sim +wtest.bat -f unique/stable/dnode2.sim +wtest.bat -f unique/stable/dnode3.sim +wtest.bat -f unique/stable/replica2_dnode4.sim +wtest.bat -f unique/stable/replica2_vnode3.sim +wtest.bat -f unique/stable/replica3_dnode6.sim +wtest.bat -f unique/stable/replica3_vnode3.sim + +wtest.bat -f unique/mnode/mgmt20.sim +wtest.bat -f unique/mnode/mgmt21.sim +wtest.bat -f unique/mnode/mgmt22.sim +wtest.bat -f unique/mnode/mgmt23.sim +wtest.bat -f unique/mnode/mgmt24.sim +wtest.bat -f unique/mnode/mgmt25.sim +wtest.bat -f unique/mnode/mgmt26.sim +wtest.bat -f unique/mnode/mgmt30.sim +wtest.bat -f unique/mnode/mgmt33.sim +wtest.bat -f unique/mnode/mgmt34.sim +wtest.bat -f unique/mnode/mgmtr2.sim + +wtest.bat -f unique/vnode/many.sim +wtest.bat -f unique/vnode/replica2_basic2.sim +wtest.bat -f unique/vnode/replica2_repeat.sim +wtest.bat -f unique/vnode/replica3_basic.sim +wtest.bat -f unique/vnode/replica3_repeat.sim +wtest.bat -f unique/vnode/replica3_vgroup.sim + +wtest.bat -f general/stream/metrics_del.sim +wtest.bat -f general/stream/metrics_replica1_vnoden.sim +wtest.bat -f general/stream/restart_stream.sim +wtest.bat -f general/stream/stream_3.sim +wtest.bat -f general/stream/stream_restart.sim +wtest.bat -f general/stream/table_del.sim +wtest.bat -f general/stream/table_replica1_vnoden.sim + +wtest.bat -f unique/arbitrator/check_cluster_cfg_para.sim +#wtest.bat -f unique/arbitrator/dn2_mn1_cache_file_sync.sim +wtest.bat -f unique/arbitrator/dn3_mn1_full_createTableFail.sim +wtest.bat -f unique/arbitrator/dn3_mn1_multiCreateDropTable.sim +#wtest.bat -f unique/arbitrator/dn3_mn1_nw_disable_timeout_autoDropDnode.sim +#wtest.bat -f unique/arbitrator/dn3_mn1_replica2_wal1_AddDelDnode.sim +wtest.bat -f unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim +wtest.bat -f unique/arbitrator/dn3_mn1_replica_change.sim +#wtest.bat -f unique/arbitrator/dn3_mn1_stopDnode_timeout.sim +# lower the priority while file corruption +#wtest.bat -f unique/arbitrator/dn3_mn1_vnode_change.sim +#wtest.bat -f unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim +#wtest.bat -f unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim +#wtest.bat -f unique/arbitrator/dn3_mn1_vnode_createErrData_online.sim +wtest.bat -f unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim +wtest.bat -f unique/arbitrator/dn3_mn1_vnode_delDir.sim +wtest.bat -f unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim +wtest.bat -f unique/arbitrator/dn3_mn1_r3_vnode_delDir.sim +wtest.bat -f unique/arbitrator/dn3_mn1_vnode_nomaster.sim +wtest.bat -f unique/arbitrator/dn3_mn2_killDnode.sim +wtest.bat -f unique/arbitrator/insert_duplicationTs.sim +wtest.bat -f unique/arbitrator/offline_replica2_alterTable_online.sim +wtest.bat -f unique/arbitrator/offline_replica2_alterTag_online.sim +wtest.bat -f unique/arbitrator/offline_replica2_createTable_online.sim +wtest.bat -f unique/arbitrator/offline_replica2_dropDb_online.sim +wtest.bat -f unique/arbitrator/offline_replica2_dropTable_online.sim +wtest.bat -f unique/arbitrator/offline_replica3_alterTable_online.sim +wtest.bat -f unique/arbitrator/offline_replica3_alterTag_online.sim +wtest.bat -f unique/arbitrator/offline_replica3_createTable_online.sim +wtest.bat -f unique/arbitrator/offline_replica3_dropDb_online.sim +wtest.bat -f unique/arbitrator/offline_replica3_dropTable_online.sim +wtest.bat -f unique/arbitrator/replica_changeWithArbitrator.sim +wtest.bat -f unique/arbitrator/sync_replica2_alterTable_add.sim +wtest.bat -f unique/arbitrator/sync_replica2_alterTable_drop.sim + +wtest.bat -f unique/arbitrator/sync_replica2_dropDb.sim +wtest.bat -f unique/arbitrator/sync_replica2_dropTable.sim +wtest.bat -f unique/arbitrator/sync_replica3_alterTable_add.sim +wtest.bat -f unique/arbitrator/sync_replica3_alterTable_drop.sim +wtest.bat -f unique/arbitrator/sync_replica3_dropDb.sim +wtest.bat -f unique/arbitrator/sync_replica3_dropTable.sim + +wtest.bat -f unique/migrate/mn2_vn2_repl2_rmMnodeDir.sim +wtest.bat -f unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir.sim +wtest.bat -f unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir_stopAll_starAll.sim +wtest.bat -f unique/migrate/mn2_vn2_repl2_rmVnodeDir.sim + +wtest.bat -f general/connection/test_old_data.sim +wtest.bat -f unique/dnode/datatrans_3node.sim +wtest.bat -f unique/dnode/datatrans_3node_2.sim + diff --git a/tests/script/loop.sh b/tests/script/loop.sh new file mode 100755 index 0000000000000000000000000000000000000000..b435eef12306fc994dd4878b8225946f179adf7e --- /dev/null +++ b/tests/script/loop.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +################################################## +# +# Do simulation test +# +################################################## + +set -e +#set -x + +CMD_NAME= +LOOP_TIMES=5 +SLEEP_TIME=0 + +while getopts "f:t:s:" arg +do + case $arg in + f) + CMD_NAME=$OPTARG + ;; + t) + LOOP_TIMES=$OPTARG + ;; + s) + SLEEP_TIME=$OPTARG + ;; + ?) + echo "unknow argument" + ;; + esac +done + +echo LOOP_TIMES ${LOOP_TIMES} +echo CMD_NAME ${CMD_NAME} +echo SLEEP_TIME ${SLEEP_TIME} + +GREEN='\033[1;32m' +GREEN_DARK='\033[0;32m' +GREEN_UNDERLINE='\033[4;32m' +NC='\033[0m' + +for ((i=0; i<$LOOP_TIMES; i++ )) +do + echo -e $GREEN loop $i $NC + echo -e $GREEN cmd $CMD_NAME $NC + $CMD_NAME + sleep ${SLEEP_TIME} +done diff --git a/tests/script/regressionSuite.sim b/tests/script/regressionSuite.sim new file mode 100644 index 0000000000000000000000000000000000000000..bada2f655202ddc34ce6e67e718336a2afc41d50 --- /dev/null +++ b/tests/script/regressionSuite.sim @@ -0,0 +1,221 @@ +##unsupport run general/alter/cached_schema_after_alter.sim +run general/alter/count.sim +run general/alter/import.sim +##unsupport run general/alter/insert1.sim +run general/alter/insert2.sim +run general/alter/metrics.sim +run general/alter/table.sim +run general/cache/new_metrics.sim +run general/cache/restart_metrics.sim +run general/cache/restart_table.sim +run general/connection/connection.sim +run general/column/commit.sim +run general/column/metrics.sim +run general/column/table.sim +run general/compress/commitlog.sim +run general/compress/compress.sim +run general/compress/compress2.sim +run general/compress/uncompress.sim +run general/compute/avg.sim +run general/compute/bottom.sim +run general/compute/count.sim +run general/compute/diff.sim +run general/compute/diff2.sim +run general/compute/first.sim +run general/compute/interval.sim +run general/compute/last.sim +run general/compute/leastsquare.sim +run general/compute/max.sim +run general/compute/min.sim +run general/compute/null.sim +run general/compute/percentile.sim +run general/compute/stddev.sim +run general/compute/sum.sim +run general/compute/top.sim +run general/compute/block_dist.sim +run general/db/alter_option.sim +run general/db/alter_tables_d2.sim +run general/db/alter_tables_v1.sim +run general/db/alter_tables_v4.sim +run general/db/alter_vgroups.sim +run general/db/basic.sim +run general/db/basic1.sim +run general/db/basic2.sim +run general/db/basic3.sim +run general/db/basic4.sim +run general/db/basic5.sim +run general/db/delete_reuse1.sim +run general/db/delete_reuse2.sim +run general/db/delete_reusevnode.sim +run general/db/delete_reusevnode2.sim +run general/db/delete_writing1.sim +run general/db/delete_writing2.sim +run general/db/delete.sim +run general/db/len.sim +run general/db/repeat.sim +run general/db/tables.sim +run general/db/vnodes.sim +run general/field/2.sim +run general/field/3.sim +run general/field/4.sim +run general/field/5.sim +run general/field/6.sim +run general/field/bigint.sim +run general/field/binary.sim +run general/field/bool.sim +run general/field/single.sim +run general/field/smallint.sim +run general/field/tinyint.sim +run general/http/restful.sim +run general/http/restful_insert.sim +run general/http/restful_limit.sim +run general/http/restful_full.sim +run general/http/prepare.sim +run general/http/telegraf.sim +run general/http/grafana_bug.sim +run general/http/grafana.sim +run general/import/basic.sim +run general/import/commit.sim +run general/import/large.sim +run general/import/replica1.sim +run general/insert/basic.sim +run general/insert/insert_drop.sim +run general/insert/query_block1_memory.sim +run general/insert/query_block2_memory.sim +run general/insert/query_block1_file.sim +run general/insert/query_block2_file.sim +run general/insert/query_file_memory.sim +run general/insert/query_multi_file.sim +run general/insert/tcp.sim +run general/parser/alter.sim +run general/parser/alter1.sim +run general/parser/alter_stable.sim +run general/parser/auto_create_tb.sim +run general/parser/auto_create_tb_drop_tb.sim +run general/parser/col_arithmetic_operation.sim +run general/parser/columnValue.sim +run general/parser/commit.sim +run general/parser/create_db.sim +run general/parser/create_mt.sim +run general/parser/create_tb.sim +run general/parser/dbtbnameValidate.sim +run general/parser/import_commit1.sim +run general/parser/import_commit2.sim +run general/parser/import_commit3.sim +run general/parser/insert_tb.sim +run general/parser/first_last.sim +##unsupport run general/parser/import_file.sim +run general/parser/lastrow.sim +run general/parser/nchar.sim +run general/parser/null_char.sim +run general/parser/single_row_in_tb.sim +run general/parser/select_from_cache_disk.sim +run general/parser/limit.sim +run general/parser/limit1.sim +run general/parser/limit1_tblocks100.sim +run general/parser/mixed_blocks.sim +run general/parser/selectResNum.sim +run general/parser/select_across_vnodes.sim +run general/parser/slimit1.sim +run general/parser/tbnameIn.sim +run general/parser/binary_escapeCharacter.sim +run general/parser/projection_limit_offset.sim +run general/parser/limit2.sim +run general/parser/slimit.sim +run general/parser/fill.sim +run general/parser/fill_stb.sim +run general/parser/interp.sim +run general/parser/where.sim +run general/parser/join.sim +run general/parser/join_multivnode.sim +run general/parser/select_with_tags.sim +run general/parser/groupby.sim +run general/parser/bug.sim +run general/parser/tags_dynamically_specifiy.sim +run general/parser/set_tag_vals.sim +run general/parser/repeatAlter.sim +run general/parser/precision_ns.sim +##unsupport run general/parser/slimit_alter_tags.sim +run general/stable/disk.sim +run general/stable/dnode3.sim +run general/stable/metrics.sim +run general/stable/values.sim +run general/stable/vnode3.sim +run general/stable/refcount.sim +run general/stable/show.sim +run general/table/autocreate.sim +run general/table/basic1.sim +run general/table/basic2.sim +run general/table/basic3.sim +run general/table/bigint.sim +run general/table/binary.sim +run general/table/bool.sim +run general/table/column_name.sim +run general/table/column_num.sim +run general/table/column_value.sim +run general/table/column2.sim +run general/table/date.sim +run general/table/db.table.sim +run general/table/delete_reuse1.sim +run general/table/delete_reuse2.sim +run general/table/delete_writing.sim +run general/table/describe.sim +run general/table/double.sim +run general/table/fill.sim +run general/table/float.sim +run general/table/int.sim +run general/table/limit.sim +run general/table/smallint.sim +run general/table/table_len.sim +run general/table/table.sim +run general/table/tinyint.sim +run general/table/vgroup.sim +run general/tag/3.sim +run general/tag/4.sim +run general/tag/5.sim +run general/tag/6.sim +run general/tag/add.sim +run general/tag/bigint.sim +run general/tag/binary_binary.sim +run general/tag/binary.sim +run general/tag/bool_binary.sim +run general/tag/bool_int.sim +run general/tag/bool.sim +run general/tag/change.sim +run general/tag/column.sim +##unsupport run general/tag/commit.sim +run general/tag/create.sim +run general/tag/delete.sim +run general/tag/double.sim +run general/tag/filter.sim +run general/tag/float.sim +run general/tag/int_binary.sim +run general/tag/int_float.sim +run general/tag/int.sim +run general/tag/set.sim +run general/tag/smallint.sim +run general/tag/tinyint.sim +run general/user/authority.sim +run general/user/monitor.sim +run general/user/pass_alter.sim +run general/user/pass_len.sim +run general/user/user_create.sim +run general/user/user_len.sim +run general/vector/metrics_field.sim +run general/vector/metrics_mix.sim +run general/vector/metrics_query.sim +run general/vector/metrics_tag.sim +run general/vector/metrics_time.sim +run general/vector/multi.sim +run general/vector/single.sim +run general/vector/table_field.sim +run general/vector/table_mix.sim +run general/vector/table_query.sim +run general/vector/table_time.sim +run general/stream/restart_stream.sim +run general/stream/stream_3.sim +run general/stream/stream_restart.sim +run general/stream/table_del.sim +run general/stream/metrics_del.sim +run general/stream/table_replica1_vnoden.sim +run general/stream/metrics_replica1_vnoden.sim diff --git a/tests/script/sh/abs_max.c b/tests/script/sh/abs_max.c new file mode 100644 index 0000000000000000000000000000000000000000..9faea60374766e47f82a70880fe2b1376bbc12dc --- /dev/null +++ b/tests/script/sh/abs_max.c @@ -0,0 +1,95 @@ +#include +#include +#include +#include + +typedef struct SUdfInit{ + int maybe_null; /* 1 if function can return NULL */ + int decimals; /* for real functions */ + int64_t length; /* For string functions */ + char *ptr; /* free pointer for function data */ + int const_item; /* 0 if result is independent of arguments */ +} SUdfInit; + + +#define TSDB_DATA_INT_NULL 0x80000000L +#define TSDB_DATA_BIGINT_NULL 0x8000000000000000L + +void abs_max(char* data, short itype, short ibytes, int numOfRows, int64_t* ts, char* dataOutput, char* interBuf, char* tsOutput, + int* numOfOutput, short otype, short obytes, SUdfInit* buf) { + int i; + int64_t r = 0; + // printf("abs_max input data:%p, type:%d, rows:%d, ts:%p, %" PRId64 ", dataoutput:%p, tsOutput:%p, numOfOutput:%p, buf:%p\n", data, itype, numOfRows, ts, *ts, dataOutput, tsOutput, numOfOutput, buf); + if (itype == 5) { + r=*(int64_t *)dataOutput; + *numOfOutput=0; + + for(i=0;i r) { + r = v; + } + } + + *(int64_t *)dataOutput=r; + + // printf("abs_max out, dataoutput:%" PRId64", numOfOutput:%d\n", *(int64_t *)dataOutput, *numOfOutput); + }else { + *numOfOutput=0; + } +} + + + +void abs_max_finalize(char* dataOutput, char* interBuf, int* numOfOutput, SUdfInit* buf) { + int i; + //int64_t r = 0; + // printf("abs_max_finalize dataoutput:%p:%d, numOfOutput:%d, buf:%p\n", dataOutput, *dataOutput, *numOfOutput, buf); + // *numOfOutput=1; + // printf("abs_max finalize, dataoutput:%" PRId64", numOfOutput:%d\n", *(int64_t *)dataOutput, *numOfOutput); +} + +void abs_max_merge(char* data, int32_t numOfRows, char* dataOutput, int32_t* numOfOutput, SUdfInit* buf) { + int64_t r = 0; + + if (numOfRows > 0) { + r = *((int64_t *)data); + } + // printf("abs_max_merge numOfRows:%d, dataoutput:%p, buf:%p\n", numOfRows, dataOutput, buf); + for (int i = 1; i < numOfRows; ++i) { + // printf("abs_max_merge %d - %" PRId64"\n", i, *((int64_t *)data + i)); + if (*((int64_t*)data + i) > r) { + r= *((int64_t*)data + i); + } + } + + *(int64_t*)dataOutput=r; + if (numOfRows > 0) { + *numOfOutput=1; + } else { + *numOfOutput=0; + } + + // printf("abs_max_merge, dataoutput:%" PRId64", numOfOutput:%d\n", *(int64_t *)dataOutput, *numOfOutput); +} + + +int abs_max_init(SUdfInit* buf) { + // printf("abs_max init\n"); + return 0; +} + + +void abs_max_destroy(SUdfInit* buf) { + // printf("abs_max destroy\n"); +} \ No newline at end of file diff --git a/tests/script/sh/add_one.c b/tests/script/sh/add_one.c new file mode 100644 index 0000000000000000000000000000000000000000..de2a7d168c88d1a13bf5cbe6a327ea451ddb2546 --- /dev/null +++ b/tests/script/sh/add_one.c @@ -0,0 +1,31 @@ +#include +#include +#include + +typedef struct SUdfInit{ + int maybe_null; /* 1 if function can return NULL */ + int decimals; /* for real functions */ + long long length; /* For string functions */ + char *ptr; /* free pointer for function data */ + int const_item; /* 0 if result is independent of arguments */ +} SUdfInit; + +void add_one(char* data, short itype, short ibytes, int numOfRows, long long* ts, char* dataOutput, char* interBUf, char* tsOutput, + int* numOfOutput, short otype, short obytes, SUdfInit* buf) { + int i; + int r = 0; + // printf("add_one input data:%p, type:%d, rows:%d, ts:%p,%lld, dataoutput:%p, tsOutput:%p, numOfOutput:%p, buf:%p\n", data, itype, numOfRows, ts, *ts, dataOutput, tsOutput, numOfOutput, buf); + if (itype == 4) { + for(i=0;i +#include +#include + +typedef struct SUdfInit{ + int maybe_null; /* 1 if function can return NULL */ + int decimals; /* for real functions */ + long long length; /* For string functions */ + char *ptr; /* free pointer for function data */ + int const_item; /* 0 if result is independent of arguments */ +} SUdfInit; + +void add_one_64232(char* data, short itype, short ibytes, int numOfRows, long long* ts, char* dataOutput, char* interBUf, char* tsOutput, + int* numOfOutput, short otype, short obytes, SUdfInit* buf) { + int i; + int r = 0; + printf("add_one_64232 input data:%p, type:%d, rows:%d, ts:%p,%lld, dataoutput:%p, tsOutput:%p, numOfOutput:%p, buf:%p\n", data, itype, numOfRows, ts, *ts, dataOutput, tsOutput, numOfOutput, buf); + if (itype == 5) { + for(i=0;i> %TAOS_CFG% diff --git a/tests/script/sh/cfg.sh b/tests/script/sh/cfg.sh new file mode 100755 index 0000000000000000000000000000000000000000..7d4d747e54bab9ed98b42ab1902f8580e17fca6c --- /dev/null +++ b/tests/script/sh/cfg.sh @@ -0,0 +1,71 @@ +#!/bin/bash + +if [ $# != 6 ]; then + echo "argument list need input : " + echo " -n nodeName" + echo " -c configName" + echo " -v configValue" + exit 1 +fi + +UNAME_BIN=`which uname` +OS_TYPE=`$UNAME_BIN` +NODE_NAME= +CONFIG_NAME= +CONFIG_VALUE= +while getopts "n:v:c:" arg +do + case $arg in + n) + NODE_NAME=$OPTARG + ;; + c) + CONFIG_NAME=$OPTARG + ;; + v) + CONFIG_VALUE=$OPTARG + ;; + ?) + echo "unkonw argument" + ;; + esac +done + +SCRIPT_DIR=`dirname $0` +cd $SCRIPT_DIR/../ +SCRIPT_DIR=`pwd` + +IN_TDINTERNAL="community" +if [[ "$SCRIPT_DIR" == *"$IN_TDINTERNAL"* ]]; then + cd ../../.. +else + cd ../../ +fi + +TAOS_DIR=`pwd` +TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1` + +if [[ "$OS_TYPE" != "Darwin" ]]; then + cut_opt="--field=" +else + cut_opt="-f " +fi + +if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then + BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3` +else + BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2` +fi + +BUILD_DIR=$TAOS_DIR/$BIN_DIR/build + +SIM_DIR=$TAOS_DIR/sim + +NODE_DIR=$SIM_DIR/$NODE_NAME +TAOS_CFG=$NODE_DIR/cfg/taos.cfg +TAOS_FLAG=$SIM_DIR/tsim/flag +if [ -f "$TAOS_FLAG" ] ; then + TAOS_CFG=/etc/taos/taos.cfg +fi + +echo "$CONFIG_NAME $CONFIG_VALUE" >> $TAOS_CFG diff --git a/tests/script/sh/clear.sh b/tests/script/sh/clear.sh new file mode 100755 index 0000000000000000000000000000000000000000..4ee296cf058370552b14c31b67006830e84847dd --- /dev/null +++ b/tests/script/sh/clear.sh @@ -0,0 +1,137 @@ +#!/bin/bash + +echo "Executing clear.sh" + +if [ $# != 6 ]; then + echo "argument list need input : " + echo " -n nodeName" + echo " -i nodeIp" + echo " -m masterIp" + exit 1 +fi + +UNAME_BIN=`which uname` +OS_TYPE=`$UNAME_BIN` +NODE_NAME= +NODE_IP= +MSATER_IP= +while getopts "n:i:m:" arg +do + case $arg in + n) + NODE_NAME=$OPTARG + ;; + i) + NODE_IP=$OPTARG + ;; + m) + MASTER_IP=$OPTARG + ;; + ?) + echo "unkonw argument" + ;; + esac +done + +SCRIPT_DIR=`dirname $0` +cd $SCRIPT_DIR/../ +SCRIPT_DIR=`pwd` +echo "SCRIPT_DIR: $SCRIPT_DIR" + +IN_TDINTERNAL="community" +if [[ "$SCRIPT_DIR" == *"$IN_TDINTERNAL"* ]]; then + cd ../../.. +else + cd ../../ +fi + +TAOS_DIR=`pwd` +TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1` + +if [[ "$OS_TYPE" != "Darwin" ]]; then + cut_opt="--field=" +else + cut_opt="-f " +fi + +if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then + BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3` +else + BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2` +fi + +BUILD_DIR=$TAOS_DIR/$BIN_DIR/build + +SIM_DIR=$TAOS_DIR/sim +NODE_DIR=$SIM_DIR/$NODE_NAME +EXE_DIR=$BUILD_DIR/bin +CFG_DIR=$NODE_DIR/cfg +LOG_DIR=$NODE_DIR/log +DATA_DIR=$NODE_DIR/data + +#echo ============ deploy $NODE_NAME +#echo === masterIp : $MASTER_IP +#echo === nodeIp : $NODE_IP +#echo === nodePath : $EXE_DIR +#echo === cfgPath : $CFG_DIR +#echo === logPath : $LOG_DIR +#echo === dataPath : $DATA_DIR + +# rm -rf $NODE_DIR + +mkdir -p $SIM_DIR +mkdir -p $NODE_DIR +mkdir -p $LOG_DIR +rm -rf $DATA_DIR +mkdir -p $DATA_DIR + +#cp -rf $TAOS_DIR/cfg $NODE_DIR/ +rm -rf $CFG_DIR +mkdir -p $CFG_DIR + +#allow normal user to read/write log +chmod -R 777 $NODE_DIR + +TAOS_CFG=$NODE_DIR/cfg/taos.cfg +touch -f $TAOS_CFG + +TAOS_FLAG=$SIM_DIR/tsim/flag +if [ -f "$TAOS_FLAG" ] ; then + TAOS_CFG=/etc/taos/taos.cfg + DATA_DIR=/var/lib/taos + LOG_DIR=/var/log/taos + sudo rm -f /etc/taos/*.cfg + sudo cp -rf $TAOS_DIR/cfg/*.cfg /etc/taos + sudo rm -rf $DATA_DIR + sudo rm -rf $LOG_DIR +fi + +echo " " >> $TAOS_CFG +echo "masterIp $MASTER_IP" >> $TAOS_CFG +echo "dataDir $DATA_DIR" >> $TAOS_CFG +echo "logDir $LOG_DIR" >> $TAOS_CFG +echo "publicIp $NODE_IP" >> $TAOS_CFG +echo "internalIp $NODE_IP" >> $TAOS_CFG +echo "privateIp $NODE_IP" >> $TAOS_CFG +echo "dDebugFlag 135" >> $TAOS_CFG +echo "mDebugFlag 135" >> $TAOS_CFG +echo "sdbDebugFlag 135" >> $TAOS_CFG +echo "rpcDebugFlag 131" >> $TAOS_CFG +echo "tmrDebugFlag 131" >> $TAOS_CFG +echo "cDebugFlag 135" >> $TAOS_CFG +echo "httpDebugFlag 131" >> $TAOS_CFG +echo "monitorDebugFlag 131" >> $TAOS_CFG +echo "udebugFlag 131" >> $TAOS_CFG +echo "jnidebugFlag 131" >> $TAOS_CFG +echo "monitor 0" >> $TAOS_CFG +echo "numOfThreadsPerCore 2.0" >> $TAOS_CFG +echo "defaultPass taosdata" >> $TAOS_CFG +echo "numOfLogLines 100000000" >> $TAOS_CFG +echo "mnodeEqualVnodeNum 0" >> $TAOS_CFG +echo "clog 0" >> $TAOS_CFG +echo "statusInterval 1" >> $TAOS_CFG +echo "asyncLog 0" >> $TAOS_CFG +echo "numOfMnodes 1" >> $TAOS_CFG +echo "locale en_US.UTF-8" >> $TAOS_CFG + + diff --git a/tests/script/sh/demo.c b/tests/script/sh/demo.c new file mode 100644 index 0000000000000000000000000000000000000000..23d217444892e5bd8dc1c83b569dc22616c42e78 --- /dev/null +++ b/tests/script/sh/demo.c @@ -0,0 +1,112 @@ +#include +#include +#include + +typedef struct SUdfInit{ + int maybe_null; /* 1 if function can return NULL */ + int decimals; /* for real functions */ + long long length; /* For string functions */ + char *ptr; /* free pointer for function data */ + int const_item; /* 0 if result is independent of arguments */ +} SUdfInit; + +typedef struct SDemo{ + double sum; + int num; + short otype; +}SDemo; + +#define FLOAT_NULL 0x7FF00000 // it is an NAN +#define DOUBLE_NULL 0x7FFFFF0000000000L // it is an NAN + + +void demo(char* data, short itype, short ibytes, int numOfRows, long long* ts, char* dataOutput, char* interBuf, char* tsOutput, + int* numOfOutput, short otype, short obytes, SUdfInit* buf) { + int i; + double r = 0; + SDemo *p = (SDemo *)interBuf; + SDemo *q = (SDemo *)dataOutput; + printf("demo input data:%p, type:%d, rows:%d, ts:%p,%lld, dataoutput:%p, interBUf:%p, tsOutput:%p, numOfOutput:%p, buf:%p\n", data, itype, numOfRows, ts, *ts, dataOutput, interBuf, tsOutput, numOfOutput, buf); + + for(i=0;isum += r*r; + } + + p->otype = otype; + p->num += numOfRows; + + q->sum = p->sum; + q->num = p->num; + q->otype = p->otype; + + *numOfOutput=1; + + printf("demo out, sum:%f, num:%d, numOfOutput:%d\n", p->sum, p->num, *numOfOutput); +} + + +void demo_merge(char* data, int32_t numOfRows, char* dataOutput, int32_t* numOfOutput, SUdfInit* buf) { + int i; + SDemo *p = (SDemo *)data; + SDemo res = {0}; + printf("demo_merge input data:%p, rows:%d, dataoutput:%p, numOfOutput:%p, buf:%p\n", data, numOfRows, dataOutput, numOfOutput, buf); + + for(i=0;isum * p->sum; + res.num += p->num; + p++; + } + + p->sum = res.sum; + p->num = res.num; + + *numOfOutput=1; + + printf("demo out, sum:%f, num:%d, numOfOutput:%d\n", p->sum, p->num, *numOfOutput); +} + + + +void demo_finalize(char* dataOutput, char* interBuf, int* numOfOutput, SUdfInit* buf) { + SDemo *p = (SDemo *)interBuf; + printf("demo_finalize interbuf:%p, numOfOutput:%p, buf:%p, sum:%f, num:%d\n", interBuf, numOfOutput, buf, p->sum, p->num); + if (p->otype == 6) { + if (p->num != 30000) { + *(unsigned int *)dataOutput = FLOAT_NULL; + } else { + *(float *)dataOutput = (float)(p->sum / p->num); + } + printf("finalize values:%f\n", *(float *)dataOutput); + } else if (p->otype == 7) { + if (p->num != 30000) { + *(unsigned long long *)dataOutput = DOUBLE_NULL; + } else { + *(double *)dataOutput = (double)(p->sum / p->num); + } + printf("finalize values:%f\n", *(double *)dataOutput); + } + + *numOfOutput=1; + + printf("demo finalize, numOfOutput:%d\n", *numOfOutput); +} + + +int demo_init(SUdfInit* buf) { + printf("demo init\n"); + return 0; +} + + +void demo_destroy(SUdfInit* buf) { + printf("demo destroy\n"); +} + diff --git a/tests/script/sh/demo.lua b/tests/script/sh/demo.lua new file mode 100644 index 0000000000000000000000000000000000000000..c5e5582fc30b58db30a5b18faa4ccfd0a5f656d0 --- /dev/null +++ b/tests/script/sh/demo.lua @@ -0,0 +1,43 @@ +funcName = "test" + +global = {} + +function test_init() + return global +end + +function test_add(rows, ans, key) + t = {} + t["sum"] = 0.0 + t["num"] = 0 + for i=1, #rows do + t["sum"] = t["sum"] + rows[i] * rows[i] + end + t["num"] = #rows + + + if (ans[key] ~= nil) + then + ans[key]["sum"] = ans[key]["sum"] + t["sum"] + ans[key]["num"] = ans[key]["num"] + t["num"] + else + ans[key] = t + end + + return ans; +end + +function test_finalize(ans, key) + local ret = 0.0 + + if (ans[key] ~= nil and ans[key]["num"] == 30000) + then + ret = ans[key]["sum"]/ans[key]["num"] + ans[key]["sum"] = 0.0 + ans[key]["num"] = 0 + else + ret = inf + end + + return ret, ans +end diff --git a/tests/script/sh/deploy.bat b/tests/script/sh/deploy.bat new file mode 100644 index 0000000000000000000000000000000000000000..921f1611fb5ea80bbeb746b693d7c529c421ef27 --- /dev/null +++ b/tests/script/sh/deploy.bat @@ -0,0 +1,106 @@ +@echo off + +rem echo Executing deploy.sh + +if %1 == -n set NODE_NAME=%2 +if %1 == -i set NODE=%2 +if %3 == -n set NODE_NAME=%4 +if %3 == -i set NODE=%4 + +rem echo NODE_NAME: %NODE_NAME% +rem echo NODE: %NODE% + +set SCRIPT_DIR=%~dp0..\ +rem echo SCRIPT_DIR: %SCRIPT_DIR% + +set BUILD_DIR=%SCRIPT_DIR%..\..\..\debug\build\bin\ +set TSIM=%BUILD_DIR%tsim +rem echo BUILD_DIR: %BUILD_DIR% +rem echo TSIM: %TSIM% + +set SIM_DIR=%SCRIPT_DIR%..\..\..\sim\ +rem echo SIM_DIR: %SIM_DIR% + +set NODE_DIR=%SIM_DIR%%NODE_NAME%\ +rem echo NODE_DIR: %NODE_DIR% + +set CFG_DIR=%NODE_DIR%cfg\ +rem echo CFG_DIR: %CFG_DIR% + +set LOG_DIR=%NODE_DIR%log\ +rem echo LOG_DIR: %LOG_DIR% + +set DATA_DIR=%NODE_DIR%data\ +rem echo DATA_DIR: %DATA_DIR% + +set TAOS_CFG=%CFG_DIR%taos.cfg +rem echo TAOS_CFG: %TAOS_CFG% + +if not exist %SIM_DIR% mkdir %SIM_DIR% +if not exist %NODE_DIR% mkdir %NODE_DIR% +if exist %CFG_DIR% rmdir /s/q %CFG_DIR% +if exist %LOG_DIR% rmdir /s/q %LOG_DIR% +if exist %DATA_DIR% rmdir /s/q %DATA_DIR% +if not exist %CFG_DIR% mkdir %CFG_DIR% +if not exist %LOG_DIR% mkdir %LOG_DIR% +if not exist %DATA_DIR% mkdir %DATA_DIR% + +if %NODE% == 1 set NODE=7100 +if %NODE% == 2 set NODE=7200 +if %NODE% == 3 set NODE=7300 +if %NODE% == 4 set NODE=7400 +if %NODE% == 5 set NODE=7500 +if %NODE% == 6 set NODE=7600 +if %NODE% == 7 set NODE=7700 +if %NODE% == 8 set NODE=7800 + +rem set "fqdn=" +for /f "skip=1" %%A in ( + 'wmic computersystem get caption' +) do if not defined fqdn set "fqdn=%%A" + +echo firstEp %fqdn%:7100 > %TAOS_CFG% +echo fqdn %fqdn% >> %TAOS_CFG% +echo serverPort %NODE% >> %TAOS_CFG% +echo dataDir %DATA_DIR% >> %TAOS_CFG% +echo logDir %LOG_DIR% >> %TAOS_CFG% +echo debugFlag 0 >> %TAOS_CFG% +echo mDebugFlag 135 >> %TAOS_CFG% +echo sdbDebugFlag 135 >> %TAOS_CFG% +echo dDebugFlag 135 >> %TAOS_CFG% +echo vDebugFlag 135 >> %TAOS_CFG% +echo tsdbDebugFlag 135 >> %TAOS_CFG% +echo cDebugFlag 135 >> %TAOS_CFG% +echo jnidebugFlag 135 >> %TAOS_CFG% +echo odbcdebugFlag 135 >> %TAOS_CFG% +echo httpDebugFlag 135 >> %TAOS_CFG% +echo monDebugFlag 135 >> %TAOS_CFG% +echo mqttDebugFlag 135 >> %TAOS_CFG% +echo qdebugFlag 135 >> %TAOS_CFG% +echo rpcDebugFlag 135 >> %TAOS_CFG% +echo tmrDebugFlag 131 >> %TAOS_CFG% +echo udebugFlag 135 >> %TAOS_CFG% +echo sdebugFlag 135 >> %TAOS_CFG% +echo wdebugFlag 135 >> %TAOS_CFG% +echo cqdebugFlag 135 >> %TAOS_CFG% +echo monitor 0 >> %TAOS_CFG% +echo monitorInterval 1 >> %TAOS_CFG% +echo http 0 >> %TAOS_CFG% +echo slaveQuery 0 >> %TAOS_CFG% +echo numOfThreadsPerCore 2.0 >> %TAOS_CFG% +echo defaultPass taosdata >> %TAOS_CFG% +echo numOfLogLines 20000000 >> %TAOS_CFG% +echo mnodeEqualVnodeNum 0 >> %TAOS_CFG% +echo balanceInterval 1 >> %TAOS_CFG% +echo clog 2 >> %TAOS_CFG% +echo days 10 >> %TAOS_CFG% +echo statusInterval 1 >> %TAOS_CFG% +echo maxVgroupsPerDb 4 >> %TAOS_CFG% +echo minTablesPerVnode 4 >> %TAOS_CFG% +echo maxTablesPerVnode 1000 >> %TAOS_CFG% +echo tableIncStepPerVnode 10000 >> %TAOS_CFG% +echo asyncLog 0 >> %TAOS_CFG% +echo numOfMnodes 1 >> %TAOS_CFG% +echo locale en_US.UTF-8 >> %TAOS_CFG% +echo fsync 0 >> %TAOS_CFG% +echo telemetryReporting 0 >> %TAOS_CFG% diff --git a/tests/script/sh/deploy.sh b/tests/script/sh/deploy.sh new file mode 100755 index 0000000000000000000000000000000000000000..cde27d7dc3fa00258d9d9d50ee3dfc82f858b138 --- /dev/null +++ b/tests/script/sh/deploy.sh @@ -0,0 +1,163 @@ +#!/bin/bash + +echo "Executing deploy.sh" + +if [ $# != 4 ]; then + echo "argument list need input : " + echo " -n nodeName" + echo " -i nodePort" + exit 1 +fi + +UNAME_BIN=`which uname` +OS_TYPE=`$UNAME_BIN` +NODE_NAME= +NODE= +while getopts "n:i:" arg +do + case $arg in + n) + NODE_NAME=$OPTARG + ;; + i) + NODE=$OPTARG + ;; + ?) + echo "unkonw argument" + ;; + esac +done + +SCRIPT_DIR=`dirname $0` +cd $SCRIPT_DIR/../ +SCRIPT_DIR=`pwd` +echo "SCRIPT_DIR: $SCRIPT_DIR" + +IN_TDINTERNAL="community" +if [[ "$SCRIPT_DIR" == *"$IN_TDINTERNAL"* ]]; then + cd ../../.. +else + cd ../../ +fi + +TAOS_DIR=`pwd` +TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1` + +if [[ "$OS_TYPE" != "Darwin" ]]; then + cut_opt="--field=" +else + cut_opt="-f " +fi + +if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then + BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3` +else + BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2` +fi + +BUILD_DIR=$TAOS_DIR/$BIN_DIR/build + +SIM_DIR=$TAOS_DIR/sim + +NODE_DIR=$SIM_DIR/$NODE_NAME +EXE_DIR=$BUILD_DIR/bin +CFG_DIR=$NODE_DIR/cfg +LOG_DIR=$NODE_DIR/log +DATA_DIR=$NODE_DIR/data + +rm -rf $NODE_DIR + +mkdir -p $SIM_DIR +mkdir -p $NODE_DIR +mkdir -p $LOG_DIR +mkdir -p $DATA_DIR + +#cp -rf $TAOS_DIR/cfg $NODE_DIR/ +mkdir -p $CFG_DIR + +#allow normal user to read/write log +chmod -R 777 $NODE_DIR + +TAOS_CFG=$NODE_DIR/cfg/taos.cfg +touch -f $TAOS_CFG + +TAOS_FLAG=$SIM_DIR/tsim/flag +if [ -f "$TAOS_FLAG" ] ; then + TAOS_CFG=/etc/taos/taos.cfg + DATA_DIR=/var/lib/taos + LOG_DIR=/var/log/taos + sudo rm -f /etc/taos/*.cfg + sudo cp -rf $TAOS_DIR/cfg/*.cfg /etc/taos + sudo rm -rf $DATA_DIR + sudo rm -rf $LOG_DIR +fi + +HOSTNAME=`hostname -f` + +if [ $NODE -eq 1 ]; then + NODE=7100 +elif [ $NODE -eq 2 ]; then + NODE=7200 +elif [ $NODE -eq 3 ]; then + NODE=7300 +elif [ $NODE -eq 4 ]; then + NODE=7400 +elif [ $NODE -eq 5 ]; then + NODE=7500 +elif [ $NODE -eq 6 ]; then + NODE=7600 +elif [ $NODE -eq 7 ]; then + NODE=7700 +elif [ $NODE -eq 8 ]; then + NODE=7800 +fi + +echo " " >> $TAOS_CFG +echo "firstEp ${HOSTNAME}:7100" >> $TAOS_CFG +echo "secondEp ${HOSTNAME}:7200" >> $TAOS_CFG +echo "serverPort ${NODE}" >> $TAOS_CFG +echo "dataDir $DATA_DIR" >> $TAOS_CFG +echo "logDir $LOG_DIR" >> $TAOS_CFG +echo "debugFlag 0" >> $TAOS_CFG +echo "mDebugFlag 143" >> $TAOS_CFG +echo "sdbDebugFlag 143" >> $TAOS_CFG +echo "dDebugFlag 143" >> $TAOS_CFG +echo "vDebugFlag 143" >> $TAOS_CFG +echo "tsdbDebugFlag 143" >> $TAOS_CFG +echo "cDebugFlag 143" >> $TAOS_CFG +echo "jnidebugFlag 143" >> $TAOS_CFG +echo "odbcdebugFlag 143" >> $TAOS_CFG +echo "httpDebugFlag 143" >> $TAOS_CFG +echo "monDebugFlag 143" >> $TAOS_CFG +echo "mqttDebugFlag 143" >> $TAOS_CFG +echo "qdebugFlag 143" >> $TAOS_CFG +echo "rpcDebugFlag 143" >> $TAOS_CFG +echo "tmrDebugFlag 131" >> $TAOS_CFG +echo "udebugFlag 143" >> $TAOS_CFG +echo "sdebugFlag 143" >> $TAOS_CFG +echo "wdebugFlag 143" >> $TAOS_CFG +echo "cqdebugFlag 143" >> $TAOS_CFG +echo "monitor 0" >> $TAOS_CFG +echo "monitorInterval 1" >> $TAOS_CFG +echo "http 0" >> $TAOS_CFG +echo "slaveQuery 0" >> $TAOS_CFG +echo "numOfThreadsPerCore 2.0" >> $TAOS_CFG +echo "defaultPass taosdata" >> $TAOS_CFG +echo "numOfLogLines 20000000" >> $TAOS_CFG +echo "mnodeEqualVnodeNum 0" >> $TAOS_CFG +echo "balanceInterval 1" >> $TAOS_CFG +echo "clog 2" >> $TAOS_CFG +#echo "cache 1" >> $TAOS_CFG +echo "days 10" >> $TAOS_CFG +echo "statusInterval 1" >> $TAOS_CFG +echo "maxVgroupsPerDb 4" >> $TAOS_CFG +echo "minTablesPerVnode 4" >> $TAOS_CFG +echo "maxTablesPerVnode 1000" >> $TAOS_CFG +echo "tableIncStepPerVnode 10000" >> $TAOS_CFG +echo "asyncLog 0" >> $TAOS_CFG +echo "numOfMnodes 1" >> $TAOS_CFG +echo "locale en_US.UTF-8" >> $TAOS_CFG +echo "fsync 0" >> $TAOS_CFG +echo "telemetryReporting 0" >> $TAOS_CFG +echo " " >> $TAOS_CFG + diff --git a/tests/script/sh/exec-default.sh b/tests/script/sh/exec-default.sh new file mode 100755 index 0000000000000000000000000000000000000000..f648315c6745f63cfba9eb06ecfd53a9ccef1fed --- /dev/null +++ b/tests/script/sh/exec-default.sh @@ -0,0 +1,123 @@ +#!/bin/bash + +# if [ $# != 4 || $# != 5 ]; then + # echo "argument list need input : " + # echo " -n nodeName" + # echo " -s start/stop" + # echo " -c clear" + # exit 1 +# fi + +UNAME_BIN=`which uname` +OS_TYPE=`$UNAME_BIN` +NODE_NAME= +EXEC_OPTON= +CLEAR_OPTION="false" +while getopts "n:s:u:x:ct" arg +do + case $arg in + n) + NODE_NAME=$OPTARG + ;; + s) + EXEC_OPTON=$OPTARG + ;; + c) + CLEAR_OPTION="clear" + ;; + t) + SHELL_OPTION="true" + ;; + u) + USERS=$OPTARG + ;; + x) + SIGNAL=$OPTARG + ;; + ?) + echo "unkown argument" + ;; + esac +done + +SCRIPT_DIR=`dirname $0` +cd $SCRIPT_DIR/../ +SCRIPT_DIR=`pwd` + +IN_TDINTERNAL="community" +if [[ "$SCRIPT_DIR" == *"$IN_TDINTERNAL"* ]]; then + cd ../../.. +else + cd ../../ +fi + +TAOS_DIR=`pwd` +TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1` + +if [[ "$OS_TYPE" != "Darwin" ]]; then + cut_opt="--field=" +else + cut_opt="-f " +fi + +if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then + BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3` +else + BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2` +fi + +BUILD_DIR=$TAOS_DIR/$BIN_DIR/build + +SIM_DIR=$TAOS_DIR/sim +NODE_DIR=$SIM_DIR/$NODE_NAME +EXE_DIR=$BUILD_DIR/bin +CFG_DIR=$NODE_DIR/cfg +LOG_DIR=$NODE_DIR/log +DATA_DIR=$NODE_DIR/data +MGMT_DIR=$NODE_DIR/data/mgmt +TSDB_DIR=$NODE_DIR/data/tsdb + +TAOS_CFG=$NODE_DIR/cfg/taos.cfg + +echo ------------ $EXEC_OPTON $NODE_NAME + +TAOS_FLAG=$SIM_DIR/tsim/flag +if [ -f "$TAOS_FLAG" ]; then + EXE_DIR=/usr/local/bin/taos +fi + +if [ "$CLEAR_OPTION" = "clear" ]; then + echo rm -rf $MGMT_DIR $TSDB_DIR + rm -rf $TSDB_DIR + rm -rf $MGMT_DIR +fi + +if [ "$EXEC_OPTON" = "start" ]; then + echo "ExcuteCmd:" $EXE_DIR/taosd -c $CFG_DIR + + if [ "$SHELL_OPTION" = "true" ]; then + TT=`date +%s` + mkdir ${LOG_DIR}/${TT} + nohup valgrind --log-file=${LOG_DIR}/${TT}/valgrind.log --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes $EXE_DIR/taosd -c $CFG_DIR > /dev/null 2>&1 & + else + nohup $EXE_DIR/taosd -c $CFG_DIR > /dev/null 2>&1 & + fi + +else + #relative path + RCFG_DIR=sim/$NODE_NAME/cfg + PID=`ps -ef|grep taosd | grep $RCFG_DIR | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + if [ "$SIGNAL" = "SIGKILL" ]; then + echo try to kill by signal SIGKILL + kill -9 $PID + else + echo try to kill by signal SIGINT + kill -SIGINT $PID + fi + sleep 1 + PID=`ps -ef|grep taosd | grep $RCFG_DIR | grep -v grep | awk '{print $2}'` + done +fi + diff --git a/tests/script/sh/exec-no-random-fail.sh b/tests/script/sh/exec-no-random-fail.sh new file mode 100755 index 0000000000000000000000000000000000000000..e01b18a8e6bb0d4631a28c64c6accd57bceb9076 --- /dev/null +++ b/tests/script/sh/exec-no-random-fail.sh @@ -0,0 +1,123 @@ +#!/bin/bash + +# if [ $# != 4 || $# != 5 ]; then + # echo "argument list need input : " + # echo " -n nodeName" + # echo " -s start/stop" + # echo " -c clear" + # exit 1 +# fi + +UNAME_BIN=`which uname` +OS_TYPE=`$UNAME_BIN` +NODE_NAME= +EXEC_OPTON= +CLEAR_OPTION="false" +while getopts "n:s:u:x:ct" arg +do + case $arg in + n) + NODE_NAME=$OPTARG + ;; + s) + EXEC_OPTON=$OPTARG + ;; + c) + CLEAR_OPTION="clear" + ;; + t) + SHELL_OPTION="true" + ;; + u) + USERS=$OPTARG + ;; + x) + SIGNAL=$OPTARG + ;; + ?) + echo "unkown argument" + ;; + esac +done + +SCRIPT_DIR=`dirname $0` +cd $SCRIPT_DIR/../ +SCRIPT_DIR=`pwd` + +IN_TDINTERNAL="community" +if [[ "$SCRIPT_DIR" == *"$IN_TDINTERNAL"* ]]; then + cd ../../.. +else + cd ../../ +fi + +TAOS_DIR=`pwd` +TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1` + +if [[ "$OS_TYPE" != "Darwin" ]]; then + cut_opt="--field=" +else + cut_opt="-f " +fi + +if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then + BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3` +else + BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2` +fi + +BUILD_DIR=$TAOS_DIR/$BIN_DIR/build + +SIM_DIR=$TAOS_DIR/sim +NODE_DIR=$SIM_DIR/$NODE_NAME +EXE_DIR=$BUILD_DIR/bin +CFG_DIR=$NODE_DIR/cfg +LOG_DIR=$NODE_DIR/log +DATA_DIR=$NODE_DIR/data +MGMT_DIR=$NODE_DIR/data/mgmt +TSDB_DIR=$NODE_DIR/data/tsdb + +TAOS_CFG=$NODE_DIR/cfg/taos.cfg + +echo ------------ $EXEC_OPTON $NODE_NAME + +TAOS_FLAG=$SIM_DIR/tsim/flag +if [ -f "$TAOS_FLAG" ]; then + EXE_DIR=/usr/local/bin/taos +fi + +if [ "$CLEAR_OPTION" = "clear" ]; then + echo rm -rf $MGMT_DIR $TSDB_DIR + rm -rf $TSDB_DIR + rm -rf $MGMT_DIR +fi + +if [ "$EXEC_OPTON" = "start" ]; then + echo "ExcuteCmd:" $EXE_DIR/taosd -c $CFG_DIR + + if [ "$SHELL_OPTION" = "true" ]; then + TT=`date +%s` + mkdir ${LOG_DIR}/${TT} + nohup valgrind --log-file=${LOG_DIR}/${TT}/valgrind.log --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes $EXE_DIR/taosd -c $CFG_DIR > /dev/null 2>&1 & + else + nohup $EXE_DIR/taosd -c $CFG_DIR --random-file-fail-factor 0 > /dev/null 2>&1 & + fi + +else + #relative path + RCFG_DIR=sim/$NODE_NAME/cfg + PID=`ps -ef|grep taosd | grep $RCFG_DIR | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + if [ "$SIGNAL" = "SIGKILL" ]; then + echo try to kill by signal SIGKILL + kill -9 $PID + else + echo try to kill by signal SIGINT + kill -SIGINT $PID + fi + sleep 1 + PID=`ps -ef|grep taosd | grep $RCFG_DIR | grep -v grep | awk '{print $2}'` + done +fi + diff --git a/tests/script/sh/exec-random-fail.sh b/tests/script/sh/exec-random-fail.sh new file mode 100755 index 0000000000000000000000000000000000000000..1f31899e3ac26861fc1860d10cb0a4899ff7bf36 --- /dev/null +++ b/tests/script/sh/exec-random-fail.sh @@ -0,0 +1,124 @@ +#!/bin/bash + +# if [ $# != 4 || $# != 5 ]; then + # echo "argument list need input : " + # echo " -n nodeName" + # echo " -s start/stop" + # echo " -c clear" + # exit 1 +# fi + +UNAME_BIN=`which uname` +OS_TYPE=`$UNAME_BIN` +NODE_NAME= +EXEC_OPTON= +CLEAR_OPTION="false" +while getopts "n:s:u:x:ct" arg +do + case $arg in + n) + NODE_NAME=$OPTARG + ;; + s) + EXEC_OPTON=$OPTARG + ;; + c) + CLEAR_OPTION="clear" + ;; + t) + SHELL_OPTION="true" + ;; + u) + USERS=$OPTARG + ;; + x) + SIGNAL=$OPTARG + ;; + ?) + echo "unkown argument" + ;; + esac +done + +SCRIPT_DIR=`dirname $0` +cd $SCRIPT_DIR/../ +SCRIPT_DIR=`pwd` + +IN_TDINTERNAL="community" +if [[ "$SCRIPT_DIR" == *"$IN_TDINTERNAL"* ]]; then + cd ../../.. +else + cd ../../ +fi + +TAOS_DIR=`pwd` +TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1` + +if [[ "$OS_TYPE" != "Darwin" ]]; then + cut_opt="--field=" +else + cut_opt="-f " +fi + +if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then + BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3` +else + BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2` +fi + +BUILD_DIR=$TAOS_DIR/$BIN_DIR/build + +SIM_DIR=$TAOS_DIR/sim +NODE_DIR=$SIM_DIR/$NODE_NAME +EXE_DIR=$BUILD_DIR/bin +CFG_DIR=$NODE_DIR/cfg +LOG_DIR=$NODE_DIR/log +DATA_DIR=$NODE_DIR/data +MGMT_DIR=$NODE_DIR/data/mgmt +TSDB_DIR=$NODE_DIR/data/tsdb + +TAOS_CFG=$NODE_DIR/cfg/taos.cfg + +echo ------------ $EXEC_OPTON $NODE_NAME + +TAOS_FLAG=$SIM_DIR/tsim/flag +if [ -f "$TAOS_FLAG" ]; then + EXE_DIR=/usr/local/bin/taos +fi + +if [ "$CLEAR_OPTION" = "clear" ]; then + echo rm -rf $MGMT_DIR $TSDB_DIR + rm -rf $TSDB_DIR + rm -rf $MGMT_DIR +fi + +if [ "$EXEC_OPTON" = "start" ]; then + echo "ExcuteCmd:" $EXE_DIR/taosd -c $CFG_DIR + + if [ "$SHELL_OPTION" = "true" ]; then + TT=`date +%s` + mkdir ${LOG_DIR}/${TT} + nohup valgrind --log-file=${LOG_DIR}/${TT}/valgrind.log --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes $EXE_DIR/taosd -c $CFG_DIR > /dev/null 2>&1 & + else + nohup $EXE_DIR/taosd -c $CFG_DIR --alloc-random-fail \ + --random-file-fail-factor 5 > /dev/null 2>&1 & + fi + +else + #relative path + RCFG_DIR=sim/$NODE_NAME/cfg + PID=`ps -ef|grep taosd | grep $RCFG_DIR | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + if [ "$SIGNAL" = "SIGKILL" ]; then + echo try to kill by signal SIGKILL + kill -9 $PID + else + echo try to kill by signal SIGINT + kill -SIGINT $PID + fi + sleep 1 + PID=`ps -ef|grep taosd | grep $RCFG_DIR | grep -v grep | awk '{print $2}'` + done +fi + diff --git a/tests/script/sh/exec.bat b/tests/script/sh/exec.bat new file mode 100644 index 0000000000000000000000000000000000000000..6651c7aa8f726d5d42d52a4c8f3a9395e7a12151 --- /dev/null +++ b/tests/script/sh/exec.bat @@ -0,0 +1,48 @@ +@echo off + +rem echo Executing exec.sh + +if %1 == -n set NODE_NAME=%2 +if %1 == -s set EXEC_OPTON=%2 +if %3 == -n set NODE_NAME=%4 +if %3 == -s set EXEC_OPTON=%4 + +rem echo NODE_NAME: %NODE_NAME% +rem echo NODE: %EXEC_OPTON% + +set SCRIPT_DIR=%~dp0..\ +rem echo SCRIPT_DIR: %SCRIPT_DIR% + +set BUILD_DIR=%SCRIPT_DIR%..\..\..\debug\build\bin\ +set TAOSD=%BUILD_DIR%taosd +rem echo BUILD_DIR: %BUILD_DIR% +rem echo TAOSD: %TAOSD% + +set SIM_DIR=%SCRIPT_DIR%..\..\..\sim\ +rem echo SIM_DIR: %SIM_DIR% + +set NODE_DIR=%SIM_DIR%%NODE_NAME%\ +rem echo NODE_DIR: %NODE_DIR% + +set CFG_DIR=%NODE_DIR%cfg\ +rem echo CFG_DIR: %CFG_DIR% + +set TAOS_CFG=%CFG_DIR%taos.cfg +rem echo TAOS_CFG: %TAOS_CFG% + +if %EXEC_OPTON% == start ( + echo start %TAOSD% -c %CFG_DIR% + start %TAOSD% -c %CFG_DIR% +) + +if %EXEC_OPTON% == stop ( + rem echo wmic process where "name='taosd.exe' and CommandLine like '%%%NODE_NAME%%%'" list INSTANCE + rem wmic process where "name='taosd.exe' and CommandLine like '%%%NODE_NAME%%%'" call terminate > NUL 2>&1 + + for /f "tokens=1 skip=1" %%A in ( + 'wmic process where "name='taosd.exe' and CommandLine like '%%%NODE_NAME%%%'" get processId ' + ) do ( + rem echo taskkill /IM %%A + taskkill /IM %%A > NUL 2>&1 + ) +) diff --git a/tests/script/sh/exec.sh b/tests/script/sh/exec.sh new file mode 100755 index 0000000000000000000000000000000000000000..80b8cda428da72daf55fc6e0d4c47867ce191d35 --- /dev/null +++ b/tests/script/sh/exec.sh @@ -0,0 +1,124 @@ +#!/bin/bash + +# if [ $# != 4 || $# != 5 ]; then + # echo "argument list need input : " + # echo " -n nodeName" + # echo " -s start/stop" + # echo " -c clear" + # exit 1 +# fi + +UNAME_BIN=`which uname` +OS_TYPE=`$UNAME_BIN` + +NODE_NAME= +EXEC_OPTON= +CLEAR_OPTION="false" +while getopts "n:s:u:x:ct" arg +do + case $arg in + n) + NODE_NAME=$OPTARG + ;; + s) + EXEC_OPTON=$OPTARG + ;; + c) + CLEAR_OPTION="clear" + ;; + t) + SHELL_OPTION="true" + ;; + u) + USERS=$OPTARG + ;; + x) + SIGNAL=$OPTARG + ;; + ?) + echo "unkown argument" + ;; + esac +done + +SCRIPT_DIR=`dirname $0` +cd $SCRIPT_DIR/../ +SCRIPT_DIR=`pwd` + +IN_TDINTERNAL="community" +if [[ "$SCRIPT_DIR" == *"$IN_TDINTERNAL"* ]]; then + cd ../../.. +else + cd ../../ +fi + +TAOS_DIR=`pwd` +TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1` + +if [[ "$OS_TYPE" != "Darwin" ]]; then + cut_opt="--field=" +else + cut_opt="-f " +fi + +if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then + BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3` +else + BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2` +fi + +BUILD_DIR=$TAOS_DIR/$BIN_DIR/build + +SIM_DIR=$TAOS_DIR/sim +NODE_DIR=$SIM_DIR/$NODE_NAME +EXE_DIR=$BUILD_DIR/bin +CFG_DIR=$NODE_DIR/cfg +LOG_DIR=$NODE_DIR/log +DATA_DIR=$NODE_DIR/data +MGMT_DIR=$NODE_DIR/data/mgmt +TSDB_DIR=$NODE_DIR/data/tsdb + +TAOS_CFG=$NODE_DIR/cfg/taos.cfg + +echo ------------ $EXEC_OPTON $NODE_NAME + +TAOS_FLAG=$SIM_DIR/tsim/flag +if [ -f "$TAOS_FLAG" ]; then + EXE_DIR=/usr/local/bin/taos +fi + +if [ "$CLEAR_OPTION" = "clear" ]; then + echo rm -rf $MGMT_DIR $TSDB_DIR + rm -rf $TSDB_DIR + rm -rf $MGMT_DIR +fi + +if [ "$EXEC_OPTON" = "start" ]; then + echo "ExcuteCmd:" $EXE_DIR/taosd -c $CFG_DIR + + if [ "$SHELL_OPTION" = "true" ]; then + TT=`date +%s` + mkdir ${LOG_DIR}/${TT} + nohup valgrind --log-file=${LOG_DIR}/${TT}/valgrind.log --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes $EXE_DIR/taosd -c $CFG_DIR > /dev/null 2>&1 & + else + nohup $EXE_DIR/taosd -c $CFG_DIR > /dev/null 2>&1 & + fi + +else + #relative path + RCFG_DIR=sim/$NODE_NAME/cfg + PID=`ps -ef|grep taosd | grep $RCFG_DIR | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + if [ "$SIGNAL" = "SIGKILL" ]; then + echo try to kill by signal SIGKILL + kill -9 $PID + else + echo try to kill by signal SIGINT + kill -SIGINT $PID + fi + sleep 1 + PID=`ps -ef|grep taosd | grep $RCFG_DIR | grep -v grep | awk '{print $2}'` + done +fi + diff --git a/tests/script/sh/exec_tarbitrator.sh b/tests/script/sh/exec_tarbitrator.sh new file mode 100755 index 0000000000000000000000000000000000000000..e985bd65856025b2db8dfef724fdc652b2a03392 --- /dev/null +++ b/tests/script/sh/exec_tarbitrator.sh @@ -0,0 +1,86 @@ +#!/bin/bash + +# if [ $# != 2 || $# != 3 ]; then + # echo "argument list need input : " + # echo " -s start/stop" + # exit 1 +# fi + +UNAME_BIN=`which uname` +OS_TYPE=`$UNAME_BIN` +EXEC_OPTON= +while getopts "n:s:u:x:ct" arg +do + case $arg in + n) + NODE_NAME=$OPTARG + ;; + s) + EXEC_OPTON=$OPTARG + ;; + c) + CLEAR_OPTION="clear" + ;; + t) + SHELL_OPTION="true" + ;; + u) + USERS=$OPTARG + ;; + x) + SIGNAL=$OPTARG + ;; + ?) + echo "unkown argument" + ;; + esac +done + + +SCRIPT_DIR=`dirname $0` +cd $SCRIPT_DIR/../ +SCRIPT_DIR=`pwd` + +IN_TDINTERNAL="community" +if [[ "$SCRIPT_DIR" == *"$IN_TDINTERNAL"* ]]; then + cd ../../.. +else + cd ../../ +fi + +TAOS_DIR=`pwd` +TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1` + +if [[ "$OS_TYPE" != "Darwin" ]]; then + cut_opt="--field=" +else + cut_opt="-f " +fi + +if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then + BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3` +else + BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2` +fi + +BUILD_DIR=$TAOS_DIR/$BIN_DIR/build + +SIM_DIR=$TAOS_DIR/sim +NODE_DIR=$SIM_DIR/arbitrator +EXE_DIR=$BUILD_DIR/bin +LOG_DIR=$NODE_DIR/log + +echo "------------ $EXEC_OPTON tarbitrator" + +if [ "$EXEC_OPTON" = "start" ]; then + echo "------------ log path: $LOG_DIR" + nohup $EXE_DIR/tarbitrator -p 8000 -d 135 -g $LOG_DIR > /dev/null 2>&1 & +else + #relative path + PID=`ps -ef|grep tarbitrator | grep -v grep | awk '{print $2}'` + if [ -n "$PID" ]; then + kill -9 $PID + pkill -9 tarbitrator + fi +fi + diff --git a/tests/script/sh/ip.sh b/tests/script/sh/ip.sh new file mode 100755 index 0000000000000000000000000000000000000000..9a0cde163a78cdd691724b3e1faf15aa7b48d456 --- /dev/null +++ b/tests/script/sh/ip.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +#already create real card, such as 192.168.0.1-5 +#exit 0 + +if [ $# != 4 ]; then + echo "argument list need input : " + echo " -i if use [192.168.0.70 ] then input [70]" + echo " -s up/down" + exit 1 +fi + +#just create ip like 192.168.0.* + +IP_ADDRESS= +EXEC_OPTON= +while getopts "i:s:" arg +do + case $arg in + i) + IP_ADDRESS=$OPTARG + ;; + s) + EXEC_OPTON=$OPTARG + ;; + ?) + echo "unkonw argument" + ;; + esac +done + +echo ============ $EXEC_OPTON $IP_ADDRESS =========== +sudo ifconfig lo:$IP_ADDRESS 192.168.0.$IP_ADDRESS $EXEC_OPTON diff --git a/tests/script/sh/move_dnode.sh b/tests/script/sh/move_dnode.sh new file mode 100755 index 0000000000000000000000000000000000000000..d3650c18ad0f49185ce1e1268273b8a44e3cdc14 --- /dev/null +++ b/tests/script/sh/move_dnode.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +echo "Executing move_dnode.sh" + +UNAME_BIN=`which uname` +OS_TYPE=`$UNAME_BIN` + +SCRIPT_DIR=`dirname $0` +cd $SCRIPT_DIR/../ +SCRIPT_DIR=`pwd` +echo "SCRIPT_DIR: $SCRIPT_DIR" + +IN_TDINTERNAL="community" +if [[ "$SCRIPT_DIR" == *"$IN_TDINTERNAL"* ]]; then + cd ../../.. +else + cd ../../ +fi + +TAOS_DIR=`pwd` +TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1` + +if [[ "$OS_TYPE" != "Darwin" ]]; then + cut_opt="--field=" +else + cut_opt="-f " +fi + +if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then + BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3` +else + BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2` +fi + +BUILD_DIR=$TAOS_DIR/$BIN_DIR/build + +SIM_DIR=$TAOS_DIR/sim + +NODE_DIR=$SIM_DIR/$NODE_NAME + +if [ -d "$SIM_DIR/$2" ];then + rm -rf $SIM_DIR/$2 +fi +mv $SIM_DIR/$1 $SIM_DIR/$2 + +if [[ $2 =~ "dnode2" ]];then + sed -i 's/serverPort 7100/serverPort 7200/g' $SIM_DIR/$2/cfg/taos.cfg + sed -i 's/dnode1/dnode2/g' $SIM_DIR/$2/cfg/taos.cfg + sed -i 's/7100/7200/g' $SIM_DIR/$2/data/dnode/dnodeEps.json +elif [[ $2 =~ "dnode4" ]];then + sed -i 's/serverPort 7100/serverPort 7400/g' $SIM_DIR/$2/cfg/taos.cfg + sed -i 's/dnode1/dnode4/g' $SIM_DIR/$2/cfg/taos.cfg + sed -i 's/7100/7400/g' $SIM_DIR/dnode2/data/dnode/dnodeEps.json + sed -i 's/7100/7400/g' $SIM_DIR/dnode3/data/dnode/dnodeEps.json + sed -i 's/7100/7400/g' $SIM_DIR/$2/data/dnode/dnodeEps.json +fi diff --git a/tests/script/sh/mv_old_data.sh b/tests/script/sh/mv_old_data.sh new file mode 100755 index 0000000000000000000000000000000000000000..3f4be6714fd757ee60d21ee97be5d411e3f95bdd --- /dev/null +++ b/tests/script/sh/mv_old_data.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +echo "Executing mv_old_data.sh" + +UNAME_BIN=`which uname` +OS_TYPE=`$UNAME_BIN` + +SCRIPT_DIR=`dirname $0` +cd $SCRIPT_DIR/../ +SCRIPT_DIR=`pwd` +echo "SCRIPT_DIR: $SCRIPT_DIR" + +IN_TDINTERNAL="community" +if [[ "$SCRIPT_DIR" == *"$IN_TDINTERNAL"* ]]; then + cd ../../.. +else + cd ../../ +fi + +TAOS_DIR=`pwd` +TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1` + +if [[ "$OS_TYPE" != "Darwin" ]]; then + cut_opt="--field=" +else + cut_opt="-f " +fi + +if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then + BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3` +else + BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2` +fi + +BUILD_DIR=$TAOS_DIR/$BIN_DIR/build + +SIM_DIR=$TAOS_DIR/sim + +NODE_DIR=$SIM_DIR/$NODE_NAME + +rm -rf $SIM_DIR/dnode1 +rm -rf $SIM_DIR/dnode2 +rm -rf $SIM_DIR/dnode3 + +tar zxf $SCRIPT_DIR/general/connection/sim.tar.gz -C $SIM_DIR/../ +cd $SIM_DIR/../sim +fqdn=`hostname -f || hostname` +grep 'test4' -l -r ./* | xargs sed -i "s/test4/${fqdn}/g" +grep 'dataDir' -l -r ./* | xargs sed -i "s#/root/TDengine#${TAOS_DIR}#g" diff --git a/tests/script/sh/prepare_udf.sh b/tests/script/sh/prepare_udf.sh new file mode 100755 index 0000000000000000000000000000000000000000..c197ccfa974c62375a265923840fab277819bd3a --- /dev/null +++ b/tests/script/sh/prepare_udf.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +echo -n "hello" > /tmp/normal +echo -n "" > /tmp/empty +dd if=/dev/zero bs=3584 of=/tmp/big count=1 + +rm -rf /tmp/sum_double.so /tmp/add_one.so +touch /tmp/normal + +gcc -g -O0 -fPIC -shared sh/sum_double.c -o /tmp/sum_double.so +gcc -g -O0 -fPIC -shared sh/add_one.c -o /tmp/add_one.so +gcc -g -O0 -fPIC -shared sh/add_one_64232.c -o /tmp/add_one_64232.so +gcc -g -O0 -fPIC -shared sh/sub_one.c -o /tmp/sub_one.so +gcc -g -O0 -fPIC -shared sh/demo.c -o /tmp/demo.so +gcc -g -O0 -fPIC -shared sh/abs_max.c -o /tmp/abs_max.so diff --git a/tests/script/sh/scalar_demo.lua b/tests/script/sh/scalar_demo.lua new file mode 100644 index 0000000000000000000000000000000000000000..cecaff90b01534316821b0a025a3fc66f9b219cf --- /dev/null +++ b/tests/script/sh/scalar_demo.lua @@ -0,0 +1,14 @@ +funcName = "test" + +ans = 1 + +function test_init() + return ans +end + +function test_add(rows, ans) + for i=1, #rows do + rows[i] = rows[i] + ans + end + return rows +end diff --git a/tests/script/sh/stop_dnodes.bat b/tests/script/sh/stop_dnodes.bat new file mode 100644 index 0000000000000000000000000000000000000000..ab7af2ca92023745b8b712cb78e9b168a6c00598 --- /dev/null +++ b/tests/script/sh/stop_dnodes.bat @@ -0,0 +1,6 @@ +@echo off + +rem echo taskkill /F /IM taosd.exe + +wmic process where "name='taosd.exe'" call terminate > NUL 2>&1 +taskkill /F /IM taosd.exe > NUL 2>&1 \ No newline at end of file diff --git a/tests/script/sh/stop_dnodes.sh b/tests/script/sh/stop_dnodes.sh new file mode 100755 index 0000000000000000000000000000000000000000..4c6d8e03510a39c2d5d1d020b5cfe7dabee39cb0 --- /dev/null +++ b/tests/script/sh/stop_dnodes.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +UNAME_BIN=`which uname` +OS_TYPE=`$UNAME_BIN` + +PID=`ps -ef|grep /usr/bin/taosd | grep -v grep | awk '{print $2}'` +if [ -n "$PID" ]; then + echo systemctl stop taosd + systemctl stop taosd +fi + +PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` +while [ -n "$PID" ]; do + echo kill -9 $PID + pkill -9 taosd + echo "Killing processes locking on port 6030" + if [ "$OS_TYPE" != "Darwin" ]; then + fuser -k -n tcp 6030 + else + lsof -nti:6030 | xargs kill -9 + fi + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` +done + +PID=`ps -ef|grep -w tarbitrator | grep -v grep | awk '{print $2}'` +while [ -n "$PID" ]; do + echo kill -9 $PID + pkill -9 tarbitrator + if [ "$OS_TYPE" != "Darwin" ]; then + fuser -k -n tcp 6040 + else + lsof -nti:6040 | xargs kill -9 + fi + PID=`ps -ef|grep -w tarbitrator | grep -v grep | awk '{print $2}'` +done + diff --git a/tests/script/sh/sub_one.c b/tests/script/sh/sub_one.c new file mode 100644 index 0000000000000000000000000000000000000000..f901dd72b93fb93986be1c55811b6d728dd6731d --- /dev/null +++ b/tests/script/sh/sub_one.c @@ -0,0 +1,33 @@ +#include +#include +#include + +typedef struct SUdfInit{ + int maybe_null; /* 1 if function can return NULL */ + int decimals; /* for real functions */ + long long length; /* For string functions */ + char *ptr; /* free pointer for function data */ + int const_item; /* 0 if result is independent of arguments */ +} SUdfInit; + +void sub_one(char* data, short itype, short ibytes, int numOfRows, long long* ts, char* dataOutput, char* interBUf, char* tsOutput, + int* numOfOutput, short otype, short obytes, SUdfInit* buf) { + int i; + int r = 0; + printf("sub_one input data:%p, type:%d, rows:%d, ts:%p,%lld, dataoutput:%p, tsOutput:%p, numOfOutput:%p, buf:%p\n", data, itype, numOfRows, ts, *ts, dataOutput, tsOutput, numOfOutput, buf); + if (itype == 4) { + for(i=0;i +#include +#include +#include + +typedef struct SUdfInit{ + int maybe_null; /* 1 if function can return NULL */ + int decimals; /* for real functions */ + int64_t length; /* For string functions */ + char *ptr; /* free pointer for function data */ + int const_item; /* 0 if result is independent of arguments */ +} SUdfInit; + +#define TSDB_DATA_INT_NULL 0x80000000L + + +void sum_double(char* data, short itype, short ibytes, int numOfRows, int64_t* ts, char* dataOutput, char* interBuf, char* tsOutput, + int* numOfOutput, short otype, short obytes, SUdfInit* buf) { + int i; + int64_t r = 0; + printf("sum_double input data:%p, type:%d, rows:%d, ts:%p,%"PRId64", dataoutput:%p, tsOutput:%p, numOfOutput:%p, buf:%p\n", data, itype, numOfRows, ts, *ts, dataOutput, tsOutput, numOfOutput, buf); + if (itype == 4) { + r=*(int64_t *)dataOutput; + *numOfOutput=0; + + for(i=0;iptr)=*(int64_t*)dataOutput*2; + *(int64_t*)dataOutput=*(int64_t*)(buf->ptr); + // printf("sum_double finalize, dataoutput:%"PRId64", numOfOutput:%d\n", *(int64_t *)dataOutput, *numOfOutput); +} + +void sum_double_merge(char* data, int32_t numOfRows, char* dataOutput, int* numOfOutput, SUdfInit* buf) { + int r = 0; + int64_t sum = 0; + + // printf("sum_double_merge numOfRows:%d, dataoutput:%p, buf:%p\n", numOfRows, dataOutput, buf); + for (int i = 0; i < numOfRows; ++i) { + // printf("sum_double_merge %d - %"PRId64"\n", i, *((int64_t*)data + i)); + sum +=*((int64_t*)data + i); + } + + *(int64_t*)dataOutput+=sum; + if (numOfRows > 0) { + *numOfOutput=1; + } else { + *numOfOutput=0; + } + + // printf("sum_double_merge, dataoutput:%"PRId64", numOfOutput:%d\n", *(int64_t *)dataOutput, *numOfOutput); +} + + +int sum_double_init(SUdfInit* buf) { + buf->maybe_null=1; + buf->ptr = malloc(sizeof(int64_t)); + // printf("sum_double init\n"); + return 0; +} + + +void sum_double_destroy(SUdfInit* buf) { + free(buf->ptr); + // printf("sum_double destroy\n"); +} \ No newline at end of file diff --git a/tests/script/test.sh b/tests/script/test.sh new file mode 100755 index 0000000000000000000000000000000000000000..29a15db4dc953818afa6de9abb3f4f8edc42173d --- /dev/null +++ b/tests/script/test.sh @@ -0,0 +1,150 @@ +#!/bin/bash + +################################################## +# +# Do simulation test +# +################################################## + +set +e +#set -x + +FILE_NAME= +RELEASE=0 +ASYNC=0 +VALGRIND=0 +UNIQUE=0 +UNAME_BIN=`which uname` +OS_TYPE=`$UNAME_BIN` +while getopts "f:avu" arg +do + case $arg in + f) + FILE_NAME=$OPTARG + ;; + a) + ASYNC=1 + ;; + v) + VALGRIND=1 + ;; + u) + UNIQUE=1 + ;; + ?) + echo "unknow argument" + ;; + esac +done + +cd . + +# Get responsible directories +CODE_DIR=`dirname $0` +CODE_DIR=`pwd` + +IN_TDINTERNAL="community" +if [[ "$CODE_DIR" == *"$IN_TDINTERNAL"* ]]; then + cd ../../.. +else + cd ../../ +fi + +TOP_DIR=`pwd` +TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1` + +if [[ "$OS_TYPE" != "Darwin" ]]; then + cut_opt="--field=" +else + cut_opt="-f " +fi + +if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then + BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3` +else + BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2` +fi + +BUILD_DIR=$TOP_DIR/$BIN_DIR/build + +SIM_DIR=$TOP_DIR/sim + +if [ $ASYNC -eq 0 ]; then + PROGRAM=$BUILD_DIR/bin/tsim +else + PROGRAM="$BUILD_DIR/bin/tsim -a" +fi + + +PRG_DIR=$SIM_DIR/tsim +CFG_DIR=$PRG_DIR/cfg +LOG_DIR=$PRG_DIR/log +DATA_DIR=$PRG_DIR/data + + +ARBITRATOR_PRG_DIR=$SIM_DIR/arbitrator +ARBITRATOR_LOG_DIR=$ARBITRATOR_PRG_DIR/log + + +chmod -R 777 $PRG_DIR +echo "------------------------------------------------------------------------" +echo "Start TDengine Testing Case ..." +echo "BUILD_DIR: $BUILD_DIR" +echo "SIM_DIR : $SIM_DIR" +echo "CODE_DIR : $CODE_DIR" +echo "CFG_DIR : $CFG_DIR" + +rm -rf $LOG_DIR +rm -rf $CFG_DIR +rm -rf $ARBITRATOR_LOG_DIR + +mkdir -p $PRG_DIR +mkdir -p $LOG_DIR +mkdir -p $CFG_DIR +mkdir -p $ARBITRATOR_LOG_DIR + +TAOS_CFG=$PRG_DIR/cfg/taos.cfg +touch -f $TAOS_CFG +TAOS_FLAG=$PRG_DIR/flag + +HOSTNAME=`hostname -f` + +echo " " >> $TAOS_CFG +echo "firstEp ${HOSTNAME}:7100" >> $TAOS_CFG +echo "secondEp ${HOSTNAME}:7200" >> $TAOS_CFG +echo "serverPort 7100" >> $TAOS_CFG +echo "dataDir $DATA_DIR" >> $TAOS_CFG +echo "logDir $LOG_DIR" >> $TAOS_CFG +echo "scriptDir ${CODE_DIR}/../script" >> $TAOS_CFG +echo "numOfLogLines 100000000" >> $TAOS_CFG +echo "rpcDebugFlag 143" >> $TAOS_CFG +echo "tmrDebugFlag 131" >> $TAOS_CFG +echo "cDebugFlag 143" >> $TAOS_CFG +echo "udebugFlag 143" >> $TAOS_CFG +echo "wal 0" >> $TAOS_CFG +echo "asyncLog 0" >> $TAOS_CFG +echo "locale en_US.UTF-8" >> $TAOS_CFG +echo "enableCoreFile 1" >> $TAOS_CFG +echo " " >> $TAOS_CFG + +ulimit -n 600000 +ulimit -c unlimited + +#sudo sysctl -w kernel.core_pattern=$TOP_DIR/core.%p.%e + +if [ -n "$FILE_NAME" ]; then + echo "------------------------------------------------------------------------" + if [ $VALGRIND -eq 1 ]; then + echo valgrind --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes --log-file=${CODE_DIR}/../script/valgrind.log $PROGRAM -c $CFG_DIR -f $FILE_NAME + valgrind --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes --log-file=${CODE_DIR}/../script/valgrind.log $PROGRAM -c $CFG_DIR -f $FILE_NAME + else + echo "ExcuteCmd:" $PROGRAM -c $CFG_DIR -f $FILE_NAME + $PROGRAM -c $CFG_DIR -f $FILE_NAME +# valgrind --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes --log-file=${CODE_DIR}/../script/valgrind.log $PROGRAM -c $CFG_DIR -f $FILE_NAME + fi +else + echo "ExcuteCmd:" $PROGRAM -c $CFG_DIR -f basicSuite.sim + echo "------------------------------------------------------------------------" + $PROGRAM -c $CFG_DIR -f basicSuite.sim +fi + diff --git a/tests/script/tjenkins b/tests/script/tjenkins new file mode 100755 index 0000000000000000000000000000000000000000..9b93527de97f29f84e2b1e6b2ec2ab4a621f6709 Binary files /dev/null and b/tests/script/tjenkins differ diff --git a/tests/script/tmp/182.sim b/tests/script/tmp/182.sim new file mode 100644 index 0000000000000000000000000000000000000000..a178282cf835b236a202c71f1ef5a595e784324c --- /dev/null +++ b/tests/script/tmp/182.sim @@ -0,0 +1,41 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c activeCode -v eglxDLzRpslJWl7OxrPZ2K3sQ5631AP9SVpezsaz2dhJWl7OxrPZ2ElaXs7Gs9nYSVpezsaz2djGIj5StnQ3ZvLHcsE8cwcN + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 100000 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 100000 +system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 100000 +system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 100000 + +system sh/cfg.sh -n dnode1 -c http -v 1 +system sh/cfg.sh -n dnode2 -c http -v 1 +system sh/cfg.sh -n dnode3 -c http -v 1 +system sh/cfg.sh -n dnode4 -c http -v 1 + +system sh/cfg.sh -n dnode1 -c httpMaxThreads -v 4 + +system sh/cfg.sh -n dnode1 -c firstEp -v 127.0.0.1:6030 +system sh/cfg.sh -n dnode1 -c secondEp -v 127.0.0.1:6030 +system sh/cfg.sh -n dnode1 -c serverPort -v 6030 +system sh/cfg.sh -n dnode1 -c fqdn -v 127.0.0.1 +system sh/exec.sh -n dnode1 -s start diff --git a/tests/script/tmp/http.sim b/tests/script/tmp/http.sim new file mode 100644 index 0000000000000000000000000000000000000000..a5212905aed8558bb47983227e16ac6341fd8945 --- /dev/null +++ b/tests/script/tmp/http.sim @@ -0,0 +1,35 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c http -v 1 +system sh/cfg.sh -n dnode2 -c http -v 1 +system sh/cfg.sh -n dnode3 -c http -v 1 + +system sh/cfg.sh -n dnode1 -c monitor -v 1 +system sh/cfg.sh -n dnode2 -c monitor -v 1 +system sh/cfg.sh -n dnode3 -c monitor -v 1 + +system sh/cfg.sh -n dnode1 -c monitorInterval -v 1 +system sh/cfg.sh -n dnode2 -c monitorInterval -v 1 +system sh/cfg.sh -n dnode3 -c monitorInterval -v 1 + +system sh/exec.sh -n dnode1 -s start \ No newline at end of file diff --git a/tests/script/tmp/mnodes.sim b/tests/script/tmp/mnodes.sim new file mode 100644 index 0000000000000000000000000000000000000000..8bca76c38b627ac6a6aa9eaae07a9126a9b19057 --- /dev/null +++ b/tests/script/tmp/mnodes.sim @@ -0,0 +1,115 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c http -v 0 +system sh/cfg.sh -n dnode2 -c http -v 0 +system sh/cfg.sh -n dnode3 -c http -v 0 + +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 20000 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 20000 +system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 20000 + +system sh/cfg.sh -n dnode1 -c minTablesPerVnode -v 1000 +system sh/cfg.sh -n dnode2 -c minTablesPerVnode -v 1000 +system sh/cfg.sh -n dnode3 -c minTablesPerVnode -v 1000 + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 20 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 20 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 20 + +system sh/cfg.sh -n dnode1 -c replica -v 3 +system sh/cfg.sh -n dnode2 -c replica -v 3 +system sh/cfg.sh -n dnode3 -c replica -v 3 + +print ============== deploy + +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create dnode $hostname2 +sql create dnode $hostname3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start + +print =============== step1 +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 + +if $data4_1 != ready then + goto step1 +endi +if $data4_2 != ready then + goto step1 +endi +if $data4_3 != ready then + goto step1 +endi + +sql show mnodes +$mnode1Role = $data2_1 +print mnode1Role $mnode1Role +$mnode2Role = $data2_2 +print mnode2Role $mnode2Role +$mnode3Role = $data2_3 +print mnode3Role $mnode3Role + +if $mnode1Role != master then + goto step1 +endi +if $mnode2Role != slave then + goto step1 +endi +if $mnode3Role != slave then + goto step1 +endi + +$x = 1 +show2: + +print =============== step $x +sql show mnodes +print $data0_1 $data2_1 + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 + +if $data4_1 != ready then + goto step1 +endi +if $data4_2 != ready then + goto step1 +endi +if $data4_3 != ready then + goto step1 +endi + +$x = $x + 1 +sleep 3000 +if $x == 100000 then + return -1 +endi + +goto show2 diff --git a/tests/script/tmp/prepare.sim b/tests/script/tmp/prepare.sim new file mode 100644 index 0000000000000000000000000000000000000000..343c422e9ff772c10f22539fb012fbf38241f91d --- /dev/null +++ b/tests/script/tmp/prepare.sim @@ -0,0 +1,49 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c activeCode -v eglxDLzRpslJWl7OxrPZ2K3sQ5631AP9SVpezsaz2dhJWl7OxrPZ2ElaXs7Gs9nYSVpezsaz2djGIj5StnQ3ZvLHcsE8cwcN + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 100000 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 100000 +system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 100000 +system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 100000 + +system sh/cfg.sh -n dnode1 -c http -v 1 +system sh/cfg.sh -n dnode2 -c http -v 1 +system sh/cfg.sh -n dnode3 -c http -v 1 +system sh/cfg.sh -n dnode4 -c http -v 1 + +return +# for crash_gen +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 10 +system sh/cfg.sh -n dnode1 -c rpcMaxTime -v 101 +system sh/cfg.sh -n dnode1 -c cache -v 2 +system sh/cfg.sh -n dnode1 -c keep -v 36500 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 + + +# for windows + +system sh/cfg.sh -n dnode1 -c firstEp -v 152.136.17.116:6030 +system sh/cfg.sh -n dnode1 -c secondEp -v 152.136.17.116:6030 +system sh/cfg.sh -n dnode1 -c serverPort -v 6030 +system sh/cfg.sh -n dnode1 -c fqdn -v 152.136.17.116 diff --git a/tests/script/unique/account/account_create.sim b/tests/script/unique/account/account_create.sim new file mode 100644 index 0000000000000000000000000000000000000000..e36de29e7c5835ddc78a9f3eab4b2b4d34634c42 --- /dev/null +++ b/tests/script/unique/account/account_create.sim @@ -0,0 +1,80 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ============================ dnode1 start + +$i = 0 +$dbPrefix = acdb +$tbPrefix = actb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +$accountPrefix = acac + +print =============== step1-4 +sql show accounts +if $rows != 1 then + return -1 +endi +sql show users +if $rows != 3 then + return -1 +endi + +$i = 0 +$acc = $accountPrefix . $i +sql_error create account $acc PASS pass123 +sql create account $acc PASS 'pass123' +#sql create account $acc PASS 'pass123' -x step1 +# return -1 +#step1: +sql create user $acc PASS 'pass123' -x step2 + return -1 +step2: + +sql show accounts +if $rows != 2 then + return -1 +endi + +sql show users +if $rows != 3 then + return -1 +endi + +print =============== step5-6 +sql drop account $acc +sql drop account $acc -x step5 + return -1 +step5: +sql show accounts +if $rows != 1 then + return -1 +endi +sql show users +if $rows != 3 then + return -1 +endi + +print =============== step7 +sql create account $acc PASS 'pass123' +#sql create account $acc PASS 'pass123' -x step7 +# return -1 +#step7: + +sql show accounts +if $rows != 2 then + return -1 +endi + +sql drop account $acc +sql show accounts +if $rows != 1 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/account/account_delete.sim b/tests/script/unique/account/account_delete.sim new file mode 100644 index 0000000000000000000000000000000000000000..d99a8b559dc6e04e4d6996e042d915671781d699 --- /dev/null +++ b/tests/script/unique/account/account_delete.sim @@ -0,0 +1,99 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ============= step1 +sql create account oroot pass 'taosdata' +sql close +sql connect oroot +sleep 2000 + +print ============= step2 +sql create user read pass 'taosdata' +sql create user write pass 'taosdata' + +sql create database d1 +sql create database d2 +sql create table d1.t1 (ts timestamp, i int) +sql create table d2.t2 (ts timestamp, i int) +sql insert into d1.t1 values(now, 1) +sql insert into d2.t2 values(now, 1) +sql insert into d2.t2 values(now+1s, 2) + +sql show databases +if $rows != 2 then + return -1 +endi +sql show users +if $rows != 4 then + return -1 +endi +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi +sql select * from d2.t2 +if $rows != 2 then + return -1 +endi + +print ============= step3 +sql close +sql connect +sleep 2000 + +sql show databases +if $rows != 0 then + return -1 +endi +sql show dnodes +print $data00 $data01 $data02 $data03 +if $data02 != 2 then + return -1 +endi +sql drop account oroot + +print ============= step4 +$x = 0 +show4: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show dnodes +if $data02 != 0 then + goto show4 +endi + +print ============= step5 +sql create account oroot pass 'taosdata' + +sql close +sql connect oroot +sleep 2000 + +sql show databases +if $rows != 0 then + return -1 +endi +sql show users +if $rows != 2 then + return -1 +endi + +sql close +sql connect +sleep 2000 +sql drop account oroot +sql show accounts +if $rows != 1 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/account/account_len.sim b/tests/script/unique/account/account_len.sim new file mode 100644 index 0000000000000000000000000000000000000000..f8379bdf954bdde122e68585b973f4957ef15739 --- /dev/null +++ b/tests/script/unique/account/account_len.sim @@ -0,0 +1,92 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$i = 0 +$dbPrefix = aldb +$tbPrefix = altb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop account ac -x step0 + return -1 +step0: + +sql create account PASS 123 -x step1 + return -1 +step1: + +sql show accounts +if $rows != 1 then + return -1 +endi + +print =============== step2 +sql drop account a -x step2 +step2: +sql create account a PASS '123' +sql show accounts +if $rows != 2 then + return -1 +endi + +sql drop account a +sql show accounts +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql drop account abc01234567890123456789 -x step3 +step3: +sql create account abc01234567890123456789 PASS '123' +sql show accounts +if $rows != 2 then + return -1 +endi + +sql drop account abc01234567890123456789 +sql show accounts +if $rows != 1 then + return -1 +endi + +print =============== step4 +sql create account abcd01234567890123456789012345689012345 PASS '123' -x step4 + return -1 +step4: +sql show accounts +if $rows != 1 then + return -1 +endi + +print =============== step5 +sql drop account 123 -x step5 +step5: +sql create account 123 pass '123' -x step51 + return -1 +step51: + +sql create account a123 PASS '123' +sql show accounts +if $rows != 2 then + return -1 +endi + +sql drop account a123 +sql show accounts +if $rows != 1 then + return -1 +endi + +sql show users +if $rows != 3 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/account/authority.sim b/tests/script/unique/account/authority.sim new file mode 100644 index 0000000000000000000000000000000000000000..8f2408de1429a8ea34add79e335f6bf7f42ca2b0 --- /dev/null +++ b/tests/script/unique/account/authority.sim @@ -0,0 +1,346 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ============= step1 + +sql create user read pass 'taosdata' +sql create user write pass 'taosdata' +sql create user manage pass 'taosdata' + +sql create user a PASS 'ade' privilege -x step11 + return -1 +step11: + +sql create user a PASS 'ade' privilege a -x step12 + return -1 +step12: + +sql create user a PASS 'ade' privilege read -x step13 + return -1 +step13: + +sql show accounts +if $rows != 1 then + return -1 +endi +sql show users +if $rows != 6 then + return -1 +endi + +sql alter user read privilege read +sql alter user write privilege write +sql_error alter user manage privilege super + +print ============= step2 +sql close +sql connect write +sleep 2000 + +sql create database d1 +sql create database d2 +sql create table d1.t1 (ts timestamp, i int) +sql create table d2.t2 (ts timestamp, i int) +sql insert into d1.t1 values(now, 1) +sql insert into d2.t2 values(now, 1) +sql insert into d2.t2 values(now+1s, 2) + +sql show accounts +if $rows != 1 then + return -1 +endi +sql show users +if $rows != 6 then + return -1 +endi +sql show databases +if $rows != 2 then + return -1 +endi +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi +sql select * from d2.t2 +if $rows != 2 then + return -1 +endi + +sql create account t1 pass 'taosdata' -x step21 + return -1 +step21: + +sql create user t1 pass 'taosdata' -x step22 + return -1 +step22: + +sql alter user read pass 'taosdata' -x step23 + return -1 +step23: + +sql create dnode $hostname2 -x step24 + return -1 +step24: + +sql drop dnode $hostname2 -x step25 + return -1 +step25: + +sql create mnode 192.168.0.2 -x step26 + return -1 +step26: + +sql drop mnode 192.168.0.2 -x step27 + return -1 +step27: + +sql drop account root -x step28 + return -1 +step28: + +sql alter user write pass 'taosdata' + +print ============= step3 +sql close +sql connect read +sleep 2000 + +sql create database d3 -x step31 + return -1 +step31: + +sql create table d1.t3 (ts timestamp, i int) -x step32 + return -1 +step32: + +#sql insert into d1.t1 values(now, 2) -x step33 +# return -1 +#step33: + +sql show accounts +if $rows != 1 then + return -1 +endi +sql show users +if $rows != 6 then + return -1 +endi +sql show databases +if $rows != 2 then + return -1 +endi +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 2 then + return -1 +endi + +sql sql create account t1 pass 'taosdata' -x step34 + return -1 +step34: + +sql sql create user t1 pass 'taosdata' -x step35 + return -1 +step35: + +print ============= step4 +sql close +sql connect manage +sleep 2000 + +sql create database d3 +sql create database d4 +sql create table d3.t3 (ts timestamp, i int) +sql create table d4.t4 (ts timestamp, i int) + +sql show accounts +if $rows != 1 then + return -1 +endi +sql show users +if $rows != 6 then + return -1 +endi +sql show databases +if $rows != 4 then + return -1 +endi +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi +sql select * from d2.t2 +if $rows != 2 then + return -1 +endi + +sql create account other pass 'taosdata' -x step41 + return -1 +step41: + +sql close +sql connect +sleep 2000 +sql create account other pass 'taosdata' + +print ============= step5 +sql close +sql connect other +sleep 2000 +sql create user read pass 'taosdata' -x step51 + return -1 +step51: +sql create other write pass 'taosdata' -x step52 + return -1 +step52: + +sql create user oread pass 'taosdata' +sql create user owrite pass 'taosdata' +sql create user omanage pass 'taosdata' + +sql show users +print show users $rows +if $rows != 5 then + return -1 +endi + +sql alter user oread privilege read +sql alter user owrite privilege write +sql alter user oroot privilege super -x step53 + return -1 +step53: +sql alter user read privilege read -x step54 + return -1 +step54: + +print ============= step6 +sql close +sql connect owrite +sleep 2000 +sql reset query cache +sleep 1000 +sql create database d1 +sql create database d3 +sql create table d1.t1 (ts timestamp, i int) +sql create table d3.t3 (ts timestamp, i int) +sql insert into d1.t1 values(now, 11) +sql insert into d3.t3 values(now, 11) +sql insert into d3.t3 values(now+1s, 12) + +sql show databases +if $rows != 2 then + return -1 +endi +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi +sql select * from d2.t2 -x step6 + return -1 +step6: +sql select * from d3.t3 +if $rows != 2 then + return -1 +endi + +sql sql create account t1 pass 'taosdata' -x step61 + return -1 +step61: + +sql sql create user t1 pass 'taosdata' -x step62 + return -1 +step62: + +print ============= step7 +sql close +sql connect oread +sleep 2000 + +sql create database d7 -x step71 + return -1 +step71: + +sql show databases +if $rows != 2 then + return -1 +endi +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi +sql select * from d2.t2 -x step72 + return -1 +step72: +sql select * from d3.t3 +if $rows != 2 then + return -1 +endi + +sql sql create account t1 pass 'taosdata' -x step73 + return -1 +step73: + +sql sql create user t1 pass 'taosdata' -x step74 + return -1 +step74: + +print ============= step8 +sql close +sql connect omanage +sleep 2000 + +sql create account t1 pass 'taosdata' -x step81 + return -1 +step81: + +sql create database d4 +sql create table d4.t4 (ts timestamp, i int) + +sql show databases +if $rows != 3 then + return -1 +endi +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi +sql select * from d2.t2 -x step82 + return -1 +step82: +sql select * from d3.t3 +if $rows != 2 then + return -1 +endi + +print ============= step9 +sql close +sql connect +sleep 2000 +sql show databases +if $rows != 4 then + return -1 +endi + +sql drop account other +sql drop user read +sql drop user manage +sql drop user write + +sql close +sql connect +sleep 2000 +sql drop database d1 +sql drop database d2 +sql drop database d3 +sql drop database d4 + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/account/basic.sim b/tests/script/unique/account/basic.sim new file mode 100644 index 0000000000000000000000000000000000000000..00e706a4482d9fa57ed2f97a9995ce84d3667fa1 --- /dev/null +++ b/tests/script/unique/account/basic.sim @@ -0,0 +1,46 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print =============== show accounts +sql show accounts +if $rows != 1 then + return -1 +endi + +print $data00 $data01 $data02 + +print =============== create account1 +sql create account account1 PASS 'account1' +sql show accounts +if $rows != 2 then + return -1 +endi + +print $data00 $data01 $data02 +print $data10 $data11 $data22 + +print =============== create account2 +sql create account account2 PASS 'account2' +sql show accounts +if $rows != 3 then + return -1 +endi + +print $data00 $data01 $data02 +print $data10 $data11 $data22 +print $data20 $data11 $data22 + +print =============== drop account1 +sql drop account account1 +sql show accounts +if $rows != 2 then + return -1 +endi + +print $data00 $data01 $data02 +print $data10 $data11 $data22 + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/account/paras.sim b/tests/script/unique/account/paras.sim new file mode 100644 index 0000000000000000000000000000000000000000..102f5b6a381e5100b35a4f0125b1318bcb8b1d76 --- /dev/null +++ b/tests/script/unique/account/paras.sim @@ -0,0 +1,114 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print =============== show accounts +sql show accounts +if $rows != 1 then + return -1 +endi + +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != root then + return -1 +endi +if $data02 != 3/128 then + return -1 +endi +if $data03 != 0/128 then + return -1 +endi +if $data04 != 0/2147483647 then + return -1 +endi +if $data05 != 0/1000 then + return -1 +endi +if $data06 != 0.000/unlimited then + return -1 +endi + +print =============== create account +sql create account hou pass "hou" tseries 80000 storage 10737418240 streams 10 qtime 3600 dbs 3 users 3 conns 10 +sql show accounts +if $rows != 2 then + return -1 +endi + +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 +if $data10 != hou then + return -1 +endi +if $data12 != 2/3 then + return -1 +endi +if $data13 != 0/3 then + return -1 +endi +if $data14 != 0/80000 then + return -1 +endi +if $data15 != 0/10 then + return -1 +endi +if $data16 != 0.000/10.000 then + return -1 +endi + +print =============== alter account +sql alter account hou pass "hou" tseries 8000 streams 10 dbs 5 users 5 +sql show accounts +if $rows != 2 then + return -1 +endi + +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 +if $data10 != hou then + return -1 +endi +if $data12 != 2/5 then + return -1 +endi +if $data13 != 0/5 then + return -1 +endi +if $data14 != 0/8000 then + return -1 +endi +if $data15 != 0/10 then + return -1 +endi +if $data16 != 0.000/10.000 then + return -1 +endi + +print =============== alter account +sql create account hou pass "hou" tseries 8000 streams 10 dbs 5 users 6 +sql show accounts +if $rows != 2 then + return -1 +endi + +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 +if $data10 != hou then + return -1 +endi +if $data12 != 2/6 then + return -1 +endi +if $data13 != 0/5 then + return -1 +endi +if $data14 != 0/8000 then + return -1 +endi +if $data15 != 0/10 then + return -1 +endi +if $data16 != 0.000/10.000 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/account/pass_alter.sim b/tests/script/unique/account/pass_alter.sim new file mode 100644 index 0000000000000000000000000000000000000000..8b857b014a292d53536c5acf2a00daa15be11239 --- /dev/null +++ b/tests/script/unique/account/pass_alter.sim @@ -0,0 +1,116 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ============= step1 +sql create user read pass 'taosdata1' +sql create user write pass 'taosdata1' + +sql alter user read pass 'taosdata' +sql alter user write pass 'taosdata' + +sql show accounts +if $rows != 1 then + return -1 +endi +sql show users +if $rows != 5 then + return -1 +endi + +print ============= step2 +sql close +sql connect read +sleep 2000 +sql alter user read pass 'taosdata' +sql alter user write pass 'taosdata1' -x step2 + return -1 +step2: + + +print ============= step3 +sql close +sql connect write +sleep 2000 +sql alter user write pass 'taosdata' +sql alter user read pass 'taosdata' -x step3 + return -1 +step3: + +print ============= step4 +sql close +sleep 1000 +sql connect +sleep 2000 +sql create account oroot pass 'taosdata' +sql show accounts +if $rows != 2 then + return -1 +endi +sql show users +if $rows != 5 then + return -1 +endi + +print ============= step5 +sql close +sql connect oroot +sleep 2000 + +sql create user oread pass 'taosdata1' +sql create user owrite pass 'taosdata1' +sql alter user oread pass 'taosdata' +sql alter user owrite pass 'taosdata' + +sql create user read pass 'taosdata1' -x step51 + return -1 +step51: +sql alter user read pass 'taosdata1' -x step52 + return -1 +step52: + +sql show accounts -x step53 + return -1 +step53: +sql show users +print show users $rows +if $rows != 4 then + return -1 +endi + +print ============= step6 +sql close +sql connect oread +sleep 2000 +sql alter user oread pass 'taosdata' +sql alter user owrite pass 'taosdata1' -x step6 + return -1 +step6: + + +print ============= step7 +sql close +sql connect owrite +sleep 2000 +sql alter user owrite pass 'taosdata' +sql alter user oread pass 'taosdata' -x step7 + return -1 +step7: + +print ============= step8 +sql close +sql connect +sleep 2000 +sql alter user oread pass 'taosdata' +sql alter user owrite pass 'taosdata' +sql alter user oroot pass 'taosdata' + +sql drop account oroot +sql drop user read +sql drop user write + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/account/pass_len.sim b/tests/script/unique/account/pass_len.sim new file mode 100644 index 0000000000000000000000000000000000000000..f4ceb76f7b8b41873217bd11ae2c3d385386b0e9 --- /dev/null +++ b/tests/script/unique/account/pass_len.sim @@ -0,0 +1,81 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$i = 0 +$dbPrefix = apdb +$tbPrefix = aptb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +$userPrefix = apusr + +print =============== step1 +$i = 0 +$user = $userPrefix . $i + +sql drop user $user -x step11 + return -1 +step11: + +sql create user $user PASS -x step12 + return -1 +step12: + +sql create user $user PASS 'taosdata' + +sql show users +if $rows != 4 then + return -1 +endi + +print =============== step2 +$i = 1 +$user = $userPrefix . $i +sql drop user $user -x step2 +step2: +sql create user $user PASS '1' +sql show users +if $rows != 5 then + return -1 +endi + +print =============== step3 +$i = 2 +$user = $userPrefix . $i +sql drop user $user -x step3 +step3: + +sql create user $user PASS 'abc0123456789' +sql show users +if $rows != 6 then + return -1 +endi + +print =============== step4 +$i = 3 +$user = $userPrefix . $i +sql create user $user PASS 'abcd012345678901234567891234567890' -x step4 + return -1 +step4: +sql show users +if $rows != 6 then + return -1 +endi + +$i = 0 +while $i < 3 + $user = $userPrefix . $i + sql drop user $user + $i = $i + 1 +endw + +sql show users +if $rows != 3 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/account/testSuite.sim b/tests/script/unique/account/testSuite.sim new file mode 100644 index 0000000000000000000000000000000000000000..9d4141cfe0c086f9a8863fffb00a9cb0f410e265 --- /dev/null +++ b/tests/script/unique/account/testSuite.sim @@ -0,0 +1,11 @@ +run unique/account/account_create.sim +run unique/account/account_delete.sim +run unique/account/account_len.sim +run unique/account/authority.sim +run unique/account/basic.sim +run unique/account/paras.sim +run unique/account/pass_alter.sim +run unique/account/pass_len.sim +run unique/account/usage.sim +run unique/account/user_create.sim +run unique/account/user_len.sim diff --git a/tests/script/unique/account/usage.sim b/tests/script/unique/account/usage.sim new file mode 100644 index 0000000000000000000000000000000000000000..3b9c20b159a6237f469fc1e48b5b3a3f4ca5f7b8 --- /dev/null +++ b/tests/script/unique/account/usage.sim @@ -0,0 +1,154 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +#system sh/exec.sh -n monitor -s 1 +system sh/exec.sh -n monitorInterval -s 1 +sleep 2000 +sql connect + +print =============== show accounts + +print =============== create account +sql alter account root pass "taosdata" tseries 8000 streams 10 dbs 5 users 5 +sql show accounts +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != root then + return -1 +endi +if $data02 != 3/5 then + return -1 +endi +if $data03 != 0/5 then + return -1 +endi +if $data04 != 0/8000 then + return -1 +endi +if $data05 != 0/10 then + return -1 +endi +if $data06 != 0.000/unlimited then + return -1 +endi + +print =============== check usage account +sql create database d1 wal 2 +sql create database d2 wal 2 +sql create database d3 wal 2 +sql create database d4 wal 2 +sql create database d5 wal 2 + +sql create table d1.t1 (ts timestamp, i int); +sql create user u1 pass "u1" + +sql show accounts +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 +if $data00 != root then + return -1 +endi +if $data02 != 4/5 then + return -1 +endi +if $data03 != 5/5 then + return -1 +endi +if $data04 != 1/8000 then + return -1 +endi +if $data05 != 0/10 then + return -1 +endi +if $data06 != 0.000/unlimited then + return -1 +endi + +print =============== step2 +sql alter account root pass "taosdata" tseries 10 storage 1073741824 streams 10 dbs 5 users 5 +sql show accounts +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != root then + return -1 +endi +if $data02 != 4/5 then + return -1 +endi +if $data03 != 5/5 then + return -1 +endi +if $data04 != 1/10 then + return -1 +endi +if $data05 != 0/10 then + return -1 +endi +if $data06 != 0.000/1.000 then + return -1 +endi + +print =============== step3 +sql alter account root pass "taosdata" tseries 10 storage 16 streams 10 dbs 5 users 5 +sql show accounts +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != root then + return -1 +endi +if $data02 != 4/5 then + return -1 +endi +if $data03 != 5/5 then + return -1 +endi +if $data04 != 1/10 then + return -1 +endi +if $data05 != 0/10 then + return -1 +endi +if $data06 != 0.000/0.000 then + return -1 +endi + +print =============== step4 +sql insert into d1.t1 values(now + 1s, 1) +sql insert into d1.t1 values(now + 2s, 2) + +sleep 10000 +print no write auth +sql_error insert into d1.t1 values(now + 3s, 2) +sql_error insert into d1.t1 values(now + 4s, 2) + +sql alter account root pass "taosdata" tseries 10 storage 36 streams 10 dbs 5 users 5 +sleep 10000 +print has write auth +sql insert into d1.t1 values(now + 5s, 1) +sql insert into d1.t1 values(now + 6s, 2) + +# no write auth +sleep 10000 +print no write auth +sql_error insert into d1.t1 values(now + 7s, 2) +sql_error insert into d1.t1 values(now + 8s, 2) + +print =============== step5 +sql alter account root pass "taosdata" tseries 10 storage 3600 streams 10 dbs 5 users 5 state all +sleep 10000 + +sql insert into d1.t1 values(now + 11s, 1) +sql insert into d1.t1 values(now + 12s, 2) + +sql alter account root pass "taosdata" tseries 10 storage 3600 streams 10 dbs 5 users 5 state no +sleep 10000 +print no write auth +sql_error insert into d1.t1 values(now + 13s, 2) +sql_error insert into d1.t1 values(now + 14s, 2) + +sql alter account root pass "taosdata" tseries 10 storage 3600 streams 10 dbs 5 users 5 state all +sleep 10000 +print has write auth +sql insert into d1.t1 values(now + 15s, 1) +sql insert into d1.t1 values(now + 16s, 2) + +print =============== check grant +sql_error create database d6 + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/account/user_create.sim b/tests/script/unique/account/user_create.sim new file mode 100644 index 0000000000000000000000000000000000000000..e54a380f0dbef8107de452354ea01bc58262d548 --- /dev/null +++ b/tests/script/unique/account/user_create.sim @@ -0,0 +1,84 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print =============== step1 +sql show users +if $rows != 3 then + return -1 +endi + +sql create user read PASS 'pass123' +sql create user read PASS 'pass123' -x step1 + return -1 +step1: + +sql show users +if $rows != 4 then + return -1 +endi + +sql alter user read PASS 'taosdata' + +print =============== step2 +sql close +sql connect read +sleep 2000 + +sql alter user read PASS 'taosdata' + +print =============== step3 +sql drop user read -x step31 + return -1 +step31: +sql drop user _root -x step32 + return -1 +step32: +sql drop user monitor -x step33 + return -1 +step33: + +print =============== step4 +sql close +sql connect +sleep 2000 + +sql alter user read privilege read +sql show users +print $data1_read +if $data1_read != readable then + return -1 +endi + +sql_error alter user read privilege super +sql show users +print $data1_read +if $data1_read != readable then + return -1 +endi + +sql alter user read privilege write +sql show users +if $data1_read != writable then + return -1 +endi + +sql alter user read privilege 1 -x step43 + return -1 +step43: + +sql drop user _root -x step41 + return -1 +step41: + +sql drop user monitor -x step42 + return -1 +step42: + +sql drop user read + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/account/user_len.sim b/tests/script/unique/account/user_len.sim new file mode 100644 index 0000000000000000000000000000000000000000..b8d448f0ffc9e43cbc0f0a5a849bda215e72e790 --- /dev/null +++ b/tests/script/unique/account/user_len.sim @@ -0,0 +1,94 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +$i = 0 +$dbPrefix = lm_us_db +$tbPrefix = lm_us_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop user ac -x step0 + return -1 +step0: + +sql create user PASS '123' -x step1 + return -1 +step1: + +sql show users +if $rows != 3 then + return -1 +endi + +print =============== step2 +sql drop user a -x step2 +step2: +sleep 1000 +sql create user a PASS '123' +sql show users +if $rows != 4 then + return -1 +endi + +sql drop user a +sql show users +if $rows != 3 then + return -1 +endi + +print =============== step3 +sql drop user abc01234567890123456789 -x step3 +step3: + +sql create user abc01234567890123456789 PASS '123' +sql show users +if $rows != 4 then + return -1 +endi + +sql drop user abc01234567890123456789 +sql show users +if $rows != 3 then + return -1 +endi + +print =============== step4 +sql create user abcd0123456789012345678901234567890111 PASS '123' -x step4 + return -1 +step4: +sql show users +if $rows != 3 then + return -1 +endi + +print =============== step5 +sql drop user 123 -x step5 +step5: +sql create user 123 PASS '123' -x step61 + return -1 +step61: + +sql create user a123 PASS '123' +sql show users +if $rows != 4 then + return -1 +endi + +sql drop user a123 +sql show users +if $rows != 3 then + return -1 +endi + +sql show accounts +if $rows != 1 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/arbitrator/check_cluster_cfg_para.sim b/tests/script/unique/arbitrator/check_cluster_cfg_para.sim new file mode 100644 index 0000000000000000000000000000000000000000..7bf2c2ac42a95d1ab6da3ecf50a287eea2ce46bb --- /dev/null +++ b/tests/script/unique/arbitrator/check_cluster_cfg_para.sim @@ -0,0 +1,199 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/deploy.sh -n dnode5 -i 5 +system sh/deploy.sh -n dnode6 -i 6 +system sh/deploy.sh -n dnode7 -i 7 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode1 -c offlineThreshold -v 8 +system sh/cfg.sh -n dnode1 -c statusInterval -v 3 +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +#system sh/cfg.sh -n dnode1 -c timezone -v "" +#system sh/cfg.sh -n dnode1 -c locale -v "" +#system sh/cfg.sh -n dnode1 -c charset -v "" +system sh/cfg.sh -n dnode1 -c balanceInterval -v 3 + +######## dnode 2 the same with dnode1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c offlineThreshold -v 8 +system sh/cfg.sh -n dnode2 -c statusInterval -v 3 +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +#system sh/cfg.sh -n dnode2 -c timezone -v "" +#system sh/cfg.sh -n dnode2 -c locale -v "" +#system sh/cfg.sh -n dnode2 -c charset -v "" +system sh/cfg.sh -n dnode2 -c balanceInterval -v 3 + +######## dnode 3 one para no same with dnode1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c offlineThreshold -v 8 +system sh/cfg.sh -n dnode3 -c statusInterval -v 3 +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +#system sh/cfg.sh -n dnode3 -c timezone -v "" +#system sh/cfg.sh -n dnode3 -c locale -v "" +#system sh/cfg.sh -n dnode3 -c charset -v "" +system sh/cfg.sh -n dnode3 -c balanceInterval -v 3 + +######## dnode 4 one para no same with dnode1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 5 +system sh/cfg.sh -n dnode4 -c offlineThreshold -v 8 +system sh/cfg.sh -n dnode4 -c statusInterval -v 3 +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator +#system sh/cfg.sh -n dnode4 -c timezone -v "" +#system sh/cfg.sh -n dnode4 -c locale -v "" +#system sh/cfg.sh -n dnode4 -c charset -v "" +system sh/cfg.sh -n dnode4 -c balanceInterval -v 3 + +######## dnode 5 one para no same with dnode1 +system sh/cfg.sh -n dnode5 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode5 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode5 -c offlineThreshold -v 7 +system sh/cfg.sh -n dnode5 -c statusInterval -v 3 +system sh/cfg.sh -n dnode5 -c arbitrator -v $arbitrator +#system sh/cfg.sh -n dnode5 -c timezone -v "" +#system sh/cfg.sh -n dnode5 -c locale -v "" +#system sh/cfg.sh -n dnode5 -c charset -v "" +system sh/cfg.sh -n dnode5 -c balanceInterval -v 3 + + +######## dnode 6 one para no same with dnode1 +system sh/cfg.sh -n dnode6 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode6 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode6 -c offlineThreshold -v 8 +system sh/cfg.sh -n dnode6 -c statusInterval -v 2 +system sh/cfg.sh -n dnode6 -c arbitrator -v $arbitrator +#system sh/cfg.sh -n dnode6 -c timezone -v "" +#system sh/cfg.sh -n dnode6 -c locale -v "" +#system sh/cfg.sh -n dnode6 -c charset -v "" +system sh/cfg.sh -n dnode6 -c balanceInterval -v 3 + + +######## dnode 7 one para no same with dnode1 +system sh/cfg.sh -n dnode7 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode7 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode7 -c offlineThreshold -v 8 +system sh/cfg.sh -n dnode7 -c statusInterval -v 3 +system sh/cfg.sh -n dnode7 -c arbitrator -v "plum-VirtualBox:8001" +#system sh/cfg.sh -n dnode7 -c timezone -v "" +#system sh/cfg.sh -n dnode7 -c locale -v "" +#system sh/cfg.sh -n dnode7 -c charset -v "" +system sh/cfg.sh -n dnode7 -c balanceInterval -v 3 + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2~7 and add into cluster +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +system sh/exec.sh -n dnode5 -s start +system sh/exec.sh -n dnode6 -s start +system sh/exec.sh -n dnode7 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 +sql create dnode $hostname4 +sql create dnode $hostname5 +sql create dnode $hostname6 +sql create dnode $hostname7 +sleep 10000 + +$loopCnt = 0 +wait_dnode_created: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi +sql show dnodes +if $rows != 8 then + sleep 2000 + goto wait_dnode_created +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +$dnode5Status = $data4_5 +$dnode6Status = $data4_6 +$dnode7Status = $data4_7 + +if $dnode1Status != ready then + return -1 +endi +if $dnode2Status != ready then + return -1 +endi +if $dnode3Status != offline then + return -1 +endi +if $dnode4Status != offline then + return -1 +endi +if $dnode5Status != offline then + return -1 +endi +if $dnode6Status != offline then + return -1 +endi +if $dnode7Status != offline then + return -1 +endi + +sleep 10000 + +$loopCnt = 0 +wait_dnode_offline_overtime_dropped: +$loopCnt = $loopCnt + 1 +if $loopCnt == 20 then + return -1 +endi +sql show dnodes +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +if $rows != 3 then + sleep 2000 + goto wait_dnode_offline_overtime_dropped +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +$dnode5Status = $data4_5 +$dnode6Status = $data4_6 +$dnode7Status = $data4_7 + +if $dnode1Status != ready then + return -1 +endi +if $dnode2Status != ready then + return -1 +endi diff --git a/tests/script/unique/arbitrator/dn2_mn1_cache_file_sync.sim b/tests/script/unique/arbitrator/dn2_mn1_cache_file_sync.sim new file mode 100644 index 0000000000000000000000000000000000000000..dbd0e2bd87c099dca54aa33d609696cb2dc89381 --- /dev/null +++ b/tests/script/unique/arbitrator/dn2_mn1_cache_file_sync.sim @@ -0,0 +1,222 @@ +# Test case describe: dnode1 is only mnode, dnode2/dnode3 are only vnode +# step 1: start dnode1 +# step 2: start dnode2 and dnode3, and all added into cluster (Suppose dnode2 is master-vnode) +# step 2: create db, table, insert data, and Falling disc into file (control only one file, e.g. 1841) +# step 3: insert old data(now-20d) and new data(now-40d), control data rows in order to save in cache, not falling disc +# step 4: stop dnode2, so date rows falling disc, generate two new files 1840, 1842 in dnode2 +# step 5: insert two data rows: now-21d, now-41d +# step 6: restart dnode2, waiting sync end +# expect: in dnode2, the files 1837 and 1839 will be removed + +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 4 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3 and add into cluster , then create database with replica 2, and create table, insert data +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 +sleep 2000 + +$totalTableNum = 1 +$sleepTimer = 3000 + +$db = db +sql create database $db replica 2 cache 1 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 double) tags(t1 int) +$rowNum = 130000 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1577808000000 # 2020-01-01 00:00:00.000 + +# insert over 2M data in order to falling disc, generate one file +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum +# $ts = $tsStart + $x + sql insert into $tb values ( now + 0s , $x ) ( now + 1s , $x ) ( now + 2s , $x ) ( now + 3s , $x ) ( now + 4s , $x ) ( now + 5s , $x ) ( now + 6s , $x ) ( now + 7s , $x ) ( now + 8s , $x ) ( now + 9s , $x ) + $x = $x + 10 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print rows:$rows data00:$data00 +if $rows != 1 then + return -1 +endi + +if $data00 == 0 then + return -1 +endi + +$totalRows = $data00 + +print ============== step3: insert old data(now-15d) and new data(now+15d), control data rows in order to save in cache, not falling disc +sql insert into $tb values ( now - 20d , -20 ) +sql insert into $tb values ( now - 40d , -40 ) +$totalRows = $totalRows + 2 + +print ============== step4: stop dnode3, so date rows falling disc, generate two new files in dnode3 +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sleep $sleepTimer + +$loopCnt = 0 +wait_dnode3_offline: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 3 then + sleep 2000 + goto wait_dnode3_offline +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +#$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode3Status != offline then + sleep 2000 + goto wait_dnode3_offline +endi +if $dnode2Status != ready then + sleep 2000 + goto wait_dnode3_offline +endi + +sleep $sleepTimer # waitting for move master vnode of dnode2 to dnode3 +# check using select +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +system_content ls ../../../sim/dnode3/data/vnode/vnode2/tsdb/data/ -l |grep "^-"|wc -l | tr -d '\n' +print ---->dnode3 data files: $system_content expect: 9 +if $system_content != 9 then + return -1 +endi + +print ============== step5: insert two data rows: now-16d, now+16d, +sql insert into $tb values ( now - 21d , -21 ) +sql insert into $tb values ( now - 41d , -41 ) +$totalRows = $totalRows + 2 + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +system_content ls ../../../sim/dnode2/data/vnode/vnode2/tsdb/data/ -l |grep "^-"|wc -l | tr -d '\n' +print ---->dnode2 data files: $system_content expect: 3 +if $system_content != 3 then + return -1 +endi + +print ============== step7: restart dnode3, waiting sync end +system sh/exec.sh -n dnode3 -s start +sleep 2000 + +$loopCnt = 0 +wait_dnode3_ready: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 3 then + sleep 2000 + goto wait_dnode3_ready +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 + +if $dnode3Status != ready then + sleep 2000 + goto wait_dnode3_ready +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +system_content ls ../../../sim/dnode2/data/vnode/vnode2/tsdb/data/ -l |grep "^-"|wc -l | tr -d '\n' +print ---->dnode2 data files: $system_content expect: 3 +if $system_content != 3 then + return -1 +endi +system_content ls ../../../sim/dnode3/data/vnode/vnode2/tsdb/data/ -l |grep "^-"|wc -l | tr -d '\n' +print ---->dnode3 data files: $system_content expect: 3 +if $system_content != 3 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/unique/arbitrator/dn2_mn1_cache_file_sync_second.sim b/tests/script/unique/arbitrator/dn2_mn1_cache_file_sync_second.sim new file mode 100644 index 0000000000000000000000000000000000000000..e15edb3f3d444b7407244b8cf3fa781ba36357d6 --- /dev/null +++ b/tests/script/unique/arbitrator/dn2_mn1_cache_file_sync_second.sim @@ -0,0 +1,52 @@ +# Test case describe: dnode1 is only mnode, dnode2/dnode3 are only vnode +# step 1: start dnode1 +# step 2: start dnode2 and dnode3, and all added into cluster (Suppose dnode2 is master-vnode) +# step 3: create db, table, insert data, and Falling disc into file (control only one file, e.g. 1841) +# step 4: insert old data(now-20d) and new data(now-40d), control data rows in order to save in cache, not falling disc +# step 5: stop dnode2, so date rows falling disc, generate two new files 1840, 1842 in dnode2 +# step 6: insert two data rows: now-21d, now-41d +# step 7: restart dnode2, waiting sync end +# expect: in dnode2, the files 1837 and 1839 will be removed + +sql connect +sleep 2000 + +print ============== step7: restart dnode2, waiting sync end +system sh/exec.sh -n dnode2 -s start +sleep 2000 + +wait_dnode2_ready: +sql show dnodes +if $rows != 3 then + sleep 2000 + goto wait_dnode2_ready +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +#$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode2Status != ready then + sleep 2000 + goto wait_dnode2_ready +endi + +sleep 1000 +# check using select +$db = db +$stb = stb +sql use $db +sql select count(*) from $stb +print data00 $data00, should equal to dn2_mn1_cache_file_sync.sim output +#if $data00 != $totalRows then +# return -1 +#endi + +print ============== step8: please check there should be 1 file in sim/dnode2/data/vnode/vnode2/tsdb/data/, and 1 file sim/dnode3/data/vnode/vnode2/tsdb/data/ diff --git a/tests/script/unique/arbitrator/dn3_mn1_full_createTableFail.sim b/tests/script/unique/arbitrator/dn3_mn1_full_createTableFail.sim new file mode 100644 index 0000000000000000000000000000000000000000..057654abb47be64bcba726df8b689b8db4d97f58 --- /dev/null +++ b/tests/script/unique/arbitrator/dn3_mn1_full_createTableFail.sim @@ -0,0 +1,101 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table to max tables +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 +sql create dnode $hostname4 +sleep 2000 + +$totalTableNum = 16 +$sleepTimer = 3000 + +$db = db +sql create database $db replica 3 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 10 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) + $x = $x + 10 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + + +print ============== step3: create one table, should return error for not more vnode +sql_error create table tbm using $stb tags( 10000 ) + + + + + + + + diff --git a/tests/script/unique/arbitrator/dn3_mn1_full_dropDnodeFail.sim b/tests/script/unique/arbitrator/dn3_mn1_full_dropDnodeFail.sim new file mode 100644 index 0000000000000000000000000000000000000000..c597c576e2994725035f83268c6b1f99392627da --- /dev/null +++ b/tests/script/unique/arbitrator/dn3_mn1_full_dropDnodeFail.sim @@ -0,0 +1,102 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 4 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table to max tables +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 +sql create dnode $hostname4 +sleep 2000 + +$totalTableNum = 16 +$sleepTimer = 3000 + +$db = db +sql create database $db replica 3 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 10 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) + $x = $x + 10 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + + +print ============== step3: drop dnode4, should return error for not more dnode +sql_error drop dnode $hostname4 + + + + + + + + diff --git a/tests/script/unique/arbitrator/dn3_mn1_multiCreateDropTable.sim b/tests/script/unique/arbitrator/dn3_mn1_multiCreateDropTable.sim new file mode 100644 index 0000000000000000000000000000000000000000..49e1dba06719a3375b221854ccb3a35d1bd03dfe --- /dev/null +++ b/tests/script/unique/arbitrator/dn3_mn1_multiCreateDropTable.sim @@ -0,0 +1,310 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table, insert data +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 +sql create dnode $hostname4 +sleep 2000 + +$sleepTimer = 3000 + +$db = db +sql create database $db replica 3 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 10 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) + $x = $x + 10 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: drop the middle table 5 +sql drop table tb5 +$totalRows = $totalRows - 10 +sleep 6000 + +print ============== step4: insert data into other tables +$tsStart = 1420041610000 +$i = 0 +$tblNum = 5 +while $i < $tblNum + $tb = tb . $i + #sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) + $x = $x + 10 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +$i = 6 +$tblNum = 10 +while $i < $tblNum + $tb = tb . $i + #sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) + $x = $x + 10 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + + +print ============== step5: create the middle table 5 and insert data +sql create table tb5 using $stb tags( 5 ) +sleep 2000 + +$tsStart = 1420041620000 +$i = 5 +$tblNum = 6 +while $i < $tblNum + $tb = tb . $i + #sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) + $x = $x + 10 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +sql select count(*) from tb5 +print data00 $data00 +if $data00 != 10 then + return -1 +endi + +print ============== step6: drop the first table 0 +sql drop table tb0 +$totalRows = $totalRows - 20 +sleep 6000 + +print ============== step7: insert data into other tables +$tsStart = 1420041630000 +$i = 1 +$tblNum = 10 +while $i < $tblNum + $tb = tb . $i + #sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) + $x = $x + 10 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi +sql select count(*) from tb5 +print data00 $data00 +if $data00 != 20 then + return -1 +endi + +print ============== step8: create the first table 0 and insert data +sql create table tb0 using $stb tags( 0 ) +sleep 2000 + +$tsStart = 1420041640000 +$i = 0 +$tblNum = 10 +while $i < $tblNum + $tb = tb . $i + #sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) + $x = $x + 10 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +sql select count(*) from tb0 +print data00 $data00 +if $data00 != 10 then + return -1 +endi + +print ============== step9: drop the last table 9 +sql drop table tb9 +$totalRows = $totalRows - 40 +sleep 6000 + +print ============== step10: insert data into other tables +$tsStart = 1420041650000 +$i = 0 +$tblNum = 9 +while $i < $tblNum + $tb = tb . $i + #sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) + $x = $x + 10 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + + +print ============== step11: create the last table 9 and insert data +sql create table tb9 using $stb tags( 9 ) +sleep 2000 + +$tsStart = 1420041660000 +$i = 0 +$tblNum = 10 +while $i < $tblNum + $tb = tb . $i + #sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) + $x = $x + 10 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +sql select count(*) from tb9 +print data00 $data00 +if $data00 != 10 then + return -1 +endi diff --git a/tests/script/unique/arbitrator/dn3_mn1_nw_disable_timeout_autoDropDnode.sim b/tests/script/unique/arbitrator/dn3_mn1_nw_disable_timeout_autoDropDnode.sim new file mode 100644 index 0000000000000000000000000000000000000000..2af7cf56b7b547a707abc18f26a18fe74bd8f95e --- /dev/null +++ b/tests/script/unique/arbitrator/dn3_mn1_nw_disable_timeout_autoDropDnode.sim @@ -0,0 +1,160 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode3 -c walLevel -v 1 +system sh/cfg.sh -n dnode4 -c walLevel -v 1 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +system sh/cfg.sh -n dnode1 -c offlineThreshold -v 10 +system sh/cfg.sh -n dnode2 -c offlineThreshold -v 10 +system sh/cfg.sh -n dnode3 -c offlineThreshold -v 10 +system sh/cfg.sh -n dnode4 -c offlineThreshold -v 10 + +system sh/cfg.sh -n dnode1 -c enableCoreFile -v 1 +system sh/cfg.sh -n dnode2 -c enableCoreFile -v 1 +system sh/cfg.sh -n dnode3 -c enableCoreFile -v 1 +system sh/cfg.sh -n dnode4 -c enableCoreFile -v 1 + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3 and add into cluster, then create database, create table , and insert data +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 +sql create dnode $hostname4 +sleep 2000 + +$rowNum = 10 +$tblNum = 16 +$totalRows = 0 +$tsStart = 1420041600000 + +$db = db +sql create database $db replica 2 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) + + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) + $x = $x + 10 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +print info: select count(*) from $stb +sleep 1000 +sql reset query cache +sleep 1000 +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +sql show dnodes +if $rows != 4 then + return -1 +endi + +print ============== step3: stop dnode4, after timerout dnode4 will be auto-dropped. +### The script using down port to stop the network is invalid, so temp it stops the service instead +system sh/exec.sh -n dnode4 -s stop +#system sh/port.sh -p 7400 -s down +sleep 12000 + +$loopCnt = 0 +wait_dnode4_dropped: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 3 then + sleep 2000 + goto wait_dnode4_dropped +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode2Status != ready then + sleep 2000 + goto wait_dnode4_dropped +endi +if $dnode3Status != ready then + sleep 2000 + goto wait_dnode4_dropped +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step4: restart dnode4, but there no dnode4 in cluster +system sh/exec.sh -n dnode4 -s start +sql show dnodes +if $rows != 3 then + return -1 +endi + diff --git a/tests/script/unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim b/tests/script/unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim new file mode 100644 index 0000000000000000000000000000000000000000..96fde9061a0648d69386cb7f5c23450dea6aad7e --- /dev/null +++ b/tests/script/unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim @@ -0,0 +1,358 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 2, and create table, insert data +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 +sleep 3000 + +$sleepTimer = 3000 + +$db = db +sql create database $db replica 2 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 100 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: stop dnode3, and remove its vnodeX subdirector +system sh/exec.sh -n dnode3 -s stop -x SIGINT +#sleep $sleepTimer + +$loopCnt = 0 +wait_dnode3_offline_0: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 4 then + sleep 2000 + goto wait_dnode3_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 + +if $dnode3Status != offline then + sleep 2000 + goto wait_dnode3_offline_0 +endi + +$loopCnt = 0 +wait_dnode3_vgroup_offline: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode3_vgroup_offline +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode3Vtatus = $data5_2 +$dnode2Vtatus = $data7_2 + +if $dnode3Vtatus != offline then + sleep 2000 + goto wait_dnode3_vgroup_offline +endi +if $dnode2Vtatus != master then + sleep 2000 + goto wait_dnode3_vgroup_offline +endi + +system rm -rf ../../../sim/dnode3/data +#system rm -rf ../../../sim/dnode3/data/vnode/* + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step4: restart dnode3, waiting sync end +system sh/exec.sh -n dnode3 -s start +#sleep $sleepTimer + +$loopCnt = 0 +wait_dnode3_reready: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 4 then + sleep 2000 + goto wait_dnode3_reready +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 + +if $dnode3Status != ready then + sleep 2000 + goto wait_dnode3_reready +endi + +$loopCnt = 0 +wait_dnode3_vgroup_slave: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode3_vgroup_slave +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode3Vtatus = $data5_2 +$dnode2Vtatus = $data7_2 + +print dnode2Vtatus: $dnode3Vtatus +print dnode3Vtatus: $dnode3Vtatus +if $dnode3Vtatus != slave then + sleep 2000 + goto wait_dnode3_vgroup_slave +endi +if $dnode2Vtatus != master then + sleep 2000 + goto wait_dnode3_vgroup_slave +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step5: stop dnode2, and remove its vnode +sleep 3000 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep $sleepTimer + +$loopCnt = 0 +wait_dnode2_offline: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 4 then + sleep 2000 + goto wait_dnode2_offline +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 + +if $dnode2Status != offline then + sleep 2000 + goto wait_dnode2_offline +endi +if $dnode3Status != ready then + sleep 2000 + goto wait_dnode2_offline +endi + +system rm -rf ../../../sim/dnode2/data +#system rm -rf ../../../sim/dnode2/data/vnode/* +#system rm -rf ../../../sim/dnode3/data/vnode/* + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + + +print ============== step6: restart dnode2, and check rows +system sh/exec.sh -n dnode2 -s start +#sleep $sleepTimer + +$loopCnt = 0 +wait_dnode2_reready: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 4 then + sleep 2000 + goto wait_dnode2_reready +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 + +if $dnode3Status != ready then + sleep 2000 + goto wait_dnode2_reready +endi +if $dnode2Status != ready then + sleep 2000 + goto wait_dnode2_reready +endi + +$loopCnt = 0 +wait_dnode2_vgroup_slave: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode2_vgroup_slave +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode3Vtatus = $data5_2 +$dnode2Vtatus = $data7_2 + +print dnode4Vtatus: $dnode4Vtatus +print dnode3Vtatus: $dnode3Vtatus +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode2_vgroup_slave +endi +if $dnode2Vtatus != slave then + sleep 2000 + goto wait_dnode2_vgroup_slave +endi + +# check using select +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +sql insert into $tb values ( now , 20000 ) ( now + 1a, 20001 ) ( now + 2a, 20002 ) +$totalRows = $totalRows + 3 + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi \ No newline at end of file diff --git a/tests/script/unique/arbitrator/dn3_mn1_r3_vnode_delDir.sim b/tests/script/unique/arbitrator/dn3_mn1_r3_vnode_delDir.sim new file mode 100644 index 0000000000000000000000000000000000000000..da76cc467b7813586c98761319a01eb1f2ed6bb6 --- /dev/null +++ b/tests/script/unique/arbitrator/dn3_mn1_r3_vnode_delDir.sim @@ -0,0 +1,409 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table, insert data +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 +sql create dnode $hostname4 +sleep 2000 + +$sleepTimer = 3000 + +$db = db +sql create database $db replica 3 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 100 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: stop dnode4, and remove its vnodeX subdirector +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep $sleepTimer + +$loopCnt = 0 +wait_dnode4_offline_0: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 5 then + sleep 2000 + goto wait_dnode4_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 + +if $dnode4Status != offline then + sleep 2000 + goto wait_dnode4_offline_0 +endi + +$loopCnt = 0 +wait_dnode4_vgroup_offline: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +if $dnode4Vtatus != offline then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi + +system rm -rf ../../../sim/dnode4/data +#system rm -rf ../../../sim/dnode4/data/vnode/* + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step4: restart dnode4, waiting sync end +system sh/exec.sh -n dnode4 -s start +#sleep $sleepTimer + +$loopCnt = 0 +wait_dnode4_reready: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 5 then + sleep 2000 + goto wait_dnode4_reready +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 + +if $dnode4Status != ready then + sleep 2000 + goto wait_dnode4_reready +endi + +$loopCnt = 0 +wait_dnode4_vgroup_slave: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_slave +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +print dnode4Vtatus: $dnode4Vtatus +print dnode3Vtatus: $dnode3Vtatus +if $dnode4Vtatus != slave then + sleep 2000 + goto wait_dnode4_vgroup_slave +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_slave +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step5: stop dnode3/dnode2, and remove its vnode +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sleep $sleepTimer + +$loopCnt = 0 +wait_dnode23_offline: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 5 then + sleep 2000 + goto wait_dnode23_offline +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 + +if $dnode2Status != offline then + sleep 2000 + goto wait_dnode23_offline +endi +if $dnode3Status != offline then + sleep 2000 + goto wait_dnode23_offline +endi +if $dnode4Status != ready then + sleep 2000 + goto wait_dnode23_offline +endi + +system rm -rf ../../../sim/dnode2/data +system rm -rf ../../../sim/dnode3/data +#system rm -rf ../../../sim/dnode2/data/vnode/* +#system rm -rf ../../../sim/dnode3/data/vnode/* + +print ============== step6: restart dnode2/dnode3, and check rows +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sleep $sleepTimer + +$loopCnt = 0 +wait_dnode23_reready: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 5 then + sleep 2000 + goto wait_dnode23_reready +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 + +if $dnode2Status != ready then + sleep 2000 + goto wait_dnode23_reready +endi +if $dnode3Status != ready then + sleep 2000 + goto wait_dnode23_reready +endi +if $dnode4Status != ready then + sleep 2000 + goto wait_dnode23_reready +endi + +$loopCnt = 0 +wait_dnode4_vgroup_master: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_master +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +print dnode4Vtatus: $dnode4Vtatus +print dnode3Vtatus: $dnode3Vtatus +if $dnode4Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_master +endi +if $dnode3Vtatus != slave then + sleep 2000 + goto wait_dnode4_vgroup_master +endi + +# check using select +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +sql insert into $tb values ( now , 20000 ) ( now + 1a, 20001 ) ( now + 2a, 20002 ) +$totalRows = $totalRows + 3 + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + + +print ============== step7: stop dnode3/dnode2, and cluster unable to provide services +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sleep 2000 +sql select count(*) from $stb -x s71 +s71: + +print ============== step8: restart dnode2, and cluster Still unable to provide services +system sh/exec.sh -n dnode2 -s start +sleep 2000 +sql select count(*) from $stb -x s81 +s81: + +print ============== step9: restart dnode3, and cluster Resume service delivery +system sh/exec.sh -n dnode3 -s start + +$loopCnt = 0 +wait_dnode4_vgroup_master_2: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_master_2 +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +print dnode4Vtatus: $dnode4Vtatus +print dnode3Vtatus: $dnode3Vtatus +if $dnode4Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_master_2 +endi +if $dnode3Vtatus != slave then + sleep 2000 + goto wait_dnode4_vgroup_master_2 +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi diff --git a/tests/script/unique/arbitrator/dn3_mn1_replica2_wal1_AddDelDnode.sim b/tests/script/unique/arbitrator/dn3_mn1_replica2_wal1_AddDelDnode.sim new file mode 100644 index 0000000000000000000000000000000000000000..c924fee1ae673f4e5696d361be331527d41ff21d --- /dev/null +++ b/tests/script/unique/arbitrator/dn3_mn1_replica2_wal1_AddDelDnode.sim @@ -0,0 +1,367 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/deploy.sh -n dnode5 -i 5 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode5 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode3 -c walLevel -v 1 +system sh/cfg.sh -n dnode4 -c walLevel -v 1 +system sh/cfg.sh -n dnode5 -c walLevel -v 1 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode5 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 16 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 16 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 16 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 16 +system sh/cfg.sh -n dnode5 -c maxVgroupsPerDb -v 16 + +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 4 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 200 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 200 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 200 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 200 +system sh/cfg.sh -n dnode5 -c mnodeEqualVnodeNum -v 200 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 +system sh/cfg.sh -n dnode5 -c role -v 2 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode5 -c arbitrator -v $arbitrator + +system sh/cfg.sh -n dnode1 -c offlineThreshold -v 10 +system sh/cfg.sh -n dnode2 -c offlineThreshold -v 10 +system sh/cfg.sh -n dnode3 -c offlineThreshold -v 10 +system sh/cfg.sh -n dnode4 -c offlineThreshold -v 10 +system sh/cfg.sh -n dnode5 -c offlineThreshold -v 10 + +system sh/cfg.sh -n dnode1 -c enableCoreFile -v 1 +system sh/cfg.sh -n dnode2 -c enableCoreFile -v 1 +system sh/cfg.sh -n dnode3 -c enableCoreFile -v 1 +system sh/cfg.sh -n dnode4 -c enableCoreFile -v 1 +system sh/cfg.sh -n dnode5 -c enableCoreFile -v 1 + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3 and add into cluster, then create database replica 2, create table , and insert data +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 +sleep 2000 + +$rowNum = 100 +$tblNum = 16 +$totalRows = 0 +$tsStart = 1420041600000 + +$db = db +sql create database $db replica 2 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) + + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +print info: select count(*) from $stb +sleep 1000 +sql reset query cache +sleep 1000 +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: add one new dnode4 expect auto balancing +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname4 +sleep 10000 +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + + +print ============== step4: stop dnode3, after offlineThreshold, dnode3 will be dropped for cluster +system sh/exec.sh -n dnode3 -s stop +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +#sleep 2000 +#sql show dnodes +#print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +#print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +#print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +# +#$dnode1Status = $data4_1 +#$dnode2Status = $data4_2 +#$dnode3Status = $data4_3 +#$dnode4Status = $data4_4 +# +#if $dnode1Status != ready then +# return -1 +#endi +#if $dnode2Status != ready then +# return -1 +#endi +#if $dnode3Status != offline then +# return -1 +#endi +#if $dnode4Status != ready then +# return -1 +#endi + +sleep 15000 + +$loopCnt = 0 +wait_drop: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 3 then + sleep 2000 + goto wait_drop +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 + +if $dnode1Status != ready then + return -1 +endi +if $dnode2Status != ready then + return -1 +endi +if $dnode3Status != null then + return -1 +endi +if $dnode4Status != ready then + return -1 +endi + +print ============== step4-1: restart dnode3, adn add into cluster +system rm -rf ../../../sim/dnode3 +sleep 1000 + +system sh/deploy.sh -n dnode3 -i 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c walLevel -v 1 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 200 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c offlineThreshold -v 10 +system sh/cfg.sh -n dnode3 -c enableCoreFile -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 16 + +system sh/exec.sh -n dnode3 -s start +sql create dnode $hostname3 +sleep 2000 + +$loopCnt = 0 +wait_dnode3_ready: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +print rows: $rows +if $rows != 4 then + sleep 2000 + goto wait_dnode3_ready +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +$dnode5Status = $data4_5 + +if $dnode1Status != ready then + goto wait_dnode3_ready +endi +if $dnode2Status != ready then + goto wait_dnode3_ready +endi +if $dnode3Status != null then + goto wait_dnode3_ready +endi +if $dnode4Status != ready then + goto wait_dnode3_ready +endi +if $dnode5Status != ready then + goto wait_dnode3_ready +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step5: start dnode5 and add into cluster , drop database +sql drop database $db +sleep 1000 +system sh/exec.sh -n dnode5 -s start +sql create dnode $hostname5 +sleep 2000 +$loopCnt = 0 +wait_dnode5: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 5 then + sleep 2000 + goto wait_dnode5 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode4Status = $data4_4 +$dnode5Status = $data4_5 +$dnode6Status = $data4_6 + +if $dnode1Status != ready then + goto wait_dnode5 +endi +if $dnode2Status != ready then + goto wait_dnode5 +endi +if $dnode3Status != null then + goto wait_dnode5 +endi +if $dnode4Status != ready then + goto wait_dnode5 +endi +if $dnode5Status != ready then + goto wait_dnode5 +endi +if $dnode6Status != ready then + goto wait_dnode5 +endi + +print ============== step6: create database and table until not free vnodes +$rowNum = 100 +$tblNum = 32 +$totalRows = 0 +$tsStart = 1420041600000 + +$db = db1 +sql create database $db replica 2 +sql use $db +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) + + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) + + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +print info: select count(*) from $stb +sleep 2000 +sql reset query cache +sleep 2000 +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step7: drop dnode $hostname5, system should prompt "DB error: no enough dnodes" +sql_error drop dnode $hostname5 +print error: $error +print ============== step8: create table tb_more using $stb tags( 1000 ), system should prompt 'DB error: no enough dnodes' +sql_error create table tb_more using $stb tags( 1000 ) +print error: $error diff --git a/tests/script/unique/arbitrator/dn3_mn1_replica_change.sim b/tests/script/unique/arbitrator/dn3_mn1_replica_change.sim new file mode 100644 index 0000000000000000000000000000000000000000..b9008e4c42b4f4a34b99bb48d4e38c780e747bb4 --- /dev/null +++ b/tests/script/unique/arbitrator/dn3_mn1_replica_change.sim @@ -0,0 +1,358 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sql connect + +print ============== step2: start dnode2 and add into cluster , then create database with replica 1, and create table, insert data +system sh/exec.sh -n dnode2 -s start +sql create dnode $hostname2 + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 + +if $data4_1 != ready then + goto step1 +endi +if $data4_2 != ready then + goto step1 +endi + +$db = db +sql create database $db replica 1 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 100 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step2-1: stop dnode2 for falling disc, then restart dnode2, and check rows +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s start + +$x = 0 +a0: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show vgroups +print online vnodes $data03 +if $data03 != 1 then + goto a0 +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: start dnode3 and add into cluster , then alter replica from 1 to 2, and waiting sync +system sh/exec.sh -n dnode3 -s start +sql create dnode $hostname3 + +$x = 0 +step2: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 + +if $data4_3 != ready then + goto step2 +endi + +sql alter database $db replica 2 + +$x = 0 +a1: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show vgroups +print online vnodes $data03 +if $data03 != 2 then + goto a1 +endi + +# check using select +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step4: stop dnode2 for checking if sync ok +system sh/exec.sh -n dnode2 -s stop +$x = 0 +a2: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show vgroups +print online vnodes $data03 +if $data03 != 1 then + goto a2 +endi + +# check using select +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step5: restart dnode2 +system sh/exec.sh -n dnode2 -s start +$x = 0 +a3: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show vgroups +print online vnodes $data03 +if $data03 != 2 then + goto a3 +endi + +# check using select +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step6: start dnode4 and add into cluster , then alter replica from 2 to 3, and waiting sync +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname4 +$x = 0 +step6: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 +print dnode4 $data4_4 + +if $data4_4 != ready then + goto step6 +endi + +sql alter database $db replica 3 +$x = 0 +a4: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show vgroups +print online vnodes $data03 +if $data03 != 3 then + goto a4 +endi + +# check using select +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step7: alter replica from 3 to 2, and waiting sync +sql alter database $db replica 2 +$x = 0 +a5: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show vgroups +print online vnodes $data03 +if $data03 != 2 then + goto a5 +endi + +# check using select +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step8: alter replica from 2 to 1, and waiting sync +sql alter database $db replica 1 +$x = 0 +a6: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show vgroups +print online vnodes $data03 +if $data03 != 1 then + goto a6 +endi + +# check using select +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step9: drop dnode2/dnode3 +sql drop dnode $hostname2 +sql drop dnode $hostname3 +sleep $sleepTimer + +$x = 0 +step9: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show dnodes +if $rows != 3 then + goto step9 +endi + +$x = 0 +a7: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show vgroups +print online vnodes $data03 +if $data03 != 1 then + goto a7 +endi + +sleep $sleepTimer #waiting move vnode from dnode3/dnode3 to dnode4 +# check using select +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT diff --git a/tests/script/unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim b/tests/script/unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim new file mode 100644 index 0000000000000000000000000000000000000000..73702835f4f41c74ae4161019808d26fd8a7c7a7 --- /dev/null +++ b/tests/script/unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim @@ -0,0 +1,150 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 2, and create table, insert data +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 +sql create dnode $hostname4 +sleep 2000 + +$totalTableNum = 10 +$sleepTimer = 10000 + +$db = db +sql create database $db replica 2 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 100 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +sleep 1000 +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: drop dnode4, then check rows +#system sh/exec.sh -n dnode4 -s stop -x SIGINT +sql drop dnode $hostname4 +sleep $sleepTimer +$loopCnt = 0 +wait_dnode4_dropped: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 4 then + sleep 2000 + goto wait_dnode4_dropped +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode2Status != ready then + sleep 2000 + goto wait_dnode4_dropped +endi +if $dnode3Status != ready then + sleep 2000 + goto wait_dnode4_dropped +endi + +sql reset query cache +sql select count(*) from $stb +sleep 1000 +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT diff --git a/tests/script/unique/arbitrator/dn3_mn1_stopDnode_timeout.sim b/tests/script/unique/arbitrator/dn3_mn1_stopDnode_timeout.sim new file mode 100644 index 0000000000000000000000000000000000000000..27b308411aea5022641ae920a3a4e8848fb1dc04 --- /dev/null +++ b/tests/script/unique/arbitrator/dn3_mn1_stopDnode_timeout.sim @@ -0,0 +1,222 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode3 -c walLevel -v 1 +system sh/cfg.sh -n dnode4 -c walLevel -v 1 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + + +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +system sh/cfg.sh -n dnode1 -c offlineThreshold -v 5 +system sh/cfg.sh -n dnode2 -c offlineThreshold -v 5 +system sh/cfg.sh -n dnode3 -c offlineThreshold -v 5 +system sh/cfg.sh -n dnode4 -c offlineThreshold -v 5 + +system sh/cfg.sh -n dnode1 -c enableCoreFile -v 1 +system sh/cfg.sh -n dnode2 -c enableCoreFile -v 1 +system sh/cfg.sh -n dnode3 -c enableCoreFile -v 1 +system sh/cfg.sh -n dnode4 -c enableCoreFile -v 1 + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3 and add into cluster, then create database, create table , and insert data +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 +sql create dnode $hostname4 +sleep 2000 + +$rowNum = 10 +$tblNum = 16 +$totalRows = 0 +$tsStart = 1420041600000 + +$db = db +sql create database $db replica 2 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) + + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) + $x = $x + 10 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +print info: select count(*) from $stb +sleep 1000 +sql reset query cache +sleep 1000 +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +sql show dnodes +if $rows != 4 then + return -1 +endi + +print ============== step3: stop dnode4, after timerout dnode4 will be auto-dropped. +system sh/exec.sh -n dnode4 -s stop +sleep 12000 + +$loopCnt = 0 +wait_dnode4_dropped: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 3 then + sleep 2000 + goto wait_dnode4_dropped +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode2Status != ready then + sleep 2000 + goto wait_dnode4_dropped +endi +if $dnode3Status != ready then + sleep 2000 + goto wait_dnode4_dropped +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step4: restart dnode4, but there are not dnode4 in cluster +system sh/exec.sh -n dnode4 -s start +sleep 2000 +sql show dnodes +if $rows != 3 then + return -1 +endi + +print ============== step5: recreate dnode4 into cluster, result should fail +sql create dnode $hostname4 +sleep 12000 +sql show dnodes +if $rows != 3 then + return -1 +endi + +print ============== step5: remove dnode4 director, then recreate dnode4 into cluster, result should ok +system sh/exec.sh -n dnode4 -s stop +system rm -rf ../../../sim/dnode4 + +system sh/deploy.sh -n dnode4 -i 4 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c walLevel -v 1 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c role -v 2 +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c offlineThreshold -v 5 +system sh/cfg.sh -n dnode4 -c enableCoreFile -v 1 + +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname4 +sleep 6000 + +$loopCnt = 0 +wait_dnode4_ready: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 4 then + sleep 2000 + goto wait_dnode4_ready +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_6 +#$dnode5Status = $data4_5 + +if $dnode2Status != ready then + sleep 2000 + goto wait_dnode4_ready +endi +if $dnode3Status != ready then + sleep 2000 + goto wait_dnode4_ready +endi +if $dnode4Status != ready then + sleep 2000 + goto wait_dnode4_ready +endi diff --git a/tests/script/unique/arbitrator/dn3_mn1_vnode_change.sim b/tests/script/unique/arbitrator/dn3_mn1_vnode_change.sim new file mode 100644 index 0000000000000000000000000000000000000000..6d81effab63bb52801ab51e53ee1147326b3e851 --- /dev/null +++ b/tests/script/unique/arbitrator/dn3_mn1_vnode_change.sim @@ -0,0 +1,319 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 2, and create table, insert data +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 +sql create dnode $hostname4 +sleep 2000 + +$totalTableNum = 10 +$sleepTimer = 3000 + +$db = db +sql create database $db replica 2 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 100 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +sql show dnodes +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 + +print ============== step3: stop dnode4, then destroy the contents of its data file +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep $sleepTimer +$loopCnt = 0 +wait_dnode4_offline_0: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi +sql show dnodes +if $rows != 4 then + sleep 2000 + goto wait_dnode4_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 + +if $dnode4Status != offline then + sleep 2000 + goto wait_dnode4_offline_0 +endi + +wait_dnode4_vgroup_offline: +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +if $dnode4Vtatus != offline then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi + +system echo "haha, nothing......" > ../../../sim/dnode4/data/vnode/vnode2/tsdb/data/v2f1643.data +#system rm -rf ../../../sim/dnode4/data/vnode/* +sleep 1000 + +print ============== step3-1: insert new data +sql insert into $tb values ( now + 0a , $x ) ( now + 1a , $x ) ( now + 2a , $x ) +$totalRows = $totalRows + 3 + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step4: restart dnode4, waiting sync end +system sh/exec.sh -n dnode4 -s start +sleep $sleepTimer + +$loopCnt = 0 +wait_dnode4_reready: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 4 then + sleep 2000 + goto wait_dnode4_reready +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode4Status != ready then + sleep 2000 + goto wait_dnode4_reready +endi + +$loopCnt = 0 +wait_dnode4_vgroup_slave: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_slave +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +print dnode4Vtatus: $dnode4Vtatus +print dnode3Vtatus: $dnode3Vtatus +if $dnode4Vtatus != slave then + sleep 2000 + goto wait_dnode4_vgroup_slave +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_slave +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step5: stop dnode3/dnode2, and check rows +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sleep $sleepTimer + +$loopCnt = 0 +wait_dnode23_offline: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi +sql show dnodes +if $rows != 4 then + sleep 2000 + goto wait_dnode23_offline +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 + +if $dnode2Status != offline then + sleep 2000 + goto wait_dnode23_offline +endi +if $dnode3Status != offline then + sleep 2000 + goto wait_dnode23_offline +endi +if $dnode4Status != ready then + sleep 2000 + goto wait_dnode23_offline +endi + +$loopCnt = 0 +wait_dnode4_vgroup_master: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_master +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +print dnode4Vtatus: $dnode4Vtatus +print dnode3Vtatus: $dnode3Vtatus +if $dnode4Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_master +endi +if $dnode3Vtatus != offline then + sleep 2000 + goto wait_dnode4_vgroup_master +endi + +# check using select +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +sql insert into $tb values ( now , 20000 ) ( now + 1a, 20001 ) ( now + 2a, 20002 ) +$totalRows = $totalRows + 3 + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + diff --git a/tests/script/unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim b/tests/script/unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim new file mode 100644 index 0000000000000000000000000000000000000000..d22aca07cbd3d3c6a902076103c9759209c6a966 --- /dev/null +++ b/tests/script/unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim @@ -0,0 +1,435 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3 and add into cluster , then create database with replica 2, and create table, insert data +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +#system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 +#sql create dnode $hostname4 +sleep 2000 + +$totalTableNum = 10 +$sleepTimer = 3000 + +$db = db +sql create database $db replica 2 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 100 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +sleep 1000 +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: stop dnode3 for falling disc, then corrupt vnode data file in dnode3 +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sleep $sleepTimer + +$loopCnt = 0 +wait_dnode3_offline_0: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 3 then + sleep 2000 + goto wait_dnode3_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode3Status != offline then + sleep 2000 + goto wait_dnode3_offline_0 +endi + +$loopCnt = 0 +wait_dnode3_vgroup_offline: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode3_vgroup_offline +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode3Vtatus = $data5_2 +$dnode2Vtatus = $data7_2 + +if $dnode3Vtatus != offline then + sleep 2000 + goto wait_dnode3_vgroup_offline +endi +if $dnode2Vtatus != master then + sleep 2000 + goto wait_dnode3_vgroup_offline +endi + +#$expectCnt = 3 . : +#print expectCnt: [ $expectCnt ] +#system_content ls ../../../sim/dnode3/data/vnode/vnode2/tsdb/data/ -l | grep "^-" | wc -l | tr '\n' ':' +#system_content ls ../../../sim/dnode3/data/vnode/vnode2/tsdb/data/ -l | grep "^-" | wc -l | tr '\n' ':' +#print --2-->dnode3 data files: [ $system_content ] + + +system_content ls ../../../sim/dnode2/data/vnode/vnode2/tsdb/data/ -l | grep "^-" | wc -l | tr -d '\n' +print ---->dnode2 data files: $system_content expect: 0 +if $system_content != 0 then + return -1 +endi + +system_content ls ../../../sim/dnode3/data/vnode/vnode2/tsdb/data/ -l | grep "^-" | wc -l | tr -d '\n' +print ---->dnode3 data files: $system_content expect: 3 +if $system_content != 3 then + return -1 +endi + +system echo "haha, nothing......" > ../../../sim/dnode3/data/vnode/vnode2/tsdb/data/v2f1643.data + +print ============== step3-1: insert some news data for let version changed +sql insert into $tb values ( now + 0a , $x ) ( now + 1a , $x ) ( now + 2a , $x ) +sql insert into $tb values ( now + 10a , $x ) ( now + 11a , $x ) ( now + 12a , $x ) +$totalRows = $totalRows + 6 +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step4: restart dnode3, and run query +system sh/exec.sh -n dnode3 -s start +sleep $sleepTimer +$loopCnt = 0 +wait_dnode3_reready: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 3 then + sleep 2000 + goto wait_dnode3_reready +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode3Status != ready then + sleep 2000 + goto wait_dnode3_reready +endi +$loopCnt = 0 +wait_dnode3_vgroup_slave: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode3_vgroup_slave +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode2Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +if $dnode2Vtatus != master then + sleep 2000 + goto wait_dnode3_vgroup_slave +endi +if $dnode3Vtatus != slave then + sleep 2000 + goto wait_dnode3_vgroup_slave +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +system_content ls ../../../sim/dnode2/data/vnode/vnode2/tsdb/data/ -l |grep "^-"|wc -l | tr -d '\n' +print ----> dnode2 data files: $system_content expect: 0 +if $system_content != 0 then + return -1 +endi + +system_content ls ../../../sim/dnode3/data/vnode/vnode2/tsdb/data/ -l |grep "^-"|wc -l | tr -d '\n' +print ----> dnode3 data files: $system_content expect: 0 +if $system_content != 0 then + print there should be no data file in dnode3 after sync + return -1 +endi + +print ============== step5: stop dnode2, and check if dnode3 sync ok +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep $sleepTimer + +$loopCnt = 0 +wait_dnode2_offline_0: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi +sql show dnodes +if $rows != 3 then + sleep 2000 + goto wait_dnode2_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode2Status != offline then + sleep 2000 + goto wait_dnode2_offline_0 +endi + +$loopCnt = 0 +wait_dnode3_vgroup_master: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode3_vgroup_master +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode2Vtatus = $data7_2 +$dnode3Vtatus = $data5_2 + +if $dnode2Vtatus != offline then + sleep 2000 + goto wait_dnode3_vgroup_master +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode3_vgroup_master +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step6: stop dnode3 for falling disck +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sleep $sleepTimer +sql show dnodes +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 + +sql show vgroups +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 + + +print ============== step7: restart dnode3, and run query +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sleep $sleepTimer +$loopCnt = 0 +wait_dnode23_reready_2: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi +sql show dnodes +if $rows != 3 then + sleep 2000 + goto wait_dnode23_reready_2 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 + +if $dnode2Status != ready then + sleep 2000 + goto wait_dnode23_reready_2 +endi + +if $dnode3Status != ready then + sleep 2000 + goto wait_dnode23_reready_2 +endi + +$loopCnt = 0 +wait_dnode23_vgroup_ok: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode23_vgroup_ok +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode2Vtatus = $data7_2 +$dnode3Vtatus = $data5_2 + +if $dnode2Vtatus == offline then + sleep 2000 + goto wait_dnode23_vgroup_ok +endi +if $dnode3Vtatus == offline then + sleep 2000 + goto wait_dnode23_vgroup_ok +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/script/unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim b/tests/script/unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim new file mode 100644 index 0000000000000000000000000000000000000000..884a43bce12d1bc2c137bab17b0e780c521e327c --- /dev/null +++ b/tests/script/unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim @@ -0,0 +1,354 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3 and add into cluster , then create database with replica 2, and create table, insert data to can fall disc +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +#system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 +#sql create dnode $hostname4 +sleep 2000 + +$totalTableNum = 4 +$sleepTimer = 3000 + +$db = db +sql create database $db cache 1 replica 2 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 128 * 1024 +$tblNum = 1 +$totalRows = 0 +$tsStart = 1420041600000 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + $tsLast = $ts + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +sleep 1000 +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: corrupt vnode data file in dnode3, not stop dnode3 +system echo "haha, nothing......" > ../../../sim/dnode3/data/vnode/vnode2/tsdb/data/v2f1643.data +sleep 1000 + +print ============== step4: insert new data, and run query +sql insert into $tb values ( now + 0a , $x ) ( now + 1a , $x ) ( now + 2a , $x ) +$totalRows = $totalRows + 3 + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print show dnodes +sql show dnodes +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 + +print show vgroups +sql show vgroups +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 + + +$tsStart = $tsLast + 1 +$i = 0 +while $i < $tblNum + $tb = tb . $i + #sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + $tsLast = $ts + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step5: stop dnode2, and check if dnode3 sync ok +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep $sleepTimer + +$loopCnt = 0 +wait_dnode2_offline_0: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 3 then + sleep 2000 + goto wait_dnode2_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode2Status != offline then + sleep 2000 + goto wait_dnode2_offline_0 +endi + +$loopCnt = 0 +wait_dnode3_vgroup_master: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode3_vgroup_master +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode2Vtatus = $data7_2 +$dnode3Vtatus = $data5_2 + +if $dnode2Vtatus != offline then + sleep 2000 + goto wait_dnode3_vgroup_master +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode3_vgroup_master +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step6: stop dnode3 for falling disc +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sleep $sleepTimer + +$loopCnt = 0 +wait_dnode3_offline_0: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 3 then + sleep 2000 + goto wait_dnode3_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode2Status != offline then + sleep 2000 + goto wait_dnode3_offline_0 +endi + +if $dnode3Status != offline then + sleep 2000 + goto wait_dnode3_offline_0 +endi + + +$loopCnt = 0 +wait_dnode3_vgroup_offline: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode3_vgroup_offline +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode2Vtatus = $data7_2 +$dnode3Vtatus = $data5_2 + +if $dnode2Vtatus != offline then + sleep 2000 + goto wait_dnode3_vgroup_offline +endi +if $dnode3Vtatus != offline then + sleep 2000 + goto wait_dnode3_vgroup_offline +endi + +print ============== step7: restart dnode2/dnode3, and run query +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sleep $sleepTimer +$loopCnt = 0 +wait_dnode3_reready: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 3 then + sleep 2000 + goto wait_dnode3_reready +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 + +if $dnode3Status != ready then + sleep 2000 + goto wait_dnode3_reready +endi + +$loopCnt = 0 +wait_dnode3_vgroup_master_1: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode3_vgroup_master_1 +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode2Vtatus = $data7_2 +$dnode3Vtatus = $data5_2 + +if $dnode2Vtatus != slave then + sleep 2000 + goto wait_dnode3_vgroup_master_1 +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode3_vgroup_master_1 +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + + + + + + + + + + diff --git a/tests/script/unique/arbitrator/dn3_mn1_vnode_createErrData_online.sim b/tests/script/unique/arbitrator/dn3_mn1_vnode_createErrData_online.sim new file mode 100644 index 0000000000000000000000000000000000000000..3c74de49166067624335937d0e0486924b9fdb4f --- /dev/null +++ b/tests/script/unique/arbitrator/dn3_mn1_vnode_createErrData_online.sim @@ -0,0 +1,316 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3 and add into cluster , then create database with replica 2, and create table, insert data +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +#system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 +#sql create dnode $hostname4 +sleep 2000 + +$totalTableNum = 10 +$sleepTimer = 3000 + +$db = db +sql create database $db replica 2 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 100 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +sleep 1000 +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: corrupt vnode data file in dnode3, not stop dnode3 +system echo "haha, nothing......" > ../../../sim/dnode3/data/vnode/vnode2/tsdb/data/v2f1643.data +sleep 1000 + +print ============== step4: insert new data, and run query +sql insert into $tb values ( now + 0a , $x ) ( now + 1a , $x ) ( now + 2a , $x ) +$totalRows = $totalRows + 3 + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step5: stop dnode2, and check if dnode3 sync ok +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep $sleepTimer + +$loopCnt = 0 +wait_dnode2_offline_0: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 3 then + sleep 2000 + goto wait_dnode2_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode2Status != offline then + sleep 2000 + goto wait_dnode2_offline_0 +endi + +$loopCnt = 0 +wait_dnode3_vgroup_master: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode3_vgroup_master +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode2Vtatus = $data7_2 +$dnode3Vtatus = $data5_2 + +if $dnode2Vtatus != offline then + sleep 2000 + goto wait_dnode3_vgroup_master +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode3_vgroup_master +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step6: stop dnode3 for falling disc +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sleep $sleepTimer + +$loopCnt = 0 +wait_dnode3_offline_0: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 3 then + sleep 2000 + goto wait_dnode3_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode2Status != offline then + sleep 2000 + goto wait_dnode3_offline_0 +endi + +if $dnode3Status != offline then + sleep 2000 + goto wait_dnode3_offline_0 +endi + + +$loopCnt = 0 +wait_dnode3_vgroup_offline: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode3_vgroup_offline +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode2Vtatus = $data7_2 +$dnode3Vtatus = $data5_2 + +if $dnode2Vtatus != offline then + sleep 2000 + goto wait_dnode3_vgroup_offline +endi +if $dnode3Vtatus != offline then + sleep 2000 + goto wait_dnode3_vgroup_offline +endi + +print ============== step7: restart dnode2/dnode3, and run query +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sleep $sleepTimer +$loopCnt = 0 +wait_dnode3_reready: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 3 then + sleep 2000 + goto wait_dnode3_reready +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 + +if $dnode3Status != ready then + sleep 2000 + goto wait_dnode3_reready +endi + +$loopCnt = 0 +wait_dnode3_vgroup_master_1: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode3_vgroup_master_1 +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode2Vtatus = $data7_2 +$dnode3Vtatus = $data5_2 + +if $dnode2Vtatus != slave then + sleep 2000 + goto wait_dnode3_vgroup_master_1 +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode3_vgroup_master_1 +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + + + + + + + + + + diff --git a/tests/script/unique/arbitrator/dn3_mn1_vnode_delDir.sim b/tests/script/unique/arbitrator/dn3_mn1_vnode_delDir.sim new file mode 100644 index 0000000000000000000000000000000000000000..d0399222f14cc8b8d7ac12ebca8b91549c34942d --- /dev/null +++ b/tests/script/unique/arbitrator/dn3_mn1_vnode_delDir.sim @@ -0,0 +1,458 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table, insert data +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 +sql create dnode $hostname4 +sleep 2000 + +$sleepTimer = 3000 + +$db = db +sql create database $db replica 3 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 100 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +sleep 1000 +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: stop dnode4, and remove its vnodeX subdirector +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep $sleepTimer + +$loopCnt = 0 +wait_dnode4_offline_0: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 5 then + sleep 2000 + goto wait_dnode4_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 + +if $dnode4Status != offline then + sleep 2000 + goto wait_dnode4_offline_0 +endi + + +$loopCnt = 0 +wait_dnode4_vgroup_offline: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +if $dnode4Vtatus != offline then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi + +system rm -rf ../../../sim/dnode4/data/vnode/* + +print ============== step4: restart dnode4, waiting sync end +system sh/exec.sh -n dnode4 -s start +sleep $sleepTimer + +$loopCnt = 0 +wait_dnode4_reready: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 5 then + sleep 2000 + goto wait_dnode4_reready +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 + +if $dnode4Status != ready then + sleep 2000 + goto wait_dnode4_reready +endi + +$loopCnt = 0 +wait_dnode4_vgroup_slave: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_slave +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +print dnode4Vtatus: $dnode4Vtatus +print dnode3Vtatus: $dnode3Vtatus +if $dnode4Vtatus != slave then + sleep 2000 + goto wait_dnode4_vgroup_slave +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_slave +endi + +print ============== step5: stop dnode3, and remove its vnodeX subdirector +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sleep $sleepTimer + +$loopCnt = 0 +wait_dnode3_offline: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 5 then + sleep 2000 + goto wait_dnode3_offline +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 + +if $dnode2Status != ready then + sleep 2000 + goto wait_dnode3_offline +endi +if $dnode3Status != offline then + sleep 2000 + goto wait_dnode3_offline +endi +if $dnode4Status != ready then + sleep 2000 + goto wait_dnode3_offline +endi + +system rm -rf ../../../sim/dnode3/data/vnode/* + +print ============== step6: restart dnode3, and check rows +system sh/exec.sh -n dnode3 -s start +sleep $sleepTimer + +$loopCnt = 0 +wait_dnode3_reready: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 5 then + sleep 2000 + goto wait_dnode3_reready +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 + +if $dnode3Status != ready then + sleep 2000 + goto wait_dnode3_reready +endi + +$loopCnt = 0 +wait_dnode3_vgroup_slave: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode3_vgroup_slave +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +print dnode4Vtatus: $dnode4Vtatus +print dnode3Vtatus: $dnode3Vtatus +if $dnode4Vtatus != master then + sleep 2000 + goto wait_dnode3_vgroup_slave +endi +if $dnode3Vtatus != slave then + sleep 2000 + goto wait_dnode3_vgroup_slave +endi + +# check using select +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +sql insert into $tb values ( now , 20000 ) ( now + 1a, 20001 ) ( now + 2a, 20002 ) +$totalRows = $totalRows + 3 + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step7: stop dnode2, and remove its vnodeX subdirector +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep $sleepTimer + +$loopCnt = 0 +wait_dnode2_offline: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 5 then + sleep 2000 + goto wait_dnode2_offline +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 + +if $dnode2Status != offline then + sleep 2000 + goto wait_dnode2_offline +endi +if $dnode3Status != ready then + sleep 2000 + goto wait_dnode2_offline +endi +if $dnode4Status != ready then + sleep 2000 + goto wait_dnode2_offline +endi + +system rm -rf ../../../sim/dnode2/data/vnode/* + +print ============== step8: restart dnode2, and check rows +system sh/exec.sh -n dnode2 -s start +sleep $sleepTimer + +$loopCnt = 0 +wait_dnode2_reready: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 5 then + sleep 2000 + goto wait_dnode2_reready +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 + +if $dnode2Status != ready then + sleep 2000 + goto wait_dnode2_reready +endi + +$loopCnt = 0 +wait_dnode2_vgroup_slave: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode2_vgroup_slave +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +print dnode4Vtatus: $dnode4Vtatus +print dnode3Vtatus: $dnode3Vtatus +if $dnode4Vtatus != master then + sleep 2000 + goto wait_dnode2_vgroup_slave +endi +if $dnode3Vtatus != slave then + sleep 2000 + goto wait_dnode2_vgroup_slave +endi + +# check using select +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +sql insert into $tb values ( now , 20000 ) ( now + 1a, 20001 ) ( now + 2a, 20002 ) +$totalRows = $totalRows + 3 + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + + + + + + + + + + diff --git a/tests/script/unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim b/tests/script/unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim new file mode 100644 index 0000000000000000000000000000000000000000..19b29bf342d7c8d045b16111fdc5d2ef9b2039f1 --- /dev/null +++ b/tests/script/unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim @@ -0,0 +1,434 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3 and add into cluster , then create database with replica 2, and create table, insert data +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +#system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 +#sql create dnode $hostname4 +sleep 2000 + +$totalTableNum = 10 +$sleepTimer = 3000 + +$db = db +sql create database $db replica 2 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 100 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +sleep 1000 +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: stop dnode3 for falling disc, then corrupt vnode data file in dnode3 +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sleep $sleepTimer + +$loopCnt = 0 +wait_dnode3_offline_0: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 4 then + sleep 2000 + goto wait_dnode3_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode3Status != offline then + sleep 2000 + goto wait_dnode3_offline_0 +endi + +$loopCnt = 0 +wait_dnode3_vgroup_offline: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode3_vgroup_offline +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode3Vtatus = $data5_2 +$dnode2Vtatus = $data7_2 + +if $dnode3Vtatus != offline then + sleep 2000 + goto wait_dnode3_vgroup_offline +endi +if $dnode2Vtatus != master then + sleep 2000 + goto wait_dnode3_vgroup_offline +endi + +#$expectCnt = 3 . : +#print expectCnt: [ $expectCnt ] +#system_content ls ../../../sim/dnode3/data/vnode/vnode2/tsdb/data/ -l | grep "^-" | wc -l | tr '\n' ':' +#system_content ls ../../../sim/dnode3/data/vnode/vnode2/tsdb/data/ -l | grep "^-" | wc -l | tr '\n' ':' +#print --2-->dnode3 data files: [ $system_content ] + + +system_content ls ../../../sim/dnode2/data/vnode/vnode2/tsdb/data/ -l | grep "^-" | wc -l | tr -d '\n' +print ---->dnode2 data files: $system_content expect: 0 +if $system_content != 0 then + return -1 +endi + +system_content ls ../../../sim/dnode3/data/vnode/vnode2/tsdb/data/ -l | grep "^-" | wc -l | tr -d '\n' +print ---->dnode3 data files: $system_content expect: 3 +if $system_content != 3 then + return -1 +endi + +#system echo "haha, nothing......" > ../../../sim/dnode3/data/vnode/vnode2/tsdb/data/f1643.data + +print ============== step3-1: insert some news data for let version changed +sql insert into $tb values ( now + 0a , $x ) ( now + 1a , $x ) ( now + 2a , $x ) +sql insert into $tb values ( now + 10a , $x ) ( now + 11a , $x ) ( now + 12a , $x ) +$totalRows = $totalRows + 6 +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step4: restart dnode3, and run query +system sh/exec.sh -n dnode3 -s start +sleep $sleepTimer +$loopCnt = 0 +wait_dnode3_reready: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 4 then + sleep 2000 + goto wait_dnode3_reready +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode3Status != ready then + sleep 2000 + goto wait_dnode3_reready +endi +$loopCnt = 0 +wait_dnode3_vgroup_slave: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode3_vgroup_slave +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode2Vtatus = $data7_2 +$dnode3Vtatus = $data5_2 + +if $dnode2Vtatus != master then + sleep 2000 + goto wait_dnode3_vgroup_slave +endi +if $dnode3Vtatus != slave then + sleep 2000 + goto wait_dnode3_vgroup_slave +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +system_content ls ../../../sim/dnode2/data/vnode/vnode2/tsdb/data/ -l |grep "^-"|wc -l | tr -d '\n' +print ----> dnode2 data files: $system_content expect: 0 +if $system_content != 0 then + return -1 +endi + +system_content ls ../../../sim/dnode3/data/vnode/vnode2/tsdb/data/ -l |grep "^-"|wc -l | tr -d '\n' +print ----> dnode3 data files: $system_content expect: 0 +if $system_content != 0 then + print there should be no data file in dnode3 after sync + return -1 +endi + +print ============== step5: stop dnode2, and check if dnode3 sync ok +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep $sleepTimer + +$loopCnt = 0 +wait_dnode2_offline_0: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi +sql show dnodes +if $rows != 4 then + sleep 2000 + goto wait_dnode2_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode2Status != offline then + sleep 2000 + goto wait_dnode2_offline_0 +endi + +$loopCnt = 0 +wait_dnode3_vgroup_master: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode3_vgroup_master +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode2Vtatus = $data7_2 +$dnode3Vtatus = $data5_2 + +if $dnode2Vtatus != offline then + sleep 2000 + goto wait_dnode3_vgroup_master +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode3_vgroup_master +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step6: stop dnode3 for falling disck +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sleep $sleepTimer +sql show dnodes +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 + +sql show vgroups +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 + + +print ============== step7: restart dnode2/dnode3, and run query +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sleep $sleepTimer +$loopCnt = 0 +wait_dnode23_reready_2: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi +sql show dnodes +if $rows != 4 then + sleep 2000 + goto wait_dnode23_reready_2 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 + +if $dnode2Status != ready then + sleep 2000 + goto wait_dnode23_reready_2 +endi +if $dnode3Status != ready then + sleep 2000 + goto wait_dnode23_reready_2 +endi + +$loopCnt = 0 +wait_dnode23_vgroup_ok: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode23_vgroup_ok +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode2Vtatus = $data7_2 +$dnode3Vtatus = $data5_2 + +if $dnode2Vtatus == offline then + sleep 2000 + goto wait_dnode23_vgroup_ok +endi +if $dnode3Vtatus == offline then + sleep 2000 + goto wait_dnode23_vgroup_ok +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/script/unique/arbitrator/dn3_mn1_vnode_nomaster.sim b/tests/script/unique/arbitrator/dn3_mn1_vnode_nomaster.sim new file mode 100644 index 0000000000000000000000000000000000000000..b9ee508f78602cee7d6c9f17dbc3e250e7014f72 --- /dev/null +++ b/tests/script/unique/arbitrator/dn3_mn1_vnode_nomaster.sim @@ -0,0 +1,299 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 + +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 20 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 20 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 20 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 20 + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table, insert data +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 +sql create dnode $hostname4 +sleep 2000 + +$sleepTimer = 3000 + +$db = db +sql create database $db replica 3 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 100 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: stop dnode4/dnode2 +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep $sleepTimer + +$loopCnt = 0 +wait_dnode4_offline_0: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi +sql show dnodes +if $rows != 5 then + sleep 2000 + goto wait_dnode4_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode4Status != offline then + sleep 2000 + goto wait_dnode4_offline_0 +endi +if $dnode2Status != offline then + sleep 2000 + goto wait_dnode4_offline_0 +endi + +$loopCnt = 0 +wait_dnode4_vgroup_offline: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +if $dnode4Vtatus != offline then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +if $dnode3Vtatus != unsynced then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi + +sql select count(*) from $stb -x s31 +s31: +#sql_error insert into $tb values (now, 9988) -x s32 +#s32: + +print ============== step4: restart dnode2, then create database with replica 2, and create table, insert data +system sh/exec.sh -n dnode2 -s start +sleep 2000 + +$totalTableNum = 10 +$sleepTimer = 3000 + +$db = db1 +sql create database $db replica 2 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 100 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step5: stop dnode3 +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sleep $sleepTimer +$loopCnt = 0 +wait_dnode3_offline_0: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi +sql show dnodes +if $rows != 5 then + sleep 2000 + goto wait_dnode3_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 + +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +print dnode1Status $dnode1Status +print dnode2Status $dnode2Status +print dnode3Status $dnode3Status +print dnode4Status $dnode4Status + +if $dnode3Status != offline then + sleep 2000 + goto wait_dnode3_offline_0 +endi +if $dnode2Status != ready then + sleep 2000 + goto wait_dnode3_offline_0 +endi + +$loopCnt = 0 +wait_dnode2_vgroup_master: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode2_vgroup_master +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode3Vtatus = $data5_3 +$dnode2Vtatus = $data7_3 + +if $dnode3Vtatus != offline then + sleep 2000 + goto wait_dnode2_vgroup_master +endi +if $dnode2Vtatus != master then + sleep 2000 + goto wait_dnode2_vgroup_master +endi + +sql insert into $tb values (now, 9000) (now + 1s, 9001) (now + 2s, 9002) +$totalRows = $totalRows + 3 +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + + + + + + + + + + + + + + + + + diff --git a/tests/script/unique/arbitrator/dn3_mn2_killDnode.sim b/tests/script/unique/arbitrator/dn3_mn2_killDnode.sim new file mode 100644 index 0000000000000000000000000000000000000000..d90853d2e41e8384acad2f4dcd5a95eee8298745 --- /dev/null +++ b/tests/script/unique/arbitrator/dn3_mn2_killDnode.sim @@ -0,0 +1,122 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 2 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +#system sh/cfg.sh -n dnode1 -c role -v 2 +#system sh/cfg.sh -n dnode2 -c role -v 2 +#system sh/cfg.sh -n dnode3 -c role -v 2 +#system sh/cfg.sh -n dnode4 -c role -v 2 + +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3 and add into cluster , then create database with replica 3, and create table to max tables +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +#system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +sleep 2000 +sql create dnode $hostname3 +#sql create dnode $hostname4 +sleep 2000 + +$totalTableNum = 4 +$sleepTimer = 3000 + +$db = db +sql create database $db replica 3 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 10 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) + $x = $x + 10 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print data00:$data00 totalRows:$totalRows +if $data00 != $totalRows then + return -1 +endi + + +print ============== step3: stop dnode2 +system sh/exec.sh -n dnode2 -s stop +sleep 2000 + +sql show mnodes +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +$mnode1Status = $data2_1 +$mnode2Status = $data2_2 +$mnode3Status = $data2_3 +#$mnode4Status = $data2_4 + +if $mnode1Status != master then + return -1 +endi + +if $mnode2Status != offline then + return -1 +endi + +sql reset query cache +sql select count(*) from $stb +print data00:$data00 totalRows:$totalRows +if $data00 != $totalRows then + return -1 +endi + + diff --git a/tests/script/unique/arbitrator/insert_duplicationTs.sim b/tests/script/unique/arbitrator/insert_duplicationTs.sim new file mode 100644 index 0000000000000000000000000000000000000000..4af47ca336c188c3194b9fc64925073f8fb406c2 --- /dev/null +++ b/tests/script/unique/arbitrator/insert_duplicationTs.sim @@ -0,0 +1,293 @@ +# Test case describe: dnode1 is only mnode, dnode2/dnode3 are only vnode +# step 1: start dnode1 +# step 2: start dnode2 and dnode3, and all added into cluster (Suppose dnode2 is master-vnode) +# step 3: create db, table, insert data, and Falling disc into file (control only one file, e.g. 1841) +# step 4: insert old data(now-15d) and new data(now+15d), control data rows in order to save in cache, not falling disc +# step 5: stop dnode2, so date rows falling disc, generate two new files 1840, 1842 in dnode2 +# step 6: insert two data rows: now-16d, now+16d +# step 7: restart dnode2, waiting sync end +# expect: in dnode2, the files 1840 and 1842 will be removed + +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3 and add into cluster , then create database with replica 2, and create table, insert data +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 +sleep 2000 + +$totalTableNum = 1 +$sleepTimer = 3000 + +$db = db +sql create database $db replica 2 cache 1 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 double) tags(t1 int) +$rowNum = 130000 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1577808000000 # 2020-01-01 00:00:00.000 + +# insert over 2M data in order to falling disc, generate one file +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum +# $ts = $tsStart + $x + sql insert into $tb values ( now + 0s , $x ) ( now + 1s , $x ) ( now + 2s , $x ) ( now + 3s , $x ) ( now + 4s , $x ) ( now + 5s , $x ) ( now + 6s , $x ) ( now + 7s , $x ) ( now + 8s , $x ) ( now + 9s , $x ) + $x = $x + 10 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql show db.vgroups; +print d1: $data04 $data05 , d2: $data06 $data07 + +sql select count(*) from $stb +print rtest1==> rows:$rows data00:$data00 +if $rows != 1 then + return -1 +endi + +if $data00 == 0 then + return -1 +endi + +$totalRows = $data00 + +sql select count(*) from $stb +print test2==> rows:$rows data00:$data00 +sql select count(*) from $stb +print test3==> rows:$rows data00:$data00 +sql select count(*) from $stb +print test4==> rows:$rows data00:$data00 +sql select count(*) from $stb +print test5==> rows:$rows data00:$data00 + +print ============== step3: insert old data(now-15d) and new data(now+15d), control data rows in order to save in cache, not falling disc +sql insert into $tb values ( now - 20d , -20 ) +sql insert into $tb values ( now - 40d , -40 ) +$totalRows = $totalRows + 2 + +print ============== step4: stop dnode2, so date rows falling disc, generate two new files in dnode2 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep $sleepTimer + +$loopCnt = 0 +wait_dnode2_offline: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 4 then + sleep 2000 + goto wait_dnode2_offline +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +#$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode2Status != offline then + sleep 2000 + goto wait_dnode2_offline +endi +if $dnode3Status != ready then + sleep 2000 + goto wait_dnode2_offline +endi + +sleep $sleepTimer # waitting for move master vnode of dnode2 to dnode3 +# check using select +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +sql select count(*) from $stb +print data00 $data00 +sql select count(*) from $stb +print data00 $data00 +sql select count(*) from $stb +print data00 $data00 +sql select count(*) from $stb +print data00 $data00 + +print ============== step5: insert two data rows: now-16d, now+16d, +sql insert into $tb values ( now - 21d , -21 ) +sql insert into $tb values ( now - 41d , -41 ) +$totalRows = $totalRows + 2 + +print ============== step6: restart dnode2, waiting sync end +system sh/exec.sh -n dnode2 -s start +sleep 2000 +$loopCnt = 0 +wait_dnode2_ready: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 4 then + sleep 2000 + goto wait_dnode2_ready +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +#$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode2Status != ready then + sleep 2000 + goto wait_dnode2_ready +endi + +sleep $sleepTimer +# check using select +sleep 3000 +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi diff --git a/tests/script/unique/arbitrator/offline_replica2_alterTable_online.sim b/tests/script/unique/arbitrator/offline_replica2_alterTable_online.sim new file mode 100644 index 0000000000000000000000000000000000000000..0adb6b475938c1aa37f56c20c5d6327c9f89d574 --- /dev/null +++ b/tests/script/unique/arbitrator/offline_replica2_alterTable_online.sim @@ -0,0 +1,217 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 2, and create table, insert data +system sh/exec.sh -n dnode2 -s start +#system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +#sql create dnode $hostname3 +sql create dnode $hostname4 +sleep 2000 + +$totalTableNum = 10 +$sleepTimer = 3000 + +$db = db +print create database $db replica 2 +sql create database $db replica 2 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int, c2 int) tags(t1 int) +$rowNum = 500 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 +$tsEnd = 0 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x , $x ) ( $ts + 1a , $x , $x ) ( $ts + 2a , $x , $x ) ( $ts + 3a , $x , $x ) ( $ts + 4a , $x , $x ) ( $ts + 5a , $x , $x ) ( $ts + 6a , $x , $x ) ( $ts + 7a , $x , $x ) ( $ts + 8a , $x , $x ) ( $ts + 9a , $x , $x ) ( $ts + 10a , $x , $x ) ( $ts + 11a , $x , $x ) ( $ts + 12a , $x , $x ) ( $ts + 13a , $x , $x ) ( $ts + 14a , $x , $x ) ( $ts + 15a , $x , $x ) ( $ts + 16a , $x , $x ) ( $ts + 17a , $x , $x ) ( $ts + 18a , $x , $x ) ( $ts + 19a , $x , $x ) + $x = $x + 20 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw +$tsEnd = $tsStart + $totalRows / $tblNum + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: stop dnode4 +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep $sleepTimer + +$loopCnt = 0 +wait_dnode4_offline_0: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi +sql show dnodes +if $rows != 4 then + sleep 2000 + goto wait_dnode4_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +#$dnode3Status = $data4_3 +$dnode4Status = $data4_3 +#$dnode5Status = $data4_5 + +if $dnode4Status != offline then + sleep 2000 + goto wait_dnode4_offline_0 +endi + +wait_dnode4_vgroup_offline: +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +if $dnode4Vtatus != offline then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi + +print ============== step4: alter table and insert more data rows +sql alter table $stb drop column c1 +sql alter table $stb add column f1 double + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql insert into $tb values (now, 10001, 1.0001) (now + 1s, 10002, 1.0002) (now + 2s, 10003, 1.0003) (now + 3s, 10004, 1.0004) + $i = $i + 1 +endw +$addRows = 4 * $tblNum +$totalRows = $totalRows + $addRows + +print ============== step5: restart dnode4, waiting dnode4 synced +system sh/exec.sh -n dnode4 -s start + +$loopCnt = 0 +wait_dnode4_ready: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi +sql show dnodes +if $rows != 4 then + sleep 2000 + goto wait_dnode4_ready +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +#$dnode2Status = $data4_2 +#$dnode3Status = $data4_3 +$dnode4Status = $data4_3 +#$dnode5Status = $data4_5 + +if $dnode4Status != ready then + sleep 2000 + goto wait_dnode4_ready +endi + +print ============== step6: check result + +sql reset query cache + +$cnt = 0 +wait_table_dropped: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql select count(*) from $stb +if $data00 != $totalRows then + print data00: $data00 totalRows: $totalRows + sleep 2000 + goto wait_table_dropped +endi + + + + diff --git a/tests/script/unique/arbitrator/offline_replica2_alterTag_online.sim b/tests/script/unique/arbitrator/offline_replica2_alterTag_online.sim new file mode 100644 index 0000000000000000000000000000000000000000..a0877ad89c20697e3b9a46f4512766fbd11439d8 --- /dev/null +++ b/tests/script/unique/arbitrator/offline_replica2_alterTag_online.sim @@ -0,0 +1,247 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +#system sh/cfg.sh -n dnode1 -c role -v 1 +#system sh/cfg.sh -n dnode2 -c role -v 2 +#system sh/cfg.sh -n dnode3 -c role -v 2 +#system sh/cfg.sh -n dnode4 -c role -v 2 + +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 2, and create table, insert data +system sh/exec.sh -n dnode2 -s start +#system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +#sql create dnode $hostname3 +sql create dnode $hostname4 +sleep 2000 + +$totalTableNum = 10 +$sleepTimer = 3000 + +$db = db +print create database $db replica 2 +sql create database $db replica 2 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int, c2 int) tags(t0 int, t1 int) +$rowNum = 500 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 +$tsEnd = 0 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i , $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x , $x ) ( $ts + 1a , $x , $x ) ( $ts + 2a , $x , $x ) ( $ts + 3a , $x , $x ) ( $ts + 4a , $x , $x ) ( $ts + 5a , $x , $x ) ( $ts + 6a , $x , $x ) ( $ts + 7a , $x , $x ) ( $ts + 8a , $x , $x ) ( $ts + 9a , $x , $x ) ( $ts + 10a , $x , $x ) ( $ts + 11a , $x , $x ) ( $ts + 12a , $x , $x ) ( $ts + 13a , $x , $x ) ( $ts + 14a , $x , $x ) ( $ts + 15a , $x , $x ) ( $ts + 16a , $x , $x ) ( $ts + 17a , $x , $x ) ( $ts + 18a , $x , $x ) ( $ts + 19a , $x , $x ) + $x = $x + 20 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw +$tsEnd = $tsStart + $totalRows / $tblNum + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: stop dnode4 +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep $sleepTimer +$cnt = 0 +wait_dnode4_offline_0: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show dnodes +if $rows != 4 then + sleep 2000 + goto wait_dnode4_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +#$dnode3Status = $data4_3 +$dnode4Status = $data4_3 +#$dnode5Status = $data4_5 + +if $dnode4Status != offline then + sleep 2000 + goto wait_dnode4_offline_0 +endi + +$cnt = 0 +wait_dnode4_vgroup_offline: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +if $dnode4Vtatus != offline then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi + +print ============== step4: alter table and tag, then drop all sub tables, recreate som subtable and insert more data rows +sql alter table $stb drop column c1 +sql alter table $stb add column f1 double + +sql alter table $stb add tag t2 int +sql alter table $stb add tag t3 int +sql alter table $stb drop tag t1 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql drop table $tb + $i = $i + 1 +endw + +$totalRows = 0 +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i , $i , $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x , $x ) ( $ts + 1a , $x , $x ) ( $ts + 2a , $x , $x ) ( $ts + 3a , $x , $x ) ( $ts + 4a , $x , $x ) ( $ts + 5a , $x , $x ) ( $ts + 6a , $x , $x ) ( $ts + 7a , $x , $x ) ( $ts + 8a , $x , $x ) ( $ts + 9a , $x , $x ) ( $ts + 10a , $x , $x ) ( $ts + 11a , $x , $x ) ( $ts + 12a , $x , $x ) ( $ts + 13a , $x , $x ) ( $ts + 14a , $x , $x ) ( $ts + 15a , $x , $x ) ( $ts + 16a , $x , $x ) ( $ts + 17a , $x , $x ) ( $ts + 18a , $x , $x ) ( $ts + 19a , $x , $x ) + $x = $x + 20 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw +$tsEnd = $tsStart + $totalRows / $tblNum + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step5: restart dnode4, waiting dnode4 synced +system sh/exec.sh -n dnode4 -s start + +$cnt = 0 +wait_dnode4_ready: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show dnodes +if $rows != 4 then + sleep 2000 + goto wait_dnode4_ready +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +#$dnode2Status = $data4_2 +#$dnode3Status = $data4_3 +$dnode4Status = $data4_3 +#$dnode5Status = $data4_5 + +if $dnode4Status != ready then + sleep 2000 + goto wait_dnode4_ready +endi + +print ============== step6: check result + +sql reset query cache + +$cnt = 0 +wait_table_dropped: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql select count(*) from $stb +if $data00 != $totalRows then + print data00: $data00 totalRows: $totalRows + sleep 2000 + goto wait_table_dropped +endi + + + + diff --git a/tests/script/unique/arbitrator/offline_replica2_createTable_online.sim b/tests/script/unique/arbitrator/offline_replica2_createTable_online.sim new file mode 100644 index 0000000000000000000000000000000000000000..376484a0661d89fcd38f6be790437e10c6ef2761 --- /dev/null +++ b/tests/script/unique/arbitrator/offline_replica2_createTable_online.sim @@ -0,0 +1,233 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 20 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 20 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 20 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 20 + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 2, and create table, insert data +system sh/exec.sh -n dnode2 -s start +#system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +#sql create dnode $hostname3 +sql create dnode $hostname4 +sleep 2000 + +$totalTableNum = 10 +$sleepTimer = 3000 + +$db = db +print create database $db replica 2 +sql create database $db replica 2 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 500 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 +$tsEnd = 0 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw +$tsEnd = $tsStart + $totalRows / $tblNum + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: stop dnode4 +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep $sleepTimer +$cnt = 0 +wait_dnode4_offline_0: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show dnodes +if $rows != 4 then + sleep 2000 + goto wait_dnode4_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +#$dnode3Status = $data4_3 +$dnode4Status = $data4_3 +#$dnode5Status = $data4_5 + +if $dnode4Status != offline then + sleep 2000 + goto wait_dnode4_offline_0 +endi + +$cnt = 0 +wait_dnode4_vgroup_offline: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +if $dnode4Vtatus != offline then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi + +print ============== step4: create more tables and insert data rows +$tsStart = $tsEnd + 1000 +$i = $tblNum +$tblNum = $tblNum * 2 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step5: restart dnode4, waiting dnode4 synced +system sh/exec.sh -n dnode4 -s start + +$cnt = 0 +wait_dnode4_ready: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show dnodes +if $rows != 4 then + sleep 2000 + goto wait_dnode4_ready +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +#$dnode2Status = $data4_2 +#$dnode3Status = $data4_3 +$dnode4Status = $data4_3 +#$dnode5Status = $data4_5 + +if $dnode4Status != ready then + sleep 2000 + goto wait_dnode4_ready +endi + +print ============== step6: check result + +sql reset query cache + +$cnt = 0 +wait_table_altered: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql select count(*) from $stb +if $data00 != $totalRows then + print data00: $data00 + sleep 2000 + goto wait_table_altered +endi + + + + diff --git a/tests/script/unique/arbitrator/offline_replica2_dropDb_online.sim b/tests/script/unique/arbitrator/offline_replica2_dropDb_online.sim new file mode 100644 index 0000000000000000000000000000000000000000..9f21193400a8d7833afe8dbc5b4671c2f623778d --- /dev/null +++ b/tests/script/unique/arbitrator/offline_replica2_dropDb_online.sim @@ -0,0 +1,180 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 2, and create table, insert data +system sh/exec.sh -n dnode2 -s start +#system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +#sql create dnode $hostname3 +sql create dnode $hostname4 +sleep 2000 + +$totalTableNum = 10 +$sleepTimer = 3000 + +$db = db +print create database $db replica 2 +sql create database $db replica 2 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 500 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 +$tsEnd = 0 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw +$tsEnd = $tsStart + $totalRows / $tblNum + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: stop dnode4 +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep $sleepTimer +$cnt = 0 +wait_dnode4_offline_0: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show dnodes +if $rows != 4 then + sleep 2000 + goto wait_dnode4_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +#$dnode3Status = $data4_3 +$dnode4Status = $data4_3 +#$dnode5Status = $data4_5 + +if $dnode4Status != offline then + sleep 2000 + goto wait_dnode4_offline_0 +endi + +$cnt = 0 +wait_dnode4_vgroup_offline: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +if $dnode4Vtatus != offline then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi + +print ============== step4: drop db +sql drop database $db + +print ============== step5: restart dnode4 +system sh/exec.sh -n dnode4 -s start + +print ============== step6: check result +sql reset query cache +$cnt = 0 +wait_database_dropped: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show databases +if $rows != 0 then + sleep 2000 + goto wait_database_dropped +endi + + + + diff --git a/tests/script/unique/arbitrator/offline_replica2_dropTable_online.sim b/tests/script/unique/arbitrator/offline_replica2_dropTable_online.sim new file mode 100644 index 0000000000000000000000000000000000000000..cb3bbb3a73f5213c346fc675049827730a6e3a01 --- /dev/null +++ b/tests/script/unique/arbitrator/offline_replica2_dropTable_online.sim @@ -0,0 +1,219 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 2, and create table, insert data +system sh/exec.sh -n dnode2 -s start +#system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +#sql create dnode $hostname3 +sql create dnode $hostname4 +sleep 2000 + +$totalTableNum = 10 +$sleepTimer = 3000 + +$db = db +print create database $db replica 2 +sql create database $db replica 2 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 500 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 +$tsEnd = 0 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw +$tsEnd = $tsStart + $totalRows / $tblNum + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: stop dnode4 +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep $sleepTimer +$cnt = 0 +wait_dnode4_offline_0: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show dnodes +if $rows != 4 then + sleep 2000 + goto wait_dnode4_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +#$dnode3Status = $data4_3 +$dnode4Status = $data4_3 +#$dnode5Status = $data4_5 + +if $dnode4Status != offline then + sleep 2000 + goto wait_dnode4_offline_0 +endi + +$cnt = 0 +wait_dnode4_vgroup_offline: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +if $dnode4Vtatus != offline then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi + +print ============== step4: drop some tables +$i = 1 +$dropTblNum = 6 + +while $i < $dropTblNum + $tb = tb . $i + sql drop table if exists $tb + $i = $i + 1 +endw +$tblNum = $tblNum - 5 + +print ============== step5: restart dnode4, waiting dnode4 synced +system sh/exec.sh -n dnode4 -s start + +$cnt = 0 +wait_dnode4_ready: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show dnodes +if $rows != 4 then + sleep 2000 + goto wait_dnode4_ready +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +#$dnode2Status = $data4_2 +#$dnode3Status = $data4_3 +$dnode4Status = $data4_3 +#$dnode5Status = $data4_5 + +if $dnode4Status != ready then + sleep 2000 + goto wait_dnode4_ready +endi + +print ============== step6: check result + +sql reset query cache + +$cnt = 0 +wait_table_dropped: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql select count(tbname) from $stb +if $data00 != $tblNum then + print data00: $data00 tblNum: $tblNum + sleep 2000 + goto wait_table_dropped +endi + + + + diff --git a/tests/script/unique/arbitrator/offline_replica3_alterTable_online.sim b/tests/script/unique/arbitrator/offline_replica3_alterTable_online.sim new file mode 100644 index 0000000000000000000000000000000000000000..8a9995f89162883c6529a3cd8e63bc764884147b --- /dev/null +++ b/tests/script/unique/arbitrator/offline_replica3_alterTable_online.sim @@ -0,0 +1,221 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table, insert data +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 +sql create dnode $hostname4 +sleep 2000 + +$totalTableNum = 10 +$sleepTimer = 3000 + +$db = db +print create database $db replica 3 +sql create database $db replica 3 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int, c2 int) tags(t1 int) +$rowNum = 500 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 +$tsEnd = 0 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x , $x ) ( $ts + 1a , $x , $x ) ( $ts + 2a , $x , $x ) ( $ts + 3a , $x , $x ) ( $ts + 4a , $x , $x ) ( $ts + 5a , $x , $x ) ( $ts + 6a , $x , $x ) ( $ts + 7a , $x , $x ) ( $ts + 8a , $x , $x ) ( $ts + 9a , $x , $x ) ( $ts + 10a , $x , $x ) ( $ts + 11a , $x , $x ) ( $ts + 12a , $x , $x ) ( $ts + 13a , $x , $x ) ( $ts + 14a , $x , $x ) ( $ts + 15a , $x , $x ) ( $ts + 16a , $x , $x ) ( $ts + 17a , $x , $x ) ( $ts + 18a , $x , $x ) ( $ts + 19a , $x , $x ) + $x = $x + 20 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw +$tsEnd = $tsStart + $totalRows / $tblNum + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: stop dnode4 +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep $sleepTimer +$cnt = 0 +wait_dnode4_offline_0: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show dnodes +if $rows != 5 then + sleep 2000 + goto wait_dnode4_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode4Status != offline then + sleep 2000 + goto wait_dnode4_offline_0 +endi + +$cnt = 0 +wait_dnode4_vgroup_offline: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +if $dnode4Vtatus != offline then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi + +print ============== step4: alter table and insert more data rows +sql alter table $stb drop column c1 +sql alter table $stb add column f1 double + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql insert into $tb values (now, 10001, 1.0001) (now + 1s, 10002, 1.0002) (now + 2s, 10003, 1.0003) (now + 3s, 10004, 1.0004) + $i = $i + 1 +endw +$addRows = 4 * $tblNum +$totalRows = $totalRows + $addRows + +print ============== step5: restart dnode4, waiting dnode4 synced +system sh/exec.sh -n dnode4 -s start + +$cnt = 0 +wait_dnode4_ready: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show dnodes +if $rows != 5 then + sleep 2000 + goto wait_dnode4_ready +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +#$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode4Status != ready then + sleep 2000 + goto wait_dnode4_ready +endi + +print ============== step6: check result + +sql reset query cache + +$cnt = 0 +wait_table_dropped: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql select count(*) from $stb +if $data00 != $totalRows then + print data00: $data00 totalRows: $totalRows + sleep 2000 + goto wait_table_dropped +endi + + + + diff --git a/tests/script/unique/arbitrator/offline_replica3_alterTag_online.sim b/tests/script/unique/arbitrator/offline_replica3_alterTag_online.sim new file mode 100644 index 0000000000000000000000000000000000000000..6eed563bbc7c79ac35a782fbd9f2ccaa79f277d6 --- /dev/null +++ b/tests/script/unique/arbitrator/offline_replica3_alterTag_online.sim @@ -0,0 +1,247 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +#system sh/cfg.sh -n dnode1 -c role -v 1 +#system sh/cfg.sh -n dnode2 -c role -v 2 +#system sh/cfg.sh -n dnode3 -c role -v 2 +#system sh/cfg.sh -n dnode4 -c role -v 2 + +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 20 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 20 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 20 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 20 + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table, insert data +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 +sql create dnode $hostname4 +sleep 2000 + +$totalTableNum = 10 +$sleepTimer = 3000 + +$db = db +print create database $db replica 3 +sql create database $db replica 3 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int, c2 int) tags(t0 int, t1 int) +$rowNum = 500 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 +$tsEnd = 0 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i , $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x , $x ) ( $ts + 1a , $x , $x ) ( $ts + 2a , $x , $x ) ( $ts + 3a , $x , $x ) ( $ts + 4a , $x , $x ) ( $ts + 5a , $x , $x ) ( $ts + 6a , $x , $x ) ( $ts + 7a , $x , $x ) ( $ts + 8a , $x , $x ) ( $ts + 9a , $x , $x ) ( $ts + 10a , $x , $x ) ( $ts + 11a , $x , $x ) ( $ts + 12a , $x , $x ) ( $ts + 13a , $x , $x ) ( $ts + 14a , $x , $x ) ( $ts + 15a , $x , $x ) ( $ts + 16a , $x , $x ) ( $ts + 17a , $x , $x ) ( $ts + 18a , $x , $x ) ( $ts + 19a , $x , $x ) + $x = $x + 20 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw +$tsEnd = $tsStart + $totalRows / $tblNum + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: stop dnode4 +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep $sleepTimer +$cnt = 0 +wait_dnode4_offline_0: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show dnodes +if $rows != 5 then + sleep 2000 + goto wait_dnode4_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode4Status != offline then + sleep 2000 + goto wait_dnode4_offline_0 +endi + +$cnt = 0 +wait_dnode4_vgroup_offline: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +if $dnode4Vtatus != offline then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi + +print ============== step4: alter table and tag, then drop all sub tables, recreate som subtable and insert more data rows +sql alter table $stb drop column c1 +sql alter table $stb add column f1 double + +sql alter table $stb add tag t2 int +sql alter table $stb add tag t3 int +sql alter table $stb drop tag t1 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql drop table $tb + $i = $i + 1 +endw + +$totalRows = 0 +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i , $i , $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x , $x ) ( $ts + 1a , $x , $x ) ( $ts + 2a , $x , $x ) ( $ts + 3a , $x , $x ) ( $ts + 4a , $x , $x ) ( $ts + 5a , $x , $x ) ( $ts + 6a , $x , $x ) ( $ts + 7a , $x , $x ) ( $ts + 8a , $x , $x ) ( $ts + 9a , $x , $x ) ( $ts + 10a , $x , $x ) ( $ts + 11a , $x , $x ) ( $ts + 12a , $x , $x ) ( $ts + 13a , $x , $x ) ( $ts + 14a , $x , $x ) ( $ts + 15a , $x , $x ) ( $ts + 16a , $x , $x ) ( $ts + 17a , $x , $x ) ( $ts + 18a , $x , $x ) ( $ts + 19a , $x , $x ) + $x = $x + 20 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw +$tsEnd = $tsStart + $totalRows / $tblNum + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step5: restart dnode4, waiting dnode4 synced +system sh/exec.sh -n dnode4 -s start + +$cnt = 0 +wait_dnode4_ready: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show dnodes +if $rows != 5 then + sleep 2000 + goto wait_dnode4_ready +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +#$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode4Status != ready then + sleep 2000 + goto wait_dnode4_ready +endi + +print ============== step6: check result + +sql reset query cache + +$cnt = 0 +wait_table_dropped: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql select count(*) from $stb +if $data00 != $totalRows then + print data00: $data00 totalRows: $totalRows + sleep 2000 + goto wait_table_dropped +endi + + + + diff --git a/tests/script/unique/arbitrator/offline_replica3_createTable_online.sim b/tests/script/unique/arbitrator/offline_replica3_createTable_online.sim new file mode 100644 index 0000000000000000000000000000000000000000..2633d822c91d87ad6e5cc70370ac880fd397b889 --- /dev/null +++ b/tests/script/unique/arbitrator/offline_replica3_createTable_online.sim @@ -0,0 +1,234 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 20 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 20 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 20 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 20 + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table, insert data +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 +sql create dnode $hostname4 +sleep 2000 + +$totalTableNum = 10 +$sleepTimer = 3000 +$maxTables = $totalTableNum * 2 + +$db = db +print create database $db replica 3 +sql create database $db replica 3 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 500 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 +$tsEnd = 0 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw +$tsEnd = $tsStart + $totalRows / $tblNum + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: stop dnode4 +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep $sleepTimer +$cnt = 0 +wait_dnode4_offline_0: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show dnodes +if $rows != 5 then + sleep 2000 + goto wait_dnode4_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode4Status != offline then + sleep 2000 + goto wait_dnode4_offline_0 +endi + +$cnt = 0 +wait_dnode4_vgroup_offline: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +if $dnode4Vtatus != offline then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi + +print ============== step4: create more tables and insert data rows +$tsStart = $tsEnd + 1000 +$i = $tblNum +$tblNum = $tblNum * 2 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step5: restart dnode4, waiting dnode4 synced +system sh/exec.sh -n dnode4 -s start + +$cnt = 0 +wait_dnode4_ready: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show dnodes +if $rows != 5 then + sleep 2000 + goto wait_dnode4_ready +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +#$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode4Status != ready then + sleep 2000 + goto wait_dnode4_ready +endi + +print ============== step6: check result + +sql reset query cache + +$cnt = 0 +wait_table_altered: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql select count(*) from $stb +if $data00 != $totalRows then + print data00: $data00 + sleep 2000 + goto wait_table_altered +endi + + + + diff --git a/tests/script/unique/arbitrator/offline_replica3_dropDb_online.sim b/tests/script/unique/arbitrator/offline_replica3_dropDb_online.sim new file mode 100644 index 0000000000000000000000000000000000000000..3abfc401611044b5cc7a1fb9411e4fd461beca78 --- /dev/null +++ b/tests/script/unique/arbitrator/offline_replica3_dropDb_online.sim @@ -0,0 +1,180 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table, insert data +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 +sql create dnode $hostname4 +sleep 2000 + +$totalTableNum = 10 +$sleepTimer = 3000 + +$db = db +print create database $db replica 3 +sql create database $db replica 3 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 500 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 +$tsEnd = 0 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw +$tsEnd = $tsStart + $totalRows / $tblNum + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: stop dnode4 +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep $sleepTimer +$cnt = 0 +wait_dnode4_offline_0: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show dnodes +if $rows != 5 then + sleep 2000 + goto wait_dnode4_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode4Status != offline then + sleep 2000 + goto wait_dnode4_offline_0 +endi + +$cnt = 0 +wait_dnode4_vgroup_offline: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +if $dnode4Vtatus != offline then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi + +print ============== step4: drop db +sql drop database $db + +print ============== step5: restart dnode4 +system sh/exec.sh -n dnode4 -s start + +print ============== step6: check result +sql reset query cache +$cnt = 0 +wait_database_dropped: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show databases +if $rows != 0 then + sleep 2000 + goto wait_database_dropped +endi + + + + diff --git a/tests/script/unique/arbitrator/offline_replica3_dropTable_online.sim b/tests/script/unique/arbitrator/offline_replica3_dropTable_online.sim new file mode 100644 index 0000000000000000000000000000000000000000..f2acb8b90a35186395ab559ee428a182a2cba0d4 --- /dev/null +++ b/tests/script/unique/arbitrator/offline_replica3_dropTable_online.sim @@ -0,0 +1,219 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table, insert data +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 +sql create dnode $hostname4 +sleep 2000 + +$totalTableNum = 10 +$sleepTimer = 3000 + +$db = db +print create database $db replica 3 +sql create database $db replica 3 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 500 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 +$tsEnd = 0 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw +$tsEnd = $tsStart + $totalRows / $tblNum + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: stop dnode4 +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep $sleepTimer +$cnt = 0 +wait_dnode4_offline_0: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show dnodes +if $rows != 5 then + sleep 2000 + goto wait_dnode4_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode4Status != offline then + sleep 2000 + goto wait_dnode4_offline_0 +endi + +$cnt = 0 +wait_dnode4_vgroup_offline: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +if $dnode4Vtatus != offline then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi + +print ============== step4: drop some tables +$i = 1 +$dropTblNum = 6 + +while $i < $dropTblNum + $tb = tb . $i + sql drop table if exists $tb + $i = $i + 1 +endw +$tblNum = $tblNum - 5 + +print ============== step5: restart dnode4, waiting dnode4 synced +system sh/exec.sh -n dnode4 -s start + +$cnt = 0 +wait_dnode4_ready: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show dnodes +if $rows != 5 then + sleep 2000 + goto wait_dnode4_ready +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +#$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode4Status != ready then + sleep 2000 + goto wait_dnode4_ready +endi + +print ============== step6: check result + +sql reset query cache + +$cnt = 0 +wait_table_dropped: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql select count(tbname) from $stb +if $data00 != $tblNum then + print data00: $data00 tblNum: $tblNum + sleep 2000 + goto wait_table_dropped +endi + + + + diff --git a/tests/script/unique/arbitrator/replica_changeWithArbitrator.sim b/tests/script/unique/arbitrator/replica_changeWithArbitrator.sim new file mode 100644 index 0000000000000000000000000000000000000000..9d0e967f4e1575195e126cd975540067038409c5 --- /dev/null +++ b/tests/script/unique/arbitrator/replica_changeWithArbitrator.sim @@ -0,0 +1,238 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c role -v 0 +system sh/cfg.sh -n dnode2 -c role -v 0 +system sh/cfg.sh -n dnode3 -c role -v 0 +system sh/cfg.sh -n dnode4 -c role -v 0 + +$totalTableNum = 12 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +system sh/cfg.sh -n dnode1 -c offlineThreshold -v 8 +system sh/cfg.sh -n dnode2 -c offlineThreshold -v 8 +system sh/cfg.sh -n dnode3 -c offlineThreshold -v 8 +system sh/cfg.sh -n dnode4 -c offlineThreshold -v 8 + +system sh/cfg.sh -n dnode1 -c statusInterval -v 3 +system sh/cfg.sh -n dnode2 -c statusInterval -v 3 +system sh/cfg.sh -n dnode3 -c statusInterval -v 3 +system sh/cfg.sh -n dnode4 -c statusInterval -v 3 + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: replica is 1, and start 1 dnode, then create tables and insert data +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +$totalTableNum = 12 + +$db = db +sql create database $db replica 1 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 10 +$tblNum = $totalTableNum +$totalRows = $rowNum * $tblNum + +$ts0 = 1420041600000 +$ts = $ts0 +$delta = 1 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + sql insert into $tb values ( $ts , $x ) + $x = $x + 1 + endw + $i = $i + 1 + print $tb inserted rows: $x +endw + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step2: add 1 new dnode, expect balanced +system sh/exec.sh -n dnode2 -s start +sql create dnode $hostname2 +sleep 2000 + +# expect after balanced, 2 vondes in dnode1, 1 vonde in dnode2 +$cnt = 0 +wait_dnode2_ready: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show dnodes +if $rows != 3 then + sleep 2000 + goto wait_dnode2_ready +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 + +if $dnode1Status != ready then + sleep 2000 + goto wait_dnode2_ready +endi +if $dnode2Status != ready then + sleep 2000 + goto wait_dnode2_ready +endi + +print ============== step3: stop dnode1/dnode2, modify cfg numOfMnodes to 2, and restart dnode1/dnode2 +system sh/exec.sh -n dnode1 -s stop +system sh/exec.sh -n dnode2 -s stop +sleep 2000 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 0 + +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +sleep 3000 + + +print ============= step4: wait dnode ready +$cnt = 0 +wait_dnode_ready: +$cnt = $cnt + 1 +if $cnt == 10 then + return -1 +endi +sql show dnodes +if $rows != 3 then + sleep 2000 + goto wait_dnode_ready +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +#print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +#$dnode3Status = $data4_3 +#$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode1Status != ready then + sleep 2000 + goto wait_dnode_ready +endi +if $dnode2Status != ready then + sleep 2000 + goto wait_dnode_ready +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step5: stop dnode1 +sleep 3000 +system sh/exec.sh -n dnode1 -s stop +sleep 2000 + +$cnt = 0 +wait_dnode2_master: +$cnt = $cnt + 1 +if $cnt == 10 then + return -1 +endi +sql show mnodes +if $rows != 2 then + sleep 2000 + goto wait_dnode2_master +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +#print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +#$dnode3Status = $data4_3 +#$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $data2_1 != offline then + sleep 2000 + goto wait_dnode2_master +endi +if $data2_2 != master then + sleep 2000 + goto wait_dnode2_master +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + + diff --git a/tests/script/unique/arbitrator/sync_replica2_alterTable_add.sim b/tests/script/unique/arbitrator/sync_replica2_alterTable_add.sim new file mode 100644 index 0000000000000000000000000000000000000000..a8c0e83cc1e5da61a473fa5b9753e90450e57bec --- /dev/null +++ b/tests/script/unique/arbitrator/sync_replica2_alterTable_add.sim @@ -0,0 +1,204 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 2, and create table, insert data +system sh/exec.sh -n dnode2 -s start +#system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +#sql create dnode $hostname3 +sql create dnode $hostname4 +sleep 2000 + +$totalTableNum = 10 +$sleepTimer = 3000 + +$db = db +print create database $db replica 2 +sql create database $db replica 2 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 500 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 +$tsEnd = 0 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw +$tsEnd = $tsStart + $totalRows / $tblNum + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: stop dnode4 +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep $sleepTimer +$cnt = 0 +wait_dnode4_offline_0: +$cnt = $cnt + 1 +if $cnt == 10 then + return -1 +endi +sql show dnodes +if $rows != 4 then + sleep 2000 + goto wait_dnode4_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +#$dnode3Status = $data4_3 +$dnode4Status = $data4_3 +#$dnode5Status = $data4_5 + +if $dnode4Status != offline then + sleep 2000 + goto wait_dnode4_offline_0 +endi + +$cnt = 0 +wait_dnode4_vgroup_offline: +$cnt = $cnt + 1 +if $cnt == 10 then + return -1 +endi +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +if $dnode4Vtatus != offline then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi + +print ============== step4: insert more data rows +$tsStart = $tsEnd + 1000 +$i = 0 +while $i < $tblNum + $tb = tb . $i + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print data00:$data00 totalRows:$totalRows +if $data00 != $totalRows then + return -1 +endi + +print ============== step5: restart dnode4, while alter table and insert data in other thead when dnode4 is syncing +system sh/exec.sh -n dnode4 -s start +run_back unique/arbitrator/sync_replica_alterTable_background_add.sim + +print ============== step6: check result +#in background.sim, add one column and insert 36 rows +$totalRows = $totalRows + 36 + +$cnt = 0 +wait_table_altered: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql select count(*) from $stb +if $data00 != $totalRows then + print data00:$data00 totalRows:$totalRows + sleep 2000 + goto wait_table_altered +endi + + + + diff --git a/tests/script/unique/arbitrator/sync_replica2_alterTable_drop.sim b/tests/script/unique/arbitrator/sync_replica2_alterTable_drop.sim new file mode 100644 index 0000000000000000000000000000000000000000..951d26635b257d1c1d3ab81889b66bb909b8038b --- /dev/null +++ b/tests/script/unique/arbitrator/sync_replica2_alterTable_drop.sim @@ -0,0 +1,204 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 2, and create table, insert data +system sh/exec.sh -n dnode2 -s start +#system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +#sql create dnode $hostname3 +sql create dnode $hostname4 +sleep 2000 + +$totalTableNum = 10 +$sleepTimer = 3000 + +$db = db +print create database $db replica 2 +sql create database $db replica 2 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 500 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 +$tsEnd = 0 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw +$tsEnd = $tsStart + $totalRows / $tblNum + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: stop dnode4 +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep $sleepTimer +$cnt = 0 +wait_dnode4_offline_0: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show dnodes +if $rows != 4 then + sleep 2000 + goto wait_dnode4_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +#$dnode3Status = $data4_3 +$dnode4Status = $data4_3 +#$dnode5Status = $data4_5 + +if $dnode4Status != offline then + sleep 2000 + goto wait_dnode4_offline_0 +endi + +$cnt = 0 +wait_dnode4_vgroup_offline: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +if $dnode4Vtatus != offline then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi + +print ============== step4: insert more data rows +$tsStart = $tsEnd + 1000 +$i = 0 +while $i < $tblNum + $tb = tb . $i + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step5: restart dnode4, while alter table and insert data in other thead when dnode4 is syncing +system sh/exec.sh -n dnode4 -s start +run_back unique/arbitrator/sync_replica_alterTable_background_drop.sim + +print ============== step6: check result +#in background.sim, drop one column and add one new column, then insert 36 rows +$totalRows = $totalRows + 36 + +$cnt = 0 +wait_table_altered: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql select count(*) from $stb +if $data00 != $totalRows then + print data00: $data00 + sleep 2000 + goto wait_table_altered +endi + + + + diff --git a/tests/script/unique/arbitrator/sync_replica2_dropDb.sim b/tests/script/unique/arbitrator/sync_replica2_dropDb.sim new file mode 100644 index 0000000000000000000000000000000000000000..e4e7f951881cf87c426c869774b2a3a548b29517 --- /dev/null +++ b/tests/script/unique/arbitrator/sync_replica2_dropDb.sim @@ -0,0 +1,200 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 2, and create table, insert data +system sh/exec.sh -n dnode2 -s start +#system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +#sql create dnode $hostname3 +sql create dnode $hostname4 +sleep 2000 + +$totalTableNum = 10 +$sleepTimer = 3000 + +$db = db +print create database $db replica 2 +sql create database $db replica 2 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 500 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 +$tsEnd = 0 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw +$tsEnd = $tsStart + $totalRows / $tblNum + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: stop dnode4 +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep $sleepTimer +$cnt = 0 +wait_dnode4_offline_0: +$cnt = $cnt + 1 +if $cnt == 10 then + return -1 +endi +sql show dnodes +if $rows != 4 then + sleep 2000 + goto wait_dnode4_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +#$dnode3Status = $data4_3 +$dnode4Status = $data4_3 +#$dnode5Status = $data4_5 + +if $dnode4Status != offline then + sleep 2000 + goto wait_dnode4_offline_0 +endi + +$cnt = 0 +wait_dnode4_vgroup_offline: +$cnt = $cnt + 1 +if $cnt == 10 then + return -1 +endi +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +if $dnode4Vtatus != offline then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi + +print ============== step4: insert more data rows +$tsStart = $tsEnd + 1000 +$i = 0 +while $i < $tblNum + $tb = tb . $i + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step5: restart dnode4, while drop database in other thead when dnode4 is syncing +system sh/exec.sh -n dnode4 -s start +run_back unique/arbitrator/sync_replica_dropDb_background.sim + +print ============== step6: check result +$cnt = 0 +wait_database_dropped: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show databases +if $rows != 0 then + sleep 2000 + goto wait_database_dropped +endi + + + + diff --git a/tests/script/unique/arbitrator/sync_replica2_dropTable.sim b/tests/script/unique/arbitrator/sync_replica2_dropTable.sim new file mode 100644 index 0000000000000000000000000000000000000000..0049dc6fba9bd33cd9c2e4f5b56510769dd0c60e --- /dev/null +++ b/tests/script/unique/arbitrator/sync_replica2_dropTable.sim @@ -0,0 +1,210 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 2, and create table, insert data +system sh/exec.sh -n dnode2 -s start +#system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +#sql create dnode $hostname3 +sql create dnode $hostname4 +sleep 2000 + +$totalTableNum = 10 +$sleepTimer = 3000 + +$db = db +print create database $db replica 2 +sql create database $db replica 2 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 500 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 +$tsEnd = 0 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw +$tsEnd = $tsStart + $totalRows / $tblNum + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: stop dnode4 +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep $sleepTimer +$cnt = 0 +wait_dnode4_offline_0: +$cnt = $cnt + 1 +if $cnt == 10 then + return -1 +endi +sql show dnodes +if $rows != 4 then + sleep 2000 + goto wait_dnode4_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode4Status = $data4_3 +#$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode4Status != offline then + sleep 2000 + goto wait_dnode4_offline_0 +endi + +$cnt = 0 +wait_dnode4_vgroup_offline: +$cnt = $cnt + 1 +if $cnt == 10 then + return -1 +endi +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +if $dnode4Vtatus != offline then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi + +print ============== step4: insert more data rows +$tsStart = $tsEnd + 1000 +$i = 0 +while $i < $tblNum + $tb = tb . $i + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print data00:$data00 totalRows:$totalRows +if $data00 != $totalRows then + return -1 +endi + +print ============== step5: restart dnode4, while drop some tables in other thread when dnode4 is syncing +system sh/exec.sh -n dnode4 -s start +run_back unique/arbitrator/sync_replica_dropTable_background.sim + +print ============== step6: check result +#in background.sim, drop 5 tables +$totalRows = $totalRows - 5400 + +$cnt = 0 +wait_table_dropped: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql select count(*) from $stb +if $data00 != $totalRows then + print data00:$data00 totalRows:$totalRows + sleep 2000 + goto wait_table_dropped +endi + +$tblNum = $tblNum - 5 +sql select count(tbname) from $stb +if $data00 != $tblNum then + print data00: $data00 tblNum: $tblNum + sleep 2000 + goto wait_table_dropped +endi + + diff --git a/tests/script/unique/arbitrator/sync_replica3_alterTable_add.sim b/tests/script/unique/arbitrator/sync_replica3_alterTable_add.sim new file mode 100644 index 0000000000000000000000000000000000000000..499089960100f0be445552112e2b2000164c1ca0 --- /dev/null +++ b/tests/script/unique/arbitrator/sync_replica3_alterTable_add.sim @@ -0,0 +1,198 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table, insert data +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 +sql create dnode $hostname4 +sleep 2000 + +$totalTableNum = 10 +$sleepTimer = 3000 + +$db = db +print create database $db replica 3 +sql create database $db replica 3 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 500 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 +$tsEnd = 0 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw +$tsEnd = $tsStart + $totalRows / $tblNum + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: stop dnode4 +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep $sleepTimer +$cnt = 0 +wait_dnode4_offline_0: +$cnt = $cnt + 1 +if $cnt == 10 then + return -1 +endi +sql show dnodes +if $rows != 5 then + sleep 2000 + goto wait_dnode4_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode4Status != offline then + sleep 2000 + goto wait_dnode4_offline_0 +endi + +$cnt = 0 +wait_dnode4_vgroup_offline: +$cnt = $cnt + 1 +if $cnt == 10 then + return -1 +endi +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +print show vgroups: +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +$dnode4Vtatus = $data05 +$dnode3Vtatus = $data07 + +if $dnode4Vtatus != offline then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi + +print ============== step4: insert more data rows +$tsStart = $tsEnd + 1000 +$i = 0 +while $i < $tblNum + $tb = tb . $i + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print data00:$data00 totalRows:$totalRows +if $data00 != $totalRows then + return -1 +endi + +print ============== step5: restart dnode4, while alter table and insert data in other thead when dnode4 is syncing +system sh/exec.sh -n dnode4 -s start +run_back unique/arbitrator/sync_replica_alterTable_background_add.sim + +print ============== step6: check result +#in background.sim, add one column and insert 36 rows +$totalRows = $totalRows + 36 + +$cnt = 0 +wait_table_altered: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql select count(*) from $stb +if $data00 != $totalRows then + print data00:$data00 totalRows:$totalRows + sleep 2000 + goto wait_table_altered +endi diff --git a/tests/script/unique/arbitrator/sync_replica3_alterTable_drop.sim b/tests/script/unique/arbitrator/sync_replica3_alterTable_drop.sim new file mode 100644 index 0000000000000000000000000000000000000000..10bd4fc8bd3946871605f66493e15cdde28ec257 --- /dev/null +++ b/tests/script/unique/arbitrator/sync_replica3_alterTable_drop.sim @@ -0,0 +1,204 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table, insert data +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 +sql create dnode $hostname4 +sleep 2000 + +$totalTableNum = 10 +$sleepTimer = 3000 + +$db = db +print create database $db replica 3 +sql create database $db replica 3 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 500 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 +$tsEnd = 0 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw +$tsEnd = $tsStart + $totalRows / $tblNum + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: stop dnode4 +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep $sleepTimer +$cnt = 0 +wait_dnode4_offline_0: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show dnodes +if $rows != 5 then + sleep 2000 + goto wait_dnode4_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode4Status != offline then + sleep 2000 + goto wait_dnode4_offline_0 +endi + +$cnt = 0 +wait_dnode4_vgroup_offline: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +if $dnode4Vtatus != offline then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi + +print ============== step4: insert more data rows +$tsStart = $tsEnd + 1000 +$i = 0 +while $i < $tblNum + $tb = tb . $i + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step5: restart dnode4, while alter table and insert data in other thead when dnode4 is syncing +system sh/exec.sh -n dnode4 -s start +run_back unique/arbitrator/sync_replica_alterTable_background_drop.sim + +print ============== step6: check result +#in background.sim, drop one column and add one new column, then insert 36 rows +$totalRows = $totalRows + 36 + +$cnt = 0 +wait_table_altered: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql select count(*) from $stb +if $data00 != $totalRows then + print data00: $data00 + sleep 2000 + goto wait_table_altered +endi + + + + diff --git a/tests/script/unique/arbitrator/sync_replica3_createTable.sim b/tests/script/unique/arbitrator/sync_replica3_createTable.sim new file mode 100644 index 0000000000000000000000000000000000000000..a0b391dd763f96fa6d340fad213943045b45ed69 --- /dev/null +++ b/tests/script/unique/arbitrator/sync_replica3_createTable.sim @@ -0,0 +1,212 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table, insert data +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 +sql create dnode $hostname4 +sleep 2000 + +$totalTableNum = 20 +$sleepTimer = 3000 + +$db = db +print create database $db replica 3 +sql create database $db replica 3 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 500 +$tblNum = 10 +$totalRows = 0 +$tsStart = 1420041600000 +$tsEnd = 0 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw +$tsEnd = $tsStart + $totalRows / $tblNum + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: stop dnode4 +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep $sleepTimer +$cnt = 0 +wait_dnode4_offline_0: +$cnt = $cnt + 1 +if $cnt == 10 then + return -1 +endi +sql show dnodes +if $rows != 4 then + sleep 2000 + goto wait_dnode4_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode4Status != offline then + sleep 2000 + goto wait_dnode4_offline_0 +endi + +$cnt = 0 +wait_dnode4_vgroup_offline: +$cnt = $cnt + 1 +if $cnt == 10 then + return -1 +endi +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +if $dnode4Vtatus != offline then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi + +print ============== step4: insert more data rows +$tsStart = $tsEnd + 1000 +$i = 0 +while $i < $tblNum + $tb = tb . $i + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print data00:$data00 totalRows:$totalRows +if $data00 != $totalRows then + return -1 +endi + +print ============== step5: restart dnode4, while alter table and insert data in other thead when dnode4 is syncing +system sh/exec.sh -n dnode4 -s start +run_back unique/arbitrator/sync_replica_createTable_background_add.sim + +print ============== step6: check result +#in background.sim, add 10 tables and insert 100 rows +$totalRows = $totalRows + 100 + +$cnt = 0 +wait_table_created: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi + +sql show tables +if $rows != $totalTableNum then + print rows:$rows totalTableNum:$totalTableNum + sleep 2000 + goto wait_table_created +endi + +sql select count(*) from $stb +if $data00 != $totalRows then + print data00:$data00 totalRows:$totalRows + sleep 2000 + goto wait_table_created +endi + + + + diff --git a/tests/script/unique/arbitrator/sync_replica3_dnodeChang_DropAddAlterTableDropDb.sim b/tests/script/unique/arbitrator/sync_replica3_dnodeChang_DropAddAlterTableDropDb.sim new file mode 100644 index 0000000000000000000000000000000000000000..68c6ecbd6ecf7c06b5ae595c16e5b7d4b89435bd --- /dev/null +++ b/tests/script/unique/arbitrator/sync_replica3_dnodeChang_DropAddAlterTableDropDb.sim @@ -0,0 +1,485 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +$totalTableNum = 40 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table, insert data +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 +sql create dnode $hostname4 +sleep 2000 + +$totalTableNum = 20 +$sleepTimer = 3000 + +$maxTables = $totalTableNum * 2 +$db = db +print create database $db replica 3 +sql create database $db replica 3 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 500 +$tblNum = 10 +$totalRows = 0 +$tsStart = 1420041600000 +$tsEnd = 0 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) + $x = $x + 10 + + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw +$tsEnd = $tsStart + $totalRows / $tblNum + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: stop dnode4 +system sh/exec.sh -n dnode4 -s stop -x SIGINT +$cnt = 0 +wait_dnode4_offline_0: +$cnt = $cnt + 1 +if $cnt == 10 then + return -1 +endi +sql show dnodes +if $rows != 4 then + sleep 2000 + goto wait_dnode4_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 + +if $dnode4Status != offline then + sleep 2000 + goto wait_dnode4_offline_0 +endi + +$cnt = 0 +wait_dnode4_vgroup_offline: +$cnt = $cnt + 1 +if $cnt == 10 then + return -1 +endi +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +if $dnode4Vtatus != offline then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi + +print ============== step4: drop some tables +sql drop table tb0 +sql drop table tb9 +sql drop table tb1 +sql drop table tb8 + +$totalRows = $totalRows - 40 +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step5: restart dnode4, waiting sync end +system sh/exec.sh -n dnode4 -s start + +$cnt = 0 +wait_dnode4_ready: +$cnt = $cnt + 1 +if $cnt == 10 then + return -1 +endi +sql show dnodes +if $rows != 4 then + sleep 2000 + goto wait_dnode4_ready +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 + +if $dnode4Status != ready then + sleep 2000 + goto wait_dnode4_ready +endi + +$cnt = 0 +wait_dnode4_vgroup_slave: +$cnt = $cnt + 1 +if $cnt == 10 then + return -1 +endi +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_slave +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +if $dnode4Vtatus != slave then + sleep 2000 + goto wait_dnode4_vgroup_slave +endi + +print ============== step6: stop dnode2/dnode3 and remove their data dir, and restart dnode2/dnode3 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sleep 1000 +system rm -rf ../../../sim/dnode2/data +system rm -rf ../../../sim/dnode3/data + +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start + +$cnt = 0 +wait_dnode4_vgroup_master: +$cnt = $cnt + 1 +if $cnt == 10 then + return -1 +endi +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_master +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +if $dnode4Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_master +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + + +print ============== step7: stop dnode4 and create some new tables +system sh/exec.sh -n dnode4 -s stop -x SIGINT + +$ts = $tsStart +sql insert into tb10 using stb tags(10) values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) +sql insert into tb11 using stb tags(11) values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) +sql insert into tb12 using stb tags(12) values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) +sql insert into tb13 using stb tags(13) values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) + +$totalRows = $totalRows + 40 +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step8: restart dnode4, waiting sync end +system sh/exec.sh -n dnode4 -s start + +$cnt = 0 +wait_dnode4_ready_2: +$cnt = $cnt + 1 +if $cnt == 10 then + return -1 +endi +sql show dnodes +if $rows != 4 then + sleep 2000 + goto wait_dnode4_ready_2 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 + +if $dnode4Status != ready then + sleep 2000 + goto wait_dnode4_ready_2 +endi + +$cnt = 0 +wait_dnode4_vgroup_slave_2: +$cnt = $cnt + 1 +if $cnt == 10 then + return -1 +endi +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_slave_2 +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +if $dnode4Vtatus != slave then + sleep 2000 + goto wait_dnode4_vgroup_slave_2 +endi + +print ============== step9: stop dnode2/dnode3 and remove their data dir, and restart dnode2/dnode3 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sleep 1000 +system rm -rf ../../../sim/dnode2/data +system rm -rf ../../../sim/dnode3/data + +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start + +$cnt = 0 +wait_dnode4_vgroup_master_2: +$cnt = $cnt + 1 +if $cnt == 10 then + return -1 +endi +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_master_2 +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +if $dnode4Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_master_2 +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + + +print ============== step10: stop dnode4 and alter table column +system sh/exec.sh -n dnode4 -s stop -x SIGINT + +sql alter table stb add column c2 int +sql alter table stb add column c3 int +sql alter table stb add column c4 int +sql alter table stb drop column c1 + +sql alter table stb add tag t2 int +sql alter table stb add tag t3 int +sql_error alter table stb drop tag t1 + +$ts = $tsEnd + 10000 +sql insert into tb2 values ( $ts + 0a , $x , $x , $x ) ( $ts + 1a , $x , $x , $x ) ( $ts + 2a , $x , $x , $x ) ( $ts + 3a , $x , $x , $x ) ( $ts + 4a , $x , $x , $x ) ( $ts + 5a , $x , $x , $x ) ( $ts + 6a , $x , $x , $x ) ( $ts + 7a , $x , $x , $x ) ( $ts + 8a , $x , $x , $x ) ( $ts + 9a , $x , $x , $x ) +sql insert into tb3 values ( $ts + 0a , $x , $x , $x ) ( $ts + 1a , $x , $x , $x ) ( $ts + 2a , $x , $x , $x ) ( $ts + 3a , $x , $x , $x ) ( $ts + 4a , $x , $x , $x ) ( $ts + 5a , $x , $x , $x ) ( $ts + 6a , $x , $x , $x ) ( $ts + 7a , $x , $x , $x ) ( $ts + 8a , $x , $x , $x ) ( $ts + 9a , $x , $x , $x ) +sql insert into tb4 values ( $ts + 0a , $x , $x , $x ) ( $ts + 1a , $x , $x , $x ) ( $ts + 2a , $x , $x , $x ) ( $ts + 3a , $x , $x , $x ) ( $ts + 4a , $x , $x , $x ) ( $ts + 5a , $x , $x , $x ) ( $ts + 6a , $x , $x , $x ) ( $ts + 7a , $x , $x , $x ) ( $ts + 8a , $x , $x , $x ) ( $ts + 9a , $x , $x , $x ) +sql insert into tb5 values ( $ts + 0a , $x , $x , $x ) ( $ts + 1a , $x , $x , $x ) ( $ts + 2a , $x , $x , $x ) ( $ts + 3a , $x , $x , $x ) ( $ts + 4a , $x , $x , $x ) ( $ts + 5a , $x , $x , $x ) ( $ts + 6a , $x , $x , $x ) ( $ts + 7a , $x , $x , $x ) ( $ts + 8a , $x , $x , $x ) ( $ts + 9a , $x , $x , $x ) + + +$ts = $tsStart +sql insert into tb14 using stb tags(14, 14, 14) values ( $ts + 0a , $x , $x , $x ) ( $ts + 1a , $x , $x , $x ) ( $ts + 2a , $x , $x , $x ) ( $ts + 3a , $x , $x , $x ) ( $ts + 4a , $x , $x , $x ) ( $ts + 5a , $x , $x , $x ) ( $ts + 6a , $x , $x , $x ) ( $ts + 7a , $x , $x , $x ) ( $ts + 8a , $x , $x , $x ) ( $ts + 9a , $x , $x , $x ) +sql insert into tb15 using stb tags(15, 15, 15) values ( $ts + 0a , $x , $x , $x ) ( $ts + 1a , $x , $x , $x ) ( $ts + 2a , $x , $x , $x ) ( $ts + 3a , $x , $x , $x ) ( $ts + 4a , $x , $x , $x ) ( $ts + 5a , $x , $x , $x ) ( $ts + 6a , $x , $x , $x ) ( $ts + 7a , $x , $x , $x ) ( $ts + 8a , $x , $x , $x ) ( $ts + 9a , $x , $x , $x ) +sql insert into tb16 using stb tags(16, 16, 16) values ( $ts + 0a , $x , $x , $x ) ( $ts + 1a , $x , $x , $x ) ( $ts + 2a , $x , $x , $x ) ( $ts + 3a , $x , $x , $x ) ( $ts + 4a , $x , $x , $x ) ( $ts + 5a , $x , $x , $x ) ( $ts + 6a , $x , $x , $x ) ( $ts + 7a , $x , $x , $x ) ( $ts + 8a , $x , $x , $x ) ( $ts + 9a , $x , $x , $x ) +sql insert into tb17 using stb tags(17, 17, 17) values ( $ts + 0a , $x , $x , $x ) ( $ts + 1a , $x , $x , $x ) ( $ts + 2a , $x , $x , $x ) ( $ts + 3a , $x , $x , $x ) ( $ts + 4a , $x , $x , $x ) ( $ts + 5a , $x , $x , $x ) ( $ts + 6a , $x , $x , $x ) ( $ts + 7a , $x , $x , $x ) ( $ts + 8a , $x , $x , $x ) ( $ts + 9a , $x , $x , $x ) + +$totalRows = $totalRows + 80 +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step11: restart dnode4, waiting sync end +system sh/exec.sh -n dnode4 -s start + +$cnt = 0 +wait_dnode4_ready_3: +$cnt = $cnt + 1 +if $cnt == 10 then + return -1 +endi +sql show dnodes +if $rows != 4 then + sleep 2000 + goto wait_dnode4_ready_3 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 + +if $dnode4Status != ready then + sleep 2000 + goto wait_dnode4_ready_3 +endi + +$cnt = 0 +wait_dnode4_vgroup_slave_3: +$cnt = $cnt + 1 +if $cnt == 10 then + return -1 +endi +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_slave_3 +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +if $dnode4Vtatus != slave then + sleep 2000 + goto wait_dnode4_vgroup_slave_3 +endi + +print ============== step12: stop dnode2/dnode3 and remove their data dir, and restart dnode2/dnode3 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sleep 1000 +system rm -rf ../../../sim/dnode2/data +system rm -rf ../../../sim/dnode3/data + +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start + +$cnt = 0 +wait_dnode4_vgroup_master_3: +$cnt = $cnt + 1 +if $cnt == 10 then + return -1 +endi +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_master_3 +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +if $dnode4Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_master_3 +endi + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi diff --git a/tests/script/unique/arbitrator/sync_replica3_dropDb.sim b/tests/script/unique/arbitrator/sync_replica3_dropDb.sim new file mode 100644 index 0000000000000000000000000000000000000000..83e53eaeeb16e0988b778ef0b2515dc12c397d38 --- /dev/null +++ b/tests/script/unique/arbitrator/sync_replica3_dropDb.sim @@ -0,0 +1,200 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table, insert data +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 +sql create dnode $hostname4 +sleep 2000 + +$totalTableNum = 10 +$sleepTimer = 3000 + +$db = db +print create database $db replica 3 +sql create database $db replica 3 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 500 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 +$tsEnd = 0 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw +$tsEnd = $tsStart + $totalRows / $tblNum + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: stop dnode4 +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep $sleepTimer +$cnt = 0 +wait_dnode4_offline_0: +$cnt = $cnt + 1 +if $cnt == 10 then + return -1 +endi +sql show dnodes +if $rows != 5 then + sleep 2000 + goto wait_dnode4_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode4Status != offline then + sleep 2000 + goto wait_dnode4_offline_0 +endi + +$cnt = 0 +wait_dnode4_vgroup_offline: +$cnt = $cnt + 1 +if $cnt == 10 then + return -1 +endi +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +if $dnode4Vtatus != offline then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi + +print ============== step4: insert more data rows +$tsStart = $tsEnd + 1000 +$i = 0 +while $i < $tblNum + $tb = tb . $i + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step5: restart dnode4, while drop database in other thead when dnode4 is syncing +system sh/exec.sh -n dnode4 -s start +run_back unique/arbitrator/sync_replica_dropDb_background.sim + +print ============== step6: check result +$cnt = 0 +wait_database_dropped: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql show databases +if $rows != 0 then + sleep 2000 + goto wait_database_dropped +endi + + + + diff --git a/tests/script/unique/arbitrator/sync_replica3_dropTable.sim b/tests/script/unique/arbitrator/sync_replica3_dropTable.sim new file mode 100644 index 0000000000000000000000000000000000000000..7496541b76da3245f034924e95fd468b61135aef --- /dev/null +++ b/tests/script/unique/arbitrator/sync_replica3_dropTable.sim @@ -0,0 +1,210 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table, insert data +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 +sql create dnode $hostname4 +sleep 2000 + +$totalTableNum = 10 +$sleepTimer = 3000 + +$db = db +print create database $db replica 3 +sql create database $db replica 3 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +$rowNum = 500 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1420041600000 +$tsEnd = 0 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw +$tsEnd = $tsStart + $totalRows / $tblNum + +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +print ============== step3: stop dnode4 +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep $sleepTimer +$cnt = 0 +wait_dnode4_offline_0: +$cnt = $cnt + 1 +if $cnt == 10 then + return -1 +endi +sql show dnodes +if $rows != 5 then + sleep 2000 + goto wait_dnode4_offline_0 +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +#$dnode1Status = $data4_1 +$dnode2Status = $data4_2 +$dnode3Status = $data4_3 +$dnode4Status = $data4_4 +#$dnode5Status = $data4_5 + +if $dnode4Status != offline then + sleep 2000 + goto wait_dnode4_offline_0 +endi + +$cnt = 0 +wait_dnode4_vgroup_offline: +$cnt = $cnt + 1 +if $cnt == 10 then + return -1 +endi +sql show vgroups +if $rows != 1 then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$dnode4Vtatus = $data5_2 +$dnode3Vtatus = $data7_2 + +if $dnode4Vtatus != offline then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi +if $dnode3Vtatus != master then + sleep 2000 + goto wait_dnode4_vgroup_offline +endi + +print ============== step4: insert more data rows +$tsStart = $tsEnd + 1000 +$i = 0 +while $i < $tblNum + $tb = tb . $i + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print data00:$data00 totalRows:$totalRows +if $data00 != $totalRows then + return -1 +endi + +print ============== step5: restart dnode4, while drop some tables in other thread when dnode4 is syncing +system sh/exec.sh -n dnode4 -s start +run_back unique/arbitrator/sync_replica_dropTable_background.sim + +print ============== step6: check result +#in background.sim, drop 5 tables +$totalRows = $totalRows - 5400 + +$cnt = 0 +wait_table_dropped: +$cnt = $cnt + 1 +if $cnt == 20 then + return -1 +endi +sql select count(*) from $stb +if $data00 != $totalRows then + print data00:$data00 totalRows:$totalRows + sleep 2000 + goto wait_table_dropped +endi + +$tblNum = $tblNum - 5 +sql select count(tbname) from $stb +if $data00 != $tblNum then + print data00: $data00 tblNum: $tblNum + sleep 2000 + goto wait_table_dropped +endi + + diff --git a/tests/script/unique/arbitrator/sync_replica_alterTable_background_add.sim b/tests/script/unique/arbitrator/sync_replica_alterTable_background_add.sim new file mode 100644 index 0000000000000000000000000000000000000000..46d5e34fcbf8d70b4f678fc8e5abf311c9363ce8 --- /dev/null +++ b/tests/script/unique/arbitrator/sync_replica_alterTable_background_add.sim @@ -0,0 +1,28 @@ +sql connect + +$db = db +$stb = stb +print =============== sync_replica_alterTable_background_add.sim step0: alter table and insert data +$totalTableNum = 10 + +sql use $db + +#sql create table $stb (ts timestamp, c1 int) tags(t1 int) +print alter table $stb add column f1 float +sql alter table $stb add column f1 float + +$tblNum = $totalTableNum +$alterTblNum = 10 + +sql reset query cache +sleep 100 + +$i = 1 +while $i < $alterTblNum + $tb = tb . $i + sql insert into $tb values (now, 10001, 10001) (now + 1s, 10002, 10002) (now + 2s, 10003, 10003) (now + 3s, 10004, 10004) + $i = $i + 1 +endw + + + diff --git a/tests/script/unique/arbitrator/sync_replica_alterTable_background_drop.sim b/tests/script/unique/arbitrator/sync_replica_alterTable_background_drop.sim new file mode 100644 index 0000000000000000000000000000000000000000..fb8bc60972e7ac5a2d5f1393fd5760168c3d843d --- /dev/null +++ b/tests/script/unique/arbitrator/sync_replica_alterTable_background_drop.sim @@ -0,0 +1,25 @@ +sql connect + +$db = db +$stb = stb +print =============== sync_replica_alterTable_background_drop.sim step0: alter table and insert data +$totalTableNum = 100 + +sql use $db + +#sql create table $stb (ts timestamp, c1 int) tags(t1 int) +sql alter table $stb add column f1 double +sql alter table $stb drop column c1 + +$tblNum = $totalTableNum +$alterTblNum = 10 + +$i = 1 +while $i < $alterTblNum + $tb = tb . $i + sql insert into $tb values (now, 10001) (now + 1s, 10002) (now + 2s, 10003) (now + 3s, 10004) + $i = $i + 1 +endw + + + diff --git a/tests/script/unique/arbitrator/sync_replica_createTable_background_add.sim b/tests/script/unique/arbitrator/sync_replica_createTable_background_add.sim new file mode 100644 index 0000000000000000000000000000000000000000..50893b58a6125cfa3ae15e0472b78538f2c9256e --- /dev/null +++ b/tests/script/unique/arbitrator/sync_replica_createTable_background_add.sim @@ -0,0 +1,32 @@ +sql connect + +$db = db +$stb = stb +print =============== sync_replica_createTable_background_add.sim step0: create table and insert data +$totalTableNum = 10 + +sql use $db + +#sql create table $stb (ts timestamp, c1 int) tags(t1 int) +# create table , insert data +#$rowNum = 500 +$tblNum = 20 +$totalRows = 100 +$tsStart = 1420141600000 +$tsEnd = 0 + +$i = 10 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 10 + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) + + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + + diff --git a/tests/script/unique/arbitrator/sync_replica_dropDb_background.sim b/tests/script/unique/arbitrator/sync_replica_dropDb_background.sim new file mode 100644 index 0000000000000000000000000000000000000000..440b525bd7b8b5a1beebc4b10aa89f410d597d77 --- /dev/null +++ b/tests/script/unique/arbitrator/sync_replica_dropDb_background.sim @@ -0,0 +1,6 @@ +sql connect + +$db = db +$stb = stb +print =============== sync_replica_dropDb_background.sim step0: drop db +sql drop database if exists $db diff --git a/tests/script/unique/arbitrator/sync_replica_dropTable_background.sim b/tests/script/unique/arbitrator/sync_replica_dropTable_background.sim new file mode 100644 index 0000000000000000000000000000000000000000..485253027a5d4521aac63ab8ad6f5f7ffba726e9 --- /dev/null +++ b/tests/script/unique/arbitrator/sync_replica_dropTable_background.sim @@ -0,0 +1,18 @@ +sql connect + +$db = db +$stb = stb +print =============== sync_replica_dropTable_background.sim step0: drop table +$totalTableNum = 6 + +sql use $db + +$tblNum = $totalTableNum +$dropTblNum = 6 + +$i = 1 +while $i < $dropTblNum + $tb = tb . $i + sql drop table if exists $tb + $i = $i + 1 +endw diff --git a/tests/script/unique/arbitrator/testSuite.sim b/tests/script/unique/arbitrator/testSuite.sim new file mode 100644 index 0000000000000000000000000000000000000000..127a320e53db686a8109505d3299715edaa262e4 --- /dev/null +++ b/tests/script/unique/arbitrator/testSuite.sim @@ -0,0 +1,41 @@ +run unique/arbitrator/check_cluster_cfg_para.sim +run unique/arbitrator/dn2_mn1_cache_file_sync.sim +run unique/arbitrator/dn3_mn1_full_createTableFail.sim +run unique/arbitrator/dn3_mn1_full_dropDnodeFail.sim +run unique/arbitrator/dn3_mn1_multiCreateDropTable.sim +run unique/arbitrator/dn3_mn1_nw_disable_timeout_autoDropDnode.sim +run unique/arbitrator/dn3_mn1_replica2_wal1_AddDelDnode.sim +run unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim +run unique/arbitrator/dn3_mn1_replica_change.sim +run unique/arbitrator/dn3_mn1_stopDnode_timeout.sim +run unique/arbitrator/dn3_mn1_vnode_change.sim +run unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim +run unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim +run unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim +run unique/arbitrator/dn3_mn1_vnode_delDir.sim +run unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim +run unique/arbitrator/dn3_mn1_r3_vnode_delDir.sim +run unique/arbitrator/dn3_mn1_vnode_nomaster.sim +run unique/arbitrator/dn3_mn2_killDnode.sim +run unique/arbitrator/insert_duplicationTs.sim +run unique/arbitrator/offline_replica2_alterTable_online.sim +run unique/arbitrator/offline_replica2_alterTag_online.sim +run unique/arbitrator/offline_replica2_createTable_online.sim +run unique/arbitrator/offline_replica2_dropDb_online.sim +run unique/arbitrator/offline_replica2_dropTable_online.sim +run unique/arbitrator/offline_replica3_alterTable_online.sim +run unique/arbitrator/offline_replica3_alterTag_online.sim +run unique/arbitrator/offline_replica3_createTable_online.sim +run unique/arbitrator/offline_replica3_dropDb_online.sim +run unique/arbitrator/offline_replica3_dropTable_online.sim +run unique/arbitrator/replica_changeWithArbitrator.sim +run unique/arbitrator/sync_replica2_alterTable_add.sim +run unique/arbitrator/sync_replica2_alterTable_drop.sim +run unique/arbitrator/sync_replica3_createTable.sim +run unique/arbitrator/sync_replica3_dnodeChang_DropAddAlterTableDropDb.sim +run unique/arbitrator/sync_replica2_dropDb.sim +run unique/arbitrator/sync_replica2_dropTable.sim +run unique/arbitrator/sync_replica3_alterTable_add.sim +run unique/arbitrator/sync_replica3_alterTable_drop.sim +run unique/arbitrator/sync_replica3_dropDb.sim +run unique/arbitrator/sync_replica3_dropTable.sim diff --git a/tests/script/unique/big/balance.sim b/tests/script/unique/big/balance.sim new file mode 100644 index 0000000000000000000000000000000000000000..f20939d458d512472cb822b44b5af0b378347017 --- /dev/null +++ b/tests/script/unique/big/balance.sim @@ -0,0 +1,399 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 4 +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 1000 + +system sh/deploy.sh -n dnode2 -i 2 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 4 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 1000 + +system sh/deploy.sh -n dnode3 -i 3 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 4 +system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 1000 + +system sh/deploy.sh -n dnode4 -i 4 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 4 +system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 1000 + +system sh/deploy.sh -n dnode5 -i 5 +system sh/cfg.sh -n dnode5 -c maxVgroupsPerDb -v 4 +system sh/cfg.sh -n dnode5 -c maxTablesPerVnode -v 1000 + +print =============== prepare data +system sh/exec.sh -n dnode1 -s start +sql connect + +$i = 0 +$tbNum = 4000 +$rowNum = 1 +$totalNum = 4000 * $rowNum + +sql create database db +sql use db +sql create table mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +$tbPrefix = t +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using mt tags( $i ) + $i = $i + 1 +endw + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql insert into $tb values (now, $i , $i ) + + $i = $i + 1 +endw + +print ========== step0 +sql show db.tables +if $rows != 4000 then + return -1 +endi + +sql select count(*) from t10 +print select count(*) from t10 $data00 expect $rowNum +if $data00 != $rowNum then + return -1 +endi + +sql select count(*) from t1010 +print select count(*) from t1010 $data00 expect $rowNum +if $data00 != $rowNum then + return -1 +endi + +sql select count(*) from t2010 +print select count(*) from t2010 $data00 expect $rowNum +if $data00 != $rowNum then + return -1 +endi + +sql select count(*) from t3010 +print select count(*) from t3010 $data00 expect $rowNum +if $data00 != $rowNum then + return -1 +endi + +sql select count(*) from mt +print select count(*) from mt $data00 expect $rowNum +if $data00 != $totalNum then + return -1 +endi + +print ========== step1 +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +show1: + $x = $x + 1 + sleep 1000 + if $x == 30 then + return -1 + endi + +sql show dnodes +print dnode1 openvnodes $data2_1 +print dnode2 openvnodes $data2_2 +if $data2_1 != 2 then + goto show1 +endi +if $data2_2 != 2 then + goto show1 +endi + +sql reset query cache +sleep 100 + +sql select count(*) from t10 +print select count(*) from t10 $data00 expect $rowNum +if $data00 != $rowNum then + goto show1 +endi + +sql select count(*) from t1010 +print select count(*) from t1010 $data00 expect $rowNum +if $data00 != $rowNum then + goto show1 +endi + +sql select count(*) from t2010 +print select count(*) from t2010 $data00 expect $rowNum +if $data00 != $rowNum then + goto show1 +endi + +sql select count(*) from t3010 +print select count(*) from t3010 $data00 expect $rowNum +if $data00 != $rowNum then + goto show1 +endi + +sql select count(*) from mt +print select count(*) from mt $data00 expect $rowNum +if $data00 != $totalNum then + goto show1 +endi + +print ========== step2 +sql create dnode $hostname3 +system sh/exec.sh -n dnode3 -s start + +print ========== step3 +sql drop dnode $hostname2 + +$x = 0 +show3: + $x = $x + 1 + sleep 1000 + if $x == 30 then + return -1 + endi + +sql show dnodes +print dnode1 freeVnodes $data2_1 +print dnode2 freeVnodes $data2_2 +print dnode3 freeVnodes $data2_3 +if $data2_1 != 2 then + goto show3 +endi +if $data2_2 != null then + goto show3 +endi +if $data2_3 != 2 then + goto show3 +endi + +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +sql reset query cache +sleep 100 + +sql select count(*) from t10 +print select count(*) from t10 $data00 expect $rowNum +if $data00 != $rowNum then + return -1 +endi + +sql select count(*) from t1010 +print select count(*) from t1010 $data00 expect $rowNum +if $data00 != $rowNum then + return -1 +endi + +sql select count(*) from t2010 +print select count(*) from t2010 $data00 expect $rowNum +if $data00 != $rowNum then + return -1 +endi + +sql select count(*) from t3010 +print select count(*) from t3010 $data00 expect $rowNum +if $data00 != $rowNum then + return -1 +endi + +sql select count(*) from mt +print select count(*) from mt $data00 expect $rowNum +if $data00 != $totalNum then + return -1 +endi + +print ========== step4 +sql drop dnode $hostname3 + +$x = 0 +show4: + $x = $x + 1 + sleep 1000 + if $x == 30 then + return -1 + endi + +sql show dnodes +print dnode1 freeVnodes $data2_1 +print dnode3 freeVnodes $data2_3 +if $data2_1 != 4 then + goto show4 +endi +if $data2_3 != null then + goto show4 +endi + +system sh/exec.sh -n dnode3 -s stop -x SIGINT + +sql reset query cache +sleep 100 + +sql select count(*) from t10 +print select count(*) from t10 $data00 expect $rowNum +if $data00 != $rowNum then + return -1 +endi + +sql select count(*) from t1010 +print select count(*) from t1010 $data00 expect $rowNum +if $data00 != $rowNum then + return -1 +endi + +sql select count(*) from t2010 +print select count(*) from t2010 $data00 expect $rowNum +if $data00 != $rowNum then + return -1 +endi + +sql select count(*) from t3010 +print select count(*) from t3010 $data00 expect $rowNum +if $data00 != $rowNum then + return -1 +endi + +sql select count(*) from mt +print select count(*) from mt $data00 expect $rowNum +if $data00 != $totalNum then + return -1 +endi + +print ========== step5 +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname4 + +$x = 0 +step5: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 +print dnode4 $data4_4 + +if $data4_4 != ready then + goto step5 +endi + +sql alter database db replica 2 + +$x = 0 +show5: + $x = $x + 1 + sleep 1000 + if $x == 30 then + return -1 + endi + +sql show dnodes +print dnode1 freeVnodes $data2_1 +print dnode4 freeVnodes $data2_4 +if $data2_1 != 4 then + goto show5 +endi +if $data2_4 != 4 then + goto show5 +endi + +sql reset query cache +sleep 100 + +sql select count(*) from t10 +print select count(*) from t10 $data00 expect $rowNum +if $data00 != $rowNum then + goto show5 +endi + +sql select count(*) from t1010 +print select count(*) from t1010 $data00 expect $rowNum +if $data00 != $rowNum then + goto show5 +endi + +sql select count(*) from t2010 +print select count(*) from t2010 $data00 expect $rowNum +if $data00 != $rowNum then + goto show5 +endi + +sql select count(*) from t3010 +print select count(*) from t3010 $data00 expect $rowNum +if $data00 != $rowNum then + goto show5 +endi + +sql select count(*) from mt +print select count(*) from mt $data00 expect $rowNum +if $data00 != $totalNum then + goto show5 +endi + +print ========== step6 +sql alter database db replica 1 + +$x = 0 +show6: + $x = $x + 1 + sleep 1000 + if $x == 30 then + return -1 + endi + +sql show dnodes +print dnode1 freeVnodes $data2_1 +print dnode4 freeVnodes $data2_4 +if $data2_1 != 2 then + goto show6 +endi +if $data2_4 != 2 then + goto show6 +endi + +sql reset query cache +sleep 100 + +sql select count(*) from t10 +print select count(*) from t10 $data00 expect $rowNum +if $data00 != $rowNum then + goto show5 +endi + +sql select count(*) from t1010 +print select count(*) from t1010 $data00 expect $rowNum +if $data00 != $rowNum then + goto show5 +endi + +sql select count(*) from t2010 +print select count(*) from t2010 $data00 expect $rowNum +if $data00 != $rowNum then + goto show5 +endi + +sql select count(*) from t3010 +print select count(*) from t3010 $data00 expect $rowNum +if $data00 != $rowNum then + goto show5 +endi + +sql select count(*) from mt +print select count(*) from mt $data00 expect $rowNum +if $data00 != $totalNum then + goto show5 +endi + + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/big/maxvnodes.sim b/tests/script/unique/big/maxvnodes.sim new file mode 100644 index 0000000000000000000000000000000000000000..10dbc8bbff1a7be19791b75d77c705ffb060e48a --- /dev/null +++ b/tests/script/unique/big/maxvnodes.sim @@ -0,0 +1,89 @@ +system sh/stop_dnodes.sh + +$totalVnodes = 20 +$minVnodes = 10 +$maxVnodes = 10 +$maxTables = 4 +$totalRows = $totalVnodes * $maxTables + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v $totalVnodes +system sh/cfg.sh -n dnode1 -c balanceInterval -v 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v $totalVnodes +system sh/cfg.sh -n dnode2 -c balanceInterval -v 1 + +print ========== prepare data +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect +sql create database db blocks 3 cache 1 +sql use db + +print ========== step1 +sql create table mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$x = 0 +while $x < $totalRows + $tb = t . $x + sql create table $tb using mt tags( $x ) + sql insert into $tb values (now, $x ) + $x = $x + 1 +endw + +print ========== step2 +sql select * from mt +if $rows != $totalRows then + return -1 +endi + +sql select count(*) from mt +if $data00 != $totalRows then + return -1 +endi + +print ========== step3 +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +show3: + $x = $x + 1 + sleep 2000 + if $x == 1000 then + return -1 + endi + +sql show dnodes +print dnode1 openvnodes $data2_1 +print dnode2 openvnodes $data2_2 +if $data2_1 != $minVnodes then + goto show3 +endi +if $data2_2 != $maxVnodes then + goto show3 +endi + +print ========== step4 +sql select * from mt +if $rows != $totalRows then + return -1 +endi + +sql select count(*) from mt +if $data00 != $totalRows then + return -1 +endi + +return + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/big/restartSpeed.sim b/tests/script/unique/big/restartSpeed.sim new file mode 100644 index 0000000000000000000000000000000000000000..bdc4a8678b2c0e766e644a69cd709ecb2cd85268 --- /dev/null +++ b/tests/script/unique/big/restartSpeed.sim @@ -0,0 +1,41 @@ +system sh/stop_dnodes.sh + +$totalVnodes = 20 +$minVnodes = 10 +$maxVnodes = 10 +$maxTables = 4 +$totalRows = $totalVnodes * $maxTables + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/deploy.sh -n dnode2 -i 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 + + +print ========== prepare data +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect +sql create database db blocks 3 cache 1 +sql use db + +print ========== step1 +sql create table mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$x = 0 +while $x < $totalRows + $tb = t . $x + sql create table $tb using mt tags( $x ) + sql insert into $tb values (now, $x ) + $x = $x + 1 +endw + + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/big/tcp.sim b/tests/script/unique/big/tcp.sim new file mode 100644 index 0000000000000000000000000000000000000000..b282e2e2223d89dde7cf6ce364b31537593a6cb4 --- /dev/null +++ b/tests/script/unique/big/tcp.sim @@ -0,0 +1,113 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 30000 + +system sh/cfg.sh -n dnode1 -c dDebugFlag -v 131 +system sh/cfg.sh -n dnode1 -c mDebugFlag -v 131 +system sh/cfg.sh -n dnode1 -c sdbDebugFlag -v 131 +system sh/cfg.sh -n dnode1 -c rpcDebugFlag -v 131 +system sh/cfg.sh -n dnode1 -c cDebugFlag -v 131 +system sh/cfg.sh -n dnode1 -c gcDebugFlag -v 131 +system sh/cfg.sh -n dnode1 -c adminDebugFlag -v 131 +system sh/cfg.sh -n dnode1 -c httpDebugFlag -v 135 +system sh/cfg.sh -n dnode1 -c debugFlag -v 131 + +system sh/exec.sh -n dnode1 -s start +sql connect +print ======================== dnode1 start + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = mt +$tbNum = 22000 +$rowNum = 10 + +print =============== step1 +$i = 0 +$db = $dbPrefix +$mt = $mtPrefix + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $i = $i + 1 +endw + +print =============== step2 +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql insert into $tb values (now, $i , $i ) + + $i = $i + 1000 +endw + +$i = 0 +while $i < 5 + print =============== step3 $i + sql select count(*) from $mt + print ===> $data00 $data01 + if $rows != 1 then + return -1 + endi + if $data00 != 22 then + return -1 + endi + + print =============== step4 $i + sql select * from $mt + print ===> $data00 $data01 + if $rows != 22 then + return -1 + endi + + $i = $i + 1 +endw + +print =============== step3 +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql insert into $tb values (now, $i , $i ) + + $i = $i + 1000 +endw + +$i = 0 +while $i < 5 + print =============== step5 $i + sql select count(*) from $mt where tgcol < 20200 + print ===> $data00 $data01 + if $rows != 1 then + return -1 + endi + if $data00 != 42 then + return -1 + endi + + print =============== step6 $i + sql select * from $mt where tgcol < 20200 + print ===> $data00 $data01 + if $rows != 42 then + return -1 + endi + + $i = $i + 1 +endw + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT diff --git a/tests/script/unique/big/testSuite.sim b/tests/script/unique/big/testSuite.sim new file mode 100644 index 0000000000000000000000000000000000000000..2cead5626a5f5dd53ffbc30a0a8502ee70da25d1 --- /dev/null +++ b/tests/script/unique/big/testSuite.sim @@ -0,0 +1,3 @@ +run unique/big/balance.sim +run unique/big/maxvnodes.sim +run unique/big/tcp.sim diff --git a/tests/script/unique/cluster/alter.sim b/tests/script/unique/cluster/alter.sim new file mode 100644 index 0000000000000000000000000000000000000000..77e040c6cd9675a6e9c0ee9926f056b008bc6596 --- /dev/null +++ b/tests/script/unique/cluster/alter.sim @@ -0,0 +1,174 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/cfg.sh -n dnode2 -c wallevel -v 2 +system sh/cfg.sh -n dnode3 -c wallevel -v 2 +system sh/cfg.sh -n dnode4 -c wallevel -v 2 + +system sh/cfg.sh -n dnode1 -c balance -v 0 +system sh/cfg.sh -n dnode2 -c balance -v 0 +system sh/cfg.sh -n dnode3 -c balance -v 0 +system sh/cfg.sh -n dnode4 -c balance -v 0 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect +sleep 2000 + +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start +sleep 2000 + +print ========== step2 +sql create database d1 +sql create table d1.t1 (t timestamp, i int) +sql insert into d1.t1 values(now+1s, 15) +sql insert into d1.t1 values(now+2s, 14) +sql insert into d1.t1 values(now+3s, 13) +sql insert into d1.t1 values(now+4s, 12) +sql insert into d1.t1 values(now+5s, 11) + +print ========== step3 +sleep 2000 +sql create dnode $hostname3 +system sh/exec.sh -n dnode3 -s start +sql create dnode $hostname4 +system sh/exec.sh -n dnode4 -s start + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 +if $data2_1 != 0 then + return -1 +endi +if $data2_2 != 1 then + return -1 +endi +if $data2_3 != 0 then + return -1 +endi +if $data2_4 != 0 then + return -1 +endi + +print ========== step4 +sql alter dnode 2 balance "vnode:2-dnode:3" + +$x = 0 +show4: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 +if $data2_2 != 0 then + goto show4 +endi +if $data2_3 != 1 then + goto show4 +endi +if $data2_4 != 0 then + goto show4 +endi + +print ========== step5 +sql alter dnode 3 balance "vnode:2-dnode:4" + +$x = 0 +show5: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 +if $data2_2 != 0 then + goto show5 +endi +if $data2_3 != 0 then + goto show5 +endi +if $data2_4 != 1 then + goto show5 +endi + +print ========== step6 +sql alter dnode 4 balance "vnode:2-dnode:2" + +$x = 0 +show6: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 +if $data2_2 != 1 then + goto show6 +endi +if $data2_3 != 0 then + goto show6 +endi +if $data2_4 != 0 then + goto show6 +endi + +print ========== step7 +sql select * from d1.t1 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 11 then + return -1 +endi +if $data11 != 12 then + return -1 +endi +if $data21 != 13 then + return -1 +endi +if $data31 != 14 then + return -1 +endi +if $data41 != 15 then + return -1 +endi + +print ========== step8 +sql_error sql alter dnode 4 balance "vnode:2-dnode:5" + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/cluster/balance1.sim b/tests/script/unique/cluster/balance1.sim new file mode 100644 index 0000000000000000000000000000000000000000..c98687a81ceae03d20fc205a121fcfc813c74be7 --- /dev/null +++ b/tests/script/unique/cluster/balance1.sim @@ -0,0 +1,590 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/deploy.sh -n dnode5 -i 5 +system sh/deploy.sh -n dnode6 -i 6 +system sh/deploy.sh -n dnode7 -i 7 +system sh/deploy.sh -n dnode8 -i 8 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode5 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode6 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode7 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode8 -c numOfMnodes -v 3 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode5 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode6 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode7 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode8 -c mnodeEqualVnodeNum -v 0 + +system sh/cfg.sh -n dnode1 -c wallevel -v 1 +system sh/cfg.sh -n dnode2 -c wallevel -v 1 +system sh/cfg.sh -n dnode3 -c wallevel -v 1 +system sh/cfg.sh -n dnode4 -c wallevel -v 1 +system sh/cfg.sh -n dnode5 -c wallevel -v 1 +system sh/cfg.sh -n dnode6 -c wallevel -v 1 +system sh/cfg.sh -n dnode7 -c wallevel -v 1 +system sh/cfg.sh -n dnode8 -c wallevel -v 1 + +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode5 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode6 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode7 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode8 -c maxTablesPerVnode -v 4 + + +print ============== step1 +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create database c_b1_d1 +sql use c_b1_d1 + +sql create table c_b1_t1 (t timestamp, i int) +sql insert into c_b1_t1 values(1520000020015, 15) +sql insert into c_b1_t1 values(1520000021014, 14) +sql insert into c_b1_t1 values(1520000022013, 13) +sql insert into c_b1_t1 values(1520000023012, 12) +sql insert into c_b1_t1 values(1520000024011, 11) + +sql create database c_b1_d2 +sql use c_b1_d2 +sql create table c_b1_t2 (t timestamp, i int) +sql insert into c_b1_t2 values(1520000020025, 25) +sql insert into c_b1_t2 values(1520000021024, 24) +sql insert into c_b1_t2 values(1520000022023, 23) +sql insert into c_b1_t2 values(1520000023022, 22) +sql insert into c_b1_t2 values(1520000024021, 21) + +sql show dnodes +$dnode1Vnodes = $data2_1 +print dnode1 $dnode1Vnodes +$dnode2Vnodes = $data2_2 +print dnode2 $dnode2Vnodes + +if $dnode1Vnodes != 2 then + return -1 +endi +if $dnode2Vnodes != null then + return -1 +endi + +print ============================== step2 +print ========= start dnode2 +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +show2: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi +sql show dnodes -x show2 +$dnode1Vnodes = $data2_1 +print dnode1 $dnode1Vnodes +$dnode2Vnodes = $data2_2 +print dnode2 $dnode2Vnodes + +if $dnode1Vnodes != 1 then + goto show2 +endi +if $dnode2Vnodes != 1 then + goto show2 +endi + +sql show mnodes +$dnode1Role = $data2_1 +$dnode2Role = $data2_2 +print dnode1 ==> $dnode1Role +print dnode2 ==> $dnode2Role + +print ============================== step3 +print ========= add db3 +sql create database c_b1_d3 +sql use c_b1_d3 +sql create table c_b1_t3 (t timestamp, i int) +sql insert into c_b1_t3 values(1520000020035, 35) +sql insert into c_b1_t3 values(1520000021034, 34) +sql insert into c_b1_t3 values(1520000022033, 33) +sql insert into c_b1_t3 values(1520000023032, 32) +sql insert into c_b1_t3 values(1520000024031, 31) + +print ============================== step4 +print ========= drop dnode2 +sql drop dnode $hostname2 + +$x = 0 +show4: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi +sql show dnodes -x show4 +$dnode1Vnodes = $data2_1 +print dnode1 $dnode1Vnodes +$dnode2Vnodes = $data2_2 +print dnode2 $dnode2Vnodes + +if $dnode1Vnodes != 3 then + goto show4 +endi +if $dnode2Vnodes != null then + goto show4 +endi + +sql show mnodes +$dnode1Role = $data2_1 +$dnode2Role = $data2_2 +$dnode3Role = $data2_3 +$dnode4Role = $data2_4 +print dnode1 ==> $dnode1Role +print dnode2 ==> $dnode2Role +print dnode3 ==> $dnode3Role +print dnode4 ==> $dnode4Role + +print ============================== step5 +print ========= add dnode2 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s start +sql create dnode $hostname3 + +$x = 0 +show5: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi +sql show dnodes -x show5 +$dnode1Vnodes = $data2_1 +print dnode1 $dnode1Vnodes +$dnode3Vnodes = $data2_3 +print dnode2 $dnode3Vnodes + +if $dnode1Vnodes != 2 then + goto show5 +endi +if $dnode3Vnodes != 1 then + goto show5 +endi + +sql show mnodes +$dnode1Role = $data2_1 +$dnode3Role = $data2_3 +$dnode4Role = $data2_4 +print dnode1 ==> $dnode1Role +print dnode3 ==> $dnode3Role +print dnode4 ==> $dnode4Role + +if $dnode1Role != master then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi + +print ============================== step6 +sql_error drop dnode $hostname1 + +print ============================== step7 +sql_error create dnode $hostname1 + +print ============================== step8 +sql drop dnode $hostname3 + +$x = 0 +show8: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi +sql show dnodes -x show8 +$dnode1Vnodes = $data2_1 +print dnode1 $dnode1Vnodes +$dnode3Vnodes = $data2_3 +print dnode3 $dnode3Vnodes + +if $dnode1Vnodes != 3 then + goto show8 +endi +if $dnode3Vnodes != null then + goto show8 +endi + +sql show mnodes +$dnode1Role = $data2_1 +$dnode3Role = $data2_3 +$dnode4Role = $data2_4 +print dnode1 ==> $dnode1Role +print dnode3 ==> $dnode3Role +print dnode4 ==> $dnode4Role + +if $dnode1Role != master then + return -1 +endi + +if $dnode3Role != null then + return -1 +endi + +print ============================== step9 +sql create dnode $hostname4 +system sh/exec.sh -n dnode4 -s start + +$x = 0 +show9: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi +sql show dnodes -x show9 +$dnode1Vnodes = $data2_1 +print dnode1 $dnode1Vnodes +$dnode4Vnodes = $data2_4 +print dnode4 $dnode4Vnodes + +if $dnode1Vnodes != 2 then + goto show9 +endi +if $dnode4Vnodes != 1 then + goto show9 +endi + +sql show mnodes +$dnode1Role = $data2_1 +$dnode4Role = $data2_4 +print dnode1 ==> $dnode1Role +print dnode4 ==> $dnode4Role + +if $dnode1Role != master then + return -1 +endi + +if $dnode4Role != slave then + return -1 +endi + +print ============================== step10 +sql create database c_b1_d4 +sql use c_b1_d4 +sql create table c_b1_t4 (t timestamp, i int) +sql insert into c_b1_t4 values(1520000020045, 45) +sql insert into c_b1_t4 values(1520000021044, 44) +sql insert into c_b1_t4 values(1520000022043, 43) +sql insert into c_b1_t4 values(1520000023042, 42) +sql insert into c_b1_t4 values(1520000024041, 41) + +$x = 0 +show10: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi +sql show dnodes -x show10 +$dnode1Vnodes = $data2_1 +print dnode1 $dnode1Vnodes +$dnode4Vnodes = $data2_4 +print dnode4 $dnode4Vnodes + +if $dnode1Vnodes != 2 then + goto show10 +endi +if $dnode4Vnodes != 2 then + goto show10 +endi + +sql reset query cache + +sql use c_b1_d3 +sql insert into c_b1_t3 values(1520000025036, 36) + +sql use c_b1_d2 +sql insert into c_b1_t2 values(1520000025026, 26) + +print ============================== step12 +sql create database c_b1_d5 +sql use c_b1_d5 +sql_error create table c_b1_t5 (t timestamp, i int) -x error3 + +print ============================== step13 +sql create dnode $hostname5 +system sh/exec.sh -n dnode5 -s start +$x = 0 +step13: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 +print dnode4 $data4_4 +print dnode5 $data4_5 + +if $data4_5 != ready then + goto step13 +endi + +sql show mnodes +$dnode1Role = $data2_1 +$dnode4Role = $data2_4 +$dnode5Role = $data2_5 +print dnode1 ==> $dnode1Role +print dnode4 ==> $dnode4Role +print dnode5 ==> $dnode5Role + +sql use c_b1_d5; +sql create table c_b1_t5 (t timestamp, i int) +sql insert into c_b1_t5 values(1520000020055, 55) +sql insert into c_b1_t5 values(1520000021054, 54) +sql insert into c_b1_t5 values(1520000022053, 53) +sql insert into c_b1_t5 values(1520000023052, 52) +sql insert into c_b1_t5 values(1520000024051, 51) + +sql create database c_b1_d6 +sql use c_b1_d6 +sql create table c_b1_t6 (t timestamp, i int) +sql insert into c_b1_t6 values(1520000020065, 65) +sql insert into c_b1_t6 values(1520000021064, 64) +sql insert into c_b1_t6 values(1520000022063, 63) +sql insert into c_b1_t6 values(1520000023062, 62) +sql insert into c_b1_t6 values(1520000024061, 61) + +sql show dnodes +$dnode1Vnodes = $data2_1 +print dnode1 $dnode1Vnodes +$dnode4Vnodes = $data2_4 +print dnode4 $dnode2Vnodes +$dnode5Vnodes = $data2_5 +print dnode5 $dnode2Vnodes + +if $dnode1Vnodes != 2 then + goto step13 +endi +if $dnode4Vnodes != 2 then + goto step13 +endi +if $dnode5Vnodes != 2 then + goto step13 +endi + +print ============================== step14 +sql create dnode $hostname6 +system sh/exec.sh -n dnode6 -s start +$x = 0 +step14: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 +print dnode4 $data4_4 +print dnode4 $data4_5 + +if $data4_6 != ready then + goto step14 +endi + +sql create database c_b1_d7 +sql use c_b1_d7 +sql create table c_b1_t7 (t timestamp, i int) +sql insert into c_b1_t7 values(1520000020075, 75) +sql insert into c_b1_t7 values(1520000021074, 74) +sql insert into c_b1_t7 values(1520000022073, 73) +sql insert into c_b1_t7 values(1520000023072, 72) +sql insert into c_b1_t7 values(1520000024071, 71) + +sql create database c_b1_d8 +sql use c_b1_d8 +sql create table c_b1_t8 (t timestamp, i int) +sql insert into c_b1_t8 values(1520000020085, 85) +sql insert into c_b1_t8 values(1520000021084, 84) +sql insert into c_b1_t8 values(1520000022083, 83) +sql insert into c_b1_t8 values(1520000023082, 82) +sql insert into c_b1_t8 values(1520000024081, 81) + +$x = 0 +show14: + $x = $x + 1 + sleep 1000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show14 +$dnode1Vnodes = $data2_1 +print dnode1 $dnode1Vnodes +$dnode4Vnodes = $data2_4 +print dnode4 $dnode4Vnodes +$dnode5Vnodes = $data2_5 +print dnode5 $dnode5Vnodes +$dnode6Vnodes = $data2_6 +print dnode6 $dnode6Vnodes + +if $dnode1Vnodes != 2 then + goto show14 +endi +if $dnode4Vnodes != 2 then + goto show14 +endi +if $dnode5Vnodes != 2 then + goto show14 +endi +if $dnode6Vnodes != 2 then + goto show14 +endi + +sql reset query cache +sleep 1000 + +print ============================== step17 +print ========= check data + +sql reset query cache +sleep 100 + +sql use c_b1_d1 +sql select * from c_b1_d1.c_b1_t1 +print $rows +print $data01 $data11 $data21 $data31 $data41 +if $rows != 5 then + return -1 +endi + +sql use c_b1_d2 +sql select * from c_b1_d2.c_b1_t2 +print $rows +print $data01 $data11 $data21 $data31 $data41 +if $rows != 6 then + return -1 +endi + +sql use c_b1_d3 +sql select * from c_b1_d3.c_b1_t3 order by t desc +print $rows +print $data01 $data11 $data21 $data31 $data41 +if $rows != 6 then + return -1 +endi +if $data01 != 36 then + return -1 +endi + +sql use c_b1_d4 +sql select * from c_b1_d4.c_b1_t4 order by t desc +print $rows +print $data01 $data11 $data21 $data31 $data41 + +sql use c_b1_d5 +sql select * from c_b1_d5.c_b1_t5 order by t desc +print $rows +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 51 then + return -1 +endi +if $data11 != 52 then + return -1 +endi +if $data21 != 53 then + return -1 +endi +if $data31 != 54 then + return -1 +endi +if $data41 != 55 then + return -1 +endi + +sql use c_b1_d6 +sql select * from c_b1_d6.c_b1_t6 order by t desc +print $rows +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 61 then + return -1 +endi +if $data11 != 62 then + return -1 +endi +if $data21 != 63 then + return -1 +endi +if $data31 != 64 then + return -1 +endi +if $data41 != 65 then + return -1 +endi + +sql use c_b1_d7 +sql select * from c_b1_d7.c_b1_t7 order by t desc +print $rows +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 71 then + return -1 +endi +if $data11 != 72 then + return -1 +endi +if $data21 != 73 then + return -1 +endi +if $data31 != 74 then + return -1 +endi +if $data41 != 75 then + return -1 +endi + +sql use c_b1_d8 +sql select * from c_b1_d8.c_b1_t8 order by t desc +print $rows +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 81 then + return -1 +endi +if $data11 != 82 then + return -1 +endi +if $data21 != 83 then + return -1 +endi +if $data31 != 84 then + return -1 +endi +if $data41 != 85 then + return -1 +endi + +print ============================================ over= +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/cluster/balance2.sim b/tests/script/unique/cluster/balance2.sim new file mode 100644 index 0000000000000000000000000000000000000000..0b80acbe6c9fc11455df6023f66da7f057db2d09 --- /dev/null +++ b/tests/script/unique/cluster/balance2.sim @@ -0,0 +1,479 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/deploy.sh -n dnode5 -i 5 +system sh/deploy.sh -n dnode6 -i 6 +system sh/deploy.sh -n dnode7 -i 7 +system sh/deploy.sh -n dnode8 -i 8 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode5 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode6 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode7 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode8 -c numOfMnodes -v 3 + +system sh/cfg.sh -n dnode1 -c wallevel -v 1 +system sh/cfg.sh -n dnode2 -c wallevel -v 1 +system sh/cfg.sh -n dnode3 -c wallevel -v 1 +system sh/cfg.sh -n dnode4 -c wallevel -v 1 +system sh/cfg.sh -n dnode5 -c wallevel -v 1 +system sh/cfg.sh -n dnode6 -c wallevel -v 1 +system sh/cfg.sh -n dnode7 -c wallevel -v 1 +system sh/cfg.sh -n dnode8 -c wallevel -v 1 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode5 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode6 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode7 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode8 -c mnodeEqualVnodeNum -v 0 + +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode5 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode6 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode7 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode8 -c maxTablesPerVnode -v 4 + + +print ============== step1 +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start + +sql connect +sql create dnode $hostname2 +sql create dnode $hostname3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 +print dnode4 $data4_4 + +if $data4_1 != ready then + goto step1 +endi +if $data4_2 != ready then + goto step1 +endi +if $data4_3 != ready then + goto step1 +endi + +sql show mnodes +print mnode1 $data2_1 +print mnode1 $data2_2 +print mnode1 $data2_3 +if $data2_1 != master then + goto step1 +endi +if $data2_2 != slave then + goto step1 +endi +if $data2_3 != slave then + goto step1 +endi + + +sql create database c_b2_d1 replica 2 +sql use c_b2_d1 +sql create table c_b2_t1 (t timestamp, i int) +sql insert into c_b2_t1 values(1520000020015, 15) +sql insert into c_b2_t1 values(1520000021014, 14) +sql insert into c_b2_t1 values(1520000022013, 13) +sql insert into c_b2_t1 values(1520000023012, 12) +sql insert into c_b2_t1 values(1520000024011, 11) + +sql create database c_b2_d2 replica 2 +sql use c_b2_d2 +sql create table c_b2_t2 (t timestamp, i int) +sql insert into c_b2_t2 values(1520000020025, 25) +sql insert into c_b2_t2 values(1520000021024, 24) +sql insert into c_b2_t2 values(1520000022023, 23) +sql insert into c_b2_t2 values(1520000023022, 22) +sql insert into c_b2_t2 values(1520000024021, 21) + +sql create database c_b2_d3 replica 2 +sql use c_b2_d3 +sql create table c_b2_t3 (t timestamp, i int) +sql insert into c_b2_t3 values(1520000020035, 35) +sql insert into c_b2_t3 values(1520000021034, 34) +sql insert into c_b2_t3 values(1520000022033, 33) +sql insert into c_b2_t3 values(1520000023032, 32) +sql insert into c_b2_t3 values(1520000024031, 31) + +$x = 0 +show1: + $x = $x + 1 + sleep 3000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show1 +$dnode1Vnodes = $data2_1 +print dnode1 $dnode1Vnodes +$dnode2Vnodes = $data2_2 +print dnode2 $dnode2Vnodes +$dnode3Vnodes = $data2_3 +print dnode3 $dnode3Vnodes + +if $dnode1Vnodes != 2 then + goto show1 +endi +if $dnode2Vnodes != 2 then + goto show1 +endi +if $dnode3Vnodes != 2 then + goto show1 +endi + +print ============================== step2 +print ========= drop dnode2 +sql drop dnode $hostname2 + +$x = 0 +show2: + $x = $x + 1 + sleep 1000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show2 +$dnode1Vnodes = $data2_1 +print dnode1 $dnode1Vnodes +$dnode2Vnodes = $data2_2 +print dnode2 $dnode2Vnodes +$dnode3Vnodes = $data2_3 +print dnode3 $dnode3Vnodes + +if $dnode1Vnodes != 3 then + goto show2 +endi +if $dnode2Vnodes != null then + goto show2 +endi +if $dnode3Vnodes != 3 then + goto show2 +endi + +sql show mnodes +$dnode1Role = $data2_1 +$dnode2Role = $data2_2 +$dnode3Role = $data2_3 +$dnode4Role = $data2_4 +print dnode1 ==> $dnode1Role +print dnode2 ==> $dnode2Role +print dnode3 ==> $dnode3Role +print dnode4 ==> $dnode4Role + +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +print ============================== step3 +print ========= start dnode4 +sql create dnode $hostname4 +system sh/exec.sh -n dnode4 -s start + +$x = 0 +show3: + $x = $x + 1 + sleep 1000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show3 +$dnode1Vnodes = $data2_1 +print dnode1 $dnode1Vnodes +$dnode4Vnodes = $data2_4 +print dnode4 $dnode4Vnodes +$dnode3Vnodes = $data2_3 +print dnode3 $dnode3Vnodes + +if $dnode1Vnodes != 2 then + goto show3 +endi +if $dnode4Vnodes != 2 then + goto show3 +endi +if $dnode3Vnodes != 2 then + goto show3 +endi + +sql show mnodes +$dnode1Role = $data2_1 +$dnode2Role = $data2_2 +$dnode3Role = $data2_3 +$dnode4Role = $data2_4 +print dnode1 ==> $dnode1Role +print dnode2 ==> $dnode2Role +print dnode3 ==> $dnode3Role +print dnode4 ==> $dnode4Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != null then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi + +if $dnode4Role != slave then + return -1 +endi + +print ============================== step4 +print ========= drop dnode3 +sql drop dnode $hostname3 + +$x = 0 +show4: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi +sql show dnodes -x show4 +$dnode1Vnodes = $data2_1 +print dnode1 $dnode1Vnodes +$dnode4Vnodes = $data2_4 +print dnode4 $dnode4Vnodes +$dnode3Vnodes = $data2_3 +print dnode3 $dnode3Vnodes + +if $dnode1Vnodes != 3 then + goto show4 +endi +if $dnode4Vnodes != 3 then + goto show4 +endi +if $dnode3Vnodes != null then + goto show4 +endi + +sql show mnodes +$dnode1Role = $data2_1 +$dnode2Role = $data2_2 +$dnode3Role = $data2_3 +$dnode4Role = $data2_4 +print dnode1 ==> $dnode1Role +print dnode2 ==> $dnode2Role +print dnode3 ==> $dnode3Role +print dnode4 ==> $dnode4Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != null then + return -1 +endi +if $dnode3Role != null then + return -1 +endi + +if $dnode4Role != slave then + return -1 +endi + +system sh/exec.sh -n dnode3 -s stop -x SIGINT + +print ============================== step5 +print ========= start dnode3 +sql create dnode $hostname5 +system sh/exec.sh -n dnode5 -s start + +$x = 0 +show5: + $x = $x + 1 + sleep 1000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show5 +$dnode1Vnodes = $data2_1 +print dnode1 $dnode1Vnodes +$dnode4Vnodes = $data2_4 +print dnode4 $dnode4Vnodes +$dnode5Vnodes = $data2_5 +print dnode5 $dnode5Vnodes + +if $dnode1Vnodes != 2 then + goto show5 +endi +if $dnode4Vnodes != 2 then + goto show5 +endi +if $dnode5Vnodes != 2 then + goto show5 +endi + +sql show mnodes +$dnode1Role = $data2_1 +$dnode4Role = $data2_4 +$dnode5Role = $data2_5 +print dnode1 ==> $dnode1Role +print dnode4 ==> $dnode4Role +print dnode5 ==> $dnode5Role + +print ============================== step6 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +print stop dnode1 and sleep 3000 +sleep 3000 + +sql show mnodes +$dnode1Role = $data2_1 +$dnode4Role = $data2_4 +$dnode5Role = $data2_5 +print dnode1 ==> $dnode1Role +print dnode4 ==> $dnode4Role +print dnode5 ==> $dnode5Role + +if $dnode1Role != offline then + return -1 +endi + +print ============================== step6.1 +system sh/exec.sh -n dnode1 -s start + +$x = 0 +step6.1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 + +if $data4_1 != ready then + goto step6.1 +endi + +sql drop dnode $hostname1 +print drop dnode1 and sleep 9000 +sleep 9000 + +$x = 0 +show6: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi +sql show dnodes -x show6 +$dnode1Vnodes = $data2_1 +print dnode1 $dnode1Vnodes +$dnode4Vnodes = $data2_4 +print dnode4 $dnode4Vnodes +$dnode5Vnodes = $data2_5 +print dnode5 $dnode5Vnodes + +if $dnode1Vnodes != null then + goto show6 +endi +if $dnode4Vnodes != 3 then + goto show6 +endi +if $dnode5Vnodes != 3 then + goto show6 +endi + +sql show mnodes +$dnode1Role = $data2_1 +$dnode4Role = $data2_4 +$dnode5Role = $data2_5 +print dnode1 ==> $dnode1Role +print dnode4 ==> $dnode4Role +print dnode5 ==> $dnode5Role + +#system sh/exec.sh -n dnode1 -s stop -x SIGINT + +print ============================== step12 +print ========= check data + +sql reset query cache +sleep 100 + +sql select * from c_b2_d1.c_b2_t1 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 11 then + return -1 +endi +if $data11 != 12 then + return -1 +endi +if $data21 != 13 then + return -1 +endi +if $data31 != 14 then + return -1 +endi +if $data41 != 15 then + return -1 +endi + +sql select * from c_b2_d2.c_b2_t2 order by t desc +print $data01 $data11 $data21 $data31 $data41 + +if $data01 != 21 then + return -1 +endi +if $data11 != 22 then + return -1 +endi +if $data21 != 23 then + return -1 +endi +if $data31 != 24 then + return -1 +endi +if $data41 != 25 then + return -1 +endi + +sql select * from c_b2_d3.c_b2_t3 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 31 then + return -1 +endi +if $data11 != 32 then + return -1 +endi +if $data21 != 33 then + return -1 +endi +if $data31 != 34 then + return -1 +endi +if $data41 != 35 then + return -1 +endi + +print ============================================ over +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGKILL +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT diff --git a/tests/script/unique/cluster/balance3.sim b/tests/script/unique/cluster/balance3.sim new file mode 100644 index 0000000000000000000000000000000000000000..c2e9a845149cd9df78b9528115c5108c1e6531d3 --- /dev/null +++ b/tests/script/unique/cluster/balance3.sim @@ -0,0 +1,643 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/deploy.sh -n dnode5 -i 5 +system sh/deploy.sh -n dnode6 -i 6 +system sh/deploy.sh -n dnode7 -i 7 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode5 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode6 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode7 -c numOfMnodes -v 3 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode5 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode6 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode7 -c mnodeEqualVnodeNum -v 0 + +system sh/cfg.sh -n dnode1 -c wallevel -v 1 +system sh/cfg.sh -n dnode2 -c wallevel -v 1 +system sh/cfg.sh -n dnode3 -c wallevel -v 1 +system sh/cfg.sh -n dnode4 -c wallevel -v 1 +system sh/cfg.sh -n dnode5 -c wallevel -v 1 +system sh/cfg.sh -n dnode6 -c wallevel -v 1 +system sh/cfg.sh -n dnode7 -c wallevel -v 1 + +print ============== step1 +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode $hostname2 +sql create dnode $hostname3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 + +if $data4_1 != ready then + goto step1 +endi +if $data4_2 != ready then + goto step1 +endi +if $data4_3 != ready then + goto step1 +endi + +sql show mnodes +print mnode1 $data2_1 +print mnode1 $data2_2 +print mnode1 $data2_3 +if $data2_1 != master then + goto step1 +endi +if $data2_2 != slave then + goto step1 +endi +if $data2_3 != slave then + goto step1 +endi + +sql create database c_b3_d1 replica 3 +sql use c_b3_d1 +sql create table c_b3_t1 (t timestamp, i int) +sql insert into c_b3_t1 values(1520000020015, 15) +sql insert into c_b3_t1 values(1520000021014, 14) +sql insert into c_b3_t1 values(1520000022013, 13) +sql insert into c_b3_t1 values(1520000023012, 12) +sql insert into c_b3_t1 values(1520000024011, 11) + +sql create database c_b3_d2 replica 3 +sql use c_b3_d2 +sql create table c_b3_t2 (t timestamp, i int) +sql insert into c_b3_t2 values(1520000020025, 25) +sql insert into c_b3_t2 values(1520000021024, 24) +sql insert into c_b3_t2 values(1520000022023, 23) +sql insert into c_b3_t2 values(1520000023022, 22) +sql insert into c_b3_t2 values(1520000024021, 21) + +sql create database c_b3_d3 replica 3 +sql use c_b3_d3 +sql create table c_b3_t3 (t timestamp, i int) +sql insert into c_b3_t3 values(1520000020035, 35) +sql insert into c_b3_t3 values(1520000021034, 34) +sql insert into c_b3_t3 values(1520000022033, 33) +sql insert into c_b3_t3 values(1520000023032, 32) +sql insert into c_b3_t3 values(1520000024031, 31) + +$x = 0 +show1: + $x = $x + 1 + sleep 2000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show1 +$dnode1Vnodes = $data2_1 +print dnode1 $dnode1Vnodes +$dnode2Vnodes = $data2_2 +print dnode2 $dnode2Vnodes +$dnode3Vnodes = $data2_3 +print dnode3 $dnode3Vnodes + +if $dnode1Vnodes != 3 then + goto show1 +endi +if $dnode2Vnodes != 3 then + goto show1 +endi +if $dnode3Vnodes != 3 then + goto show1 +endi + +sql show mnodes +print dnode1 ==> $data2_1 +print dnode2 ==> $data2_2 +print dnode3 ==> $data2_3 + +print ============================== step2 +print ========= start dnode4 +sql create dnode $hostname4 +system sh/exec.sh -n dnode4 -s start + +$x = 0 +show2: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi +sql show dnodes -x show2 +$dnode1Vnodes = $data2_1 +print dnode1 $dnode1Vnodes +$dnode2Vnodes = $data2_2 +print dnode2 $dnode2Vnodes +$dnode3Vnodes = $data2_3 +print dnode3 $dnode3Vnodes +$dnode4Vnodes = $data2_4 +print dnode4 $dnode4Vnodes + +if $dnode4Vnodes != 2 then + goto show2 +endi + +sql show mnodes +print dnode1 ==> $data2_1 +print dnode2 ==> $data2_2 +print dnode3 ==> $data2_3 + +print ============================== step3 +print ========= drop dnode2 +sql drop dnode $hostname2 + +$x = 0 +show3: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi +sql show dnodes -x show3 +$dnode1Vnodes = $data2_1 +print dnode1 $dnode1Vnodes +$dnode2Vnodes = $data2_2 +print dnode2 $dnode2Vnodes +$dnode3Vnodes = $data2_3 +print dnode3 $dnode3Vnodes +$dnode4Vnodes = $data2_4 +print dnode4 $dnode4Vnodes + +if $dnode1Vnodes != 3 then + goto show3 +endi +if $dnode2Vnodes != null then + goto show3 +endi +if $dnode3Vnodes != 3 then + goto show3 +endi +if $dnode4Vnodes != 3 then + goto show3 +endi + +sql show mnodes +print dnode1 ==> $data2_1 +print dnode2 ==> $data2_2 +print dnode3 ==> $data2_3 + +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +print ============================== step4 +sql create dnode $hostname5 +system sh/exec.sh -n dnode5 -s start + +$x = 0 +show4: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show dnodes -x show4 +$dnode1Vnodes = $data2_1 +print dnode1 $dnode1Vnodes +$dnode5Vnodes = $data2_5 +print dnode5 $dnode5Vnodes +$dnode3Vnodes = $data2_3 +print dnode3 $dnode3Vnodes +$dnode4Vnodes = $data2_4 +print dnode4 $dnode4Vnodes + +if $dnode5Vnodes != 2 then + goto show4 +endi + +sql show mnodes +print dnode1 ==> $data2_1 +print dnode2 ==> $data2_2 +print dnode3 ==> $data2_3 +print dnode4 ==> $data2_4 +print dnode5 ==> $data2_5 + +if $data2_4 != slave then + goto show4 +endi + +print ============================== step5 +print ========= drop dnode3 +sql drop dnode $hostname3 +sleep 9000 + +$x = 0 +show5: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi +sql show dnodes -x show5 +$dnode1Vnodes = $data2_1 +print dnode1 $dnode1Vnodes +$dnode5Vnodes = $data2_5 +print dnode5 $dnode5Vnodes +$dnode3Vnodes = $data2_3 +print dnode3 $dnode3Vnodes +$dnode4Vnodes = $data2_4 +print dnode4 $dnode4Vnodes + +if $dnode1Vnodes != 3 then + goto show5 +endi +if $dnode5Vnodes != 3 then + goto show5 +endi +if $dnode3Vnodes != null then + goto show5 +endi +if $dnode4Vnodes != 3 then + goto show5 +endi + +system sh/exec.sh -n dnode3 -s stop -x SIGINT + +sql show mnodes +print dnode1 ==> $data2_1 +print dnode2 ==> $data2_2 +print dnode3 ==> $data2_3 +print dnode4 ==> $data2_4 +print dnode5 ==> $data2_5 +print dnode6 ==> $data2_6 +print dnode7 ==> $data2_7 + +if $data2_5 != slave then + goto show5 +endi + +print ============================== step6 +sql create dnode $hostname6 +system sh/exec.sh -n dnode6 -s start + +$x = 0 +show6: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi +sql show dnodes -x show6 +$dnode1Vnodes = $data2_1 +print dnode1 $dnode1Vnodes +$dnode4Vnodes = $data2_4 +print dnode4 $dnode4Vnodes +$dnode5Vnodes = $data2_5 +print dnode5 $dnode5Vnodes +$dnode6Vnodes = $data2_6 +print dnode6 $dnode6Vnodes + +if $dnode1Vnodes != 2 then + goto show6 +endi +if $dnode4Vnodes != 2 then + goto show6 +endi +if $dnode5Vnodes != 3 then + goto show6 +endi +if $dnode6Vnodes != 2 then + goto show6 +endi + +sql show mnodes +print dnode1 ==> $data2_1 +print dnode2 ==> $data2_2 +print dnode3 ==> $data2_3 +print dnode4 ==> $data2_4 +print dnode5 ==> $data2_5 +print dnode6 ==> $data2_6 +print dnode7 ==> $data2_7 + +print ============================== step7 +print ========= drop dnode4 +sql drop dnode $hostname4 + +$x = 0 +show7: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi +sql show dnodes -x show7 +$dnode1Vnodes = $data2_1 +print dnode1 $dnode1Vnodes +$dnode4Vnodes = $data2_4 +print dnode4 $dnode4Vnodes +$dnode5Vnodes = $data2_5 +print dnode5 $dnode5Vnodes +$dnode6Vnodes = $data2_6 +print dnode6 $dnode6Vnodes + +if $dnode1Vnodes != 3 then + goto show7 +endi +if $dnode5Vnodes != 3 then + goto show7 +endi +if $dnode6Vnodes != 3 then + goto show7 +endi +if $dnode4Vnodes != null then + goto show7 +endi + +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sql show mnodes +print dnode1 ==> $data2_1 +print dnode2 ==> $data2_2 +print dnode3 ==> $data2_3 +print dnode4 ==> $data2_4 +print dnode5 ==> $data2_5 +print dnode6 ==> $data2_6 +print dnode7 ==> $data2_7 + +if $data2_6 != slave then + goto show7 +endi + +print ============================== step8 +sql create dnode $hostname7 +system sh/exec.sh -n dnode7 -s start + +$x = 0 +show8: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi +sql show dnodes -x show8 +$dnode1Vnodes = $data2_1 +print dnode1 $dnode1Vnodes +$dnode5Vnodes = $data2_5 +print dnode5 $dnode5Vnodes +$dnode6Vnodes = $data2_6 +print dnode6 $dnode6Vnodes +$dnode7Vnodes = $data2_7 +print dnode7 $dnode7Vnodes + +if $dnode1Vnodes != 2 then + goto show8 +endi +if $dnode5Vnodes != 2 then + goto show8 +endi +if $dnode6Vnodes != 3 then + goto show8 +endi +if $dnode7Vnodes != 2 then + goto show8 +endi + +sql show mnodes +print dnode1 ==> $data2_1 +print dnode2 ==> $data2_2 +print dnode3 ==> $data2_3 +print dnode4 ==> $data2_4 +print dnode5 ==> $data2_5 +print dnode6 ==> $data2_6 +print dnode7 ==> $data2_7 + +print ============================== step9 +system sh/exec.sh -n dnode1 -s stop -x SIGINT + +$x = 0 +show9: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi +sql show mnodes -x show9 + +print dnode1 ==> $data2_1 +print dnode2 ==> $data2_2 +print dnode3 ==> $data2_3 +print dnode4 ==> $data2_4 +print dnode5 ==> $data2_5 +print dnode6 ==> $data2_6 +print dnode7 ==> $data2_7 + +if $data2_1 != offline then + goto show9 +endi +if $data2_5 != master then + goto show9 +endi +if $data2_6 != slave then + goto show9 +endi + +print ============================== step10 +sql drop dnode $hostname1 +$x = 0 +show10: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi +sql show mnodes -x show10 + +print dnode1 ==> $data2_1 +print dnode2 ==> $data2_2 +print dnode3 ==> $data2_3 +print dnode4 ==> $data2_4 +print dnode5 ==> $data2_5 +print dnode6 ==> $data2_6 +print dnode7 ==> $data2_7 + +if $data2_1 != null then + goto show10 +endi +if $data2_5 != master then + goto show10 +endi +if $data2_6 != slave then + goto show10 +endi +if $data2_7 != slave then + goto show10 +endi + +print ============================== step11 +system sh/exec.sh -n dnode1 -s start + +$x = 0 +show11: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show dnodes -x show11 +$dnode5Vnodes = $data2_5 +print dnode5 $dnode5Vnodes +$dnode6Vnodes = $data2_6 +print dnode6 $dnode6Vnodes +$dnode7Vnodes = $data2_7 +print dnode7 $dnode7Vnodes + +if $dnode5Vnodes != 3 then + goto show11 +endi +if $dnode6Vnodes != 3 then + goto show11 +endi +if $dnode7Vnodes != 3 then + goto show11 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT + +sql show mnodes +print dnode1 ==> $data2_1 +print dnode2 ==> $data2_2 +print dnode3 ==> $data2_3 +print dnode4 ==> $data2_4 +print dnode5 ==> $data2_5 +print dnode6 ==> $data2_6 +print dnode7 ==> $data2_7 + +print ============================== step12 +sql create database c_b3_d4 replica 3 +sql use c_b3_d4 +$x = 0 +create4: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create table c_b3_t4 (t timestamp, i int) -x create4 +sql insert into c_b3_t4 values(1520000020045, 45) +sql insert into c_b3_t4 values(1520000021044, 44) +sql insert into c_b3_t4 values(1520000022043, 43) +sql insert into c_b3_t4 values(1520000023042, 42) +sql insert into c_b3_t4 values(1520000024041, 41) + +$x = 0 +show12: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi +sql show dnodes -x show12 +$dnode5Vnodes = $data2_5 +print dnode5 $dnode5Vnodes +$dnode6Vnodes = $data2_6 +print dnode6 $dnode6Vnodes +$dnode7Vnodes = $data2_7 +print dnode7 $dnode7Vnodes + +if $dnode5Vnodes != 4 then + goto show12 +endi +if $dnode6Vnodes != 4 then + goto show12 +endi +if $dnode7Vnodes != 4 then + goto show12 +endi + +print ============================== step13 +sql reset query cache +sleep 200 + +print ========= check data + +sql select * from c_b3_d1.c_b3_t1 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 11 then + return -1 +endi +if $data11 != 12 then + return -1 +endi +if $data21 != 13 then + return -1 +endi +if $data31 != 14 then + return -1 +endi +if $data41 != 15 then + return -1 +endi + +sql select * from c_b3_d2.c_b3_t2 order by t desc +print $data01 $data11 $data21 $data31 $data41 + +if $data01 != 21 then + return -1 +endi +if $data11 != 22 then + return -1 +endi +if $data21 != 23 then + return -1 +endi +if $data31 != 24 then + return -1 +endi +if $data41 != 25 then + return -1 +endi + +sql select * from c_b3_d3.c_b3_t3 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 31 then + return -1 +endi +if $data11 != 32 then + return -1 +endi +if $data21 != 33 then + return -1 +endi +if $data31 != 34 then + return -1 +endi +if $data41 != 35 then + return -1 +endi + +print ============================================ over +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT diff --git a/tests/script/unique/cluster/cache.sim b/tests/script/unique/cluster/cache.sim new file mode 100644 index 0000000000000000000000000000000000000000..740eddfb0d36767631c08a60806ab2e38e6f364a --- /dev/null +++ b/tests/script/unique/cluster/cache.sim @@ -0,0 +1,65 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 + +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c httpMaxThreads -v 2 +system sh/cfg.sh -n dnode2 -c httpMaxThreads -v 2 +system sh/cfg.sh -n dnode1 -c monitor -v 1 +system sh/cfg.sh -n dnode1 -c monitor -v 2 +system sh/cfg.sh -n dnode2 -c http -v 1 +system sh/cfg.sh -n dnode1 -c enableHttp -v 1 +system sh/cfg.sh -n dnode2 -c monitor -v 1 +system sh/cfg.sh -n dnode1 -c monitorInterval -v 1 +system sh/cfg.sh -n dnode2 -c monitorInterval -v 1 + +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +sql create database testdb +sql use testdb +sql create table meter1 (ts timestamp, val int) + +$x = 0 +$v = -100 +while $x < 30 + $v = $v + 1 + $ms = $v . m + sql insert into meter1 values (now $ms , $x ) + $x = $x + 1 +endw + +sleep 2000 +system sh/exec.sh -n dnode2 -s start +sql create dnode $hostname2 + + +sleep 10000 + +sql show log.tables; +if $rows > 6 then + return -1 +endi + +sql select * from log.dn1 +print ===>rows $rows +print $data00 $data01 $data02 +print $data10 $data11 $data12 +print $data20 $data21 $data22 +if $rows < 10 then + return -1 +endi + +#sql create table sys.st as select avg(taosd), avg(system) from sys.cpu interval(30s) + +sql show log.vgroups +if $data05 != master then + return -1 +endi +if $data15 != master then + return -1 +endi diff --git a/tests/script/unique/cluster/client1_0.sim b/tests/script/unique/cluster/client1_0.sim new file mode 100644 index 0000000000000000000000000000000000000000..ad48e6dc9378a18969c10ef022b5c14b8256079a --- /dev/null +++ b/tests/script/unique/cluster/client1_0.sim @@ -0,0 +1,70 @@ +#system sh/stop_dnodes.sh +#system sh/deploy.sh -n dnode1 -i 1 +#system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 10000 +#system sh/exec.sh -n dnode1 -s start +#sql connect +#$db = db1 +#sql create database $db +#sql use $db +#$stb = stb1 +#sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) + +$tblStart = 0 +$tblEnd = 1000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +$db = db1 +$stb = stb1 + +sql use $db + +######sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) +$tagPrex = ' . tag + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $tagBinary = $tagPrex . $i + $tagBinary = $tagBinary . ' +# print create table if not exists $tb using $stb tags ( $i , $tagBinary ) + sql create table if not exists $tb using $stb tags ( $i , $tagBinary ) + $i = $i + 1 +endw + +print ====================== client1_0 create table end, start insert data ............ +sql select count(tbname) from $stb +print select count(tbname) from $stb +print data00 $data00 + +$rowsPerLoop = 100 +$ts = $tsStart + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb -x continue_loop + print data00 $data00 totalRows $totalRows + if $data00 < $totalRows then + print ********************** select error ********************** + endi + continue_loop: + print ====================== client1_0 insert data complete once ............ + endi +endw +print ====================== client1_0 success and auto end ===================== \ No newline at end of file diff --git a/tests/script/unique/cluster/client1_1.sim b/tests/script/unique/cluster/client1_1.sim new file mode 100644 index 0000000000000000000000000000000000000000..dd1e68ab4fdcd7949e34eab6b1ea24790215aa80 --- /dev/null +++ b/tests/script/unique/cluster/client1_1.sim @@ -0,0 +1,52 @@ +$tblStart = 10000 +$tblEnd = 20000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +$db = db1 +$stb = stb1 + +sql use $db + + +######sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) +$tagPrex = ' . tag + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $tagBinary = $tagPrex . $i + $tagBinary = $tagBinary . ' + sql create table if not exists $tb using $stb tags ($i, $tagBinary) + $i = $i + 1 +endw + +$rowsPerLoop = 100 +$ts = $tsStart + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb -x continue_loop + print data00 $data00 totalRows $totalRows + if $data00 < $totalRows then + print ********************** select error ********************** + endi + continue_loop: + endi +endw diff --git a/tests/script/unique/cluster/client1_2.sim b/tests/script/unique/cluster/client1_2.sim new file mode 100644 index 0000000000000000000000000000000000000000..4f87810e42b729b5d436eacb6c6be3f04545f2c3 --- /dev/null +++ b/tests/script/unique/cluster/client1_2.sim @@ -0,0 +1,52 @@ +$tblStart = 20000 +$tblEnd = 30000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +$db = db1 +$stb = stb1 + +sql use $db + + +######sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) +$tagPrex = ' . tag + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $tagBinary = $tagPrex . $i + $tagBinary = $tagBinary . ' + sql create table if not exists $tb using $stb tags ($i, $tagBinary) + $i = $i + 1 +endw + +$rowsPerLoop = 100 +$ts = $tsStart + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb -x continue_loop + print data00 $data00 totalRows $totalRows + if $data00 < $totalRows then + print ********************** select error ********************** + endi + continue_loop: + endi +endw diff --git a/tests/script/unique/cluster/client1_3.sim b/tests/script/unique/cluster/client1_3.sim new file mode 100644 index 0000000000000000000000000000000000000000..04df0dfffc37a1e7fa78afefca869f974ea280be --- /dev/null +++ b/tests/script/unique/cluster/client1_3.sim @@ -0,0 +1,52 @@ +$tblStart = 30000 +$tblEnd = 40000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +$db = db1 +$stb = stb1 + +sql use $db + + +######sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) +$tagPrex = ' . tag + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $tagBinary = $tagPrex . $i + $tagBinary = $tagBinary . ' + sql create table if not exists $tb using $stb tags ($i, $tagBinary) + $i = $i + 1 +endw + +$rowsPerLoop = 100 +$ts = $tsStart + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb -x continue_loop + print data00 $data00 totalRows $totalRows + if $data00 < $totalRows then + print ********************** select error ********************** + endi + continue_loop: + endi +endw diff --git a/tests/script/unique/cluster/client2_0.sim b/tests/script/unique/cluster/client2_0.sim new file mode 100644 index 0000000000000000000000000000000000000000..75e4dccf7d2d1013a29b109af3a2dff6c15ce4dd --- /dev/null +++ b/tests/script/unique/cluster/client2_0.sim @@ -0,0 +1,52 @@ +$tblStart = 0 +$tblEnd = 10000 +$tsStart = 1325347200001 # 2012-01-01 00:00:00.001 +############################################################### + +sql connect + +$db = db1 +$stb = stb1 + +sql use $db + + +######sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) +$tagPrex = ' . tag + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $tagBinary = $tagPrex . $i + $tagBinary = $tagBinary . ' + sql create table if not exists $tb using $stb tags ($i, $tagBinary) + $i = $i + 1 +endw + +$rowsPerLoop = 100 +$ts = $tsStart + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb -x continue_loop + print data00 $data00 totalRows $totalRows + if $data00 < $totalRows then + print ********************** select error ********************** + endi + continue_loop: + endi +endw diff --git a/tests/script/unique/cluster/client2_1.sim b/tests/script/unique/cluster/client2_1.sim new file mode 100644 index 0000000000000000000000000000000000000000..4c0d755c045b051cc3a6e8f4f41b088ab0cc2000 --- /dev/null +++ b/tests/script/unique/cluster/client2_1.sim @@ -0,0 +1,52 @@ +$tblStart = 10000 +$tblEnd = 20000 +$tsStart = 1325347200001 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +$db = db1 +$stb = stb1 + +sql use $db + + +######sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) +$tagPrex = ' . tag + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $tagBinary = $tagPrex . $i + $tagBinary = $tagBinary . ' + sql create table if not exists $tb using $stb tags ($i, $tagBinary) + $i = $i + 1 +endw + +$rowsPerLoop = 100 +$ts = $tsStart + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb -x continue_loop + print data00 $data00 totalRows $totalRows + if $data00 < $totalRows then + print ********************** select error ********************** + endi + continue_loop: + endi +endw diff --git a/tests/script/unique/cluster/client2_2.sim b/tests/script/unique/cluster/client2_2.sim new file mode 100644 index 0000000000000000000000000000000000000000..2f08facf38f03f5f80fea4eb9610acfb755ff121 --- /dev/null +++ b/tests/script/unique/cluster/client2_2.sim @@ -0,0 +1,52 @@ +$tblStart = 20000 +$tblEnd = 30000 +$tsStart = 1325347200001 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +$db = db1 +$stb = stb1 + +sql use $db + + +######sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) +$tagPrex = ' . tag + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $tagBinary = $tagPrex . $i + $tagBinary = $tagBinary . ' + sql create table if not exists $tb using $stb tags ($i, $tagBinary) + $i = $i + 1 +endw + +$rowsPerLoop = 100 +$ts = $tsStart + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb -x continue_loop + print data00 $data00 totalRows $totalRows + if $data00 < $totalRows then + print ********************** select error ********************** + endi + continue_loop: + endi +endw diff --git a/tests/script/unique/cluster/client2_3.sim b/tests/script/unique/cluster/client2_3.sim new file mode 100644 index 0000000000000000000000000000000000000000..b83e5b6eaf63c6a2fc3d0702f911de9cc4c45d95 --- /dev/null +++ b/tests/script/unique/cluster/client2_3.sim @@ -0,0 +1,52 @@ +$tblStart = 30000 +$tblEnd = 40000 +$tsStart = 1325347200001 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +$db = db1 +$stb = stb1 + +sql use $db + + +######sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) +$tagPrex = ' . tag + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $tagBinary = $tagPrex . $i + $tagBinary = $tagBinary . ' + sql create table if not exists $tb using $stb tags ($i, $tagBinary) + $i = $i + 1 +endw + +$rowsPerLoop = 100 +$ts = $tsStart + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb -x continue_loop + print data00 $data00 totalRows $totalRows + if $data00 < $totalRows then + print ********************** select error ********************** + endi + continue_loop: + endi +endw diff --git a/tests/script/unique/cluster/client3.sim b/tests/script/unique/cluster/client3.sim new file mode 100644 index 0000000000000000000000000000000000000000..4b3024f881864cdce103afaca8f7b2925ad564d3 --- /dev/null +++ b/tests/script/unique/cluster/client3.sim @@ -0,0 +1,55 @@ +$tblStart = 0 +$tblEnd = 10000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +$db = db1 +$stb = stb1 + +sql use $db + +loop_lable: +print ====================== client3 start loop: dynamic create table and insert data, select, drop table ............ + +$totalRows = 0 + +#sql create table $stb ( ts timestamp, c1 int) tags ( t1 int, t2 binary(16) ) +$tagBinary = ' . client3 +$tagBinary = $tagBinary . ' + +$rowsPerLoop = 100 +$ts = $tsStart + +$i = $tblStart +while $i < $tblEnd + $tb = dtb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb using $stb tags ( $i , $tagBinary ) values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRows = $totalRows + $x +# print ====== app insert totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb where t2 == $tagBinary +if $data00 != $totalRows then + print data00 $data00 totalRows $totalRows + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + print ************ client3 insert loss: $deltaRows ***** + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +endi + +print ====================== client3 drop table +$i = $tblStart +while $i < $tblEnd + $tb = dtb . $i + sql drop table if exists $tb + $i = $i + 1 +endw +goto loop_lable \ No newline at end of file diff --git a/tests/script/unique/cluster/client4.sim b/tests/script/unique/cluster/client4.sim new file mode 100644 index 0000000000000000000000000000000000000000..a4c347695ea4f1adae1dfd7f3a6909533fa64381 --- /dev/null +++ b/tests/script/unique/cluster/client4.sim @@ -0,0 +1,113 @@ +$tblStart = 0 +$tblEnd = 2000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +loop_lable: +print ====================== client4 start loop: create db2, tables and insert data, select, drop db2 ............ + +$db = db2 +$stb = stb2 + +print create database if not exists $db replica 2 +sql create database if not exists $db replica 2 +sql use $db + +print ==== client4start create table +$i = $tblStart +while $i < $tblEnd + $tb = dtb . $i + sql create table $tb (ts timestamp, c1 int) + $i = $i + 1 +endw + + +print ==== client4start insert, include multi table data in one insert sql +$totalRows = 0 +$totalRowsPerTbl = 0 + +$rowsPerLoop = 100 +$ts = $tsStart + +$i = $tblStart +while $i < $tblEnd + $tb0 = dtb . $i + $i = $i + 1 + $tb1 = dtb . $i + $i = $i + 1 + $tb2 = dtb . $i + $i = $i + 1 + $tb3 = dtb . $i + $i = $i + 1 + $tb4 = dtb . $i + $i = $i + 1 + + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb0 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) $tb1 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) $tb2 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) $tb3 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) $tb4 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRowsPerTbl = $totalRowsPerTbl + $x + $x = $x * 5 + $totalRows = $totalRows + $x +endw + +sql select count(*) from tb10 +if $data00 != $totalRowsPerTbl then + print data00 $data00 totalRowsPerTbl $totalRowsPerTbl + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + print ************ client4 insert loss: $deltaRows ***** + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +endi + + +print ====client4 start alter table +$i = $tblStart +while $i < $tblEnd + $tb = dtb . $i + sql alter table $tb add c2 float + $i = $i + 1 +endw + +print ====client4 continue insert, include multi table data in one insert sql + +$i = $tblStart +while $i < $tblEnd + $tb0 = dtb . $i + $i = $i + 1 + $tb1 = dtb . $i + $i = $i + 1 + $tb2 = dtb . $i + $i = $i + 1 + $tb3 = dtb . $i + $i = $i + 1 + $tb4 = dtb . $i + $i = $i + 1 + + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb0 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) $tb1 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) $tb2 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) $tb3 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) $tb4 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRowsPerTbl = $totalRowsPerTbl + $x + $x = $x * 5 + $totalRows = $totalRows + $x +endw + +sql select count(*) from tb10 +if $data00 != $totalRowsPerTbl then + print data00 $data00 totalRowsPerTbl $totalRowsPerTbl + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + print ************ client4 insert loss: $deltaRows ***** + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +endi + +print ====================== client4 drop database +sql drop if exists database $db +goto loop_lable \ No newline at end of file diff --git a/tests/script/unique/cluster/client5.sim b/tests/script/unique/cluster/client5.sim new file mode 100644 index 0000000000000000000000000000000000000000..1fe6298ae7efd78ffb25c58d9ffaa13e29c22d36 --- /dev/null +++ b/tests/script/unique/cluster/client5.sim @@ -0,0 +1,53 @@ +$tblStart = 0 +$tblEnd = 2000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +$tsEnd = 1325347210000 +############################################################### + +sql connect +$db = db1 +$stb = stb1 +#subtable: tb0 - tb4999 +#print create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(16)) + +sleep 20000 # wait other client insert data + +loop_lable: +print ====================== client5 start loop query + +sql use $db + +sql select count(*) from $stb + +$tsQueryStart = $tsStart +$tsQueryStart = $tsStart + 90000 +sql select * from $stb where ts > $tsQueryStart and ts < $tsQueryStart order by ts asc limit 500 offset 7 +sql select * from $stb where ts > $tsQueryStart and ts < $tsQueryStart order by ts desc limit 500 offset 7 + +sql select * from $stb where ts > $tsQueryStart and ts < $tsQueryStart and t2 == 'client1_0' +sql select * from $stb where ts > $tsQueryStart and ts < $tsQueryStart and t2 == 'client1_1' +sql select * from $stb where ts > $tsQueryStart and ts < $tsQueryStart and t2 == 'client1_2' +sql select * from $stb where ts > $tsQueryStart and ts < $tsQueryStart and t2 == 'client1_3' + +sql select * from $stb where ts > $tsQueryStart and ts < $tsQueryStart and t2 == 'client2_0' +sql select * from $stb where ts > $tsQueryStart and ts < $tsQueryStart and t2 == 'client2_1' +sql select * from $stb where ts > $tsQueryStart and ts < $tsQueryStart and t2 == 'client2_2' +sql select * from $stb where ts > $tsQueryStart and ts < $tsQueryStart and t2 == 'client2_3' + +sql select min(c1) from $stb +sql select max(c1) from $stb +sql select first(*) from $stb +sql select last(*) from $stb +sql select last_row(*) from $stb +sql select sum(c1) from $stb +sql select avg(c1) from $stb + +sql select min(c1) from tb1 +sql select max(c1) from tb10 +sql select first(*) from tb100 +sql select last(*) from tb1000 +sql select last_row(*) from tb20 +sql select sum(c1) from tb200 +sql select avg(c1) from tb2000 + +goto loop_lable \ No newline at end of file diff --git a/tests/script/unique/cluster/cluster_main.sim b/tests/script/unique/cluster/cluster_main.sim new file mode 100644 index 0000000000000000000000000000000000000000..d3750be6b4cdefa602dc2987c7cab3541589bd8f --- /dev/null +++ b/tests/script/unique/cluster/cluster_main.sim @@ -0,0 +1,297 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/deploy.sh -n dnode5 -i 5 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode5 -c numOfMnodes -v 3 + +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode3 -c walLevel -v 1 +system sh/cfg.sh -n dnode4 -c walLevel -v 1 +system sh/cfg.sh -n dnode5 -c walLevel -v 1 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode5 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 0 +system sh/cfg.sh -n dnode2 -c role -v 0 +system sh/cfg.sh -n dnode3 -c role -v 0 +system sh/cfg.sh -n dnode4 -c role -v 0 +system sh/cfg.sh -n dnode5 -c role -v 0 + +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 5000 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 5000 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 5000 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 5000 +system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 5000 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode5 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1/dnode2/dnode3 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sleep 2000 +sql connect +sql create dnode $hostname2 +sql create dnode $hostname3 +sleep 2000 + +print ============== step2: create db1 with replica 3 +$db = db1 +print create database $db replica 3 +#sql create database $db replica 3 +sql create database $db replica 3 +sql use $db + +print ============== step3: create stable stb1 +$stb = stb1 +sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) + +print ============== step4: start back client1_0.sim +run_back unique/cluster/client1_0.sim +#run_back unique/cluster/client1_1.sim +#run_back unique/cluster/client1_2.sim +#run_back unique/cluster/client1_3.sim +#run_back unique/cluster/client2_0.sim +#run_back unique/cluster/client2_1.sim +#run_back unique/cluster/client2_2.sim +#run_back unique/cluster/client2_3.sim +#run_back unique/cluster/client3.sim +#run_back unique/cluster/client4.sim + +sleep 20000 + +wait_subsim_insert_complete_create_tables: +sql select count(tbname) from $stb +print select count(tbname) from $stb +print data00 $data00 +if $data00 < 1000 then + sleep 2000 + goto wait_subsim_insert_complete_create_tables +endi + +wait_subsim_insert_data: +print select count(*) from $stb +sql select count(*) from $stb +print data00 $data00 +if $data00 < 1000 then + sleep 2000 + goto wait_subsim_insert_data +endi + +print wait for a while to let clients start insert data +sleep 3000 + +print ============== step4-1: add dnode4/dnode5 into cluster +sql create dnode $hostname4 +sql create dnode $hostname5 + +$loop_cnt = 0 +loop_cluster_do: +print **** **** **** START loop cluster do (loop_cnt: $loop_cnt )**** **** **** **** +print ============== step5: start dnode4/dnode5 +system sh/exec.sh -n dnode4 -s start +system sh/exec.sh -n dnode5 -s start +sleep 20000 + +print ============== step6: stop dnode1 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 10000 +#sql drop dnode $hostname1 +#sleep 3000 + +#system rm -rf ../../../sim/dnode1/data +#sleep 20000 + +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step6-1: restart dnode1 +system sh/exec.sh -n dnode1 -s start +sleep 10000 +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step7: stop dnode2 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 3000 + +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step8: restart dnode2, then wait sync end +system sh/exec.sh -n dnode2 -s start +sleep 20000 +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step9: stop dnode3, then wait sync end +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sleep 20000 +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step10: restart dnode3, then wait sync end +system sh/exec.sh -n dnode3 -s start +sleep 20000 +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step11: stop dnode4, then wait sync end +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep 20000 + +print ============== step12: restart dnode4, then wait sync end +system sh/exec.sh -n dnode4 -s start +sleep 20000 +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step13: alter replica 2 +sql alter database $db replica 2 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +if $data04 != 2 then + print rplica is not modify to 2, error!!!!!! + return -1 +endi + +print ============== step14: stop dnode4/dnode5 +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +sleep 20000 +#system sh/exec.sh -n dnode4 -s start +#system sh/exec.sh -n dnode5 -s start +#sleep 10000 +#sql drop dnode $hostname4 +#sql drop dnode $hostname5 +#system rm -rf ../../../sim/dnode4/data +#system rm -rf ../../../sim/dnode5/data + +print ============== step15: alter replica 1 +sql alter database $db replica 1 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data04 != 1 then + print rplica is not modify to 1, error!!!!!! + return -1 +endi + +print ============== step16: alter replica 2 +sql alter database $db replica 2 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data04 != 2 then + print rplica is not modify to 2, error!!!!!! + return -1 +endi + +#print ============== step17: start dnode1 and add into cluster, then wait dnode1 ready +#system sh/cfg.sh -n dnode1 -c first -v $hostname2 +#system sh/cfg.sh -n dnode1 -c second -v $hostname3 +# +#system sh/exec.sh -n dnode1 -s start +#sql create dnode $hostname1 +#sleep 20000 + +print ============== step18: alter replica 3 +sql alter database $db replica 3 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data04 != 3 then + print rplica is not modify to 3, error!!!!!! + return -1 +endi + +print **** **** **** (loop_cnt: $loop_cnt ) end, continue...... **** **** **** **** +$loop_cnt = $loop_cnt + 1 +goto loop_cluster_do diff --git a/tests/script/unique/cluster/cluster_main0.sim b/tests/script/unique/cluster/cluster_main0.sim new file mode 100644 index 0000000000000000000000000000000000000000..48403d011b4b7603e861441728fd030de6e3c7ba --- /dev/null +++ b/tests/script/unique/cluster/cluster_main0.sim @@ -0,0 +1,282 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/deploy.sh -n dnode5 -i 5 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode5 -c numOfMnodes -v 3 + +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode3 -c walLevel -v 1 +system sh/cfg.sh -n dnode4 -c walLevel -v 1 +system sh/cfg.sh -n dnode5 -c walLevel -v 1 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode5 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 0 +system sh/cfg.sh -n dnode2 -c role -v 0 +system sh/cfg.sh -n dnode3 -c role -v 0 +system sh/cfg.sh -n dnode4 -c role -v 0 +system sh/cfg.sh -n dnode5 -c role -v 0 + +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 5000 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 5000 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 5000 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 5000 +system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 5000 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode5 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1/dnode2/dnode3 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sleep 2000 +sql connect +sql create dnode $hostname2 +sql create dnode $hostname3 +sleep 2000 + +print ============== step2: create db1 with replica 3 +$db = db1 +print create database $db replica 3 +#sql create database $db replica 3 +sql create database $db replica 3 +sql use $db + +print ============== step3: create stable stb1 +$stb = stb1 +print create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(16)) +sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(16)) + +print ============== step4: start others client +run_back unique/cluster/client1_0.sim +run_back unique/cluster/client1_1.sim +run_back unique/cluster/client1_2.sim +run_back unique/cluster/client1_3.sim +#run_back unique/cluster/client2_0.sim +#run_back unique/cluster/client2_1.sim +#run_back unique/cluster/client2_2.sim +#run_back unique/cluster/client2_3.sim +#run_back unique/cluster/client3.sim +#run_back unique/cluster/client4.sim + +sleep 20000 + +wait_subsim_insert_complete_create_tables: +sql select count(tbname) from $stb +print select count(tbname) from $stb +print data00 $data00 +if $data00 < 1000 then + sleep 2000 + goto wait_subsim_insert_complete_create_tables +endi + +wait_subsim_insert_data: +print select count(*) from $stb +sql select count(*) from $stb +print data00 $data00 +if $data00 < 1000 then + sleep 2000 + goto wait_subsim_insert_data +endi + +print wait for a while to let clients start insert data +sleep 3000 + +$loop_cnt = 0 +loop_cluster_do: +print **** **** **** START loop cluster do (loop_cnt: $loop_cnt )**** **** **** **** +print ============== step5: start dnode4/dnode5 and add into cluster, then wait ready +system sh/exec.sh -n dnode4 -s start +system sh/exec.sh -n dnode5 -s start +sql create dnode $hostname4 +sql create dnode $hostname5 + +sleep 3000 + + +print ============== step6: stop dnode1 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 10000 +#sql drop dnode $hostname1 +#sleep 3000 +#system rm -rf ../../../sim/dnode1/data +#sleep 20000 +print ============== step6-1: restart dnode1 +system sh/exec.sh -n dnode1 -s start +sleep 10000 + +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step7: stop dnode2 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 3000 + +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step8: restart dnode2, then wait sync end +system sh/exec.sh -n dnode2 -s start +sleep 20000 +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step9: stop dnode3, then wait sync end +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sleep 20000 +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step10: restart dnode3, then wait sync end +system sh/exec.sh -n dnode3 -s start +sleep 20000 +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step11: stop dnode4, then wait sync end +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep 20000 + +print ============== step12: restart dnode4, then wait sync end +system sh/exec.sh -n dnode4 -s start +sleep 20000 +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step13: alter replica 2 +sql alter database $db replica 2 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +if $data04 != 2 then + print rplica is not modify to 2, error!!!!!! + return -1 +endi + +print ============== step14: stop and drop dnode4/dnode5, then remove data dir of dnode4/dnode5 +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +sleep 2000 +sql drop dnode $hostname4 +sql drop dnode $hostname5 +system rm -rf ../../../sim/dnode4/data +system rm -rf ../../../sim/dnode5/data +sleep 20000 + +print ============== step15: alter replica 1 +sql alter database $db replica 1 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data04 != 1 then + print rplica is not modify to 1, error!!!!!! + return -1 +endi + +print ============== step16: alter replica 2 +sql alter database $db replica 2 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data04 != 2 then + print rplica is not modify to 2, error!!!!!! + return -1 +endi + +#print ============== step17: start dnode1 and add into cluster, then wait dnode1 ready +#system sh/cfg.sh -n dnode1 -c first -v $hostname2 +#system sh/cfg.sh -n dnode1 -c second -v $hostname3 +# +#system sh/exec.sh -n dnode1 -s start +#sql create dnode $hostname1 +#sleep 20000 + +print ============== step18: alter replica 3 +sql alter database $db replica 3 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data04 != 3 then + print rplica is not modify to 3, error!!!!!! + return -1 +endi + +print **** **** **** (loop_cnt: $loop_cnt ) end, continue...... **** **** **** **** +$loop_cnt = $loop_cnt + 1 +goto loop_cluster_do diff --git a/tests/script/unique/cluster/cluster_main1.sim b/tests/script/unique/cluster/cluster_main1.sim new file mode 100644 index 0000000000000000000000000000000000000000..a2426dc5744fe116329013e658dee48dc957a5f2 --- /dev/null +++ b/tests/script/unique/cluster/cluster_main1.sim @@ -0,0 +1,324 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/deploy.sh -n dnode5 -i 5 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode5 -c numOfMnodes -v 3 + +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode3 -c walLevel -v 1 +system sh/cfg.sh -n dnode4 -c walLevel -v 1 +system sh/cfg.sh -n dnode5 -c walLevel -v 1 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode5 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 0 +system sh/cfg.sh -n dnode2 -c role -v 0 +system sh/cfg.sh -n dnode3 -c role -v 0 +system sh/cfg.sh -n dnode4 -c role -v 0 +system sh/cfg.sh -n dnode5 -c role -v 0 + +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 5000 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 5000 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 5000 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 5000 +system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 5000 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode5 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1/dnode2/dnode3 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sleep 2000 +sql connect +sql create dnode $hostname2 +sql create dnode $hostname3 +sleep 2000 + +print ============== step2: create db1 with replica 3 +$replica = 3 +$db = db1 +print create database $db replica $replica +#sql create database $db replica 3 +sql create database $db replica $replica +sql use $db + +print ============== step3: create stable stb1 +$stb = stb1 +print create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(16)) +sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(16)) + +print ============== step4: start others client +run_back unique/cluster/main1_client1_0.sim +run_back unique/cluster/main1_client1_1.sim +run_back unique/cluster/main1_client1_2.sim +run_back unique/cluster/main1_client1_3.sim +run_back unique/cluster/client3.sim +run_back unique/cluster/client4.sim +run_back unique/cluster/client5.sim + +sleep 20000 + +wait_subsim_insert_complete_create_tables: +sql select count(tbname) from $stb +print select count(tbname) from $stb +print data00 $data00 +if $data00 < 1000 then + sleep 3000 + goto wait_subsim_insert_complete_create_tables +endi + +wait_subsim_insert_data: +print select count(*) from $stb +sql select count(*) from $stb +print data00 $data00 +if $data00 < 1000 then + sleep 2000 + goto wait_subsim_insert_data +endi + +print wait for a while to let clients start insert data +sleep 3000 + +print ============== step4-1: add dnode4/dnode5 into cluster +sql create dnode $hostname4 +sql create dnode $hostname5 +sleep 3000 + +$loop_cnt = 0 +loop_cluster_do: +print **** **** **** START loop cluster do (loop_cnt: $loop_cnt )**** **** **** **** +print ============== step5: start dnode4/dnode5 +system sh/exec.sh -n dnode4 -s start +system sh/exec.sh -n dnode5 -s start +sleep 20000 + +print ============== step6: stop dnode1 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 10000 +#sql drop dnode $hostname1 +#sleep 3000 +#system rm -rf ../../../sim/dnode1/data +#sleep 20000 +print ============== step6-1: restart dnode1 +system sh/exec.sh -n dnode1 -s start +sleep 10000 + +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step7: stop dnode2 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 3000 + +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step8: restart dnode2, then wait sync end +system sh/exec.sh -n dnode2 -s start +sleep 20000 +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step9: stop dnode3, then wait sync end +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sleep 20000 +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step10: restart dnode3, then wait sync end +system sh/exec.sh -n dnode3 -s start +sleep 20000 +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step11: stop dnode4, then wait sync end +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep 20000 + +#print ============== step12: restart dnode4, then wait sync end +#system sh/exec.sh -n dnode4 -s start +#sleep 20000 +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step13: alter replica 2 +sql alter database $db replica 2 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 + +if $data00 == db1 then + $replica = $data04 +elif $data10 == db1 then + $replica = $data14 +else then + print ==== db1 already not exists!!!!! + return -1 +endi + +if $replica != 2 then + print rplica is not modify to 2, error!!!!!! + return -1 +endi + +print ============== step14: stop dnode5 +system sh/exec.sh -n dnode5 -s stop -x SIGINT +sleep 20000 +#system rm -rf ../../../sim/dnode5/data + +#print ============== step14-1: drop dnode5, then remove data dir +#sql drop dnode $hostname5 +#sleep 20000 +#system rm -rf ../../../sim/dnode5/data + +print ============== step15: alter replica 1 +sql alter database $db replica 1 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 + +if $data00 == db1 then + $replica = $data04 +elif $data10 == db1 then + $replica = $data14 +else then + print ==== db1 already not exists!!!!! + return -1 +endi + +if $replica != 1 then + print rplica is not modify to 1, error!!!!!! + return -1 +endi + +print ============== step16: alter replica 2 +sql alter database $db replica 2 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 + +if $data00 == db1 then + $replica = $data04 +elif $data10 == db1 then + $replica = $data14 +else then + print ==== db1 already not exists!!!!! + return -1 +endi + +if $replica != 2 then + print rplica is not modify to 2, error!!!!!! + return -1 +endi + +#print ============== step17: start dnode1 and add into cluster, then wait dnode1 ready +#system sh/cfg.sh -n dnode1 -c first -v $hostname2 +#system sh/cfg.sh -n dnode1 -c second -v $hostname3 +# +#system sh/exec.sh -n dnode1 -s start +#sql create dnode $hostname1 +#sleep 20000 + +print ============== step18: alter replica 3 +sql alter database $db replica 3 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 + +if $data00 == db1 then + $replica = $data04 +elif $data10 == db1 then + $replica = $data14 +else then + print ==== db1 already not exists!!!!! + return -1 +endi + +if $replica != 3 then + print rplica is not modify to 3, error!!!!!! + return -1 +endi + +print **** **** **** (loop_cnt: $loop_cnt ) end, continue...... **** **** **** **** +$loop_cnt = $loop_cnt + 1 +goto loop_cluster_do diff --git a/tests/script/unique/cluster/cluster_main2.sim b/tests/script/unique/cluster/cluster_main2.sim new file mode 100644 index 0000000000000000000000000000000000000000..e050ab3acf54d22becb50f6e91f83fc4eab0485b --- /dev/null +++ b/tests/script/unique/cluster/cluster_main2.sim @@ -0,0 +1,328 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/deploy.sh -n dnode5 -i 5 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode5 -c numOfMnodes -v 3 + +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode3 -c walLevel -v 1 +system sh/cfg.sh -n dnode4 -c walLevel -v 1 +system sh/cfg.sh -n dnode5 -c walLevel -v 1 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode5 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 0 +system sh/cfg.sh -n dnode2 -c role -v 0 +system sh/cfg.sh -n dnode3 -c role -v 0 +system sh/cfg.sh -n dnode4 -c role -v 0 +system sh/cfg.sh -n dnode5 -c role -v 0 + +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 5000 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 5000 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 5000 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 5000 +system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 5000 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode5 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1/dnode2/dnode3 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sleep 2000 +sql connect +sql create dnode $hostname2 +sql create dnode $hostname3 +sleep 2000 + +print ============== step2: create db1 with replica 3 +$replica = 3 +$db = db1 +print create database $db replica $replica +#sql create database $db replica 3 +sql create database $db replica $replica +sql use $db + +print ============== step3: create stable stb1 +$stb = stb1 +print create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(16)) +sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(16)) + +print ============== step4: start others client +run_back unique/cluster/main2_client1_0.sim +run_back unique/cluster/main2_client1_1.sim +run_back unique/cluster/main2_client1_2.sim +run_back unique/cluster/main2_client1_3.sim +run_back unique/cluster/main2_client2_0.sim +run_back unique/cluster/main2_client2_1.sim +run_back unique/cluster/main2_client2_2.sim +run_back unique/cluster/main2_client2_3.sim +run_back unique/cluster/client3.sim +run_back unique/cluster/client4.sim +run_back unique/cluster/client5.sim + +sleep 20000 + +wait_subsim_insert_complete_create_tables: +sql select count(tbname) from $stb +print select count(tbname) from $stb +print data00 $data00 +if $data00 < 1000 then + sleep 2000 + goto wait_subsim_insert_complete_create_tables +endi + +wait_subsim_insert_data: +print select count(*) from $stb +sql select count(*) from $stb +print data00 $data00 +if $data00 < 1000 then + sleep 2000 + goto wait_subsim_insert_data +endi + +print wait for a while to let clients start insert data +sleep 3000 + +print ============== step4-1: add dnode4/dnode5 into cluster +sql create dnode $hostname4 +sql create dnode $hostname5 +sleep 3000 + + +$loop_cnt = 0 +loop_cluster_do: +print **** **** **** START loop cluster do (loop_cnt: $loop_cnt )**** **** **** **** +print ============== step5: start dnode4/dnode5 +system sh/exec.sh -n dnode4 -s start +system sh/exec.sh -n dnode5 -s start + +print ============== step6: stop dnode1 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 10000 +#sql drop dnode $hostname1 +#sleep 3000 +#system rm -rf ../../../sim/dnode1/data +#sleep 20000 +print ============== step6-1: restart dnode1 +system sh/exec.sh -n dnode1 -s start +sleep 10000 + +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step7: stop dnode2 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 3000 + +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step8: restart dnode2, then wait sync end +system sh/exec.sh -n dnode2 -s start +sleep 20000 +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step9: stop dnode3, then wait sync end +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sleep 20000 +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step10: restart dnode3, then wait sync end +system sh/exec.sh -n dnode3 -s start +sleep 20000 +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step11: stop dnode4, then wait sync end +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep 20000 + +#print ============== step12: restart dnode4, then wait sync end +#system sh/exec.sh -n dnode4 -s start +#sleep 20000 +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step13: alter replica 2 +sql alter database $db replica 2 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 + +if $data00 == db1 then + $replica = $data04 +elif $data10 == db1 then + $replica = $data14 +else then + print ==== db1 already not exists!!!!! + return -1 +endi + +if $replica != 2 then + print rplica is not modify to 2, error!!!!!! + return -1 +endi + +print ============== step14: drop dnode5, then remove data dir +system sh/exec.sh -n dnode5 -s stop -x SIGINT +sleep 20000 +#system rm -rf ../../../sim/dnode5/data + +#print ============== step14-1: drop dnode5, then remove data dir +#sql drop dnode $hostname5 +#sleep 20000 +#system rm -rf ../../../sim/dnode5/data + +print ============== step15: alter replica 1 +sql alter database $db replica 1 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 + +if $data00 == db1 then + $replica = $data04 +elif $data10 == db1 then + $replica = $data14 +else then + print ==== db1 already not exists!!!!! + return -1 +endi + +if $replica != 1 then + print rplica is not modify to 1, error!!!!!! + return -1 +endi + +print ============== step16: alter replica 2 +sql alter database $db replica 2 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 + +if $data00 == db1 then + $replica = $data04 +elif $data10 == db1 then + $replica = $data14 +else then + print ==== db1 already not exists!!!!! + return -1 +endi + +if $replica != 2 then + print rplica is not modify to 2, error!!!!!! + return -1 +endi + +#print ============== step17: start dnode1 and add into cluster, then wait dnode1 ready +#system sh/cfg.sh -n dnode1 -c first -v $hostname2 +#system sh/cfg.sh -n dnode1 -c second -v $hostname3 +# +#system sh/exec.sh -n dnode1 -s start +#sql create dnode $hostname1 +#sleep 20000 + +print ============== step18: alter replica 3 +sql alter database $db replica 3 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 + +if $data00 == db1 then + $replica = $data04 +elif $data10 == db1 then + $replica = $data14 +else then + print ==== db1 already not exists!!!!! + return -1 +endi + +if $replica != 3 then + print rplica is not modify to 3, error!!!!!! + return -1 +endi + +print **** **** **** (loop_cnt: $loop_cnt ) end, continue...... **** **** **** **** +$loop_cnt = $loop_cnt + 1 +goto loop_cluster_do diff --git a/tests/script/unique/cluster/flowctrl.sim b/tests/script/unique/cluster/flowctrl.sim new file mode 100644 index 0000000000000000000000000000000000000000..700fa0a3f195c84ed6e7903fe572c81b20b4fd21 --- /dev/null +++ b/tests/script/unique/cluster/flowctrl.sim @@ -0,0 +1,131 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c http -v 0 +system sh/cfg.sh -n dnode2 -c http -v 0 +system sh/cfg.sh -n dnode3 -c http -v 0 + +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 20000 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 20000 +system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 20000 + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 20 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 20 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 20 + +system sh/cfg.sh -n dnode1 -c replica -v 3 +system sh/cfg.sh -n dnode2 -c replica -v 3 +system sh/cfg.sh -n dnode3 -c replica -v 3 + +print ============== deploy + +system sh/exec.sh -n dnode1 -s start +sleep 5001 +sql connect + +sql create dnode $hostname2 +sql create dnode $hostname3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start + +print =============== step1 +$x = 0 +show1: + $x = $x + 1 + sleep 2000 + if $x == 5 then + return -1 + endi +sql show mnodes -x show1 +$mnode1Role = $data2_1 +print mnode1Role $mnode1Role +$mnode2Role = $data2_2 +print mnode2Role $mnode2Role +$mnode3Role = $data2_3 +print mnode3Role $mnode3Role + +if $mnode1Role != master then + goto show1 +endi +if $mnode2Role != slave then + goto show1 +endi +if $mnode3Role != slave then + goto show1 +endi + +print =============== step2 + +sql create database db replica 3 +sql use db +sql create table tb (ts timestamp, test int) + +$x = 0 +while $x < 100 + $ms = $x . s + sql insert into tb values (now + $ms , $x ) + $x = $x + 1 +endw + +print =============== step3 +sleep 2000 + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT + +print =============== step4 +sleep 3000 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start + +print =============== step5 +sleep 8000 +while $x < 200 + $ms = $x . s + sql insert into tb values (now + $ms , $x ) + $x = $x + 1 +endw + +print =============== step6 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 2000 +while $x < 300 + $ms = $x . s + sql insert into tb values (now + $ms , $x ) + $x = $x + 1 +endw + +system sh/exec.sh -n dnode2 -s start + +sleep 6000 +print =============== step7 +while $x < 400 + $ms = $x . s + sql insert into tb values (now + $ms , $x ) + $x = $x + 1 + sleep 1 +endw + +print =============== step8 +sql select * from tb +print rows $rows +if $rows != 400 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/cluster/main1_client1_0.sim b/tests/script/unique/cluster/main1_client1_0.sim new file mode 100644 index 0000000000000000000000000000000000000000..e54fd7f1a7efad6db79268eda211d4a414fb3ed5 --- /dev/null +++ b/tests/script/unique/cluster/main1_client1_0.sim @@ -0,0 +1,93 @@ +#system sh/stop_dnodes.sh +#system sh/deploy.sh -n dnode1 -i 1 +#system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 10000\ +#system sh/exec.sh -n dnode1 -s start +#sql connect +#$db = db1 +#sql create database $db +#sql use $db +#$stb = stb1 +#sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) + + +$tblStart = 0 +$tblEnd = 1000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +$db = db1 +$stb = stb1 + +sql use $db + +######sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) +$tagBinary = ' . client1_0 +$tagBinary = $tagBinary . ' +#print ======= tag: $tagBinary + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i +# print create table if not exists $tb using $stb tags ( $i , $tagBinary ) + sql create table if not exists $tb using $stb tags ( $i , $tagBinary ) + $i = $i + 1 +endw + +print ====================== client1_0 create table end, start insert data ............ +sql select count(tbname) from $stb +print select count(tbname) from $stb +print data00 $data00 + +$rowsPerLoop = 100 +$ts = $tsStart + +$lastLossRows = 0 + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) -x insert_error_loop + $x = $x + 20 + $ts = $ts + 40a + goto continue_next_0 + insert_error_loop: + print ============== main1_client1_0 run error: sql insert into $tb values ( $ts + 0a , $x ) ... ... + continue_next_0: + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb where t2 == $tagBinary -x query_error_loop + if $data00 != $totalRows then + print data00 $data00 totalRows $totalRows + $deltaRows = $totalRows - $data00 + if $lastLossRows == 0 then + $lastLossRows = $deltaRows + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + print ************ client1_0 insert loss: $deltaRows ***** + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + elif $deltaRows != $lastLossRows + $tmp = $deltaRows - $lastLossRows + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + print ************ client1_0 insert loss: $tmp *********** + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + $lastLossRows = $deltaRows + endi +# return -1 + endi + goto continue_next_1 + query_error_loop: + print ============== main1_client1_0 run error: sql select count(*) from $stb where t2 == $tagBinary -x query_error_loop + continue_next_1: + print ====================== client1_0 insert data complete once ............ + endi +endw +print ====================== client1_0 success and auto end ===================== \ No newline at end of file diff --git a/tests/script/unique/cluster/main1_client1_1.sim b/tests/script/unique/cluster/main1_client1_1.sim new file mode 100644 index 0000000000000000000000000000000000000000..b50f533ce1cede4c1c8fd788bd89c85b64d8d375 --- /dev/null +++ b/tests/script/unique/cluster/main1_client1_1.sim @@ -0,0 +1,82 @@ +$tblStart = 1000 +$tblEnd = 2000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +$db = db1 +$stb = stb1 + +sql use $db + + +######sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) +$tagBinary = ' . client1_1 +$tagBinary = $tagBinary . ' +#print ======= tag: $tagBinary + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i +# print create table if not exists $tb using $stb tags ( $i , $tagBinary ) + sql create table if not exists $tb using $stb tags ( $i , $tagBinary ) + $i = $i + 1 +endw + +print ====================== client1_1 create table end, start insert data ............ +sql select count(tbname) from $stb +print select count(tbname) from $stb +print data00 $data00 + +$rowsPerLoop = 100 +$ts = $tsStart + +$lastLossRows = 0 + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) -x insert_error_loop + $x = $x + 20 + $ts = $ts + 40a + goto continue_next_0 + insert_error_loop: + print ============== main1_client1_1 run error: sql insert into $tb values ( $ts + 0a , $x ) ... ... + continue_next_0: + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb where t2 == $tagBinary -x query_error_loop + if $data00 != $totalRows then + print data00 $data00 totalRows $totalRows + $deltaRows = $totalRows - $data00 + if $lastLossRows == 0 then + $lastLossRows = $deltaRows + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + print ************ client1_1 insert loss: $deltaRows ***** + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + elif $deltaRows != $lastLossRows + $tmp = $deltaRows - $lastLossRows + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + print ************ client1_1 insert loss: $tmp *********** + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + $lastLossRows = $deltaRows + endi +# return -1 + endi + goto continue_next_1 + query_error_loop: + print ============== main1_client1_1 run error: sql select count(*) from $stb where t2 == $tagBinary -x query_error_loop + continue_next_1: + print ====================== client1_2 insert data complete once ............ + endi +endw +print ====================== client1_1 success and auto end ===================== \ No newline at end of file diff --git a/tests/script/unique/cluster/main1_client1_2.sim b/tests/script/unique/cluster/main1_client1_2.sim new file mode 100644 index 0000000000000000000000000000000000000000..8cc39ded0437379cbd391dad0dfad26cc32a8f05 --- /dev/null +++ b/tests/script/unique/cluster/main1_client1_2.sim @@ -0,0 +1,81 @@ +$tblStart = 2000 +$tblEnd = 3000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +$db = db1 +$stb = stb1 + +sql use $db + +######sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) +$tagBinary = ' . client1_2 +$tagBinary = $tagBinary . ' +#print ======= tag: $tagBinary + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i +# print create table if not exists $tb using $stb tags ( $i , $tagBinary ) + sql create table if not exists $tb using $stb tags ( $i , $tagBinary ) + $i = $i + 1 +endw + +print ====================== client1_2 create table end, start insert data ............ +sql select count(tbname) from $stb +print select count(tbname) from $stb +print data00 $data00 + +$rowsPerLoop = 100 +$ts = $tsStart + +$lastLossRows = 0 + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) -x insert_error_loop + $x = $x + 20 + $ts = $ts + 40a + goto continue_next_0 + insert_error_loop: + print ============== main1_client1_2 run error: sql insert into $tb values ( $ts + 0a , $x ) ... ... + continue_next_0: + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb where t2 == $tagBinary -x query_error_loop + if $data00 != $totalRows then + print data00 $data00 totalRows $totalRows + $deltaRows = $totalRows - $data00 + if $lastLossRows == 0 then + $lastLossRows = $deltaRows + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + print ************ client1_2 insert loss: $deltaRows ***** + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + elif $deltaRows != $lastLossRows + $tmp = $deltaRows - $lastLossRows + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + print ************ client1_2 insert loss: $tmp *********** + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + $lastLossRows = $deltaRows + endi +# return -1 + endi + goto continue_next_1 + query_error_loop: + print ============== main1_client1_2 run error: sql select count(*) from $stb where t2 == $tagBinary -x query_error_loop + continue_next_1: + print ====================== client1_2 insert data complete once ............ + endi +endw +print ====================== client1_2 success and auto end ===================== \ No newline at end of file diff --git a/tests/script/unique/cluster/main1_client1_3.sim b/tests/script/unique/cluster/main1_client1_3.sim new file mode 100644 index 0000000000000000000000000000000000000000..72e1be48ac64d34f7c7c06e7ae882de164b3c22c --- /dev/null +++ b/tests/script/unique/cluster/main1_client1_3.sim @@ -0,0 +1,81 @@ +$tblStart = 3000 +$tblEnd = 4000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +$db = db1 +$stb = stb1 + +sql use $db + +######sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) +$tagBinary = ' . client1_3 +$tagBinary = $tagBinary . ' +#print ======= tag: $tagBinary + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i +# print create table if not exists $tb using $stb tags ( $i , $tagBinary ) + sql create table if not exists $tb using $stb tags ( $i , $tagBinary ) + $i = $i + 1 +endw + +print ====================== client1_3 create table end, start insert data ............ +sql select count(tbname) from $stb +print select count(tbname) from $stb +print data00 $data00 + +$rowsPerLoop = 100 +$ts = $tsStart + +$lastLossRows = 0 + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) -x insert_error_loop + $x = $x + 20 + $ts = $ts + 40a + goto continue_next_0 + insert_error_loop: + print ============== main1_client1_3 run error: sql insert into $tb values ( $ts + 0a , $x ) ... ... + continue_next_0: + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb where t2 == $tagBinary -x query_error_loop + if $data00 != $totalRows then + print data00 $data00 totalRows $totalRows + $deltaRows = $totalRows - $data00 + if $lastLossRows == 0 then + $lastLossRows = $deltaRows + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + print ************ client1_3 insert loss: $deltaRows ***** + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + elif $deltaRows != $lastLossRows + $tmp = $deltaRows - $lastLossRows + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + print ************ client1_3 insert loss: $tmp *********** + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + $lastLossRows = $deltaRows + endi +# return -1 + endi + goto continue_next_1 + query_error_loop: + print ============== main1_client1_3 run error: sql select count(*) from $stb where t2 == $tagBinary -x query_error_loop + continue_next_1: + print ====================== client1_3 insert data complete once ............ + endi +endw +print ====================== client1_3 success and auto end ===================== \ No newline at end of file diff --git a/tests/script/unique/cluster/main1_client4.sim b/tests/script/unique/cluster/main1_client4.sim new file mode 100644 index 0000000000000000000000000000000000000000..eb8049b04beafa2c8a909deae83b26d83d12245d --- /dev/null +++ b/tests/script/unique/cluster/main1_client4.sim @@ -0,0 +1,127 @@ +$tblStart = 0 +$tblEnd = 10000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +$db = db2 +$stb = stb2 + +loop_lable: +print ========= start loop create db, table, inset data, alter column/tag, select, drop db + +sql create database if not exists $db +sql use $db +sql create table if not exists $stb ( ts timestamp, c1 int, c2 float ) tags ( t1 int , t2 binary(16) ) +$tagBinary = ' . client4 +$tagBinary = $tagBinary . ' + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + sql create table if not exists $tb using $stb tags ( $i , $tagBinary ) + $i = $i + 1 +endw + +$rowsPerLoop = 100 +$ts = $tsStart + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x , $x ) ( $ts + 2a , $x , $x ) ( $ts + 4a , $x , $x ) ( $ts + 6a , $x , $x ) ( $ts + 8a , $x , $x ) ( $ts + 10a , $x , $x ) ( $ts + 12a , $x , $x ) ( $ts + 14a , $x , $x ) ( $ts + 16a , $x , $x ) ( $ts + 18a , $x , $x ) ( $ts + 20a , $x , $x ) ( $ts + 22a , $x , $x ) ( $ts + 24a , $x , $x ) ( $ts + 26a , $x , $x ) ( $ts + 28a , $x , $x ) ( $ts + 30a , $x , $x ) ( $ts + 32a , $x , $x ) ( $ts + 34a , $x , $x ) ( $ts + 36a , $x , $x ) ( $ts + 38a , $x , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb -x continue_loop + print data00 $data00 totalRows $totalRows + if $data00 != $totalRows then + print ********************** select error ********************** + endi + continue_loop: + print ====================== client4 insert data complete once ............ + endi +endw + +##################### alter column +sql alter table $stb add column c3 double +sql alter table $stb drop column c2 + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x , $x ) ( $ts + 2a , $x , $x ) ( $ts + 4a , $x , $x ) ( $ts + 6a , $x , $x ) ( $ts + 8a , $x , $x ) ( $ts + 10a , $x , $x ) ( $ts + 12a , $x , $x ) ( $ts + 14a , $x , $x ) ( $ts + 16a , $x , $x ) ( $ts + 18a , $x , $x ) ( $ts + 20a , $x , $x ) ( $ts + 22a , $x , $x ) ( $ts + 24a , $x , $x ) ( $ts + 26a , $x , $x ) ( $ts + 28a , $x , $x ) ( $ts + 30a , $x , $x ) ( $ts + 32a , $x , $x ) ( $ts + 34a , $x , $x ) ( $ts + 36a , $x , $x ) ( $ts + 38a , $x , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb -x continue_loop + print data00 $data00 totalRows $totalRows + if $data00 != $totalRows then + print ********************** select error ********************** + endi + continue_loop: + print ====================== client4 insert data complete once ............ + endi +endw + + +##################### alter tag +sql alter table $stb add tag t3 int +sql alter table $stb drop tag t2 + +$i = $tblStart +while $i < $tblEnd + $tb = ttb . $i + sql create table if not exists $tb using $stb tags ($i, $i) + $i = $i + 1 +endw + +$rowsPerLoop = 100 +$ts = $tsStart + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x , $x ) ( $ts + 2a , $x , $x ) ( $ts + 4a , $x , $x ) ( $ts + 6a , $x , $x ) ( $ts + 8a , $x , $x ) ( $ts + 10a , $x , $x ) ( $ts + 12a , $x , $x ) ( $ts + 14a , $x , $x ) ( $ts + 16a , $x , $x ) ( $ts + 18a , $x , $x ) ( $ts + 20a , $x , $x ) ( $ts + 22a , $x , $x ) ( $ts + 24a , $x , $x ) ( $ts + 26a , $x , $x ) ( $ts + 28a , $x , $x ) ( $ts + 30a , $x , $x ) ( $ts + 32a , $x , $x ) ( $ts + 34a , $x , $x ) ( $ts + 36a , $x , $x ) ( $ts + 38a , $x , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb -x continue_loop + print data00 $data00 totalRows $totalRows + if $data00 != $totalRows then + print ********************** select error ********************** + endi + continue_loop: + print ====================== client4 insert data complete once ............ + endi +endw + +goto loop_lable \ No newline at end of file diff --git a/tests/script/unique/cluster/main2_client1_0.sim b/tests/script/unique/cluster/main2_client1_0.sim new file mode 100644 index 0000000000000000000000000000000000000000..240c22aacc452b25a1d12c0a60f65bb52919de7e --- /dev/null +++ b/tests/script/unique/cluster/main2_client1_0.sim @@ -0,0 +1,68 @@ +#system sh/stop_dnodes.sh +#system sh/deploy.sh -n dnode1 -i 1 +#system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 10000 +#system sh/exec.sh -n dnode1 -s start +#sql connect +#$db = db1 +#sql create database $db +#sql use $db +#$stb = stb1 +#sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) + + +$tblStart = 0 +$tblEnd = 1000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +$db = db1 +$stb = stb1 + +sql use $db + +######sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) +$tagBinary = ' . client1_0 +$tagBinary = $tagBinary . ' +#print ======= tag: $tagBinary + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i +# print create table if not exists $tb using $stb tags ( $i , $tagBinary ) + sql create table if not exists $tb using $stb tags ( $i , $tagBinary ) + $i = $i + 1 +endw + +print ====================== client1_0 create table end, start insert data ............ +sql select count(tbname) from $stb +print select count(tbname) from $stb +print data00 $data00 + +$rowsPerLoop = 100 +$ts = $tsStart + +$lastLossRows = 0 + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb where t2 == $tagBinary + print ====================== client1_0 insert data complete once ............ + endi +endw +print ====================== client1_0 success and auto end ===================== \ No newline at end of file diff --git a/tests/script/unique/cluster/main2_client1_1.sim b/tests/script/unique/cluster/main2_client1_1.sim new file mode 100644 index 0000000000000000000000000000000000000000..f22d62a7411110e3b7b94fd54702dd24c9af1b48 --- /dev/null +++ b/tests/script/unique/cluster/main2_client1_1.sim @@ -0,0 +1,57 @@ +$tblStart = 1000 +$tblEnd = 2000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +$db = db1 +$stb = stb1 + +sql use $db + + +######sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) +$tagBinary = ' . client1_1 +$tagBinary = $tagBinary . ' +#print ======= tag: $tagBinary + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i +# print create table if not exists $tb using $stb tags ( $i , $tagBinary ) + sql create table if not exists $tb using $stb tags ( $i , $tagBinary ) + $i = $i + 1 +endw + +print ====================== client1_1 create table end, start insert data ............ +sql select count(tbname) from $stb +print select count(tbname) from $stb +print data00 $data00 + +$rowsPerLoop = 100 +$ts = $tsStart + +$lastLossRows = 0 + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb where t2 == $tagBinary + print ====================== client1_1 insert data complete once ............ + endi +endw +print ====================== client1_1 success and auto end ===================== \ No newline at end of file diff --git a/tests/script/unique/cluster/main2_client1_2.sim b/tests/script/unique/cluster/main2_client1_2.sim new file mode 100644 index 0000000000000000000000000000000000000000..df3a925c591194b819d8d1fc6bf9234d851fa5b4 --- /dev/null +++ b/tests/script/unique/cluster/main2_client1_2.sim @@ -0,0 +1,56 @@ +$tblStart = 2000 +$tblEnd = 3000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +$db = db1 +$stb = stb1 + +sql use $db + +######sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) +$tagBinary = ' . client1_2 +$tagBinary = $tagBinary . ' +#print ======= tag: $tagBinary + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i +# print create table if not exists $tb using $stb tags ( $i , $tagBinary ) + sql create table if not exists $tb using $stb tags ( $i , $tagBinary ) + $i = $i + 1 +endw + +print ====================== client1_2 create table end, start insert data ............ +sql select count(tbname) from $stb +print select count(tbname) from $stb +print data00 $data00 + +$rowsPerLoop = 100 +$ts = $tsStart + +$lastLossRows = 0 + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb where t2 == $tagBinary + print ====================== client1_2 insert data complete once ............ + endi +endw +print ====================== client1_2 success and auto end ===================== \ No newline at end of file diff --git a/tests/script/unique/cluster/main2_client1_3.sim b/tests/script/unique/cluster/main2_client1_3.sim new file mode 100644 index 0000000000000000000000000000000000000000..9c22432fa5176ec8cb36f6549e312170803263db --- /dev/null +++ b/tests/script/unique/cluster/main2_client1_3.sim @@ -0,0 +1,56 @@ +$tblStart = 3000 +$tblEnd = 4000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +$db = db1 +$stb = stb1 + +sql use $db + +######sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) +$tagBinary = ' . client1_3 +$tagBinary = $tagBinary . ' +#print ======= tag: $tagBinary + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i +# print create table if not exists $tb using $stb tags ( $i , $tagBinary ) + sql create table if not exists $tb using $stb tags ( $i , $tagBinary ) + $i = $i + 1 +endw + +print ====================== client1_3 create table end, start insert data ............ +sql select count(tbname) from $stb +print select count(tbname) from $stb +print data00 $data00 + +$rowsPerLoop = 100 +$ts = $tsStart + +$lastLossRows = 0 + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb where t2 == $tagBinary + print ====================== client1_3 insert data complete once ............ + endi +endw +print ====================== client1_3 success and auto end ===================== \ No newline at end of file diff --git a/tests/script/unique/cluster/main2_client2_0.sim b/tests/script/unique/cluster/main2_client2_0.sim new file mode 100644 index 0000000000000000000000000000000000000000..e44efc49fc7333541d5870ed05eb1cb1a289c3a2 --- /dev/null +++ b/tests/script/unique/cluster/main2_client2_0.sim @@ -0,0 +1,56 @@ +$tblStart = 0 +$tblEnd = 1000 +$tsStart = 1325347200001 # 2012-01-01 00:00:00.001 +############################################################### + +sql connect + +$db = db1 +$stb = stb1 + +sql use $db + +######sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) +$tagBinary = ' . client2_0 +$tagBinary = $tagBinary . ' +#print ======= tag: $tagBinary + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i +# print create table if not exists $tb using $stb tags ( $i , $tagBinary ) + sql create table if not exists $tb using $stb tags ( $i , $tagBinary ) + $i = $i + 1 +endw + +print ====================== client2_0 create table end, start insert data ............ +sql select count(tbname) from $stb +print select count(tbname) from $stb +print data00 $data00 + +$rowsPerLoop = 100 +$ts = $tsStart + +$lastLossRows = 0 + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb where t2 == $tagBinary + print ====================== client2_0 insert data complete once ............ + endi +endw +print ====================== client2_0 success and auto end ===================== \ No newline at end of file diff --git a/tests/script/unique/cluster/main2_client2_1.sim b/tests/script/unique/cluster/main2_client2_1.sim new file mode 100644 index 0000000000000000000000000000000000000000..19de147d3ea79b54702b8ce0da30d2bff69841f2 --- /dev/null +++ b/tests/script/unique/cluster/main2_client2_1.sim @@ -0,0 +1,57 @@ +$tblStart = 1000 +$tblEnd = 2000 +$tsStart = 1325347200001 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +$db = db1 +$stb = stb1 + +sql use $db + + +######sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) +$tagBinary = ' . client2_1 +$tagBinary = $tagBinary . ' +#print ======= tag: $tagBinary + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i +# print create table if not exists $tb using $stb tags ( $i , $tagBinary ) + sql create table if not exists $tb using $stb tags ( $i , $tagBinary ) + $i = $i + 1 +endw + +print ====================== client2_1 create table end, start insert data ............ +sql select count(tbname) from $stb +print select count(tbname) from $stb +print data00 $data00 + +$rowsPerLoop = 100 +$ts = $tsStart + +$lossRows = 0 + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb where t2 == $tagBinary + print ====================== client2_1 insert data complete once ............ + endi +endw +print ====================== client2_1 success and auto end ===================== \ No newline at end of file diff --git a/tests/script/unique/cluster/main2_client2_2.sim b/tests/script/unique/cluster/main2_client2_2.sim new file mode 100644 index 0000000000000000000000000000000000000000..19e3540bd1676ebb15d0d318488feea61ef9074a --- /dev/null +++ b/tests/script/unique/cluster/main2_client2_2.sim @@ -0,0 +1,57 @@ +$tblStart = 2000 +$tblEnd = 3000 +$tsStart = 1325347200001 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +$db = db1 +$stb = stb1 + +sql use $db + + +######sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) +$tagBinary = ' . client2_2 +$tagBinary = $tagBinary . ' +#print ======= tag: $tagBinary + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i +# print create table if not exists $tb using $stb tags ( $i , $tagBinary ) + sql create table if not exists $tb using $stb tags ( $i , $tagBinary ) + $i = $i + 1 +endw + +print ====================== client2_2 create table end, start insert data ............ +sql select count(tbname) from $stb +print select count(tbname) from $stb +print data00 $data00 + +$rowsPerLoop = 100 +$ts = $tsStart + +$lossRows = 0 + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb where t2 == $tagBinary + print ====================== client2_2 insert data complete once ............ + endi +endw +print ====================== client2_2 success and auto end ===================== \ No newline at end of file diff --git a/tests/script/unique/cluster/main2_client2_3.sim b/tests/script/unique/cluster/main2_client2_3.sim new file mode 100644 index 0000000000000000000000000000000000000000..219df131c8f31babc25f2204dbddab7f0232c56b --- /dev/null +++ b/tests/script/unique/cluster/main2_client2_3.sim @@ -0,0 +1,57 @@ +$tblStart = 3000 +$tblEnd = 4000 +$tsStart = 1325347200001 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +$db = db1 +$stb = stb1 + +sql use $db + + +######sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) +$tagBinary = ' . client2_3 +$tagBinary = $tagBinary . ' +#print ======= tag: $tagBinary + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i +# print create table if not exists $tb using $stb tags ( $i , $tagBinary ) + sql create table if not exists $tb using $stb tags ( $i , $tagBinary ) + $i = $i + 1 +endw + +print ====================== client2_3 create table end, start insert data ............ +sql select count(tbname) from $stb +print select count(tbname) from $stb +print data00 $data00 + +$rowsPerLoop = 100 +$ts = $tsStart + +$lossRows = 0 + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb where t2 == $tagBinary + print ====================== client2_3 insert data complete once ............ + endi +endw +print ====================== client2_3 success and auto end ===================== \ No newline at end of file diff --git a/tests/script/unique/cluster/testSuite.sim b/tests/script/unique/cluster/testSuite.sim new file mode 100644 index 0000000000000000000000000000000000000000..9657558c12a0a47441127f64a25541ebc15390e6 --- /dev/null +++ b/tests/script/unique/cluster/testSuite.sim @@ -0,0 +1,4 @@ +run unique/cluster/balance1.sim +run unique/cluster/balance2.sim +run unique/cluster/balance3.sim +run unique/cluster/cache.sim diff --git a/tests/script/unique/cluster/vgroup100.sim b/tests/script/unique/cluster/vgroup100.sim new file mode 100644 index 0000000000000000000000000000000000000000..656ed2ec44ebbb2d666ed2618e15d5ae34a5e525 --- /dev/null +++ b/tests/script/unique/cluster/vgroup100.sim @@ -0,0 +1,146 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 + +system sh/cfg.sh -n dnode1 -c maxTables -v 4 +system sh/cfg.sh -n dnode2 -c maxTables -v 4 +system sh/cfg.sh -n dnode3 -c maxTables -v 4 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 0 + +print ============================== step1 +system sh/exec.sh -n dnode1 -s start +sql connect + +print ============================== step2 +print ========= start dnode2 +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start +sql create dnode $hostname3 +system sh/exec.sh -n dnode3 -s start + +$maxNum = 102 +$maxNum = 12 + +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show mnodes +$dnode1Role = $data2_1 +$dnode2Role = $data2_2 +$dnode3Role = $data2_3 + +print $dnode1Role +print $dnode2Role +print $dnode3Role + +if $dnode1Role != master then + goto show2 +endi +if $dnode2Role != slave then + goto show2 +endi +if $dnode3Role != slave then + goto show2 +endi + +print ============================== step3 +$count = 2 +while $count < $maxNum + $db = d . $count + $tb = $db . .t + $tb2 = $db . .t2 + sql create database $db replica 3 cache 1 blocks 3 + sql create table $tb (ts timestamp, i int) + sql insert into $tb values(now, 1) + sql create table $tb2 as select count(*) from $tb interval(10s) + $count = $count + 1 + print insert into $tb values(now, 1) ==> finished +endw + +print ============================== step4 + +$count = 2 +while $count < $maxNum + $db = d . $count + $tb = $db . .t + sql select * from $tb + if $rows != 1 then + print select * from $tb + return -1 + endi + $count = $count + 1 + print select * from $tb ==> rows: $rows +endw + +print ============================== step5 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT + +print ============================== step6 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start + +print ============================== step7 + +$x = 0 +show7: + $x = $x + 1 + sleep 2000 + if $x == 50 then + return -1 + endi + +sql show mnodes -x show7 +$dnode1Role = $data2_1 +$dnode2Role = $data2_2 +$dnode3Role = $data2_3 +if $dnode1Role != master then + goto show7 +endi +if $dnode2Role != slave then + goto show7 +endi +if $dnode2Role != slave then + goto show7 +endi + +print ============================== step8 +$x = 0 +show8: + $x = $x + 1 + sleep 2000 + if $x == 20 then + return -1 + endi + +$count = 2 +while $count < $maxNum + $db = d . $count + $tb = $db . .t + sql select * from $tb + if $rows != 1 then + print select * from $tb + goto show8 + endi + $count = $count + 1 + print select * from $tb ==> rows: $rows +endw + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/clusterSimCase/client-01.sim b/tests/script/unique/clusterSimCase/client-01.sim new file mode 100644 index 0000000000000000000000000000000000000000..b35790d69ee3272caa83a28566b9d77be7d7b4e9 --- /dev/null +++ b/tests/script/unique/clusterSimCase/client-01.sim @@ -0,0 +1,69 @@ +# create database db1 +# create table tb () +# loop insert seq data +############################################################### +################ set script parameters ################ +$tblStart = 0 +$tblEnd = 10000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +$preBinary = ' . client-01- +############################################################### + +sql connect + +print ================ create db +$db = db +sql create database if not exists $db replica 2 +sql use $db + +print ================ create table $tb (ts timestamp, c1 int, c2 binary(16)) + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i +# print create table if not exists $tb ( ts timestamp , c1 int , c2 binary(16) ) + sql create table if not exists $tb ( ts timestamp , c1 int , c2 binary(16) ) + $i = $i + 1 +endw + +$totalRows = 0 +$rowsPerTbl = 0 +$ts = $tsStart +$rowsPerLoop = 160 + +$loop_cnt = 0 +loop_run: +print ================ client-01 start loop insert data ( loop_cnt: $loop_cnt ) +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + + $c2Binary = $preBinary . $i + $c2Binary = $c2Binary . ' + + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x , $c2Binary ) ( $ts + 2a , $x , $c2Binary ) ( $ts + 4a , $x , $c2Binary ) ( $ts + 6a , $x , $c2Binary ) ( $ts + 8a , $x , $c2Binary ) ( $ts + 10a , $x , $c2Binary ) ( $ts + 12a , $x , $c2Binary ) ( $ts + 14a , $x , $c2Binary ) ( $ts + 16a , $x , $c2Binary ) ( $ts + 18a , $x , $c2Binary ) ( $ts + 20a , $x , $c2Binary ) ( $ts + 22a , $x , $c2Binary ) ( $ts + 24a , $x , $c2Binary ) ( $ts + 26a , $x , $c2Binary ) ( $ts + 28a , $x , $c2Binary ) ( $ts + 30a , $x , $c2Binary ) ( $ts + 32a , $x , $c2Binary ) ( $ts + 34a , $x , $c2Binary ) ( $ts + 36a , $x , $c2Binary ) ( $ts + 38a , $x , $c2Binary ) + $x = $x + 20 + $ts = $ts + 40a + endw + if $i == $tblStart then + $rowsPerTbl = $rowsPerTbl + $x + endi + + $totalRows = $totalRows + $x + $i = $i + 1 + +endw + +sql select count(*) from $tb +print data00 $data00 rowsPerTbl $rowsPerTbl +if $data00 != $rowsPerTbl then + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + print ************ client-01 insert data into $tb error ***** ***** + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + return -1 +endi + +$loop_cnt = $loop_cnt + 1 +goto loop_run diff --git a/tests/script/unique/clusterSimCase/client-02.sim b/tests/script/unique/clusterSimCase/client-02.sim new file mode 100644 index 0000000000000000000000000000000000000000..30a2ceb08942140b3b03dec7a1285b30f6fd99ac --- /dev/null +++ b/tests/script/unique/clusterSimCase/client-02.sim @@ -0,0 +1,70 @@ +# create database db1 +# create table tb () +# loop insert disorder data +############################################################### +################ set script parameters ################ +$tblStart = 0 +$tblEnd = 10000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +$preBinary = ' . client-02- +############################################################### + +sql connect + +print ================ create db +$db = db +sql create database if not exists $db replica 2 +sql use $db + +print ================ create table $tb (ts timestamp, c1 int, c2 binary(16)) + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i +# print create table if not exists $tb ( ts timestamp , c1 int , c2 binary(16) ) + sql create table if not exists $tb ( ts timestamp , c1 int , c2 binary(16) ) + $i = $i + 1 +endw + +$totalRows = 0 +$rowsPerTbl = 0 +$ts = $tsStart +$rowsPerLoop = 160 + +$loop_cnt = 0 +loop_run: +print ================ client-02 start loop insert data ( loop_cnt: $loop_cnt ) +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + + $c2Binary = $preBinary . $i + $c2Binary = $c2Binary . ' + + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x , $c2Binary ) ( $ts + 2a , $x , $c2Binary ) ( $ts + 4a , $x , $c2Binary ) ( $ts + 6a , $x , $c2Binary ) ( $ts + 8a , $x , $c2Binary ) ( $ts + 10a , $x , $c2Binary ) ( $ts + 12a , $x , $c2Binary ) ( $ts + 14a , $x , $c2Binary ) ( $ts + 16a , $x , $c2Binary ) ( $ts + 18a , $x , $c2Binary ) ( $ts + 20a , $x , $c2Binary ) ( $ts + 22a , $x , $c2Binary ) ( $ts + 24a , $x , $c2Binary ) ( $ts + 26a , $x , $c2Binary ) ( $ts + 28a , $x , $c2Binary ) ( $ts + 30a , $x , $c2Binary ) ( $ts + 32a , $x , $c2Binary ) ( $ts + 34a , $x , $c2Binary ) ( $ts + 36a , $x , $c2Binary ) ( $ts + 38a , $x , $c2Binary ) + sql insert into $tb values ( $ts + 1a , $x , $c2Binary ) ( $ts + 3a , $x , $c2Binary ) ( $ts + 5a , $x , $c2Binary ) ( $ts + 7a , $x , $c2Binary ) ( $ts + 9a , $x , $c2Binary ) ( $ts + 11a , $x , $c2Binary ) ( $ts + 13a , $x , $c2Binary ) ( $ts + 15a , $x , $c2Binary ) ( $ts + 17a , $x , $c2Binary ) ( $ts + 19a , $x , $c2Binary ) ( $ts + 21a , $x , $c2Binary ) ( $ts + 23a , $x , $c2Binary ) ( $ts + 25a , $x , $c2Binary ) ( $ts + 27a , $x , $c2Binary ) ( $ts + 29a , $x , $c2Binary ) ( $ts + 31a , $x , $c2Binary ) ( $ts + 33a , $x , $c2Binary ) ( $ts + 35a , $x , $c2Binary ) ( $ts + 37a , $x , $c2Binary ) ( $ts + 39a , $x , $c2Binary ) + $x = $x + 40 + $ts = $ts + 40a + endw + if $i == $tblStart then + $rowsPerTbl = $rowsPerTbl + $x + endi + + $totalRows = $totalRows + $x + $i = $i + 1 + +endw + +sql select count(*) from $tb +print data00 $data00 rowsPerTbl $rowsPerTbl +if $data00 != $rowsPerTbl then + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + print ************ client-02 insert data into $tb error ***** ***** + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + return -1 +endi + +$loop_cnt = $loop_cnt + 1 +goto loop_run diff --git a/tests/script/unique/clusterSimCase/client-03.sim b/tests/script/unique/clusterSimCase/client-03.sim new file mode 100644 index 0000000000000000000000000000000000000000..78a25e26a5344bbfe3434dec61643bf5a9c26f19 --- /dev/null +++ b/tests/script/unique/clusterSimCase/client-03.sim @@ -0,0 +1,83 @@ +# create database db1 +# create table stb () +# loop dynamic create sub table and insert disorder data +############################################################### +################ set script parameters ################ +$tblStart = 0 +$tblEnd = 10000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +$preBinary = ' . client-03- +############################################################### + +sql connect + +print ================ create db and super-table +$db = db +$stb = stb +sql create database if not exists $db replica 2 +sql use $db +sql create table if not exists $stb ( ts timestamp , c1 int , c2 binary(16) ) tags ( t1 int , t2 binary(16) ) + +#print ================ create table $tb (ts timestamp, c1 int, c2 binary(16)) +#$i = $tblStart +#while $i < $tblEnd +# $tb = tb . $i +## print create table if not exists $tb ( ts timestamp , c1 int , c2 binary(16) ) +# sql create table if not exists $tb ( ts timestamp , c1 int , c2 binary(16) ) +# $i = $i + 1 +#endw + +$totalRows = 0 +$rowsPerTbl = 0 +$ts = $tsStart +$rowsPerLoop = 160 + +$loop_cnt = 0 +loop_run: +print ================ client-03 start loop insert data ( loop_cnt: $loop_cnt ) +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + + $t2Binary = $preBinary . $i + $t2Binary = $t2Binary . ' + + $c2Binary = $preBinary . $i + $c2Binary = $c2Binary . ' + + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb using $stb tags ( $i , $t2Binary ) values ( $ts + 0a , $x , $c2Binary ) ( $ts + 2a , $x , $c2Binary ) ( $ts + 4a , $x , $c2Binary ) ( $ts + 6a , $x , $c2Binary ) ( $ts + 8a , $x , $c2Binary ) ( $ts + 10a , $x , $c2Binary ) ( $ts + 12a , $x , $c2Binary ) ( $ts + 14a , $x , $c2Binary ) ( $ts + 16a , $x , $c2Binary ) ( $ts + 18a , $x , $c2Binary ) ( $ts + 20a , $x , $c2Binary ) ( $ts + 22a , $x , $c2Binary ) ( $ts + 24a , $x , $c2Binary ) ( $ts + 26a , $x , $c2Binary ) ( $ts + 28a , $x , $c2Binary ) ( $ts + 30a , $x , $c2Binary ) ( $ts + 32a , $x , $c2Binary ) ( $ts + 34a , $x , $c2Binary ) ( $ts + 36a , $x , $c2Binary ) ( $ts + 38a , $x , $c2Binary ) + sql insert into $tb using $stb tags ( $i , $t2Binary ) values ( $ts + 1a , $x , $c2Binary ) ( $ts + 3a , $x , $c2Binary ) ( $ts + 5a , $x , $c2Binary ) ( $ts + 7a , $x , $c2Binary ) ( $ts + 9a , $x , $c2Binary ) ( $ts + 11a , $x , $c2Binary ) ( $ts + 13a , $x , $c2Binary ) ( $ts + 15a , $x , $c2Binary ) ( $ts + 17a , $x , $c2Binary ) ( $ts + 19a , $x , $c2Binary ) ( $ts + 21a , $x , $c2Binary ) ( $ts + 23a , $x , $c2Binary ) ( $ts + 25a , $x , $c2Binary ) ( $ts + 27a , $x , $c2Binary ) ( $ts + 29a , $x , $c2Binary ) ( $ts + 31a , $x , $c2Binary ) ( $ts + 33a , $x , $c2Binary ) ( $ts + 35a , $x , $c2Binary ) ( $ts + 37a , $x , $c2Binary ) ( $ts + 39a , $x , $c2Binary ) + $x = $x + 40 + $ts = $ts + 40a + endw + if $i == $tblStart then + $rowsPerTbl = $rowsPerTbl + $x + endi + + $totalRows = $totalRows + $x + $i = $i + 1 + +endw + +sql select count(*) from $tb +print data00 $data00 rowsPerTbl $rowsPerTbl +if $data00 != $rowsPerTbl then + + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + print ****** client-3 insert data into $tb error *** + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + return -1 +endi + +sql select count(*) from $stb +print data00 $data00 totalRows $totalRows +if $data00 != $totalRows then + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + print ***** client-3 insert data into $stbl error ******** + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + return -1 +endi +$loop_cnt = $loop_cnt + 1 +goto loop_run diff --git a/tests/script/unique/clusterSimCase/client-04.sim b/tests/script/unique/clusterSimCase/client-04.sim new file mode 100644 index 0000000000000000000000000000000000000000..5248e9d7bb9b339cdcd157c495b9bc8f73705d89 --- /dev/null +++ b/tests/script/unique/clusterSimCase/client-04.sim @@ -0,0 +1,81 @@ +# create database db1 +# create table tb () +# loop insert disorder data, drop database, sleep , +############################################################### +################ set script parameters ################ +$tblStart = 0 +$tblEnd = 10000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +$preBinary = ' . client-04- +############################################################### + +$totalRows = 0 + +sql connect + +init_lable: +print ================ create db +$db = db +sql create database if not exists $db replica 2 +sql use $db + +print ================ create table $tb (ts timestamp, c1 int, c2 binary(16)) + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i +# print create table if not exists $tb ( ts timestamp , c1 int , c2 binary(16) ) + sql create table if not exists $tb ( ts timestamp , c1 int , c2 binary(16) ) + $i = $i + 1 +endw + +$rowsPerTbl = 0 +$ts = $tsStart +$rowsPerLoop = 160 + +$loopCnt = 0 + +loop_run: +print ================ client-04 start loop insert data ( loopCnt: $loopCnt ) +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + + $c2Binary = $preBinary . $i + $c2Binary = $c2Binary . ' + + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x , $c2Binary ) ( $ts + 2a , $x , $c2Binary ) ( $ts + 4a , $x , $c2Binary ) ( $ts + 6a , $x , $c2Binary ) ( $ts + 8a , $x , $c2Binary ) ( $ts + 10a , $x , $c2Binary ) ( $ts + 12a , $x , $c2Binary ) ( $ts + 14a , $x , $c2Binary ) ( $ts + 16a , $x , $c2Binary ) ( $ts + 18a , $x , $c2Binary ) ( $ts + 20a , $x , $c2Binary ) ( $ts + 22a , $x , $c2Binary ) ( $ts + 24a , $x , $c2Binary ) ( $ts + 26a , $x , $c2Binary ) ( $ts + 28a , $x , $c2Binary ) ( $ts + 30a , $x , $c2Binary ) ( $ts + 32a , $x , $c2Binary ) ( $ts + 34a , $x , $c2Binary ) ( $ts + 36a , $x , $c2Binary ) ( $ts + 38a , $x , $c2Binary ) + sql insert into $tb values ( $ts + 1a , $x , $c2Binary ) ( $ts + 3a , $x , $c2Binary ) ( $ts + 5a , $x , $c2Binary ) ( $ts + 7a , $x , $c2Binary ) ( $ts + 9a , $x , $c2Binary ) ( $ts + 11a , $x , $c2Binary ) ( $ts + 13a , $x , $c2Binary ) ( $ts + 15a , $x , $c2Binary ) ( $ts + 17a , $x , $c2Binary ) ( $ts + 19a , $x , $c2Binary ) ( $ts + 21a , $x , $c2Binary ) ( $ts + 23a , $x , $c2Binary ) ( $ts + 25a , $x , $c2Binary ) ( $ts + 27a , $x , $c2Binary ) ( $ts + 29a , $x , $c2Binary ) ( $ts + 31a , $x , $c2Binary ) ( $ts + 33a , $x , $c2Binary ) ( $ts + 35a , $x , $c2Binary ) ( $ts + 37a , $x , $c2Binary ) ( $ts + 39a , $x , $c2Binary ) + $x = $x + 40 + $ts = $ts + 40a + endw + if $i == $tblStart then + $rowsPerTbl = $rowsPerTbl + $x + endi + + $totalRows = $totalRows + $x + $i = $i + 1 + +endw + +sql select count(*) from $tb +print data00 $data00 rowsPerTbl $rowsPerTbl +if $data00 != $rowsPerTbl then + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + print ************ client-04 insert data into $tb error ***** ***** + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + return -1 +endi + +$loopCnt = $loopCnt + 1 + +if $loopCnt > 100 then + sql drop database if exists $db + sleep 20000 + $totalRows = 0 + goto init_lable +endi + +goto loop_run diff --git a/tests/script/unique/clusterSimCase/client-05.sim b/tests/script/unique/clusterSimCase/client-05.sim new file mode 100644 index 0000000000000000000000000000000000000000..a2deaba9b2943b7e3720ae6c6f9b9001d5e3b743 --- /dev/null +++ b/tests/script/unique/clusterSimCase/client-05.sim @@ -0,0 +1,86 @@ +# create database db1 +# loop create table , insert disorder data, drop table, sleep , +############################################################### +################ set script parameters ################ +$tblStart = 0 +$tblEnd = 10000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +$preBinary = ' . client-05- +############################################################### + +$totalRows = 0 + +sql connect + +print ================ create db +$db = db +sql create database if not exists $db replica 2 +sql use $db + +init_lable: +print ================ create table $tb (ts timestamp, c1 int, c2 binary(16)) + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i +# print create table if not exists $tb ( ts timestamp , c1 int , c2 binary(16) ) + sql create table if not exists $tb ( ts timestamp , c1 int , c2 binary(16) ) + $i = $i + 1 +endw + +$rowsPerTbl = 0 +$ts = $tsStart +$rowsPerLoop = 160 + +$loopCnt = 0 + +loop_run: +print ================ client-05 start loop insert data ( loopCnt: $loopCnt ) +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + + $c2Binary = $preBinary . $i + $c2Binary = $c2Binary . ' + + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x , $c2Binary ) ( $ts + 2a , $x , $c2Binary ) ( $ts + 4a , $x , $c2Binary ) ( $ts + 6a , $x , $c2Binary ) ( $ts + 8a , $x , $c2Binary ) ( $ts + 10a , $x , $c2Binary ) ( $ts + 12a , $x , $c2Binary ) ( $ts + 14a , $x , $c2Binary ) ( $ts + 16a , $x , $c2Binary ) ( $ts + 18a , $x , $c2Binary ) ( $ts + 20a , $x , $c2Binary ) ( $ts + 22a , $x , $c2Binary ) ( $ts + 24a , $x , $c2Binary ) ( $ts + 26a , $x , $c2Binary ) ( $ts + 28a , $x , $c2Binary ) ( $ts + 30a , $x , $c2Binary ) ( $ts + 32a , $x , $c2Binary ) ( $ts + 34a , $x , $c2Binary ) ( $ts + 36a , $x , $c2Binary ) ( $ts + 38a , $x , $c2Binary ) + sql insert into $tb values ( $ts + 1a , $x , $c2Binary ) ( $ts + 3a , $x , $c2Binary ) ( $ts + 5a , $x , $c2Binary ) ( $ts + 7a , $x , $c2Binary ) ( $ts + 9a , $x , $c2Binary ) ( $ts + 11a , $x , $c2Binary ) ( $ts + 13a , $x , $c2Binary ) ( $ts + 15a , $x , $c2Binary ) ( $ts + 17a , $x , $c2Binary ) ( $ts + 19a , $x , $c2Binary ) ( $ts + 21a , $x , $c2Binary ) ( $ts + 23a , $x , $c2Binary ) ( $ts + 25a , $x , $c2Binary ) ( $ts + 27a , $x , $c2Binary ) ( $ts + 29a , $x , $c2Binary ) ( $ts + 31a , $x , $c2Binary ) ( $ts + 33a , $x , $c2Binary ) ( $ts + 35a , $x , $c2Binary ) ( $ts + 37a , $x , $c2Binary ) ( $ts + 39a , $x , $c2Binary ) + $x = $x + 40 + $ts = $ts + 40a + endw + if $i == $tblStart then + $rowsPerTbl = $rowsPerTbl + $x + endi + + $totalRows = $totalRows + $x + $i = $i + 1 + +endw + +sql select count(*) from $tb +print data00 $data00 rowsPerTbl $rowsPerTbl +if $data00 != $rowsPerTbl then + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + print ************ client-05 insert data into $tb error ***** ***** + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + return -1 +endi + +$loopCnt = $loopCnt + 1 + +if $loopCnt > 100 then + + $i = $tblStart + while $i < $tblEnd + $tb = tb . $i + sql drop table if exists $tb + $i = $i + 1 + $totalRows = $totalRows - $rowsPerTbl + endw + sleep 20000 + goto init_lable +endi + +goto loop_run diff --git a/tests/script/unique/clusterSimCase/client-06.sim b/tests/script/unique/clusterSimCase/client-06.sim new file mode 100644 index 0000000000000000000000000000000000000000..209b615e64a2742cac732bd22d0e25f7a8f5db4e --- /dev/null +++ b/tests/script/unique/clusterSimCase/client-06.sim @@ -0,0 +1,95 @@ +# create database db1 +# create table tb () +# loop insert disorder data, drop some tables and create new tables, sleep , +############################################################### +################ set script parameters ################ +$tblStart = 0 +$tblEnd = 10000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +$preBinary = ' . client-06- +$numPerUpdateTbl = 2000 +############################################################### +$totalRows = 0 +$dropTblStart = $tblStart +$dropTblEnd = $dropTblStart + +sql connect + +print ================ create db +$db = db +sql create database if not exists $db replica 2 +sql use $db + +init_lable: +print ================ create table [ from $tblStart to $tblEnd ] (ts timestamp, c1 int, c2 binary(16)) + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i +# print create table if not exists $tb ( ts timestamp , c1 int , c2 binary(16) ) + sql create table if not exists $tb ( ts timestamp , c1 int , c2 binary(16) ) + $i = $i + 1 +endw + +$dropTblStart = $dropTblEnd +$dropTblEnd = $dropTblStart + $numPerUpdateTbl + +$tblStart = $tblEnd +$tblEnd = $tblEnd + $numPerUpdateTbl + +$rowsPerTbl = 0 +$ts = $tsStart +$rowsPerLoop = 160 + +$loopCnt = 0 + +loop_run: +print ================ client-06 start loop insert data from $dropTblStart to $tblStart ( loopCnt: $loopCnt ) +$i = $dropTblStart +while $i < $tblStart + $tb = tb . $i + + $c2Binary = $preBinary . $i + $c2Binary = $c2Binary . ' + + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x , $c2Binary ) ( $ts + 2a , $x , $c2Binary ) ( $ts + 4a , $x , $c2Binary ) ( $ts + 6a , $x , $c2Binary ) ( $ts + 8a , $x , $c2Binary ) ( $ts + 10a , $x , $c2Binary ) ( $ts + 12a , $x , $c2Binary ) ( $ts + 14a , $x , $c2Binary ) ( $ts + 16a , $x , $c2Binary ) ( $ts + 18a , $x , $c2Binary ) ( $ts + 20a , $x , $c2Binary ) ( $ts + 22a , $x , $c2Binary ) ( $ts + 24a , $x , $c2Binary ) ( $ts + 26a , $x , $c2Binary ) ( $ts + 28a , $x , $c2Binary ) ( $ts + 30a , $x , $c2Binary ) ( $ts + 32a , $x , $c2Binary ) ( $ts + 34a , $x , $c2Binary ) ( $ts + 36a , $x , $c2Binary ) ( $ts + 38a , $x , $c2Binary ) + sql insert into $tb values ( $ts + 1a , $x , $c2Binary ) ( $ts + 3a , $x , $c2Binary ) ( $ts + 5a , $x , $c2Binary ) ( $ts + 7a , $x , $c2Binary ) ( $ts + 9a , $x , $c2Binary ) ( $ts + 11a , $x , $c2Binary ) ( $ts + 13a , $x , $c2Binary ) ( $ts + 15a , $x , $c2Binary ) ( $ts + 17a , $x , $c2Binary ) ( $ts + 19a , $x , $c2Binary ) ( $ts + 21a , $x , $c2Binary ) ( $ts + 23a , $x , $c2Binary ) ( $ts + 25a , $x , $c2Binary ) ( $ts + 27a , $x , $c2Binary ) ( $ts + 29a , $x , $c2Binary ) ( $ts + 31a , $x , $c2Binary ) ( $ts + 33a , $x , $c2Binary ) ( $ts + 35a , $x , $c2Binary ) ( $ts + 37a , $x , $c2Binary ) ( $ts + 39a , $x , $c2Binary ) + $x = $x + 40 + $ts = $ts + 40a + endw + if $i == $dropTblStart then + $rowsPerTbl = $rowsPerTbl + $x + endi + + $totalRows = $totalRows + $x + $i = $i + 1 + +endw + +sql select count(*) from $tb +print data00 $data00 rowsPerTbl $rowsPerTbl +if $data00 != $rowsPerTbl then + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + print ************ client-06 insert data into $tb error ***** ***** + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + return -1 +endi + +$loopCnt = $loopCnt + 1 + +if $loopCnt > 2 then + print ================ client-06 drop table from $dropTblStart to $dropTblEnd + $i = $dropTblStart + while $i < $dropTblEnd + $tb = tb . $i + sql drop table if exists $tb + $i = $i + 1 + $totalRows = $totalRows - $rowsPerTbl + endw + sleep 10000 + goto init_lable +endi + +goto loop_run diff --git a/tests/script/unique/clusterSimCase/client-07.sim b/tests/script/unique/clusterSimCase/client-07.sim new file mode 100644 index 0000000000000000000000000000000000000000..3bf358520511dc04cc33c5953f91bee237ccd576 --- /dev/null +++ b/tests/script/unique/clusterSimCase/client-07.sim @@ -0,0 +1,101 @@ +# create database db1 +# loop create table , insert disorder data, drop table, sleep , +############################################################### +################ set script parameters ################ +$tblStart = 0 +$tblEnd = 10000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +$preBinary = ' . client-07- +############################################################### +$alterCnt = 0 + +$columnA = c . $alterCnt +$columnB = d . $alterCnt + +$totalRows = 0 + +sql connect + +print ================ create db +$db = db +sql create database if not exists $db replica 2 +sql use $db + +$rowsPerTbl = 0 +$ts = $tsStart + +print ================ create table $tb (ts timestamp, $columnA int, $columnB binary(16)) + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i +# print create table if not exists $tb ( ts timestamp , c1 int , c2 binary(16) ) + sql create table if not exists $tb ( ts timestamp , $columnA int , $columnB binary(16) ) + $i = $i + 1 +endw + +$rowsPerLoop = 160 + +$loopCnt = 0 +$alterStep = 0 + +loop_run: +print ================ client-07 start loop insert data ( loopCnt: $loopCnt ) +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + + $c2Binary = $preBinary . $i + $c2Binary = $c2Binary . ' + + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x , $c2Binary ) ( $ts + 2a , $x , $c2Binary ) ( $ts + 4a , $x , $c2Binary ) ( $ts + 6a , $x , $c2Binary ) ( $ts + 8a , $x , $c2Binary ) ( $ts + 10a , $x , $c2Binary ) ( $ts + 12a , $x , $c2Binary ) ( $ts + 14a , $x , $c2Binary ) ( $ts + 16a , $x , $c2Binary ) ( $ts + 18a , $x , $c2Binary ) ( $ts + 20a , $x , $c2Binary ) ( $ts + 22a , $x , $c2Binary ) ( $ts + 24a , $x , $c2Binary ) ( $ts + 26a , $x , $c2Binary ) ( $ts + 28a , $x , $c2Binary ) ( $ts + 30a , $x , $c2Binary ) ( $ts + 32a , $x , $c2Binary ) ( $ts + 34a , $x , $c2Binary ) ( $ts + 36a , $x , $c2Binary ) ( $ts + 38a , $x , $c2Binary ) + sql insert into $tb values ( $ts + 1a , $x , $c2Binary ) ( $ts + 3a , $x , $c2Binary ) ( $ts + 5a , $x , $c2Binary ) ( $ts + 7a , $x , $c2Binary ) ( $ts + 9a , $x , $c2Binary ) ( $ts + 11a , $x , $c2Binary ) ( $ts + 13a , $x , $c2Binary ) ( $ts + 15a , $x , $c2Binary ) ( $ts + 17a , $x , $c2Binary ) ( $ts + 19a , $x , $c2Binary ) ( $ts + 21a , $x , $c2Binary ) ( $ts + 23a , $x , $c2Binary ) ( $ts + 25a , $x , $c2Binary ) ( $ts + 27a , $x , $c2Binary ) ( $ts + 29a , $x , $c2Binary ) ( $ts + 31a , $x , $c2Binary ) ( $ts + 33a , $x , $c2Binary ) ( $ts + 35a , $x , $c2Binary ) ( $ts + 37a , $x , $c2Binary ) ( $ts + 39a , $x , $c2Binary ) + $x = $x + 40 + $ts = $ts + 40a + endw + if $i == $tblStart then + $rowsPerTbl = $rowsPerTbl + $x + endi + + $totalRows = $totalRows + $x + $i = $i + 1 + +endw + +sql select count(*) from $tb +print data00 $data00 rowsPerTbl $rowsPerTbl +if $data00 != $rowsPerTbl then + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + print ************ client-07 insert data into $tb error ***** ***** + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + return -1 +endi + +$loopCnt = $loopCnt + 1 + +if $alterStep > 2 then + $alterStep = 0 + + $alterCnt = $alterCnt + 1 + $i = $tblStart + while $i < $tblEnd + $tb = tb . $i + $newColumnA = c . $alterCnt + $newcolumnB = d . $alterCnt + + sql alter table $tb add column $newColumnA double + sql alter table $tb add column $newcolumnB binary( 16 ) + sql alter table $tb drop column $columnA + sql alter table $tb drop column $columnB + $i = $i + 1 + endw + $columnA = $newColumnA + $columnB = $newcolumnB + + sleep 10000 + goto loop_run +endi + +goto loop_run diff --git a/tests/script/unique/clusterSimCase/client-08.sim b/tests/script/unique/clusterSimCase/client-08.sim new file mode 100644 index 0000000000000000000000000000000000000000..d9d64834cb36693328ce721dab449cdacc2f026a --- /dev/null +++ b/tests/script/unique/clusterSimCase/client-08.sim @@ -0,0 +1,95 @@ +# create database db1 +# create table tb () +# loop insert disorder data, drop some tables and create new tables, sleep , +############################################################### +################ set script parameters ################ +$tblStart = 0 +$tblEnd = 10000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +$preBinary = ' . client-08- +$numPerUpdateTbl = 2000 +############################################################### +$totalRows = 0 +$dropTblStart = $tblStart +$dropTblEnd = $dropTblStart + +sql connect + +print ================ create db +$db = db +sql create database if not exists $db replica 2 +sql use $db + +init_lable: +print ================ create table [ from $tblStart to $tblEnd ] (ts timestamp, c1 int, c2 binary(16)) + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i +# print create table if not exists $tb ( ts timestamp , c1 int , c2 binary(16) ) + sql create table if not exists $tb ( ts timestamp , c1 int , c2 binary(16) ) + $i = $i + 1 +endw + +$dropTblStart = $dropTblEnd +$dropTblEnd = $dropTblStart + $numPerUpdateTbl + +$tblStart = $tblEnd +$tblEnd = $tblEnd + $numPerUpdateTbl + +$rowsPerTbl = 0 +$ts = $tsStart +$rowsPerLoop = 40 + +$loopCnt = 0 + +loop_run: +print ================ client-08 start loop insert data from $dropTblStart to $tblStart ( loopCnt: $loopCnt ) +$i = $dropTblStart +while $i < $tblStart + $tb = tb . $i + + $c2Binary = $preBinary . $i + $c2Binary = $c2Binary . ' + + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x , $c2Binary ) ( $ts + 2a , $x , $c2Binary ) ( $ts + 4a , $x , $c2Binary ) ( $ts + 6a , $x , $c2Binary ) ( $ts + 8a , $x , $c2Binary ) ( $ts + 10a , $x , $c2Binary ) ( $ts + 12a , $x , $c2Binary ) ( $ts + 14a , $x , $c2Binary ) ( $ts + 16a , $x , $c2Binary ) ( $ts + 18a , $x , $c2Binary ) ( $ts + 20a , $x , $c2Binary ) ( $ts + 22a , $x , $c2Binary ) ( $ts + 24a , $x , $c2Binary ) ( $ts + 26a , $x , $c2Binary ) ( $ts + 28a , $x , $c2Binary ) ( $ts + 30a , $x , $c2Binary ) ( $ts + 32a , $x , $c2Binary ) ( $ts + 34a , $x , $c2Binary ) ( $ts + 36a , $x , $c2Binary ) ( $ts + 38a , $x , $c2Binary ) + sql insert into $tb values ( $ts + 1a , $x , $c2Binary ) ( $ts + 3a , $x , $c2Binary ) ( $ts + 5a , $x , $c2Binary ) ( $ts + 7a , $x , $c2Binary ) ( $ts + 9a , $x , $c2Binary ) ( $ts + 11a , $x , $c2Binary ) ( $ts + 13a , $x , $c2Binary ) ( $ts + 15a , $x , $c2Binary ) ( $ts + 17a , $x , $c2Binary ) ( $ts + 19a , $x , $c2Binary ) ( $ts + 21a , $x , $c2Binary ) ( $ts + 23a , $x , $c2Binary ) ( $ts + 25a , $x , $c2Binary ) ( $ts + 27a , $x , $c2Binary ) ( $ts + 29a , $x , $c2Binary ) ( $ts + 31a , $x , $c2Binary ) ( $ts + 33a , $x , $c2Binary ) ( $ts + 35a , $x , $c2Binary ) ( $ts + 37a , $x , $c2Binary ) ( $ts + 39a , $x , $c2Binary ) + $x = $x + 40 + $ts = $ts + 40a + endw + if $i == $dropTblStart then + $rowsPerTbl = $rowsPerTbl + $x + endi + + $totalRows = $totalRows + $x + $i = $i + 1 + +endw + +sql select count(*) from $tb +print data00 $data00 rowsPerTbl $rowsPerTbl tb: $tb +if $data00 != $rowsPerTbl then + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + print ************ client-08 insert data into $tb error ***** ***** + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + return -1 +endi + +$loopCnt = $loopCnt + 1 + +#if $loopCnt > 3 then + print ================ client-08 drop table from $dropTblStart to $dropTblEnd + $i = $dropTblStart + while $i < $dropTblEnd + $tb = tb . $i + sql drop table if exists $tb + $i = $i + 1 + $totalRows = $totalRows - $rowsPerTbl + endw + sleep 10000 + goto init_lable +#endi + +goto loop_run diff --git a/tests/script/unique/clusterSimCase/cluster_main.sim b/tests/script/unique/clusterSimCase/cluster_main.sim new file mode 100644 index 0000000000000000000000000000000000000000..274ce85974bb2238bae60e6ffa9723760ae1c394 --- /dev/null +++ b/tests/script/unique/clusterSimCase/cluster_main.sim @@ -0,0 +1,248 @@ +# scp -r root@114.116.252.220:/home/ubuntu/clusterSimCase unique/. + +#taos> show dnodes; +# id | end_point | vnodes | cores | status | role | create_time | +#================================================================================================================== +# 1 | ubuntu-OptiPlex-7060:7100 | 0 | 12 | ready | mnode | 2020-07-22 06:25:31.677 | +# 2 | ubuntu-OptiPlex-7060:7200 | 4 | 12 | ready | vnode | 2020-07-22 06:25:34.795 | +# 3 | ubuntu-OptiPlex-7060:7300 | 4 | 12 | ready | vnode | 2020-07-22 06:25:34.803 | +#Query OK, 3 row(s) in set (0.002448s) +#taos> show vgroups; +# vgId | tables | status | onlineVnodes | dnode | vstatus | dnode | vstatus | +#====================================================================================================== +# 2 | 1024 | ready | 2 | 3 | master | 2 | slave | +# 3 | 1024 | ready | 2 | 3 | master | 2 | slave | +# 4 | 1024 | ready | 2 | 3 | master | 2 | slave | +# 5 | 718 | ready | 2 | 3 | master | 2 | slave | +#Query OK, 4 row(s) in set (0.002749s) +# +#taos> show mnodes +# -> ; +# id | end_point | role | create_time | +#===================================================================================== +# 1 | ubuntu-OptiPlex-7060:7100 | master | 2020-07-22 06:25:31.677 | +#Query OK, 1 row(s) in set (0.002126s) + + +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode3 -c walLevel -v 1 +system sh/cfg.sh -n dnode4 -c walLevel -v 1 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 256 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 256 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 256 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 256 + +#system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +#system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +#system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +#system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 + +#system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 256 +#system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 256 +#system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 256 +#system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 256 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 5000 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 5000 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 5000 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 5000 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator and dnode1 +system sh/exec_tarbitrator.sh -s start +system sh/exec.sh -n dnode1 -s start + +print ============== step2: start dnode2/dnode3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sleep 1000 +sql connect + +print ============== step1: add dnode2/dnode3 into cluster +sql create dnode $hostname2 +sql create dnode $hostname3 +sleep 2000 +sleep 2000 +print ============== step3: start back client-01.sim +#run_back unique/clusterSimCase/client-01.sim +#run_back unique/clusterSimCase/client-02.sim +#run_back unique/clusterSimCase/client-03.sim +#run_back unique/clusterSimCase/client-04.sim +#run_back unique/clusterSimCase/client-05.sim +#run_back unique/clusterSimCase/client-06.sim +#run_back unique/clusterSimCase/client-07.sim +run_back unique/clusterSimCase/client-08.sim +#run_back unique/clusterSimCase/client-01.sim +#run_back unique/clusterSimCase/client-01.sim +sleep 20000 + +$db = db +sql use $db + +$loop_cnt = 0 +loop_cluster_do: +print **** **** **** START loop cluster do (loop_cnt: $loop_cnt )**** **** **** **** + +print ============== step4: stop dnode3 +system sh/exec.sh -n dnode3 -s stop -x SIGINT + +$checkCnt = 0 +wait_vgroup_chang_0: +$checkCnt = $checkCnt + 1 +if $loopCnt == 10 then + return -1 +endi +print show vgroups +sql show vgroups +#if $rows != 4 then +# print rows: $rows +# sleep 2000 +# goto wait_vgroup_chang_0 +#endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$vg2Dnode3Status = $data5_2 +$vg2Dnode2Status = $data7_2 + +if $vg2Dnode3Status != offline then + sleep 2000 + goto wait_vgroup_chang_0 +endi +if $vg2Dnode2Status != master then + sleep 2000 + goto wait_vgroup_chang_0 +endi + + +sleep 2000 +print ============== step3: restart dnode3 +system sh/exec.sh -n dnode3 -s start + +$checkCnt = 0 +wait_vgroup_chang_1: +$checkCnt = $checkCnt + 1 +if $loopCnt == 10 then + return -1 +endi +print show vgroups +sql show vgroups +#if $rows != 4 then +# print rows: $rows +# sleep 2000 +# goto wait_vgroup_chang_1 +#endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$vg2Dnode3Status = $data5_2 +$vg2Dnode2Status = $data7_2 + +if $vg2Dnode3Status != slave then + sleep 2000 + goto wait_vgroup_chang_1 +endi +if $vg2Dnode2Status != master then + sleep 2000 + goto wait_vgroup_chang_1 +endi + +sleep 2000 +print ============== step4: stop dnode2 +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +$checkCnt = 0 +wait_vgroup_chang_2: +$checkCnt = $checkCnt + 1 +if $loopCnt == 10 then + return -1 +endi +print show vgroups +sql show vgroups +#if $rows != 4 then +# print rows: $rows +# sleep 2000 +# goto wait_vgroup_chang_2 +#endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$vg2Dnode3Status = $data5_2 +$vg2Dnode2Status = $data7_2 + +if $vg2Dnode3Status != master then + sleep 2000 + goto wait_vgroup_chang_2 +endi +if $vg2Dnode2Status != offline then + sleep 2000 + goto wait_vgroup_chang_2 +endi + + +sleep 2000 +print ============== step5: restart dnode2 +system sh/exec.sh -n dnode2 -s start + +$checkCnt = 0 +wait_vgroup_chang_3: +$checkCnt = $checkCnt + 1 +if $loopCnt == 10 then + return -1 +endi +print show vgroups +sql show vgroups +#if $rows != 4 then +# print rows: $rows +# sleep 2000 +# goto wait_vgroup_chang_3 +#endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +$vg2Dnode3Status = $data5_2 +$vg2Dnode2Status = $data7_2 + +if $vg2Dnode2Status != slave then + sleep 2000 + goto wait_vgroup_chang_3 +endi +if $vg2Dnode3Status != master then + sleep 2000 + goto wait_vgroup_chang_3 +endi + +sleep 2000 +print **** **** **** (loop_cnt: $loop_cnt ) end, continue...... **** **** **** **** +$loop_cnt = $loop_cnt + 1 +if $loop_cnt == 50 then + return 0 +endi +goto loop_cluster_do diff --git a/tests/script/unique/column/replica3.sim b/tests/script/unique/column/replica3.sim new file mode 100644 index 0000000000000000000000000000000000000000..2d6c194ef806022f7ff5a81d9f906365c49cd197 --- /dev/null +++ b/tests/script/unique/column/replica3.sim @@ -0,0 +1,43 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/cfg.sh -n dnode2 -c wallevel -v 2 +system sh/cfg.sh -n dnode3 -c wallevel -v 2 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 + +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode $hostname2 +sql create dnode $hostname3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start + +sql create database db replica 3 +sql use db +sql create table db.mt (ts timestamp, f1 float, f2 float, f3 float, f4 float, f5 float, f6 float, f7 float, f8 float, f9 float, f10 float) tags (t1 int, t2 int) +sql create table db.tb1 using db.mt tags(1, 2) +sleep 3001 + +$x = 1000 +while $x < 1010 + sql insert into tb1 values (now+1s , $x , $x , $x , $x , $x , $x , $x , $x , $x , $x ) + $x = $x + 1 +endw + +sql_error create database d1 replica 2 wallevel 0 +sql_error create database d2 replica 1 wallevel 0 +sql_error alter database d2 replica 2 + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/column/testSuite.sim b/tests/script/unique/column/testSuite.sim new file mode 100644 index 0000000000000000000000000000000000000000..8663e9f30518e1092bc63b60e429753fc7ad8712 --- /dev/null +++ b/tests/script/unique/column/testSuite.sim @@ -0,0 +1 @@ +run unique/column/replica3.sim diff --git a/tests/script/unique/db/back_insert.sim b/tests/script/unique/db/back_insert.sim new file mode 100644 index 0000000000000000000000000000000000000000..43831cca95b49218719c5172c3d2d96ad3500896 --- /dev/null +++ b/tests/script/unique/db/back_insert.sim @@ -0,0 +1,7 @@ +sql connect +$x = 1 +begin: + sql insert into db.tb values(now, $x ) -x begin + #print ===> insert successed $x + $x = $x + 1 +goto begin \ No newline at end of file diff --git a/tests/script/unique/db/commit.sim b/tests/script/unique/db/commit.sim new file mode 100644 index 0000000000000000000000000000000000000000..661dd4505f704fff961739075247d4264d617f72 --- /dev/null +++ b/tests/script/unique/db/commit.sim @@ -0,0 +1,125 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 + +print ========= start dnode1 as master +system sh/exec.sh -n dnode1 -s start +sql connect +sleep 2000 + +print ========= start other dnodes +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start +sleep 2000 + +print ======== step1 create db +sql create database commitdb replica 1 days 7 keep 30 +sql use commitdb +sql create table tb (ts timestamp, i int) + +$x = 1 +while $x < 41 + $time = $x . m + sql insert into tb values (now + $time , $x ) + $x = $x + 1 +endw + +sql select * from tb order by ts desc +print ===> rows $rows +print ===> last $data01 + +if $rows != 40 then + return -1 +endi +if $data01 != 40 then + return -1 +endi + +print ======== step2 stop dnode +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode2 -s start +sleep 3000 + +sql select * from tb order by ts desc +print ===> rows $rows +print ===> last $data01 + +if $rows != 40 then + return -1 +endi +if $data01 != 40 then + return -1 +endi + +$oldnum = $rows +$num = $rows + 2 + +print ======== step3 import old data +sql import into tb values (now - 10d , -10 ) + +sql import into tb values (now - 11d , -11 ) + +sql select * from tb order by ts desc +print ===> rows $rows expect $num +print ===> last $data01 expect $data01 + +if $rows != $num then + return -1 +endi +if $data01 != 40 then + return -1 +endi + +print ======== step4 import new data +sql_error import into tb values (now + 30d , 30 ) +sql_error import into tb values (now + 31d , 31 ) + +sql select * from tb order by ts desc +print ===> rows $rows +print ===> last $data01 + +if $rows != $num then + return -1 +endi +if $data01 != 40 then + return -1 +endi + +print ======== step5 stop dnode +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode2 -s start +sleep 3000 + +sql select * from tb +print ===> rows $rows +print ===> last $data01 + +sql select * from tb order by ts desc +if $rows != $num then + return -1 +endi +if $data01 != 40 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/db/delete.sim b/tests/script/unique/db/delete.sim new file mode 100644 index 0000000000000000000000000000000000000000..c876f23de35f67b0cd2a6f0e428a825d98de7c27 --- /dev/null +++ b/tests/script/unique/db/delete.sim @@ -0,0 +1,99 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 + +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/cfg.sh -n dnode2 -c wallevel -v 2 +system sh/cfg.sh -n dnode3 -c wallevel -v 2 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 2 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 2 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 2 +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 1000 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 1000 +system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 1000 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode $hostname2 +sql create dnode $hostname3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sleep 2000 + +print ======== step1 +sql create database db replica 3 blocks 3 +sql create table db.mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$tbPrefix = db.t +$i = 0 +while $i < 2000 + $tb = $tbPrefix . $i + sql create table $tb using db.mt tags( $i ) + $i = $i + 1 +endw + +sql show db.vgroups +if $rows != 2 then + return -1 +endi + +print ======== step2 +sql drop database db +sql show databases +if $rows != 0 then + return -1 +endi + +sleep 2000 +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +if $data2_1 != 0 then + return -1 +endi +if $data2_2 != 0 then + return -1 +endi +if $data2_3 != 0 then + return -1 +endi + +print ======== step3 + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT + +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start + +$x = 0 +step3: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show mnodes +print dnode1 role $data2_1 +if $data2_1 != master then + goto step3 +endi + + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/db/delete_part.sim b/tests/script/unique/db/delete_part.sim new file mode 100644 index 0000000000000000000000000000000000000000..682444e922a5e1403ac6046b85f1c48b0f4bc78a --- /dev/null +++ b/tests/script/unique/db/delete_part.sim @@ -0,0 +1,202 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/cfg.sh -n dnode2 -c wallevel -v 2 +system sh/cfg.sh -n dnode3 -c wallevel -v 2 +system sh/cfg.sh -n dnode4 -c wallevel -v 2 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 0 + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 8 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 8 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 8 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 8 + +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 + +if $data4_1 != ready then + goto step1 +endi +if $data4_2 != ready then + goto step1 +endi + +$loop = 0 +begin: + + $db = db . $loop + + print ======== step1 $loop + sql create database $db + sql use $db + + sql create table t11 (ts timestamp, i int) + sql insert into t11 values(now, 1 ) + sql create table t12 (ts timestamp, i int) + sql insert into t12 values(now, 1 ) + sql create table t13 (ts timestamp, i int) + sql insert into t13 values(now, 1 ) + sql create table t14 (ts timestamp, i int) + sql insert into t14 values(now, 1 ) + + sql create table t21 (ts timestamp, i int) + sql insert into t21 values(now, 1 ) + sql create table t22 (ts timestamp, i int) + sql insert into t22 values(now, 1 ) + sql create table t23 (ts timestamp, i int) + sql insert into t23 values(now, 1 ) + sql create table t24 (ts timestamp, i int) + sql insert into t24 values(now, 1 ) + + sql create table t31 (ts timestamp, i int) + sql insert into t31 values(now, 1 ) + sql create table t32 (ts timestamp, i int) + sql insert into t32 values(now, 1 ) + sql create table t33 (ts timestamp, i int) + sql insert into t33 values(now, 1 ) + sql create table t34 (ts timestamp, i int) + sql insert into t34 values(now, 1 ) + + sql create table t41 (ts timestamp, i int) + sql insert into t41 values(now, 1 ) + sql create table t42 (ts timestamp, i int) + sql insert into t42 values(now, 1 ) + sql create table t43 (ts timestamp, i int) + sql insert into t43 values(now, 1 ) + sql create table t44 (ts timestamp, i int) + sql insert into t44 values(now, 1 ) + + sql create table t51 (ts timestamp, i int) + sql insert into t51 values(now, 1 ) + sql create table t52 (ts timestamp, i int) + sql insert into t52 values(now, 1 ) + sql create table t53 (ts timestamp, i int) + sql insert into t53 values(now, 1 ) + sql create table t54 (ts timestamp, i int) + sql insert into t54 values(now, 1 ) + + sql create table t61 (ts timestamp, i int) + sql insert into t61 values(now, 1 ) + sql create table t62 (ts timestamp, i int) + sql insert into t62 values(now, 1 ) + sql create table t63 (ts timestamp, i int) + sql insert into t63 values(now, 1 ) + sql create table t64 (ts timestamp, i int) + sql insert into t64 values(now, 1 ) + + sql create table t71 (ts timestamp, i int) + sql insert into t71 values(now, 1 ) + sql create table t72 (ts timestamp, i int) + sql insert into t72 values(now, 1 ) + sql create table t73 (ts timestamp, i int) + sql insert into t73 values(now, 1 ) + sql create table t74 (ts timestamp, i int) + sql insert into t74 values(now, 1 ) + + sql create table t81 (ts timestamp, i int) + sql insert into t81 values(now, 1 ) + sql create table t82 (ts timestamp, i int) + sql insert into t82 values(now, 1 ) + sql create table t83 (ts timestamp, i int) + sql insert into t83 values(now, 1 ) + sql create table t84 (ts timestamp, i int) + sql insert into t84 values(now, 1 ) + + sql show dnodes + print dnode1 openVnodes $data2_1 + print dnode2 openVnodes $data2_2 + if $data2_1 != 4 then + return -1 + endi + if $data2_2 != 4 then + return -1 + endi + + print ======== step2 $loop + + system sh/exec.sh -n dnode2 -s stop + print ==> drop database $db + sql drop database $db + + print ======== step3 $loop + sleep 2000 + system sh/exec.sh -n dnode2 -s start + + + $x = 0 + step3: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + + sql show dnodes -x step3 + print dnode1 openVnodes $data2_1 $data4_1 + print dnode2 openVnodes $data2_2 $data4_2 + if $data2_1 != 0 then + goto step3 + endi + if $data2_2 != 0 then + goto step3 + endi + if $data4_1 != ready then + goto step3 + endi + if $data4_2 != ready then + goto step3 + endi + + print ===> test times : $loop + if $loop > 3 then + return 0 + endi + + $loop = $loop + 1 + + sql reset query cache + sleep 100 + +goto begin + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/db/replica_add12.sim b/tests/script/unique/db/replica_add12.sim new file mode 100644 index 0000000000000000000000000000000000000000..d46187e4456acbd39c7b1f7689388af156d04f85 --- /dev/null +++ b/tests/script/unique/db/replica_add12.sim @@ -0,0 +1,349 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/cfg.sh -n dnode2 -c wallevel -v 2 +system sh/cfg.sh -n dnode3 -c wallevel -v 2 +system sh/cfg.sh -n dnode4 -c wallevel -v 2 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 1 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 1 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 1 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 1 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start +sql create dnode $hostname3 +system sh/exec.sh -n dnode3 -s start + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 + +if $data4_1 != ready then + goto step1 +endi +if $data4_2 != ready then + goto step1 +endi +if $data4_3 != ready then + goto step1 +endi + +sql show mnodes +print mnode1 $data2_1 +print mnode1 $data2_2 +print mnode1 $data2_3 +if $data2_1 != master then + goto step1 +endi +if $data2_2 != null then + goto step1 +endi +if $data2_3 != null then + goto step1 +endi + +print ======== step1 +sql create database d1 replica 1 +sql create database d2 replica 1 +sql create database d3 replica 1 +sql create database d4 replica 1 + +sql create table d1.t1 (ts timestamp, i int) +sql create table d2.t2 (ts timestamp, i int) +sql create table d3.t3 (ts timestamp, i int) +sql create table d4.t4 (ts timestamp, i int) + +sql insert into d1.t1 values(now, 1) +sql insert into d2.t2 values(now, 1) +sql insert into d3.t3 values(now, 1) +sql insert into d4.t4 values(now, 1) + +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 1 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 1 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 1 then + return -1 +endi + +sql show dnodes +print dnode1 ==> openVnodes: $data2_1 +print dnode2 ==> openVnodes: $data2_2 +print dnode3 ==> openVnodes: $data2_3 + +if $data2_1 != 0 then + return -1 +endi + +if $data2_2 != 2 then + return -1 +endi + +if $data2_3 != 2 then + return -1 +endi + +print ======== step2 +sql alter database d1 replica 2 +sql alter database d2 replica 2 +sql alter database d3 replica 2 +sql alter database d4 replica 2 + +$x = 0 +a1: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show d1.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto a1 +endi + +sql show d2.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto a1 +endi + +sql show d3.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto a1 +endi + +sql show d4.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto a1 +endi + +print ======== step3 +sql show dnodes +print dnode1 ==> openVnodes: $data2_1 +print dnode2 ==> openVnodes: $data2_2 +print dnode3 ==> openVnodes: $data2_3 + +if $data2_1 != 0 then + return -1 +endi + +if $data2_2 != 4 then + return -1 +endi + +if $data2_3 != 4 then + return -1 +endi + +print ======== step4 +sql insert into d1.t1 values(now, 2) +sql insert into d2.t2 values(now, 2) +sql insert into d3.t3 values(now, 2) +sql insert into d4.t4 values(now, 2) + +sql select * from d1.t1 +if $rows != 2 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 2 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 2 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 2 then + return -1 +endi + +sql reset query cache +sleep 200 + +print ========= step5 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sql select * from d1.t1 -x s51 +s51: +#sql insert into d1.t1 values(now, 3) -x s52 +s52: + +print ========= step6 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +step6: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show d1.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto step6 +endi + +sql show d2.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto step6 +endi + +sql show d3.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto step6 +endi + +sql show d4.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto step6 +endi + +sql insert into d1.t1 values(now, 3) -x step6 +sql insert into d2.t2 values(now, 3) -x step6 +sql insert into d3.t3 values(now, 3) -x step6 +sql insert into d4.t4 values(now, 3) -x step6 + +sql select * from d1.t1 +if $rows != 3 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 3 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 3 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 3 then + return -1 +endi + +print ========= step61 +system sh/exec.sh -n dnode3 -s stop -x SIGINT +#sql insert into d1.t1 values(now, 3) -x s61 +s61: + +sql select * from d2.t2 -x s62 +s62: + +print ========= step7 +system sh/exec.sh -n dnode3 -s start + +$x = 0 +step7: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show d1.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto step7 +endi + +sql show d2.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto step7 +endi + +sql show d3.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto step7 +endi + +sql show d4.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto step7 +endi + +sql insert into d1.t1 values(now, 5) -x step7 +sql insert into d2.t2 values(now, 5) -x step7 +sql insert into d3.t3 values(now, 5) -x step7 +sql insert into d4.t4 values(now, 5) -x step7 + +sql select * from d1.t1 +if $rows != 4 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 4 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 4 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 4 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/db/replica_add13.sim b/tests/script/unique/db/replica_add13.sim new file mode 100644 index 0000000000000000000000000000000000000000..13a5c9783228761c2b431f9bb1f571c29c05f080 --- /dev/null +++ b/tests/script/unique/db/replica_add13.sim @@ -0,0 +1,419 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/cfg.sh -n dnode2 -c wallevel -v 2 +system sh/cfg.sh -n dnode3 -c wallevel -v 2 +system sh/cfg.sh -n dnode4 -c wallevel -v 2 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 1 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 1 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 1 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 1 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start +sql create dnode $hostname3 +system sh/exec.sh -n dnode3 -s start +sql create dnode $hostname4 +system sh/exec.sh -n dnode4 -s start + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 +print dnode4 $data4_4 + +if $data4_1 != ready then + goto step1 +endi +if $data4_2 != ready then + goto step1 +endi +if $data4_3 != ready then + goto step1 +endi +if $data4_4 != ready then + goto step1 +endi + +sql show mnodes +print mnode1 $data2_1 +print mnode1 $data2_2 +print mnode1 $data2_3 +if $data2_1 != master then + goto step1 +endi + +print ======== step1 +sql create database d1 replica 1 +sql create database d2 replica 1 +sql create database d3 replica 1 +sql create database d4 replica 1 + +sql create table d1.t1 (ts timestamp, i int) +sql create table d2.t2 (ts timestamp, i int) +sql create table d3.t3 (ts timestamp, i int) +sql create table d4.t4 (ts timestamp, i int) + +sql insert into d1.t1 values(1589529000011, 1) +sql insert into d2.t2 values(1589529000021, 1) +sql insert into d3.t3 values(1589529000031, 1) +sql insert into d4.t4 values(1589529000041, 1) + +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 1 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 1 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 1 then + return -1 +endi + +print ======== step2 +sql alter database d1 replica 3 +sql alter database d2 replica 3 +sql alter database d3 replica 3 +sql alter database d4 replica 3 + +$x = 0 +a1: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show d1.vgroups +print online vnodes $data03 +if $data03 != 3 then + goto a1 +endi + +sql show d2.vgroups +print online vnodes $data03 +if $data03 != 3 then + goto a1 +endi + +sql show d3.vgroups +print online vnodes $data03 +if $data03 != 3 then + goto a1 +endi + +sql show d4.vgroups +print online vnodes $data03 +if $data03 != 3 then + goto a1 +endi + +print ======== step3 +sql show dnodes +print dnode1 ==> openVnodes: $data2_1 +print dnode2 ==> openVnodes: $data2_2 +print dnode3 ==> openVnodes: $data2_3 +print dnode4 ==> openVnodes: $data2_4 + +if $data2_1 != 0 then + return -1 +endi + +if $data2_2 != 4 then + return -1 +endi + +if $data2_3 != 4 then + return -1 +endi + +if $data2_3 != 4 then + return -1 +endi + +print ======== step4 +sql insert into d1.t1 values(1589529000012, 2) +sql insert into d2.t2 values(1589529000022, 2) +sql insert into d3.t3 values(1589529000032, 2) +sql insert into d4.t4 values(1589529000042, 2) + +sql select * from d1.t1 +if $rows != 2 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 2 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 2 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 2 then + return -1 +endi + +print ========= step5 +sql reset query cache +sleep 100 +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +sql insert into d1.t1 values(1589529000013, 3) +sql insert into d2.t2 values(1589529000023, 3) +sql insert into d3.t3 values(1589529000033, 3) +sql insert into d4.t4 values(1589529000043, 3) + +sql select * from d1.t1 +if $rows != 3 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 3 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 3 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 3 then + return -1 +endi + +print ========= step6 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +step6: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show d1.vgroups +print online vnodes $data03 +if $data03 != 3 then + goto step6 +endi + +sql show d2.vgroups +print online vnodes $data03 +if $data03 != 3 then + goto step6 +endi + +sql show d3.vgroups +print online vnodes $data03 +if $data03 != 3 then + goto step6 +endi + +sql show d4.vgroups +print online vnodes $data03 +if $data03 != 3 then + goto step6 +endi + +system sh/exec.sh -n dnode3 -s stop -x SIGINT + +sql insert into d1.t1 values(1589529000014, 4) +sql insert into d2.t2 values(1589529000024, 4) +sql insert into d3.t3 values(1589529000034, 4) +sql insert into d4.t4 values(1589529000044, 4) + +sql select * from d1.t1 +print select * from d1.t1 $rows +if $rows != 4 then + return -1 +endi + +sql select * from d2.t2 +print select * from d2.t2 $rows +if $rows != 4 then + return -1 +endi + +sql select * from d3.t3 +print select * from d3.t3 $rows +if $rows != 4 then + return -1 +endi + +sql select * from d4.t4 +print select * from d4.t4 $rows +if $rows != 4 then + return -1 +endi + +print ========= step7 +system sh/exec.sh -n dnode3 -s start + +$x = 0 +step7: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show d1.vgroups +print online vnodes $data03 +if $data03 != 3 then + goto step7 +endi + +sql show d2.vgroups +print online vnodes $data03 +if $data03 != 3 then + goto step7 +endi + +sql show d3.vgroups +print online vnodes $data03 +if $data03 != 3 then + goto step7 +endi + +sql show d4.vgroups +print online vnodes $data03 +if $data03 != 3 then + goto step7 +endi + +system sh/exec.sh -n dnode4 -s stop -x SIGINT + +sql insert into d1.t1 values(1589529000015, 5) +sql insert into d2.t2 values(1589529000025, 5) +sql insert into d3.t3 values(1589529000035, 5) +sql insert into d4.t4 values(1589529000045, 5) + +sql select * from d1.t1 +if $rows != 5 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 5 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 5 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 5 then + return -1 +endi + +print ========= step8 +system sh/exec.sh -n dnode4 -s start + +$x = 0 +step8: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show d1.vgroups +print online vnodes $data03 +if $data03 != 3 then + goto step8 +endi + +sql show d2.vgroups +print online vnodes $data03 +if $data03 != 3 then + goto step8 +endi + +sql show d3.vgroups +print online vnodes $data03 +if $data03 != 3 then + goto step8 +endi + +sql show d4.vgroups +print online vnodes $data03 +if $data03 != 3 then + goto step8 +endi + +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +sql insert into d1.t1 values(1589529000016, 6) +sql insert into d2.t2 values(1589529000026, 6) +sql insert into d3.t3 values(1589529000036, 6) +sql insert into d4.t4 values(1589529000046, 6) + +sql select * from d1.t1 +if $rows != 6 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 6 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 6 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 6 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/db/replica_add23.sim b/tests/script/unique/db/replica_add23.sim new file mode 100644 index 0000000000000000000000000000000000000000..ac0bd6d9d7b09065c832fb8ad0698b97a9f94853 --- /dev/null +++ b/tests/script/unique/db/replica_add23.sim @@ -0,0 +1,416 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/cfg.sh -n dnode2 -c wallevel -v 2 +system sh/cfg.sh -n dnode3 -c wallevel -v 2 +system sh/cfg.sh -n dnode4 -c wallevel -v 2 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 1 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 1 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 1 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 1 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start +sql create dnode $hostname3 +system sh/exec.sh -n dnode3 -s start +sql create dnode $hostname4 +system sh/exec.sh -n dnode4 -s start + + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 +print dnode4 $data4_4 + +if $data4_1 != ready then + goto step1 +endi +if $data4_2 != ready then + goto step1 +endi +if $data4_3 != ready then + goto step1 +endi +if $data4_4 != ready then + goto step1 +endi + +sql show mnodes +print mnode1 $data2_1 +print mnode1 $data2_2 +print mnode1 $data2_3 +if $data2_1 != master then + goto step1 +endi + +print ======== step1 +sql create database d1 replica 2 +sql create database d2 replica 2 +sql create database d3 replica 2 +sql create database d4 replica 2 + +sql create table d1.t1 (ts timestamp, i int) +sql create table d2.t2 (ts timestamp, i int) +sql create table d3.t3 (ts timestamp, i int) +sql create table d4.t4 (ts timestamp, i int) + +sql insert into d1.t1 values(1588262400001, 1) +sql insert into d2.t2 values(1588262400001, 1) +sql insert into d3.t3 values(1588262400001, 1) +sql insert into d4.t4 values(1588262400001, 1) + +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 1 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 1 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 1 then + return -1 +endi + +print ======== step2 +sql alter database d1 replica 3 +sql alter database d2 replica 3 +sql alter database d3 replica 3 +sql alter database d4 replica 3 + +$x = 0 +a1: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show d1.vgroups +print online vnodes $data03 +if $data03 != 3 then + goto a1 +endi + +sql show d2.vgroups +print online vnodes $data03 +if $data03 != 3 then + goto a1 +endi + +sql show d3.vgroups +print online vnodes $data03 +if $data03 != 3 then + goto a1 +endi + +sql show d4.vgroups +print online vnodes $data03 +if $data03 != 3 then + goto a1 +endi + +print ======== step3 +sql show dnodes +print dnode1 ==> openVnodes: $data2_1 +print dnode2 ==> openVnodes: $data2_2 +print dnode3 ==> openVnodes: $data2_3 +print dnode4 ==> openVnodes: $data2_4 + +if $data2_1 != 0 then + return -1 +endi + +if $data2_2 != 4 then + return -1 +endi + +if $data2_3 != 4 then + return -1 +endi + +if $data2_3 != 4 then + return -1 +endi + +print ======== step4 +sql insert into d1.t1 values(1588262400002, 2) +sql insert into d2.t2 values(1588262400002, 2) +sql insert into d3.t3 values(1588262400002, 2) +sql insert into d4.t4 values(1588262400002, 2) + +sql select * from d1.t1 +if $rows != 2 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 2 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 2 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 2 then + return -1 +endi + +sql reset query cache +sleep 100 + +print ========= step5 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sql insert into d1.t1 values(1588262400003, 3) +sql insert into d2.t2 values(1588262400003, 3) +sql insert into d3.t3 values(1588262400003, 3) +sql insert into d4.t4 values(1588262400003, 3) + +sql select * from d1.t1 +if $rows != 3 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 3 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 3 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 3 then + return -1 +endi + +print ========= step6 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +step6: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show d1.vgroups +print online vnodes $data03 +if $data03 != 3 then + goto step6 +endi + +sql show d2.vgroups +print online vnodes $data03 +if $data03 != 3 then + goto step6 +endi + +sql show d3.vgroups +print online vnodes $data03 +if $data03 != 3 then + goto step6 +endi + +sql show d4.vgroups +print online vnodes $data03 +if $data03 != 3 then + goto step6 +endi + +system sh/exec.sh -n dnode3 -s stop -x SIGINT + +sql insert into d1.t1 values(1588262400004, 4) +sql insert into d2.t2 values(1588262400004, 4) +sql insert into d3.t3 values(1588262400004, 4) +sql insert into d4.t4 values(1588262400004, 4) + +sql select * from d1.t1 +if $rows != 4 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 4 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 4 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 4 then + return -1 +endi + +print ========= step7 +system sh/exec.sh -n dnode3 -s start + +$x = 0 +step7: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show d1.vgroups +print online vnodes $data03 +if $data03 != 3 then + goto step7 +endi + +sql show d2.vgroups +print online vnodes $data03 +if $data03 != 3 then + goto step7 +endi + +sql show d3.vgroups +print online vnodes $data03 +if $data03 != 3 then + goto step7 +endi + +sql show d4.vgroups +print online vnodes $data03 +if $data03 != 3 then + goto step7 +endi + +system sh/exec.sh -n dnode4 -s stop -x SIGINT + +sql insert into d1.t1 values(1588262400005, 5) +sql insert into d2.t2 values(1588262400005, 5) +sql insert into d3.t3 values(1588262400005, 5) +sql insert into d4.t4 values(1588262400005, 5) + +sql select * from d1.t1 +if $rows != 5 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 5 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 5 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 5 then + return -1 +endi + +print ========= step8 +system sh/exec.sh -n dnode4 -s start + +$x = 0 +step8: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show d1.vgroups +print online vnodes $data03 +if $data03 != 3 then + goto step8 +endi + +sql show d2.vgroups +print online vnodes $data03 +if $data03 != 3 then + goto step8 +endi + +sql show d3.vgroups +print online vnodes $data03 +if $data03 != 3 then + goto step8 +endi + +sql show d4.vgroups +print online vnodes $data03 +if $data03 != 3 then + goto step8 +endi + +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +sql insert into d1.t1 values(1588262400006, 6) +sql insert into d2.t2 values(1588262400006, 6) +sql insert into d3.t3 values(1588262400006, 6) +sql insert into d4.t4 values(1588262400006, 6) + +sql select * from d1.t1 +if $rows != 6 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 6 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 6 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 6 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/db/replica_part.sim b/tests/script/unique/db/replica_part.sim new file mode 100644 index 0000000000000000000000000000000000000000..9880ec666c8543676c406c843d14235a09ae13ee --- /dev/null +++ b/tests/script/unique/db/replica_part.sim @@ -0,0 +1,306 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 + +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/cfg.sh -n dnode2 -c wallevel -v 2 +system sh/cfg.sh -n dnode3 -c wallevel -v 2 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 1 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 1 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 1 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start +sql create dnode $hostname3 +system sh/exec.sh -n dnode3 -s start + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 +print dnode4 $data4_4 + +if $data4_1 != ready then + goto step1 +endi +if $data4_2 != ready then + goto step1 +endi +if $data4_3 != ready then + goto step1 +endi + +sql show mnodes +print mnode1 $data2_1 +print mnode1 $data2_2 +print mnode1 $data2_3 +if $data2_1 != master then + goto step1 +endi + +print ======== step1 +sql create database d1 replica 3 +sql create database d2 replica 3 +sql create database d3 replica 3 +sql create database d4 replica 3 + +sql create table d1.t1 (ts timestamp, i int) +sql create table d2.t2 (ts timestamp, i int) +sql create table d3.t3 (ts timestamp, i int) +sql create table d4.t4 (ts timestamp, i int) + +sql insert into d2.t2 values(now, 1) +sql insert into d1.t1 values(now, 1) +sql insert into d3.t3 values(now, 1) +sql insert into d4.t4 values(now, 1) + +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 1 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 1 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 1 then + return -1 +endi + +print ========= step2 alter db +sql alter database d1 replica 2 +sql alter database d2 replica 2 +sql alter database d3 replica 2 +sql alter database d4 replica 2 + +$x = 0 +a1: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show d1.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto a1 +endi + +sql show d2.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto a1 +endi + +sql show d3.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto a1 +endi + +sql show d4.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto a1 +endi + +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +print ========= step3 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +step3: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show d1.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto step3 +endi + +sql show d2.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto step3 +endi + +sql show d3.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto step3 +endi + +sql show d4.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto step3 +endi + +print ========= step4 +sql insert into d1.t1 values(now, 2) +sql insert into d2.t2 values(now, 2) +sql insert into d3.t3 values(now, 2) +sql insert into d4.t4 values(now, 2) + +sql select * from d1.t1 +if $rows != 2 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 2 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 2 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 2 then + return -1 +endi + +print ========= step5 +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +sql reset query cache +sleep 100 + +sql insert into d1.t1 values(now, 3) -x s1 +s1: +#sql insert into d2.t2 values(now, 3) -x s2 +#s2: +#sql insert into d3.t3 values(now, 3) -x s3 +#s3: +#sql insert into d4.t4 values(now, 3) -x s4 +#s4: + +print ========= step6 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +step6: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show d1.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto step6 +endi + +sql show d2.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto step6 +endi + +sql show d3.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto step6 +endi + +sql show d4.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto step6 +endi + +system sh/exec.sh -n dnode3 -s stop -x SIGINT + +#sql insert into d1.t1 values(now, 4) -x s5 +#s5: +sql insert into d2.t2 values(now, 4) -x s6 +s6: +#sql insert into d3.t3 values(now, 4) -x s7 +#s7: +#sql insert into d4.t4 values(now, 4) -x s8 +#s8: + +print ========= step7 +system sh/exec.sh -n dnode3 -s start + +$x = 0 +step7: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show d1.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto step7 +endi + +sql show d2.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto step7 +endi + +sql show d3.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto step7 +endi + +sql show d4.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto step7 +endi + +sql insert into d1.t1 values(now, 5) +sql insert into d2.t2 values(now, 5) +sql insert into d3.t3 values(now, 5) +sql insert into d4.t4 values(now, 5) + +sql select * from d1.t1 +sql select * from d2.t2 +sql select * from d3.t3 +sql select * from d4.t4 + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/db/replica_reduce21.sim b/tests/script/unique/db/replica_reduce21.sim new file mode 100644 index 0000000000000000000000000000000000000000..d3a76485f81616497a8c4859aafefda7ef371c01 --- /dev/null +++ b/tests/script/unique/db/replica_reduce21.sim @@ -0,0 +1,187 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 + +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/cfg.sh -n dnode2 -c wallevel -v 2 +system sh/cfg.sh -n dnode3 -c wallevel -v 2 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 1 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 1 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 1 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 1 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 + +if $data4_1 != ready then + goto step1 +endi +if $data4_2 != ready then + goto step1 +endi + +sql show mnodes +print mnode1 $data2_1 +print mnode1 $data2_2 +if $data2_1 != master then + goto step1 +endi + +print ======== step1 +sql create database d1 replica 2 +sql create database d2 replica 2 +sql create database d3 replica 2 +sql create database d4 replica 2 + +sql create table d1.t1 (ts timestamp, i int) +sql create table d2.t2 (ts timestamp, i int) +sql create table d3.t3 (ts timestamp, i int) +sql create table d4.t4 (ts timestamp, i int) + +sql insert into d2.t2 values(now, 1) +sql insert into d1.t1 values(now, 1) +sql insert into d3.t3 values(now, 1) +sql insert into d4.t4 values(now, 1) +sleep 1000 + +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 1 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 1 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 1 then + return -1 +endi + +print ======== step2 create d5 +sql create database d5 replica 1 + +print ========= step3 alter d1 +sql alter database d1 replica 1 + +$x = 0 +a1: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show d1.vgroups +print online vnodes $data03 +if $data03 != 1 then + goto a1 +endi + + +print ========= step4 query d1 +sql insert into d1.t1 values(now, 2) +sql select * from d1.t1 +if $rows != 2 then + return -1 +endi + +print ========= step5 query d5 +sql create table d5.t5 (ts timestamp, i int) +sql insert into d5.t5 values(now, 1); +sql select * from d5.t5 +if $rows != 1 then + return -1 +endi +return +print ========= step7 drop d1 +sql drop database d1 +sql reset query cache +sleep 100 + +print ========= step8 +sql insert into d5.t5 values(now, 2) +sql insert into d2.t2 values(now, 2) +sql insert into d3.t3 values(now, 2) +sql insert into d4.t4 values(now, 2) + +sql select * from d5.t5 +if $rows != 2 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 2 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 2 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 2 then + return -1 +endi + +print ======== step9 stop dnode2 +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +sql insert into d5.t5 values(now, 3) +sql insert into d2.t2 values(now, 3) +sql insert into d3.t3 values(now, 3) +sql insert into d4.t4 values(now, 3) + +sql select * from d5.t5 +if $rows != 3 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 3 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 3 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 3 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/db/replica_reduce31.sim b/tests/script/unique/db/replica_reduce31.sim new file mode 100644 index 0000000000000000000000000000000000000000..5350bcc78c327ae9eb35f24e6d01901cebfb7a07 --- /dev/null +++ b/tests/script/unique/db/replica_reduce31.sim @@ -0,0 +1,327 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 + +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/cfg.sh -n dnode2 -c wallevel -v 2 +system sh/cfg.sh -n dnode3 -c wallevel -v 2 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 1 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 1 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 1 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 1 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start +sql create dnode $hostname3 +system sh/exec.sh -n dnode3 -s start + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 +print dnode4 $data4_4 + +if $data4_1 != ready then + goto step1 +endi +if $data4_2 != ready then + goto step1 +endi +if $data4_3 != ready then + goto step1 +endi + +sql show mnodes +print mnode1 $data2_1 +print mnode1 $data2_2 +print mnode1 $data2_3 +if $data2_1 != master then + goto step1 +endi + +print ======== step1 +sql create database d1 replica 3 +sql create database d2 replica 3 +sql create database d3 replica 3 +sql create database d4 replica 3 + +sql create table d1.t1 (ts timestamp, i int) +sql create table d2.t2 (ts timestamp, i int) +sql create table d3.t3 (ts timestamp, i int) +sql create table d4.t4 (ts timestamp, i int) + +sql insert into d1.t1 values(now, 1) +sql insert into d2.t2 values(now, 1) +sql insert into d3.t3 values(now, 1) +sql insert into d4.t4 values(now, 1) + +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 1 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 1 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 1 then + return -1 +endi + +print ========= step2 alter db +sql_error alter database d1 replica 1 +sql_error alter database d2 replica 1 +sql_error alter database d3 replica 1 +sql_error alter database d4 replica 1 +sql alter database d1 replica 2 +sql alter database d2 replica 2 +sql alter database d3 replica 2 +sql alter database d4 replica 2 + +$x = 0 +a2: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show d1.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto a2 +endi + +sql show d2.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto a2 +endi + +sql show d3.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto a2 +endi + +sql show d4.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto a2 +endi + +sql alter database d1 replica 1 +sql alter database d2 replica 1 +sql alter database d3 replica 1 +sql alter database d4 replica 1 + +$x = 0 +a1: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show d1.vgroups +print online vnodes $data03 +if $data03 != 1 then + goto a1 +endi + +sql show d2.vgroups +print online vnodes $data03 +if $data03 != 1 then + goto a1 +endi + +sql show d3.vgroups +print online vnodes $data03 +if $data03 != 1 then + goto a1 +endi + +sql show d4.vgroups +print online vnodes $data03 +if $data03 != 1 then + goto a1 +endi + +sql show dnodes +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 + +if $data02 != 0 then + goto a1 +endi +if $data12 != 2 then + goto a1 +endi +if $data22 != 2 then + goto a1 +endi + +print ========= step3 +sql reset query cache +sleep 100 + +sql insert into d1.t1 values(now, 2) +sql insert into d2.t2 values(now, 2) +sql insert into d3.t3 values(now, 2) +sql insert into d4.t4 values(now, 2) + +sql select * from d1.t1 +if $rows != 2 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 2 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 2 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 2 then + return -1 +endi + +print ========= step4 alter db +sql alter database d1 replica 2 +sql alter database d2 replica 2 +sql alter database d3 replica 2 +sql alter database d4 replica 2 + +$x = 0 +step4: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show d1.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto step4 +endi + +sql show d2.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto step4 +endi + +sql show d3.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto step4 +endi + +sql show d4.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto step4 +endi + +sql insert into d1.t1 values(now, 3) +sql insert into d2.t2 values(now, 3) +sql insert into d3.t3 values(now, 3) +sql insert into d4.t4 values(now, 3) + +sql select * from d1.t1 +if $rows != 3 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 3 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 3 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 3 then + return -1 +endi + +print ========= step4 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sql reset query cache +sleep 100 + +#sql insert into d1.t1 values(now, 4) -x step1 +#step1: +#sql insert into d2.t2 values(now, 4) -x step2 +#step2: +#sql insert into d3.t3 values(now, 4) -x step3 +#step3: +#sql insert into d4.t4 values(now, 4) -x step4 +#step4: + +print ========= step5 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s stop -x SIGINT + +#sql insert into d1.t1 values(now, 5) -x step5 +#step5: +#sql insert into d2.t2 values(now, 5) -x step6 +#step6: +#sql insert into d3.t3 values(now, 5) -x step7 +#step7: +#sql insert into d4.t4 values(now, 5) -x step8 +#step8: + +print ========= step6 +system sh/exec.sh -n dnode3 -s start + +sql insert into d1.t1 values(now, 6) +sql insert into d2.t2 values(now, 6) +sql insert into d3.t3 values(now, 6) +sql insert into d4.t4 values(now, 6) + +sql select * from d1.t1 +sql select * from d2.t2 +sql select * from d3.t3 +sql select * from d4.t4 + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/db/replica_reduce32.sim b/tests/script/unique/db/replica_reduce32.sim new file mode 100644 index 0000000000000000000000000000000000000000..ead265d5d54bd415d12147e5b61b04fcc5d7544f --- /dev/null +++ b/tests/script/unique/db/replica_reduce32.sim @@ -0,0 +1,294 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 + +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/cfg.sh -n dnode2 -c wallevel -v 2 +system sh/cfg.sh -n dnode3 -c wallevel -v 2 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 1 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 1 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 1 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 1 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start +sql create dnode $hostname3 +system sh/exec.sh -n dnode3 -s start + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 + +if $data4_1 != ready then + goto step1 +endi +if $data4_2 != ready then + goto step1 +endi +if $data4_3 != ready then + goto step1 +endi + +sql show mnodes +print mnode1 $data2_1 +print mnode1 $data2_2 +print mnode1 $data2_3 +if $data2_1 != master then + goto step1 +endi +if $data2_2 != null then + goto step1 +endi +if $data2_3 != null then + goto step1 +endi + +print ======== step1 +sql create database d1 replica 3 +sql create database d2 replica 3 +sql create database d3 replica 3 +sql create database d4 replica 3 + +sql create table d1.t1 (ts timestamp, i int) +sql create table d2.t2 (ts timestamp, i int) +sql create table d3.t3 (ts timestamp, i int) +sql create table d4.t4 (ts timestamp, i int) + +sql insert into d2.t2 values(now, 1) +sql insert into d1.t1 values(now, 1) +sql insert into d3.t3 values(now, 1) +sql insert into d4.t4 values(now, 1) + +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 1 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 1 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 1 then + return -1 +endi + +print ========= step2 alter db +sql alter database d1 replica 2 +sql alter database d2 replica 2 +sql alter database d3 replica 2 +sql alter database d4 replica 2 + +$x = 0 +a1: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show d1.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto a1 +endi + +sql show d2.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto a1 +endi + +sql show d3.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto a1 +endi + +sql show d4.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto a1 +endi + +print ========= step3 +sql insert into d1.t1 values(now, 2) +sql insert into d2.t2 values(now, 2) +sql insert into d3.t3 values(now, 2) +sql insert into d4.t4 values(now, 2) + +sql select * from d1.t1 +if $rows != 2 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 2 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 2 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 2 then + return -1 +endi + +sql reset query cache +sleep 200 + +print ========= step4 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 3000 + +sql insert into d1.t1 values(now, 3) -x s41 +s41: +sql insert into d2.t2 values(now, 3) -x s42 +s42: +sql insert into d3.t3 values(now, 3) -x s43 +s43: +sql insert into d4.t4 values(now, 3) -x s44 +s44: + +sql select * from d1.t1 -x s45 +s45: +sql select * from d2.t2 -x s46 +s46: +sql select * from d3.t3 -x s47 +s47: +sql select * from d4.t4 -x s48 +s48: + +print ========= step5 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +step5: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show d1.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto step5 +endi + +sql show d2.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto step5 +endi + +sql show d3.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto step5 +endi + +sql show d4.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto step5 +endi + +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sql reset query cache +sleep 100 + +sql_error insert into d1.t1 values(now, 3) -x s51 +s51: +sql_error insert into d2.t2 values(now, 3) -x s52 +s52: +sql_error insert into d3.t3 values(now, 3) -x s53 +s53: +sql_error insert into d4.t4 values(now, 3) -x s54 +s54: + +print ========= step6 +system sh/exec.sh -n dnode3 -s start +$x = 0 +step6: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show d1.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto step6 +endi + +sql show d2.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto step6 +endi + +sql show d3.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto step6 +endi + +sql show d4.vgroups +print online vnodes $data03 +if $data03 != 2 then + goto step6 +endi + +sql insert into d1.t1 values(now, 5) +sql insert into d2.t2 values(now, 5) +sql insert into d3.t3 values(now, 5) +sql insert into d4.t4 values(now, 5) +sleep 1000 + +sql select * from d1.t1 +print d1.t1 $rows + +sql select * from d2.t2 +print d2.t2 $rows + +sql select * from d3.t3 +print d3.t3 $rows + +sql select * from d4.t4 +print d4.t4 $rows + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/db/testSuite.sim b/tests/script/unique/db/testSuite.sim new file mode 100644 index 0000000000000000000000000000000000000000..adc1883a71c32d0b18e17a994f32e7ddd9577e9b --- /dev/null +++ b/tests/script/unique/db/testSuite.sim @@ -0,0 +1,10 @@ +run unique/db/commit.sim +run unique/db/delete.sim +run unique/db/replica_add12.sim +run unique/db/replica_add13.sim +run unique/db/replica_add23.sim +run unique/db/replica_reduce21.sim +run unique/db/replica_reduce32.sim +run unique/db/replica_reduce31.sim +run unique/db/replica_part.sim +run unique/db/delete_part.sim diff --git a/tests/script/unique/dnode/alternativeRole.sim b/tests/script/unique/dnode/alternativeRole.sim new file mode 100644 index 0000000000000000000000000000000000000000..7e647925d1d3d66d21f279ace852e3fc12496510 --- /dev/null +++ b/tests/script/unique/dnode/alternativeRole.sim @@ -0,0 +1,114 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 0 + +system sh/cfg.sh -n dnode1 -c wallevel -v 1 +system sh/cfg.sh -n dnode2 -c wallevel -v 1 +system sh/cfg.sh -n dnode3 -c wallevel -v 1 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 + +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4 + + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start +sql create dnode $hostname3 +system sh/exec.sh -n dnode3 -s start +sleep 3000 + +$x = 0 +show1: + $x = $x + 1 + sleep 1000 + if $x == 30 then + return -1 + endi + +sql show dnodes +print dnode1 $data5_1 +print dnode2 $data5_2 +print dnode3 $data5_3 + +if $data5_1 != mnode then + goto show1 +endi +if $data5_2 != vnode then + goto show1 +endi +if $data5_3 != any then + goto show1 +endi + +show2: + $x = $x + 1 + sleep 1000 + if $x == 30 then + return -1 + endi + +sql show mnodes +print dnode1 ==> $data2_1 +print dnode2 ==> $data2_2 +print dnode3 ==> $data2_3 +if $data2_1 != master then + goto show2 +endi +if $data2_2 != null then + goto show2 +endi +if $data2_3 != slave then + goto show2 +endi + +print ========== step2 +sql create database d1 +sql create table d1.t1 (ts timestamp, i int) +sql create table d1.t2 (ts timestamp, i int) +sql create table d1.t3 (ts timestamp, i int) +sql create table d1.t4 (ts timestamp, i int) +sql create table d1.t5 (ts timestamp, i int) +sql create table d1.t6 (ts timestamp, i int) +sql create table d1.t7 (ts timestamp, i int) +sql create table d1.t8 (ts timestamp, i int) + +show3: + $x = $x + 1 + sleep 1000 + if $x == 30 then + return -1 + endi + +sql show dnodes +print dnode1 $data2_1 +print dnode2 $data2_2 +print dnode3 $data2_3 + +if $data2_1 != 0 then + goto show3 +endi +if $data2_2 != 1 then + goto show3 +endi +if $data2_3 != 1 then + goto show3 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/balance1.sim b/tests/script/unique/dnode/balance1.sim new file mode 100644 index 0000000000000000000000000000000000000000..8743204a03e06d0aefc66b2f70cbdc111e317237 --- /dev/null +++ b/tests/script/unique/dnode/balance1.sim @@ -0,0 +1,341 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/cfg.sh -n dnode2 -c wallevel -v 2 +system sh/cfg.sh -n dnode3 -c wallevel -v 2 +system sh/cfg.sh -n dnode4 -c wallevel -v 2 + +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/cfg.sh -n dnode2 -c wallevel -v 2 +system sh/cfg.sh -n dnode3 -c wallevel -v 2 +system sh/cfg.sh -n dnode4 -c wallevel -v 2 + +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create database d1 +sql create table d1.t1 (t timestamp, i int) +sql insert into d1.t1 values(now+1s, 15) +sql insert into d1.t1 values(now+2s, 14) +sql insert into d1.t1 values(now+3s, 13) +sql insert into d1.t1 values(now+4s, 12) +sql insert into d1.t1 values(now+5s, 11) + +sql show dnodes +print dnode1 openVnodes $data2_1 +if $data2_1 != 1 then + return -1 +endi + +print ========== step2 +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +show2: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +if $data2_1 != 0 then + goto show2 +endi +if $data2_2 != 1 then + goto show2 +endi + +print ========== step3 +sql create database d2 +sql create table d2.t2 (t timestamp, i int) +sql insert into d2.t2 values(now+1s, 25) +sql insert into d2.t2 values(now+2s, 24) +sql insert into d2.t2 values(now+3s, 23) +sql insert into d2.t2 values(now+4s, 22) +sql insert into d2.t2 values(now+5s, 21) + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +if $data2_1 != 0 then + return -1 +endi +if $data2_2 != 2 then + return -1 +endi + +print ========== step4 +sql drop dnode $hostname2 + +$x = 0 +show4: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +if $data2_1 != 2 then + goto show4 +endi +if $data2_2 != null then + goto show4 +endi +if $rows != 1 then + goto show4 +endi + +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +print ========== step5 +sql create dnode $hostname3 +system sh/exec.sh -n dnode3 -s start + +$x = 0 +show5: + $x = $x + 1 + sleep 1000 + if $x == 30 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +if $data2_1 != 0 then + goto show5 +endi +if $data2_2 != null then + goto show5 +endi +if $data2_3 != 2 then + goto show5 +endi + +print ========== step6 +sql create database d3 +sql create table d3.t3 (t timestamp, i int) +sql insert into d3.t3 values(now+1s, 35) +sql insert into d3.t3 values(now+2s, 34) +sql insert into d3.t3 values(now+3s, 33) +sql insert into d3.t3 values(now+4s, 32) +sql insert into d3.t3 values(now+5s, 31) + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 + +if $data2_1 != 0 then + return -1 +endi +if $data2_2 != null then + return -1 +endi +if $data2_3 != 3 then + return -1 +endi + +print ========== step7 +sql create dnode $hostname4 +system sh/exec.sh -n dnode4 -s start + +$x = 0 +show7: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 +if $data2_1 != 0 then + goto show7 +endi +if $data2_2 != null then + goto show7 +endi +if $data2_3 != 2 then + goto show7 +endi +if $data2_4 != 1 then + goto show7 +endi + +print ========== step8 +sql create database d4 +sql create table d4.t4 (t timestamp, i int) +sql insert into d4.t4 values(now+1s, 45) +sql insert into d4.t4 values(now+2s, 44) +sql insert into d4.t4 values(now+3s, 43) +sql insert into d4.t4 values(now+4s, 42) +sql insert into d4.t4 values(now+5s, 41) + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 + +if $data2_1 != 0 then + return -1 +endi +if $data2_2 != null then + return -1 +endi +if $data2_3 != 2 then + return -1 +endi +if $data2_4 != 2 then + return -1 +endi + +print ========== step9 +sql drop dnode $hostname3 + +$x = 0 +show9: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 + +if $data2_1 != 0 then + goto show9 +endi +if $data2_2 != null then + goto show9 +endi +if $data2_3 != null then + goto show9 +endi +if $data2_4 != 4 then + goto show9 +endi + +system sh/exec.sh -n dnode3 -s stop -x SIGINT + +sql reset query cache +sleep 100 + +print ========== step10 +sql select * from d1.t1 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 11 then + return -1 +endi +if $data11 != 12 then + return -1 +endi +if $data21 != 13 then + return -1 +endi +if $data31 != 14 then + return -1 +endi +if $data41 != 15 then + return -1 +endi + +sql select * from d2.t2 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 21 then + return -1 +endi +if $data11 != 22 then + return -1 +endi +if $data21 != 23 then + return -1 +endi +if $data31 != 24 then + return -1 +endi +if $data41 != 25 then + return -1 +endi + +sql select * from d3.t3 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 31 then + return -1 +endi +if $data11 != 32 then + return -1 +endi +if $data21 != 33 then + return -1 +endi +if $data31 != 34 then + return -1 +endi +if $data41 != 35 then + return -1 +endi + +sql select * from d4.t4 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 41 then + return -1 +endi +if $data11 != 42 then + return -1 +endi +if $data21 != 43 then + return -1 +endi +if $data31 != 44 then + return -1 +endi +if $data41 != 45 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/balance2.sim b/tests/script/unique/dnode/balance2.sim new file mode 100644 index 0000000000000000000000000000000000000000..4c67e20c3eb5e65b0bacf0aafc3d9dc1a53d5ac3 --- /dev/null +++ b/tests/script/unique/dnode/balance2.sim @@ -0,0 +1,306 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/deploy.sh -n dnode5 -i 5 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode5 -c mnodeEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode5 -c maxTablesPerVnode -v 4 + +system sh/cfg.sh -n dnode1 -c wallevel -v 1 +system sh/cfg.sh -n dnode2 -c wallevel -v 1 +system sh/cfg.sh -n dnode3 -c wallevel -v 1 +system sh/cfg.sh -n dnode4 -c wallevel -v 1 +system sh/cfg.sh -n dnode5 -c wallevel -v 1 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create dnode $hostname2 +sql create dnode $hostname3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 +print dnode4 $data4_4 + +if $data4_1 != ready then + goto step1 +endi +if $data4_2 != ready then + goto step1 +endi +if $data4_3 != ready then + goto step1 +endi + +sql create database d1 replica 2 +sql create table d1.t1 (t timestamp, i int) +sql insert into d1.t1 values(now+1s, 15) +sql insert into d1.t1 values(now+2s, 14) +sql insert into d1.t1 values(now+3s, 13) +sql insert into d1.t1 values(now+4s, 12) +sql insert into d1.t1 values(now+5s, 11) + +sql create database d2 replica 2 +sql create table d2.t2 (t timestamp, i int) +sql insert into d2.t2 values(now+1s, 25) +sql insert into d2.t2 values(now+2s, 24) +sql insert into d2.t2 values(now+3s, 23) +sql insert into d2.t2 values(now+4s, 22) +sql insert into d2.t2 values(now+5s, 21) + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +if $data2_1 != 0 then + return -1 +endi +if $data2_2 != 2 then + return -1 +endi +if $data2_3 != 2 then + return -1 +endi + +print ========== step2 +sql drop dnode $hostname2 + +$x = 0 +show2: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +if $data2_1 != 2 then + goto show2 +endi +if $data2_2 != null then + goto show2 +endi +if $data2_3 != 2 then + goto show2 +endi + +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +print ========== step3 +sql create dnode $hostname4 +system sh/exec.sh -n dnode4 -s start + +$x = 0 +show3: + $x = $x + 1 + sleep 2000 + if $x == 20 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 +if $data2_1 != 0 then + goto show3 +endi +if $data2_2 != null then + goto show3 +endi +if $data2_3 != 2 then + goto show3 +endi +if $data2_4 != 2 then + goto show3 +endi + +print ========== step4 +sql create database d3 replica 2 +sql create table d3.t3 (t timestamp, i int) +sql insert into d3.t3 values(now+1s, 35) +sql insert into d3.t3 values(now+2s, 34) +sql insert into d3.t3 values(now+3s, 33) +sql insert into d3.t3 values(now+4s, 32) +sql insert into d3.t3 values(now+5s, 31) + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 +if $data2_1 != 0 then + return -1 +endi +if $data2_2 != null then + return -1 +endi +if $data2_3 != 3 then + return -1 +endi +if $data2_4 != 3 then + return -1 +endi + +print ========== step5 +sql create dnode $hostname5 +system sh/exec.sh -n dnode5 -s start + +$x = 0 +show5: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 +print dnode5 openVnodes $data2_5 +if $data2_1 != 0 then + goto show5 +endi +if $data2_2 != null then + goto show5 +endi +if $data2_3 != 2 then + goto show5 +endi +if $data2_4 != 2 then + goto show5 +endi +if $data2_5 != 2 then + goto show5 +endi + +print ========== step6 +sql drop dnode $hostname3 + +$x = 0 +show6: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 +print dnode5 openVnodes $data2_5 +if $data2_1 != 0 then + goto show6 +endi +if $data2_2 != null then + goto show6 +endi +if $data2_3 != null then + goto show6 +endi +if $data2_4 != 3 then + goto show6 +endi +if $data2_5 != 3 then + goto show6 +endi + +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sql reset query cache +sleep 100 + +print ========== step7 +sql select * from d1.t1 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 11 then + return -1 +endi +if $data11 != 12 then + return -1 +endi +if $data21 != 13 then + return -1 +endi +if $data31 != 14 then + return -1 +endi +if $data41 != 15 then + return -1 +endi + +sql select * from d2.t2 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 21 then + return -1 +endi +if $data11 != 22 then + return -1 +endi +if $data21 != 23 then + return -1 +endi +if $data31 != 24 then + return -1 +endi +if $data41 != 25 then + return -1 +endi + +sql select * from d3.t3 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 31 then + return -1 +endi +if $data11 != 32 then + return -1 +endi +if $data21 != 33 then + return -1 +endi +if $data31 != 34 then + return -1 +endi +if $data41 != 35 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/balance3.sim b/tests/script/unique/dnode/balance3.sim new file mode 100644 index 0000000000000000000000000000000000000000..f5558d504e34608eafb2a076a8739024e13dcff2 --- /dev/null +++ b/tests/script/unique/dnode/balance3.sim @@ -0,0 +1,337 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/deploy.sh -n dnode5 -i 5 +system sh/deploy.sh -n dnode6 -i 6 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode5 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode6 -c mnodeEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c wallevel -v 1 +system sh/cfg.sh -n dnode2 -c wallevel -v 1 +system sh/cfg.sh -n dnode3 -c wallevel -v 1 +system sh/cfg.sh -n dnode4 -c wallevel -v 1 +system sh/cfg.sh -n dnode5 -c wallevel -v 1 +system sh/cfg.sh -n dnode6 -c wallevel -v 1 + +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode5 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode6 -c maxTablesPerVnode -v 4 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create dnode $hostname2 +sql create dnode $hostname3 +sql create dnode $hostname4 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 +print dnode4 $data4_4 + +if $data4_1 != ready then + goto step1 +endi +if $data4_2 != ready then + goto step1 +endi +if $data4_3 != ready then + goto step1 +endi +if $data4_4 != ready then + goto step1 +endi + +sql create database d1 replica 3 +sql create table d1.t1 (t timestamp, i int) +sql insert into d1.t1 values(now+1s, 15) +sql insert into d1.t1 values(now+2s, 14) +sql insert into d1.t1 values(now+3s, 13) +sql insert into d1.t1 values(now+4s, 12) +sql insert into d1.t1 values(now+5s, 11) + +sql create database d2 replica 3 +sql create table d2.t2 (t timestamp, i int) +sql insert into d2.t2 values(now+1s, 25) +sql insert into d2.t2 values(now+2s, 24) +sql insert into d2.t2 values(now+3s, 23) +sql insert into d2.t2 values(now+4s, 22) +sql insert into d2.t2 values(now+5s, 21) + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 + +if $data2_1 != 0 then + return -1 +endi +if $data2_2 != 2 then + return -1 +endi +if $data2_3 != 2 then + return -1 +endi +if $data2_4 != 2 then + return -1 +endi + +print ========== step2 +sql drop dnode $hostname2 + +$x = 0 +show2: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 + +if $data2_1 != 2 then + goto show2 +endi +if $data2_2 != null then + goto show2 +endi +if $data2_3 != 2 then + goto show2 +endi +if $data2_4 != 2 then + goto show2 +endi + +system sh/exec.sh -n dnode2 -s stop -x SIGINT +print ========== step +sql create dnode $hostname5 +system sh/exec.sh -n dnode5 -s start + +$x = 0 +show3: + $x = $x + 1 + sleep 1000 + if $x == 60 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 +print dnode5 openVnodes $data2_5 + +if $data2_1 != 0 then + goto show3 +endi +if $data2_2 != null then + goto show3 +endi +if $data2_3 != 2 then + goto show3 +endi +if $data2_4 != 2 then + goto show3 +endi +if $data2_5 != 2 then + goto show3 +endi + +print ========== step4 +sql create database d3 replica 3 +sql create table d3.t3 (t timestamp, i int) +sql insert into d3.t3 values(now+1s, 35) +sql insert into d3.t3 values(now+2s, 34) +sql insert into d3.t3 values(now+3s, 33) +sql insert into d3.t3 values(now+4s, 32) +sql insert into d3.t3 values(now+5s, 31) + +$x = 0 +show4: + $x = $x + 1 + sleep 1000 + if $x == 30 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 +print dnode5 openVnodes $data2_5 + +if $data2_1 != 0 then + goto show4 +endi +if $data2_2 != null then + goto show4 +endi +if $data2_3 != 3 then + goto show4 +endi +if $data2_4 != 3 then + goto show4 +endi +if $data2_5 != 3 then + goto show4 +endi + +print ========== step5 +sql create dnode $hostname6 +system sh/exec.sh -n dnode6 -s start + +$x = 0 +show5: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode6 openVnodes $data2_6 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 +print dnode5 openVnodes $data2_5 + +if $data2_1 != 0 then + goto show5 +endi +if $data2_6 != 2 then + goto show5 +endi + +sleep 8000 + +print ========== step6 +sql drop dnode $hostname3 + +$x = 0 +show6: + $x = $x + 1 + sleep 1000 + if $x == 30 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode6 openVnodes $data2_6 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 +print dnode5 openVnodes $data2_5 + +if $data2_1 != 0 then + goto show6 +endi +if $data2_6 != 3 then + goto show6 +endi +if $data2_3 != null then + goto show6 +endi +if $data2_4 != 3 then + goto show6 +endi +if $data2_5 != 3 then + goto show6 +endi + +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sql reset query cache +sleep 100 + +print ========== step7 +sql select * from d1.t1 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 11 then + return -1 +endi +if $data11 != 12 then + return -1 +endi +if $data21 != 13 then + return -1 +endi +if $data31 != 14 then + return -1 +endi +if $data41 != 15 then + return -1 +endi + +sql select * from d2.t2 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 21 then + return -1 +endi +if $data11 != 22 then + return -1 +endi +if $data21 != 23 then + return -1 +endi +if $data31 != 24 then + return -1 +endi +if $data41 != 25 then + return -1 +endi + +sql select * from d3.t3 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 31 then + return -1 +endi +if $data11 != 32 then + return -1 +endi +if $data21 != 33 then + return -1 +endi +if $data31 != 34 then + return -1 +endi +if $data41 != 35 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/balancex.sim b/tests/script/unique/dnode/balancex.sim new file mode 100644 index 0000000000000000000000000000000000000000..d2c738ee97ff8432999125abfd63d253b0546a91 --- /dev/null +++ b/tests/script/unique/dnode/balancex.sim @@ -0,0 +1,215 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c wallevel -v 1 +system sh/cfg.sh -n dnode2 -c wallevel -v 1 +system sh/cfg.sh -n dnode3 -c wallevel -v 1 +system sh/cfg.sh -n dnode4 -c wallevel -v 1 + +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect +sleep 2000 + +sql create database d1 +sql create table d1.t1 (t timestamp, i int) +sql insert into d1.t1 values(now+1s, 15) +sql insert into d1.t1 values(now+2s, 14) +sql insert into d1.t1 values(now+3s, 13) +sql insert into d1.t1 values(now+4s, 12) +sql insert into d1.t1 values(now+5s, 11) + +sql create database d2 +sql create table d2.t2 (t timestamp, i int) +sql insert into d2.t2 values(now+1s, 25) +sql insert into d2.t2 values(now+2s, 24) +sql insert into d2.t2 values(now+3s, 23) +sql insert into d2.t2 values(now+4s, 22) +sql insert into d2.t2 values(now+5s, 21) + +sql show dnodes +print dnode1 openVnodes $data2_1 +if $data2_1 != 2 then + return -1 +endi + +print ========== step2 +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +if $data2_1 != 0 then + goto show2 +endi +if $data2_2 != 2 then + goto show2 +endi + +print ========== step3 +sql create database d3 replica 2 +sql create table d3.t3 (t timestamp, i int) +sql insert into d3.t3 values(now+1s, 35) +sql insert into d3.t3 values(now+2s, 34) +sql insert into d3.t3 values(now+3s, 33) +sql insert into d3.t3 values(now+4s, 32) +sql insert into d3.t3 values(now+5s, 31) + +$x = 0 +show3: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +if $data2_1 != 1 then + goto show3 +endi +if $data2_2 != 3 then + goto show3 +endi + +print ========== step3 +sql create dnode $hostname3 +system sh/exec.sh -n dnode3 -s start + +$x = 0 +show4: + $x = $x + 1 + sleep 2000 + if $x == 20 then + return -1 + endi +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +if $data2_1 != 0 then + goto show4 +endi +if $data2_2 != 2 then + goto show4 +endi +if $data2_3 != 2 then + goto show4 +endi + +print ========== step5 +sql drop dnode $hostname2 + +$x = 0 +show5: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +if $data2_1 != 1 then + goto show5 +endi +if $data2_2 != null then + goto show5 +endi +if $data2_3 != 3 then + goto show5 +endi + +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 3000 + +sql reset query cache +sleep 1000 + +print ========== step6 +sql select * from d1.t1 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 11 then + return -1 +endi +if $data11 != 12 then + return -1 +endi +if $data21 != 13 then + return -1 +endi +if $data31 != 14 then + return -1 +endi +if $data41 != 15 then + return -1 +endi + +sql select * from d2.t2 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 21 then + return -1 +endi +if $data11 != 22 then + return -1 +endi +if $data21 != 23 then + return -1 +endi +if $data31 != 24 then + return -1 +endi +if $data41 != 25 then + return -1 +endi + +sql select * from d3.t3 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 31 then + return -1 +endi +if $data11 != 32 then + return -1 +endi +if $data21 != 33 then + return -1 +endi +if $data31 != 34 then + return -1 +endi +if $data41 != 35 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/basic1.sim b/tests/script/unique/dnode/basic1.sim new file mode 100644 index 0000000000000000000000000000000000000000..5382e88e536596682636496e9e3f66bc121b1561 --- /dev/null +++ b/tests/script/unique/dnode/basic1.sim @@ -0,0 +1,90 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +sql connect + +print =============== show dnodes +sql show dnodes; +if $rows != 1 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + +if $data01 != 192.168.0.1 then + return -1 +endi + +sql show mnodes; +if $rows != 1 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + +if $data01 != 192.168.0.1 then + return -1 +endi + +print =============== create dnodes +sql create dnode $hostname2 +sql show dnodes; +if $rows != 2 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + +if $data01 != 192.168.0.1 then + return -1 +endi + +if $data10 != 2 then + return -1 +endi + +if $data11 != 192.168.0.2 then + return -1 +endi + +sql show mnodes; +if $rows != 1 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + +if $data01 != 192.168.0.1 then + return -1 +endi + +print =============== create table +sql create database d1; +sql create database d2; +sql create database d3; +sql create database d4; +sql create database d5; + +sql create table d1.t1 (ts timestamp, i int); +sql create table d2.t1 (ts timestamp, i int); +sql create table d3.t1 (ts timestamp, i int); +sql create table d4.t1 (ts timestamp, i int); + +sql show dnodes; +if $data05 != 2 then + return -1 +endi + +if $data15 != 2 then + return -1 +endi diff --git a/tests/script/unique/dnode/data1.sim b/tests/script/unique/dnode/data1.sim new file mode 100644 index 0000000000000000000000000000000000000000..75a484abb60c1e09a7c96f8f03902ea4f0f40aa1 --- /dev/null +++ b/tests/script/unique/dnode/data1.sim @@ -0,0 +1,137 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/cfg.sh -n dnode2 -c wallevel -v 2 +system sh/cfg.sh -n dnode3 -c wallevel -v 2 +system sh/cfg.sh -n dnode4 -c wallevel -v 2 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect +sleep 2000 + +print ========== step2 +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start +sql create dnode $hostname3 +system sh/exec.sh -n dnode3 -s start +sql create dnode $hostname4 +system sh/exec.sh -n dnode4 -s start + +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 +if $data2_1 != 0 then + goto show2 +endi +if $data2_2 != 0 then + goto show2 +endi +if $data2_3 != 0 then + goto show2 +endi +if $data2_4 != 0 then + goto show2 +endi + +print ========== step3 +sql create database d1 replica 3 +sql create table d1.t1 (t timestamp, i int) +sql insert into d1.t1 values(now+1s, 35) +sql insert into d1.t1 values(now+2s, 34) +sql insert into d1.t1 values(now+3s, 33) +sql insert into d1.t1 values(now+4s, 32) +sql insert into d1.t1 values(now+5s, 31) + +$x = 0 +show3: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 +if $data2_1 != 0 then + goto show3 +endi +if $data2_2 != 1 then + goto show3 +endi +if $data2_3 != 1 then + goto show3 +endi +if $data2_4 != 1 then + goto show3 +endi + +print ========== step4 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT + +print ========== step5 +system_content rm -rf ../../../sim/dnode4/data/vnode/vnode2/tsdb/data + +print ========== step6 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sleep 10000 + +print ========== step7 +sql select * from d1.t1 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 31 then + return -1 +endi +if $data11 != 32 then + return -1 +endi +if $data21 != 33 then + return -1 +endi +if $data31 != 34 then + return -1 +endi +if $data41 != 35 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/datatrans_1node.sim b/tests/script/unique/dnode/datatrans_1node.sim new file mode 100644 index 0000000000000000000000000000000000000000..a156c32672cf2936c0b69fe10242744d2dd235a3 --- /dev/null +++ b/tests/script/unique/dnode/datatrans_1node.sim @@ -0,0 +1,53 @@ + +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print =============== step1 +sql drop database -x step1 +step1: +sql create database db +sql use db +sql create table m1 (ts timestamp, speed int) + +print =============== step 2 +$x = 0 +while $x < 10 + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + sql insert into m1 values ($ms , $x ) + $x = $x + 1 +endw + +sql select * from m1 + +print $rows points data are retrieved +if $rows != 10 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT + +print =============== step 3 +system sh/move_dnode.sh dnode1 dnode2 +system sh/exec.sh -n dnode2 -s start + + +print =============== step 4 +sleep 2000 +sql connect + +sql select * from db.m1 + +print $rows points data are retrieved +if $rows != 10 then + return -1 +endi + +system sh/exec.sh -n dnode2 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/datatrans_3node.sim b/tests/script/unique/dnode/datatrans_3node.sim new file mode 100644 index 0000000000000000000000000000000000000000..7948eb6d3a4317ab3d829a874ced71d9f290d641 --- /dev/null +++ b/tests/script/unique/dnode/datatrans_3node.sim @@ -0,0 +1,91 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 + + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 + + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 2 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 + + +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 + + + + +print ============== step1: start dnode1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3 and add into cluster , then create database with replica 2, and create table, insert data +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 +sleep 2000 + +# create table +sql drop database -x step1 +step1: +sql create database db +sql use db +sql create table m1 (ts timestamp, speed int) + +# insert data +$x = 0 +while $x < 10 + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + sql insert into m1 values ($ms , $x ) + $x = $x + 1 +endw + +sql select * from m1 + +print $rows points data are retrieved +if $rows != 10 then + return -1 +endi + +print ============== step3: stop cluster , then move_dnode1 ,start cluster +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT + +system sh/move_dnode.sh dnode1 dnode4 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start + +print =============== step 4 +sleep 2000 +sql connect + +sql select * from db.m1 + +print $rows points data are retrieved +if $rows != 10 then + return -1 +endi + +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/datatrans_3node_2.sim b/tests/script/unique/dnode/datatrans_3node_2.sim new file mode 100644 index 0000000000000000000000000000000000000000..844afc5b02f7de4e41d545ad546b9ec41943b18f --- /dev/null +++ b/tests/script/unique/dnode/datatrans_3node_2.sim @@ -0,0 +1,91 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 + + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 + + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 2 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 + + +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 + + + + +print ============== step1: start dnode1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ============== step2: start dnode2/dnode3 and add into cluster , then create database with replica 2, and create table, insert data +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 +sleep 2000 + +# create table +sql drop database -x step1 +step1: +sql create database db replica 2 +sql use db +sql create table m1 (ts timestamp, speed int) + +# insert data +$x = 0 +while $x < 10 + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + sql insert into m1 values ($ms , $x ) + $x = $x + 1 +endw + +sql select * from m1 + +print $rows points data are retrieved +if $rows != 10 then + return -1 +endi + +print ============== step3: stop cluster , then move_dnode1 ,start cluster +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT + +system sh/move_dnode.sh dnode1 dnode4 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start + +print =============== step 4 +sleep 2000 +sql connect + +sql select * from db.m1 + +print $rows points data are retrieved +if $rows != 10 then + return -1 +endi + +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/lossdata.sim b/tests/script/unique/dnode/lossdata.sim new file mode 100644 index 0000000000000000000000000000000000000000..89ba7169708eedb21c663a5e4fe0f897d42c5f43 --- /dev/null +++ b/tests/script/unique/dnode/lossdata.sim @@ -0,0 +1,165 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/deploy.sh -n dnode5 -i 5 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode5 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode5 -c mnodeEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode5 -c maxTablesPerVnode -v 4 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create dnode $hostname2 +sql create dnode $hostname3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 + +if $data4_1 != ready then + goto step1 +endi +if $data4_2 != ready then + goto step1 +endi +if $data4_3 != ready then + goto step1 +endi + +print ========== step2 + +sql create database d1 replica 2 +sql create table d1.t1 (t timestamp, i int) + +print ========== step2.1 + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 + +if $data2_1 != 0 then + return -1 +endi +if $data2_2 != 1 then + return -1 +endi +if $data2_3 != 1 then + return -1 +endi + +print ========== step3 +sql create dnode $hostname4 +system sh/exec.sh -n dnode4 -s start + +$x = 0 +show3: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 + +if $data2_2 != 1 then + goto show3 +endi +if $data2_3 != 1 then + goto show3 +endi +if $data2_4 != 0 then + goto show3 +endi + +sql show d1.vgroups; +print d1.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +print ========== step4 +sql drop dnode $hostname3 + +$i = 0 +$rowNum = 10000 + +while $i < $rowNum + $ts = 1500000000000 + $i + sql insert into d1.t1 values( $ts , $i ) + + $i = $i + 1 +endw + +print insert $rowNum finished + +$x = 0 +show4: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 +print dnode5 openVnodes $data2_5 + +if $data2_2 != 1 then + goto show4 +endi +if $data2_3 != null then + goto show4 +endi +if $data2_4 != 1 then + goto show4 +endi + +system sh/exec.sh -n dnode3 -s stop -x SIGINT + +print ========== step5 +sql select count(*) from d1.t1 +print select count(*) from d1.t1 ==> $data00 +if $data00 != $rowNum then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/m2.sim b/tests/script/unique/dnode/m2.sim new file mode 100644 index 0000000000000000000000000000000000000000..5fdf3b740081e74024f02616483af2c943d47eb9 --- /dev/null +++ b/tests/script/unique/dnode/m2.sim @@ -0,0 +1,367 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/deploy.sh -n dnode5 -i 5 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode5 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode5 -c mnodeEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode5 -c maxTablesPerVnode -v 4 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create dnode $hostname2 +sql create dnode $hostname3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 + +if $data4_1 != ready then + goto step1 +endi +if $data4_2 != ready then + goto step1 +endi +if $data4_3 != ready then + goto step1 +endi + +print ========== step2 + +sql create database d1 replica 2 +sql create table d1.t1 (t timestamp, i int) +sql insert into d1.t1 values(now+1s, 15) +sql insert into d1.t1 values(now+2s, 14) +sql insert into d1.t1 values(now+3s, 13) +sql insert into d1.t1 values(now+4s, 12) +sql insert into d1.t1 values(now+5s, 11) + +sql create database d2 replica 2 +sql create table d2.t2 (t timestamp, i int) +sql insert into d2.t2 values(now+1s, 25) +sql insert into d2.t2 values(now+2s, 24) +sql insert into d2.t2 values(now+3s, 23) +sql insert into d2.t2 values(now+4s, 22) +sql insert into d2.t2 values(now+5s, 21) + +sql create database d3 replica 2 +sql create table d3.t3 (t timestamp, i int) +sql insert into d3.t3 values(now+1s, 35) +sql insert into d3.t3 values(now+2s, 34) +sql insert into d3.t3 values(now+3s, 33) +sql insert into d3.t3 values(now+4s, 32) +sql insert into d3.t3 values(now+5s, 31) + +sql create database d4 replica 2 +sql create table d4.t4 (t timestamp, i int) +sql insert into d4.t4 values(now+1s, 45) +sql insert into d4.t4 values(now+2s, 44) +sql insert into d4.t4 values(now+3s, 43) +sql insert into d4.t4 values(now+4s, 42) +sql insert into d4.t4 values(now+5s, 41) + +print ========== step2.1 + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 + +if $data2_1 != 0 then + return -1 +endi +if $data2_2 != 4 then + return -1 +endi +if $data2_3 != 4 then + return -1 +endi + +sql show d1.vgroups; +print d1.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d2.vgroups; +print d2.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d3.vgroups; +print d3.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d4.vgroups; +print d4.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +print ========== step3 +sql create dnode $hostname4 +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname5 +system sh/exec.sh -n dnode5 -s start + + +$x = 0 +show3: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 +print dnode5 openVnodes $data2_5 + +if $data2_2 != 2 then + goto show3 +endi +if $data2_3 != 2 then + goto show3 +endi +if $data2_4 != 2 then + goto show3 +endi +if $data2_5 != 2 then + goto show3 +endi + +sql show d1.vgroups; +print d1.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data03 != 2 then + goto show3 +endi + +sql show d2.vgroups; +print d2.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data03 != 2 then + goto show3 +endi + +sql show d3.vgroups; +print d3.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data03 != 2 then + goto show3 +endi + +sql show d4.vgroups; +print d4.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data03 != 2 then + goto show3 +endi + +print ========== step4 +sql drop dnode $hostname2 + +$x = 0 +show4: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 +print dnode5 openVnodes $data2_5 + +if $data2_2 != null then + goto show4 +endi + +sql show d1.vgroups; +print d1.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data03 != 2 then + goto show4 +endi + +sql show d2.vgroups; +print d2.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data03 != 2 then + goto show4 +endi + +sql show d3.vgroups; +print d3.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data03 != 2 then + goto show4 +endi + +sql show d4.vgroups; +print d4.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data03 != 2 then + goto show4 +endi + +sql reset query cache +sleep 100 +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +print ========== step5 +sql drop dnode $hostname3 + +$x = 0 +show5: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 +print dnode5 openVnodes $data2_5 + +if $data2_2 != null then + goto show5 +endi +if $data2_3 != null then + goto show5 +endi +if $data2_4 != 4 then + goto show5 +endi +if $data2_5 != 4 then + goto show4 +endi + +sql show d1.vgroups; +print d1.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data03 != 2 then + goto show5 +endi + +sql show d2.vgroups; +print d2.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data03 != 2 then + goto show5 +endi + +sql show d3.vgroups; +print d3.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data03 != 2 then + goto show5 +endi + +sql show d4.vgroups; +print d4.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data03 != 2 then + goto show5 +endi + +sql reset query cache +sleep 100 +system sh/exec.sh -n dnode3 -s stop -x SIGINT + +print ========== step6 +sql select * from d1.t1 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 11 then + return -1 +endi +if $data11 != 12 then + return -1 +endi +if $data21 != 13 then + return -1 +endi +if $data31 != 14 then + return -1 +endi +if $data41 != 15 then + return -1 +endi + +sql select * from d2.t2 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 21 then + return -1 +endi +if $data11 != 22 then + return -1 +endi +if $data21 != 23 then + return -1 +endi +if $data31 != 24 then + return -1 +endi +if $data41 != 25 then + return -1 +endi + +sql select * from d3.t3 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 31 then + return -1 +endi +if $data11 != 32 then + return -1 +endi +if $data21 != 33 then + return -1 +endi +if $data31 != 34 then + return -1 +endi +if $data41 != 35 then + return -1 +endi + +sql select * from d4.t4 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 41 then + return -1 +endi +if $data11 != 42 then + return -1 +endi +if $data21 != 43 then + return -1 +endi +if $data31 != 44 then + return -1 +endi +if $data41 != 45 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/m3.sim b/tests/script/unique/dnode/m3.sim new file mode 100644 index 0000000000000000000000000000000000000000..5850147d045d4e58fc8b700bcbb7d70318f0420a --- /dev/null +++ b/tests/script/unique/dnode/m3.sim @@ -0,0 +1,359 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/deploy.sh -n dnode5 -i 5 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode5 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode5 -c mnodeEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode5 -c maxTablesPerVnode -v 4 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create dnode $hostname2 +sql create dnode $hostname3 +sql create dnode $hostname4 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 +print dnode4 $data4_4 + +if $data4_1 != ready then + goto step1 +endi +if $data4_2 != ready then + goto step1 +endi +if $data4_3 != ready then + goto step1 +endi +if $data4_4 != ready then + goto step1 +endi + +print ========== step2 + +sql create database d1 replica 3 +sql create table d1.t1 (t timestamp, i int) +sql insert into d1.t1 values(now+1s, 15) +sql insert into d1.t1 values(now+2s, 14) +sql insert into d1.t1 values(now+3s, 13) +sql insert into d1.t1 values(now+4s, 12) +sql insert into d1.t1 values(now+5s, 11) + +sql create database d2 replica 3 +sql create table d2.t2 (t timestamp, i int) +sql insert into d2.t2 values(now+1s, 25) +sql insert into d2.t2 values(now+2s, 24) +sql insert into d2.t2 values(now+3s, 23) +sql insert into d2.t2 values(now+4s, 22) +sql insert into d2.t2 values(now+5s, 21) + +sql create database d3 replica 3 +sql create table d3.t3 (t timestamp, i int) +sql insert into d3.t3 values(now+1s, 35) +sql insert into d3.t3 values(now+2s, 34) +sql insert into d3.t3 values(now+3s, 33) +sql insert into d3.t3 values(now+4s, 32) +sql insert into d3.t3 values(now+5s, 31) + +sql create database d4 replica 3 +sql create table d4.t4 (t timestamp, i int) +sql insert into d4.t4 values(now+1s, 45) +sql insert into d4.t4 values(now+2s, 44) +sql insert into d4.t4 values(now+3s, 43) +sql insert into d4.t4 values(now+4s, 42) +sql insert into d4.t4 values(now+5s, 41) + +print ========== step2.1 + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 + +if $data2_1 != 0 then + return -1 +endi +if $data2_2 != 4 then + return -1 +endi +if $data2_3 != 4 then + return -1 +endi +if $data2_4 != 4 then + return -1 +endi + +sql show d1.vgroups; +print d1.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data04 != 4 then + return -1 +endi + +sql show d2.vgroups; +print d2.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data04 != 3 then + return -1 +endi + +sql show d3.vgroups; +print d3.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data04 != 2 then + return -1 +endi + +sql show d4.vgroups; +print d4.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data04 != 4 then + return -1 +endi + +print ========== step3 +sql create dnode $hostname5 +system sh/exec.sh -n dnode5 -s start + +$x = 0 +show3: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 +print dnode5 openVnodes $data2_5 + +if $data2_2 != 3 then + goto show3 +endi +if $data2_3 != 3 then + goto show3 +endi +if $data2_4 != 3 then + goto show3 +endi +if $data2_5 != 3 then + goto show3 +endi + +sql show d1.vgroups; +print d1.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data04 != 5 then + return -1 +endi +if $data03 != 3 then + goto show3 +endi + +sql show d2.vgroups; +print d2.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data04 != 5 then + return -1 +endi +if $data03 != 3 then + goto show3 +endi + +sql show d3.vgroups; +print d3.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data04 != 2 then + return -1 +endi +if $data03 != 3 then + goto show3 +endi + +sql show d4.vgroups; +print d4.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data04 != 4 then + return -1 +endi +if $data03 != 3 then + goto show3 +endi + +print ========== step4 +sql drop dnode $hostname2 + +$x = 0 +show4: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 +print dnode5 openVnodes $data2_5 + +if $data2_2 != null then + goto show4 +endi +if $data2_3 != 4 then + goto show4 +endi +if $data2_4 != 4 then + goto show4 +endi +if $data2_5 != 4 then + goto show4 +endi + +sql show d1.vgroups; +print d1.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data04 != 5 then + return -1 +endi +if $data03 != 3 then + goto show4 +endi + +sql show d2.vgroups; +print d2.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data04 != 3 then + return -1 +endi +if $data03 != 3 then + goto show4 +endi + +sql show d3.vgroups; +print d3.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data04 != 4 then + return -1 +endi +if $data03 != 3 then + goto show4 +endi + +sql show d4.vgroups; +print d4.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data04 != 4 then + return -1 +endi +if $data03 != 3 then + goto show4 +endi + +sql reset query cache +sleep 100 + +print ========== step5 +sql select * from d1.t1 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 11 then + return -1 +endi +if $data11 != 12 then + return -1 +endi +if $data21 != 13 then + return -1 +endi +if $data31 != 14 then + return -1 +endi +if $data41 != 15 then + return -1 +endi + +sql select * from d2.t2 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 21 then + return -1 +endi +if $data11 != 22 then + return -1 +endi +if $data21 != 23 then + return -1 +endi +if $data31 != 24 then + return -1 +endi +if $data41 != 25 then + return -1 +endi + +sql select * from d3.t3 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 31 then + return -1 +endi +if $data11 != 32 then + return -1 +endi +if $data21 != 33 then + return -1 +endi +if $data31 != 34 then + return -1 +endi +if $data41 != 35 then + return -1 +endi + +sql select * from d4.t4 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 41 then + return -1 +endi +if $data11 != 42 then + return -1 +endi +if $data21 != 43 then + return -1 +endi +if $data31 != 44 then + return -1 +endi +if $data41 != 45 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/monitor.sim b/tests/script/unique/dnode/monitor.sim new file mode 100644 index 0000000000000000000000000000000000000000..0b41a4137ca74046b24e84fb6202279f45eaa578 --- /dev/null +++ b/tests/script/unique/dnode/monitor.sim @@ -0,0 +1,92 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 + +system sh/cfg.sh -n dnode1 -c wallevel -v 1 +system sh/cfg.sh -n dnode2 -c wallevel -v 1 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 + +system sh/cfg.sh -n dnode1 -c minTablesPerVnode -v 10 +system sh/cfg.sh -n dnode2 -c minTablesPerVnode -v 10 +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 10 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 10 + +system sh/cfg.sh -n dnode1 -c monitor -v 1 +system sh/cfg.sh -n dnode2 -c monitor -v 1 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect +sleep 3000 + +sql show dnodes +print dnode1 openVnodes $data3_1 +if $data2_1 != 0 then + return -1 +endi + +print ========== step2 +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start + +sleep 10000 +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +if $data2_1 != 0 then + return -1 +endi +if $data2_2 != 1 then + return -1 +endi + +print ========== step3 +sql show log.tables + +print $data00 +print $data10 +print $data20 +print $data30 +print $data40 +print $data50 + +if $rows > 6 then + return -1 +endi + +print ========== step4 +sql select * from log.dn1 +print $rows +$rows1 = $rows + +sleep 2000 +sql select * from log.dn1 +print $rows +$rows2 = $rows + +if $rows2 <= $rows1 then + return -1 +endi + +print ========== step5 +sql select * from log.dn2 +print $rows +$rows1 = $rows + +sleep 2000 +sql select * from log.dn2 +print $rows +$rows2 = $rows + +if $rows2 <= $rows1 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT diff --git a/tests/script/unique/dnode/monitor_bug.sim b/tests/script/unique/dnode/monitor_bug.sim new file mode 100644 index 0000000000000000000000000000000000000000..60c6524d9ce70c549cbea2964768888bf0d72fcb --- /dev/null +++ b/tests/script/unique/dnode/monitor_bug.sim @@ -0,0 +1,77 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c wallevel -v 1 +system sh/cfg.sh -n dnode2 -c wallevel -v 1 + +system sh/cfg.sh -n dnode1 -c monitor -v 1 +system sh/cfg.sh -n dnode2 -c monitor -v 0 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect +sleep 3000 + +sql show dnodes +print dnode1 openVnodes $data2_1 +if $data2_1 > 2 then + return -1 +endi + +print ========== step2 +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +if $data2_1 != 0 then + goto show2 +endi +if $data2_2 > 2 then + goto show2 +endi + +print ========== step3 +sql show log.tables + +print $data00 +print $data10 +print $data20 +print $data30 +print $data40 +print $data50 + +if $rows > 5 then + return -1 +endi + +print ========== step4 +sql select * from log.dn1 +print $rows +$rows1 = $rows + +sleep 2000 +sql select * from log.dn1 +print $rows +$rows2 = $rows + +if $rows2 <= $rows1 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/offline1.sim b/tests/script/unique/dnode/offline1.sim new file mode 100644 index 0000000000000000000000000000000000000000..9bbd14cf07891583711f8298c09da24d9fae4df4 --- /dev/null +++ b/tests/script/unique/dnode/offline1.sim @@ -0,0 +1,77 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 + +system sh/cfg.sh -n dnode1 -c offlineThreshold -v 10 +system sh/cfg.sh -n dnode2 -c offlineThreshold -v 10 +system sh/cfg.sh -n dnode3 -c offlineThreshold -v 10 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 5 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 5 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 5 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c wallevel -v 1 +system sh/cfg.sh -n dnode2 -c wallevel -v 1 +system sh/cfg.sh -n dnode3 -c wallevel -v 1 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start +sleep 2000 + +sql show dnodes +print dnode1 $data4_1 +print dnode1 $data4_2 + +if $data4_1 != ready then + return -1 +endi +if $data4_2 != ready then + return -1 +endi + +print ========== step2 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 8000 + +sql show dnodes +print dnode1 $data4_1 +print dnode1 $data4_2 + +if $data4_1 != ready then + return -1 +endi +if $data4_2 == ready then + return -1 +endi + +print ========== step3 +sleep 10000 + +sql show dnodes +print dnode1 $data4_1 +print dnode1 $data4_2 + +if $data4_1 != ready then + return -1 +endi +if $data4_2 != null then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/offline2.sim b/tests/script/unique/dnode/offline2.sim new file mode 100644 index 0000000000000000000000000000000000000000..711488cf3f4dc2aebd1980c6615291b0e88dc825 --- /dev/null +++ b/tests/script/unique/dnode/offline2.sim @@ -0,0 +1,126 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 + +system sh/cfg.sh -n dnode1 -c offlineThreshold -v 10 +system sh/cfg.sh -n dnode2 -c offlineThreshold -v 10 +system sh/cfg.sh -n dnode3 -c offlineThreshold -v 10 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 5 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 5 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 5 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 + + +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4 + + +system sh/cfg.sh -n dnode1 -c wallevel -v 1 +system sh/cfg.sh -n dnode2 -c wallevel -v 1 +system sh/cfg.sh -n dnode3 -c wallevel -v 1 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start +sleep 2000 + +sql create database d1 replica 2 +sql create table d1.t1(ts timestamp, i int) +sql insert into d1.t1 values(1588262400001, 1) + +sql show dnodes +print dnode1 $data4_1 +print dnode1 $data4_2 + +if $data4_1 != ready then + return -1 +endi +if $data4_2 != ready then + return -1 +endi + +print ========== step2 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 8000 + +sql show dnodes +print dnode1 $data4_1 +print dnode1 $data4_2 + +if $data4_1 != ready then + return -1 +endi +if $data4_2 == ready then + return -1 +endi + +print ========== step3 +sleep 10000 + +sql show dnodes +print dnode1 $data4_1 +print dnode1 $data4_2 + +if $data4_1 != ready then + return -1 +endi +if $data4_2 != dropping then + return -1 +endi + +print ========== step4 +sql create dnode $hostname3 +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode2 -s start +sql drop dnode $hostname2 + +sleep 3000 +$x = 0 +show4: + $x = $x + 1 + sleep 3000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 +if $data4_1 != ready then + goto show4 +endi +if $data4_2 != null then + goto show4 +endi +if $data4_3 != ready then + goto show4 +endi + +print ======================== step5 +sql reset query cache +sleep 1000 + +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/offline3.sim b/tests/script/unique/dnode/offline3.sim new file mode 100644 index 0000000000000000000000000000000000000000..93c75e3b13333d55aea7cb2417413a14a1c13e62 --- /dev/null +++ b/tests/script/unique/dnode/offline3.sim @@ -0,0 +1,111 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c offlineThreshold -v 3 +system sh/cfg.sh -n dnode2 -c offlineThreshold -v 3 +system sh/cfg.sh -n dnode3 -c offlineThreshold -v 3 +system sh/cfg.sh -n dnode4 -c offlineThreshold -v 3 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 300 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 300 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 300 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 300 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start +sql create dnode $hostname3 +system sh/exec.sh -n dnode3 -s start +sql create dnode $hostname4 +system sh/exec.sh -n dnode4 -s start + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 +print dnode4 $data4_4 + +if $data4_1 != ready then + goto step1 +endi +if $data4_2 != ready then + goto step1 +endi +if $data4_3 != ready then + goto step1 +endi +if $data4_4 != ready then + goto step1 +endi + +sql show mnodes +print mnode1 $data2_1 +if $data2_1 != master then + goto step1 +endi + +print ========== step2 +sql create database db replica 3 +sql use db +sql create table tb (ts timestamp, value int) +sql insert into tb values (now, 1) +sql insert into tb values (now, 2) + +sql show vgroups; +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +print ========== step2 +system sh/exec.sh -n dnode4 -s stop -x SIGINT + +$x = 0 +step2: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show vgroups; +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 +print dnode4 $data4_4 + +if $data4_1 != ready then + goto step2 +endi +if $data4_2 != ready then + goto step2 +endi +if $data4_3 != ready then + goto step2 +endi +if $data4_4 != null then + goto step2 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/reason.sim b/tests/script/unique/dnode/reason.sim new file mode 100644 index 0000000000000000000000000000000000000000..c685b1129d924131d38e60369d97924250b3ad66 --- /dev/null +++ b/tests/script/unique/dnode/reason.sim @@ -0,0 +1,203 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode $hostname2 + +sql show dnodes +print dnode1 off: $data7_1 +print dnode2 off: $data7_2 +if $data7_2 != @status not received@ then + return -1 +endi + +print ========== step2 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 + +if $data4_1 != ready then + goto step1 +endi +if $data4_2 != ready then + goto step1 +endi + +print ========== step3 +system sh/exec.sh -n dnode2 -s stop + +$x = 0 +step3: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi +sql show dnodes +print dnode1 off: $data7_1 +print dnode2 off: $data7_2 +if $data7_2 != @status msg timeout@ then + goto step3 +endi + +print ========== step4 +sql drop dnode $hostname2 +$x = 0 +step4: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +if $rows != 1 then + goto step4 +endi + +print ========== step5 +system sh/exec.sh -n dnode2 -s start +sql create dnode $hostname2 + +$x = 0 +step5: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 off: $data7_1 +print dnode2 off: $data7_3 +if $data7_3 != @dnodeId not match@ then + goto step5 +endi + +print ========== step6 +system sh/deploy.sh -n dnode4 -i 4 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 3 +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname4 + +$x = 0 +step6: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 off: $data7_1 +print dnode4 off: $data7_4 +if $data7_4 != @mnEqualVn not match@ then + goto step6 +endi + +print ========== step7 +system sh/deploy.sh -n dnode5 -i 5 +system sh/cfg.sh -n dnode5 -c statusInterval -v 3 +system sh/exec.sh -n dnode5 -s start +sql create dnode $hostname5 + +$x = 0 +step7: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 off: $data7_1 +print dnode5 off: $data7_5 +if $data7_5 != @interval not match@ then + goto step7 +endi + +print ========== step8 +system sh/deploy.sh -n dnode6 -i 6 +system sh/cfg.sh -n dnode6 -c balance -v 0 +system sh/exec.sh -n dnode6 -s start +sql create dnode $hostname6 + +$x = 0 +step8: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 off: $data7_1 +print dnode6 off: $data7_6 +if $data7_6 != @balance not match@ then + goto step8 +endi + +print ========== step9 +system sh/deploy.sh -n dnode7 -i 7 +system sh/cfg.sh -n dnode7 -c maxTablesPerVnode -v 3000 +system sh/exec.sh -n dnode7 -s start +sql create dnode $hostname7 + +$x = 0 +step9: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 off: $data7_1 +print dnode7 off: $data7_7 +if $data7_7 != @maxTabPerVn not match@ then + goto step9 +endi + +print ========== step10 +system sh/deploy.sh -n dnode8 -i 8 +system sh/cfg.sh -n dnode8 -c maxVgroupsPerDb -v 3 +system sh/exec.sh -n dnode8 -s start +sql create dnode $hostname8 + +$x = 0 +step10: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 off: $data7_1 +print dnode8 off: $data7_8 +if $data7_8 != @maxVgPerDb not match@ then + goto step10 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/remove1.sim b/tests/script/unique/dnode/remove1.sim new file mode 100644 index 0000000000000000000000000000000000000000..25e0846129da4dfed1ffcafa9815d16848771ad7 --- /dev/null +++ b/tests/script/unique/dnode/remove1.sim @@ -0,0 +1,227 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c wallevel -v 1 +system sh/cfg.sh -n dnode2 -c wallevel -v 1 +system sh/cfg.sh -n dnode3 -c wallevel -v 1 +system sh/cfg.sh -n dnode4 -c wallevel -v 1 + +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create database d1 +sql create table d1.t1 (t timestamp, i int) +sql insert into d1.t1 values(now+1s, 15) +sql insert into d1.t1 values(now+2s, 14) +sql insert into d1.t1 values(now+3s, 13) +sql insert into d1.t1 values(now+4s, 12) +sql insert into d1.t1 values(now+5s, 11) + +sql create database d2 +sql create table d2.t2 (t timestamp, i int) +sql insert into d2.t2 values(now+1s, 25) +sql insert into d2.t2 values(now+2s, 24) +sql insert into d2.t2 values(now+3s, 23) +sql insert into d2.t2 values(now+4s, 22) +sql insert into d2.t2 values(now+5s, 21) + +sql show dnodes +print dnode1 openVnodes $data2_1 +if $data2_1 != 2 then + return -1 +endi + +print ========== step2 +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start +$x = 0 +step2: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 +print dnode4 $data4_4 + +if $data4_1 != ready then + goto step2 +endi +if $data4_2 != ready then + goto step2 +endi + +sql create database d3 replica 2 +sql create table d3.t3 (t timestamp, i int) +sql insert into d3.t3 values(now+1s, 35) +sql insert into d3.t3 values(now+2s, 34) +sql insert into d3.t3 values(now+3s, 33) +sql insert into d3.t3 values(now+4s, 32) +sql insert into d3.t3 values(now+5s, 31) + +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +if $data2_1 != 1 then + goto show2 +endi +if $data2_2 != 3 then + goto show2 +endi + +print ========== step3 + +$x = 0 +show3: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 + +print ========== step4 +sql create dnode $hostname3 +system sh/exec.sh -n dnode3 -s start +sql drop dnode $hostname2 + +$x = 0 +show4: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +if $data2_2 != null then + goto show4 +endi + +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +print ========== step5 +sql create dnode $hostname4 +system sh/exec.sh -n dnode4 -s start + +$x = 0 +show5: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 +if $data2_1 != 0 then + goto show5 +endi +if $data2_2 != null then + goto show5 +endi +if $data2_3 != 2 then + goto show5 +endi +if $data2_4 != 2 then + goto show5 +endi + +print ========== step6 +sql select * from d1.t1 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 11 then + return -1 +endi +if $data11 != 12 then + return -1 +endi +if $data21 != 13 then + return -1 +endi +if $data31 != 14 then + return -1 +endi +if $data41 != 15 then + return -1 +endi + +sql select * from d2.t2 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 21 then + return -1 +endi +if $data11 != 22 then + return -1 +endi +if $data21 != 23 then + return -1 +endi +if $data31 != 24 then + return -1 +endi +if $data41 != 25 then + return -1 +endi + +sql select * from d3.t3 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 31 then + return -1 +endi +if $data11 != 32 then + return -1 +endi +if $data21 != 33 then + return -1 +endi +if $data31 != 34 then + return -1 +endi +if $data41 != 35 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT diff --git a/tests/script/unique/dnode/remove2.sim b/tests/script/unique/dnode/remove2.sim new file mode 100644 index 0000000000000000000000000000000000000000..1d707bc4a319ce0dbc5bd66b9cff52318c25aa8d --- /dev/null +++ b/tests/script/unique/dnode/remove2.sim @@ -0,0 +1,204 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/cfg.sh -n dnode2 -c wallevel -v 2 +system sh/cfg.sh -n dnode3 -c wallevel -v 2 +system sh/cfg.sh -n dnode4 -c wallevel -v 2 + +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create database d1 +sql create table d1.t1 (t timestamp, i int) +sql insert into d1.t1 values(1588262400001, 15) +sql insert into d1.t1 values(1588262400002, 14) +sql insert into d1.t1 values(1588262400003, 13) +sql insert into d1.t1 values(1588262400004, 12) +sql insert into d1.t1 values(1588262400005, 11) + +sql create database d2 +sql create table d2.t2 (t timestamp, i int) +sql insert into d2.t2 values(1588262400001, 25) +sql insert into d2.t2 values(1588262400002, 24) +sql insert into d2.t2 values(1588262400003, 23) +sql insert into d2.t2 values(1588262400004, 22) +sql insert into d2.t2 values(1588262400005, 21) + +sql show dnodes +print dnode1 openVnodes $data2_1 +if $data2_1 != 2 then + return -1 +endi + +print ========== step2 +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start +$x = 0 +step2: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 +print dnode4 $data4_4 + +if $data4_1 != ready then + goto step2 +endi +if $data4_2 != ready then + goto step2 +endi + +sql create database d3 replica 2 +sql create table d3.t3 (t timestamp, i int) +sql insert into d3.t3 values(1588262400001, 35) +sql insert into d3.t3 values(1588262400002, 34) +sql insert into d3.t3 values(1588262400003, 33) +sql insert into d3.t3 values(1588262400004, 32) +sql insert into d3.t3 values(1588262400005, 31) + +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +if $data2_1 != 1 then + goto show2 +endi +if $data2_2 != 3 then + goto show2 +endi + +print ========== step3 +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 + +print ========== step4 +sql create dnode $hostname3 +system sh/exec.sh -n dnode3 -s start + +$x = 0 +step4: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +# wait dnode3 create first vgroup in dnode-status msg +if $data2_3 != 1 then + goto step4 +endi + +print ============ step 4.1 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +step4.1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 +print dnode4 $data4_4 + +if $data4_2 != ready then + goto step4.1 +endi + +sql drop dnode $hostname2 + +$x = 0 +show4: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +if $data2_1 != 1 then + goto show4 +endi +if $data2_2 != null then + goto show4 +endi +if $data2_3 != 3 then + goto show4 +endi + +print ========== step5 +sql select * from d1.t1 order by t desc +print $data01 $data11 $data21 $data31 $data41 + +sql select * from d2.t2 order by t desc +print $data01 $data11 $data21 $data31 $data41 + +sql select * from d3.t3 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 31 then + return -1 +endi +if $data11 != 32 then + return -1 +endi +if $data21 != 33 then + return -1 +endi +if $data31 != 34 then + return -1 +endi +if $data41 != 35 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT diff --git a/tests/script/unique/dnode/simple.sim b/tests/script/unique/dnode/simple.sim new file mode 100644 index 0000000000000000000000000000000000000000..38d8c08d75b4201fd4375afe50a83d8757ac0120 --- /dev/null +++ b/tests/script/unique/dnode/simple.sim @@ -0,0 +1,147 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start +sql create dnode $hostname3 +system sh/exec.sh -n dnode3 -s start +sleep 2000 + +sql create database d1 replica 2 +sql create table d1.t1 (t timestamp, i int) +sql insert into d1.t1 values(now+1s, 15) +sql insert into d1.t1 values(now+2s, 14) +sql insert into d1.t1 values(now+3s, 13) +sql insert into d1.t1 values(now+4s, 12) +sql insert into d1.t1 values(now+5s, 11) + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 +if $data2_1 != 0 then + return -1 +endi +if $data2_2 != 1 then + return -1 +endi +if $data2_3 != 1 then + return -1 +endi +if $data2_4 != null then + return -1 +endi + +print ========== step2 +sql create dnode $hostname4 +system sh/exec.sh -n dnode4 -s start +sleep 2000 + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 +if $data2_1 != 0 then + return -1 +endi +if $data2_2 != 1 then + return -1 +endi +if $data2_3 != 1 then + return -1 +endi +if $data2_4 != 0 then + return -1 +endi + +print ========== step3 +sql drop dnode $hostname2 + +$x = 0 +show3: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 +if $data2_1 != 0 then + goto show3 +endi +if $data2_2 != null then + goto show3 +endi +if $data2_3 != 1 then + goto show3 +endi +if $data2_4 != 1 then + goto show3 +endi + +print ========== step4 +sql drop dnode $hostname3 + +$x = 0 +show4: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 +if $data2_1 != 1 then + goto show4 +endi +if $data2_2 != null then + goto show4 +endi +if $data2_3 != null then + goto show4 +endi +if $data2_4 != 1 then + goto show4 +endi + +print ========== step5 +sql select * from d1.t1 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 11 then + return -1 +endi +if $data11 != 12 then + return -1 +endi +if $data21 != 13 then + return -1 +endi +if $data31 != 14 then + return -1 +endi +if $data41 != 15 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT diff --git a/tests/script/unique/dnode/testSuite.sim b/tests/script/unique/dnode/testSuite.sim new file mode 100644 index 0000000000000000000000000000000000000000..ecd43cc224136deaa615fb04f0e6c21fa8ee50d5 --- /dev/null +++ b/tests/script/unique/dnode/testSuite.sim @@ -0,0 +1,9 @@ +run unique/dnode/balance1.sim +run unique/dnode/balance2.sim +run unique/dnode/balance3.sim +run unique/dnode/balancex.sim +run unique/dnode/offline1.sim +run unique/dnode/offline2.sim +run unique/dnode/remove1.sim +run unique/dnode/remove2.sim +run unique/dnode/vnode_clean.sim diff --git a/tests/script/unique/dnode/vnode_clean.sim b/tests/script/unique/dnode/vnode_clean.sim new file mode 100644 index 0000000000000000000000000000000000000000..76311a6cacb2d2c06ff4125b689d3782c3e0dc98 --- /dev/null +++ b/tests/script/unique/dnode/vnode_clean.sim @@ -0,0 +1,311 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c wallevel -v 1 +system sh/cfg.sh -n dnode2 -c wallevel -v 1 +system sh/cfg.sh -n dnode3 -c wallevel -v 1 +system sh/cfg.sh -n dnode4 -c wallevel -v 1 + +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create database d1 +sql create table d1.t1 (t timestamp, i int) +sql insert into d1.t1 values(now+1s, 15) +sql insert into d1.t1 values(now+2s, 14) +sql insert into d1.t1 values(now+3s, 13) +sql insert into d1.t1 values(now+4s, 12) +sql insert into d1.t1 values(now+5s, 11) + +sql show dnodes +print dnode1 openVnodes $data2_1 +if $data2_1 != 1 then + return -1 +endi + +print ========== step2 +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +show2: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +if $data2_1 != 0 then + goto show2 +endi +if $data2_2 != 1 then + goto show2 +endi + +print ========== step3 +sql create database d2 + +sql create table d2.t2 (t timestamp, i int) +sql insert into d2.t2 values(now+1s, 25) +sql insert into d2.t2 values(now+2s, 24) +sql insert into d2.t2 values(now+3s, 23) +sql insert into d2.t2 values(now+4s, 22) +sql insert into d2.t2 values(now+5s, 21) + +$x = 0 +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +if $data2_1 != 0 then + return -1 +endi +if $data2_2 != 2 then + return -1 +endi + +print ========== step4 +sql drop dnode $hostname2 + +$x = 0 +show4: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_2 +if $data2_1 != 2 then + goto show4 +endi +if $data2_2 != null then + goto show4 +endi +if $rows != 1 then + goto show4 +endi + +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +print ========== step5 +sql create dnode $hostname3 +system sh/exec.sh -n dnode3 -s start + +$x = 0 +show5: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode3 openVnodes $data2_3 +if $data2_1 != 0 then + goto show5 +endi +if $data2_3 != 2 then + goto show5 +endi + +print ========== step6 +sql create database d3 +sql create table d3.t3 (t timestamp, i int) +sql insert into d3.t3 values(now+1s, 35) +sql insert into d3.t3 values(now+2s, 34) +sql insert into d3.t3 values(now+3s, 33) +sql insert into d3.t3 values(now+4s, 32) +sql insert into d3.t3 values(now+5s, 31) + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode2 openVnodes $data2_3 +if $data2_1 != 0 then + return -1 +endi +if $data2_3 != 3 then + return -1 +endi + +print ========== step7 +sql create dnode $hostname4 +system sh/exec.sh -n dnode4 -s start + +$x = 0 +show7: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 +if $data2_1 != 0 then + goto show7 +endi +if $data2_3 != 2 then + goto show7 +endi +if $data2_4 != 1 then + goto show7 +endi + +print ========== step8 +sql create database d4 +sql create table d4.t4 (t timestamp, i int) +sql insert into d4.t4 values(now+1s, 45) +sql insert into d4.t4 values(now+2s, 44) +sql insert into d4.t4 values(now+3s, 43) +sql insert into d4.t4 values(now+4s, 42) +sql insert into d4.t4 values(now+5s, 41) + +$x = 0 +show8: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 +if $data2_1 != 0 then + goto show8 +endi +if $data2_3 != 2 then + goto show8 +endi +if $data2_4 != 2 then + goto show8 +endi + +print ========== step9 +sql drop dnode $hostname3 + +$x = 0 +show9: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show dnodes +print dnode1 openVnodes $data2_1 +print dnode3 openVnodes $data2_3 +print dnode4 openVnodes $data2_4 +if $data2_1 != 0 then + goto show9 +endi +if $data2_3 != null then + goto show9 +endi +if $data2_4 != 4 then + goto show9 +endi + +system sh/exec.sh -n dnode3 -s stop + +print ========== step10 +sql select * from d1.t1 order by t desc +print $data01 $data11 $data21 $data31 $data41 order by t desc +if $data01 != 11 then + return -1 +endi +if $data11 != 12 then + return -1 +endi +if $data21 != 13 then + return -1 +endi +if $data31 != 14 then + return -1 +endi +if $data41 != 15 then + return -1 +endi + +sql select * from d2.t2 order by t desc +print $data01 $data11 $data21 $data31 $data41 order by t desc +if $data01 != 21 then + return -1 +endi +if $data11 != 22 then + return -1 +endi +if $data21 != 23 then + return -1 +endi +if $data31 != 24 then + return -1 +endi +if $data41 != 25 then + return -1 +endi + +sql select * from d3.t3 order by t desc +print $data01 $data11 $data21 $data31 $data41 order by t desc +if $data01 != 31 then + return -1 +endi +if $data11 != 32 then + return -1 +endi +if $data21 != 33 then + return -1 +endi +if $data31 != 34 then + return -1 +endi +if $data41 != 35 then + return -1 +endi + +sql select * from d4.t4 order by t desc +print $data01 $data11 $data21 $data31 $data41 order by t desc +if $data01 != 41 then + return -1 +endi +if $data11 != 42 then + return -1 +endi +if $data21 != 43 then + return -1 +endi +if $data31 != 44 then + return -1 +endi +if $data41 != 45 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/http/admin.sim b/tests/script/unique/http/admin.sim new file mode 100644 index 0000000000000000000000000000000000000000..ae206744c4e93ab7cebd5f4db7d8d4b84ad5ebbb --- /dev/null +++ b/tests/script/unique/http/admin.sim @@ -0,0 +1,192 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c http -v 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 0 +#system sh/cfg.sh -n dnode1 -c adminRowLimit -v 10 +system sh/cfg.sh -n dnode1 -c httpDebugFlag -v 135 +system sh/exec.sh -n dnode1 -s start + +sql connect +sleep 2000 + +print ============================ dnode1 start + +print =============== step0 - prepare data +sql create database d1 +sql use d1 + +sql create table table_admin (ts timestamp, i int) + +sql insert into table_admin values('2017-12-25 21:28:41.022', 1) +sql insert into table_admin values('2017-12-25 21:28:42.022', 2) +sql insert into table_admin values('2017-12-25 21:28:43.022', 3) +sql insert into table_admin values('2017-12-25 21:28:44.022', 4) +sql insert into table_admin values('2017-12-25 21:28:45.022', 5) +sql insert into table_admin values('2017-12-25 21:28:46.022', 6) +sql insert into table_admin values('2017-12-25 21:28:47.022', 7) +sql insert into table_admin values('2017-12-25 21:28:48.022', 8) +sql insert into table_admin values('2017-12-25 21:28:49.022', 9) +sql insert into table_admin values('2017-12-25 21:28:50.022', 10) + +print =============== step1 - login + +system_content curl 127.0.0.1:7111/admin/ +print 1-> $system_content +if $system_content != @{"status":"error","code":4357,"desc":"no auth info input"}@ then + print actual: $system_content + return -1 +endi + +system_content curl 127.0.0.1:7111/admin/xx +print 2-> $system_content +if $system_content != @{"status":"error","code":4357,"desc":"no auth info input"}@ then + return -1 +endi + +system_content curl 127.0.0.1:7111/admin/login +print 3-> $system_content +if $system_content != @{"status":"error","code":4357,"desc":"no auth info input"}@ then + return -1 +endi + +system_content curl 127.0.0.1:7111/admin/login/root +print 4-> $system_content +if $system_content != @{"status":"error","code":4357,"desc":"no auth info input"}@ then + return -1 +endi + +system_content curl 127.0.0.1:7111/admin/login/root/123 +print 5-> $system_content +if $system_content != @{"status":"error","code":3,"desc":"Authentication failure"}@ then + return -1 +endi + +system_content curl 127.0.0.1:7111/admin/login/root/123/1/1/3 +print 6-> $system_content +if $system_content != @{"status":"error","code":3,"desc":"Authentication failure"}@ then + return -1 +endi + +system_content curl -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.' -d 'show databases' 127.0.0.1:7111/admin/login/root/1 +print 7-> $system_content +if $system_content != @{"status":"error","code":4387,"desc":"invalid format of Authorization"}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ3d3cudGFvc2RhdGEuY29tIiwicGFzcyI6InRhb3NkYXRhIiwic3ViIjoicm9vdCJ9.xPv3b5odlR7YF8G_QWASjIRbMtA5v4ItToJ35fFgi' 127.0.0.1:7111/admin/login/root/1 +print 8-> $system_content +if $system_content != @{"status":"error","code":4387,"desc":"invalid format of Authorization"}@ then + return -1 +endi + +sleep 2000 +system_content curl 127.0.0.1:7111/admin/login/root/taosdata +print 9 -----> $system_content + +if $system_content != {"status":"succ","code":0,"desc":"/KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04"} then + return -1 +endi + +#system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'show databases' 127.0.0.1:7111/admin/login/root/1 +#print 10-> $system_content +#if $system_content != @{"status":"error","code":29,"desc":"failed to connect to server"}@ then +# return -1 +#endi + +print =============== step2 - logout + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' 127.0.0.1:7111/admin/logout +print 10 -----> $system_content + +if $system_content != @{"status":"succ","code":0,"desc":"logout success"}@ then + return -1 +endi + +system_content curl 127.0.0.1:7111/admin/logout +print 11 -----> $system_content + +if $system_content != @{"status":"error","code":4357,"desc":"no auth info input"}@ then + return -1 +endi + +print =============== step3 - info + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' 127.0.0.1:7111/admin/info +print curl 127.0.0.1:7111/admin/info -----> $system_content +if $system_content != {"status":"succ","data":[{"dbs":1,"tables":1,"users":3,"mnodes":1,"dnodes":1}]} then + return -1 +endi + +print =============== step4 - meta + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'show mnodes' 127.0.0.1:7111/admin/meta +print curl 127.0.0.1:7111/admin/meta -----> $system_content +#if $system_content != @{"status":"succ","head":["column type","column name","column bytes"],"data":[["binary","IP",16],["timestamp","created time",8],["binary","status",10],["binary","role",10],["binary","public ip",16]],"rows":5}@ then +# return -1 +#endi + +print =============== step5 - query data + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select * from d1.table_admin' 127.0.0.1:7111/admin/sql +print curl 127.0.0.1:7111/admin/all -----> $system_content +if $system_content != @{"status":"succ","head":["ts","i"],"data":[["2017-12-25 21:28:41.022",1],["2017-12-25 21:28:42.022",2],["2017-12-25 21:28:43.022",3],["2017-12-25 21:28:44.022",4],["2017-12-25 21:28:45.022",5],["2017-12-25 21:28:46.022",6],["2017-12-25 21:28:47.022",7],["2017-12-25 21:28:48.022",8],["2017-12-25 21:28:49.022",9],["2017-12-25 21:28:50.022",10]],"rows":10}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select * from d1.table_admin' 127.0.0.1:7111/admin/sql +print curl 127.0.0.1:7111/admin/sql -----> $system_content +if $system_content != @{"status":"succ","head":["ts","i"],"data":[["2017-12-25 21:28:41.022",1],["2017-12-25 21:28:42.022",2],["2017-12-25 21:28:43.022",3],["2017-12-25 21:28:44.022",4],["2017-12-25 21:28:45.022",5],["2017-12-25 21:28:46.022",6],["2017-12-25 21:28:47.022",7],["2017-12-25 21:28:48.022",8],["2017-12-25 21:28:49.022",9],["2017-12-25 21:28:50.022",10]],"rows":10}@ then + return -1 +endi + +print =============== step6 - insert data +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.table_admin values('2017-12-25 21:28:51.022', 11)" 127.0.0.1:7111/admin/sql +print curl 127.0.0.1:7111/admin/sql -----> $system_content +if $system_content != @{"status":"succ","head":["affect_rows"],"data":[[1]],"rows":1}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select * from d1.table_admin' 127.0.0.1:7111/admin/all +print curl 127.0.0.1:7111/admin/all -----> $system_content +if $system_content != @{"status":"succ","head":["ts","i"],"data":[["2017-12-25 21:28:41.022",1],["2017-12-25 21:28:42.022",2],["2017-12-25 21:28:43.022",3],["2017-12-25 21:28:44.022",4],["2017-12-25 21:28:45.022",5],["2017-12-25 21:28:46.022",6],["2017-12-25 21:28:47.022",7],["2017-12-25 21:28:48.022",8],["2017-12-25 21:28:49.022",9],["2017-12-25 21:28:50.022",10],["2017-12-25 21:28:51.022",11]],"rows":11}@ then + print actual: $system_content + print expect =======> {"status":"succ","head":["ts","i"],"data":[["2017-12-25 21:28:41.022",1],["2017-12-25 21:28:42.022",2],["2017-12-25 21:28:43.022",3],["2017-12-25 21:28:44.022",4],["2017-12-25 21:28:45.022",5],["2017-12-25 21:28:46.022",6],["2017-12-25 21:28:47.022",7],["2017-12-25 21:28:48.022",8],["2017-12-25 21:28:49.022",9],["2017-12-25 21:28:50.022",10],["2017-12-25 21:28:51.022",11]],"rows":11} + return -1 +endi + +#system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select * from d1.table_admin' 127.0.0.1:7111/admin/sql +#print curl 127.0.0.1:7111/admin/sql -----> $system_content +#if $system_content != @{"status":"succ","head":["ts","i"],"data":[["2017-12-25 21:28:51.022",11],["2017-12-25 21:28:50.022",10],["2017-12-25 21:28:49.022",9],["2017-12-25 21:28:48.022",8],["2017-12-25 21:28:47.022",7],["2017-12-25 21:28:46.022",6],["2017-12-25 21:28:45.022",5],["2017-12-25 21:28:44.022",4],["2017-12-25 21:28:43.022",3],["2017-12-25 21:28:42.022",2]],"rows":10}@ then +# return -1 +#endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' 127.0.0.1:7111/admin/info +print curl 127.0.0.1:7111/admin/info -----> $system_content +if $system_content != {"status":"succ","data":[{"dbs":1,"tables":1,"users":3,"mnodes":1,"dnodes":1}]} then + return -1 +endi + +print =============== step7 - use dbs + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'use d1;' 127.0.0.1:7111/admin/all +print 23-> $system_content +if $system_content != @{"status":"error","code":4360,"desc":"no need to execute use db cmd"}@ then + return -1 +endi + +print =============== step8 - monitor dbs +#system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'show dnodes;show mnodes;' 127.0.0.1:7111/admin/sqls +#print 24-> $system_content +#if $system_content != @[{"status":"succ","head":["IP","created time","open vnodes","free vnodes","status","balance state"],"data":[["127.0.0.1","2018-09-04 #11:16:13.985",1,3,"ready","balanced"]],"rows":1},{"status":"succ","head":["IP","created time","status","role"],"data":[["127.0.0.1","2018-09-04 11:16:13.371","serving","master"]],"rows":1}]@ then +# return -1 +# endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/http/opentsdb.sim b/tests/script/unique/http/opentsdb.sim new file mode 100644 index 0000000000000000000000000000000000000000..7d1e6b03d4547a6b0b2a6a7857000a8a6518a002 --- /dev/null +++ b/tests/script/unique/http/opentsdb.sim @@ -0,0 +1,247 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c http -v 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ============================ dnode1 start + +print =============== step1 - parse +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846400,"value": 18,"tags": {"host": "web01","group1": "1","dc": "lga"}}]' 127.0.0.1:7111/opentsdb/ +print $system_content +if $system_content != @{"status":"error","code":4496,"desc":"database name can not be null"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846400,"value": 18,"tags": {"host": "web01","group1": "1","dc": "lga"}}]' 127.0.0.1:7111/opentsdb/db123456789012345678901234567890db +print $system_content +if $system_content != @{"status":"error","code":4497,"desc":"database name too long"}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d '[{"metric": "sys_cpu","timestamp": 1346846400,"value": 18,"tags": {"host": "web01","group1": "1","dc": "lga"}}]' 127.0.0.1:7111/opentsdb/ +print $system_content +if $system_content != @{"status":"error","code":4496,"desc":"database name can not be null"}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d '[{"metric": "sys_cpu","timestamp": 1346846400,"value": 18,"tags": {"host": "web01","group1": "1","dc": "lga"}}]' 127.0.0.1:7111/opentsdb/db/put2 +print $system_content +if $system_content != @{"status":"error","code":4354,"desc":"invalid url format"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[]' 127.0.0.1:7111/opentsdb/db/put +print $system_content +if $system_content != @{"status":"error","code":4499,"desc":"metrics size is 0"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[' 127.0.0.1:7111/opentsdb/db/put +print $system_content +if $system_content != @{"status":"error","code":4498,"desc":"invalid opentsdb json fromat"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{}' 127.0.0.1:7111/opentsdb/db/put +print $system_content +if $system_content != @{"status":"error","code":4499,"desc":"metrics size is 0"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{}]' 127.0.0.1:7111/opentsdb/db/put +print $system_content + +if $system_content != @{"status":"error","code":4501,"desc":"metric name not find"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{"metric": 1,"timestamp": 1346846400,"value": 18,"tags": {"host": "web01","group1": "1","dc": "lga"}}]' 127.0.0.1:7111/opentsdb/db/put +print $system_content +if $system_content != @{"status":"error","code":4502,"desc":"metric name type should be string"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{"metric": "","timestamp": 1346846400,"value": 18,"tags": {"host": "web01","group1": "1","dc": "lga"}}]' 127.0.0.1:7111/opentsdb/db/put +print $system_content +if $system_content != @{"status":"error","code":4503,"desc":"metric name length is 0"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{"metric": "ab1234567890123456789012345678ab1234567890123456789012345678","timestamp": 1346846400,"value": 18,"tags": {"host": "web01","group1": "1","dc": "lga"}}]' 127.0.0.1:7111/opentsdb/db/put +print $system_content +if $system_content != @{"errors":[{"datapoint":{"metric":"ab1234567890123456789012345678ab1234567890123456789012345678","stable":"ab1234567890123456789012345678ab1234567890123456789012345678_d_bbb","table":"ab1234567890123456789012345678ab1234567890123456789012345678_d_bbb_lga_1_web01","timestamp":1346846400,"value":18.000000,"tags":{"dc":"lga","group1":"1","host":"web01"},"status":"error","code":1547,"desc":"Timestamp data out of range"}}],"failed":1,"success":0,"affected_rows":0}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","value": 18,"tags": {"host": "web01","group1": "1","dc": "lga"}}]' 127.0.0.1:7111/opentsdb/db/put +print $system_content +if $system_content != @{"status":"error","code":4505,"desc":"timestamp not find"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": "2","value": 18,"tags": {"host": "web01","group1": "1","dc": "lga"}}]' 127.0.0.1:7111/opentsdb/db/put +print $system_content +if $system_content != @{"status":"error","code":4506,"desc":"timestamp type should be integer"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": -1,"value": 18,"tags": {"host": "web01","group1": "1","dc": "lga"}}]' 127.0.0.1:7111/opentsdb/db/put +print $system_content +if $system_content != @{"status":"error","code":4507,"desc":"timestamp value smaller than 0"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846400,"tags": {"host": "web01","group1": "1","dc": "lga"}}]' 127.0.0.1:7111/opentsdb/db/put +print $system_content +if $system_content != @{"status":"error","code":4517,"desc":"value not find"}@ then + return -1 +endi + +####### + +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846400,"value": 18}]' 127.0.0.1:7111/opentsdb/db/put +print $system_content +if $system_content != @{"status":"error","code":4508,"desc":"tags not find"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846400,"value": 18,"tags": {}}]' 127.0.0.1:7111/opentsdb/db/put +print $system_content +if $system_content != @{"status":"error","code":4509,"desc":"tags size is 0"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846400,"value": 18,"tags": 0}]' 127.0.0.1:7111/opentsdb/db/put +print $system_content +if $system_content != @{"status":"error","code":4509,"desc":"tags size is 0"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846400,"value": 18,"tags": {"host": "web01","group1": "1","group1": "1","group1": "1","group1": "1","group1": "1","dc": "lga"}}]' 127.0.0.1:7111/opentsdb/db/put +print $system_content +if $system_content != @{"errors":[{"datapoint":{"metric":"sys_cpu","stable":"sys_cpu_d_bbbbbbb","table":"sys_cpu_d_bbbbbbb_lga_1_1_1_1_1_web01","timestamp":1346846400,"value":18.000000,"tags":{"dc":"lga","group1":"1","group1":"1","group1":"1","group1":"1","group1":"1","host":"web01"},"status":"error","code":866,"desc":"failed to create table"}}],"failed":1,"success":0,"affected_rows":0}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846400,"value": 18,"tags": {"": "web01"}}]' 127.0.0.1:7111/opentsdb/db/put +print $system_content +if $system_content != @{"status":"error","code":4512,"desc":"tag name is null"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846400,"value": 18,"tags": {"host01123456789001123456789001123456789001123456789001123456789001123456789": "01"}}]' 127.0.0.1:7111/opentsdb/db/put +print $system_content +if $system_content != @{"status":"error","code":4513,"desc":"tag name length too long"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846400,"value": 18,"tags": {"host": "web011234567890011234567890011234567890011234567890011234567890011234567890011234567890011234567890"}}]' 127.0.0.1:7111/opentsdb/db/put +print $system_content +if $system_content != @{"status":"error","code":4516,"desc":"tag value can not more than 64"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846400,"value": 18,"tags": {"host": ""}}]' 127.0.0.1:7111/opentsdb/db/put +print $system_content +if $system_content != @{"status":"error","code":4515,"desc":"tag value is null"}@ then + return -1 +endi + +sleep 2000 + +print =============== step2 - insert single data +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846400000,"value": 18,"tags": {"host": "web01","group1": "1","dc": "lga"}}]' 127.0.0.1:7111/opentsdb/db/put +print $system_content +if $system_content != @{"errors":[{"datapoint":{"metric":"sys_cpu","stable":"sys_cpu_d_bbb","table":"sys_cpu_d_bbb_lga_1_web01","timestamp":1346846400000,"value":18.000000,"tags":{"dc":"lga","group1":"1","host":"web01"},"affected_rows":1,"status":"succ"}}],"failed":0,"success":1,"affected_rows":1}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846400000,"value": 18,"tags": {"host": "web01","group1": "1","dc": "lga"}}]' 127.0.0.1:7111/opentsdb/db/put +print $system_content +if $system_content != @{"errors":[{"datapoint":{"metric":"sys_cpu","stable":"sys_cpu_d_bbb","table":"sys_cpu_d_bbb_lga_1_web01","timestamp":1346846400000,"value":18.000000,"tags":{"dc":"lga","group1":"1","host":"web01"},"affected_rows":1,"status":"succ"}}],"failed":0,"success":1,"affected_rows":1}@ then + return -1 +endi + +system_content curl -u root:taosdata -d 'select * from db.sys_cpu_d_bbb_lga_1_web01' 127.0.0.1:7111/rest/sql/ +print $system_content +if $system_content != @{"status":"succ","head":["ts","value"],"column_meta":[["ts",9,8],["value",7,8]],"data":[["2012-09-05 20:00:00.000",18.000000000]],"rows":1}@ then + return -1 +endi + +print =============== step3 - multi-query data +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846405000,"value": 18,"tags": {"host": "web01","group1": "1","dc": "lga"}},{"metric": "sys_cpu","timestamp": 1346846402000,"value": 18,"tags": {"host": "web02","group1": "1","dc": "lga"}}]' 127.0.0.1:7111/opentsdb/db/put + +print $system_content + +if $system_content != @{"errors":[{"datapoint":{"metric":"sys_cpu","stable":"sys_cpu_d_bbb","table":"sys_cpu_d_bbb_lga_1_web01","timestamp":1346846405000,"value":18.000000,"tags":{"dc":"lga","group1":"1","host":"web01"},"affected_rows":1,"status":"succ"}},{"datapoint":{"metric":"sys_cpu","stable":"sys_cpu_d_bbb","table":"sys_cpu_d_bbb_lga_1_web02","timestamp":1346846402000,"value":18.000000,"tags":{"dc":"lga","group1":"1","host":"web02"},"affected_rows":1,"status":"succ"}}],"failed":0,"success":2,"affected_rows":2}@ then + return -1 +endi + +system_content curl -u root:taosdata -d 'select * from db.sys_cpu_d_bbb_lga_1_web01' 127.0.0.1:7111/rest/sql/ + +print $system_content + +if $system_content != @{"status":"succ","head":["ts","value"],"column_meta":[["ts",9,8],["value",7,8]],"data":[["2012-09-05 20:00:00.000",18.000000000],["2012-09-05 20:00:05.000",18.000000000]],"rows":2}@ then + return -1 +endi + +system_content curl -u root:taosdata -d 'select count(*) from db.sys_cpu_d_bbb' 127.0.0.1:7111/rest/sql/ + +print $system_content + +if $system_content != @{"status":"succ","head":["count(*)"],"column_meta":[["count(*)",5,8]],"data":[[3]],"rows":1}@ then + return -1 +endi + +print =============== step4 - summary-put data +system_content curl -u root:taosdata -d '[{"metric": "sys_mem","timestamp": 1346846400000,"value": 8,"tags": {"host": "web01","group1": "1","dc": "lga"}},{"metric": "sys_mem","timestamp": 1346846405000,"value": 9,"tags": {"host": "web01","group1": "1","dc": "lga"}}]' 127.0.0.1:7111/opentsdb/db/put?details=false + +print $system_content + +if $system_content != @{"failed":0,"success":2}@ then + return -1 +endi + +system_content curl -u root:taosdata -d 'select * from db.sys_mem_d_bbb_lga_1_web01' 127.0.0.1:7111/rest/sql/ + +print $system_content + +if $system_content != @{"status":"succ","head":["ts","value"],"column_meta":[["ts",9,8],["value",7,8]],"data":[["2012-09-05 20:00:00.000",8.000000000],["2012-09-05 20:00:05.000",9.000000000]],"rows":2}@ then + return -1 +endi + +system_content curl -u root:taosdata -d 'select count(*) from db.sys_mem_d_bbb' 127.0.0.1:7111/rest/sql/ + +print $system_content + +if $system_content != @{"status":"succ","head":["count(*)"],"column_meta":[["count(*)",5,8]],"data":[[2]],"rows":1}@ then + return -1 +endi + +print =============== step5 - prepare data + +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846402000,"value": 19,"tags": {"host": "web01","group1": "1","dc": "lga"}},{"metric": "sys_cpu","timestamp": 1346846402,"value": 19,"tags": {"host": "web02","group1": "1","dc": "lga"}}]' 127.0.0.1:7111/opentsdb/db/put +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846403000,"value": 20,"tags": {"host": "web01","group1": "1","dc": "lga"}},{"metric": "sys_cpu","timestamp": 1346846403,"value": 20,"tags": {"host": "web02","group1": "1","dc": "lga"}}]' 127.0.0.1:7111/opentsdb/db/put +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846404000,"value": 21,"tags": {"host": "web01","group1": "1","dc": "lga"}},{"metric": "sys_cpu","timestamp": 1346846404,"value": 21,"tags": {"host": "web02","group1": "1","dc": "lga"}}]' 127.0.0.1:7111/opentsdb/db/put +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846405000,"value": 22,"tags": {"host": "web01","group1": "1","dc": "lga"}},{"metric": "sys_cpu","timestamp": 1346846405,"value": 22,"tags": {"host": "web02","group1": "1","dc": "lga"}}]' 127.0.0.1:7111/opentsdb/db/put +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846406000,"value": 23,"tags": {"host": "web01","group1": "1","dc": "lga"}},{"metric": "sys_cpu","timestamp": 1346846406,"value": 23,"tags": {"host": "web02","group1": "1","dc": "lga"}}]' 127.0.0.1:7111/opentsdb/db/put + +system_content curl -u root:taosdata -d 'select count(*) from db.sys_cpu_d_bbb' 127.0.0.1:7111/rest/sql/ +print $system_content +if $system_content != @{"status":"succ","head":["count(*)"],"column_meta":[["count(*)",5,8]],"data":[[7]],"rows":1}@ then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT diff --git a/tests/script/unique/http/testSuite.sim b/tests/script/unique/http/testSuite.sim new file mode 100644 index 0000000000000000000000000000000000000000..3a9753e744b84bfea28e40e8b3554cb82d2ebb40 --- /dev/null +++ b/tests/script/unique/http/testSuite.sim @@ -0,0 +1,2 @@ +run unique/http/admin.sim +run general/http/opentsdb.sim \ No newline at end of file diff --git a/tests/script/unique/import/replica2.sim b/tests/script/unique/import/replica2.sim new file mode 100644 index 0000000000000000000000000000000000000000..54ce28543e741a1264e1bcf76c7152bee74564c0 --- /dev/null +++ b/tests/script/unique/import/replica2.sim @@ -0,0 +1,300 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 10 + +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2000 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 2000 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 2000 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 2000 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 +print dnode4 $data4_4 + +if $data4_1 != ready then + goto step1 +endi +if $data4_2 != ready then + goto step1 +endi + +sql create database ir2db replica 2 days 7 +sql use ir2db +sql create table tb(ts timestamp, i bigint) + +print ================= step1 +sql import into tb values(1520000010000, 1520000010000) +sql select * from tb; +print $rows +if $rows != 1 then + return -1 +endi + +print ================= step2 +sql insert into tb values(1520000008000, 1520000008000) +print $rows +sql select * from tb; +if $rows != 2 then + return -1 +endi + +print ================= step3 +sql insert into tb values(1520000020000, 1520000020000) +sql select * from tb; +print $rows +if $rows != 3 then + return -1 +endi + +print ================= step4 +sql import into tb values(1520000009000, 1520000009000) +sql import into tb values(1520000015000, 1520000015000) +sql import into tb values(1520000030000, 1520000030000) +sql select * from tb; +print $rows +if $rows != 6 then + return -1 +endi + +print ================= step5 +sql insert into tb values(1520000008000, 1520000008000) +sql insert into tb values(1520000014000, 1520000014000) +sql insert into tb values(1520000025000, 1520000025000) +sql insert into tb values(1520000040000, 1520000040000) +sql select * from tb; +print $rows +if $rows != 9 then + return -1 +endi + +print ================= step6 +sql import into tb values(1520000007000, 1520000007000) +sql import into tb values(1520000012000, 1520000012000) +sql import into tb values(1520000023000, 1520000023000) +sql import into tb values(1520000034000, 1520000034000) +sql import into tb values(1520000050000, 1520000050000) +sql select * from tb; +print $rows +if $rows != 14 then + return -1 +endi + +print ================== dnode restart +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s start + +$x = 0 +a1: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show vgroups +print online vnodes $data03 +if $data03 != 2 then + goto a1 +endi + +sql select * from tb; +if $rows != 14 then + return -1 +endi + +print ================= step7 +sql import into tb values(1520000007001, 1520000007001) +sql import into tb values(1520000012001, 1520000012001) +sql import into tb values(1520000023001, 1520000023001) +sql import into tb values(1520000034001, 1520000034001) +sql import into tb values(1520000050001, 1520000050001) +sql select * from tb; +print $rows +if $rows != 19 then + print expect 19, actual: $rows + return -1 +endi + +print ================= step8 +sql insert into tb values(1520000008002, 1520000008002) +sql insert into tb values(1520000014002, 1520000014002) +sql insert into tb values(1520000025002, 1520000025002) +sql insert into tb values(1520000060000, 1520000060000) +sql select * from tb; +print $rows +if $rows != 23 then + return -1 +endi + +print ================= step9 +#1520000000000 +#sql import into tb values(now-30d, 7003) +#sql import into tb values(now-20d, 34003) +#sql import into tb values(now-10d, 34003) +#sql import into tb values(now-5d, 34003) +#sql import into tb values(now+1d, 50001) +#sql import into tb values(now+2d, 50001) +#sql import into tb values(now+6d, 50001) +#sql import into tb values(now+8d, 50002) +#sql import into tb values(now+10d, 50003) +#sql import into tb values(now+12d, 50004) +#sql import into tb values(now+14d, 50001) +#sql import into tb values(now+16d, 500051) + +sql import into tb values(1517408000000, 1517408000000) +sql import into tb values(1518272000000, 1518272000000) +sql import into tb values(1519136000000, 1519136000000) +sql import into tb values(1519568000000, 1519568000000) +sql import into tb values(1519654400000, 1519654400000) +sql import into tb values(1519827200000, 1519827200000) +sql import into tb values(1520345600000, 1520345600000) +sql import into tb values(1520691200000, 1520691200000) +sql import into tb values(1520864000000, 1520864000000) +sql import into tb values(1521900800000, 1521900800000) +sql import into tb values(1523110400000, 1523110400000) +sql import into tb values(1521382400000, 1521382400000) +sql select * from tb; +print $rows +if $rows != 35 then + return -1 +endi + +print ================= step10 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s start + +$x = 0 +a2: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show vgroups +print online vnodes $data03 +if $data03 != 2 then + goto a2 +endi + +sql select * from tb; +print $rows +if $rows != 35 then + return -1 +endi + +print ================= step11 + +#sql import into tb values(now-50d, 7003) (now-48d, 7003) (now-46d, 7003) (now-44d, 7003) (now-42d, 7003) +sql import into tb values(1515680000000, 1) (1515852800000, 2) (1516025600000, 3) (1516198400000, 4) (1516371200000, 5) +sql select * from tb; +if $rows != 40 then + return -1 +endi + +print ================= step12 +#1520000000000 +#sql import into tb values(now-19d, -19) (now-18d, -18) (now-17d, -17) (now-16d, -16) (now-15d, -15) (now-14d, -14) (now-13d, -13) (now-12d, -12) (now-11d, -11) +sql import into tb values(1518358400000, 6) (1518444800000, 7) (1518531200000, 8) (1518617600000, 9) (1518704000000, 10) (1518790400000, 11) (1518876800000, 12) (1518963200000, 13) (1519049600000, 14) +sql select * from tb; +print $rows +if $rows != 49 then + return -1 +endi + +print ================= step13 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s start +$x = 0 +a3: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show vgroups +print online vnodes $data03 +if $data03 != 2 then + goto a3 +endi + +print ================= step14 +#1520000000000 +#sql import into tb values(now-48d, -48) +#sql import into tb values(now-38d, -38) +#sql import into tb values(now-28d, -28) + +sql import into tb values(1515852800001, -48) +sql import into tb values(1516716800000, -38) +sql import into tb values(1517580800000, -28) + +sql select * from tb; +if $rows != 52 then + return -1 +endi + +print ================= step15 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s start +$x = 0 +a4: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show vgroups +print online vnodes $data03 +if $data03 != 2 then + goto a4 +endi + +sql select * from tb; +if $rows != 52 then + goto a4 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/import/replica3.sim b/tests/script/unique/import/replica3.sim new file mode 100644 index 0000000000000000000000000000000000000000..5da9e141a5867dd2e3d61114379ede589c0fa744 --- /dev/null +++ b/tests/script/unique/import/replica3.sim @@ -0,0 +1,291 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 10 + +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2000 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 2000 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 2000 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 2000 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create dnode $hostname2 +sql create dnode $hostname3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 +print dnode4 $data4_4 + +if $data4_1 != ready then + goto step1 +endi +if $data4_2 != ready then + goto step1 +endi +if $data4_3 != ready then + goto step1 +endi + +sql create database ir3db replica 3 days 7 +sql use ir3db +sql create table tb(ts timestamp, i bigint) + +print ================= step1 +sql import into tb values(1520000010000, 1520000010000) +sql select * from tb; +print $rows +if $rows != 1 then + return -1 +endi + +print ================= step2 +sql insert into tb values(1520000008000, 1520000008000) +print $rows +sql select * from tb; +if $rows != 2 then + return -1 +endi + +print ================= step3 +sql insert into tb values(1520000020000, 1520000020000) +sql select * from tb; +print $rows +if $rows != 3 then + return -1 +endi + +print ================= step4 +sql import into tb values(1520000009000, 1520000009000) +sql import into tb values(1520000015000, 1520000015000) +sql import into tb values(1520000030000, 1520000030000) +sql select * from tb; +print $rows +if $rows != 6 then + return -1 +endi + +print ================= step5 +sql insert into tb values(1520000008000, 1520000008000) +sql insert into tb values(1520000014000, 1520000014000) +sql insert into tb values(1520000025000, 1520000025000) +sql insert into tb values(1520000040000, 1520000040000) +sql select * from tb; +print $rows +if $rows != 9 then + return -1 +endi + +print ================= step6 +sql import into tb values(1520000007000, 1520000007000) +sql import into tb values(1520000012000, 1520000012000) +sql import into tb values(1520000023000, 1520000023000) +sql import into tb values(1520000034000, 1520000034000) +sql import into tb values(1520000050000, 1520000050000) +sql select * from tb; +print $rows +if $rows != 14 then + return -1 +endi + +print ================== dnode restart +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s start +$x = 0 +a4: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi +sql show vgroups +print online vnodes $data03 +if $data03 != 3 then + goto a4 +endi + +sql select * from tb; +if $rows != 14 then + return -1 +endi + +print ================= step7 +sql import into tb values(1520000007001, 1520000007001) +sql import into tb values(1520000012001, 1520000012001) +sql import into tb values(1520000023001, 1520000023001) +sql import into tb values(1520000034001, 1520000034001) +sql import into tb values(1520000050001, 1520000050001) +sql select * from tb; +print $rows +if $rows != 19 then + print expect 19, actual: $rows + return -1 +endi + +print ================= step8 +sql insert into tb values(1520000008002, 1520000008002) +sql insert into tb values(1520000014002, 1520000014002) +sql insert into tb values(1520000025002, 1520000025002) +sql insert into tb values(1520000060000, 1520000060000) +sql select * from tb; +print $rows +if $rows != 23 then + return -1 +endi + +print ================= step9 +#1520000000000 +#sql import into tb values(now-30d, 7003) +#sql import into tb values(now-20d, 34003) +#sql import into tb values(now-10d, 34003) +#sql import into tb values(now-5d, 34003) +#sql import into tb values(now+1d, 50001) +#sql import into tb values(now+2d, 50001) +#sql import into tb values(now+6d, 50001) +#sql import into tb values(now+8d, 50002) +#sql import into tb values(now+10d, 50003) +#sql import into tb values(now+12d, 50004) +#sql import into tb values(now+14d, 50001) +#sql import into tb values(now+16d, 500051) + +sql import into tb values(1517408000000, 1517408000000) +sql import into tb values(1518272000000, 1518272000000) +sql import into tb values(1519136000000, 1519136000000) +sql import into tb values(1519568000000, 1519568000000) +sql import into tb values(1519654400000, 1519654400000) +sql import into tb values(1519827200000, 1519827200000) +sql import into tb values(1520345600000, 1520345600000) +sql import into tb values(1520691200000, 1520691200000) +sql import into tb values(1520864000000, 1520864000000) +sql import into tb values(1521900800000, 1521900800000) +sql import into tb values(1523110400000, 1523110400000) +sql import into tb values(1521382400000, 1521382400000) +sql select * from tb; +print $rows +if $rows != 35 then + return -1 +endi + +print ================= step10 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s start + +$x = 0 +step10: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi +sql show vgroups +print online vnodes $data03 +if $data03 != 3 then + goto step10 +endi + +sql select * from tb; +print $rows +if $rows != 35 then + return -1 +endi + +print ================= step11 + +#sql import into tb values(now-50d, 7003) (now-48d, 7003) (now-46d, 7003) (now-44d, 7003) (now-42d, 7003) +sql import into tb values(1515680000000, 1) (1515852800000, 2) (1516025600000, 3) (1516198400000, 4) (1516371200000, 5) +sql select * from tb; +if $rows != 40 then + return -1 +endi + +print ================= step12 +#1520000000000 +#sql import into tb values(now-19d, -19) (now-18d, -18) (now-17d, -17) (now-16d, -16) (now-15d, -15) (now-14d, -14) (now-13d, -13) (now-12d, -12) (now-11d, -11) +sql import into tb values(1518358400000, 6) (1518444800000, 7) (1518531200000, 8) (1518617600000, 9) (1518704000000, 10) (1518790400000, 11) (1518876800000, 12) (1518963200000, 13) (1519049600000, 14) +sql select * from tb; +print $rows +if $rows != 49 then + return -1 +endi + +print ================= step13 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode2 -s start +sleep 3000 + +print ================= step14 +#1520000000000 +#sql import into tb values(now-48d, -48) +#sql import into tb values(now-38d, -38) +#sql import into tb values(now-28d, -28) + +sql import into tb values(1515852800001, -48) +sql import into tb values(1516716800000, -38) +sql import into tb values(1517580800000, -28) + +sql select * from tb; +if $rows != 52 then + return -1 +endi + +print ================= step15 +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s start +$x = 0 +step15: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi +sql show vgroups +print online vnodes $data03 +if $data03 != 3 then + goto step15 +endi + +sql select * from tb; +if $rows != 52 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/import/testSuite.sim b/tests/script/unique/import/testSuite.sim new file mode 100644 index 0000000000000000000000000000000000000000..8be358ce17ee864538c47137630520cd3e69c337 --- /dev/null +++ b/tests/script/unique/import/testSuite.sim @@ -0,0 +1,2 @@ +run unique/import/replica2.sim +run unique/import/replica3.sim \ No newline at end of file diff --git a/tests/script/unique/migrate/mn2_vn2_repl2_rmMnodeDir.sim b/tests/script/unique/migrate/mn2_vn2_repl2_rmMnodeDir.sim new file mode 100644 index 0000000000000000000000000000000000000000..5b1842fcf53f8a0ef8ee272f4a2690574df05a4e --- /dev/null +++ b/tests/script/unique/migrate/mn2_vn2_repl2_rmMnodeDir.sim @@ -0,0 +1,275 @@ +# Test case describe: dnode1/dnode2 include mnode and vnode roles +# step 1: start dnode1/dnode2, and added into cluster +# step 2: create db(repl = 2), table, insert data, +# step 4: stop dnode1, remove its mnode dir, and copy mnode dir of dnode2 to dnode1 +# step 5: restart dnode1, waiting sync end +# step 6: stop dnode2, reset query cache, and query + +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +#system sh/deploy.sh -n dnode3 -i 3 +#system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 +#system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +#system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +#system sh/cfg.sh -n dnode3 -c walLevel -v 2 +#system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +#system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +#system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 0 +system sh/cfg.sh -n dnode2 -c role -v 0 +#system sh/cfg.sh -n dnode3 -c role -v 2 +#system sh/cfg.sh -n dnode4 -c role -v 2 + +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +#system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 +#system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +#system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 4 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +#system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1/dnode2 and add into cluster +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +sleep 1000 +sql connect +sleep 1000 +sql create dnode $hostname2 +sleep 3000 + +print ============== step2: create database with replica 2, and create table, insert data +$totalTableNum = 10 +$sleepTimer = 3000 + +$db = db +sql create database $db replica 2 cache 1 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 double) tags(t1 int) +$rowNum = 1200 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1577808000000 # 2020-01-01 00:00:00.000 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print rows:$rows data00:$data00 totalRows:$totalRows +if $rows != 1 then + return -1 +endi + +if $data00 != $totalRows then + return -1 +endi + + +print ============== step3: insert old data(now-15d) and new data(now+15d), control data rows in order to save in cache, not falling disc +sql insert into $tb values ( now - 20d , -20 ) +sql insert into $tb values ( now - 40d , -40 ) +$totalRows = $totalRows + 2 + +print ============== step4: stop dnode1 +system sh/exec.sh -n dnode1 -s stop -x SIGINT + +$loopCnt = 0 +wait_dnode1_offline: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 3 then + sleep 2000 + goto wait_dnode1_offline +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 + +if $dnode1Status != offline then + sleep 2000 + goto wait_dnode1_offline +endi +if $dnode2Status != ready then + sleep 2000 + goto wait_dnode1_offline +endi + +# check using select +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +#sql show vgroups +#print show vgroups: +#print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +#print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +#print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 + +print ============== step5: remove the mnode dir of dnode1, then copy the monde dir of dnode2 +system_content rm -rf ../../../sim/dnode1/data/mnode +system_content cp -rf ../../../sim/dnode2/data/mnode ../../../sim/dnode1/data/ + +print ============== step6: restart dnode1, waiting sync end +system sh/exec.sh -n dnode1 -s start +sleep 1000 + +$loopCnt = 0 +wait_dnode1_ready: +$loopCnt = $loopCnt + 1 +if $loopCnt == 20 then + return -1 +endi + +sql show dnodes -x wait_dnode1_ready +if $rows != 3 then + sleep 2000 + goto wait_dnode1_ready +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 + +if $dnode1Status != ready then + sleep 2000 + goto wait_dnode1_ready +endi +if $dnode2Status != ready then + sleep 2000 + goto wait_dnode1_ready +endi + +$loopCnt = 0 +wait_dnode1_vgroup_slave: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show vgroups +if $rows != 3 then + sleep 2000 + goto wait_dnode1_vgroup_slave +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 $data5_4 $data6_4 $data7_4 $data8_4 $data9_4 + +if $data5_4 != master then + print $data5_4 + sleep 2000 + goto wait_dnode1_vgroup_slave +endi +if $data5_3 != slave then +print $data5_2 + sleep 2000 + goto wait_dnode1_vgroup_slave +endi +if $data5_2 != master then +print $data5_3 + sleep 2000 + goto wait_dnode1_vgroup_slave +endi + +if $data7_4 != slave then + print $data7_4 + sleep 2000 + goto wait_dnode1_vgroup_slave +endi +if $data7_3 != master then + print $data7_3 + sleep 2000 + goto wait_dnode1_vgroup_slave +endi +if $data7_2 != slave then + print $data7_2 + sleep 2000 + goto wait_dnode1_vgroup_slave +endi + +print ============== step7: stop dnode2 +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +$loopCnt = 0 +wait_dnode2_offline: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 3 then + sleep 2000 + goto wait_dnode2_offline +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 + +if $dnode1Status != ready then + sleep 2000 + goto wait_dnode2_offline +endi +if $dnode2Status != offline then + sleep 2000 + goto wait_dnode2_offline +endi + +sql reset query cache + +# check using select +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT diff --git a/tests/script/unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir.sim b/tests/script/unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir.sim new file mode 100644 index 0000000000000000000000000000000000000000..7a716bd065a767266c50ca34677ed34b77e89bc8 --- /dev/null +++ b/tests/script/unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir.sim @@ -0,0 +1,271 @@ +# Test case describe: dnode1/dnode2 include mnode and vnode roles +# step 1: start dnode1/dnode2, and added into cluster +# step 2: create db(repl = 2), table, insert data, +# step 4: stop dnode1, remove its mnode and vnode dir, and copy mnode and vnode dir of dnode2 to dnode1 +# step 5: restart dnode1, waiting sync end +# step 6: stop dnode2, reset query cache, and query + +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +#system sh/deploy.sh -n dnode3 -i 3 +#system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 +#system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +#system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +#system sh/cfg.sh -n dnode3 -c walLevel -v 2 +#system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +#system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +#system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 0 +system sh/cfg.sh -n dnode2 -c role -v 0 +#system sh/cfg.sh -n dnode3 -c role -v 2 +#system sh/cfg.sh -n dnode4 -c role -v 2 + +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +#system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 +#system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +#system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 4 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +#system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1/dnode2 and add into cluster +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +sleep 1000 +sql connect +sleep 1000 +sql create dnode $hostname2 +sleep 2000 + +print ============== step2: create database with replica 2, and create table, insert data +$totalTableNum = 10 +$sleepTimer = 3000 + +$db = db +sql create database $db replica 2 cache 1 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 double) tags(t1 int) +$rowNum = 1200 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1577808000000 # 2020-01-01 00:00:00.000 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print rows:$rows data00:$data00 totalRows:$totalRows +if $rows != 1 then + return -1 +endi + +if $data00 != $totalRows then + return -1 +endi + + +print ============== step3: insert old data(now-15d) and new data(now+15d), control data rows in order to save in cache, not falling disc +sql insert into $tb values ( now - 20d , -20 ) +sql insert into $tb values ( now - 40d , -40 ) +$totalRows = $totalRows + 2 + +print ============== step4: stop dnode1 +system sh/exec.sh -n dnode1 -s stop -x SIGINT + +$loopCnt = 0 +wait_dnode1_offline: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 3 then + sleep 2000 + goto wait_dnode1_offline +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 + +if $dnode1Status != offline then + sleep 2000 + goto wait_dnode1_offline +endi +if $dnode2Status != ready then + sleep 2000 + goto wait_dnode1_offline +endi + +# check using select +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +#sql show vgroups +#print show vgroups: +#print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +#print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +#print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 + +print ============== step5: remove the mnode dir of dnode1, then copy the monde dir of dnode2 +system_content rm -rf ../../../sim/dnode1/data/vnode +system_content rm -rf ../../../sim/dnode1/data/mnode +system_content cp -rf ../../../sim/dnode2/data/vnode ../../../sim/dnode1/data/ +system_content cp -rf ../../../sim/dnode2/data/mnode ../../../sim/dnode1/data/ + +print ============== step6: restart dnode1, waiting sync end +system sh/exec.sh -n dnode1 -s start +sleep 1000 + +$loopCnt = 0 +wait_dnode1_ready: +$loopCnt = $loopCnt + 1 +if $loopCnt == 20 then + return -1 +endi + +sql show dnodes -x wait_dnode1_ready +if $rows != 3 then + sleep 2000 + goto wait_dnode1_ready +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 + +if $dnode1Status != ready then + sleep 2000 + goto wait_dnode1_ready +endi +if $dnode2Status != ready then + sleep 2000 + goto wait_dnode1_ready +endi + +$loopCnt = 0 +wait_dnode1_vgroup_slave: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show vgroups +if $rows != 3 then + sleep 2000 + goto wait_dnode1_vgroup_slave +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 $data5_4 $data6_4 $data7_4 $data8_4 $data9_4 + +if $data5_4 != master then + sleep 2000 + goto wait_dnode1_vgroup_slave +endi +if $data5_3 != slave then + sleep 2000 + goto wait_dnode1_vgroup_slave +endi +if $data5_2 != master then + sleep 2000 + goto wait_dnode1_vgroup_slave +endi + +if $data7_4 != slave then + sleep 2000 + goto wait_dnode1_vgroup_slave +endi +if $data7_3 != master then + sleep 2000 + goto wait_dnode1_vgroup_slave +endi +if $data7_2 != slave then + sleep 2000 + goto wait_dnode1_vgroup_slave +endi + +print ============== step7: stop dnode2 +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +$loopCnt = 0 +wait_dnode2_offline: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 3 then + sleep 2000 + goto wait_dnode2_offline +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 + +if $dnode1Status != ready then + sleep 2000 + goto wait_dnode2_offline +endi +if $dnode2Status != offline then + sleep 2000 + goto wait_dnode2_offline +endi + +sql reset query cache + +# check using select +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT diff --git a/tests/script/unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir_stopAll_starAll.sim b/tests/script/unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir_stopAll_starAll.sim new file mode 100644 index 0000000000000000000000000000000000000000..69e83a2c0091394b2babf76a592ab80a95ae3e6a --- /dev/null +++ b/tests/script/unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir_stopAll_starAll.sim @@ -0,0 +1,205 @@ +# Test case describe: dnode1/dnode2 include mnode and vnode roles +# step 1: start dnode1/dnode2, and added into cluster +# step 2: create db(repl = 2), table, insert data, +# step 4: stop dnode1, remove its mnode and vnode dir, and copy mnode and vnode dir of dnode2 to dnode1 +# step 5: restart dnode1, waiting sync end +# step 6: stop dnode2, reset query cache, and query + +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +#system sh/deploy.sh -n dnode3 -i 3 +#system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 +#system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +#system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +#system sh/cfg.sh -n dnode3 -c walLevel -v 2 +#system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +#system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +#system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 0 +system sh/cfg.sh -n dnode2 -c role -v 0 +#system sh/cfg.sh -n dnode3 -c role -v 2 +#system sh/cfg.sh -n dnode4 -c role -v 2 + +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +#system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 +#system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +#system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 4 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +#system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1/dnode2 and add into cluster +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +sleep 1000 +sql connect +sleep 1000 +sql create dnode $hostname2 +sleep 1000 + +print ============== step2: create database with replica 2, and create table, insert data +$totalTableNum = 10 +$sleepTimer = 3000 + +$db = db +sql create database $db replica 2 cache 1 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 double) tags(t1 int) +$rowNum = 1200 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1577808000000 # 2020-01-01 00:00:00.000 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print rows:$rows data00:$data00 totalRows:$totalRows +if $rows != 1 then + return -1 +endi + +if $data00 != $totalRows then + return -1 +endi + + +print ============== step3: insert old data(now-15d) and new data(now+15d), control data rows in order to save in cache, not falling disc +sql insert into $tb values ( now - 20d , -20 ) +sql insert into $tb values ( now - 40d , -40 ) +$totalRows = $totalRows + 2 + +print ============== step4: stop dnode1 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +print ============== step5: remove the mnode dir of dnode1, then copy the monde dir of dnode2 +system_content rm -rf ../../../sim/dnode1/data/vnode +system_content rm -rf ../../../sim/dnode1/data/mnode +system_content cp -rf ../../../sim/dnode2/data/vnode ../../../sim/dnode1/data/ +system_content cp -rf ../../../sim/dnode2/data/mnode ../../../sim/dnode1/data/ + +print ============== step6: restart dnode1/dnode2 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +sleep 1000 +sql connect +sql use $db + +$loopCnt = 0 +wait_dnode1_ready: +$loopCnt = $loopCnt + 1 +if $loopCnt == 20 then + return -1 +endi + +sql show dnodes -x wait_dnode1_ready +if $rows != 3 then + sleep 2000 + goto wait_dnode1_ready +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 + +if $dnode1Status != ready then + sleep 2000 + goto wait_dnode1_ready +endi +if $dnode2Status != ready then + sleep 2000 + goto wait_dnode1_ready +endi + +$loopCnt = 0 +wait_dnode1_vgroup_slave: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show vgroups +if $rows != 3 then + sleep 2000 + goto wait_dnode1_vgroup_slave +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 $data5_4 $data6_4 $data7_4 $data8_4 $data9_4 +$d2v2status = $data5_4 +$d2v3status = $data5_2 +$d2v4status = $data5_3 + +$d1v2status = $data7_4 +$d1v3status = $data7_2 +$d1v4status = $data7_3 + +if $d2v2status != master then + sleep 2000 + goto wait_dnode1_vgroup_slave +endi +if $d2v3status != master then + sleep 2000 + goto wait_dnode1_vgroup_slave +endi +if $d2v4status != master then + sleep 2000 + goto wait_dnode1_vgroup_slave +endi + +if $d1v2status != slave then + sleep 2000 + goto wait_dnode1_vgroup_slave +endi +if $d1v3status != slave then + sleep 2000 + goto wait_dnode1_vgroup_slave +endi +if $d1v4status != slave then + sleep 2000 + goto wait_dnode1_vgroup_slave +endi + +sql reset query cache + +# check using select +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi \ No newline at end of file diff --git a/tests/script/unique/migrate/mn2_vn2_repl2_rmVnodeDir.sim b/tests/script/unique/migrate/mn2_vn2_repl2_rmVnodeDir.sim new file mode 100644 index 0000000000000000000000000000000000000000..7581528d8237d736bb93cce200733510cb209b56 --- /dev/null +++ b/tests/script/unique/migrate/mn2_vn2_repl2_rmVnodeDir.sim @@ -0,0 +1,269 @@ +# Test case describe: dnode1/dnode2 include mnode and vnode roles +# step 1: start dnode1/dnode2, and added into cluster +# step 2: create db(repl = 2), table, insert data, +# step 4: stop dnode1, remove its vnode dir, and copy vnode dir of dnode2 to dnode1 +# step 5: restart dnode1, waiting sync end +# step 6: stop dnode2, reset query cache, and query + +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +#system sh/deploy.sh -n dnode3 -i 3 +#system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 +#system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +#system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +#system sh/cfg.sh -n dnode3 -c walLevel -v 2 +#system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +#system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +#system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 0 +system sh/cfg.sh -n dnode2 -c role -v 0 +#system sh/cfg.sh -n dnode3 -c role -v 2 +#system sh/cfg.sh -n dnode4 -c role -v 2 + +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +#system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 +#system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +#system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 4 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +#system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1/dnode2 and add into cluster +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +sleep 1000 +sql connect +sleep 1000 +sql create dnode $hostname2 +sleep 2000 + +print ============== step2: create database with replica 2, and create table, insert data +$totalTableNum = 10 +$sleepTimer = 3000 + +$db = db +sql create database $db replica 2 cache 1 +sql use $db + +# create table , insert data +$stb = stb +sql create table $stb (ts timestamp, c1 double) tags(t1 int) +$rowNum = 1200 +$tblNum = $totalTableNum +$totalRows = 0 +$tsStart = 1577808000000 # 2020-01-01 00:00:00.000 + +$i = 0 +while $i < $tblNum + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $ts = $tsStart + $x + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x ) + $x = $x + 60 + endw + $totalRows = $totalRows + $x + print info: inserted $x rows into $tb and totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb +print rows:$rows data00:$data00 totalRows:$totalRows +if $rows != 1 then + return -1 +endi + +if $data00 != $totalRows then + return -1 +endi + + +print ============== step3: insert old data(now-15d) and new data(now+15d), control data rows in order to save in cache, not falling disc +sql insert into $tb values ( now - 20d , -20 ) +sql insert into $tb values ( now - 40d , -40 ) +$totalRows = $totalRows + 2 + +print ============== step4: stop dnode1 +system sh/exec.sh -n dnode1 -s stop -x SIGINT + +$loopCnt = 0 +wait_dnode1_offline: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 3 then + sleep 2000 + goto wait_dnode1_offline +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 + +if $dnode1Status != offline then + sleep 2000 + goto wait_dnode1_offline +endi +if $dnode2Status != ready then + sleep 2000 + goto wait_dnode1_offline +endi + +# check using select +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +#sql show vgroups +#print show vgroups: +#print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +#print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +#print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 + +print ============== step5: remove the mnode dir of dnode1, then copy the monde dir of dnode2 +system_content rm -rf ../../../sim/dnode1/data/vnode +system_content cp -rf ../../../sim/dnode2/data/vnode ../../../sim/dnode1/data/ + +print ============== step6: restart dnode1, waiting sync end +system sh/exec.sh -n dnode1 -s start +sleep 1000 + +$loopCnt = 0 +wait_dnode1_ready: +$loopCnt = $loopCnt + 1 +if $loopCnt == 20 then + return -1 +endi + +sql show dnodes -x wait_dnode1_ready +if $rows != 3 then + sleep 2000 + goto wait_dnode1_ready +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 + +if $dnode1Status != ready then + sleep 2000 + goto wait_dnode1_ready +endi +if $dnode2Status != ready then + sleep 2000 + goto wait_dnode1_ready +endi + +$loopCnt = 0 +wait_dnode1_vgroup_slave: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show vgroups +if $rows != 3 then + sleep 2000 + goto wait_dnode1_vgroup_slave +endi +print show vgroups: +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 $data5_4 $data6_4 $data7_4 $data8_4 $data9_4 + +if $data5_4 != master then + sleep 2000 + goto wait_dnode1_vgroup_slave +endi +if $data5_3 != slave then + sleep 2000 + goto wait_dnode1_vgroup_slave +endi +if $data5_2 != master then + sleep 2000 + goto wait_dnode1_vgroup_slave +endi + +if $data7_4 != slave then + sleep 2000 + goto wait_dnode1_vgroup_slave +endi +if $data7_3 != master then + sleep 2000 + goto wait_dnode1_vgroup_slave +endi +if $data7_2 != slave then + sleep 2000 + goto wait_dnode1_vgroup_slave +endi + +print ============== step7: stop dnode2 +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +$loopCnt = 0 +wait_dnode2_offline: +$loopCnt = $loopCnt + 1 +if $loopCnt == 10 then + return -1 +endi + +sql show dnodes +if $rows != 3 then + sleep 2000 + goto wait_dnode2_offline +endi +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +$dnode1Status = $data4_1 +$dnode2Status = $data4_2 + +if $dnode1Status != ready then + sleep 2000 + goto wait_dnode2_offline +endi +if $dnode2Status != offline then + sleep 2000 + goto wait_dnode2_offline +endi + +sql reset query cache + +# check using select +sql select count(*) from $stb +print data00 $data00 +if $data00 != $totalRows then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT diff --git a/tests/script/unique/mnode/mgmt20.sim b/tests/script/unique/mnode/mgmt20.sim new file mode 100644 index 0000000000000000000000000000000000000000..8945cffab226ab5dc379057d55e562f5c3ed9cfa --- /dev/null +++ b/tests/script/unique/mnode/mgmt20.sim @@ -0,0 +1,88 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 + +system sh/cfg.sh -n dnode1 -c monitor -v 1 +system sh/cfg.sh -n dnode2 -c monitor -v 1 + +print ============== step1 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +sql connect + +print ============== step2 +sql create dnode $hostname2 + +$x = 0 +show2: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show mnodes +print dnode1 ==> $data2_1 +print dnode2 ==> $data2_2 +if $data2_1 != master then + goto show2 +endi +if $data2_2 != slave then + goto show2 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +print ============== step3 +system sh/exec.sh -n dnode2 -s start +sleep 10000 + +system sh/exec.sh -n dnode1 -s start +sql connect + +print =============== step4 +sql select * from log.dn1 +$d1_first = $rows +sql select * from log.dn2 +$d2_first = $rows + +$x = 0 +show4: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show mnodes +print dnode1 ==> $data2_1 +print dnode2 ==> $data2_2 +if $data2_1 != master then + goto show4 +endi +if $data2_2 != slave then + goto show4 +endi + +sleep 2000 +sql select * from log.dn1 +$d1_second = $rows +sql select * from log.dn2 +$d2_second = $rows + +print dnode1 $d1_first $d1_second +print dnode2 $d2_first $d2_second +if $d1_first >= $d1_second then + return -1 +endi + +if $d2_first >= $d2_second then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/mnode/mgmt21.sim b/tests/script/unique/mnode/mgmt21.sim new file mode 100644 index 0000000000000000000000000000000000000000..8409383309dbde5500b9719cd64fd74ca5e384b2 --- /dev/null +++ b/tests/script/unique/mnode/mgmt21.sim @@ -0,0 +1,44 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 + +print ============== step1 +system sh/exec.sh -n dnode2 -s start +sleep 10000 + +system sh/exec.sh -n dnode1 -s start +sql connect + +sql show mnodes +print dnode1 ==> $data2_1 +print dnode2 ==> $data2_2 +if $data2_1 != master then + return -1 +endi + +print ============== step2 +sql create dnode $hostname2 + +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 5 then + return -1 + endi + +sql show mnodes -x show2 +print dnode1 ==> $data2_1 +print dnode2 ==> $data2_2 +if $data2_1 != master then + goto show2 +endi +if $data2_2 != slave then + goto show2 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/mnode/mgmt22.sim b/tests/script/unique/mnode/mgmt22.sim new file mode 100644 index 0000000000000000000000000000000000000000..399805312ba905d55bceffe011cfe074c831684e --- /dev/null +++ b/tests/script/unique/mnode/mgmt22.sim @@ -0,0 +1,114 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 2 + +print ============== step1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql show mnodes +print dnode1 ==> $data2_1 +print dnode2 ==> $data2_2 +if $data2_1 != master then + return -1 +endi + +print ============== step2 +system sh/exec.sh -n dnode2 -s start +sql create dnode $hostname2 + +$x = 0 +show2: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show mnodes +print dnode1 ==> $data2_1 +print dnode2 ==> $data2_2 +if $data2_1 != master then + goto show2 +endi +if $data2_2 != slave then + goto show2 +endi + +print ============== step3 +sql_error drop dnode $hostname1 -x error1 +print should not drop master + +print ============== step4 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +sql_error show mnodes +print error of no master + +print ============== step5 +sql_error drop dnode $hostname1 +print error of no master + +print ============== step6 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql close +sql connect + +$x = 0 +show6: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show mnodes -x show6 +print dnode1 ==> $data2_1 +print dnode2 ==> $data2_2 +if $data2_1 != master then + goto show6 +endi +if $data2_2 != slave then + goto show6 +endi + +print ============== step7 +system sh/exec.sh -n dnode3 -s start +sql create dnode $hostname3 + +$x = 0 +show7: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show mnodes +print dnode1 ==> $data2_1 +print dnode2 ==> $data2_2 +print dnode3 ==> $data2_3 +if $data2_1 != master then + goto show7 +endi +if $data2_2 != slave then + goto show7 +endi +if $data3_3 != null then + goto show7 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/mnode/mgmt23.sim b/tests/script/unique/mnode/mgmt23.sim new file mode 100644 index 0000000000000000000000000000000000000000..19c7b4ba762d4bf5a73c10c1afa39e927c7a1c91 --- /dev/null +++ b/tests/script/unique/mnode/mgmt23.sim @@ -0,0 +1,141 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 2 + +print ============== step1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql show mnodes +print dnode1 ==> $data2_1 +print dnode2 ==> $data2_2 +if $data2_1 != master then + return -1 +endi + +print ============== step2 +system sh/exec.sh -n dnode2 -s start +sql create dnode $hostname2 + +$x = 0 +show2: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show mnodes +print dnode1 ==> $data2_1 +print dnode2 ==> $data2_2 +if $data2_1 != master then + goto show2 +endi +if $data2_2 != slave then + goto show2 +endi + +print ============== step3 +system sh/exec.sh -n dnode3 -s start +sql create dnode $hostname3 +sleep 8000 + +sql show mnodes +$dnode1Role = $data2_1 +$dnode2Role = $data2_2 +$dnode3Role = $data2_3 +print dnode1 ==> $dnode1Role +print dnode2 ==> $dnode2Role +print dnode3 ==> $dnode3Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != null then + return -1 +endi + +print ============== step4 +sql drop dnode $hostname2 + +$x = 0 +step4: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show mnodes +$dnode1Role = $data2_1 +$dnode2Role = $data2_2 +$dnode3Role = $data2_3 +print dnode1 ==> $dnode1Role +print dnode2 ==> $dnode2Role +print dnode3 ==> $dnode3Role + +if $dnode1Role != master then + goto step4 +endi +if $dnode2Role != null then + goto step4 +endi +if $dnode3Role != slave then + goto step4 +endi + +system sh/exec.sh -n dnode2 -s stop + +print ============== step5 +sleep 2000 +sql create dnode $hostname2 +system sh/deploy.sh -n dnode2 -i 2 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +step5: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show mnodes +$dnode1Role = $data2_1 +$dnode2Role = $data2_2 +$dnode3Role = $data2_3 +print dnode1 ==> $dnode1Role +print dnode2 ==> $dnode2Role +print dnode3 ==> $dnode3Role + +if $dnode1Role != master then + goto step5 +endi +if $dnode2Role != null then + goto step5 +endi +if $dnode3Role != slave then + goto step5 +endi + +print ============== step6 +system sh/exec.sh -n dnode1 -s stop +sql_error show mnodes + +print ============== step7 +sql_error drop dnode $hostname1 + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/mnode/mgmt24.sim b/tests/script/unique/mnode/mgmt24.sim new file mode 100644 index 0000000000000000000000000000000000000000..a7bcc59ac0bfa6163d1e2fddfd3a817b102bfa3c --- /dev/null +++ b/tests/script/unique/mnode/mgmt24.sim @@ -0,0 +1,84 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 2 + +print ============== step1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql show mnodes +print dnode1 ==> $data2_1 +print dnode2 ==> $data2_2 +if $data2_1 != master then + return -1 +endi + +print ============== step2 +system sh/exec.sh -n dnode2 -s start +sql create dnode $hostname2 + +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show mnodes +print dnode1 ==> $data2_1 +print dnode2 ==> $data2_2 +if $data2_1 != master then + goto show2 +endi +if $data2_2 != slave then + goto show2 +endi + +print ============== step3 +system sh/exec.sh -n dnode1 -s stop +sleep 2000 +sql_error show mnodes + +print ============== step4 +sql_error drop dnode $hostname1 + +print ============== step5 +system sh/exec.sh -n dnode1 -s start +sql_error create dnode $hostname1 + +sql close +sql connect + +$x = 0 +step5: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show mnodes -x step5 + +print dnode1 ==> $data2_1 +print dnode2 ==> $data2_2 +if $data2_1 != master then + goto step5 +endi +if $data2_2 != slave then + goto step5 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/mnode/mgmt25.sim b/tests/script/unique/mnode/mgmt25.sim new file mode 100644 index 0000000000000000000000000000000000000000..9cca9c844806b138faf52186ffc3184d4876a1d6 --- /dev/null +++ b/tests/script/unique/mnode/mgmt25.sim @@ -0,0 +1,95 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 2 + +print ============== step1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql show mnodes +print dnode1 ==> $data2_1 +print dnode2 ==> $data2_2 +if $data2_1 != master then + return -1 +endi + +print ============== step2 +system sh/exec.sh -n dnode2 -s start +sql create dnode $hostname2 + +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show mnodes +print dnode1 ==> $data2_1 +print dnode2 ==> $data2_2 +if $data2_1 != master then + goto show2 +endi +if $data2_2 != slave then + goto show2 +endi + +print ============== step3 +system sh/exec.sh -n dnode3 -s start +sql create dnode $hostname3 +sleep 6000 + +sql show mnodes +$dnode1Role = $data2_1 +$dnode2Role = $data2_2 +$dnode3Role = $data2_3 +print dnode1 ==> $dnode1Role +print dnode2 ==> $dnode2Role +print dnode3 ==> $dnode3Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != null then + return -1 +endi + +print ============== step4 +sql drop dnode $hostname2 +sleep 6000 + +sql show mnodes +$dnode1Role = $data2_1 +$dnode2Role = $data2_2 +$dnode3Role = $data2_3 +print dnode1 ==> $dnode1Role +print dnode2 ==> $dnode2Role +print dnode3 ==> $dnode3Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != null then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/mnode/mgmt26.sim b/tests/script/unique/mnode/mgmt26.sim new file mode 100644 index 0000000000000000000000000000000000000000..2816845052e835cf11e0ec7d4ddc71cbdee0ada1 --- /dev/null +++ b/tests/script/unique/mnode/mgmt26.sim @@ -0,0 +1,123 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 2 + +print ============== step1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql show mnodes +print dnode1 ==> $data2_1 +print dnode2 ==> $data2_2 +if $data2_1 != master then + return -1 +endi + +print ============== step2 +system sh/exec.sh -n dnode2 -s start +sql create dnode $hostname2 + +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show mnodes +print dnode1 ==> $data2_1 +print dnode2 ==> $data2_2 +if $data2_1 != master then + goto show2 +endi +if $data2_2 != slave then + goto show2 +endi + +print ============== step3 +system sh/exec.sh -n dnode3 -s start +sql create dnode $hostname3 +sleep 6000 + +sql show mnodes +$dnode1Role = $data2_1 +$dnode2Role = $data2_2 +$dnode3Role = $data2_3 +print dnode1 ==> $dnode1Role +print dnode2 ==> $dnode2Role +print dnode3 ==> $dnode3Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != null then + return -1 +endi + + +print ============== step4 +sql drop dnode $hostname2 +sleep 6000 + +sql show mnodes +$dnode1Role = $data2_1 +$dnode2Role = $data2_2 +$dnode3Role = $data2_3 +print dnode1 ==> $dnode1Role +print dnode2 ==> $dnode2Role +print dnode3 ==> $dnode3Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != null then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi + +print ============== step5 +system sh/exec.sh -n dnode2 -s stop +system sh/deploy.sh -n dnode2 -i 2 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 +sleep 3000 +system sh/exec.sh -n dnode2 -s start +sql create dnode $hostname2 +sleep 6000 + +sql show mnodes +$dnode1Role = $data2_1 +$dnode2Role = $data2_2 +$dnode3Role = $data2_3 +print dnode1 ==> $dnode1Role +print dnode2 ==> $dnode2Role +print dnode3 ==> $dnode3Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != null then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/mnode/mgmt30.sim b/tests/script/unique/mnode/mgmt30.sim new file mode 100644 index 0000000000000000000000000000000000000000..d0858c0d6cdffa1cb1cd7f2ba570ae0521f412d5 --- /dev/null +++ b/tests/script/unique/mnode/mgmt30.sim @@ -0,0 +1,68 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 3000 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 3000 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 3000 + +print ============== step1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql show mnodes +print dnode1 ==> $data2_1 +print dnode2 ==> $data2_2 +print dnode3 ==> $data3_3 +if $data2_1 != master then + return -1 +endi +if $data3_2 != null then + return -1 +endi +if $data3_3 != null then + return -1 +endi + +print ============== step2 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sleep 3000 + +sql create dnode $hostname2 +sql create dnode $hostname3 + +$x = 0 +step2: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show mnodes +$dnode1Role = $data2_1 +$dnode2Role = $data2_2 +$dnode3Role = $data2_3 +print dnode1 ==> $dnode1Role +print dnode2 ==> $dnode2Role +print dnode3 ==> $dnode3Role + +if $dnode1Role != master then + goto step2 +endi +if $dnode2Role != slave then + goto step2 +endi +if $dnode3Role != slave then + goto step2 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/mnode/mgmt33.sim b/tests/script/unique/mnode/mgmt33.sim new file mode 100644 index 0000000000000000000000000000000000000000..ce7cdce35d8c0463564f46d26a0711d39340c8bf --- /dev/null +++ b/tests/script/unique/mnode/mgmt33.sim @@ -0,0 +1,214 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 + +print ============== step1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql show mnodes +print dnode1 ==> $data2_1 +print dnode2 ==> $data2_2 +print dnode3 ==> $data3_3 +if $data2_1 != master then + return -1 +endi +if $data3_2 != null then + return -1 +endi +if $data3_3 != null then + return -1 +endi + +print ============== step2 +system sh/exec.sh -n dnode2 -s start +sql create dnode $hostname2 + +$x = 0 +step2: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show mnodes +$dnode1Role = $data2_1 +$dnode2Role = $data2_2 +$dnode3Role = $data2_3 +print dnode1 ==> $dnode1Role +print dnode2 ==> $dnode2Role +print dnode3 ==> $dnode3Role + +if $dnode1Role != master then + goto step2 +endi +if $dnode2Role != slave then + goto step2 +endi +if $dnode3Role != null then + goto step2 +endi + +print ============== step3 +system sh/exec.sh -n dnode3 -s start +sql create dnode $hostname3 + +$x = 0 +step3: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show mnodes +$dnode1Role = $data2_1 +$dnode2Role = $data2_2 +$dnode3Role = $data2_3 +print dnode1 ==> $dnode1Role +print dnode2 ==> $dnode2Role +print dnode3 ==> $dnode3Role + +if $dnode1Role != master then + goto step3 +endi +if $dnode2Role != slave then + goto step3 +endi +if $dnode3Role != slave then + goto step3 +endi + +print ============== step4 +sql drop dnode $hostname2 + +$x = 0 +step4: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show mnodes +$dnode1Role = $data2_1 +$dnode2Role = $data2_2 +$dnode3Role = $data2_3 +print dnode1 ==> $dnode1Role +print dnode2 ==> $dnode2Role +print dnode3 ==> $dnode3Role + +if $dnode1Role != master then + goto step4 +endi +if $dnode2Role != null then + goto step4 +endi +if $dnode3Role != slave then + goto step4 +endi + +system sh/exec.sh -n dnode2 -s stop +system sh/deploy.sh -n dnode2 -i 2 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/exec.sh -n dnode2 -s start + +print ============== step5 +sql create dnode $hostname2 + +$x = 0 +step5: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show mnodes +$dnode1Role = $data2_1 +$dnode2Role = $data2_4 +$dnode3Role = $data2_3 +print dnode1 ==> $dnode1Role +print dnode2 ==> $dnode2Role +print dnode3 ==> $dnode3Role + +if $dnode1Role != master then + goto step5 +endi +if $dnode2Role != slave then + goto step5 +endi +if $dnode3Role != slave then + goto step5 +endi + +print ============== step6 +system sh/exec.sh -n dnode1 -s stop +$x = 0 +step6: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show mnodes -x step6 +$dnode1Role = $data2_1 +$dnode2Role = $data2_4 +$dnode3Role = $data2_3 +print dnode1 ==> $dnode1Role +print dnode2 ==> $dnode2Role +print dnode3 ==> $dnode3Role + +if $dnode1Role != offline then + goto step6 +endi +#if $dnode2Role != master then +# return -1 +#endi +#if $dnode3Role != slave then +# return -1 +#endi + +print ============== step7 +sql drop dnode $hostname1 +$x = 0 +step7: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show mnodes -x step7 +$dnode1Role = $data2_1 +$dnode2Role = $data2_2 +$dnode3Role = $data2_3 +print dnode1 ==> $dnode1Role +print dnode2 ==> $dnode2Role +print dnode3 ==> $dnode3Role + +if $dnode1Role != null then + goto step7 +endi +#if $dnode2Role != master then +# return -1 +#endi +#if $dnode3Role != slave then +# return -1 +#endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/mnode/mgmt34.sim b/tests/script/unique/mnode/mgmt34.sim new file mode 100644 index 0000000000000000000000000000000000000000..d8a46b0955f59273279bbbc5c89c07c05db672d7 --- /dev/null +++ b/tests/script/unique/mnode/mgmt34.sim @@ -0,0 +1,269 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 3 + +print ============== step1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql show mnodes +print dnode1 ==> $data2_1 +print dnode2 ==> $data2_2 +print dnode3 ==> $data3_3 +if $data2_1 != master then + return -1 +endi +if $data3_2 != null then + return -1 +endi +if $data3_3 != null then + return -1 +endi + +print ============== step2 +system sh/exec.sh -n dnode2 -s start +sql create dnode $hostname2 +$x = 0 +step2: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show mnodes +$dnode1Role = $data2_1 +$dnode2Role = $data2_2 +$dnode3Role = $data2_3 +$dnode4Role = $data2_4 +print dnode1 ==> $dnode1Role +print dnode2 ==> $dnode2Role +print dnode3 ==> $dnode3Role +print dnode4 ==> $dnode4Role + +if $dnode1Role != master then + goto step2 +endi +if $dnode2Role != slave then + goto step2 +endi +if $dnode3Role != null then + goto step2 +endi +if $dnode4Role != null then + goto step2 +endi + +print ============== step3 +system sh/exec.sh -n dnode3 -s start +sql create dnode $hostname3 + +$x = 0 +step3: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show mnodes +$dnode1Role = $data2_1 +$dnode2Role = $data2_2 +$dnode3Role = $data2_3 +$dnode4Role = $data2_4 +print dnode1 ==> $dnode1Role +print dnode2 ==> $dnode2Role +print dnode3 ==> $dnode3Role +print dnode4 ==> $dnode4Role + +if $dnode1Role != master then + goto step3 +endi +if $dnode2Role != slave then + goto step3 +endi +if $dnode3Role != slave then + goto step3 +endi +if $dnode4Role != null then + goto step3 +endi + + +print ============== step4 +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname4 +$x = 0 +step4: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show mnodes +$dnode1Role = $data2_1 +$dnode2Role = $data2_2 +$dnode3Role = $data2_3 +$dnode4Role = $data2_4 +print dnode1 ==> $dnode1Role +print dnode2 ==> $dnode2Role +print dnode3 ==> $dnode3Role +print dnode4 ==> $dnode4Role + +if $dnode1Role != master then + goto step4 +endi +if $dnode2Role != slave then + goto step4 +endi +if $dnode3Role != slave then + goto step4 +endi +if $dnode4Role != null then + goto step4 +endi + +print ============== step5 +sql drop dnode $hostname2 +$x = 0 +step5: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show mnodes +$dnode1Role = $data2_1 +$dnode2Role = $data2_2 +$dnode3Role = $data2_3 +$dnode4Role = $data2_4 +print dnode1 ==> $dnode1Role +print dnode2 ==> $dnode2Role +print dnode3 ==> $dnode3Role +print dnode4 ==> $dnode4Role + +if $dnode1Role != master then + goto step5 +endi +if $dnode2Role != null then + goto step5 +endi +if $dnode3Role != slave then + goto step5 +endi +if $dnode4Role != slave then + goto step5 +endi + +system sh/exec.sh -n dnode2 -s stop +system sh/deploy.sh -n dnode2 -i 2 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/exec.sh -n dnode2 -s start + +print ============== step6 +sql create dnode $hostname2 +$x = 0 +step6: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show mnodes +$dnode1Role = $data2_1 +$dnode2Role = $data2_2 +$dnode3Role = $data2_3 +$dnode4Role = $data2_4 +print dnode1 ==> $dnode1Role +print dnode2 ==> $dnode2Role +print dnode3 ==> $dnode3Role +print dnode4 ==> $dnode4Role + +if $dnode1Role != master then + goto step6 +endi +if $dnode2Role != null then + goto step6 +endi +if $dnode3Role != slave then + goto step6 +endi +if $dnode4Role != slave then + goto step6 +endi + +print ============== step7 +system sh/exec.sh -n dnode1 -s stop +$x = 0 +step7: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show mnodes -x step7 +$dnode1Role = $data2_1 +$dnode2Role = $data2_2 +$dnode3Role = $data2_3 +$dnode4Role = $data2_4 +print dnode1 ==> $dnode1Role +print dnode2 ==> $dnode2Role +print dnode3 ==> $dnode3Role +print dnode4 ==> $dnode4Role + +if $dnode1Role != offline then + goto step7 +endi + +print ============== step8 +sql drop dnode $hostname1 +step8: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show mnodes -x step8 +$dnode1Role = $data2_1 +$dnode2Role = $data2_5 +$dnode3Role = $data2_3 +$dnode4Role = $data2_4 +print dnode1 ==> $dnode1Role +print dnode2 ==> $dnode2Role +print dnode3 ==> $dnode3Role +print dnode4 ==> $dnode4Role + +if $dnode1Role != null then + goto step8 +endi +if $dnode2Role != slave then + goto step8 +endi +#if $dnode3Role != master then +# return -1 +#endi +#if $dnode4Role != slave then +# return -1 +#endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/mnode/mgmtr2.sim b/tests/script/unique/mnode/mgmtr2.sim new file mode 100644 index 0000000000000000000000000000000000000000..5afb41905846bff3ce9894e928245a7d34078354 --- /dev/null +++ b/tests/script/unique/mnode/mgmtr2.sim @@ -0,0 +1,87 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 2 + +print ============== step1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +sql show mnodes +$dnode1Role = $data2_1 +$dnode2Role = $data2_2 +$dnode3Role = $data2_3 +print dnode1 ==> $dnode1Role +print dnode2 ==> $dnode2Role +print dnode3 ==> $dnode3Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != null then + return -1 +endi +if $dnode3Role != null then + return -1 +endi + +print ============== step2 +sql create dnode $hostname2 +sql create dnode $hostname3 + +print ============== step3 +print ========= start dnode2 and dnode3 + +system sh/exec.sh -n dnode2 -s start +sleep 1000 +system sh/exec.sh -n dnode3 -s start + +sleep 8000 +system sh/exec.sh -n dnode2 -s stop +system sh/exec.sh -n dnode3 -s stop +sleep 4000 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sleep 4000 +system sh/exec.sh -n dnode2 -s stop +system sh/exec.sh -n dnode3 -s stop +sleep 4000 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start + +print ============== step4 +$x = 0 +step4: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show mnodes + +$dnode1Role = $data2_1 +$dnode2Role = $data2_2 +$dnode3Role = $data2_3 +print dnode1 ==> $dnode1Role +print dnode2 ==> $dnode2Role +print dnode3 ==> $dnode3Role + +if $dnode1Role != master then + goto step4 +endi +if $dnode2Role != slave then + goto step4 +endi +if $dnode3Role != null then + goto step4 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/mnode/testSuite.sim b/tests/script/unique/mnode/testSuite.sim new file mode 100644 index 0000000000000000000000000000000000000000..b9adbe06a282548d56d7e7feb8a36f99198d8c0d --- /dev/null +++ b/tests/script/unique/mnode/testSuite.sim @@ -0,0 +1,9 @@ +run unique/mnode/mgmt21.sim +run unique/mnode/mgmt22.sim +run unique/mnode/mgmt23.sim +run unique/mnode/mgmt24.sim +run unique/mnode/mgmt25.sim +run unique/mnode/mgmt26.sim +run unique/mnode/mgmt33.sim +run unique/mnode/mgmt34.sim +run unique/mnode/mgmtr2.sim diff --git a/tests/script/unique/stable/balance_replica1.sim b/tests/script/unique/stable/balance_replica1.sim new file mode 100644 index 0000000000000000000000000000000000000000..3ea158eb39c0d560900b34d5465fc1ef12a4b42f --- /dev/null +++ b/tests/script/unique/stable/balance_replica1.sim @@ -0,0 +1,143 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/cfg.sh -n dnode1 -c statusInterval -v 1 +system sh/cfg.sh -n dnode2 -c statusInterval -v 1 +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 + +$dbPrefix = br1_db +$tbPrefix = br1_tb +$mtPrefix = br1_mt +$tbNum = 13 +$rowNum = 200 +$totalNum = 200 + +print ============== step1 +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start +sql connect + +$i = 0 +$db = $dbPrefix +$mt = $mtPrefix +$st = $stPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + $y = 0 + while $y < $rowNum + $val = $x * 60000 + $ms = 1519833600000 + $val + sql insert into $tb values ($ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 + +$x = 0 +show1: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi +sql show dnodes -x show1 +$dnode1Vnodes = $data2_1 +print dnode1 $dnode1Vnodes +$dnode2Vnodes = $data2_2 +print dnode2 $dnode2Vnodes + +if $dnode1Vnodes != 4 then + goto show1 +endi +if $dnode2Vnodes != null then + goto show1 +endi +print =============== step3 start dnode2 +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start +sleep 8000 + +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi +sql show dnodes -x show2 +$dnode1Vnodes = $data2_1 +print dnode1 $dnode1Vnodes +$dnode2Vnodes = $data2_2 +print dnode2 $dnode2Vnodes + +if $dnode1Vnodes != 2 then + goto show2 +endi +if $dnode2Vnodes != 2 then + goto show2 +endi + + +print =============== step4 +$i = 1 +$tb = $tbPrefix . $i +sql select * from $tb +print select * from $tb ==> $rows +if $rows != 200 then + return -1 +endi + +$i = 5 +$tb = $tbPrefix . $i +sql select * from $tb +print select * from $tb ==> $rows +if $rows != 200 then + return -1 +endi + +$i = 8 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $tb +print select * from $tb ==> $rows +if $rows != 200 then + return -1 +endi + +print =============== step5 +sql select * from $mt +print select * from $mt ==> $rows +if $rows != 2600 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/stable/dnode2.sim b/tests/script/unique/stable/dnode2.sim new file mode 100644 index 0000000000000000000000000000000000000000..3ca8c4ee20bb74890da8f42c73521186306e3097 --- /dev/null +++ b/tests/script/unique/stable/dnode2.sim @@ -0,0 +1,202 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sql connect + +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_2 == offline then + goto createDnode +endi + +print ======================== dnode1 start + +$dbPrefix = d2_db +$tbPrefix = d2_tb +$mtPrefix = d2_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $val = $x * 60000 + $ms = 1519833600000 + $val + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sql show vgroups +print vgroups ==> $rows +if $rows != 3 then + return -1 +endi + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +sql select count(tbcol) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step3 +sql select count(tbcol) from $tb where ts <= 1519833840000 +print ===> $data00 +if $data00 != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol) as b from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step5 +sql select count(tbcol) as b from $tb interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi + +sql select count(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != $rowNum then + return -1 +endi + +print =============== step6 +sql select count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select count(*) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +sql select count(tbcol) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +print =============== step8 +sql select count(tbcol) as c from $mt where ts <= 1519833840000 +print ===> $data00 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 and ts <= 1519833840000 +print ===> $data00 +if $data00 != 25 then + return -1 +endi + +print =============== step9 +sql select count(tbcol) as b from $mt interval(1m) +print ===> $data01 +if $data01 != 10 then + return -1 +endi + +sql select count(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 200 then + return -1 +endi + +print =============== step10 +sql select count(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select count(tbcol) as b from $mt where ts <= 1519833840000 interval(1m) group by tgcol +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/stable/dnode2_stop.sim b/tests/script/unique/stable/dnode2_stop.sim new file mode 100644 index 0000000000000000000000000000000000000000..c10f04338d894106a6a543a872af69da9e49bae5 --- /dev/null +++ b/tests/script/unique/stable/dnode2_stop.sim @@ -0,0 +1,156 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sql connect +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_2 == offline then + goto createDnode +endi + +print ======================== dnode1 start + +$dbPrefix = d2s_db +$tbPrefix = d2s_tb +$mtPrefix = d2s_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +sql show dnodes; +print dnodes ==> $rows +if $rows != 2 then + return -1 +endi + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $val = $x * 60000 + $ms = 1519833600000 + $val + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sql show vgroups +print vgroups ==> $rows +if $rows != 3 then + return -1 +endi + +sleep 100 + +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 3000 + +print =============== step2 +sql select count(*) from $mt -x step2 + return -1 +step2: + +sql select count(tbcol) from $mt -x step21 + return -1 +step21: + +system sh/exec.sh -n dnode2 -s start +sleep 3000 + +print =============== step3 +sql select count(tbcol) as c from $mt where ts <= 1519833840000 +print ===> $data00 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 and ts <= 1519833840000 +print ===> $data00 +if $data00 != 25 then + return -1 +endi + +print =============== step4 +sql select count(tbcol) as b from $mt interval(1m) +print ===> $data01 +if $data01 != 10 then + return -1 +endi + +sql select count(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 200 then + return -1 +endi + +print =============== step5 +sql select count(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step6 +sql select count(tbcol) as b from $mt where ts <= 1519833840000 interval(1m) group by tgcol +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/stable/dnode3.sim b/tests/script/unique/stable/dnode3.sim new file mode 100644 index 0000000000000000000000000000000000000000..d0708c81542f13634466053d7159c119687dfa04 --- /dev/null +++ b/tests/script/unique/stable/dnode3.sim @@ -0,0 +1,229 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode3 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sql connect + +sql create dnode $hostname2 +sql create dnode $hostname3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start + +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_2 == offline then + goto createDnode +endi +if $data4_3 == offline then + goto createDnode +endi + + +print ======================== dnode1 start + +$dbPrefix = d3_db +$tbPrefix = d3_tb +$mtPrefix = d3_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $val = $x * 60000 + $ms = 1519833600000 + $val + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sql show vgroups +print vgroups ==> $rows +if $rows != 3 then + return -1 +endi + +sql show dnodes +$dnode1Vnodes = $data2_1 +print dnode1 $dnode1Vnodes +$dnode2Vnodes = $data2_2 +print dnode2 $dnode2Vnodes +$dnode3Vnodes = $data2_3 +print dnode3 $dnode3Vnodes + +if $dnode1Vnodes != 1 then + return -1 +endi +if $dnode2Vnodes != 1 then + return -1 +endi +if $dnode3Vnodes != 1 then + return -1 +endi + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +sql select count(tbcol) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step3 +sql select count(tbcol) from $tb where ts <= 1519833840000 +print ===> $data00 +if $data00 != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol) as b from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step5 +sql select count(tbcol) as b from $tb interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi + +sql select count(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != $rowNum then + return -1 +endi + +print =============== step6 +sql select count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select count(*) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +sql select count(tbcol) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +print =============== step8 +sql select count(tbcol) as c from $mt where ts <= 1519833840000 +print ===> $data00 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 and ts <= 1519833840000 +print ===> $data00 +if $data00 != 25 then + return -1 +endi + +print =============== step9 +sql select count(tbcol) as b from $mt interval(1m) +print ===> $data01 +if $data01 != 10 then + return -1 +endi + +sql select count(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 200 then + return -1 +endi + +print =============== step10 +sql select count(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select count(tbcol) as b from $mt where ts <= 1519833840000 interval(1m) group by tgcol +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/stable/replica2_dnode4.sim b/tests/script/unique/stable/replica2_dnode4.sim new file mode 100644 index 0000000000000000000000000000000000000000..4f8211d5d4b7ec5cbee3bee8104d0842346978d6 --- /dev/null +++ b/tests/script/unique/stable/replica2_dnode4.sim @@ -0,0 +1,218 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sql connect + +sql create dnode $hostname2 +sql create dnode $hostname3 +sql create dnode $hostname4 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start + +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_2 == offline then + goto createDnode +endi +if $data4_3 == offline then + goto createDnode +endi +if $data4_4 == offline then + goto createDnode +endi + +print ======================== dnode1 start + +$dbPrefix = r2d4_db +$tbPrefix = r2d4_tb +$mtPrefix = r2d4_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db replica 2 +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $val = $x * 60000 + $ms = 1519833600000 + $val + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sql show vgroups +print vgroups ==> $rows +if $rows != 3 then + return -1 +endi + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +sql select count(tbcol) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step3 +sql select count(tbcol) from $tb where ts <= 1519833840000 +print ===> $data00 +if $data00 != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol) as b from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step5 +sql select count(tbcol) as b from $tb interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi + +sql select count(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != $rowNum then + return -1 +endi + +print =============== step6 +sql select count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select count(*) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +sql select count(tbcol) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +print =============== step8 +sql select count(tbcol) as c from $mt where ts <= 1519833840000 +print ===> $data00 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 and ts <= 1519833840000 +print ===> $data00 +if $data00 != 25 then + return -1 +endi + +print =============== step9 +sql select count(tbcol) as b from $mt interval(1m) +print ===> $data01 +if $data01 != 10 then + return -1 +endi + +sql select count(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 200 then + return -1 +endi + +print =============== step10 +sql select count(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select count(tbcol) as b from $mt where ts <= 1519833840000 interval(1m) group by tgcol +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 50 then + return -1 +endi +return +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/stable/replica2_vnode3.sim b/tests/script/unique/stable/replica2_vnode3.sim new file mode 100644 index 0000000000000000000000000000000000000000..47d45c3d3d7d7a4e32cf94fd8cf4d7dcb0b53477 --- /dev/null +++ b/tests/script/unique/stable/replica2_vnode3.sim @@ -0,0 +1,199 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sql connect +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_2 == offline then + goto createDnode +endi + +print ======================== dnode1 start + +$dbPrefix = r2v3_db +$tbPrefix = r2v3_tb +$mtPrefix = r2v3_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db replica 2 +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $val = $x * 60000 + $ms = 1519833600000 + $val + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sql show vgroups +print vgroups ==> $rows +if $rows != 3 then + return -1 +endi + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +sql select count(tbcol) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step3 +sql select count(tbcol) from $tb where ts <= 1519833840000 +print ===> $data00 +if $data00 != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol) as b from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step5 +sql select count(tbcol) as b from $tb interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi + +sql select count(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != $rowNum then + return -1 +endi + +print =============== step6 +sql select count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select count(*) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +sql select count(tbcol) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +print =============== step8 +sql select count(tbcol) as c from $mt where ts <= 1519833840000 +print ===> $data00 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 and ts <= 1519833840000 +print ===> $data00 +if $data00 != 25 then + return -1 +endi + +print =============== step9 +sql select count(tbcol) as b from $mt interval(1m) +print ===> $data01 +if $data01 != 10 then + return -1 +endi + +sql select count(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 200 then + return -1 +endi + +print =============== step10 +sql select count(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select count(tbcol) as b from $mt where ts <= 1519833840000 interval(1m) group by tgcol +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 50 then + return -1 +endi +return +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/stable/replica3_dnode6.sim b/tests/script/unique/stable/replica3_dnode6.sim new file mode 100644 index 0000000000000000000000000000000000000000..eeffb86cdbeefaeaf351ec5be3743e53136692ec --- /dev/null +++ b/tests/script/unique/stable/replica3_dnode6.sim @@ -0,0 +1,242 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/deploy.sh -n dnode5 -i 5 +system sh/deploy.sh -n dnode6 -i 6 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 +system sh/cfg.sh -n dnode5 -c walLevel -v 2 +system sh/cfg.sh -n dnode6 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode6 -c maxtablesPerVnode -v 4 + +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create dnode $hostname2 +sql create dnode $hostname3 +sql create dnode $hostname4 +sql create dnode $hostname5 +sql create dnode $hostname6 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +system sh/exec.sh -n dnode5 -s start +system sh/exec.sh -n dnode6 -s start + +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_2 == offline then + goto createDnode +endi +if $data4_3 == offline then + goto createDnode +endi +if $data4_4 == offline then + goto createDnode +endi +if $data4_5 == offline then + goto createDnode +endi +if $data4_6 == offline then + goto createDnode +endi + +print ======================== dnode1 start + +$dbPrefix = r3d6_db +$tbPrefix = r3d6_tb +$mtPrefix = r3d6_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +sql show dnodes; +print dnodes ==> $rows +if $rows != 6 then + return -1 +endi + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db replica 3 +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $val = $x * 60000 + $ms = 1519833600000 + $val + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sql show vgroups +print vgroups ==> $rows +if $rows != 3 then + return -1 +endi + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +sql select count(tbcol) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step3 +sql select count(tbcol) from $tb where ts <= 1519833840000 +print ===> $data00 +if $data00 != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol) as b from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step5 +sql select count(tbcol) as b from $tb interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi + +sql select count(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != $rowNum then + return -1 +endi + +print =============== step6 +sql select count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select count(*) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +sql select count(tbcol) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +print =============== step8 +sql select count(tbcol) as c from $mt where ts <= 1519833840000 +print ===> $data00 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 and ts <= 1519833840000 +print ===> $data00 +if $data00 != 25 then + return -1 +endi + +print =============== step9 +#sql select count(tbcol) as b from $mt interval(1m) +#print ===> $data01 +#if $data01 != 10 then +# return -1 +#endi + +sql select count(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 200 then + return -1 +endi + +print =============== step10 +sql select count(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select count(tbcol) as b from $mt where ts <= 1519833840000 interval(1m) group by tgcol +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 50 then + return -1 +endi +return +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/stable/replica3_vnode3.sim b/tests/script/unique/stable/replica3_vnode3.sim new file mode 100644 index 0000000000000000000000000000000000000000..bc700b7dda1cf95c96f16907fa207cd0c47819d1 --- /dev/null +++ b/tests/script/unique/stable/replica3_vnode3.sim @@ -0,0 +1,219 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sql connect + +sql create dnode $hostname2 +sql create dnode $hostname3 +sql create dnode $hostname4 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_2 == offline then + goto createDnode +endi +if $data4_3 == offline then + goto createDnode +endi +if $data4_4 == offline then + goto createDnode +endi + +print ======================== dnode1 start + +$dbPrefix = r3v3_db +$tbPrefix = r3v3_tb +$mtPrefix = r3v3_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db replica 3 +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $val = $x * 60000 + $ms = 1519833600000 + $val + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sql show vgroups +print vgroups ==> $rows +if $rows != 3 then + return -1 +endi + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +sql select count(tbcol) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step3 +sql select count(tbcol) from $tb where ts <= 1519833840000 +print ===> $data00 +if $data00 != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol) as b from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step5 +sql select count(tbcol) as b from $tb interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi + +sql select count(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != $rowNum then + return -1 +endi + +print =============== step6 +sql select count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +print select count(*) from $mt +sql select count(*) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +sql select count(tbcol) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +print =============== step8 +sql select count(tbcol) as c from $mt where ts <= 1519833840000 +print ===> $data00 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 and ts <= 1519833840000 +print ===> $data00 +if $data00 != 25 then + return -1 +endi + +print =============== step9 +sql select count(tbcol) as b from $mt interval(1m) +print ===> $data01 +if $data01 != 10 then + return -1 +endi + +sql select count(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 200 then + return -1 +endi + +print =============== step10 +sql select count(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select count(tbcol) as b from $mt where ts <= 1519833840000 interval(1m) group by tgcol +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/stable/testSuite.sim b/tests/script/unique/stable/testSuite.sim new file mode 100644 index 0000000000000000000000000000000000000000..2e3ab31a44201f8e01fd70d8a0b2dffe8f51d7df --- /dev/null +++ b/tests/script/unique/stable/testSuite.sim @@ -0,0 +1,8 @@ +run unique/metrics/balance_replica1.sim +run unique/metrics/dnode2_stop.sim +run unique/metrics/dnode2.sim +run unique/metrics/dnode3.sim +run unique/metrics/replica2_dnode4.sim +run unique/metrics/replica2_vnode3.sim +run unique/metrics/replica3_dnode6.sim +run unique/metrics/replica3_vnode3.sim \ No newline at end of file diff --git a/tests/script/unique/stream/metrics_balance.sim b/tests/script/unique/stream/metrics_balance.sim new file mode 100644 index 0000000000000000000000000000000000000000..ff48c2236709635c8d1a790104b0185144a96866 --- /dev/null +++ b/tests/script/unique/stream/metrics_balance.sim @@ -0,0 +1,312 @@ +system sh/stop_dnodes.sh + + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/cfg.sh -n dnode1 -c statusInterval -v 1 +system sh/cfg.sh -n dnode2 -c statusInterval -v 1 +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = mt +$stPrefix = st +$tbNum = 3 +$rowNum = 200 + +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start +sql connect + +print ============== step1 +$db = $dbPrefix +sql create database $db +sql use $db + +$i = 0 +$st = $stPrefix . $i +$mt = $mtPrefix . $i +$tbNum = 3 +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + if $i == 0 then + sleep 2000 + endi + + $x = 0 + $y = 0 + while $y < $rowNum + $ms = $x . s + sql insert into $tb values (now + $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(10s) + +$st = $stPrefix . $i +$mt = $mtPrefix . $i +$tbNum = 6 +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + if $i == 0 then + sleep 2000 + endi + + $x = 0 + $y = 0 + while $y < $rowNum + $ms = $x . s + sql insert into $tb values (now + $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(10s) + +$st = $stPrefix . $i +$mt = $mtPrefix . $i +$tbNum = 9 +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + if $i == 0 then + sleep 2000 + endi + + $x = 0 + $y = 0 + while $y < $rowNum + $ms = $x . s + sql insert into $tb values (now + $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(10s) + +$st = $stPrefix . $i +$mt = $mtPrefix . $i +$tbNum = 12 +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + if $i == 0 then + sleep 2000 + endi + + $x = 0 + $y = 0 + while $y < $rowNum + $ms = $x . s + sql insert into $tb values (now + $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(10s) + + +print =============== step2 + +sql show tables +if $rows != 16 then + return -1 +endi + +print =============== step3 +print sleep 22 seconds +sleep 22000 + +$i = 0 +$mt = $mtPrefix . $i +$st = $stPrefix . $i +sql select * from $st +$r0 = $rows +print $st ==> $r0 $data00 $data01 $data10 $data11 + +$i = 3 +$mt = $mtPrefix . $i +$st = $stPrefix . $i +sql select * from $st +$r3 = $rows +print $st ==> $r3 $data00 $data01 $data10 $data11 + +$i = 6 +$mt = $mtPrefix . $i +$st = $stPrefix . $i +sql select * from $st +$r6 = $rows +print $st ==> $r6 $data00 $data01 $data10 $data11 + +$i = 9 +$mt = $mtPrefix . $i +$st = $stPrefix . $i +sql select * from $st +$r9 = $rows +print $st ==> $r9 $data00 $data01 $data10 $data11 + +print rows0=>$r0 rows3=>$r3 rows6=>$r6 rows9=>$r9 + +$x = 0 +show1: + $x = $x + 1 + sleep 2000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show1 +$dnode1Vnodes = $data3_192.168.0.1 +print dnode1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print dnode2 $dnode2Vnodes + +if $dnode1Vnodes != 0 then + goto show1 +endi +if $dnode2Vnodes != NULL then + goto show1 +endi + +print =============== step4 start dnode2 +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start +sleep 8000 + +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show2 +$dnode1Vnodes = $data3_192.168.0.1 +print dnode1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print dnode2 $dnode2Vnodes + +if $dnode1Vnodes != 2 then + goto show2 +endi +if $dnode2Vnodes != 2 then + goto show2 +endi + +print rows0=>$r0 rows3=>$r3 rows6=>$r6 rows9=>$r9 +print =============== step5 +print sleep 22 seconds +sleep 22000 + +print =============== step6 +$i = 0 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $tb +if $rows != $rowNum then + return -1 +endi + +$i = 3 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $tb +if $rows != $rowNum then + return -1 +endi + +$i = 6 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $tb +if $rows != $rowNum then + return -1 +endi + +$i = 9 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $tb +if $rows != $rowNum then + return -1 +endi + +print rows0=>$r0 rows3=>$r3 rows6=>$r6 rows9=>$r9 +print =============== step7 +$i = 0 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $st +print $st ==> $r0 $rows , $data00 $data01 $data10 $data11 +if $rows == 0 then + return -1 +endi +if $rows <= $r0 then + return -1 +endi + +$i = 3 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $st +print $st ==> $r3 $rows , $data00 $data01 $data10 $data11 +if $rows == 0 then + return -1 +endi +if $rows <= $r3 then + return -1 +endi + + +$i = 6 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $st +print $st ==> $r6 $rows , $data00 $data01 $data10 $data11 +if $rows == 0 then + return -1 +endi +if $rows <= $r6 then + return -1 +endi + +$i = 9 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $st +print $st ==> $r0 $rows , $data00 $data01 $data10 $data11 +if $rows == 0 then + return -1 +endi +if $rows <= $r9 then + return -1 +endi + +print =============== clear +system sh/exec.sh -n dnode1 -s stop +system sh/exec.sh -n dnode2 -s stop + diff --git a/tests/script/unique/stream/metrics_replica1_dnode2.sim b/tests/script/unique/stream/metrics_replica1_dnode2.sim new file mode 100644 index 0000000000000000000000000000000000000000..20c37cefc39f8fa6393d49934adb046f409fca25 --- /dev/null +++ b/tests/script/unique/stream/metrics_replica1_dnode2.sim @@ -0,0 +1,260 @@ +system sh/stop_dnodes.sh + + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sql connect + +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_192.168.0.2 == offline then + goto createDnode +endi +print ======================== dnode1 start + +$dbPrefix = m1d_db +$tbPrefix = m1d_tb +$mtPrefix = m1d_mt +$stPrefix = m1d_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c1 + +sql select count(*) from $mt interval(1d) +print select count(*) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c1 +sql create table $st as select count(*) from $mt interval(1d) + +print =============== step3 c2 +sql select count(tbcol) from $mt interval(1d) +print select count(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c2 +sql create table $st as select count(tbcol) from $mt interval(1d) + +print =============== step4 c3 +sql select count(tbcol2) from $mt interval(1d) +print select count(tbcol2) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c3 +sql create table $st as select count(tbcol2) from $mt interval(1d) + +print =============== step5 avg +sql select avg(tbcol) from $mt interval(1d) +print select avg(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . av +sql create table $st as select avg(tbcol) from $mt interval(1d) + +print =============== step6 su +sql select sum(tbcol) from $mt interval(1d) +print select sum(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 1900 then + return -1 +endi + +$st = $stPrefix . su +sql create table $st as select sum(tbcol) from $mt interval(1d) + +print =============== step7 mi +sql select min(tbcol) from $mt interval(1d) +print select min(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . mi +sql create table $st as select min(tbcol) from $mt interval(1d) + +print =============== step8 ma +sql select max(tbcol) from $mt interval(1d) +print select max(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . ma +sql create table $st as select max(tbcol) from $mt interval(1d) + +print =============== step9 fi +sql select first(tbcol) from $mt interval(1d) +print select first(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . fi +sql create table $st as select first(tbcol) from $mt interval(1d) + +print =============== step10 la +sql select last(tbcol) from $mt interval(1d) +print select last(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . la +sql create table $st as select last(tbcol) from $mt interval(1d) + +print =============== step11 wh +sql select count(tbcol) from $mt where ts < now + 4m interval(1d) +print select count(tbcol) from $mt where ts < now + 4m interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . wh +#sql create table $st as select count(tbcol) from $mt where ts < now + 4m interval(1d) + +print =============== step12 as +sql select count(tbcol) from $mt interval(1d) +print select count(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . as +sql create table $st as select count(tbcol) as c from $mt interval(1d) + +print =============== step13 +print sleep 22 seconds +sleep 32000 + +print =============== step14 +$st = $stPrefix . c1 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c2 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c3 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . av +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . su +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 1900 then + return -1 +endi + +$st = $stPrefix . mi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . ma +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . fi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . la +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . wh +#sql select * from $st +#print ===> select * from $st ===> $data00 $data01 +#if $data01 != 200 then +# return -1 +#endi + +$st = $stPrefix . as +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi diff --git a/tests/script/unique/stream/metrics_replica2_dnode2.sim b/tests/script/unique/stream/metrics_replica2_dnode2.sim new file mode 100644 index 0000000000000000000000000000000000000000..aa8c1871017982cecc695abc8f64d732a8a7fc4e --- /dev/null +++ b/tests/script/unique/stream/metrics_replica2_dnode2.sim @@ -0,0 +1,260 @@ +system sh/stop_dnodes.sh + + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sql connect + +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_192.168.0.2 == offline then + goto createDnode +endi + + +print ======================== dnode1 start + +$dbPrefix = m2d_db +$tbPrefix = m2d_tb +$mtPrefix = m2d_mt +$stPrefix = m2d_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db replica 2 +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c1 + +sql select count(*) from $mt interval(1d) +print select count(*) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c1 +sql create table $st as select count(*) from $mt interval(1d) + +print =============== step3 c2 +sql select count(tbcol) from $mt interval(1d) +print select count(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c2 +sql create table $st as select count(tbcol) from $mt interval(1d) + +print =============== step4 c3 +sql select count(tbcol2) from $mt interval(1d) +print select count(tbcol2) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c3 +sql create table $st as select count(tbcol2) from $mt interval(1d) + +print =============== step5 avg +sql select avg(tbcol) from $mt interval(1d) +print select avg(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . av +sql create table $st as select avg(tbcol) from $mt interval(1d) + +print =============== step6 su +sql select sum(tbcol) from $mt interval(1d) +print select sum(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 1900 then + return -1 +endi + +$st = $stPrefix . su +sql create table $st as select sum(tbcol) from $mt interval(1d) + +print =============== step7 mi +sql select min(tbcol) from $mt interval(1d) +print select min(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . mi +sql create table $st as select min(tbcol) from $mt interval(1d) + +print =============== step8 ma +sql select max(tbcol) from $mt interval(1d) +print select max(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . ma +sql create table $st as select max(tbcol) from $mt interval(1d) + +print =============== step9 fi +sql select first(tbcol) from $mt interval(1d) +print select first(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . fi +sql create table $st as select first(tbcol) from $mt interval(1d) + +print =============== step10 la +sql select last(tbcol) from $mt interval(1d) +print select last(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . la +sql create table $st as select last(tbcol) from $mt interval(1d) + +print =============== step11 wh +sql select count(tbcol) from $mt where ts < now + 4m interval(1d) +print select count(tbcol) from $mt where ts < now + 4m interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . wh +#sql create table $st as select count(tbcol) from $mt where ts < now + 4m interval(1d) + +print =============== step12 as +sql select count(tbcol) from $mt interval(1d) +print select count(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . as +sql create table $st as select count(tbcol) as c from $mt interval(1d) + +print =============== step13 +print sleep 22 seconds +sleep 22000 + +print =============== step14 +$st = $stPrefix . c1 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c2 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c3 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . av +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . su +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 1900 then + return -1 +endi + +$st = $stPrefix . mi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . ma +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . fi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . la +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . wh +#sql select * from $st +#print ===> select * from $st ===> $data00 $data01 +#if $data01 != 200 then +# return -1 +#endi + +$st = $stPrefix . as +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi diff --git a/tests/script/unique/stream/metrics_replica2_dnode2_vnoden.sim b/tests/script/unique/stream/metrics_replica2_dnode2_vnoden.sim new file mode 100644 index 0000000000000000000000000000000000000000..be2fcefe66ed6ca2e24a44cd22fa072201137b89 --- /dev/null +++ b/tests/script/unique/stream/metrics_replica2_dnode2_vnoden.sim @@ -0,0 +1,261 @@ +system sh/stop_dnodes.sh + + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sql connect + +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_192.168.0.2 == offline then + goto createDnode +endi + +print ======================== dnode1 start + +$dbPrefix = m2dv_db +$tbPrefix = m2dv_tb +$mtPrefix = m2dv_mt +$stPrefix = m2dv_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db replica 2 +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c1 + +sql select count(*) from $mt interval(1d) +print select count(*) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c1 +sql create table $st as select count(*) from $mt interval(1d) + +print =============== step3 c2 +sql select count(tbcol) from $mt interval(1d) +print select count(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c2 +sql create table $st as select count(tbcol) from $mt interval(1d) + +print =============== step4 c3 +sql select count(tbcol2) from $mt interval(1d) +print select count(tbcol2) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c3 +sql create table $st as select count(tbcol2) from $mt interval(1d) + +print =============== step5 avg +sql select avg(tbcol) from $mt interval(1d) +print select avg(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . av +sql create table $st as select avg(tbcol) from $mt interval(1d) + +print =============== step6 su +sql select sum(tbcol) from $mt interval(1d) +print select sum(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 1900 then + return -1 +endi + +$st = $stPrefix . su +sql create table $st as select sum(tbcol) from $mt interval(1d) + +print =============== step7 mi +sql select min(tbcol) from $mt interval(1d) +print select min(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . mi +sql create table $st as select min(tbcol) from $mt interval(1d) + +print =============== step8 ma +sql select max(tbcol) from $mt interval(1d) +print select max(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . ma +sql create table $st as select max(tbcol) from $mt interval(1d) + +print =============== step9 fi +sql select first(tbcol) from $mt interval(1d) +print select first(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . fi +sql create table $st as select first(tbcol) from $mt interval(1d) + +print =============== step10 la +sql select last(tbcol) from $mt interval(1d) +print select last(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . la +sql create table $st as select last(tbcol) from $mt interval(1d) + +print =============== step11 wh +sql select count(tbcol) from $mt where ts < now + 4m interval(1d) +print select count(tbcol) from $mt where ts < now + 4m interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . wh +#sql create table $st as select count(tbcol) from $mt where ts < now + 4m interval(1d) + +print =============== step12 as +sql select count(tbcol) from $mt interval(1d) +print select count(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . as +sql create table $st as select count(tbcol) as c from $mt interval(1d) + +print =============== step13 +print sleep 22 seconds +sleep 22000 + +print =============== step14 +$st = $stPrefix . c1 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c2 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c3 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . av +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . su +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 1900 then + return -1 +endi + +$st = $stPrefix . mi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . ma +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . fi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . la +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . wh +#sql select * from $st +#print ===> select * from $st ===> $data00 $data01 +#if $data01 != 200 then +# return -1 +#endi + +$st = $stPrefix . as +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi diff --git a/tests/script/unique/stream/metrics_replica2_dnode3.sim b/tests/script/unique/stream/metrics_replica2_dnode3.sim new file mode 100644 index 0000000000000000000000000000000000000000..f7b17610c380d9f90a2cefd4af86ea766facdffa --- /dev/null +++ b/tests/script/unique/stream/metrics_replica2_dnode3.sim @@ -0,0 +1,270 @@ +system sh/stop_dnodes.sh + + + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode3 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sql connect + +sql create dnode $hostname2 +sql create dnode $hostname3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_192.168.0.2 == offline then + goto createDnode +endi +if $data4_192.168.0.3 == offline then + goto createDnode +endi + +print ======================== dnode1 start + +$dbPrefix = m2d3_db +$tbPrefix = m2d3_tb +$mtPrefix = m2d3_mt +$stPrefix = m2d3_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db replica 2 +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c1 + +sql select count(*) from $mt interval(1d) +print select count(*) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c1 +sql create table $st as select count(*) from $mt interval(1d) + +print =============== step3 c2 +sql select count(tbcol) from $mt interval(1d) +print select count(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c2 +sql create table $st as select count(tbcol) from $mt interval(1d) + +print =============== step4 c3 +sql select count(tbcol2) from $mt interval(1d) +print select count(tbcol2) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c3 +sql create table $st as select count(tbcol2) from $mt interval(1d) + +print =============== step5 avg +sql select avg(tbcol) from $mt interval(1d) +print select avg(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . av +sql create table $st as select avg(tbcol) from $mt interval(1d) + +print =============== step6 su +sql select sum(tbcol) from $mt interval(1d) +print select sum(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 1900 then + return -1 +endi + +$st = $stPrefix . su +sql create table $st as select sum(tbcol) from $mt interval(1d) + +print =============== step7 mi +sql select min(tbcol) from $mt interval(1d) +print select min(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . mi +sql create table $st as select min(tbcol) from $mt interval(1d) + +print =============== step8 ma +sql select max(tbcol) from $mt interval(1d) +print select max(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . ma +sql create table $st as select max(tbcol) from $mt interval(1d) + +print =============== step9 fi +sql select first(tbcol) from $mt interval(1d) +print select first(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . fi +sql create table $st as select first(tbcol) from $mt interval(1d) + +print =============== step10 la +sql select last(tbcol) from $mt interval(1d) +print select last(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . la +sql create table $st as select last(tbcol) from $mt interval(1d) + +print =============== step11 wh +sql select count(tbcol) from $mt where ts < now + 4m interval(1d) +print select count(tbcol) from $mt where ts < now + 4m interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . wh +#sql create table $st as select count(tbcol) from $mt where ts < now + 4m interval(1d) + +print =============== step12 as +sql select count(tbcol) from $mt interval(1d) +print select count(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . as +sql create table $st as select count(tbcol) as c from $mt interval(1d) + +print =============== step13 +print sleep 22 seconds +sleep 22000 + +print =============== step14 +$st = $stPrefix . c1 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c2 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c3 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . av +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . su +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 1900 then + return -1 +endi + +$st = $stPrefix . mi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . ma +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . fi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . la +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . wh +#sql select * from $st +#print ===> select * from $st ===> $data00 $data01 +#if $data01 != 200 then +# return -1 +#endi + +$st = $stPrefix . as +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi diff --git a/tests/script/unique/stream/metrics_replica3_dnode4.sim b/tests/script/unique/stream/metrics_replica3_dnode4.sim new file mode 100644 index 0000000000000000000000000000000000000000..402712800313ff5b96f970d12ffe007f77bc26f7 --- /dev/null +++ b/tests/script/unique/stream/metrics_replica3_dnode4.sim @@ -0,0 +1,280 @@ +system sh/stop_dnodes.sh + + + + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode3 -c walLevel -v 1 +system sh/cfg.sh -n dnode4 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sql connect + +sql create dnode $hostname2 +sql create dnode $hostname3 +sql create dnode $hostname4 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start + +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_192.168.0.2 == offline then + goto createDnode +endi +if $data4_192.168.0.3 == offline then + goto createDnode +endi +if $data4_192.168.0.4 == offline then + goto createDnode +endi + +print ======================== dnode1 start + +$dbPrefix = m2d3_db +$tbPrefix = m2d3_tb +$mtPrefix = m2d3_mt +$stPrefix = m2d3_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db replica 2 +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c1 + +sql select count(*) from $mt interval(1d) +print select count(*) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c1 +sql create table $st as select count(*) from $mt interval(1d) + +print =============== step3 c2 +sql select count(tbcol) from $mt interval(1d) +print select count(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c2 +sql create table $st as select count(tbcol) from $mt interval(1d) + +print =============== step4 c3 +sql select count(tbcol2) from $mt interval(1d) +print select count(tbcol2) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c3 +sql create table $st as select count(tbcol2) from $mt interval(1d) + +print =============== step5 avg +sql select avg(tbcol) from $mt interval(1d) +print select avg(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . av +sql create table $st as select avg(tbcol) from $mt interval(1d) + +print =============== step6 su +sql select sum(tbcol) from $mt interval(1d) +print select sum(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 1900 then + return -1 +endi + +$st = $stPrefix . su +sql create table $st as select sum(tbcol) from $mt interval(1d) + +print =============== step7 mi +sql select min(tbcol) from $mt interval(1d) +print select min(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . mi +sql create table $st as select min(tbcol) from $mt interval(1d) + +print =============== step8 ma +sql select max(tbcol) from $mt interval(1d) +print select max(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . ma +sql create table $st as select max(tbcol) from $mt interval(1d) + +print =============== step9 fi +sql select first(tbcol) from $mt interval(1d) +print select first(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . fi +sql create table $st as select first(tbcol) from $mt interval(1d) + +print =============== step10 la +sql select last(tbcol) from $mt interval(1d) +print select last(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . la +sql create table $st as select last(tbcol) from $mt interval(1d) + +print =============== step11 wh +sql select count(tbcol) from $mt where ts < now + 4m interval(1d) +print select count(tbcol) from $mt where ts < now + 4m interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . wh +#sql create table $st as select count(tbcol) from $mt where ts < now + 4m interval(1d) + +print =============== step12 as +sql select count(tbcol) from $mt interval(1d) +print select count(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . as +sql create table $st as select count(tbcol) as c from $mt interval(1d) + +print =============== step13 +print sleep 22 seconds +sleep 22000 + +print =============== step14 +$st = $stPrefix . c1 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c2 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c3 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . av +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . su +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 1900 then + return -1 +endi + +$st = $stPrefix . mi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . ma +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . fi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . la +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . wh +#sql select * from $st +#print ===> select * from $st ===> $data00 $data01 +#if $data01 != 200 then +# return -1 +#endi + +$st = $stPrefix . as +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi diff --git a/tests/script/unique/stream/metrics_vnode_stop.sim b/tests/script/unique/stream/metrics_vnode_stop.sim new file mode 100644 index 0000000000000000000000000000000000000000..cd84cb3cdf5f8096f4986a222cc371db3900f765 --- /dev/null +++ b/tests/script/unique/stream/metrics_vnode_stop.sim @@ -0,0 +1,188 @@ +system sh/stop_dnodes.sh + + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 +system sh/exec.sh -n dnode1 -s start + +sql connect + +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_192.168.0.2 == offline then + goto createDnode +endi +print ======================== dnode start + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = mt +$stPrefix = st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql create database $db replica 2 +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c1 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $mt interval(1d) +print select count(*) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c1 +sql create table $st as select count(*) from $mt interval(1d) + +print =============== step3 +system sh/exec.sh -n dnode2 -s stop + +print =============== step4 +print sleep 22 seconds +sleep 22000 + +print =============== step5 +$st = $stPrefix . c1 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +print ============= step6 + +sql close +system sh/exec.sh -n dnode1 -s stop +system sh/exec.sh -n dnode2 -s stop +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/exec.sh -n dnode2 -s start +sleep 2000 + +$x = 0 +connectTbase2: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql connect -x connectTbase2 +sleep 2000 + +sql create dnode $hostname1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +print ======================== dnode start + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = mt +$stPrefix = st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step7 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql create database $db replica 2 +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step8 c1 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $mt interval(1d) +print select count(*) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c1 +sql create table $st as select count(*) from $mt interval(1d) + +print =============== step9 +system sh/exec.sh -n dnode1 -s stop + +print =============== step10 +print sleep 22 seconds +sleep 22000 + +print =============== step11 +$st = $stPrefix . c1 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + + + diff --git a/tests/script/unique/stream/table_balance.sim b/tests/script/unique/stream/table_balance.sim new file mode 100644 index 0000000000000000000000000000000000000000..45e054e2efdfbd7f3d01e3a860c5ac227f3327fc --- /dev/null +++ b/tests/script/unique/stream/table_balance.sim @@ -0,0 +1,238 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/cfg.sh -n dnode1 -c statusInterval -v 1 +system sh/cfg.sh -n dnode2 -c statusInterval -v 1 +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 + +$dbPrefix = tb_db +$tbPrefix = tb_tb +$mtPrefix = tb_mt +$stPrefix = tb_st +$tbNum = 10 +$rowNum = 200 +$totalNum = 200 + +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start + +sql connect + +print ============== step1 +$i = 0 +$db = $dbPrefix +$mt = $mtPrefix +$st = $stPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + if $i == 0 then + sleep 2000 + endi + + $x = 0 + $y = 0 + while $y < $rowNum + $ms = $x . s + sql insert into $tb values (now + $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 + +$i = 1 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(10s) + +$i = 5 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(10s) + +$i = 8 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(10s) + +sql show tables +if $rows != 13 then + return -1 +endi + +print =============== step3 +print sleep 22 seconds +sleep 22000 + +$i = 1 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $st +$r1 = $rows +print $st ==> $r1 $data00 $data01 $data10 $data11 + +$i = 5 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $st +$r5 = $rows +print $st ==> $r5 $data00 $data01 $data10 $data11 + +$i = 8 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $st +$r8 = $rows +print $st ==> $r8 $data00 $data01 $data10 $data11 + +print rows1=>$r1 rows5=>$r5 rows8=>$r8 + +$x = 0 +show1: + $x = $x + 1 + sleep 2000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show1 +$dnode1Vnodes = $data3_192.168.0.1 +print dnode1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print dnode2 $dnode2Vnodes + +if $dnode1Vnodes != 0 then + goto show1 +endi +if $dnode2Vnodes != NULL then + goto show1 +endi + +print =============== step4 start dnode2 +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start +sleep 8000 + +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show2 +$dnode1Vnodes = $data3_192.168.0.1 +print dnode1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print dnode2 $dnode2Vnodes + +if $dnode1Vnodes != 2 then + goto show2 +endi +if $dnode2Vnodes != 2 then + goto show2 +endi + +print rows1=>$r1 rows5=>$r5 rows8=>$r8 +print =============== step5 +print sleep 22 seconds +sleep 22000 + +print =============== step6 +$i = 1 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $tb +if $rows != $rowNum then + return -1 +endi + +$i = 5 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $tb +if $rows != $rowNum then + return -1 +endi + +$i = 8 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $tb +if $rows != $rowNum then + return -1 +endi + +print rows1=>$r1 rows5=>$r5 rows8=>$r8 +print =============== step7 +$i = 1 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $st +print $st ==> $r1 $rows , $data00 $data01 $data10 $data11 +if $rows == 0 then + return -1 +endi +if $rows <= $r1 then + return -1 +endi + +$i = 5 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $st +print $st ==> $r5 $rows , $data00 $data01 $data10 $data11 +if $rows == 0 then + return -1 +endi +if $rows <= $r5 then + return -1 +endi + + +$i = 8 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $st +print $st ==> $r8 $rows , $data00 $data01 $data10 $data11 +if $rows == 0 then + return -1 +endi +if $rows <= $r8 then + return -1 +endi + + +if $r1 != $r5 then + return -1 +endi + +if $r8 != $r5 then + return -1 +endi + +print =============== clear +system sh/exec.sh -n dnode1 -s stop +system sh/exec.sh -n dnode2 -s stop + diff --git a/tests/script/unique/stream/table_move.sim b/tests/script/unique/stream/table_move.sim new file mode 100644 index 0000000000000000000000000000000000000000..964a0c025363fd650e8051312a812fffbddaea7d --- /dev/null +++ b/tests/script/unique/stream/table_move.sim @@ -0,0 +1,269 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c statusInterval -v 1 +system sh/cfg.sh -n dnode2 -c statusInterval -v 1 +system sh/cfg.sh -n dnode3 -c statusInterval -v 1 +system sh/cfg.sh -n dnode4 -c statusInterval -v 1 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c wallevel -v 1 +system sh/cfg.sh -n dnode2 -c wallevel -v 1 +system sh/cfg.sh -n dnode3 -c wallevel -v 1 +system sh/cfg.sh -n dnode4 -c wallevel -v 1 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 0 + +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 + +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 3 + +system sh/cfg.sh -n dnode1 -c maxVnodeConnections -v 1000 +system sh/cfg.sh -n dnode1 -c maxMeterConnections -v 1000 +system sh/cfg.sh -n dnode1 -c maxShellConns -v 1000 +system sh/cfg.sh -n dnode1 -c maxMgmtConnections -v 1000 + +system sh/cfg.sh -n dnode2 -c maxVnodeConnections -v 1000 +system sh/cfg.sh -n dnode2 -c maxMeterConnections -v 1000 +system sh/cfg.sh -n dnode2 -c maxShellConns -v 1000 +system sh/cfg.sh -n dnode2 -c maxMgmtConnections -v 1000 + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = mt +$stPrefix = st +$tbNum = 5 +$rowNum = 20 +$totalNum = 200 + +print ============== step1 +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start + +sql connect +sleep 2000 + +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -20 + $y = 0 + while $y < $rowNum + $ms = $x . s + sql insert into $tb values (now $ms , $x , $x ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 0 +$tb = $tbPrefix . $i +$st = $stPrefix . $i + +sql select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) +print select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) ===> $data00 $data01 $data02, $data03 +if $data01 != $rowNum then + return -1 +endi +if $data02 != $rowNum then + return -1 +endi +if $data03 != $rowNum then + return -1 +endi + +sql show tables +if $rows != 5 then + return -1 +endi + +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(10s) + +sql show tables +if $rows != 6 then + return -1 +endi + +print =============== step3 +print sleep 22 seconds +sleep 22000 + +sql select * from $tb +if $rows != 20 then + return -1 +endi + +sql select * from $mt +if $rows != 100 then + return -1 +endi + +sql select * from $st +print select * from $st => $data01 +if $rows == 0 then + return -1 +endi + +$x = 0 +show1: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show1 +$dnode1Vnodes = $data3_192.168.0.1 +print dnode1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print dnode2 $dnode2Vnodes + +if $dnode1Vnodes != 6 then + goto show1 +endi +if $dnode2Vnodes != NULL then + goto show1 +endi + +print =============== step4 start dnode2 +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start +sleep 8000 + +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show2 +$dnode1Vnodes = $data3_192.168.0.1 +print dnode1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print dnode2 $dnode2Vnodes + +if $dnode1Vnodes != 7 then + goto show2 +endi +if $dnode2Vnodes != 7 then + goto show2 +endi + +print =============== step5 drop dnode1 +system sh/exec.sh -n dnode1 -s stop +print stop dnode1 and sleep 10000 +sleep 10000 + +sql drop dnode $hostname1 +print drop dnode1 and sleep 9000 +sleep 9000 + +$x = 0 +show6: + $x = $x + 1 + sleep 2000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show6 +$dnode1Vnodes = $data3_192.168.0.1 +print dnode1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print dnode2 $dnode2Vnodes + +if $dnode1Vnodes != NULL then + goto show6 +endi +if $dnode2Vnodes != 6 then + goto show6 +endi + +print =============== step6 + +print select * from $tb +sql select * from $tb +if $rows != 20 then + return -1 +endi + +print select * from $mt +sql select * from $mt +if $rows != 80 then + return -1 +endi + + +print =============== step7 +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + + $x = 0 + $y = 0 + while $y < $rowNum + $ms = $x . s + sql insert into $tb values (now + $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +$i = 0 +$tb = $tbPrefix . $i +$st = $stPrefix . $i + +print =============== step8 +print sleep 22 seconds +sleep 22000 + +print select * from $st +sql select * from $st +if $rows == 0 then + return -1 +endi + + +print =============== clear +system sh/exec.sh -n dnode1 -s stop +system sh/exec.sh -n dnode2 -s stop + diff --git a/tests/script/unique/stream/table_replica1_dnode2.sim b/tests/script/unique/stream/table_replica1_dnode2.sim new file mode 100644 index 0000000000000000000000000000000000000000..ccc6026e9c92975ccdd4fd12366a11f50a818d3f --- /dev/null +++ b/tests/script/unique/stream/table_replica1_dnode2.sim @@ -0,0 +1,137 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sql connect + +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_192.168.0.2 == offline then + goto createDnode +endi +print ======================== dnode1 start + +$dbPrefix = t1d_db +$tbPrefix = t1d_tb +$mtPrefix = t1d_mt +$stPrefix = t1d_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 + +$i = 1 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) +print select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) --> $data00 $data01 $data02 $data03 +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) + +$i = 5 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) +print select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) --> $data00 $data01 $data02 $data03 +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) + +$i = 8 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) +print select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) --> $data00 $data01 $data02 $data03 +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) + +sql show tables +if $rows != 13 then + return -1 +endi + +print =============== step3 +print sleep 22 seconds +sleep 22000 + + +print =============== step4 +$i = 1 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $st +print $st ==> $rows $data00 $data01 $data10 $data11 +$rows1 = $rows +if $data01 != 20 then + return -1 +endi + +$i = 5 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $st +print $st => $rows $data00 $data01 $data10 $data11 +$rows5 = $rows +if $data01 != 20 then + return -1 +endi + +$i = 8 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $st +print $st ==> $rows $data00 $data01 $data10 $data11 +$rows8 = $rows +if $data01 != 20 then + return -1 +endi + +if $rows8 != $rows5 then + return -1 +endi + +if $rows8 != $rows1 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/unique/stream/table_replica2_dnode2.sim b/tests/script/unique/stream/table_replica2_dnode2.sim new file mode 100644 index 0000000000000000000000000000000000000000..947fa0d2f9093c802a9c99c74edddeffca102d38 --- /dev/null +++ b/tests/script/unique/stream/table_replica2_dnode2.sim @@ -0,0 +1,312 @@ +system sh/stop_dnodes.sh + + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start + +sql connect + +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_192.168.0.2 == offline then + goto createDnode +endi +print ======================== dnode1 start + +$dbPrefix = t2d_db +$tbPrefix = t2d_tb +$mtPrefix = t2d_mt +$stPrefix = t2d_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db replica 2 +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c1 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb interval(1d) +print select count(*) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c1 +sql create table $st as select count(*) from $tb interval(1d) + +print =============== step3 c2 +sql select count(tbcol) from $tb interval(1d) +print select count(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c2 +sql create table $st as select count(tbcol) from $tb interval(1d) + +print =============== step4 c3 +sql select count(tbcol2) from $tb interval(1d) +print select count(tbcol2) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c3 +sql create table $st as select count(tbcol2) from $tb interval(1d) + +print =============== step5 avg +sql select avg(tbcol) from $tb interval(1d) +print select avg(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . av +sql create table $st as select avg(tbcol) from $tb interval(1d) + +print =============== step6 su +sql select sum(tbcol) from $tb interval(1d) +print select sum(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 190 then + return -1 +endi + +$st = $stPrefix . su +sql create table $st as select sum(tbcol) from $tb interval(1d) + +print =============== step7 mi +sql select min(tbcol) from $tb interval(1d) +print select min(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . mi +sql create table $st as select min(tbcol) from $tb interval(1d) + +print =============== step8 ma +sql select max(tbcol) from $tb interval(1d) +print select max(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . ma +sql create table $st as select max(tbcol) from $tb interval(1d) + +print =============== step9 fi +sql select first(tbcol) from $tb interval(1d) +print select first(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . fi +sql create table $st as select first(tbcol) from $tb interval(1d) + +print =============== step10 la +sql select last(tbcol) from $tb interval(1d) +print select last(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . la +sql create table $st as select last(tbcol) from $tb interval(1d) + +print =============== step11 st +sql select stddev(tbcol) from $tb interval(1d) +print select stddev(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 5.766281297 then + return -1 +endi + +$st = $stPrefix . std +sql create table $st as select stddev(tbcol) from $tb interval(1d) + +print =============== step12 le +sql select leastsquares(tbcol, 1, 1) from $tb interval(1d) +print select leastsquares(tbcol, 1, 1) from $tb interval(1d) ===> $data00 $data01 +#if $data01 != @(0.000017, -25362055.126740)@ then +# return -1 +#endi + +$st = $stPrefix . le +sql create table $st as select leastsquares(tbcol, 1, 1) from $tb interval(1d) + +print =============== step13 pe + +sql select percentile(tbcol, 1) from $tb interval(1d) +print select percentile(tbcol, 1) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 0.190000000 then + return -1 +endi + +$st = $stPrefix . pe +sql create table $st as select percentile(tbcol, 1) from $tb interval(1d) + +print =============== step14 wh +sql select count(tbcol) from $tb where ts < now + 4m interval(1d) +print select count(tbcol) from $tb where ts < now + 4m interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . wh +#sql create table $st as select count(tbcol) from $tb where ts < now + 4m interval(1d) + +print =============== step15 as +sql select count(tbcol) from $tb interval(1d) +print select count(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . as +sql create table $st as select count(tbcol) as c from $tb interval(1d) + +print =============== step16 +print sleep 22 seconds +sleep 22000 + +print =============== step17 +$st = $stPrefix . c1 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c2 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c3 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . av +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . su +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 190 then + return -1 +endi + +$st = $stPrefix . mi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . ma +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . fi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . la +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . std +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 5.766281297 then + return -1 +endi + +$st = $stPrefix . le +sql select * from $st +#print ===> select * from $st ===> $data00 $data01 +#if $data01 != @(0.000017, -25270086.331047)@ then +# return -1 +#endi + +$st = $stPrefix . pe +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0.190000000 then + return -1 +endi + +$st = $stPrefix . wh +#sql select * from $st +#print ===> select * from $st ===> $data00 $data01 +#if $data01 != $rowNum then +# return -1 +#endi + +$st = $stPrefix . as +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi diff --git a/tests/script/unique/stream/table_replica2_dnode2_vnoden.sim b/tests/script/unique/stream/table_replica2_dnode2_vnoden.sim new file mode 100644 index 0000000000000000000000000000000000000000..75300362393eaa543740307d4d11f9a4eabbbc50 --- /dev/null +++ b/tests/script/unique/stream/table_replica2_dnode2_vnoden.sim @@ -0,0 +1,314 @@ +system sh/stop_dnodes.sh + + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sql connect + +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_192.168.0.2 == offline then + goto createDnode +endi +print ======================== dnode1 start + +$dbPrefix = t2dv_db +$tbPrefix = t2dv_tb +$mtPrefix = t2dv_mt +$stPrefix = t2dv_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db replica 2 +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c1 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb interval(1d) +print select count(*) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c1 +sql create table $st as select count(*) from $tb interval(1d) + +print =============== step3 c2 +sql select count(tbcol) from $tb interval(1d) +print select count(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c2 +sql create table $st as select count(tbcol) from $tb interval(1d) + +print =============== step4 c3 +sql select count(tbcol2) from $tb interval(1d) +print select count(tbcol2) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c3 +sql create table $st as select count(tbcol2) from $tb interval(1d) + +print =============== step5 avg +sql select avg(tbcol) from $tb interval(1d) +print select avg(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . av +sql create table $st as select avg(tbcol) from $tb interval(1d) + +print =============== step6 su +sql select sum(tbcol) from $tb interval(1d) +print select sum(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 190 then + return -1 +endi + +$st = $stPrefix . su +sql create table $st as select sum(tbcol) from $tb interval(1d) + +print =============== step7 mi +sql select min(tbcol) from $tb interval(1d) +print select min(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . mi +sql create table $st as select min(tbcol) from $tb interval(1d) + +print =============== step8 ma +sql select max(tbcol) from $tb interval(1d) +print select max(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . ma +sql create table $st as select max(tbcol) from $tb interval(1d) + +print =============== step9 fi +sql select first(tbcol) from $tb interval(1d) +print select first(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . fi +sql create table $st as select first(tbcol) from $tb interval(1d) + +print =============== step10 la +sql select last(tbcol) from $tb interval(1d) +print select last(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . la +sql create table $st as select last(tbcol) from $tb interval(1d) + +print =============== step11 st +sql select stddev(tbcol) from $tb interval(1d) +print select stddev(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 5.766281297 then + return -1 +endi + +$st = $stPrefix . std +sql create table $st as select stddev(tbcol) from $tb interval(1d) + +print =============== step12 le +sql select leastsquares(tbcol, 1, 1) from $tb interval(1d) +print select leastsquares(tbcol, 1, 1) from $tb interval(1d) ===> $data00 $data01 +#if $data01 != @(0.000017, -25362055.126740)@ then +# return -1 +#endi + +$st = $stPrefix . le +sql create table $st as select leastsquares(tbcol, 1, 1) from $tb interval(1d) + +print =============== step13 pe + +sql select percentile(tbcol, 1) from $tb interval(1d) +print select percentile(tbcol, 1) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 0.190000000 then + return -1 +endi + +$st = $stPrefix . pe +sql create table $st as select percentile(tbcol, 1) from $tb interval(1d) + +print =============== step14 wh +sql select count(tbcol) from $tb where ts < now + 4m interval(1d) +print select count(tbcol) from $tb where ts < now + 4m interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . wh +#sql create table $st as select count(tbcol) from $tb where ts < now + 4m interval(1d) + +print =============== step15 as +sql select count(tbcol) from $tb interval(1d) +print select count(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . as +sql create table $st as select count(tbcol) as c from $tb interval(1d) + +print =============== step16 +print sleep 22 seconds +sleep 22000 + +print =============== step17 +$st = $stPrefix . c1 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c2 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c3 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . av +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . su +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 190 then + return -1 +endi + +$st = $stPrefix . mi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . ma +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . fi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . la +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . std +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 5.766281297 then + return -1 +endi + +$st = $stPrefix . le +sql select * from $st +#print ===> select * from $st ===> $data00 $data01 +#if $data01 != @(0.000017, -25270086.331047)@ then +# return -1 +#endi + +$st = $stPrefix . pe +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0.190000000 then + return -1 +endi + +$st = $stPrefix . wh +#sql select * from $st +#print ===> select * from $st ===> $data00 $data01 +#if $data01 != $rowNum then +# return -1 +#endi + +$st = $stPrefix . as +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi diff --git a/tests/script/unique/stream/table_replica2_dnode3.sim b/tests/script/unique/stream/table_replica2_dnode3.sim new file mode 100644 index 0000000000000000000000000000000000000000..49eb3563b3964f05f31d72a8fd1ff12f2b5b3a03 --- /dev/null +++ b/tests/script/unique/stream/table_replica2_dnode3.sim @@ -0,0 +1,325 @@ +system sh/stop_dnodes.sh + + + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode3 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + + +sql connect + +sql create dnode $hostname2 +sql create dnode $hostname3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_192.168.0.2 == offline then + goto createDnode +endi +if $data4_192.168.0.3 == offline then + goto createDnode +endi + +print ======================== dnode1 start + +$dbPrefix = t2d3_db +$tbPrefix = t2d3_tb +$mtPrefix = t2d3_mt +$stPrefix = t2d3_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db replica 2 +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c1 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb interval(1d) +print select count(*) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c1 +sql create table $st as select count(*) from $tb interval(1d) + +print =============== step3 c2 +sql select count(tbcol) from $tb interval(1d) +print select count(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c2 +sql create table $st as select count(tbcol) from $tb interval(1d) + +print =============== step4 c3 +sql select count(tbcol2) from $tb interval(1d) +print select count(tbcol2) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c3 +sql create table $st as select count(tbcol2) from $tb interval(1d) + +print =============== step5 avg +sql select avg(tbcol) from $tb interval(1d) +print select avg(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . av +sql create table $st as select avg(tbcol) from $tb interval(1d) + +print =============== step6 su +sql select sum(tbcol) from $tb interval(1d) +print select sum(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 190 then + return -1 +endi + +$st = $stPrefix . su +sql create table $st as select sum(tbcol) from $tb interval(1d) + +print =============== step7 mi +sql select min(tbcol) from $tb interval(1d) +print select min(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . mi +sql create table $st as select min(tbcol) from $tb interval(1d) + +print =============== step8 ma +sql select max(tbcol) from $tb interval(1d) +print select max(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . ma +sql create table $st as select max(tbcol) from $tb interval(1d) + +print =============== step9 fi +sql select first(tbcol) from $tb interval(1d) +print select first(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . fi +sql create table $st as select first(tbcol) from $tb interval(1d) + +print =============== step10 la +sql select last(tbcol) from $tb interval(1d) +print select last(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . la +sql create table $st as select last(tbcol) from $tb interval(1d) + +print =============== step11 st +sql select stddev(tbcol) from $tb interval(1d) +print select stddev(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 5.766281297 then + return -1 +endi + +$st = $stPrefix . std +sql create table $st as select stddev(tbcol) from $tb interval(1d) + +print =============== step12 le +sql select leastsquares(tbcol, 1, 1) from $tb interval(1d) +print select leastsquares(tbcol, 1, 1) from $tb interval(1d) ===> $data00 $data01 +#if $data01 != @(0.000017, -25362055.126740)@ then +# return -1 +#endi + +$st = $stPrefix . le +sql create table $st as select leastsquares(tbcol, 1, 1) from $tb interval(1d) + +print =============== step13 pe + +sql select percentile(tbcol, 1) from $tb interval(1d) +print select percentile(tbcol, 1) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 0.190000000 then + return -1 +endi + +$st = $stPrefix . pe +sql create table $st as select percentile(tbcol, 1) from $tb interval(1d) + +print =============== step14 wh +sql select count(tbcol) from $tb where ts < now + 4m interval(1d) +print select count(tbcol) from $tb where ts < now + 4m interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . wh +#sql create table $st as select count(tbcol) from $tb where ts < now + 4m interval(1d) + +print =============== step15 as +sql select count(tbcol) from $tb interval(1d) +print select count(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . as +sql create table $st as select count(tbcol) as c from $tb interval(1d) + +print =============== step16 +print sleep 22 seconds +sleep 22000 + +print =============== step17 +$st = $stPrefix . c1 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c2 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c3 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . av +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . su +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 190 then + return -1 +endi + +$st = $stPrefix . mi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . ma +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . fi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . la +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . std +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 5.766281297 then + return -1 +endi + +$st = $stPrefix . le +sql select * from $st +#print ===> select * from $st ===> $data00 $data01 +#if $data01 != @(0.000017, -25270086.331047)@ then +# return -1 +#endi + +$st = $stPrefix . pe +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0.190000000 then + return -1 +endi + +$st = $stPrefix . wh +#sql select * from $st +#print ===> select * from $st ===> $data00 $data01 +#if $data01 != $rowNum then +# return -1 +#endi + +$st = $stPrefix . as +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi diff --git a/tests/script/unique/stream/table_replica3_dnode4.sim b/tests/script/unique/stream/table_replica3_dnode4.sim new file mode 100644 index 0000000000000000000000000000000000000000..2cc443c72fc656b87ca8c1d330381ed5078cd755 --- /dev/null +++ b/tests/script/unique/stream/table_replica3_dnode4.sim @@ -0,0 +1,333 @@ +system sh/stop_dnodes.sh + + + + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode3 -c walLevel -v 1 +system sh/cfg.sh -n dnode4 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sql connect + +sql create dnode $hostname2 +sql create dnode $hostname3 +sql create dnode $hostname4 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_192.168.0.2 == offline then + goto createDnode +endi +if $data4_192.168.0.3 == offline then + goto createDnode +endi +if $data4_192.168.0.4 == offline then + goto createDnode +endi + +print ======================== dnode1 start + +$dbPrefix = t3d_db +$tbPrefix = t3d_tb +$mtPrefix = t3d_mt +$stPrefix = t3d_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db replica 3 +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c1 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb interval(1d) +print select count(*) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c1 +sql create table $st as select count(*) from $tb interval(1d) + +print =============== step3 c2 +sql select count(tbcol) from $tb interval(1d) +print select count(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c2 +sql create table $st as select count(tbcol) from $tb interval(1d) + +print =============== step4 c3 +sql select count(tbcol2) from $tb interval(1d) +print select count(tbcol2) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c3 +sql create table $st as select count(tbcol2) from $tb interval(1d) + +print =============== step5 avg +sql select avg(tbcol) from $tb interval(1d) +print select avg(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . av +sql create table $st as select avg(tbcol) from $tb interval(1d) + +print =============== step6 su +sql select sum(tbcol) from $tb interval(1d) +print select sum(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 190 then + return -1 +endi + +$st = $stPrefix . su +sql create table $st as select sum(tbcol) from $tb interval(1d) + +print =============== step7 mi +sql select min(tbcol) from $tb interval(1d) +print select min(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . mi +sql create table $st as select min(tbcol) from $tb interval(1d) + +print =============== step8 ma +sql select max(tbcol) from $tb interval(1d) +print select max(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . ma +sql create table $st as select max(tbcol) from $tb interval(1d) + +print =============== step9 fi +sql select first(tbcol) from $tb interval(1d) +print select first(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . fi +sql create table $st as select first(tbcol) from $tb interval(1d) + +print =============== step10 la +sql select last(tbcol) from $tb interval(1d) +print select last(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . la +sql create table $st as select last(tbcol) from $tb interval(1d) + +print =============== step11 st +sql select stddev(tbcol) from $tb interval(1d) +print select stddev(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 5.766281297 then + return -1 +endi + +$st = $stPrefix . std +sql create table $st as select stddev(tbcol) from $tb interval(1d) + +print =============== step12 le +sql select leastsquares(tbcol, 1, 1) from $tb interval(1d) +print select leastsquares(tbcol, 1, 1) from $tb interval(1d) ===> $data00 $data01 +#if $data01 != @(0.000017, -25362055.126740)@ then +# return -1 +#endi + +$st = $stPrefix . le +sql create table $st as select leastsquares(tbcol, 1, 1) from $tb interval(1d) + +print =============== step13 pe + +sql select percentile(tbcol, 1) from $tb interval(1d) +print select percentile(tbcol, 1) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 0.190000000 then + return -1 +endi + +$st = $stPrefix . pe +sql create table $st as select percentile(tbcol, 1) from $tb interval(1d) + +print =============== step14 wh +sql select count(tbcol) from $tb where ts < now + 4m interval(1d) +print select count(tbcol) from $tb where ts < now + 4m interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . wh +#sql create table $st as select count(tbcol) from $tb where ts < now + 4m interval(1d) + +print =============== step15 as +sql select count(tbcol) from $tb interval(1d) +print select count(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . as +sql create table $st as select count(tbcol) as c from $tb interval(1d) + +print =============== step16 +print sleep 22 seconds +sleep 22000 + +print =============== step17 +$st = $stPrefix . c1 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c2 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c3 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . av +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . su +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 190 then + return -1 +endi + +$st = $stPrefix . mi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . ma +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . fi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . la +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . std +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 5.766281297 then + return -1 +endi + +$st = $stPrefix . le +sql select * from $st +#print ===> select * from $st ===> $data00 $data01 +#if $data01 != @(0.000017, -25270086.331047)@ then +# return -1 +#endi + +$st = $stPrefix . pe +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0.190000000 then + return -1 +endi + +$st = $stPrefix . wh +#sql select * from $st +#print ===> select * from $st ===> $data00 $data01 +#if $data01 != $rowNum then +# return -1 +#endi + +$st = $stPrefix . as +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi diff --git a/tests/script/unique/stream/table_vnode_stop.sim b/tests/script/unique/stream/table_vnode_stop.sim new file mode 100644 index 0000000000000000000000000000000000000000..625de32a8d7a1e5336dd10f313565bdbc0daf0fc --- /dev/null +++ b/tests/script/unique/stream/table_vnode_stop.sim @@ -0,0 +1,189 @@ +system sh/stop_dnodes.sh + + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 +system sh/exec.sh -n dnode1 -s start + +sql connect + +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_192.168.0.2 == offline then + goto createDnode +endi + +print ======================== dnode start + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = mt +$stPrefix = st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql create database $db replica 2 +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c1 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb interval(1d) +print select count(*) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c1 +sql create table $st as select count(*) from $tb interval(1d) + +print =============== step3 +system sh/exec.sh -n dnode2 -s stop + +print =============== step4 +print sleep 22 seconds +sleep 22000 + +print =============== step5 +$st = $stPrefix . c1 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +print ============= step6 + +sql close +system sh/exec.sh -n dnode1 -s stop +system sh/exec.sh -n dnode2 -s stop +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +sleep 2000 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +connectTbase2: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql connect -x connectTbase2 +sleep 2000 + +sql create dnode $hostname1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +print ======================== dnode start + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = mt +$stPrefix = st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step7 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql create database $db replica 2 +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step8 c1 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb interval(1d) +print select count(*) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c1 +sql create table $st as select count(*) from $tb interval(1d) + +print =============== step9 +system sh/exec.sh -n dnode1 -s stop + +print =============== step10 +print sleep 22 seconds +sleep 22000 + +print =============== step11 +$st = $stPrefix . c1 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + + + diff --git a/tests/script/unique/stream/testSuite.sim b/tests/script/unique/stream/testSuite.sim new file mode 100644 index 0000000000000000000000000000000000000000..bbf5da3d376d9eccc02aa61b1122cadb5fc04813 --- /dev/null +++ b/tests/script/unique/stream/testSuite.sim @@ -0,0 +1,15 @@ +#run unique/stream/table_replica1_dnode2.sim +#run unique/stream/metrics_replica1_dnode2.sim +#run unique/stream/table_replica2_dnode2.sim +#run unique/stream/metrics_replica2_dnode2.sim +#run unique/stream/table_replica2_dnode2_vnoden.sim +#run unique/stream/metrics_replica2_dnode2_vnoden.sim +#run unique/stream/table_replica2_dnode3.sim +#run unique/stream/metrics_replica2_dnode3.sim +#run unique/stream/table_replica3_dnode4.sim +#run unique/stream/metrics_replica3_dnode4.sim +#run unique/stream/table_vnode_stop.sim +#run unique/stream/metrics_vnode_stop.sim +##run unique/stream/table_balance.sim +##run unique/stream/metrics_balance.sim +##run unique/stream/table_move.sim \ No newline at end of file diff --git a/tests/script/unique/vnode/back_insert.sim b/tests/script/unique/vnode/back_insert.sim new file mode 100644 index 0000000000000000000000000000000000000000..43831cca95b49218719c5172c3d2d96ad3500896 --- /dev/null +++ b/tests/script/unique/vnode/back_insert.sim @@ -0,0 +1,7 @@ +sql connect +$x = 1 +begin: + sql insert into db.tb values(now, $x ) -x begin + #print ===> insert successed $x + $x = $x + 1 +goto begin \ No newline at end of file diff --git a/tests/script/unique/vnode/back_insert_many.sim b/tests/script/unique/vnode/back_insert_many.sim new file mode 100644 index 0000000000000000000000000000000000000000..6181a835ed8dfd344a96029d9965f2b87c8b1b3e --- /dev/null +++ b/tests/script/unique/vnode/back_insert_many.sim @@ -0,0 +1,10 @@ +sql connect +$x = 1 +begin: + sql insert into db1.tb1 values(now, $x ) -x begin + sql insert into db2.tb2 values(now, $x ) -x begin + sql insert into db3.tb3 values(now, $x ) -x begin + sql insert into db4.tb4 values(now, $x ) -x begin + #print ===> insert successed $x + $x = $x + 1 +goto begin \ No newline at end of file diff --git a/tests/script/unique/vnode/backup/replica4.sim b/tests/script/unique/vnode/backup/replica4.sim new file mode 100644 index 0000000000000000000000000000000000000000..c0ff267c734b58e1f198932c86e78c817625981e --- /dev/null +++ b/tests/script/unique/vnode/backup/replica4.sim @@ -0,0 +1,220 @@ +system sh/stop_dnodes.sh + + + + + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode3 -c walLevel -v 1 +system sh/cfg.sh -n dnode4 -c walLevel -v 1 + +system sh/exec.sh -n dnode1 -s start +$x = 0 +connectTbase: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql connect -x connectTbase + +sql create dnode $hostname2 +sql create dnode $hostname3 +sql create dnode $hostname4 + +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sleep 3001 + +$N = 10 +$table = table_r4 +$db = db1 + +print =================== step 1 + +$x = 0 +created: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create database $db replica 4 -x created +sql use $db + +$x = 0 +create1: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create table $table (ts timestamp, speed int) -x create1 +sleep 3001 + +print =================== step 2 +$x = 1 +$y = $x + $N +$expect = $N +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 3 +system sh/exec.sh -n dnode2 -s stop +sleep 2000 +$y = $x + $N +$expect = $N * 2 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 4 +system sh/exec.sh -n dnode2 -s start +sleep 2000 +$y = $x + $N +$expect = $N * 3 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 5 +system sh/exec.sh -n dnode3 -s stop +sleep 2000 +$y = $x + $N +$expect = $N * 4 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , 10) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 6 +system sh/exec.sh -n dnode3 -s start +sleep 2000 +$y = $x + $N +$expect = $N * 5 +while $x < $y +$ms = $x . m +sql insert into $table values (now + $ms , $x ) +$x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then +return -1 +endi + + +print =================== step 7 +system sh/exec.sh -n dnode4 -s stop +sleep 2000 +$y = $x + $N +$expect = $N * 6 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , 10) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 8 +system sh/exec.sh -n dnode4 -s start +sleep 2000 +$y = $x + $N +$expect = $N * 7 +while $x < $y +$ms = $x . m +sql insert into $table values (now + $ms , $x ) +$x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then +return -1 +endi + +print =================== step 9 +system sh/exec.sh -n dnode1 -s stop +sleep 2000 +$y = $x + $N +$expect = $N * 8 +while $x < $y +$ms = $x . m +sql insert into $table values (now + $ms , 10) +$x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then +return -1 +endi + +print =================== step 10 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +$y = $x + $N +$expect = $N * 9 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , 10) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop +system sh/exec.sh -n dnode2 -s stop +system sh/exec.sh -n dnode3 -s stop +system sh/exec.sh -n dnode4 -s stop + diff --git a/tests/script/unique/vnode/backup/replica5.sim b/tests/script/unique/vnode/backup/replica5.sim new file mode 100644 index 0000000000000000000000000000000000000000..1223cf6b585f7affeb40e2f625a3f6cbd79dae80 --- /dev/null +++ b/tests/script/unique/vnode/backup/replica5.sim @@ -0,0 +1,263 @@ +system sh/stop_dnodes.sh + + + + + + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/deploy.sh -n dnode5 -i 5 + +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode3 -c walLevel -v 1 +system sh/cfg.sh -n dnode4 -c walLevel -v 1 +system sh/cfg.sh -n dnode5 -c walLevel -v 1 + +system sh/exec.sh -n dnode1 -s start + +$x = 0 +connectTbase: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql connect -x connectTbase + +sql create dnode $hostname2 +sql create dnode $hostname3 +sql create dnode $hostname4 +sql create dnode $hostname5 + +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +system sh/exec.sh -n dnode5 -s start +sleep 3001 + +$N = 10 +$table = table_r5 +$db = db1 + +print =================== step 1 + +$x = 0 +created: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create database $db replica 5 -x created +sql use $db + +$x = 0 +create1: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create table $table (ts timestamp, speed int) -x create1 + +sleep 3001 + +print =================== step 2 +$x = 1 +$y = $x + $N +$expect = $N +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 3 +system sh/exec.sh -n dnode2 -s stop +sleep 2000 +$y = $x + $N +$expect = $N * 2 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 4 +system sh/exec.sh -n dnode2 -s start +sleep 2000 +$y = $x + $N +$expect = $N * 3 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 5 +system sh/exec.sh -n dnode3 -s stop +sleep 2000 +$y = $x + $N +$expect = $N * 4 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , 10) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 6 +system sh/exec.sh -n dnode3 -s start +sleep 2000 +$y = $x + $N +$expect = $N * 5 +while $x < $y +$ms = $x . m +sql insert into $table values (now + $ms , $x ) +$x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then +return -1 +endi + + +print =================== step 7 +system sh/exec.sh -n dnode4 -s stop +sleep 2000 +$y = $x + $N +$expect = $N * 6 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , 10) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 8 +system sh/exec.sh -n dnode4 -s start +sleep 2000 +$y = $x + $N +$expect = $N * 7 +while $x < $y +$ms = $x . m +sql insert into $table values (now + $ms , $x ) +$x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then +return -1 +endi + + +print =================== step 9 +system sh/exec.sh -n dnode5 -s stop +sleep 2000 +$y = $x + $N +$expect = $N * 8 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , 10) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 10 +system sh/exec.sh -n dnode5 -s start +sleep 2000 +$y = $x + $N +$expect = $N * 9 +while $x < $y +$ms = $x . m +sql insert into $table values (now + $ms , $x ) +$x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then +return -1 +endi + +print =================== step 11 +system sh/exec.sh -n dnode1 -s stop +sleep 2000 +$y = $x + $N +$expect = $N * 10 +while $x < $y +$ms = $x . m +sql insert into $table values (now + $ms , 10) +$x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then +return -1 +endi + +print =================== step 12 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +$y = $x + $N +$expect = $N * 11 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , 10) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop +system sh/exec.sh -n dnode2 -s stop +system sh/exec.sh -n dnode3 -s stop +system sh/exec.sh -n dnode4 -s stop +system sh/exec.sh -n dnode5 -s stop + diff --git a/tests/script/unique/vnode/many.sim b/tests/script/unique/vnode/many.sim new file mode 100644 index 0000000000000000000000000000000000000000..a9298b1cf275c24ab6ebe7fea9387a51d6d044ba --- /dev/null +++ b/tests/script/unique/vnode/many.sim @@ -0,0 +1,147 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/cfg.sh -n dnode2 -c wallevel -v 2 +system sh/cfg.sh -n dnode3 -c wallevel -v 2 +system sh/cfg.sh -n dnode4 -c wallevel -v 2 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 +system sh/exec.sh -n dnode1 -s start + +sql connect +sql create dnode $hostname2 +sql create dnode $hostname3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 +print dnode4 $data4_4 + +if $data4_1 != ready then + goto step1 +endi +if $data4_2 != ready then + goto step1 +endi +if $data4_3 != ready then + goto step1 +endi + +sql show mnodes +print mnode1 $data2_1 +print mnode1 $data2_2 +print mnode1 $data2_3 +if $data2_1 != master then + goto step1 +endi + +print ========= step1 +sql create database db1 replica 2 +sql create database db2 replica 2 +sql create database db3 replica 2 +sql create database db4 replica 2 +sql create table db1.tb1 (ts timestamp, i int) +sql create table db2.tb2 (ts timestamp, i int) +sql create table db3.tb3 (ts timestamp, i int) +sql create table db4.tb4 (ts timestamp, i int) +sql insert into db1.tb1 values(now, 1) +sql insert into db2.tb2 values(now, 1) +sql insert into db3.tb3 values(now, 1) +sql insert into db4.tb4 values(now, 1) + +sql select count(*) from db1.tb1 +$lastRows1 = $rows +sql select count(*) from db2.tb2 +$lastRows2 = $rows +sql select count(*) from db3.tb3 +$lastRows3 = $rows +sql select count(*) from db4.tb4 +$lastRows4 = $rows + +print ======== step2 +run_back unique/vnode/back_insert_many.sim +sleep 3000 + +print ======== step3 + +$x = 0 +loop: + +print ======== step4 +system sh/exec.sh -n dnode3 -s stop +sleep 3000 +system sh/exec.sh -n dnode3 -s start +sleep 3000 + +print ======== step5 +system sh/exec.sh -n dnode2 -s stop +sleep 3000 +system sh/exec.sh -n dnode2 -s start +sleep 3000 + +print ======== step6 +sql select count(*) from db1.tb1 +print select count(*) from db1.tb1 ==> $data00 $lastRows1 +if $data00 <= $lastRows1 then + return -1 +endi +$lastRows1 = $data00 + +sql select count(*) from db2.tb2 +print select count(*) from db2.tb2 ==> $data00 $lastRows2 +if $data00 <= $lastRows2 then + return -1 +endi +$lastRows2 = $data00 + +sql select count(*) from db3.tb3 +print select count(*) from db3.tb3 ==> $data00 $lastRows3 +if $data00 <= $lastRows3 then + return -1 +endi +$lastRows3 = $data00 + +sql select count(*) from db4.tb4 +print select count(*) from db4.tb4 ==> $data00 $lastRows4 +if $data00 <= $lastRows4 then + return -1 +endi +$lastRows4 = $data00 + +print ======== step7 + +print ======== loop Times $x + +if $x < 2 then + $x = $x + 1 + goto loop +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/vnode/replica2_a_large.sim b/tests/script/unique/vnode/replica2_a_large.sim new file mode 100644 index 0000000000000000000000000000000000000000..6f318038454a171445600e37d17852b2c2de835e --- /dev/null +++ b/tests/script/unique/vnode/replica2_a_large.sim @@ -0,0 +1,103 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/cfg.sh -n dnode2 -c wallevel -v 2 +system sh/cfg.sh -n dnode3 -c wallevel -v 2 +system sh/cfg.sh -n dnode4 -c wallevel -v 2 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode1 -c debugFlag -v 131 +system sh/cfg.sh -n dnode2 -c debugFlag -v 131 +system sh/cfg.sh -n dnode3 -c debugFlag -v 131 +system sh/cfg.sh -n dnode4 -c debugFlag -v 131 +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +sql create dnode $hostname2 +sql create dnode $hostname3 +system sh/exec.sh -n dnode2 -s start -t +system sh/exec.sh -n dnode3 -s start -t +sleep 2000 + +print ========= step1 +sql create database db replica 2 +#sql create table db.tb1 (ts timestamp, i int) +#sql create table db.tb2 (ts timestamp, i int) +#sql create table db.tb3 (ts timestamp, i int) +#sql create table db.tb4 (ts timestamp, i int) +#sql insert into db.tb1 values(now, 1) +#sql select count(*) from db.tb1 + +sql create database db replica 2 +sql create table db.tb (ts timestamp, i int) +sql insert into db.tb values(now, 1) +sql select count(*) from db.tb +$lastRows = $rows + +print ======== step2 +#run_back unique/vnode/back_insert_many.sim +run_back unique/vnode/back_insert.sim +sleep 2000 + +print ======== step3 + +$x = 0 +loop: + +print ======== step4 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 10000 +system sh/exec.sh -n dnode2 -s start -t +sleep 10000 + +print ======== step5 +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sleep 10000 +system sh/exec.sh -n dnode3 -s start -t +sleep 10000 + +print ======== step6 +#sql select count(*) from db.tb1 +#print select count(*) from db.tb1 ==> $data00 $lastRows +sql select count(*) from db.tb +print select count(*) from db.tb ==> $data00 $lastRows +if $data00 <= $lastRows then + return -1 +endi + +print ======== step7 +$lastRows = $data00 +print ======== loop Times $x + +if $x < 10 then + $x = $x + 1 + goto loop +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/vnode/replica2_basic2.sim b/tests/script/unique/vnode/replica2_basic2.sim new file mode 100644 index 0000000000000000000000000000000000000000..c081f878dda513a3b11c9546db4dad31c3d2c5ff --- /dev/null +++ b/tests/script/unique/vnode/replica2_basic2.sim @@ -0,0 +1,223 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/cfg.sh -n dnode2 -c wallevel -v 2 +system sh/cfg.sh -n dnode3 -c wallevel -v 2 +system sh/cfg.sh -n dnode4 -c wallevel -v 2 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect +sql create dnode $hostname2 +sql create dnode $hostname3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sleep 2000 + +sql reset query cache + +print ========= step1 +sql create database d1 replica 2 +sql create database d2 replica 2 +sql create database d3 replica 2 +sql create database d4 replica 2 + +sql create table d1.t1 (ts timestamp, i int) +sql create table d2.t2 (ts timestamp, i int) +sql create table d3.t3 (ts timestamp, i int) +sql create table d4.t4 (ts timestamp, i int) + +sql insert into d1.t1 values(now, 1) +sql insert into d2.t2 values(now, 1) +sql insert into d3.t3 values(now, 1) +sql insert into d4.t4 values(now, 1) + +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 1 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 1 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 1 then + return -1 +endi + +sql show dnodes +print dnode1 ==> openVnodes: $data2_1 +print dnode2 ==> openVnodes: $data2_2 +print dnode3 ==> openVnodes: $data2_3 + +if $data2_1 != 0 then + return -1 +endi + +if $data2_2 != 4 then + return -1 +endi + +if $data2_3 != 4 then + return -1 +endi + +if $data4_1 != ready then + print dnode1 status should ready but is $data4_1 + return -1 +endi + +if $data4_2 != ready then + return -1 +endi + +if $data4_3 != ready then + return -1 +endi + +print ========= step2 +sql insert into d1.t1 values(now, 2) +sql insert into d2.t2 values(now, 2) +sql insert into d3.t3 values(now, 2) +sql insert into d4.t4 values(now, 2) + +sql select * from d1.t1 +if $rows != 2 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 2 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 2 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 2 then + return -1 +endi + +print ========= step3 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 3000 + +#sql insert into d1.t1 values(now, 3) +#sql insert into d2.t2 values(now, 3) +#sql insert into d3.t3 values(now, 3) +#sql insert into d4.t4 values(now, 3) + +#sql select * from d1.t1 +#if $rows != 2 then +# return -1 +#endi + +#sql select * from d2.t2 +#if $rows != 2 then +# return -1 +#endi + +#sql select * from d3.t3 +#if $rows != 2 then +# return -1 +#endi + +#sql select * from d4.t4 +#if $rows != 2 then +# return -1 +#endi + +print ========= step4 +system sh/exec.sh -n dnode2 -s start +sleep 3000 +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sleep 3000 + +#sql insert into d1.t1 values(now, 4) +#sql insert into d2.t2 values(now, 4) +#sql insert into d3.t3 values(now, 4) +#sql insert into d4.t4 values(now, 4) + +#sql select * from d1.t1 +#if $rows != 2 then +# return -1 +#endi + +#sql select * from d2.t2 +#if $rows != 2 then +# return -1 +#endi + +#sql select * from d3.t3 +#if $rows != 2 then +# return -1 +#endi + +#sql select * from d4.t4 +#if $rows != 2 then +# return -1 +#endi + +print ========= step5 +system sh/exec.sh -n dnode3 -s start +sleep 3000 + +sql insert into d1.t1 values(now, 5) +sql insert into d2.t2 values(now, 5) +sql insert into d3.t3 values(now, 5) +sql insert into d4.t4 values(now, 5) + +sql select * from d1.t1 +if $rows != 3 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 3 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 3 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 3 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/vnode/replica2_repeat.sim b/tests/script/unique/vnode/replica2_repeat.sim new file mode 100644 index 0000000000000000000000000000000000000000..ac68d591648b2dd66f3fdda8c70b0af40c814459 --- /dev/null +++ b/tests/script/unique/vnode/replica2_repeat.sim @@ -0,0 +1,110 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/cfg.sh -n dnode2 -c wallevel -v 2 +system sh/cfg.sh -n dnode3 -c wallevel -v 2 +system sh/cfg.sh -n dnode4 -c wallevel -v 2 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 +system sh/exec.sh -n dnode1 -s start + +sql connect +sql create dnode $hostname2 +sql create dnode $hostname3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 +print dnode4 $data4_4 + +if $data4_1 != ready then + goto step1 +endi +if $data4_2 != ready then + goto step1 +endi +if $data4_3 != ready then + goto step1 +endi + +sql show mnodes +print mnode1 $data2_1 +print mnode1 $data2_2 +print mnode1 $data2_3 +if $data2_1 != master then + goto step1 +endi + +print ========= step1 +sql create database db replica 2 +sql create table db.tb (ts timestamp, i int) +sql insert into db.tb values(now, 1) +sql select count(*) from db.tb +$lastRows = $rows + +print ======== step2 +run_back unique/vnode/back_insert.sim +sleep 2000 + +print ======== step3 + +$x = 0 +loop: + +print ======== step4 +system sh/exec.sh -n dnode2 -s stop +sleep 3000 +system sh/exec.sh -n dnode2 -s start +sleep 3000 + +print ======== step5 +system sh/exec.sh -n dnode3 -s stop +sleep 3000 +system sh/exec.sh -n dnode3 -s start +sleep 3000 + +print ======== step6 +sql select count(*) from db.tb +print select count(*) from db.tb ==> $data00 $lastRows +if $data00 <= $lastRows then + return -1 +endi + +print ======== step7 +$lastRows = $data00 +print ======== loop Times $x + +if $x < 2 then + $x = $x + 1 + goto loop +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/vnode/replica3_basic.sim b/tests/script/unique/vnode/replica3_basic.sim new file mode 100644 index 0000000000000000000000000000000000000000..0ff42b523b8982c85bd84bb251715585a66137fc --- /dev/null +++ b/tests/script/unique/vnode/replica3_basic.sim @@ -0,0 +1,233 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/cfg.sh -n dnode2 -c wallevel -v 2 +system sh/cfg.sh -n dnode3 -c wallevel -v 2 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 + +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode $hostname2 +sql create dnode $hostname3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 + +if $data4_1 != ready then + goto step1 +endi +if $data4_2 != ready then + goto step1 +endi +if $data4_3 != ready then + goto step1 +endi + +sql show mnodes +print mnode1 $data2_1 +print mnode1 $data2_2 +print mnode1 $data2_3 +if $data2_1 != master then + goto step1 +endi +if $data2_2 != slave then + goto step1 +endi +if $data2_3 != slave then + goto step1 +endi + +$N = 10 +$table = table_r3 +$db = db1 + +print =================== step 1 + +sql create database $db replica 3 +sql use $db +sql create table $table (ts timestamp, speed int) +sleep 3001 + +print =================== step 2 +$x = 1 +$y = $x + $N +$expect = $N +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 3 +system sh/exec.sh -n dnode2 -s stop +sleep 2000 +$y = $x + $N +$expect = $N * 2 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 4 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +step4: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show db1.vgroups +print online vnodes $data03 +if $data03 != 3 then + goto step4 +endi + +$y = $x + $N +$expect = $N * 3 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 5 +system sh/exec.sh -n dnode3 -s stop +$y = $x + $N +$expect = $N * 4 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , 10) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 6 +system sh/exec.sh -n dnode3 -s start + +$x = 0 +step6: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show db1.vgroups +print online vnodes $data03 +if $data03 != 3 then + goto step6 +endi + +$y = $x + $N +$expect = $N * 5 +while $x < $y +$ms = $x . m +sql insert into $table values (now + $ms , $x ) +$x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then +return -1 +endi + +print =================== step 7 +system sh/exec.sh -n dnode1 -s stop +$y = $x + $N +$expect = $N * 6 +while $x < $y +$ms = $x . m +sql insert into $table values (now + $ms , 10) +$x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then +return -1 +endi + +print =================== step 8 +system sh/exec.sh -n dnode1 -s start + +$x = 0 +step8: + $x = $x + 1 + sleep 1000 + if $x == 40 then + return -1 + endi + +sql show db1.vgroups +print online vnodes $data03 +if $data03 != 3 then + goto step8 +endi + +$y = $x + $N +$expect = $N * 7 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , 10) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/vnode/replica3_repeat.sim b/tests/script/unique/vnode/replica3_repeat.sim new file mode 100644 index 0000000000000000000000000000000000000000..636bc64f89948a8bd4ec0d3dc9dc2a1b10f50e00 --- /dev/null +++ b/tests/script/unique/vnode/replica3_repeat.sim @@ -0,0 +1,125 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/cfg.sh -n dnode2 -c wallevel -v 2 +system sh/cfg.sh -n dnode3 -c wallevel -v 2 +system sh/cfg.sh -n dnode4 -c wallevel -v 2 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 + +system sh/exec.sh -n dnode1 -s start + +sql connect +sql create dnode $hostname2 +sql create dnode $hostname3 +sql create dnode $hostname4 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start + + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 +print dnode4 $data4_4 + +if $data4_1 != ready then + goto step1 +endi +if $data4_2 != ready then + goto step1 +endi +if $data4_3 != ready then + goto step1 +endi +if $data4_4 != ready then + goto step1 +endi + +sql show mnodes +print mnode1 $data2_1 +print mnode1 $data2_2 +print mnode1 $data2_3 +if $data2_1 != master then + goto step1 +endi + +print ========= step1 +sql create database db replica 3 +sql create table db.tb (ts timestamp, i int) +sql insert into db.tb values(now, 1) +sql select count(*) from db.tb +$lastRows = $rows + +print ======== step2 +run_back unique/vnode/back_insert.sim +sleep 2000 + +print ======== step3 +system sh/exec.sh -n dnode2 -s stop +sleep 3000 + +$x = 0 +loop: + +print ======== step4 +system sh/exec.sh -n dnode2 -s start +sleep 3000 +system sh/exec.sh -n dnode3 -s stop +sleep 3000 + +print ======== step5 +system sh/exec.sh -n dnode3 -s start +sleep 3000 +system sh/exec.sh -n dnode4 -s stop +sleep 3000 + +print ======== step6 +system sh/exec.sh -n dnode4 -s start +sleep 3000 +system sh/exec.sh -n dnode2 -s stop +sleep 3000 + +print ======== step7 +sql select count(*) from db.tb +print select count(*) from db.tb ==> $data00 $lastRows +if $data00 <= $lastRows then + return -1 +endi + +print ======== step8 +$lastRows = $data00 +print ======== loop Times $x + +if $x < 2 then + $x = $x + 1 + goto loop +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/vnode/replica3_vgroup.sim b/tests/script/unique/vnode/replica3_vgroup.sim new file mode 100644 index 0000000000000000000000000000000000000000..de4c48eca5683fc7599d545e2887ae8d2c073b82 --- /dev/null +++ b/tests/script/unique/vnode/replica3_vgroup.sim @@ -0,0 +1,71 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/cfg.sh -n dnode2 -c wallevel -v 2 +system sh/cfg.sh -n dnode3 -c wallevel -v 2 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 + +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode $hostname2 +sql create dnode $hostname3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sleep 2000 + +$N = 10 +$table = table_r3 +$db = db1 + +sleep 2000 + +print =================== step 1 + +sql create database $db replica 3 +sql use $db +sql create table st (ts timestamp, speed int) tags (t1 int) +sleep 3001 + + +$tbPre = m +$N = 300 +$x = 0 +$y = $x + $N +while $x < $y + $table = $tbPre . $x + sql create table $table using st tags ( $x ) + $ms = $x . m + sql insert into $table values (now + $ms , $x ) + $x = $x + 1 +endw + + +#print =================== step 2 +$x = -500 +$y = $x + $N +while $x < $y + $ms = $x . m + sql insert into $table values (now $ms , $x ) + $x = $x + 1 +endw + +$expect = $N + 1 +sql select * from $table +print sql select * from $table -> $rows points expect $expect +if $rows != $expect then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/vnode/testSuite.sim b/tests/script/unique/vnode/testSuite.sim new file mode 100644 index 0000000000000000000000000000000000000000..3a9db66beb77d29b7d6bcb68d070edd91c97e199 --- /dev/null +++ b/tests/script/unique/vnode/testSuite.sim @@ -0,0 +1,6 @@ +run unique/vnode/many.sim +run unique/vnode/replica2_basic2.sim +run unique/vnode/replica2_repeat.sim +run unique/vnode/replica3_basic.sim +run unique/vnode/replica3_repeat.sim +run unique/vnode/replica3_vgroup.sim diff --git a/tests/script/windows/alter/metrics.sim b/tests/script/windows/alter/metrics.sim new file mode 100644 index 0000000000000000000000000000000000000000..7dfda05bd0b0849fa6cbdb27e064113ad2fec595 --- /dev/null +++ b/tests/script/windows/alter/metrics.sim @@ -0,0 +1,769 @@ +sleep 2000 +sql connect + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +print ======== step1 +sql create database d2 +sql use d2 +sql create table mt (ts timestamp, a int) TAGS (t int) +sql create table tb using mt tags (1) +sql insert into tb values(now-28d, -28) +sql insert into tb values(now-27d, -27) +sql insert into tb values(now-26d, -26) +sql select * from tb +if $rows != 3 then + return -1 +endi +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != t then + return -1 +endi +if $data21 != INT then + return -1 +endi + +print ======== step2 +sql alter table mt add column b smallint +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != t then + return -1 +endi +if $data31 != INT then + return -1 +endi + +print ======== step3 +sql alter table mt add column c tinyint +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != t then + return -1 +endi +if $data41 != INT then + return -1 +endi + +print ======== step4 +sql alter table mt add column d int +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != t then + return -1 +endi +if $data51 != INT then + return -1 +endi + +print ======== step5 +sql alter table mt add column e bigint +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != t then + return -1 +endi +if $data61 != INT then + return -1 +endi + +print ======== step6 +sql alter table mt add column f float +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != f then + return -1 +endi +if $data61 != FLOAT then + return -1 +endi +if $data70 != t then + return -1 +endi +if $data71 != INT then + return -1 +endi + +print ======== step7 +sql alter table mt add column g double +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != f then + return -1 +endi +if $data61 != FLOAT then + return -1 +endi +if $data70 != g then + return -1 +endi +if $data71 != DOUBLE then + return -1 +endi +if $data80 != t then + return -1 +endi +if $data81 != INT then + return -1 +endi + +print ======== step8 +sql alter table mt add column h binary(10) +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != f then + return -1 +endi +if $data61 != FLOAT then + return -1 +endi +if $data70 != g then + return -1 +endi +if $data71 != DOUBLE then + return -1 +endi +if $data80 != h then + return -1 +endi +if $data81 != BINARY then + return -1 +endi +if $data82 != 10 then + return -1 +endi +if $data90 != t then + return -1 +endi +if $data91 != INT then + return -1 +endi + +print ======== step9 +print ======== step10 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +sql use d2 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != f then + return -1 +endi +if $data61 != FLOAT then + return -1 +endi +if $data70 != g then + return -1 +endi +if $data71 != DOUBLE then + return -1 +endi +if $data80 != h then + return -1 +endi +if $data81 != BINARY then + return -1 +endi +if $data82 != 10 then + return -1 +endi +if $data90 != t then + return -1 +endi +if $data91 != INT then + return -1 +endi + +print ======== step11 +#sql alter table mt drop column a -x step111 +# return -1 +#step111: + +#sql alter table mt drop column ts -x step112 +# return -1 +#step112: + +#sql alter table mt drop column cdfg -x step113 +# return -1 +#step113: + +#sql alter table mt add column a -x step114 +# return -1 +#step114: + +#sql alter table mt add column b -x step115 +# return -1 +#step115: + +print ======== step12 +sql alter table mt drop column b +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != c then + return -1 +endi +if $data21 != TINYINT then + return -1 +endi +if $data30 != d then + return -1 +endi +if $data31 != INT then + return -1 +endi +if $data40 != e then + return -1 +endi +if $data41 != BIGINT then + return -1 +endi +if $data50 != f then + return -1 +endi +if $data51 != FLOAT then + return -1 +endi +if $data60 != g then + return -1 +endi +if $data61 != DOUBLE then + return -1 +endi +if $data70 != h then + return -1 +endi +if $data71 != BINARY then + return -1 +endi +if $data72 != 10 then + return -1 +endi +if $data80 != t then + return -1 +endi +if $data81 != INT then + return -1 +endi + +print ======== step13 +sql alter table mt drop column c +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != d then + return -1 +endi +if $data21 != INT then + return -1 +endi +if $data30 != e then + return -1 +endi +if $data31 != BIGINT then + return -1 +endi +if $data40 != f then + return -1 +endi +if $data41 != FLOAT then + return -1 +endi +if $data50 != g then + return -1 +endi +if $data51 != DOUBLE then + return -1 +endi +if $data60 != h then + return -1 +endi +if $data61 != BINARY then + return -1 +endi +if $data62 != 10 then + return -1 +endi +if $data70 != t then + return -1 +endi +if $data71 != INT then + return -1 +endi + +print ======== step14 +sql alter table mt drop column d +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != e then + return -1 +endi +if $data21 != BIGINT then + return -1 +endi +if $data30 != f then + return -1 +endi +if $data31 != FLOAT then + return -1 +endi +if $data40 != g then + return -1 +endi +if $data41 != DOUBLE then + return -1 +endi +if $data50 != h then + return -1 +endi +if $data51 != BINARY then + return -1 +endi +if $data52 != 10 then + return -1 +endi +if $data60 != t then + return -1 +endi +if $data61 != INT then + return -1 +endi + +print ======== step15 +sql alter table mt drop column e +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != f then + return -1 +endi +if $data21 != FLOAT then + return -1 +endi +if $data30 != g then + return -1 +endi +if $data31 != DOUBLE then + return -1 +endi +if $data40 != h then + return -1 +endi +if $data41 != BINARY then + return -1 +endi +if $data42 != 10 then + return -1 +endi +if $data50 != t then + return -1 +endi +if $data51 != INT then + return -1 +endi + +print ======== step16 +sql alter table mt drop column f +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != g then + return -1 +endi +if $data21 != DOUBLE then + return -1 +endi +if $data30 != h then + return -1 +endi +if $data31 != BINARY then + return -1 +endi +if $data32 != 10 then + return -1 +endi +if $data40 != t then + return -1 +endi +if $data41 != INT then + return -1 +endi + +print ======== step17 +sql alter table mt drop column g +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != h then + return -1 +endi +if $data21 != BINARY then + return -1 +endi +if $data22 != 10 then + return -1 +endi +if $data30 != t then + return -1 +endi +if $data31 != INT then + return -1 +endi + +print ============= step18 +sql alter table mt drop column h +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != t then + return -1 +endi +if $data21 != INT then + return -1 +endi +if $data30 != null then + return -1 +endi + +print ======= over +sql drop database d2 +sql show databases +if $rows != 0 then + return -1 +endi + diff --git a/tests/script/windows/alter/table.sim b/tests/script/windows/alter/table.sim new file mode 100644 index 0000000000000000000000000000000000000000..52757da20ef226ececec64698cea7846584a73bd --- /dev/null +++ b/tests/script/windows/alter/table.sim @@ -0,0 +1,672 @@ +sleep 2000 +sql connect + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +print ======== step1 +sql create database d1 +sql use d1 +sql create table tb (ts timestamp, a int) +sql insert into tb values(now-28d, -28) +sql insert into tb values(now-27d, -27) +sql insert into tb values(now-26d, -26) +sql select * from tb +if $rows != 3 then + return -1 +endi +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi + +print ======== step2 +sql alter table tb add column b smallint +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi + +print ======== step3 +sql alter table tb add column c tinyint +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi + +print ======== step4 +sql alter table tb add column d int +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi + +print ======== step5 +sql alter table tb add column e bigint +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi + +print ======== step6 +sql alter table tb add column f float +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != f then + return -1 +endi +if $data61 != FLOAT then + return -1 +endi + +print ======== step7 +sql alter table tb add column g double +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != f then + return -1 +endi +if $data61 != FLOAT then + return -1 +endi +if $data70 != g then + return -1 +endi +if $data71 != DOUBLE then + return -1 +endi + +print ======== step8 +sql alter table tb add column h binary(10) +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != f then + return -1 +endi +if $data61 != FLOAT then + return -1 +endi +if $data70 != g then + return -1 +endi +if $data71 != DOUBLE then + return -1 +endi +if $data80 != h then + return -1 +endi +if $data81 != BINARY then + return -1 +endi +if $data82 != 10 then + return -1 +endi + +print ======== step9 +print ======== step10 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +sql use d1 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != f then + return -1 +endi +if $data61 != FLOAT then + return -1 +endi +if $data70 != g then + return -1 +endi +if $data71 != DOUBLE then + return -1 +endi +if $data80 != h then + return -1 +endi +if $data81 != BINARY then + return -1 +endi +if $data82 != 10 then + return -1 +endi + +print ======== step11 +sql alter table drop column a -x step111 + return -1 +step111: + +sql alter table drop column ts -x step112 + return -1 +step112: + +sql alter table drop column cdfg -x step113 + return -1 +step113: + +sql alter table add column a -x step114 + return -1 +step114: + +sql alter table add column b -x step115 + return -1 +step115: + +print ======== step12 +sql alter table tb drop column b +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != c then + return -1 +endi +if $data21 != TINYINT then + return -1 +endi +if $data30 != d then + return -1 +endi +if $data31 != INT then + return -1 +endi +if $data40 != e then + return -1 +endi +if $data41 != BIGINT then + return -1 +endi +if $data50 != f then + return -1 +endi +if $data51 != FLOAT then + return -1 +endi +if $data60 != g then + return -1 +endi +if $data61 != DOUBLE then + return -1 +endi +if $data70 != h then + return -1 +endi +if $data71 != BINARY then + return -1 +endi +if $data72 != 10 then + return -1 +endi + +print ======== step13 +sql alter table tb drop column c +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != d then + return -1 +endi +if $data21 != INT then + return -1 +endi +if $data30 != e then + return -1 +endi +if $data31 != BIGINT then + return -1 +endi +if $data40 != f then + return -1 +endi +if $data41 != FLOAT then + return -1 +endi +if $data50 != g then + return -1 +endi +if $data51 != DOUBLE then + return -1 +endi +if $data60 != h then + return -1 +endi +if $data61 != BINARY then + return -1 +endi +if $data62 != 10 then + return -1 +endi + +print ======== step14 +sql alter table tb drop column d +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != e then + return -1 +endi +if $data21 != BIGINT then + return -1 +endi +if $data30 != f then + return -1 +endi +if $data31 != FLOAT then + return -1 +endi +if $data40 != g then + return -1 +endi +if $data41 != DOUBLE then + return -1 +endi +if $data50 != h then + return -1 +endi +if $data51 != BINARY then + return -1 +endi +if $data52 != 10 then + return -1 +endi + +print ======== step15 +sql alter table tb drop column e +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != f then + return -1 +endi +if $data21 != FLOAT then + return -1 +endi +if $data30 != g then + return -1 +endi +if $data31 != DOUBLE then + return -1 +endi +if $data40 != h then + return -1 +endi +if $data41 != BINARY then + return -1 +endi +if $data42 != 10 then + return -1 +endi + +print ======== step16 +sql alter table tb drop column f +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != g then + return -1 +endi +if $data21 != DOUBLE then + return -1 +endi +if $data30 != h then + return -1 +endi +if $data31 != BINARY then + return -1 +endi +if $data32 != 10 then + return -1 +endi + +print ======== step17 +sql alter table tb drop column g +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != h then + return -1 +endi +if $data21 != BINARY then + return -1 +endi +if $data22 != 10 then + return -1 +endi + +print ============= step18 +sql alter table tb drop column h +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != null then + return -1 +endi + +print ======= over +sql drop database d1 +sql show databases +if $rows != 0 then + return -1 +endi + diff --git a/tests/script/windows/compute/avg.sim b/tests/script/windows/compute/avg.sim new file mode 100644 index 0000000000000000000000000000000000000000..7445808db5dbd293e781f66ed7010396413880bc --- /dev/null +++ b/tests/script/windows/compute/avg.sim @@ -0,0 +1,158 @@ +sql connect +sleep 2000 + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = m_av_db +$tbPrefix = m_av_tb +$mtPrefix = m_av_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select avg(tbcol) from $tb +print ===> $data00 +if $data00 != 9.500000000 then + return -1 +endi + +print =============== step3 +sql select avg(tbcol) from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +print =============== step4 +sql select avg(tbcol) as b from $tb +print ===> $data00 +if $data00 != 9.500000000 then + return -1 +endi + +print =============== step5 +sql select avg(tbcol) as b from $tb interval(1m) +print ===> $data01 +if $data11 != 1.000000000 then + return -1 +endi + +sql select avg(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != 9.500000000 then + return -1 +endi + +print =============== step6 +sql select avg(tbcol) as b from $tb where ts < now + 4m interval(1m) +print ===> $data01 +if $data41 != 4.000000000 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select avg(tbcol) from $mt +print ===> $data00 +if $data00 != 9.500000000 then + return -1 +endi + +print =============== step8 +sql select avg(tbcol) as c from $mt where ts < now + 4m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select avg(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 9.500000000 then + return -1 +endi + +sql select avg(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +print =============== step9 +sql select avg(tbcol) as b from $mt interval(1m) +print ===> $data11 +if $data11 != 1.000000000 then + return -1 +endi + +sql select avg(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 9.500000000 then + return -1 +endi + +print =============== step10 +sql select avg(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != 9.500000000 then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select avg(tbcol) as b from $mt where ts < now + 4m interval(1m) group by tgcol +print ===> $data11 +if $data11 != 1.000000000 then + return -1 +endi +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/compute/bottom.sim b/tests/script/windows/compute/bottom.sim new file mode 100644 index 0000000000000000000000000000000000000000..18f6c0bd09d1e6ee4cba734dab20f2634e587d32 --- /dev/null +++ b/tests/script/windows/compute/bottom.sim @@ -0,0 +1,99 @@ +sql connect +sleep 2000 + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = m_bo_db +$tbPrefix = m_bo_tb +$mtPrefix = m_bo_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select bottom(tbcol, 1) from $tb +print ===> $data01 +if $data01 != 0 then + return -1 +endi + +print =============== step3 +sql select bottom(tbcol, 1) from $tb where ts > now + 4m +print ===> $data01 +if $data01 != 5 then + return -1 +endi + +print =============== step4 +sql select bottom(tbcol, 1) as b from $tb +print ===> $data01 +if $data01 != 0 then + return -1 +endi + +print =============== step5 +sql select bottom(tbcol, 2) as b from $tb +print ===> $data01 $data11 +if $data01 != 0 then + return -1 +endi +if $data11 != 1 then + return -1 +endi + +print =============== step6 +sql select bottom(tbcol, 2) as b from $tb where ts > now + 4m +print ===> $data01 $data11 +if $data01 != 5 then + return -1 +endi +if $data11 != 6 then + return -1 +endi + +sql select bottom(tbcol, 122) as b from $tb -x step6 + return -1 +step6: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/compute/count.sim b/tests/script/windows/compute/count.sim new file mode 100644 index 0000000000000000000000000000000000000000..227b49a8bd61d74f242f3f505fddd599a2862cdc --- /dev/null +++ b/tests/script/windows/compute/count.sim @@ -0,0 +1,174 @@ +sql connect +sleep 2000 + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = m_co_db +$tbPrefix = m_co_tb +$mtPrefix = m_co_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + + +sql select count(*) from $tb +print ===> select count(*) from $tb => $data00 +if $data00 != $rowNum then + return -1 +endi + +sql select count(tbcol) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step3 +sql select count(tbcol) from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol) as b from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step5 +sql select count(tbcol) as b from $tb interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi + +sql select count(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != $rowNum then + return -1 +endi + +print =============== step6 +sql select count(tbcol) as b from $tb where ts < now + 4m interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select count(*) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +sql select count(tbcol) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +print =============== step8 +sql select count(tbcol) as c from $mt where ts < now + 4m +print ===> $data00 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m +print ===> $data00 +if $data00 != 25 then + return -1 +endi + +print =============== step9 +sql select count(tbcol) as b from $mt interval(1m) +print ===> $data01 +if $data01 != 10 then + return -1 +endi +if $data11 != 10 then + return -1 +endi + +sql select count(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 200 then + return -1 +endi + +print =============== step10 +sql select count(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select count(tbcol) as b from $mt where ts < now + 4m interval(1m) group by tgcol +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/compute/diff.sim b/tests/script/windows/compute/diff.sim new file mode 100644 index 0000000000000000000000000000000000000000..bdc5a0e3d8a781bdccc500ef667ad6f568ad8e66 --- /dev/null +++ b/tests/script/windows/compute/diff.sim @@ -0,0 +1,91 @@ +sleep 2000 +sql connect + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = m_di_db +$tbPrefix = m_di_tb +$mtPrefix = m_di_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select diff(tbcol) from $tb +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +print =============== step3 +sql select diff(tbcol) from $tb where ts > now + 4m +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select diff(tbcol) from $tb where ts < now + 4m +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +print =============== step4 +sql select diff(tbcol) as b from $tb +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +print =============== step5 +sql select diff(tbcol) as b from $tb interval(1m) -x step5 + return -1 +step5: + +print =============== step6 +sql select diff(tbcol) as b from $tb where ts < now + 4m interval(1m) -x step6 + return -1 +step6: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/compute/first.sim b/tests/script/windows/compute/first.sim new file mode 100644 index 0000000000000000000000000000000000000000..a83939c2a629e13eb474b6b936e7e4b409d7329e --- /dev/null +++ b/tests/script/windows/compute/first.sim @@ -0,0 +1,160 @@ +sleep 2000 +sql connect + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = m_fi_db +$tbPrefix = m_fi_tb +$mtPrefix = m_fi_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select first(tbcol) from $tb +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step3 +sql select first(tbcol) from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step4 +sql select first(tbcol) as b from $tb +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step5 +sql select first(tbcol) as b from $tb interval(1m) +print ===> $data01 +if $data01 != 0 then + return -1 +endi + +sql select first(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != 0 then + return -1 +endi + +print =============== step6 +sql select first(tbcol) as b from $tb where ts < now + 4m interval(1m) +print ===> $data01 +if $data41 != 4 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select first(tbcol) from $mt +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step8 +sql select first(tbcol) as c from $mt where ts < now + 4m +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +sql select first(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +sql select first(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step9 +sql select first(tbcol) as b from $mt interval(1m) +print select first(tbcol) as b from $mt interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select first(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 0 then + return -1 +endi + +print =============== step10 +sql select first(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select first(tbcol) as b from $mt where ts < now + 4m interval(1m) group by tgcol +print ===> $data11 +if $data11 != 1 then + return -1 +endi +print ===> $rows +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/compute/interval.sim b/tests/script/windows/compute/interval.sim new file mode 100644 index 0000000000000000000000000000000000000000..feacce16066a4b5a06268033dedefe327a9f6fa8 --- /dev/null +++ b/tests/script/windows/compute/interval.sim @@ -0,0 +1,176 @@ +sleep 2000 +sql connect + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = m_in_db +$tbPrefix = m_in_tb +$mtPrefix = m_in_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb interval(1m) +print ===> $rows +if $rows < $rowNum then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data05 != 1 then + return -1 +endi + +print =============== step3 +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts < now + 4m interval(1m) +print ===> $rows +if $rows > 10 then + return -1 +endi +if $rows < 3 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data05 != 1 then + return -1 +endi + +print =============== step4 +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts < now+40m and ts > now-1m interval(1m) +print ===> $rows +if $rows < 18 then + return -1 +endi +if $rows > 22 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data05 != 1 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts < now+40m and ts > now+1m interval(1m) fill(value,0) +print ===> $rows +if $rows < 30 then + return -1 +endi +if $rows > 50 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data25 != 1 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt interval(1m) +print ===> $rows +if $rows < 18 then + return -1 +endi +if $rows > 22 then + return -1 +endi +if $data11 > 15 then + return -1 +endi +if $data11 < 5 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts < now + 4m interval(1m) +print ===> $rows +if $rows < 3 then + return -1 +endi +if $rows > 7 then + return -1 +endi +if $data11 > 15 then + return -1 +endi +if $data11 < 5 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts < now+40m and ts > now-1m interval(1m) +print ===> $rows +if $rows < 18 then + return -1 +endi +if $rows > 22 then + return -1 +endi +if $data11 > 15 then + return -1 +endi +if $data11 < 5 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts < now+40m and ts > now+1m interval(1m) fill(value, 0) +if $rows < 30 then + return -1 +endi +if $rows > 50 then + return -1 +endi +if $data11 > 15 then + return -1 +endi +if $data11 < 5 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/compute/last.sim b/tests/script/windows/compute/last.sim new file mode 100644 index 0000000000000000000000000000000000000000..379a5ae64a48b467ffdae816066e8bc3c956d50c --- /dev/null +++ b/tests/script/windows/compute/last.sim @@ -0,0 +1,159 @@ +sleep 2000 +sql connect + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = m_la_db +$tbPrefix = m_la_tb +$mtPrefix = m_la_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select last(tbcol) from $tb +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +print =============== step3 +sql select last(tbcol) from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 4 then + return -1 +endi + +print =============== step4 +sql select last(tbcol) as b from $tb +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +print =============== step5 +sql select last(tbcol) as b from $tb interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select last(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != 19 then + return -1 +endi + +print =============== step6 +sql select last(tbcol) as b from $tb where ts < now + 4m interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select last(tbcol) from $mt +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +print =============== step8 +sql select last(tbcol) as c from $mt where ts < now + 4m +print ===> $data00 +if $data00 != 4 then + return -1 +endi + +sql select last(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +sql select last(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m +print ===> $data00 +if $data00 != 4 then + return -1 +endi + +print =============== step9 +sql select last(tbcol) as b from $mt interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select last(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 19 then + return -1 +endi + +print =============== step10 +sql select last(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select last(tbcol) as b from $mt where ts < now + 4m interval(1m) group by tgcol +print ===> $data11 +if $data11 != 1 then + return -1 +endi +print ===> $rows +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/compute/leastsquare.sim b/tests/script/windows/compute/leastsquare.sim new file mode 100644 index 0000000000000000000000000000000000000000..20353a409e166243212c072d5596492e251e984b --- /dev/null +++ b/tests/script/windows/compute/leastsquare.sim @@ -0,0 +1,102 @@ +sleep 2000 +sql connect + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = m_le_db +$tbPrefix = m_le_tb +$mtPrefix = m_le_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db keep 36500 +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 2 + $ms = 1000 + while $x < $rowNum + $ms = $ms + 1000 + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select leastsquares(tbcol, 1, 1) from $tb +print ===> $data00 +if $data00 != @{slop:1.000000, intercept:1.000000}@ then + return -1 +endi + +print =============== step3 +sql select leastsquares(tbcol, 1, 1) from $tb where ts < now + 4m +print ===> $data00 +if $data00 != @{slop:1.000000, intercept:1.000000}@ then + return -1 +endi + +print =============== step4 +sql select leastsquares(tbcol, 1, 1) as b from $tb +print ===> $data00 +if $data00 != @{slop:1.000000, intercept:1.000000}@ then + return -1 +endi + +print =============== step5 +print select leastsquares(tbcol, 1, 1) as b from $tb interval(1d) +sql select leastsquares(tbcol, 1, 1) as b from $tb interval(1m) +print ===> $data01 +if $data01 != @{slop:1.000000, intercept:1.000000}@ then + return -1 +endi + +print select leastsquares(tbcol, 1, 1) as b from $tb interval(1d) +sql select leastsquares(tbcol, 1, 1) as b from $tb interval(1d) +print ===> $data01 +if $data01 != @{slop:1.000000, intercept:1.000000}@ then + return -1 +endi + +print =============== step6 +sql select leastsquares(tbcol, 1, 1) as b from $tb where ts < now + 4m interval(1m) +print ===> $data01 +if $data01 != @{slop:1.000000, intercept:1.000000}@ then + return -1 +endi +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/windows/compute/max.sim b/tests/script/windows/compute/max.sim new file mode 100644 index 0000000000000000000000000000000000000000..641b31fe362712e09081f105bacdb11f41f2bb99 --- /dev/null +++ b/tests/script/windows/compute/max.sim @@ -0,0 +1,159 @@ +sleep 2000 +sql connect + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = m_ma_db +$tbPrefix = m_ma_tb +$mtPrefix = m_ma_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select max(tbcol) from $tb +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +print =============== step3 +sql select max(tbcol) from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 4 then + return -1 +endi + +print =============== step4 +sql select max(tbcol) as b from $tb +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +print =============== step5 +sql select max(tbcol) as b from $tb interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select max(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != 19 then + return -1 +endi + +print =============== step6 +sql select max(tbcol) as b from $tb where ts < now + 4m interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select max(tbcol) from $mt +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +print =============== step8 +sql select max(tbcol) as c from $mt where ts < now + 4m +print ===> $data00 +if $data00 != 4 then + return -1 +endi + +sql select max(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +sql select max(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m +print ===> $data00 +if $data00 != 4 then + return -1 +endi + +print =============== step9 +sql select max(tbcol) as b from $mt interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select max(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 19 then + return -1 +endi + +print =============== step10 +sql select max(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select max(tbcol) as b from $mt where ts < now + 4m interval(1m) group by tgcol +print ===> $data11 +if $data11 != 1 then + return -1 +endi +print ===> $rows +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/compute/min.sim b/tests/script/windows/compute/min.sim new file mode 100644 index 0000000000000000000000000000000000000000..3528f573ce4c65ac03ac0c0d6c5502b33979cb17 --- /dev/null +++ b/tests/script/windows/compute/min.sim @@ -0,0 +1,159 @@ +sleep 2000 +sql connect + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = m_mi_db +$tbPrefix = m_mi_tb +$mtPrefix = m_mi_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select min(tbcol) from $tb +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step3 +sql select min(tbcol) from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step4 +sql select min(tbcol) as b from $tb +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step5 +sql select min(tbcol) as b from $tb interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select min(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != 0 then + return -1 +endi + +print =============== step6 +sql select min(tbcol) as b from $tb where ts < now + 4m interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select min(tbcol) from $mt +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step8 +sql select min(tbcol) as c from $mt where ts < now + 4m +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +sql select min(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +sql select min(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step9 +sql select min(tbcol) as b from $mt interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select min(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 0 then + return -1 +endi + +print =============== step10 +sql select min(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select min(tbcol) as b from $mt where ts < now + 4m interval(1m) group by tgcol +print ===> $data11 +if $data11 != 1 then + return -1 +endi +print ===> $rows +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/compute/percentile.sim b/tests/script/windows/compute/percentile.sim new file mode 100644 index 0000000000000000000000000000000000000000..fa6212f013b4ec0aa92c06842263fd32be05e1e9 --- /dev/null +++ b/tests/script/windows/compute/percentile.sim @@ -0,0 +1,116 @@ +sleep 2000 +sql connect + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = m_pe_db +$tbPrefix = m_pe_tb +$mtPrefix = m_pe_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select percentile(tbcol, 10) from $tb +print ===> $data00 +if $data00 != 1.900000000 then + return -1 +endi + +sql select percentile(tbcol, 20) from $tb +print ===> $data00 +if $data00 != 3.800000000 then + return -1 +endi + +sql select percentile(tbcol, 100) from $tb +print ===> $data00 +if $data00 != 19.000000000 then + return -1 +endi + +sql select percentile(tbcol, 110) from $tb -x step2 + return -1 +step2: + +print =============== step3 +sql select percentile(tbcol, 1) from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 5.140000000 then + return -1 +endi + +sql select percentile(tbcol, 5) from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 5.700000000 then + return -1 +endi + +sql select percentile(tbcol, 0) from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +print =============== step4 +sql select percentile(tbcol, 1) as c from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 5.140000000 then + return -1 +endi + +sql select percentile(tbcol, 5) as c from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 5.700000000 then + return -1 +endi + +sql select percentile(tbcol, 0) as c from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/compute/stddev.sim b/tests/script/windows/compute/stddev.sim new file mode 100644 index 0000000000000000000000000000000000000000..eea6c8aa0529d0f8dba9907de76017751fbf3d6f --- /dev/null +++ b/tests/script/windows/compute/stddev.sim @@ -0,0 +1,98 @@ +sleep 2000 +sql connect + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = m_st_db +$tbPrefix = m_st_tb +$mtPrefix = m_st_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select stddev(tbcol) from $tb +print ===> $data00 +if $data00 != 5.766281297 then + return -1 +endi + +print =============== step3 +sql select stddev(tbcol) from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 1.414213562 then + return -1 +endi + +print =============== step4 +sql select stddev(tbcol) as b from $tb +print ===> $data00 +if $data00 != 5.766281297 then + return -1 +endi + +print =============== step5 +sql select stddev(tbcol) as b from $tb interval(1m) +print ===> $data01 +if $data01 != 0.000000000 then + return -1 +endi + +sql select stddev(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != 5.766281297 then + return -1 +endi + +print =============== step6 +sql select stddev(tbcol) as b from $tb where ts < now + 4m interval(1m) +print ===> $data01 +if $data01 != 0.000000000 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/compute/sum.sim b/tests/script/windows/compute/sum.sim new file mode 100644 index 0000000000000000000000000000000000000000..a429ce99e0b2faea0d594cc97c7f232b11c5e781 --- /dev/null +++ b/tests/script/windows/compute/sum.sim @@ -0,0 +1,159 @@ +sleep 2000 +sql connect + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = m_su_db +$tbPrefix = m_su_tb +$mtPrefix = m_su_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select sum(tbcol) from $tb +print ===> $data00 +if $data00 != 190 then + return -1 +endi + +print =============== step3 +sql select sum(tbcol) from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 10 then + return -1 +endi + +print =============== step4 +sql select sum(tbcol) as b from $tb +print ===> $data00 +if $data00 != 190 then + return -1 +endi + +print =============== step5 +sql select sum(tbcol) as b from $tb interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select sum(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != 190 then + return -1 +endi + +print =============== step6 +sql select sum(tbcol) as b from $tb where ts < now + 4m interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select sum(tbcol) from $mt +print ===> $data00 +if $data00 != 1900 then + return -1 +endi + +print =============== step8 +sql select sum(tbcol) as c from $mt where ts < now + 4m +print ===> $data00 +if $data00 != 100 then + return -1 +endi + +sql select sum(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 950 then + return -1 +endi + +sql select sum(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m +print ===> $data00 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select sum(tbcol) as b from $mt interval(1m) +print ===> $data11 +if $data11 < 5 then + return -1 +endi + +sql select sum(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 1900 then + return -1 +endi + +print =============== step10 +sql select sum(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != 190 then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select sum(tbcol) as b from $mt where ts < now + 4m interval(1d) group by tgcol +print select sum(tbcol) as b from $mt where ts < now + 4m interval(1d) group by tgcol +print ===> $data01 +if $data01 != 10 then + return -1 +endi +if $rows != 10 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/compute/top.sim b/tests/script/windows/compute/top.sim new file mode 100644 index 0000000000000000000000000000000000000000..65e448b0fa5fb1dffcaf1e63129099c57a4a9a02 --- /dev/null +++ b/tests/script/windows/compute/top.sim @@ -0,0 +1,99 @@ +sleep 2000 +sql connect + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = m_to_db +$tbPrefix = m_to_tb +$mtPrefix = m_to_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select top(tbcol, 1) from $tb +print ===> $data01 +if $data01 != 19 then + return -1 +endi + +print =============== step3 +sql select top(tbcol, 1) from $tb where ts < now + 4m +print ===> $data01 +if $data01 != 4 then + return -1 +endi + +print =============== step4 +sql select top(tbcol, 1) as b from $tb +print ===> $data01 +if $data01 != 19 then + return -1 +endi + +print =============== step5 +sql select top(tbcol, 2) as b from $tb +print ===> $data01 $data11 +if $data01 != 18 then + return -1 +endi +if $data11 != 19 then + return -1 +endi + +print =============== step6 +sql select top(tbcol, 2) as b from $tb where ts < now + 4m +print ===> $data01 $data11 +if $data01 != 3 then + return -1 +endi +if $data11 != 4 then + return -1 +endi + +sql select top(tbcol, 122) as b from $tb -x step6 + return -1 +step6: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/db/basic.sim b/tests/script/windows/db/basic.sim new file mode 100644 index 0000000000000000000000000000000000000000..914e456fe1e3a52ca107275b30995f88c37b0415 --- /dev/null +++ b/tests/script/windows/db/basic.sim @@ -0,0 +1,193 @@ +sleep 2000 +sql connect + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +print ============================ dnode1 start + +$i = 0 +$dbPrefix = ob_db_db +$tbPrefix = ob_db_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db replica 1 days 20 keep 2000 cache 16 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 +if $data00 != $db then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 0 then + return -1 +endi +if $data04 != 1 then + return -1 +endi +if $data06 != 20 then + return -1 +endi +if $data08 != 16 then + return -1 +endi + +print =============== step2 +sql create database $db +sql show databases +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +print =============== step4 +sql_error drop database $db + +print =============== step5 +sql create database $db replica 1 days 15 keep 1500 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 +if $data00 != $db then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 0 then + return -1 +endi +if $data04 != 1 then + return -1 +endi +if $data06 != 15 then + return -1 +endi + +print =============== step6 +sql use $db +sql create table $tb (ts timestamp, speed int) +$i = 1 +while $i < 4 + $db = $dbPrefix . $i + $tb = $tbPrefix . $i + sql create database $db + sql use $db + sql create table $tb (ts timestamp, speed int) + $i = $i + 1 +endw + +sql show databases +if $rows != 4 then + return -1 +endi + +$i = 4 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed int) + +print =============== step7 +$i = 0 +while $i < 5 + $db = $dbPrefix . $i + sql drop database $db + $i = $i + 1 +endw + +print =============== step8 +$i = 0 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed int) +sql show tables +if $rows != 1 then + return -1 +endi + +print =============== step9 +sql drop database $db + +print =============== step10 +sql create database $db +sql use $db +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step11 +sql create table $tb (ts timestamp, speed int) +sql show tables +if $rows != 1 then + return -1 +endi + +print =============== step12 +sql drop database $db + +print =============== step13 +sql create database $db +sql use $db +sql show tables +if $rows != 0 then + return -1 +endi +sql create table $tb (ts timestamp, speed int) +sql show tables +if $rows != 1 then + return -1 +endi +sql insert into $tb values (now+1a, 0) +sql insert into $tb values (now+2a, 1) +sql insert into $tb values (now+3a, 2) +sql insert into $tb values (now+4a, 3) +sql insert into $tb values (now+5a, 4) +sql select * from $tb +if $rows != 5 then + return -1 +endi + +print =============== step14 +sql drop database $db + +print =============== step15 +sql create database $db +sql use $db +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step16 +sql create table $tb (ts timestamp, speed int) +sql show tables +if $rows != 1 then + return -1 +endi +sql select * from $tb +if $rows != 0 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/db/len.sim b/tests/script/windows/db/len.sim new file mode 100644 index 0000000000000000000000000000000000000000..3356165117d3986d9eef4e7dced3bb1b61dd36da --- /dev/null +++ b/tests/script/windows/db/len.sim @@ -0,0 +1,92 @@ +sleep 2000 +sql connect + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +print =============== step1 +sql_error drop database dd + +sql create database -x step1 + return -1 +step1: + +sql show databases +if $rows != 0 then + return -1 +endi + +print =============== step2 +sql create database a +sql show databases +if $rows != 1 then + return -1 +endi + +sql drop database a +sql show databases +if $rows != 0 then + return -1 +endi + +print =============== step3 +sql create database a12345678 +sql show databases +if $rows != 1 then + return -1 +endi + +sql drop database a12345678 +sql show databases +if $rows != 0 then + return -1 +endi + +print =============== step4 +sql create database a012345678901201234567890120123456789012a012345678901201234567890120123456789012 -x step4 + return -1 +step4: +sql show databases +if $rows != 0 then + return -1 +endi + +print =============== step5 +sql create database a;1 +sql drop database a +sql show databases +if $rows != 0 then + return -1 +endi + +print =============== step6 +sql create database a'1 -x step6 + return -1 +step6: + +sql show databases +if $rows != 0 then + return -1 +endi + +print =============== step7 +sql create database (a) -x step7 + return -1 +step7: +sql show databases +if $rows != 0 then + return -1 +endi + +print =============== step8 +sql create database a.1 -x step8 + return -1 +step8: +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/field/2.sim b/tests/script/windows/field/2.sim new file mode 100644 index 0000000000000000000000000000000000000000..e258fbe80efbdde2d1b8f289f5302b74adb8b0f7 --- /dev/null +++ b/tests/script/windows/field/2.sim @@ -0,0 +1,295 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = fi_bt_db +$tbPrefix = fi_bt_tb +$mtPrefix = fi_bt_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol2 bool, tbcol int) TAGS(tgcol bool, tgcol2 int) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0, 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1, 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tbcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where ts > now + 4m and tbcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select * from $mt where ts > now + 4m and tbcol2 = 1 and tbcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 1 and tbcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 = 0 and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 <> 0 and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 = 0 and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 and tbcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m and ts < now + 5m and tbcol <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol2 = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 and tbcol2 = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol2 = 1 interval(1d) group by tgcol order by tgcol desc +print $db +print select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol2 = 1 interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/field/3.sim b/tests/script/windows/field/3.sim new file mode 100644 index 0000000000000000000000000000000000000000..e3fe0b0b1162548ccd8ce0d4e5d5606a628abcef --- /dev/null +++ b/tests/script/windows/field/3.sim @@ -0,0 +1,521 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = fi_3_db +$tbPrefix = fi_3_tb +$mtPrefix = fi_3_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol1 smallint, tbcol2 int, tbcol3 float) TAGS(tgcol1 smallint, tgcol2 int, tgcol3 float) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0, 0, 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1, 1, 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tbcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tbcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where tbcol3 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step6 +sql select * from $mt where ts > now + 4m and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > now + 4m and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step9 +sql select * from $mt where ts > now + 4m and tbcol2 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m and ts < now + 5m and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step10 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step11 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step12 +sql select * from $mt where ts > now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step13 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step14 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step15 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step16 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step17 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step18 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step19 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol1 order by tgcol1 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol2 order by tgcol2 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol3 order by tgcol3 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/field/4.sim b/tests/script/windows/field/4.sim new file mode 100644 index 0000000000000000000000000000000000000000..aabfe2be2ce76d5fa52fcde85c129b0f4bdf75ac --- /dev/null +++ b/tests/script/windows/field/4.sim @@ -0,0 +1,711 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = fi_4_db +$tbPrefix = fi_4_tb +$mtPrefix = fi_4_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol1 smallint, tbcol2 bigint, tbcol3 float, tbcol4 double) TAGS(tgcol1 smallint, tgcol2 bigint, tgcol3 float, tgcol4 double) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0, 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0, 0, 0, 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1, 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1, 1, 1, 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tbcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tbcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where tbcol3 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step6 +sql select * from $mt where tbcol4 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > now + 4m and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select * from $mt where ts > now + 4m and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step9 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step10 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step11 +sql select * from $mt where ts > now + 4m and tbcol2 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m and ts < now + 5m and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step12 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step13 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step14 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step15 +sql select * from $mt where ts > now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step16 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step17 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step18 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step19 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step20 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step21 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step22 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step23 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step24 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol1 order by tgcol1 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol2 order by tgcol2 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol3 order by tgcol3 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 interval(1d) group by tgcol4 order by tgcol4 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/field/5.sim b/tests/script/windows/field/5.sim new file mode 100644 index 0000000000000000000000000000000000000000..874730ff1c9cd341e8c3cc1f9c8d33b228d5b3ad --- /dev/null +++ b/tests/script/windows/field/5.sim @@ -0,0 +1,834 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = fi_5_db +$tbPrefix = fi_5_tb +$mtPrefix = fi_5_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol1 tinyint, tbcol2 int, tbcol3 bigint, tbcol4 double, tbcol5 smallint) TAGS(tgcol1 tinyint, tgcol2 int, tgcol3 bigint, tgcol4 double, tgcol5 smallint) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0, 0, 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0, 0, 0, 0, 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1, 1, 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1, 1, 1, 1, 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tbcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tbcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where tbcol3 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step6 +sql select * from $mt where tbcol4 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step7 +sql select * from $mt where tbcol5 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol5 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol5 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol5 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step8 +sql select * from $mt where ts > now + 4m and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step9 +sql select * from $mt where ts > now + 4m and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step10 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step11 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step12 +sql select * from $mt where ts > now + 4m and tbcol5 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol5 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol5 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol5 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step13 +sql select * from $mt where ts > now + 4m and tbcol2 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m and ts < now + 5m and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step14 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step15 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step16 +sql select * from $mt where ts > now + 4m and tbcol5 = 1 and tbcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol5 <> 1 and tbcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol5 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol5 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol5 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol5 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol5 <> 0 and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol5 <> 0 and ts < now + 5m and ts < now + 5m and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step17 +sql select * from $mt where ts > now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step18 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step19 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step20 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol1 = 1 and tbcol5 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 and tbcol1 <> 1 and tbcol5 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 and tbcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 and tbcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step21 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step22 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step23 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step24 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol5 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step25 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step26 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step27 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol1 order by tgcol1 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol2 order by tgcol2 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol3 order by tgcol3 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 interval(1d) group by tgcol4 order by tgcol4 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 interval(1d) group by tgcol5 order by tgcol5 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/field/6.sim b/tests/script/windows/field/6.sim new file mode 100644 index 0000000000000000000000000000000000000000..77277df35b2a41bbf7ab759763b9601054b0d5d6 --- /dev/null +++ b/tests/script/windows/field/6.sim @@ -0,0 +1,989 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = fi_6_db +$tbPrefix = fi_6_tb +$mtPrefix = fi_6_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol1 smallint, tbcol2 bigint, tbcol3 smallint, tbcol4 bigint, tbcol5 float, tbcol6 bool) TAGS(tgcol1 smallint, tgcol2 bigint, tgcol3 smallint, tgcol4 bigint, tgcol5 float, tgcol6 bool) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0, 0, 0, 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0, 0, 0, 0, 0, 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1, 1, 1, 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1, 1, 1, 1, 1, 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tbcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tbcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where tbcol3 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step6 +sql select * from $mt where tbcol4 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step7 +sql select * from $mt where tbcol5 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol5 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol5 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol5 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step8 +sql select * from $mt where tbcol6 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol6 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol6 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol6 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step9 +sql select * from $mt where ts > now + 4m and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step10 +sql select * from $mt where ts > now + 4m and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step11 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step12 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step13 +sql select * from $mt where ts > now + 4m and tbcol5 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol5 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol5 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol5 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step14 +sql select * from $mt where ts > now + 4m and tbcol6 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol6 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol6 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol6 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step15 +sql select * from $mt where ts > now + 4m and tbcol2 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m and ts < now + 5m and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step16 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step17 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step18 +sql select * from $mt where ts > now + 4m and tbcol5 = 1 and tbcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol5 <> 1 and tbcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol5 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol5 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol5 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol5 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol5 <> 0 and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol5 <> 0 and ts < now + 5m and ts < now + 5m and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step19 +sql select * from $mt where ts > now + 4m and tbcol5 = 1 and tbcol6 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol5 <> 1 and tbcol6 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol5 = 0 and tbcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol5 <> 0 and tbcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol5 = 0 and tbcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol5 <> 0 and tbcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol5 <> 0 and tbcol6 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol5 <> 0 and ts < now + 5m and ts < now + 5m and tbcol6 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step20 +sql select * from $mt where ts > now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step21 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step22 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step23 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol1 = 1 and tbcol5 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 and tbcol1 <> 1 and tbcol5 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 and tbcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 and tbcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step24 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol1 = 1 and tbcol5 = 1 and tbcol6 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 and tbcol1 <> 1 and tbcol5 <> 1 and tbcol6 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 and tbcol5 = 0 and tbcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 and tbcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 and tbcol5 = 0 and tbcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 and tbcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 and tbcol6 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 and tbcol6 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step25 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step26 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 and tbcol6 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step27 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 and tbcol6 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step28 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol5 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol6 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step29 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 and tbcol6 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step30 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 and tbcol6 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step31 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol1 order by tgcol1 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol2 order by tgcol2 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol3 order by tgcol3 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 interval(1d) group by tgcol4 order by tgcol4 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 interval(1d) group by tgcol5 order by tgcol5 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 and tbcol6 = 1 interval(1d) group by tgcol6 order by tgcol6 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/field/bigint.sim b/tests/script/windows/field/bigint.sim new file mode 100644 index 0000000000000000000000000000000000000000..f912ee968b0955e339340e9ee712b99eb954914a --- /dev/null +++ b/tests/script/windows/field/bigint.sim @@ -0,0 +1,160 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = fi_bi_db +$tbPrefix = fi_bi_tb +$mtPrefix = fi_bi_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol bigint) TAGS(tgcol bigint) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step3 +sql select * from $mt where ts > now + 4m and tbcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 interval(1d) group by tgcol order by tgcol desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/field/binary.sim b/tests/script/windows/field/binary.sim new file mode 100644 index 0000000000000000000000000000000000000000..aa641878e4c49463aca22ab3f57b43a558e955f7 --- /dev/null +++ b/tests/script/windows/field/binary.sim @@ -0,0 +1,77 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = fi_by_db +$tbPrefix = fi_by_tb +$mtPrefix = fi_by_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol binary(10)) TAGS(tgcol binary(10)) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '0' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , '0' ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '1' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , '1' ) + $x = $x + 1 + endw + $i = $i + 1 +endw + + +print =============== step2 + +sql select * from $mt where tbcol = '0' +if $rows != 100 then + return -1 +endi + +sql select * from $mt where ts > now + 4m and tbcol = '1' +if $rows != 75 then + return -1 +endi + +print select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = '1' +sql_error select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = '1' group by tgcol +sql_error select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = '1' group by tgcol +sql_error select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = '1' interval(1d) group by tgcol + +#can't filter binary fields + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/field/bool.sim b/tests/script/windows/field/bool.sim new file mode 100644 index 0000000000000000000000000000000000000000..3ef56a1d95082faf54f1e34db4009b8af0e80c6c --- /dev/null +++ b/tests/script/windows/field/bool.sim @@ -0,0 +1,161 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = fi_bo_db +$tbPrefix = fi_bo_tb +$mtPrefix = fi_bo_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol bool) TAGS(tgcol bool) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = false +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> false +if $rows != 100 then + return -1 +endi + +print =============== step3 +sql select * from $mt where ts > now + 4m and tbcol = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> false and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = true +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = true group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = true group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = true interval(1d) group by tgcol order by tgcol desc +print select count(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = true interval(1d) group by tgcol order by tgcol desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/field/double.sim b/tests/script/windows/field/double.sim new file mode 100644 index 0000000000000000000000000000000000000000..ef404d28dc306edaf2fe6be00eb83dfb484c23a3 --- /dev/null +++ b/tests/script/windows/field/double.sim @@ -0,0 +1,160 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = fi_do_db +$tbPrefix = fi_do_tb +$mtPrefix = fi_do_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol double) TAGS(tgcol double) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step3 +sql select * from $mt where ts > now + 4m and tbcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 interval(1d) group by tgcol order by tgcol desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/field/float.sim b/tests/script/windows/field/float.sim new file mode 100644 index 0000000000000000000000000000000000000000..8435f31c1fbc3353f87f8abc620184919b32ccbc --- /dev/null +++ b/tests/script/windows/field/float.sim @@ -0,0 +1,160 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = fi_fl_db +$tbPrefix = fi_fl_tb +$mtPrefix = fi_fl_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol float) TAGS(tgcol float) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step3 +sql select * from $mt where ts > now + 4m and tbcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 interval(1d) group by tgcol order by tgcol desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/field/int.sim b/tests/script/windows/field/int.sim new file mode 100644 index 0000000000000000000000000000000000000000..781b9394849192725ba5d46e3d669d53838501b7 --- /dev/null +++ b/tests/script/windows/field/int.sim @@ -0,0 +1,160 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = fi_in_db +$tbPrefix = fi_in_tb +$mtPrefix = fi_in_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step3 +sql select * from $mt where ts > now + 4m and tbcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 interval(1d) group by tgcol order by tgcol desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/field/single.sim b/tests/script/windows/field/single.sim new file mode 100644 index 0000000000000000000000000000000000000000..b6b44020915e57b130c77f2c40e1a7a2e4e1342c --- /dev/null +++ b/tests/script/windows/field/single.sim @@ -0,0 +1,218 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = fi_si_db +$tbPrefix = fi_si_tb +$mtPrefix = fi_si_mt +$rowNum = 20 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql create database $db +sql use $db +sql create table $tb (ts timestamp, tbcol int) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + +print =============== step2 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi + +sql select * from $tb where tbcol = 10 +if $rows != 1 then + return -1 +endi +if $data01 != 10 then + return -1 +endi + +sql select * from $tb where tbcol = 8 +if $rows != 1 then + return -1 +endi +if $data01 != 8 then + return -1 +endi + +sql select * from $tb where tbcol < 10 +if $rows != 10 then + return -1 +endi +if $data91 != 9 then + return -1 +endi + +sql select * from $tb where tbcol <= 10 +if $rows != 11 then + return -1 +endi +if $data81 != 8 then + return -1 +endi + +sql select * from $tb where tbcol > 10 +if $rows != 9 then + return -1 +endi +if $data81 != 19 then + return -1 +endi + +sql select * from $tb where tbcol > 10 order by ts asc +if $rows != 9 then + return -1 +endi +if $data01 != 11 then + return -1 +endi + +sql select * from $tb where tbcol < 10 and tbcol > 5 order by ts desc +if $rows != 4 then + return -1 +endi +if $data01 != 9 then + return -1 +endi +if $data31 != 6 then + return -1 +endi + +sql select * from $tb where tbcol < 10 and tbcol > 5 order by ts asc +if $rows != 4 then + return -1 +endi +if $data01 != 6 then + return -1 +endi +if $data31 != 9 then + return -1 +endi + +sql select * from $tb where tbcol > 10 and tbcol < 5 order by ts asc +if $rows != 0 then + return -1 +endi + +print =============== step3 +sql select * from $tb where ts < now + 4m +if $rows != 5 then + return -1 +endi + +sql select * from $tb where tbcol = 10 and ts < now + 4m +print select * from $tb where tbcol = 10 and ts < now + 4m +if $rows != 0 then + return -1 +endi + +sql select * from $tb where tbcol = 4 and ts < now + 4m order by ts desc +if $rows != 1 then + return -1 +endi +if $data01 != 4 then + return -1 +endi + +sql select * from $tb where tbcol < 10 and ts < now + 4m order by ts desc +if $rows != 5 then + return -1 +endi +if $data01 != 4 then + return -1 +endi + +sql select * from $tb where tbcol < 10 and ts > now + 4m and ts < now + 5m order by ts desc +print $rows $data00 $data01 +if $rows != 1 then + return -1 +endi +if $data01 != 5 then + return -1 +endi + +print =============== step4 +sql select count(*) from $tb +if $data00 != $rowNum then + return -1 +endi + +sql select count(*) from $tb where tbcol = 10 +if $data00 != 1 then + return -1 +endi + +#sql select count(*) from $tb where tbcol = 8 or tbcol = 9 +#if $data00 != 2 then +# return -1 +#endi + +sql select count(*) from $tb where tbcol < 10 +if $data00 != 10 then + return -1 +endi + +sql select count(*) from $tb where tbcol <= 10 +if $data00 != 11 then + return -1 +endi + +sql select count(*) from $tb where tbcol < 10 and tbcol > 5 +if $data00 != 4 then + return -1 +endi + +sql select count(*) from $tb where tbcol < 10 and tbcol > 5 order by ts asc -x step4 +# return -1 +step4: + +print =============== step5 +sql select count(*) from $tb where ts < now + 4m +if $data00 != 5 then + return -1 +endi + +#sql select count(*) from $tb where tbcol = 10 and ts < now + 4m +#if $data00 != 0 then +# return -1 +#endi + +sql select count(*) from $tb where tbcol = 4 and ts < now + 4m +if $data00 != 1 then + return -1 +endi + +sql select count(*) from $tb where tbcol < 10 and ts < now + 4m +if $data00 != 5 then + return -1 +endi + +sql select count(*) from $tb where tbcol < 10 and ts > now + 4m and ts < now + 5m +if $data00 != 1 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/field/smallint.sim b/tests/script/windows/field/smallint.sim new file mode 100644 index 0000000000000000000000000000000000000000..5f1839226b1d3aabfebfe9b30ad3f8b02d1e21a9 --- /dev/null +++ b/tests/script/windows/field/smallint.sim @@ -0,0 +1,160 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = fi_sm_db +$tbPrefix = fi_sm_tb +$mtPrefix = fi_sm_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol smallint) TAGS(tgcol smallint) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step3 +sql select * from $mt where ts > now + 4m and tbcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 interval(1d) group by tgcol order by tgcol desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/field/tinyint.sim b/tests/script/windows/field/tinyint.sim new file mode 100644 index 0000000000000000000000000000000000000000..c90ff3f932a3eeb52e1ff607ac0bcacf21fecfe4 --- /dev/null +++ b/tests/script/windows/field/tinyint.sim @@ -0,0 +1,160 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = fi_ti_db +$tbPrefix = fi_ti_tb +$mtPrefix = fi_ti_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol tinyint) TAGS(tgcol tinyint) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step3 +sql select * from $mt where ts > now + 4m and tbcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 interval(1d) group by tgcol order by tgcol desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/import/basic.sim b/tests/script/windows/import/basic.sim new file mode 100644 index 0000000000000000000000000000000000000000..ee19893ae21fd8c97eeb9aa5898ead86b8b8d19f --- /dev/null +++ b/tests/script/windows/import/basic.sim @@ -0,0 +1,125 @@ +sql connect +sleep 2000 + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +sql create database ibadb +sql use ibadb +sql create table tb(ts timestamp, i int) + +print ================= step1 + +sql import into tb values(1564641710000, 10000) +sql select * from tb; +if $rows != 1 then + return -1 +endi + +print ================= step2 +sql insert into tb values(1564641708000, 8000) +sql select * from tb; +if $rows != 2 then + return -1 +endi + +print ================= step3 +sql insert into tb values(1564641720000, 20000) +sql select * from tb; +if $rows != 3 then + return -1 +endi + +print ================= step4 +sql import into tb values(1564641708000, 8000) +sql import into tb values(1564641715000, 15000) +sql import into tb values(1564641730000, 30000) +sql select * from tb; +if $rows != 5 then + return -1 +endi + +print ================= step5 +sql insert into tb values(1564641708000, 8000) +sql insert into tb values(1564641714000, 14000) +sql insert into tb values(1564641725000, 25000) +sql insert into tb values(1564641740000, 40000) +sql select * from tb; +if $rows != 8 then + return -1 +endi + +print ================= step6 +sql import into tb values(1564641707000, 7000) +sql import into tb values(1564641712000, 12000) +sql import into tb values(1564641723000, 23000) +sql import into tb values(1564641734000, 34000) +sql import into tb values(1564641750000, 50000) +sql select * from tb; +if $rows != 13 then + return -1 +endi + +print ================= step7 +sql import into tb values(1564641707001, 7001) +sql import into tb values(1564641712001, 12001) +sql import into tb values(1564641723001, 23001) +sql import into tb values(1564641734001, 34001) +sql import into tb values(1564641750001, 50001) +sql select * from tb; +if $rows != 18 then + return -1 +endi + +print ================= step8 +sql insert into tb values(1564641708002, 8002) +sql insert into tb values(1564641714002, 14002) +sql insert into tb values(1564641725002, 25002) +sql insert into tb values(1564641900000, 200000) +sql select * from tb; +if $rows != 22 then + return -1 +endi + +print ================= step9 only insert last one +sql import into tb values(1564641705000, 5000)(1564641718000, 18000)(1564642400000, 700000) +sql select * from tb; +if $rows != 25 then + return -1 +endi + +print ================= step10 +sql import into tb values(1564641705000, 5000)(1564641718000, 18000)(1564642400000, 70000) +sql select * from tb; +if $rows != 25 then + return -1 +endi + +print ================= step11 +sql import into tb values(1564642400000, 700000) +sql select * from tb; +if $rows != 25 then + return -1 +endi + +print ================= step12 +sql import into tb values(1564641709527, 9527)(1564641709527, 9528) +sql select * from tb; +print rows=> $rows +if $rows != 26 then + return -1 +endi + +print ================= step13 +sql import into tb values(1564641709898, 9898)(1564641709897, 9897) +sql select * from tb; +print rows=> $rows +if $rows != 28 then + return -1 +endi + +sql drop database ibadb \ No newline at end of file diff --git a/tests/script/windows/insert/basic.sim b/tests/script/windows/insert/basic.sim new file mode 100644 index 0000000000000000000000000000000000000000..a516f80e1013a40a8889ca939ca650360e4fc976 --- /dev/null +++ b/tests/script/windows/insert/basic.sim @@ -0,0 +1,49 @@ +sql connect +sleep 2000 + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$i = 0 +$dbPrefix = tb_in_db +$tbPrefix = tb_in_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop database -x step1 +step1: +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed int) + +$x = 0 +while $x < 10 + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 +endw + +print =============== step 2 +sql insert into $tb values (now - 5m , 10) +sql insert into $tb values (now - 6m , 10) +sql insert into $tb values (now - 7m , 10) +sql insert into $tb values (now - 8m , 10) + +sql select * from $tb + +print $rows points data are retrieved +if $rows != 14 then + return -1 +endi + +sql drop database $db +sleep 1000 +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/windows/insert/query_block1_file.sim b/tests/script/windows/insert/query_block1_file.sim new file mode 100644 index 0000000000000000000000000000000000000000..62b74ac19c18a624d41941e8c51a3e8fb87ddee0 --- /dev/null +++ b/tests/script/windows/insert/query_block1_file.sim @@ -0,0 +1,195 @@ +sql connect +sleep 2000 + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$i = 0 +$dbPrefix = tb_1f_db +$tbPrefix = tb_1f_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop database -x step1 +step1: +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed int) + +#commit to file will trigger if insert 82 rows + +$N = 82 + +print =============== step 1 +$x = $N +$y = $N / 2 +while $x > $y + $ms = $x . m + $xt = - . $x + sql insert into $tb values (now - $ms , $x ) + $x = $x - 1 +endw + +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $y then + return -1 +endi + +$x = $N / 2 +$y = $N +while $x < $y + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 +endw +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $N then + return -1 +endi + +print =============== step 2 + +$R = 4 +$x = $N * 2 +$y = $N * $R +$expect = $y + $N +$y = $y + $x +while $x < $y + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $expect then + return -1 +endi + +print =============== step 3 + +$N1 = $N + 1 +$result1 = $N / 2 +$result2 = $N +$step = $N1 . m + +$start1 = now- . $step +$start2 = now +$start3 = now+ . $step +$end1 = now- . $step +$end2 = now +$end3 = now+ . $step + + +sql select * from $tb where ts < $start1 and ts > $end1 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 +print select * from $tb where ts < $start2 and ts > $end1 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 +print sql select * from $tb where ts < $start3 and ts > $end1 -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 +print sql select * from $tb where ts < $start3 and ts > $end2 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 +if $rows != 0 then + return -1 +endi + +print ================= order by ts desc + +sql select * from $tb where ts < $start1 and ts > $end1 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 order by ts desc +print select * from $tb where ts < $start2 and ts > $end1 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +clear: + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/windows/insert/query_block1_memory.sim b/tests/script/windows/insert/query_block1_memory.sim new file mode 100644 index 0000000000000000000000000000000000000000..6c3e58d70e992a79bfcd84a670616b9b3441393f --- /dev/null +++ b/tests/script/windows/insert/query_block1_memory.sim @@ -0,0 +1,177 @@ +sql connect +sleep 2000 + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$i = 0 +$dbPrefix = tb_1m_db +$tbPrefix = tb_1m_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop database -x step1 +step1: +sql create database $db +sql use $db + +sql create table $tb (ts timestamp, speed int) + +#commit to file will trigger if insert 82 rows + +$N = 82 + +print =============== step 1 +$x = $N +$y = $N / 2 +while $x > $y + $ms = $x . m + $xt = - . $x + sql insert into $tb values (now - $ms , -$x ) + $x = $x - 1 +endw + +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $y then + return -1 +endi + +$x = $N / 2 +$y = $N +while $x < $y + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 +endw +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $N then + return -1 +endi + +print =============== step 2 + +$N1 = $N + 1 +$result1 = $N / 2 +$result2 = $N +$step = $N1 . m + +$start1 = now- . $step +$start2 = now +$start3 = now+ . $step +$end1 = now- . $step +$end2 = now +$end3 = now+ . $step + +sql select * from $tb where ts < $start1 and ts > $end1 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 +print select * from $tb where ts < $start2 and ts > $end1 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 +print sql select * from $tb where ts < $start3 and ts > $end1 -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 +print sql select * from $tb where ts < $start3 and ts > $end2 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 +if $rows != 0 then + return -1 +endi + +print ================= order by ts desc + +sql select * from $tb where ts < $start1 and ts > $end1 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 order by ts desc +print select * from $tb where ts < $start2 and ts > $end1 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +clear: + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + diff --git a/tests/script/windows/insert/query_block2_file.sim b/tests/script/windows/insert/query_block2_file.sim new file mode 100644 index 0000000000000000000000000000000000000000..164c8a1124eb7648c2cb0d39a1dba3839849aab4 --- /dev/null +++ b/tests/script/windows/insert/query_block2_file.sim @@ -0,0 +1,210 @@ +sql connect +sleep 2000 + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$i = 0 +$dbPrefix = tb_2f_db +$tbPrefix = tb_2f_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop database -x step1 +step1: +sql create database $db +sql use $db + +$x = 0 +create1: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create table $tb (ts timestamp, speed int) -x create1 + +#commit to file will trigger if insert 82 rows +$N = 82 + +print =============== step 1 +$x = $N * 2 +$y = $N +$expect = $N +while $x > $y + $ms = $x . m + $xt = - . $x + sql insert into $tb values (now - $ms , $xt ) + $x = $x - 1 +endw + +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $expect then + return -1 +endi + +$x = $N +$y = $N * 2 +$expect = $N * 2 +while $x < $y + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 +endw +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $expect then + return -1 +endi + +print =============== step 2 + +$R = 4 +$y = $N * $R + +$expect = $y + $N +$expect = $expect + $N + +$x = $N * 3 +$y = $y + $x + +while $x < $y + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $expect then + return -1 +endi + + +print =============== step 2 + +$N2 = $N +$result1 = $N +$result2 = 2 * $N +$N1 = $result2 + 1 +$step = $N1 . m + +$start1 = now- . $step +$start2 = now +$start3 = now+ . $step +$end1 = now- . $step +$end2 = now +$end3 = now+ . $step + +sql select * from $tb where ts < $start1 and ts > $end1 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 +print select * from $tb where ts < $start2 and ts > $end1 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 +print sql select * from $tb where ts < $start3 and ts > $end1 -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 +print sql select * from $tb where ts < $start3 and ts > $end2 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 +if $rows != 0 then + return -1 +endi + +print ================= order by ts desc + +sql select * from $tb where ts < $start1 and ts > $end1 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 order by ts desc +print select * from $tb where ts < $start2 and ts > $end1 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +clear: + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + diff --git a/tests/script/windows/insert/query_block2_memory.sim b/tests/script/windows/insert/query_block2_memory.sim new file mode 100644 index 0000000000000000000000000000000000000000..f3ceb503acfebae398856d1a2d085fd0e3a0ce2d --- /dev/null +++ b/tests/script/windows/insert/query_block2_memory.sim @@ -0,0 +1,172 @@ +sql connect +sleep 2000 + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$i = 0 +$dbPrefix = tb_2m_db +$tbPrefix = tb_2m_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop database -x step1 +step1: +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed int) + +$N = 82 + +$x = $N * 2 +$y = $N +while $x > $y + $ms = $x . m + $xt = - . $x + sql insert into $tb values (now - $ms , $xt ) + $x = $x - 1 +endw + +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $y then + return -1 +endi + +$x = $N +$y = $N * 2 +$expect = $N * 2 +while $x < $y + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 +endw +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $expect then + return -1 +endi + +print =============== step 2 + +$result1 = $N +$result2 = $N * 2 + +$N1 = $result2 + 1 +$step = $N1 . m + +$start1 = now- . $step +$start2 = now +$start3 = now+ . $step +$end1 = now- . $step +$end2 = now +$end3 = now+ . $step + +sql select * from $tb where ts < $start1 and ts > $end1 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 +print select * from $tb where ts < $start2 and ts > $end1 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 +print sql select * from $tb where ts < $start3 and ts > $end1 -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 +print sql select * from $tb where ts < $start3 and ts > $end2 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 +if $rows != 0 then + return -1 +endi + +print ================= order by ts desc + +sql select * from $tb where ts < $start1 and ts > $end1 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 order by ts desc +print select * from $tb where ts < $start2 and ts > $end1 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/insert/query_file_memory.sim b/tests/script/windows/insert/query_file_memory.sim new file mode 100644 index 0000000000000000000000000000000000000000..d9752c40c9cc7c264a86e245eb3877fc47783b2a --- /dev/null +++ b/tests/script/windows/insert/query_file_memory.sim @@ -0,0 +1,209 @@ +sql connect +sleep 2000 + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$i = 0 +$dbPrefix = tb_fm_db +$tbPrefix = tb_fm_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop database -x step1 +step1: +sql create database $db +sql use $db + +$x = 0 +create1: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create table $tb (ts timestamp, speed int) -x create1 + +#commit to file will trigger if insert 82 rows + +$N = 82 + +$x = $N * 2 +$y = $N +$expect = $y +while $x > $y + $ms = $x . m + $xt = - . $x + sql insert into $tb values (now - $ms , $xt ) + $x = $x - 1 +endw + +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $expect then + return -1 +endi + +$x = $N +$y = $N * 2 +$expect = $N * 2 +while $x < $y + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 +endw +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $expect then + return -1 +endi + +$R = 4 +$R = $R - 1 + +$y = $N * $R +$expect = $y + $N +$expect = $expect + $N + +$x = $N * 3 +$y = $y + $x +while $x < $y + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $expect then + return -1 +endi + + +print =============== step 2 + +$result1 = $N +$result2 = $N * 2 +$N1 = $result2 + 1 +$step = $N1 . m + +$start1 = now- . $step +$start2 = now +$start3 = now+ . $step +$end1 = now- . $step +$end2 = now +$end3 = now+ . $step + + +sql select * from $tb where ts < $start1 and ts > $end1 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 +print select * from $tb where ts < $start2 and ts > $end1 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 +print sql select * from $tb where ts < $start3 and ts > $end1 -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 +print sql select * from $tb where ts < $start3 and ts > $end2 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 +if $rows != 0 then + return -1 +endi + +print ================= order by ts desc + +sql select * from $tb where ts < $start1 and ts > $end1 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 order by ts desc +print select * from $tb where ts < $start2 and ts > $end1 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +clear: + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + + diff --git a/tests/script/windows/insert/query_multi_file.sim b/tests/script/windows/insert/query_multi_file.sim new file mode 100644 index 0000000000000000000000000000000000000000..ba617ce63c6886bc978fe732222a54a7a99ad4d5 --- /dev/null +++ b/tests/script/windows/insert/query_multi_file.sim @@ -0,0 +1,55 @@ +sql connect +sleep 2000 + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$i = 0 +$dbPrefix = tb_mf_db +$tbPrefix = tb_mf_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop database -x step1 +step1: +sql create database $db +sql use $db + +$x = 0 +create1: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create table $tb (ts timestamp, speed int) -x create1 + +$N = 20000 + +$x = 0 + +while $x < $N + $ms = $x . s + #print insert into $tb values (now + $ms , $x ) + sql insert into $tb values (now + $ms , $x ) -x error_insert + $x = $x + 1 +endw +error_insert: + +sql select * from $tb +print $rows points data are retrieved -> exepct $N rows +if $rows < $N then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + diff --git a/tests/script/windows/table/binary.sim b/tests/script/windows/table/binary.sim new file mode 100644 index 0000000000000000000000000000000000000000..5efa0bc6667c4f2418e53f341315bf6529527455 --- /dev/null +++ b/tests/script/windows/table/binary.sim @@ -0,0 +1,63 @@ +sql connect +sleep 2000 + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$i = 0 +$dbPrefix = lm_bn_db +$tbPrefix = lm_bn_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed binary(5)) + +sql insert into $tb values (now, ) -x step1 + return -1 +step1: + +print =============== step2 +sql insert into $tb values (now+1a, '1234') +sql select speed from $tb order by ts desc +if $rows != 1 then + return -1 +endi +if $data00 != 1234 then + return -1 +endi + +print =============== step3 +sql insert into $tb values (now+2a, '23456') +sql select speed from $tb order by ts desc +if $rows != 2 then + return -1 +endi +print ==> $data00 +if $data00 != 23456 then + return -1 +endi + +print =============== step4 +sql_error insert into $tb values (now+3a, '345678') +sql insert into $tb values (now+3a, '34567') +sql select speed from $tb order by ts desc +if $rows != 3 then + return -1 +endi +print ==> $data00 +if $data00 != 34567 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/windows/table/bool.sim b/tests/script/windows/table/bool.sim new file mode 100644 index 0000000000000000000000000000000000000000..0d185d31e81c34d7289d753cce63ec419612646b --- /dev/null +++ b/tests/script/windows/table/bool.sim @@ -0,0 +1,92 @@ +sql connect +sleep 2000 + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$i = 0 +$dbPrefix = lm_bo_db +$tbPrefix = lm_bo_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db +$x = 0 +sql create table $tb (ts timestamp, speed bool) + +sql insert into $tb values (now, true) +sql select * from $tb +if $rows != 1 then + return -1 +endi + +if $data01 != 1 then + return -1 +endi + +print =============== step2 +sql insert into $tb values (now+1m, 1) +sql select * from $tb order by ts desc +if $rows != 2 then + return -1 +endi + +if $data01 != 1 then + return -1 +endi + +print =============== step3 +sql insert into $tb values (now+2m, 2) +sql select * from $tb order by ts desc +if $rows != 3 then + return -1 +endi + +if $data01 != 1 then + return -1 +endi + +print =============== step4 +sql insert into $tb values (now+3m, 0) +sql select * from $tb order by ts desc +if $rows != 4 then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +print =============== step5 +sql insert into $tb values (now+4m, -1) +sql select * from $tb order by ts desc +if $rows != 5 then + return -1 +endi + +if $data01 != 1 then + return -1 +endi + +print =============== step6 +sql insert into $tb values (now+5m, false) +sql select * from $tb order by ts desc +if $rows != 6 then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/windows/table/column_name.sim b/tests/script/windows/table/column_name.sim new file mode 100644 index 0000000000000000000000000000000000000000..6f9f954461c6faaddb01ab8e327c008a86809bbd --- /dev/null +++ b/tests/script/windows/table/column_name.sim @@ -0,0 +1,91 @@ +sql connect +sleep 2000 + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + + +$i = 0 +$dbPrefix = lm_cm_db +$tbPrefix = lm_cm_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db + +sql drop table dd -x step0 + return -1 +step0: + +sql create table $tb(ts timestamp, int) -x step1 + return -1 +step1: + +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step2 +sql create table $tb (ts timestamp, s int) +sql show tables +if $rows != 1 then + return -1 +endi + +sql drop table $tb +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step3 +sql create table $tb (ts timestamp, a0123456789 int) +sql show tables +if $rows != 1 then + return -1 +endi + +sql drop table $tb +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step4 +sql create table $tb (ts timestamp, a0123456789012345678901234567890123456789 int) +sql drop table $tb + +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step5 +sql create table $tb (ts timestamp, a0123456789 int) +sql show tables +if $rows != 1 then + return -1 +endi + +sql insert into $tb values (now , 1) +sql select * from $tb +if $rows != 1 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + + + + diff --git a/tests/script/windows/table/column_num.sim b/tests/script/windows/table/column_num.sim new file mode 100644 index 0000000000000000000000000000000000000000..395ee02cdea0b90fe8cd248af63cc950c090c283 --- /dev/null +++ b/tests/script/windows/table/column_num.sim @@ -0,0 +1,86 @@ +sql connect +sleep 2000 + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + + +$i = 0 +$dbPrefix = lm_cn_db +$tbPrefix = lm_cn_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db + +sql create table $tb() -x step1 + return -1 +step1: + +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step2 +sql create table $tb (ts timestamp) -x step2 + return -1 +step2: + +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step3 +sql create table $tb (ts int) -x step3 + return -1 +step3: + +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step4 +sql create table $tb (ts timestamp, a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, a10 int, a11 int, a12 int, a13 int, a14 int, a15 int, a16 int, a17 int, a18 int, a19 int, a20 int, a21 int, a22 int, a23 int, a24 int, a25 int, a26 int, a27 int, a28 int,a29 int,a30 int,a31 int,a32 int, b1 int, b2 int, b3 int, b4 int, b5 int, b6 int, b7 int, b8 int, b9 int, b10 int, b11 int, b12 int, b13 int, b14 int, b15 int, b16 int, b17 int, b18 int, b19 int, b20 int, b21 int, b22 int, b23 int, b24 int, b25 int, b26 int, b27 int, b28 int,b29 int,b30 int,b31 int,b32 int) + +sql show tables +if $rows != 1 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb = $tbPrefix . $i + +sql create table $tb (ts timestamp, a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, a10 int, a11 int, a12 int, a13 int, a14 int, a15 int, a16 int, a17 int, a18 int, a19 int, a20 int, a21 int, a22 int, a23 int, a24 int, a25 int, a26 int, a27 int, a28 int,a29 int,a30 int,a31 int,a32 int, b1 int, b2 int, b3 int, b4 int, b5 int) + +sql show tables +if $rows != 2 then + return -1 +endi + +sql insert into $tb values (now, 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 , 25 ,26 , 27 ,28 ,29,30,31, 32, 33, 34, 35, 36, 37) +sql select * from $tb +if $rows != 1 then + return -1 +endi + +sql drop table $tb +sql show tables +if $rows != 1 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/windows/table/column_value.sim b/tests/script/windows/table/column_value.sim new file mode 100644 index 0000000000000000000000000000000000000000..8db85f16ad876deff5c1a4b445351c83e9c5a3b7 --- /dev/null +++ b/tests/script/windows/table/column_value.sim @@ -0,0 +1,80 @@ +sql connect +sleep 2000 + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + + +$i = 0 +$dbPrefix = lm_cv_db +$tbPrefix = lm_cv_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db + +sql create table $tb (ts timestamp, speed int, v1 binary(100), v2 binary(100), v3 binary(100), v4 binary(100), v5 binary(100)) +sql show tables +if $rows != 1 then + return -1 +endi +sql insert into $tb values(now, 1, '1', '2', '3', '4', '5') +sql insert into $tb values(now+1a, 1, '1', '2', '3', '4', '5') +sql select * from $tb +if $rows != 2 then + return -1 +endi +sql drop table $tb +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step2 +sql create table $tb (ts timestamp, speed bigint, v1 binary(1500), v2 binary(1500), v3 binary(1500), v4 binary(500), v5 binary(500)) +sql show tables +if $rows != 1 then + return -1 +endi +sql drop table $tb + +print =============== step3 +sql create table $tb (ts timestamp, speed float, v1 binary(100), v2 binary(100), v3 binary(100), v4 binary(100), v5 binary(100)) +sql show tables +if $rows != 1 then + return -1 +endi +sql insert into $tb values(now+2a, 1, '1', '2', '3', '4', '5') +sql insert into $tb values(now+3a, 1, '1', '2', '3', '4', '5') +sql select * from $tb +if $rows != 2 then + return -1 +endi +sql drop table $tb +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step4 +sql create table $tb (ts timestamp, speed double, v1 binary(1500), v2 binary(1500), v3 binary(1500), v4 binary(500), v5 binary(500)) +sql show tables +if $rows != 1 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + + + + diff --git a/tests/script/windows/table/db.table.sim b/tests/script/windows/table/db.table.sim new file mode 100644 index 0000000000000000000000000000000000000000..0e207c998276fe4e33d0f875155d971506aadb70 --- /dev/null +++ b/tests/script/windows/table/db.table.sim @@ -0,0 +1,48 @@ +sql connect +sleep 2000 + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + + +$i = 0 +$dbPrefix = lm_dt_db +$tbPrefix = lm_dt_tb +$db = $dbPrefix +$tb = $tbPrefix + +print =============== step1 +sql create database $db +$table = lm_dt_db.lm_dt_tb + +print =============== step2 +sql create table $table (ts timestamp, speed int) + +print =============== step3 +sql insert into $table values (now, 1) + +print =============== step4 +sql select * from $table +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +print =============== step5 +sql describe $table + +print =============== step6 +sql drop table $table + + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/table/double.sim b/tests/script/windows/table/double.sim new file mode 100644 index 0000000000000000000000000000000000000000..b88ac4a199c9394422c7427eda6d824ec524e667 --- /dev/null +++ b/tests/script/windows/table/double.sim @@ -0,0 +1,98 @@ +sql connect +sleep 2000 + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$i = 0 +$dbPrefix = lm_do_db +$tbPrefix = lm_do_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed double) +#sql insert into $tb values (now, -1.79E+308) -x step1 +# return -1 +#step1: + +print =============== step2 +#sql insert into $tb values (now+1a, 1.79E+308) -x step2 +# return -1 +#step2: + +sql select * from $tb order by ts desc +if $rows != 0 then + return -1 +endi + +print =============== step3 +sql insert into $tb values (now+2a, 2.85) +sql select * from $tb order by ts desc +if $rows != 1 then + return -1 +endi +if $data01 != 2.850000000 then + return -1 +endi + +print =============== step4 +sql insert into $tb values (now+3a, 3.4) +sql select * from $tb order by ts desc +if $rows != 2 then + return -1 +endi +if $data01 != 3.400000000 then + return -1 +endi + +print =============== step5 +sql insert into $tb values (now+4a, a2) -x step51 + return -1 +step51: +sql insert into $tb values (now+4a, 0) +sql select * from $tb order by ts desc +if $rows != 3 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi + +print =============== step6 +sql insert into $tb values (now+5a, 2a) -x step6 + return -1 +step6: +sql insert into $tb values(now+5a, 2) +sql select * from $tb order by ts desc +if $rows != 4 then + return -1 +endi +if $data01 != 2.000000000 then + return -1 +endi + +print =============== step7 +sql insert into $tb values (now+6a, 2a'1) -x step7 + return -1 +step7: +sql insert into $tb values(now+6a, 2) +sql select * from $tb order by ts desc +if $rows != 5 then + return -1 +endi +if $data01 != 2.000000000 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/windows/table/float.sim b/tests/script/windows/table/float.sim new file mode 100644 index 0000000000000000000000000000000000000000..741525830d9a5ea38d82420e9affcb8015dab1db --- /dev/null +++ b/tests/script/windows/table/float.sim @@ -0,0 +1,98 @@ +sql connect +sleep 2000 + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$i = 0 +$dbPrefix = lm_fl_db +$tbPrefix = lm_fl_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed float) +#sql insert into $tb values (now, -3.40E+38) -x step1 +# return -1 +#step1: + +print =============== step2 +#sql insert into $tb values (now+1a, 3.40E+308) -x step2 +# return -1 +#step2: + +sql select * from $tb order by ts desc +if $rows != 0 then + return -1 +endi + +print =============== step3 +sql insert into $tb values (now+2a, 2.85) +sql select * from $tb order by ts desc +if $rows != 1 then + return -1 +endi +if $data01 != 2.85000 then + return -1 +endi + +print =============== step4 +sql insert into $tb values (now+3a, 3.4) +sql select * from $tb order by ts desc +if $rows != 2 then + return -1 +endi +if $data01 != 3.40000 then + return -1 +endi + +print =============== step5 +sql insert into $tb values (now+4a, a2) -x step5 + return -1 +step5: +sql insert into $tb values (now+4a, 0) +sql select * from $tb order by ts desc +if $rows != 3 then + return -1 +endi +if $data01 != 0.00000 then + return -1 +endi + +print =============== step6 +sql insert into $tb values (now+5a, 2a) -x step6 + return -1 +step6: +sql insert into $tb values (now+5a, 2) +sql select * from $tb order by ts desc +if $rows != 4 then + return -1 +endi +if $data01 != 2.00000 then + return -1 +endi + +print =============== step7 +sql insert into $tb values (now+6a, 2a'1) -x step7 + return -1 +step7: +sql insert into $tb values (now+6a, 2) +sql select * from $tb order by ts desc +if $rows != 5 then + return -1 +endi +if $data01 != 2.00000 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/windows/table/table.sim b/tests/script/windows/table/table.sim new file mode 100644 index 0000000000000000000000000000000000000000..13d157627720e9f5c8a355255782b10ea43b4a58 --- /dev/null +++ b/tests/script/windows/table/table.sim @@ -0,0 +1,225 @@ +sql connect +sleep 2000 +print ============================ dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$i = 0 +$dbPrefix = ob_tb_db +$tbPrefix = ob_tb_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop database $db -x step1 +step1: +sql create database $db + +print =============== step2-3-4 +sql use $db + +$i = 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val tinyint, val2 tinyint) +sql insert into $tb values(now, 1, 1) +sql select * from $tb +if $data01 != 1 then + return -1 +endi + +$i = 2 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val smallint, val2 smallint) +sql insert into $tb values(now, 2, 2) +sql select * from $tb +if $data01 != 2 then + return -1 +endi + +$i = 3 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val int, val2 int) +sql insert into $tb values(now, 3, 3) +sql select * from $tb +if $data01 != 3 then + return -1 +endi + +$i = 4 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val bigint, val2 bigint) +sql insert into $tb values(now, 4, 4) +sql select * from $tb +if $data01 != 4 then + return -1 +endi + +$i = 5 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val float, val2 float) +sql insert into $tb values(now, 5, 5) +sql select * from $tb +print ==> $data01 $data02 +if $data01 != 5.00000 then + return -1 +endi + +$i = 6 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val double, val2 double) +sql insert into $tb values(now, 6, 6) +sql select * from $tb +print ==> $data01 $data02 +if $data01 != 6.000000000 then + return -1 +endi + +$i = 7 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val binary(20), val2 binary(20)) +sql insert into $tb values(now, '7', '7') +sql select * from $tb +if $data01 != 7 then + return -1 +endi + +print =============== step5 +sql show tables +if $rows != 7 then + return -1 +endi + +$i = 1 +while $i < 8 + $tb = $tbPrefix . $i + sql drop table $tb + $i = $i + 1 +endw + +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step6-9 +$i = 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val tinyint, val2 tinyint) +sql select * from $tb +if $rows != 0 then + return -1 +endi +sql insert into $tb values(now, 1, 1) +sql select * from $tb +if $data01 != 1 then + return -1 +endi + +$i = 2 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val smallint, val2 smallint) +sql select * from $tb +if $rows != 0 then + return -1 +endi +sql insert into $tb values(now, 2, 2) +sql select * from $tb +if $data01 != 2 then + return -1 +endi + +$i = 3 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val int, val2 int) +sql select * from $tb +if $rows != 0 then + return -1 +endi +sql insert into $tb values(now, 3, 3) +sql select * from $tb +if $data01 != 3 then + return -1 +endi + +$i = 4 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val bigint, val2 bigint) +sql select * from $tb +if $rows != 0 then + return -1 +endi +sql insert into $tb values(now, 4, 4) +sql select * from $tb +if $data01 != 4 then + return -1 +endi + +$i = 5 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val float, val2 float) +sql select * from $tb +if $rows != 0 then + return -1 +endi +sql insert into $tb values(now, 5, 5) +sql select * from $tb +print ==> $data01 $data02 +if $data01 != 5.00000 then + return -1 +endi + +$i = 6 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val double, val2 double) +sql select * from $tb +if $rows != 0 then + return -1 +endi +sql insert into $tb values(now, 6, 6) +sql select * from $tb +print ==> $data01 $data02 +if $data01 != 6.000000000 then + return -1 +endi + +$i = 7 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val binary(20), val2 binary(20)) +sql select * from $tb +if $rows != 0 then + return -1 +endi +sql insert into $tb values(now, '7', '7') +sql select * from $tb +if $data01 != 7 then + return -1 +endi + +print =============== step10 +$i = 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val tinyint, val2 tinyint) +sql show tables +if $rows != 7 then + return -1 +endi + +print =============== step11 +sql create table $tb (ts timestamp, val float, val2 double) +sql show tables +if $rows != 7 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + + diff --git a/tests/script/windows/table/table_len.sim b/tests/script/windows/table/table_len.sim new file mode 100644 index 0000000000000000000000000000000000000000..72ed549466a61e984a0d9f287639a590c7d07f79 --- /dev/null +++ b/tests/script/windows/table/table_len.sim @@ -0,0 +1,105 @@ +sql connect +sleep 2000 + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$i = 0 +$dbPrefix = lm_tb_db +$tbPrefix = lm_tb_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db + +sql drop table dd -x step0 + return -1 +step0: + +sql create table (ts timestamp, speed int) -x step1 + return -1 +step1: + +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step2 +sql create table a (ts timestamp, speed int) +sql show tables +if $rows != 1 then + return -1 +endi + +sql drop table a +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step3 +sql create table a0123456789 (ts timestamp, speed int) +sql show tables +if $rows != 1 then + return -1 +endi + +sql drop table a0123456789 +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step4 +sql create table ab01234567890123456789a0123456789a0123456789ab01234567890123456789a0123456789a0123456789ab01234567890123456789a0123456789a0123456789ab01234567890123456789a0123456789a0123456789ab01234567890123456789a0123456789a0123456789ab01234567890123456789a0123456789a0123456789 (ts timestamp, speed int) -x step4 + return -1 +step4: +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step5 +sql create table a;1 (ts timestamp, speed int) -x step5 + return -1 +step5: +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step6 +sql create table a'1 (ts timestamp, speed int) -x step6 + return -1 +step6: +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step7 +sql create table (a) (ts timestamp, speed int) -x step7 + return -1 +step7: +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step8 +sql create table a.1 (ts timestamp, speed int) -x step8 + return -1 +step8: + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/3.sim b/tests/script/windows/tag/3.sim new file mode 100644 index 0000000000000000000000000000000000000000..5479be158ba4ab0be883d1f0eb26d2eb09aaafa1 --- /dev/null +++ b/tests/script/windows/tag/3.sim @@ -0,0 +1,521 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = ta_3_db +$tbPrefix = ta_3_tb +$mtPrefix = ta_3_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 float) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = false +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> false +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where tgcol3 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step6 +sql select * from $mt where ts > now + 4m and tgcol1 = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> false and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step9 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 and tgcol1 = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 and tgcol1 <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 and tgcol1 = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 and tgcol1 <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 and tgcol1 = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 and tgcol1 <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol1 <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> false +if $rows != 5 then + return -1 +endi + +print =============== step10 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol1 = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol1 <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol1 = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol1 <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol1 = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol1 <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol1 <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> false +if $rows != 5 then + return -1 +endi + +print =============== step11 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step12 +sql select * from $mt where ts > now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step13 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step14 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step15 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = true +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = true and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step16 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step17 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step18 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = true group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = true and tgcol2 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step19 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/4.sim b/tests/script/windows/tag/4.sim new file mode 100644 index 0000000000000000000000000000000000000000..17552010b0382db3e9cc7e0bafdecdefff03dd96 --- /dev/null +++ b/tests/script/windows/tag/4.sim @@ -0,0 +1,711 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = ta_4_db +$tbPrefix = ta_4_tb +$mtPrefix = ta_4_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 bigint, tgcol3 float, tgcol4 double) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0, 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1, 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where tgcol3 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step6 +sql select * from $mt where tgcol4 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > now + 4m and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step9 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step10 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step11 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step12 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step13 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step14 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step15 +sql select * from $mt where ts > now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step16 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step17 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step18 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step19 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step20 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step21 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step22 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step23 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step24 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 interval(1d) group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/5.sim b/tests/script/windows/tag/5.sim new file mode 100644 index 0000000000000000000000000000000000000000..f06d78e7b5b4082699349e12ee99c96e110fa91b --- /dev/null +++ b/tests/script/windows/tag/5.sim @@ -0,0 +1,834 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = ta_5_db +$tbPrefix = ta_5_tb +$mtPrefix = ta_5_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 tinyint, tgcol2 int, tgcol3 bigint, tgcol4 double, tgcol5 binary(20)) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0, 0, 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1, 1, 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where tgcol3 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step6 +sql select * from $mt where tgcol4 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step7 +sql select * from $mt where tgcol5 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol5 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol5 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol5 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step8 +sql select * from $mt where ts > now + 4m and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step9 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step10 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step11 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step12 +sql select * from $mt where ts > now + 4m and tgcol5 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol5 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step13 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step14 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step15 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step16 +sql select * from $mt where ts > now + 4m and tgcol5 = 1 and tgcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 1 and tgcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol5 <> 0 and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 0 and ts < now + 5m and ts < now + 5m and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step17 +sql select * from $mt where ts > now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step18 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step19 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step20 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 and tgcol5 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 and tgcol5 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step21 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step22 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step23 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step24 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol5 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step25 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step26 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step27 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 interval(1d) group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 interval(1d) group by tgcol5 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/6.sim b/tests/script/windows/tag/6.sim new file mode 100644 index 0000000000000000000000000000000000000000..64cb9df6f030d4c0314d533fb6239daf7ba3586e --- /dev/null +++ b/tests/script/windows/tag/6.sim @@ -0,0 +1,989 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = ta_6_db +$tbPrefix = ta_6_tb +$mtPrefix = ta_6_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 bigint, tgcol3 smallint, tgcol4 bigint, tgcol5 binary(30), tgcol6 binary(20)) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '0', 0, 0, 0, '0', '0' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '1', 1, 1, 1, '1', '1' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where tgcol3 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step6 +sql select * from $mt where tgcol4 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step7 +sql select * from $mt where tgcol5 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol5 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol5 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol5 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step8 +sql select * from $mt where tgcol6 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol6 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol6 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol6 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step9 +sql select * from $mt where ts > now + 4m and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step10 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step11 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step12 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step13 +sql select * from $mt where ts > now + 4m and tgcol5 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol5 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step14 +sql select * from $mt where ts > now + 4m and tgcol6 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol6 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol6 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol6 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step15 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step16 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step17 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step18 +sql select * from $mt where ts > now + 4m and tgcol5 = 1 and tgcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 1 and tgcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol5 <> 0 and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 0 and ts < now + 5m and ts < now + 5m and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step19 +sql select * from $mt where ts > now + 4m and tgcol5 = 1 and tgcol6 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 1 and tgcol6 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 = 0 and tgcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 <> 0 and tgcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 = 0 and tgcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 <> 0 and tgcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol5 <> 0 and tgcol6 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 0 and ts < now + 5m and ts < now + 5m and tgcol6 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step20 +sql select * from $mt where ts > now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step21 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step22 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step23 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 and tgcol5 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 and tgcol5 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step24 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 and tgcol5 = 1 and tgcol6 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 and tgcol5 <> 1 and tgcol6 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 and tgcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and tgcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 and tgcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and tgcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and tgcol6 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and tgcol6 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step25 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step26 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step27 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step28 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol5 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol6 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step29 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step30 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step31 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 interval(1d) group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 interval(1d) group by tgcol5 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 interval(1d) group by tgcol6 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/add.sim b/tests/script/windows/tag/add.sim new file mode 100644 index 0000000000000000000000000000000000000000..02d027ccf4e43c472a1d8b60daa99d254b2df35c --- /dev/null +++ b/tests/script/windows/tag/add.sim @@ -0,0 +1,854 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = ta_ad_db +$tbPrefix = ta_ad_tb +$mtPrefix = ta_ad_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i + +sql create database $db +sql use $db + +print =============== step2 +$i = 2 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt add tag tgcol4 int +sql reset query cache +sql alter table $tb set tag tgcol4 =4 +sql reset query cache + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step2 + return -1 +step2: + +print =============== step3 +$i = 3 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt add tag tgcol4 tinyint +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql reset query cache + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step3 + return -1 +step3: + +print =============== step4 +$i = 4 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.00000 then + return -1 +endi + +sql describe $tb +print sql describe $tb +if $data21 != BIGINT then + return -1 +endi +if $data31 != FLOAT then + return -1 +endi +if $data23 != TAG then + return -1 +endi +if $data33 != TAG then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt add tag tgcol4 float +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql reset query cache + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4.00000 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step4 + return -1 +step4: + +print =============== step5 +$i = 5 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10)) +sql create table $tb using $mt tags( 1, '2' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = '2' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt add tag tgcol4 smallint +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql reset query cache + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol3 = '1' -x step5 + return -1 +step5: + +print =============== step6 +$i = 6 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 tinyint) +sql create table $tb using $mt tags( 1, 2, 3 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt add tag tgcol5 binary(10) +sql alter table $mt add tag tgcol6 binary(10) + +sql reset query cache +sql alter table $tb set tag tgcol4=false +sql alter table $tb set tag tgcol5=5 +sql alter table $tb set tag tgcol6=6 +sql reset query cache + +sql select * from $mt where tgcol5 = '5' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 6 then + return -1 +endi + +sql select * from $mt where tgcol6 = '6' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 6 then + return -1 +endi + +sql select * from $mt where tgcol4 = 1 +if $rows != 0 then + return -1 +endi +sql select * from $mt where tgcol3 = 1 -x step52 + return -1 +step52: + +print =============== step7 +$i = 7 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint, tgcol3 binary(10)) +sql create table $tb using $mt tags( 1, 2, '3' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol3 = '3' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt add tag tgcol5 bigint +sql alter table $mt add tag tgcol6 tinyint + +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql alter table $tb set tag tgcol5=5 +sql alter table $tb set tag tgcol6=6 +sql reset query cache + +sql select * from $mt where tgcol6 = 6 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 6 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step71 + return -1 +step71: +sql select * from $mt where tgcol3 = 1 -x step72 + return -1 +step72: + +print =============== step8 +$i = 8 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float, tgcol3 binary(10)) +sql create table $tb using $mt tags( 1, 2, '3' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol3 = '3' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.00000 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt add tag tgcol5 binary(17) +sql alter table $mt add tag tgcol6 bool +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql alter table $tb set tag tgcol5=5 +sql alter table $tb set tag tgcol6=1 +sql reset query cache + +sql select * from $mt where tgcol5 = '5' +print select * from $mt where tgcol5 = 5 +print $data01 $data02 $data03 $data04 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 1 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step81 + return -1 +step81: +sql select * from $mt where tgcol3 = 1 -x step82 + return -1 +step82: + +print =============== step9 +$i = 9 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10), tgcol3 binary(10)) +sql create table $tb using $mt tags( 1, 2, '3' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = '2' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt add tag tgcol5 bool +sql alter table $mt add tag tgcol6 float + +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql alter table $tb set tag tgcol5=1 +sql alter table $tb set tag tgcol6=6 +sql reset query cache + +sql select * from $mt where tgcol5 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 4.000000000 then + return -1 +endi +if $data03 != 1 then + return -1 +endi +if $data04 != 6.00000 then + return -1 +endi + +sql select * from $mt where tgcol3 = 1 -x step91 + return -1 +step91: +sql select * from $mt where tgcol2 = 1 -x step92 + return -1 +step92: + +print =============== step10 +$i = 10 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10)) +sql create table $tb using $mt tags( '1', '2', '3', '4' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol4 = '4' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 -x step103 + return -1 +step103: + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol4 +sql reset query cache +sql alter table $mt add tag tgcol4 binary(10) +sql alter table $mt add tag tgcol5 bool + +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql alter table $tb set tag tgcol5=false +sql reset query cache + +sql select * from $mt where tgcol4 = '4' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4 then + return -1 +endi +if $data04 != 0 then + return -1 +endi +if $data05 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step101 + return -1 +step101: +sql select * from $mt where tgcol3 = 1 -x step102 + return -1 +step102: + +print =============== step11 +$i = 11 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 smallint, tgcol4 float, tgcol5 binary(10)) +sql create table $tb using $mt tags( 1, 2, 3, 4, '5' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4.00000 then + return -1 +endi +if $data06 != 5 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 -x step114 + return -1 +step114: + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol4 +sql alter table $mt drop tag tgcol5 +sql reset query cache +sql alter table $mt add tag tgcol4 binary(10) +sql alter table $mt add tag tgcol5 int +sql alter table $mt add tag tgcol6 binary(10) +sql alter table $mt add tag tgcol7 bigint +sql alter table $mt add tag tgcol8 smallint + +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql alter table $tb set tag tgcol5=5 +sql alter table $tb set tag tgcol6=6 +sql alter table $tb set tag tgcol7=7 +sql alter table $tb set tag tgcol8=8 +sql reset query cache + +sql select * from $mt where tgcol5 =5 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4 then + return -1 +endi +if $data04 != 5 then + return -1 +endi +if $data05 != 6 then + return -1 +endi +if $data06 != 7 then + return -1 +endi +if $data07 != 8 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step111 + return -1 +step111: +sql select * from $mt where tgcol3 = 1 -x step112 + return -1 +step112: +sql select * from $mt where tgcol9 = 1 -x step113 + return -1 +step113: + +print =============== step12 +$i = 12 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 smallint, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 binary(20)) +sql create table $tb using $mt tags( 1, 2, 3, 4, '5', '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3.00000 then + return -1 +endi +if $data05 != 4.000000000 then + return -1 +endi +if $data06 != 5 then + return -1 +endi +if $data07 != 6 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol4 +sql alter table $mt drop tag tgcol5 +sql reset query cache +sql alter table $mt add tag tgcol2 binary(10) +sql alter table $mt add tag tgcol3 int +sql alter table $mt add tag tgcol4 binary(10) +sql alter table $mt add tag tgcol5 bigint + +sql reset query cache +sql alter table $tb set tag tgcol1=false +sql alter table $tb set tag tgcol2=5 +sql alter table $tb set tag tgcol3=4 +sql alter table $tb set tag tgcol4=3 +sql alter table $tb set tag tgcol5=2 +sql alter table $tb set tag tgcol6=1 +sql reset query cache + +sql select * from $mt where tgcol4 = '3' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 1 then + return -1 +endi +if $data04 != 5 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 3 then + return -1 +endi +if $data07 != 2 then + return -1 +endi + +sql select * from $mt where tgcol2 = '5' +if $rows != 1 then + return -1 +endi + +sql select * from $mt where tgcol3 = 4 +if $rows != 1 then + return -1 +endi + +sql select * from $mt where tgcol5 = 2 +if $rows != 1 then + return -1 +endi + +sql select * from $mt where tgcol6 = '1' +if $rows != 1 then + return -1 +endi + +print =============== step13 +$i = 13 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20)) +sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = '1' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 5.000000000 then + return -1 +endi +if $data07 != 6 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol4 +sql alter table $mt drop tag tgcol6 +sql reset query cache +sql alter table $mt add tag tgcol2 binary(10) +sql alter table $mt add tag tgcol4 int +sql alter table $mt add tag tgcol6 bigint + +sql reset query cache +sql alter table $tb set tag tgcol1=7 +sql alter table $tb set tag tgcol2=8 +sql alter table $tb set tag tgcol3=9 +sql alter table $tb set tag tgcol4=10 +sql alter table $tb set tag tgcol5=11 +sql alter table $tb set tag tgcol6=12 +sql reset query cache + +sql select * from $mt where tgcol2 = '8' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 7 then + return -1 +endi +if $data03 != 9 then + return -1 +endi +if $data04 != 11.000000000 then + return -1 +endi +if $data05 != 8 then + return -1 +endi +if $data06 != 10 then + return -1 +endi +if $data07 != 12 then + return -1 +endi + +print =============== step14 +$i = 14 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 bigint) +sql create table $tb using $mt tags( 1, 1 ) +sql insert into $tb values(now, 1) + +sql alter table $mt add tag tgcol3 binary(10) +sql alter table $mt add tag tgcol4 int +sql alter table $mt add tag tgcol5 bigint +sql alter table $mt add tag tgcol6 bigint + +return +sql alter table $mt add tag tgcol7 bigint -x step141 + return -1 +step141: +sql reset query cache +sql alter table $mt drop tag tgcol6 +sql alter table $mt add tag tgcol7 bigint +sql alter table $mt add tag tgcol8 bigint -x step142 + return -1 +step142: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/bigint.sim b/tests/script/windows/tag/bigint.sim new file mode 100644 index 0000000000000000000000000000000000000000..ebb67d452c82586d31f673d7c9c5c78249285795 --- /dev/null +++ b/tests/script/windows/tag/bigint.sim @@ -0,0 +1,241 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = ta_bi_db +$tbPrefix = ta_bi_tb +$mtPrefix = ta_bi_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bigint) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sleep 100 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi +sql select * from $tb where ts < now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts <= now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts > now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts >= now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 5m +if $rows != 1 then + return -1 +endi +sql select * from $tb where ts < now + 4m and ts > now + 5m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > 100000 and ts < 100000 +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 3m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/binary.sim b/tests/script/windows/tag/binary.sim new file mode 100644 index 0000000000000000000000000000000000000000..c59039b6a6d8ba5d05a653c1f5d40de170e89f15 --- /dev/null +++ b/tests/script/windows/tag/binary.sim @@ -0,0 +1,241 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = ta_by_db +$tbPrefix = ta_by_tb +$mtPrefix = ta_by_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(10)) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '0' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '1' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sleep 100 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi +sql select * from $tb where ts < now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts <= now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts > now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts >= now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 5m +if $rows != 1 then + return -1 +endi +sql select * from $tb where ts < now + 4m and ts > now + 5m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > 100000 and ts < 100000 +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 3m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol = '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> '0' +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> '0' +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> '0' and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/binary_binary.sim b/tests/script/windows/tag/binary_binary.sim new file mode 100644 index 0000000000000000000000000000000000000000..361a6edb8b3f6d9440a1796bed5ca7c431bcf115 --- /dev/null +++ b/tests/script/windows/tag/binary_binary.sim @@ -0,0 +1,308 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = ta_bib_db +$tbPrefix = ta_bib_tb +$mtPrefix = ta_bib_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(5), tgcol2 binary(5)) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '0', '0' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '1', '1' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol = '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> '0' +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 = '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> '1' +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> '0' +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> '0' and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select * from $mt where ts > now + 4m and tgcol2 = '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> '0' +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > now + 4m and tgcol2 = '1' and tgcol = '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '1' and tgcol <> '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = '0' and tgcol = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> '0' and tgcol <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = '0' and tgcol = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' and tgcol <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> '0' and tgcol <> '0' +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and ts < now + 5m and ts < now + 5m and tgcol <> '0' +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' and tgcol2 = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' and tgcol2 = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + + +print =============== step13 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step14 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/bool.sim b/tests/script/windows/tag/bool.sim new file mode 100644 index 0000000000000000000000000000000000000000..adf12338d089c41fea9e23b65b8dee03f8eb5b46 --- /dev/null +++ b/tests/script/windows/tag/bool.sim @@ -0,0 +1,238 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = ta_bo_db +$tbPrefix = ta_bo_tb +$mtPrefix = ta_bo_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sleep 100 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi +sql select * from $tb where ts < now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts <= now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts > now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts >= now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 5m +if $rows != 1 then + return -1 +endi +sql select * from $tb where ts < now + 4m and ts > now + 5m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 3m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = false +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> false +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> false and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/bool_binary.sim b/tests/script/windows/tag/bool_binary.sim new file mode 100644 index 0000000000000000000000000000000000000000..064677ee407ee9851e45ea3c743b5d95c66e8545 --- /dev/null +++ b/tests/script/windows/tag/bool_binary.sim @@ -0,0 +1,308 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = ta_bob_db +$tbPrefix = ta_bob_tb +$mtPrefix = ta_bob_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 binary(5)) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, '0' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, '1' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = false +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> false +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 = '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> '1' +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> false and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select * from $mt where ts > now + 4m and tgcol2 = '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> '0' +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > now + 4m and tgcol2 = '1' and tgcol = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '1' and tgcol <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = '0' and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> '0' and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = '0' and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> '0' and tgcol <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and ts < now + 5m and ts < now + 5m and tgcol <> false +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true and tgcol2 = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true and tgcol2 = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + + +print =============== step13 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step14 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/bool_int.sim b/tests/script/windows/tag/bool_int.sim new file mode 100644 index 0000000000000000000000000000000000000000..ef5cd27553161345e95d1ca1b0f414ed16394cb1 --- /dev/null +++ b/tests/script/windows/tag/bool_int.sim @@ -0,0 +1,324 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = ta_boi_db +$tbPrefix = ta_boi_tb +$mtPrefix = ta_boi_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 int) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = false +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> false +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = false +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> false +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> false and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 and tgcol = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 and tgcol <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol <> false +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true and tgcol2 = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + + +print =============== step13 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step14 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/change.sim b/tests/script/windows/tag/change.sim new file mode 100644 index 0000000000000000000000000000000000000000..4126ea1181e8b554cac2833eb66c27f3d4290071 --- /dev/null +++ b/tests/script/windows/tag/change.sim @@ -0,0 +1,513 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = ta_ch_db +$tbPrefix = ta_ch_tb +$mtPrefix = ta_ch_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i + +sql create database $db +sql use $db + +print =============== step2 +$i = 2 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt change tag tagcx tgcol3 -x step21 + return -1 +step21: +sql alter table $mt change tag tgcol1 tgcol2 -x step22 + return -1 +step22: +#sql alter table $mt change tag tgcol1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -x step20 +# return -1 +#step20: + +sql alter table $mt change tag tgcol1 tgcol3 +sql alter table $mt change tag tgcol2 tgcol4 +sql alter table $mt change tag tgcol4 tgcol3 -x step23 + return -1 +step23: + +print =============== step3 +$i = 3 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol3 +sql alter table $mt change tag tgcol2 tgcol4 + +print =============== step4 +$i = 4 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.00000 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol3 +sql alter table $mt change tag tgcol2 tgcol4 + +print =============== step5 +$i = 5 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10)) +sql create table $tb using $mt tags( 1, '2' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = '2' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol3 +sql alter table $mt change tag tgcol2 tgcol4 + +print =============== step6 +$i = 6 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20)) +sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = '1' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 5.000000000 then + return -1 +endi +if $data07 != 6 then + return -1 +endi + +sql alter table $mt drop tag tgcol3 +sql reset query cache +sql alter table $mt change tag tgcol4 tgcol3 +sql alter table $mt change tag tgcol1 tgcol7 +sql alter table $mt change tag tgcol2 tgcol8 +sql reset query cache +sql alter table $mt change tag tgcol3 tgcol9 +sql alter table $mt change tag tgcol5 tgcol10 +sql alter table $mt change tag tgcol6 tgcol11 + +sleep 3000 +sql reset query cache + +print =============== step2 +$i = 2 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 -x step24 + return -1 +step24: +sql select * from $mt where tgcol2 = 1 -x step25 + return -1 +step25: + +sql select * from $mt where tgcol3 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql select * from $mt where tgcol4 = 2 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +print =============== step3 +$i = 3 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 -x step31 + return -1 +step31: +sql select * from $mt where tgcol2 = 1 -x step32 + return -1 +step32: + +sql select * from $mt where tgcol3 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql select * from $mt where tgcol4 = 2 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +print =============== step4 +$i = 4 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 -x step41 + return -1 +step41: +sql select * from $mt where tgcol2 = 1 -x step42 + return -1 +step42: + +sql select * from $mt where tgcol3 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.00000 then + return -1 +endi + +sql select * from $mt where tgcol4 = 2 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.00000 then + return -1 +endi + +print =============== step5 +$i = 5 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 -x step51 + return -1 +step51: +sql select * from $mt where tgcol2 = 1 -x step52 + return -1 +step52: + +sql select * from $mt where tgcol3 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql select * from $mt where tgcol4 = '2' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +print =============== step6 +$i = 6 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 -x step61 + return -1 +step61: +sql select * from $mt where tgcol2 = 1 -x step62 + return -1 +step62: +sql select * from $mt where tgcol3 = 1 -x step63 + return -1 +step63: +sql select * from $mt where tgcol4 = 1 -x step64 + return -1 +step64: +sql select * from $mt where tgcol5 = 1 -x step65 + return -1 +step65: +sql select * from $mt where tgcol6 = 1 -x step66 + return -1 +step66: + +sql select * from $mt where tgcol7 = '1' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 4 then + return -1 +endi +if $data05 != 5.000000000 then + return -1 +endi +if $data06 != 6 then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol8 = 2 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 4 then + return -1 +endi +if $data05 != 5.000000000 then + return -1 +endi +if $data06 != 6 then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol9 = '4' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 4 then + return -1 +endi +if $data05 != 5.000000000 then + return -1 +endi +if $data06 != 6 then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol10 = 5 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 4 then + return -1 +endi +if $data05 != 5.000000000 then + return -1 +endi +if $data06 != 6 then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol11 = '6' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 4 then + return -1 +endi +if $data05 != 5.000000000 then + return -1 +endi +if $data06 != 6 then + return -1 +endi +if $data07 != null then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/windows/tag/column.sim b/tests/script/windows/tag/column.sim new file mode 100644 index 0000000000000000000000000000000000000000..40159bcae347e1292e2c327110bc4db6b7176bbb --- /dev/null +++ b/tests/script/windows/tag/column.sim @@ -0,0 +1,93 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = ta_co_db +$tbPrefix = ta_co_tb +$mtPrefix = ta_co_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db + +$i = 0 +sql create table $mt (ts timestamp, tbcol int, tbcol2 binary(10)) TAGS(tgcol int, tgcol2 binary(10)) + +print =============== step2 + +$i = 0 +$tb = $tbPrefix . $i +sql create table $tb using $mt tags( 0, '0' ) + +$i = 1 +$tb = $tbPrefix . $i +sql create table $tb using $mt tags( 1, 1 ) + +$i = 2 +$tb = $tbPrefix . $i +sql create table $tb using $mt tags( '2', '2' ) + +$i = 3 +$tb = $tbPrefix . $i +sql create table $tb using $mt tags( '3', 3 ) + +sql show tables +if $rows != 4 then + return -1 +endi + +print =============== step3 + +$i = 0 +$tb = $tbPrefix . $i +sql insert into $tb values(now, 0, '0') + +$i = 1 +$tb = $tbPrefix . $i +sql insert into $tb values(now, 1, 1 ) + +$i = 2 +$tb = $tbPrefix . $i +sql insert into $tb values(now, '2', '2') + +$i = 3 +$tb = $tbPrefix . $i +sql insert into $tb values(now, '3', 3) + +print =============== step4 +sql select * from $mt where tgcol2 = '1' +if $rows != 1 then + return -1 +endi + +print =============== step5 +sql select * from $mt +if $rows != 4 then + return -1 +endi + +sql select * from $mt where tgcol = 1 +if $rows != 1 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/create.sim b/tests/script/windows/tag/create.sim new file mode 100644 index 0000000000000000000000000000000000000000..62dc8a7a21c442b0a38fd067da0d55ad5c8ed8ef --- /dev/null +++ b/tests/script/windows/tag/create.sim @@ -0,0 +1,601 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = ta_cr_db +$tbPrefix = ta_cr_tb +$mtPrefix = ta_cr_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i + +sql create database $db +sql use $db + +print =============== step2 +$i = 2 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool) +sql create table $tb using $mt tags( 1 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 0 then + return -1 +endi + +print =============== step3 +$i = 3 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol smallint) +sql create table $tb using $mt tags( 1 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 0 then + return -1 +endi + +print =============== step4 +$i = 4 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol tinyint) +sql create table $tb using $mt tags( 1 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 0 then + return -1 +endi + +print =============== step5 +$i = 5 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) +sql create table $tb using $mt tags( 1 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 0 then + return -1 +endi + +print =============== step6 +$i = 6 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bigint) +sql create table $tb using $mt tags( 1 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 0 then + return -1 +endi + +print =============== step7 +$i = 7 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol float) +sql create table $tb using $mt tags( 1 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 0 then + print expect 0, actual: $rows + return -1 +endi + +print =============== step8 +$i = 8 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol double) +sql create table $tb using $mt tags( 1 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 0 then + return -1 +endi + +print =============== step9 +$i = 9 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(10)) +sql create table $tb using $mt tags( '1') +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = '1' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol = '0' +if $rows != 0 then + return -1 +endi + +print =============== step10 +$i = 10 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 bool) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + print expect 1, actual: $rows + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step11 +$i = 11 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 smallint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step12 +$i = 12 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 tinyint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step13 +$i = 13 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 int) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step14 +$i = 14 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 bigint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi +print =============== step15 +$i = 15 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 float) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step16 +$i = 16 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 double) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step17 +$i = 17 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 binary(10)) +sql create table $tb using $mt tags( 1, '2' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = true +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step18 +$i = 18 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol smallint, tgcol2 tinyint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step19 +$i = 19 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol tinyint, tgcol2 int) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step20 +$i = 20 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int, tgcol2 bigint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step21 +$i = 21 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bigint, tgcol2 float) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step22 +$i = 22 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol float, tgcol2 double) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step23 +$i = 23 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol double, tgcol2 binary(10)) +sql create table $tb using $mt tags( 1, '2' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = '2' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step24 +$i = 24 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 bool, tgcol3 int, tgcol4 float, tgcol5 double, tgcol6 binary(10)) +sql create table $tb using $mt tags( 1, 2, 3, 4, 5, '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol3 = 3 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol4 = 4 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol5 = 5 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol6 = '6' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol6 = '0' +if $rows != 0 then + return -1 +endi + +print =============== step25 +$i = 25 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 int, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 binary(10)) +sql create table $tb using $mt tags( 1, 2, 3, 4, '5', '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol6 = '6' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol6 = '0' +if $rows != 0 then + return -1 +endi + +print =============== step26 +$i = 26 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10), tgcol5 binary(10), tgcol6 binary(10)) +sql create table $tb using $mt tags( '1', '2', '3', '4', '5', '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol3 = '3' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol3 = '0' +if $rows != 0 then + return -1 +endi + +print =============== step27 +$i = 27 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 bool, tgcol3 int, tgcol4 float, tgcol5 double, tgcol6 binary(10), tgcol7) -x step27 + return -1 +step27: + +print =============== step28 +$i = 28 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(250), tgcol2 binary(250)) +sql create table $tb using $mt tags('1', '1') +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = '1' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +print =============== step29 +$i = 29 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(25), tgcol2 binary(250)) +sql create table $tb using $mt tags('1', '1') +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = '1' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +print =============== step30 +$i = 30 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(250), tgcol2 binary(250), tgcol3 binary(30)) -x step30 +# return -1 +step30: + +print =============== step31 +$i = 31 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(5)) +sql_error create table $tb using $mt tags('1234567') +sql create table $tb using $mt tags('12345') +sql insert into $tb values(now, 1) +sql select * from $mt +print sql select * from $mt +if $rows != 1 then + return -1 +endi + +print $data00 $data01 $data02 +if $data02 != 12345 then + return -1 +endi diff --git a/tests/script/windows/tag/delete.sim b/tests/script/windows/tag/delete.sim new file mode 100644 index 0000000000000000000000000000000000000000..2b503fdf47ac2eaa5ea18c8c6af1bbbe05e9c44c --- /dev/null +++ b/tests/script/windows/tag/delete.sim @@ -0,0 +1,825 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = ta_de_db +$tbPrefix = ta_de_tb +$mtPrefix = ta_de_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i + +sql create database $db +sql use $db + +print =============== step2 +$i = 2 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 + +print =============== step3 +$i = 3 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 + +print =============== step4 +$i = 4 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 < 3 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.00000 then + return -1 +endi + +sql describe $tb +if $data21 != BIGINT then + return -1 +endi +if $data31 != FLOAT then + return -1 +endi +if $data23 != TAG then + return -1 +endi + +sql alter table $mt drop tag tgcol1 -x step40 + return -1 +step40: +sql alter table $mt drop tag tgcol2 + +print =============== step5 +$i = 5 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10)) +sql create table $tb using $mt tags( 1, '2' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = '2' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt drop tag tgcol1 -x step50 + return -1 +step50: +sql alter table $mt drop tag tgcol2 + +print =============== step6 +$i = 6 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 tinyint) +sql create table $tb using $mt tags( 1, 2, 3 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 + +print =============== step7 +$i = 7 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint, tgcol3 binary(10)) +sql create table $tb using $mt tags( 1, 2, '3' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol3 = '3' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql describe $tb +if $data21 != SMALLINT then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data41 != BINARY then + return -1 +endi +if $data22 != 2 then + return -1 +endi +if $data32 != 1 then + return -1 +endi +if $data42 != 10 then + return -1 +endi +if $data23 != TAG then + return -1 +endi +if $data33 != TAG then + return -1 +endi +if $data43 != TAG then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 + +print =============== step8 +$i = 8 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float, tgcol3 binary(10)) +sql create table $tb using $mt tags( 1, 2, '3' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol3 = '3' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.00000 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 + +print =============== step9 +$i = 9 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10), tgcol3 binary(10)) +sql create table $tb using $mt tags( 1, '2', '3' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol2 + +print =============== step10 +$i = 10 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10)) +sql create table $tb using $mt tags( '1', '2', '3', '4' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol4 = '4' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4 then + return -1 +endi + +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol4 + +print =============== step11 +$i = 11 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 smallint, tgcol4 float, tgcol5 binary(10)) +sql create table $tb using $mt tags( 1, 2, 3, 4, '5' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4.00000 then + return -1 +endi +if $data06 != 5 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol5 + +print =============== step12 +$i = 12 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 smallint, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 binary(20)) +sql create table $tb using $mt tags( 1, 2, 3, 4, '5', '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3.00000 then + return -1 +endi +if $data05 != 4.000000000 then + return -1 +endi +if $data06 != 5 then + return -1 +endi +if $data07 != 6 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol5 +sql alter table $mt drop tag tgcol6 + +print =============== step13 +$i = 13 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20)) +sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = '1' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 5.000000000 then + return -1 +endi +if $data07 != 6 then + return -1 +endi + +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol4 +sql alter table $mt drop tag tgcol6 + +sleep 3000 + +print =============== step2 +$i = 2 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step2 + return -1 +step2: + +print =============== step3 +$i = 3 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step3 + return -1 +step3: + +print =============== step4 +$i = 4 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step4 + return -1 +step4: + +print =============== step5 +$i = 5 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = '1' -x step5 + return -1 +step5: + +print =============== step6 +$i = 6 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data04 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step51 + return -1 +step51: +sql select * from $mt where tgcol3 = 1 -x step52 + return -1 +step52: + +print =============== step7 +$i = 7 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data04 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step71 + return -1 +step71: +sql select * from $mt where tgcol3 = 1 -x step72 + return -1 +step72: + +print =============== step8 +$i = 8 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data04 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step81 + return -1 +step81: +sql select * from $mt where tgcol3 = 1 -x step82 + return -1 +step82: + +print =============== step9 +$i = 9 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data04 != null then + return -1 +endi + +sql select * from $mt where tgcol3 = 1 -x step91 + return -1 +step91: +sql select * from $mt where tgcol2 = 1 -x step92 + return -1 +step92: + +print =============== step10 +$i = 10 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = '1' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data04 != null then + return -1 +endi +if $data05 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step101 + return -1 +step101: +sql select * from $mt where tgcol3 = 1 -x step102 + return -1 +step102: +sql select * from $mt where tgcol4 = 1 -x step103 + return -1 +step103: + +print =============== step11 +$i = 11 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol4=4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4.00000 then + return -1 +endi +if $data04 != null then + return -1 +endi +if $data05 != null then + return -1 +endi +if $data06 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step111 + return -1 +step111: +sql select * from $mt where tgcol3 = 1 -x step112 + return -1 +step112: +sql select * from $mt where tgcol5 = 1 -x step113 + return -1 +step113: + +print =============== step12 +$i = 12 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4.000000000 then + return -1 +endi +if $data04 != null then + return -1 +endi +if $data05 != null then + return -1 +endi +if $data06 != null then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step120 + return -1 +step120: +sql select * from $mt where tgcol3 = 1 -x step121 + return -1 +step121: +sql select * from $mt where tgcol5 = 1 -x step122 + return -1 +step122: +sql select * from $mt where tgcol6 = 1 -x step123 + return -1 +step123: + +print =============== step13 +$i = 13 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql reset query cache +sql select * from $mt where tgcol2 = 2 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 5.000000000 then + return -1 +endi +if $data05 != null then + return -1 +endi +if $data06 != null then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol3 = 1 -x step130 + return -1 +step130: +sql select * from $mt where tgcol4 = 1 -x step131 + return -1 +step131: +sql select * from $mt where tgcol6 = 1 -x step133 + return -1 +step133: + +print =============== step14 +$i = 14 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 bigint) +sql create table $tb using $mt tags( 1, 1 ) +sql insert into $tb values(now, 1) + +sql alter table xxmt drop tag tag1 -x step141 + return -1 +step141: +sql alter table $tb drop tag tag1 -x step142 + return -1 +step142: +sql alter table $mt drop tag tag1 -x step143 + return -1 +step143: + +sql alter table $mt drop tag tagcol1 -x step144 + return -1 +step144: + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol1 -x step145 + return -1 +step145: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/double.sim b/tests/script/windows/tag/double.sim new file mode 100644 index 0000000000000000000000000000000000000000..4381aa20f939d79ac81804a5be54952db7a27ba4 --- /dev/null +++ b/tests/script/windows/tag/double.sim @@ -0,0 +1,241 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = ta_do_db +$tbPrefix = ta_do_tb +$mtPrefix = ta_do_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol double) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sleep 100 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi +sql select * from $tb where ts < now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts <= now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts > now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts >= now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 5m +if $rows != 1 then + return -1 +endi +sql select * from $tb where ts < now + 4m and ts > now + 5m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > 100000 and ts < 100000 +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 3m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/filter.sim b/tests/script/windows/tag/filter.sim new file mode 100644 index 0000000000000000000000000000000000000000..802e9a312f8cccbc34bb537dbba5ec3ab13b11d5 --- /dev/null +++ b/tests/script/windows/tag/filter.sim @@ -0,0 +1,149 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = ta_fi_db +$tbPrefix = ta_fi_tb +$mtPrefix = ta_fi_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(10)) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '0' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '1' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tg = '1' -x step2 + return -1 +step2: + +print =============== step3 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where noexist = '1' -x step3 + return -1 +step3: + +print =============== step4 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = '1' +if $rows != 1 then + return -1 +endi +if $data00 != 10 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(cc), sum(xx), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt -x step6 + return -1 +step6: + +print =============== step7 +sql select count(tgcol), avg(tgcol), sum(tgcol), min(tgcol), max(tgcol), first(tgcol), last(tgcol) from $mt -x step7 + return -1 +step7: + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tbcol + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by noexist -x step9 + return -1 +step9: + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol) as c from $mt group by tbcol + +print =============== step12 +sql select count(tbcol) as c from $mt group by noexist -x step12 + return -1 +step12: + +print =============== step13 +sql select count(tbcol) as c from $mt group by tgcol +print $data00 +if $data00 != 100 then + return -1 +endi + +print =============== step14 +sql select count(tbcol) as c from $mt where ts > 1000 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + print expect 100, actual $data00 + return -1 +endi + +print =============== step15 +sql select count(tbcol) as c from $mt where noexist < 1 group by tgcol -x step15 + return -1 +step15: + +print =============== step16 +sql select count(tbcol) as c from $mt where tgcol = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/float.sim b/tests/script/windows/tag/float.sim new file mode 100644 index 0000000000000000000000000000000000000000..8df44c24a56d8c013af7c63aa9d45b720069cbaa --- /dev/null +++ b/tests/script/windows/tag/float.sim @@ -0,0 +1,241 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = ta_fl_db +$tbPrefix = ta_fl_tb +$mtPrefix = ta_fl_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol float) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sleep 100 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi +sql select * from $tb where ts < now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts <= now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts > now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts >= now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 5m +if $rows != 1 then + return -1 +endi +sql select * from $tb where ts < now + 4m and ts > now + 5m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > 100000 and ts < 100000 +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 3m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/int.sim b/tests/script/windows/tag/int.sim new file mode 100644 index 0000000000000000000000000000000000000000..dbff8c15b6aad716a1c90ad5c74269f955c7307d --- /dev/null +++ b/tests/script/windows/tag/int.sim @@ -0,0 +1,241 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = ta_in_db +$tbPrefix = ta_in_tb +$mtPrefix = ta_in_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sleep 100 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi +sql select * from $tb where ts < now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts <= now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts > now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts >= now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 5m +if $rows != 1 then + return -1 +endi +sql select * from $tb where ts < now + 4m and ts > now + 5m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > 100000 and ts < 100000 +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 3m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/int_binary.sim b/tests/script/windows/tag/int_binary.sim new file mode 100644 index 0000000000000000000000000000000000000000..94aa9eb7f40441f5cc4e399ac8a4f5f5ce396beb --- /dev/null +++ b/tests/script/windows/tag/int_binary.sim @@ -0,0 +1,308 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = ta_inb_db +$tbPrefix = ta_inb_tb +$mtPrefix = ta_inb_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int, tgcol2 binary(5)) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, '0' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, '1' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 = '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> '1' +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select * from $mt where ts > now + 4m and tgcol2 = '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> '0' +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > now + 4m and tgcol2 = '1' and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '1' and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = '0' and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> '0' and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = '0' and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> '0' and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and ts < now + 5m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 and tgcol2 = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 and tgcol2 = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + + +print =============== step13 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step14 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/int_float.sim b/tests/script/windows/tag/int_float.sim new file mode 100644 index 0000000000000000000000000000000000000000..9789c9ea06640432e8866a787ec0389ed3d239c2 --- /dev/null +++ b/tests/script/windows/tag/int_float.sim @@ -0,0 +1,324 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = ta_inf_db +$tbPrefix = ta_inf_tb +$mtPrefix = ta_inf_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int, tgcol2 float) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 > 0.5 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 < 0.5 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 > 0.5 and tgcol2 < 1.5 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 and tgcol2 = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + + +print =============== step13 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step14 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/set.sim b/tests/script/windows/tag/set.sim new file mode 100644 index 0000000000000000000000000000000000000000..54b87c7d0c1c4eac55a16d42b61979329a31167d --- /dev/null +++ b/tests/script/windows/tag/set.sim @@ -0,0 +1,457 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = ta_se_db +$tbPrefix = ta_se_tb +$mtPrefix = ta_se_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i + +sql create database $db +sql use $db + +print =============== step2 +$i = 2 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $tb set tag tagcx 1 -x step21 + return -1 +step21: +sql alter table $tb set tag tgcol1=false +sql alter table $tb set tag tgcol2=4 + +sql reset query cache + +sql select * from $mt where tgcol1 = false +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol2 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql describe $tb +print $data21 $data23 $data32 $data33 +if $data21 != BOOL then + return -1 +endi +if $data31 != INT then + return -1 +endi +if $data23 != TAG then + return -1 +endi +if $data33 != TAG then + return -1 +endi + +print =============== step3 +$i = 3 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $tb set tag tgcol1=3 +sql alter table $tb set tag tgcol2=4 + +sql reset query cache + +sql select * from $mt where tgcol1 = 3 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 3 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol2 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 3 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol2 = 2 +if $rows != 0 then + return -1 +endi + + +print =============== step4 +$i = 4 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.00000 then + return -1 +endi + +sql alter table $tb set tag tgcol1=3 +sql alter table $tb set tag tgcol2=4 + +sql reset query cache + +sql select * from $mt where tgcol1 = 3 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 3 then + return -1 +endi +if $data03 != 4.00000 then + return -1 +endi + +sql select * from $mt where tgcol2 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 3 then + return -1 +endi +if $data03 != 4.00000 then + return -1 +endi + + +print =============== step5 +$i = 5 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10)) +sql create table $tb using $mt tags( 1, '2' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = '2' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $tb set tag tgcol1=3 +sql alter table $tb set tag tgcol2='4' + +sql reset query cache + +sql select * from $mt where tgcol1 = 3 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 3.000000000 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol2 = '4' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 3.000000000 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +print =============== step6 +$i = 6 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20)) +sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = '1' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 5.000000000 then + return -1 +endi +if $data07 != 6 then + return -1 +endi + +sql alter table $mt drop tag tgcol3 +sql alter table $tb set tag tgcol1='7' +sql alter table $tb set tag tgcol2=8 +sql alter table $tb set tag tgcol4='9' +sql alter table $tb set tag tgcol5=10 +sql alter table $tb set tag tgcol6='11' + +sql reset query cache + +sql select * from $mt where tgcol1 = '7' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 7 then + return -1 +endi +if $data03 != 8 then + return -1 +endi +if $data04 != 9 then + return -1 +endi +if $data05 != 10.000000000 then + return -1 +endi +if $data06 != 11 then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 8 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 7 then + return -1 +endi +if $data03 != 8 then + return -1 +endi +if $data04 != 9 then + return -1 +endi +if $data05 != 10.000000000 then + return -1 +endi +if $data06 != 11 then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol4 = '9' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 7 then + return -1 +endi +if $data03 != 8 then + return -1 +endi +if $data04 != 9 then + return -1 +endi +if $data05 != 10.000000000 then + return -1 +endi +if $data06 != 11 then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol5 = 10 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 7 then + return -1 +endi +if $data03 != 8 then + return -1 +endi +if $data04 != 9 then + return -1 +endi +if $data05 != 10.000000000 then + return -1 +endi +if $data06 != 11 then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol6 = '11' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 7 then + return -1 +endi +if $data03 != 8 then + return -1 +endi +if $data04 != 9 then + return -1 +endi +if $data05 != 10.000000000 then + return -1 +endi +if $data06 != 11 then + return -1 +endi +if $data07 != null then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/smallint.sim b/tests/script/windows/tag/smallint.sim new file mode 100644 index 0000000000000000000000000000000000000000..bc668b164d53309512d69434e021f5744da2a253 --- /dev/null +++ b/tests/script/windows/tag/smallint.sim @@ -0,0 +1,241 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = ta_sm_db +$tbPrefix = ta_sm_tb +$mtPrefix = ta_sm_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol smallint) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sleep 100 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi +sql select * from $tb where ts < now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts <= now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts > now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts >= now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 5m +if $rows != 1 then + return -1 +endi +sql select * from $tb where ts < now + 4m and ts > now + 5m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > 100000 and ts < 100000 +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 3m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/tinyint.sim b/tests/script/windows/tag/tinyint.sim new file mode 100644 index 0000000000000000000000000000000000000000..44fc9ba4dc0d0f4a670c3c03abf36a38f658f878 --- /dev/null +++ b/tests/script/windows/tag/tinyint.sim @@ -0,0 +1,241 @@ +sql connect +sleep 2000 +print ======================== dnode1 start + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = ta_ti_db +$tbPrefix = ta_ti_tb +$mtPrefix = ta_ti_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol tinyint) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sleep 100 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi +sql select * from $tb where ts < now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts <= now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts > now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts >= now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 5m +if $rows != 1 then + return -1 +endi +sql select * from $tb where ts < now + 4m and ts > now + 5m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > 100000 and ts < 100000 +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 3m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/testSuite.sim b/tests/script/windows/testSuite.sim new file mode 100644 index 0000000000000000000000000000000000000000..e372217b620fcf0735e3645fa96872ca11450225 --- /dev/null +++ b/tests/script/windows/testSuite.sim @@ -0,0 +1,93 @@ +run windows/alter/table.sim +run windows/alter/metrics.sim + +run windows/compute/avg.sim +run windows/compute/bottom.sim +run windows/compute/count.sim +run windows/compute/diff.sim +run windows/compute/first.sim +run windows/compute/interval.sim +run windows/compute/last.sim +run windows/compute/leastsquare.sim +run windows/compute/max.sim +run windows/compute/min.sim +run windows/compute/percentile.sim +run windows/compute/stddev.sim +run windows/compute/sum.sim +run windows/compute/top.sim + +run windows/db/basic.sim +run windows/db/len.sim + +run windows/field/2.sim +run windows/field/3.sim +run windows/field/4.sim +run windows/field/5.sim +run windows/field/6.sim +run windows/field/bigint.sim +run windows/field/binary.sim +run windows/field/bool.sim +run windows/field/double.sim +run windows/field/float.sim +run windows/field/int.sim +run windows/field/single.sim +run windows/field/smallint.sim +run windows/field/tinyint.sim + +run windows/import/basic.sim + +run windows/insert/basic.sim +run windows/insert/query_block1_file.sim +run windows/insert/query_block1_memory.sim +run windows/insert/query_block2_file.sim +run windows/insert/query_block2_memory.sim +run windows/insert/query_file_memory.sim +run windows/insert/query_multi_file.sim + +run windows/table/binary.sim +run windows/table/bool.sim +run windows/table/column_num.sim +run windows/table/column_name.sim +run windows/table/column_value.sim +run windows/table/db.table.sim +run windows/table/double.sim +run windows/table/float.sim +run windows/table/table_len.sim +run windows/table/table.sim + +run windows/tag/3.sim +run windows/tag/4.sim +run windows/tag/5.sim +run windows/tag/6.sim +run windows/tag/add.sim +run windows/tag/bigint.sim +run windows/tag/binary_binary.sim +run windows/tag/binary.sim +run windows/tag/bool_binary.sim +run windows/tag/bool_int.sim +run windows/tag/bool.sim +run windows/tag/change.sim +run windows/tag/column.sim +run windows/tag/create.sim +run windows/tag/delete.sim +run windows/tag/double.sim +run windows/tag/filter.sim +run windows/tag/float.sim +run windows/tag/int_binary.sim +run windows/tag/int_float.sim +run windows/tag/int.sim +run windows/tag/set.sim +run windows/tag/smallint.sim +run windows/tag/tinyint.sim + +run windows/vector/metrics_field.sim +run windows/vector/metrics_mix.sim +run windows/vector/metrics_query.sim +run windows/vector/metrics_tag.sim +run windows/vector/metrics_time.sim +run windows/vector/multi.sim +run windows/vector/single.sim +run windows/vector/table_field.sim +run windows/vector/table_mix.sim +run windows/vector/table_query.sim +run windows/vector/table_time.sim diff --git a/tests/script/windows/vector/metrics_field.sim b/tests/script/windows/vector/metrics_field.sim new file mode 100644 index 0000000000000000000000000000000000000000..dfaa7e1d9978357f5858e529ebac40941dd6bf2c --- /dev/null +++ b/tests/script/windows/vector/metrics_field.sim @@ -0,0 +1,622 @@ +sql connect +sleep 2000 + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = m_mf_db +$tbPrefix = m_mf_tb +$mtPrefix = m_mf_mt + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - f from $mt where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - a from $mt where a = 5 +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select b - f from $mt where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - b from $mt where a = 5 +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select c - f from $mt where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select d - f from $mt where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select e - f from $mt where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - f from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $mt where a = 5 -x step21 + return -1 +step21: + +sql select h - f from $mt where a = 5 -x step22 + return -1 +step22: + +sql select ts - f from $mt where a = 5 -x step23 + return -1 +step23: + +sql select a - e from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a + f from $mt where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + a from $mt where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select b + f from $mt where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + b from $mt where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select c + f from $mt where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select d + f from $mt where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select e + f from $mt where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + f from $mt where a = 5 +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + e from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + e from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d + e from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + d from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + d from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + d from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + c from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + c from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + b from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + a from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a * f from $mt where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * a from $mt where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select b * f from $mt where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * b from $mt where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select c * f from $mt where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select d * f from $mt where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select e * f from $mt where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * f from $mt where a = 5 +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * e from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * e from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select d * e from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * d from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * d from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * d from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * c from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * c from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * b from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * a from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a / f from $mt where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / a from $mt where a = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b / f from $mt where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / b from $mt where a = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c / f from $mt where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select d / f from $mt where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select e / f from $mt where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / f from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $mt where a = 5 +print ===> $data00 +if $data00 != 2.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $mt where a = 5 +print ===> $data00 +if $data00 != 0.400000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $mt where a = 5 +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $mt where a = 5 +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $mt where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $mt where a = 5 +print ===> $data00 +if $data00 != -15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $mt where a = 5 +print ===> $data00 +if $data00 != -1.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $mt where a = 5 +print ===> $data00 +if $data00 != -150.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $mt where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $mt where a = 5 +print ===> $data00 +if $data00 != -25.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $mt where a = 5 +print ===> $data00 +if $data00 != -1300.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $mt where a = 5 -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $mt where a = 5 -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $mt where a = 5 -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/vector/metrics_mix.sim b/tests/script/windows/vector/metrics_mix.sim new file mode 100644 index 0000000000000000000000000000000000000000..111fdebb05735057a922ce313d9c595a7d8491ff --- /dev/null +++ b/tests/script/windows/vector/metrics_mix.sim @@ -0,0 +1,622 @@ +sql connect +sleep 2000 + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = m_mx_db +$tbPrefix = m_mx_tb +$mtPrefix = m_mx_mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - ffrom $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -x step020 + return -1 +step020: + +sql select a -f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select b - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select c - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select d - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select e - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -x step21 + return -1 +step21: + +sql select h - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -x step22 + return -1 +step22: + +sql select ts - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -x step23 + return -1 +step23: + +sql select a - e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a + f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select b + f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select c + f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select d + f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select e + f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d + e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select b * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select c * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select d * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select e * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select d * e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select d / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select e / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.400000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -1.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -150.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -25.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -1300.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/vector/metrics_query.sim b/tests/script/windows/vector/metrics_query.sim new file mode 100644 index 0000000000000000000000000000000000000000..45e734f468deb4fb1567260fdde8b072bdb2a3b2 --- /dev/null +++ b/tests/script/windows/vector/metrics_query.sim @@ -0,0 +1,618 @@ +sql connect +sleep 2000 + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = m_mq_db +$tbPrefix = m_mq_tb +$mtPrefix = m_mq_mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - f from $mt +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - a from $mt +print ===> $data00 +if $data00 != 9.000000000 then + return -1 +endi + +sql select b - f from $mt +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - b from $mt +print ===> $data00 +if $data00 != 9.000000000 then + return -1 +endi + +sql select c - f from $mt +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select d - f from $mt +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select e - f from $mt +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - f from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $mt -x step21 + return -1 +step21: + +sql select h - f from $mt -x step22 + return -1 +step22: + +sql select ts - f from $mt -x step23 + return -1 +step23: + +sql select a - e from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb = $tbPrefix . $i + +sql select a + f from $mt +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + a from $mt +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select b + f from $mt +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + b from $mt +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select c + f from $mt +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select d + f from $mt +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select e + f from $mt +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + f from $mt +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + e from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c + e from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select d + e from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + d from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + d from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c + d from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + c from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + c from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + b from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + a from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb = $tbPrefix . $i + +sql select a * f from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * a from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b * f from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * b from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c * f from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d * f from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select e * f from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * f from $mt +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * e from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c * e from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d * e from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * d from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * d from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c * d from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * c from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * c from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * b from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * a from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb = $tbPrefix . $i + +sql select a / f from $mt +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / a from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b / f from $mt +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / b from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c / f from $mt +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select d / f from $mt +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select e / f from $mt +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / f from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $mt +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $mt +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $mt +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $mt +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $mt +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $mt +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $mt +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $mt +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $mt +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $mt +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $mt -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $mt -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $mt -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/vector/metrics_tag.sim b/tests/script/windows/vector/metrics_tag.sim new file mode 100644 index 0000000000000000000000000000000000000000..80c204fa10e963fa264aa8f64d116cfc5ee1277f --- /dev/null +++ b/tests/script/windows/vector/metrics_tag.sim @@ -0,0 +1,618 @@ +sql connect +sleep 2000 + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = m_mtg_db +$tbPrefix = m_mtg_tb +$mtPrefix = m_mtg_mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - f from $mt +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - a from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 9.000000000 then + return -1 +endi + +sql select b - f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - b from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 9.000000000 then + return -1 +endi + +sql select c - f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select d - f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select e - f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $mt where tgcol = 5 -x step21 + return -1 +step21: + +sql select h - f from $mt where tgcol = 5 -x step22 + return -1 +step22: + +sql select ts - f from $mt where tgcol = 5 -x step23 + return -1 +step23: + +sql select a - e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb = $tbPrefix . $i + +sql select a + f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + a from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select b + f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + b from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select c + f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select d + f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select e + f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c + e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select d + e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c + d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + c from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + c from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + b from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + a from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb = $tbPrefix . $i + +sql select a * f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * a from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b * f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * b from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c * f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d * f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select e * f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c * e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d * e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c * d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * c from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * c from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * b from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * a from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb = $tbPrefix . $i + +sql select a / f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / a from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b / f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / b from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c / f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select d / f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select e / f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $mt where tgcol = 5 -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $mt where tgcol = 5 -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $mt where tgcol = 5 -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/vector/metrics_time.sim b/tests/script/windows/vector/metrics_time.sim new file mode 100644 index 0000000000000000000000000000000000000000..c127fe78fc1acf712cc5505a680477c0e52d8514 --- /dev/null +++ b/tests/script/windows/vector/metrics_time.sim @@ -0,0 +1,618 @@ +sql connect +sleep 2000 + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = m_mt_db +$tbPrefix = m_mt_tb +$mtPrefix = m_mt_mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select b - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select c - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select d - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select e - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -x step21 + return -1 +step21: + +sql select h - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -x step22 + return -1 +step22: + +sql select ts - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -x step23 + return -1 +step23: + +sql select a - e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select b + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select c + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select d + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select e + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d + e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select b * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select c * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select d * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select e * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select d * e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select d / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select e / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.400000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -1.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -150.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -25.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -1300.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/vector/multi.sim b/tests/script/windows/vector/multi.sim new file mode 100644 index 0000000000000000000000000000000000000000..ff63cda9a5777a3f20102aafb388f9a7b491a972 --- /dev/null +++ b/tests/script/windows/vector/multi.sim @@ -0,0 +1,215 @@ +sql connect +sleep 2000 + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = m_mu_db +$tbPrefix = m_mu_tb +$mtPrefix = m_mu_mt + +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f binary(10), g bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a + b from $tb +print ===> $data00 $data10 $data20 $data30 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + c from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + d from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + e from $tb where ts < now + 4m order by ts desc + +sql select a + a from $tb where ts > now + 4m order by ts desc + +sql select a + c from $tb where ts < now + 4m order by ts asc + +sql select a + f from $tb where ts > now + 4m order by ts asc -x step24 + return -1 +step24: + +print =============== step3 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - e from $tb +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select a - b from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - e from $tb where ts > now + 4m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb = $tbPrefix . $i + +sql select a * b + e from $tb +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select a * b + c from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a * b -d from $tb where ts > now + 4m +print ===> $data20 +if $data20 != 42.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb = $tbPrefix . $i + +sql select a / 2 + e from $tb +print ===> $data00 +if $data00 != 10.500000000 then + return -1 +endi + +sql select a / 2 from $tb where ts < now + 4m +print ===> $data10 +if $data10 != 1.000000000 then + return -1 +endi + +sql select a / 2 * e from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a / e from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb = $tbPrefix . $i +sql select a + ts from $tb -x step61 + return -1 +step61: + +sql select a + f from $tb -x step62 + return -1 +step62: + +sql select a + g from $tb -x step63 + return -1 +step63: + +print =============== step7 +$i = 1 +$tb = $tbPrefix . $i + +sql select a + b from $tb where a = 2 +print ===> $data00 +if $data00 != 4.000000000 then + return -1 +endi + +sql select * from $tb where b < 2 +print ===> $rows +if $rows != 1 then + return -1 +endi + +sql select * from $tb where b > 2 +print ===> $rows +if $rows != 17 then + return -1 +endi + +sql select a + c from $tb where b = 2 and ts < now + 4m +print ===> $data00 +if $data00 != 4.000000000 then + return -1 +endi + +sql select a + d from $tb where c = 10 and ts > now + 4m +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $tb where d = 2 and ts < now + 4m order by ts desc + +sql select a + a from $tb where e = 2 and ts > now + 4m order by ts desc + +sql select a + c from $tb where f = 2 and ts < now + 4m order by ts asc + +sql select a + f from $tb where g = 2 and ts > now + 4m order by ts asc -x step74 + return -1 +step74: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/vector/single.sim b/tests/script/windows/vector/single.sim new file mode 100644 index 0000000000000000000000000000000000000000..fb3a52760b4efb5133998a9d71d0b7ce2957e69b --- /dev/null +++ b/tests/script/windows/vector/single.sim @@ -0,0 +1,302 @@ +sql connect +sleep 2000 + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = m_si_db +$tbPrefix = m_si_tb +$mtPrefix = m_si_mt + +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select tbcol + 1 from $tb +print ===> $data00 $data10 $data20 $data30 +if $data00 != 1.000000000 then + return -1 +endi + +sql select tbcol + 1 from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select tbcol + 1 from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 6.000000000 then + return -1 +endi + +sql select tbcol + 1 from $tb where ts < now + 4m order by ts desc + +sql select tbcol + 1 from $tb where ts > now + 4m order by ts desc + +sql select tbcol + 1 from $tb where ts < now + 4m order by ts asc + +sql select tbcol + 1 from $tb where ts > now + 4m order by ts asc + +print =============== step3 +$i = 1 +$tb = $tbPrefix . $i + +sql select tbcol - 1 from $tb +print ===> $data00 +if $data00 != -1.000000000 then + return -1 +endi + +sql select tbcol - 1 from $tb where ts < now + 4m +print ===> $data00 +if $data00 != -1.000000000 then + return -1 +endi + +sql select tbcol - 1 from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 4.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb = $tbPrefix . $i + +sql select tbcol * 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select tbcol * 2 from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select tbcol * 2 from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb = $tbPrefix . $i + +sql select tbcol / 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select tbcol / 2 from $tb where ts < now + 4m +print ===> $data10 +if $data10 != 0.500000000 then + return -1 +endi + +sql select tbcol / 2 from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 2.500000000 then + return -1 +endi + +sql select tbcol / 0 from $tb where ts > now + 4m +print ===> $data00 +#if $data00 != 0.000000000 then +# return -1 +#endi + +print =============== step6 +$i = 11 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, tbcol bool) +sql insert into $tb values(now, 0) +sql select tbcol + 2 from $tb -x step6 + return -1 +step6: + +print =============== step7 +$i = $i + 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, tbcol tinyint) +sql insert into $tb values(now, 0); +sql select tbcol + 2 from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi +sql select tbcol - 2 from $tb +print ===> $data00 +if $data00 != -2.000000000 then + return -1 +endi +sql select tbcol * 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi +sql select tbcol / 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step8 +$i = $i + 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, tbcol smallint) +sql insert into $tb values(now, 0); +sql select tbcol + 2 from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi +sql select tbcol - 2 from $tb +print ===> $data00 +if $data00 != -2.000000000 then + return -1 +endi +sql select tbcol * 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi +sql select tbcol / 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step9 +$i = $i + 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, tbcol bigint) +sql insert into $tb values(now, 0); +sql select tbcol + 2 from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi +sql select tbcol - 2 from $tb +print ===> $data00 +if $data00 != -2.000000000 then + return -1 +endi +sql select tbcol * 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi +sql select tbcol / 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step10 +$i = $i + 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, tbcol float) +sql insert into $tb values(now, 0); +sql select tbcol + 2 from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi +sql select tbcol - 2 from $tb +print ===> $data00 +if $data00 != -2.000000000 then + return -1 +endi +sql select tbcol * 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi +sql select tbcol / 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step11 +$i = $i + 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, tbcol double) +sql insert into $tb values(now, 0); +sql select tbcol + 2 from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi +sql select tbcol - 2 from $tb +print ===> $data00 +if $data00 != -2.000000000 then + return -1 +endi +sql select tbcol * 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi +sql select tbcol / 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step12 +$i = $i + 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, tbcol binary(100)) +sql insert into $tb values(now, '0'); +sql select tbcol + 2 from $tb -x step12 + return -1 +step12: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/vector/table_field.sim b/tests/script/windows/vector/table_field.sim new file mode 100644 index 0000000000000000000000000000000000000000..10c5148243793adbd01221743cbda673ae7ce651 --- /dev/null +++ b/tests/script/windows/vector/table_field.sim @@ -0,0 +1,618 @@ +sql connect +sleep 2000 + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = m_tf_db +$tbPrefix = m_tf_tb +$mtPrefix = m_tf_mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - f from $tb where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - a from $tb where a = 5 +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select b - f from $tb where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - b from $tb where a = 5 +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select c - f from $tb where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select d - f from $tb where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select e - f from $tb where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - f from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $tb where a = 5 -x step21 + return -1 +step21: + +sql select h - f from $tb where a = 5 -x step22 + return -1 +step22: + +sql select ts - f from $tb where a = 5 -x step23 + return -1 +step23: + +sql select a - e from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb where a = 5 = $tbPrefix . $i + +sql select a + f from $tb where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + a from $tb where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select b + f from $tb where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + b from $tb where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select c + f from $tb where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select d + f from $tb where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select e + f from $tb where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + f from $tb where a = 5 +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + e from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + e from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d + e from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + d from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + d from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + d from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + c from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + c from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + b from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + a from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb where a = 5 = $tbPrefix . $i + +sql select a * f from $tb where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * a from $tb where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select b * f from $tb where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * b from $tb where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select c * f from $tb where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select d * f from $tb where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select e * f from $tb where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * f from $tb where a = 5 +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * e from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * e from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select d * e from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * d from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * d from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * d from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * c from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * c from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * b from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * a from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb where a = 5 = $tbPrefix . $i + +sql select a / f from $tb where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / a from $tb where a = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b / f from $tb where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / b from $tb where a = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c / f from $tb where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select d / f from $tb where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select e / f from $tb where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / f from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb where a = 5 = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $tb where a = 5 +print ===> $data00 +if $data00 != 2.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $tb where a = 5 +print ===> $data00 +if $data00 != 0.400000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $tb where a = 5 +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $tb where a = 5 +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $tb where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $tb where a = 5 +print ===> $data00 +if $data00 != -15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $tb where a = 5 +print ===> $data00 +if $data00 != -1.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $tb where a = 5 +print ===> $data00 +if $data00 != -150.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $tb where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $tb where a = 5 +print ===> $data00 +if $data00 != -25.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $tb where a = 5 +print ===> $data00 +if $data00 != -1300.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $tb where a = 5 -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $tb where a = 5 -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $tb where a = 5 -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/vector/table_mix.sim b/tests/script/windows/vector/table_mix.sim new file mode 100644 index 0000000000000000000000000000000000000000..7418cb453df7fc627acc9f34598db6ce7db144d9 --- /dev/null +++ b/tests/script/windows/vector/table_mix.sim @@ -0,0 +1,618 @@ +sql connect +sleep 2000 + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = m_tm_db +$tbPrefix = m_tm_tb +$mtPrefix = m_tm_mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - f from $tb where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - a from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select b - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - b from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select c - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select d - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select e - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -x step21 + return -1 +step21: + +sql select h - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -x step22 + return -1 +step22: + +sql select ts - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -x step23 + return -1 +step23: + +sql select a - e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb where a = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a + f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + a from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select b + f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + b from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select c + f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select d + f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select e + f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d + e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + c from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + c from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + b from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + a from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb where a = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * a from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select b * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * b from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select c * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select d * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select e * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select d * e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * c from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * c from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * b from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * a from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb where a = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / a from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / b from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select d / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select e / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb where a = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.400000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -1.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -150.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -25.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -1300.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $tb where a = 5 and ts > now + 4m and ts < now + 6m -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $tb where a = 5 and ts > now + 4m and ts < now + 6m -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $tb where a = 5 and ts > now + 4m and ts < now + 6m -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/vector/table_query.sim b/tests/script/windows/vector/table_query.sim new file mode 100644 index 0000000000000000000000000000000000000000..7654688b269eb16c278c000d9da565515512062a --- /dev/null +++ b/tests/script/windows/vector/table_query.sim @@ -0,0 +1,618 @@ +sql connect +sleep 2000 + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = m_tq_db +$tbPrefix = m_tq_tb +$mtPrefix = m_tq_mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - f from $tb +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - a from $tb +print ===> $data00 +if $data00 != 9.000000000 then + return -1 +endi + +sql select b - f from $tb +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - b from $tb +print ===> $data00 +if $data00 != 9.000000000 then + return -1 +endi + +sql select c - f from $tb +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select d - f from $tb +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select e - f from $tb +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - f from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $tb -x step21 + return -1 +step21: + +sql select h - f from $tb -x step22 + return -1 +step22: + +sql select ts - f from $tb -x step23 + return -1 +step23: + +sql select a - e from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb = $tbPrefix . $i + +sql select a + f from $tb +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + a from $tb +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select b + f from $tb +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + b from $tb +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select c + f from $tb +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select d + f from $tb +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select e + f from $tb +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + f from $tb +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + e from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c + e from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select d + e from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + d from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + d from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c + d from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + c from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + c from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + b from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + a from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb = $tbPrefix . $i + +sql select a * f from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * a from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b * f from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * b from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c * f from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d * f from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select e * f from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * f from $tb +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * e from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c * e from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d * e from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * d from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * d from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c * d from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * c from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * c from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * b from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * a from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb = $tbPrefix . $i + +sql select a / f from $tb +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / a from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b / f from $tb +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / b from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c / f from $tb +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select d / f from $tb +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select e / f from $tb +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / f from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $tb +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $tb +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $tb +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $tb +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $tb +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $tb +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $tb +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $tb +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $tb +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $tb +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $tb -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $tb -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $tb -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/vector/table_time.sim b/tests/script/windows/vector/table_time.sim new file mode 100644 index 0000000000000000000000000000000000000000..bea9d41d1bcdfa77acd5eaf52a2de22353b075d9 --- /dev/null +++ b/tests/script/windows/vector/table_time.sim @@ -0,0 +1,618 @@ +sql connect +sleep 2000 + +sql show databases +sql drop database $data00 -x e1 +e1: +sql show databases +sql drop database $data00 -x e2 +e2: + +$dbPrefix = m_tt_db +$tbPrefix = m_tt_tb +$mtPrefix = m_tt_mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - a from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select b - f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - b from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select c - f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select d - f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select e - f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $tb where ts > now + 4m and ts < now + 6m -x step21 + return -1 +step21: + +sql select h - f from $tb where ts > now + 4m and ts < now + 6m -x step22 + return -1 +step22: + +sql select ts - f from $tb where ts > now + 4m and ts < now + 6m -x step23 + return -1 +step23: + +sql select a - e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb where ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a + f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + a from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select b + f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + b from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select c + f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select d + f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select e + f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d + e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + c from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + c from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + b from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + a from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb where ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a * f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * a from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select b * f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * b from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select c * f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select d * f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select e * f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select d * e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * c from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * c from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * b from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * a from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb where ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a / f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / a from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b / f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / b from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c / f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select d / f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select e / f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb where ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.400000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -1.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -150.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -25.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -1300.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $tb where ts > now + 4m and ts < now + 6m -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $tb where ts > now + 4m and ts < now + 6m -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $tb where ts > now + 4m and ts < now + 6m -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/wtest.bat b/tests/script/wtest.bat new file mode 100644 index 0000000000000000000000000000000000000000..9ed58a90d1ba6bd781d306070e03f56b75984093 --- /dev/null +++ b/tests/script/wtest.bat @@ -0,0 +1,62 @@ +@echo off + +echo TDengine in windows +rem echo Start TDengine Testing Case ... + +set "SCRIPT_DIR=%~dp0" +rem echo SCRIPT_DIR: %SCRIPT_DIR% + +set "BUILD_DIR=%SCRIPT_DIR%..\..\..\debug\build\bin\" +set "TSIM=%BUILD_DIR%tsim" +rem echo BUILD_DIR: %BUILD_DIR% +rem echo TSIM: %TSIM% + +set "SIM_DIR=%SCRIPT_DIR%..\..\..\sim\" +rem echo SIM_DIR: %SIM_DIR% + +set "TSIM_DIR=%SIM_DIR%tsim\" +rem echo TSIM_DIR: %TSIM_DIR% + +set "CFG_DIR=%TSIM_DIR%cfg\" +rem echo CFG_DIR: %CFG_DIR% + +set "LOG_DIR=%TSIM_DIR%log\" +rem echo LOG_DIR: %LOG_DIR% + +set "TAOS_CFG=%CFG_DIR%taos.cfg" +rem echo TAOS_CFG: %TAOS_CFG% + +if not exist %SIM_DIR% mkdir %SIM_DIR% +if not exist %TSIM_DIR% mkdir %TSIM_DIR% +if exist %CFG_DIR% rmdir /s/q %CFG_DIR% +if exist %LOG_DIR% rmdir /s/q %LOG_DIR% +if not exist %CFG_DIR% mkdir %CFG_DIR% +if not exist %LOG_DIR% mkdir %LOG_DIR% + +rem set "fqdn=" +for /f "skip=1" %%A in ( + 'wmic computersystem get caption' +) do if not defined fqdn set "fqdn=%%A" + +echo firstEp %fqdn% > %TAOS_CFG% +echo fqdn %fqdn% >> %TAOS_CFG% +echo serverPort 7100 >> %TAOS_CFG% +echo logDir %LOG_DIR% >> %TAOS_CFG% +echo scriptDir %SCRIPT_DIR% >> %TAOS_CFG% +echo numOfLogLines 100000000 >> %TAOS_CFG% +echo rpcDebugFlag 135 >> %TAOS_CFG% +echo tmrDebugFlag 131 >> %TAOS_CFG% +echo cDebugFlag 135 >> %TAOS_CFG% +echo udebugFlag 135 >> %TAOS_CFG% +echo wal 0 >> %TAOS_CFG% +echo asyncLog 0 >> %TAOS_CFG% +echo locale en_US.UTF-8 >> %TAOS_CFG% +echo enableCoreFile 1 >> %TAOS_CFG% + +set "FILE_NAME=testSuite.sim" +if "%1" == "-f" set "FILE_NAME=%2" + +rem echo FILE_NAME: %FILE_NAME% +echo ExcuteCmd: %tsim% -c %CFG_DIR% -f %FILE_NAME% + +%TSIM% -c %CFG_DIR% -f %FILE_NAME% \ No newline at end of file diff --git a/tests/stress/.gitignore b/tests/stress/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..25a8031c43c318e14e42873dcceca728aa5a48e1 --- /dev/null +++ b/tests/stress/.gitignore @@ -0,0 +1,3 @@ +stress +stress.exe +cases.json \ No newline at end of file diff --git a/tests/stress/README.md b/tests/stress/README.md new file mode 100644 index 0000000000000000000000000000000000000000..a7f8a2dac6a8500bbbdb177ecbce89ea2b7f97a6 --- /dev/null +++ b/tests/stress/README.md @@ -0,0 +1,80 @@ +# STRESS + +Stress test tool for TDengine. It run a set of test cases randomly and show statistics. + +## COMMAND LINE + +``` bash +$ ./stress [-h=] [-P=<0>] [-d=] [-u=] [-p=] [-c=<4>] [-f=] [-l=] [path_or_sql] +``` + +* **-h**: host name or IP address of TDengine server (default: localhost). +* **-P**: port number of TDengine server (default: 0). +* **-u**: user name (default: root). +* **-p**: password (default: taosdata). +* **-c**: concurrency, number of concurrent goroutines for query (default: 4). +* **-f**: fetch data or not (default: true). +* **-l**: log file path (default: no log). +* **path_or_sql**: a SQL statement or path of a JSON file which contains the test cases (default: cases.json). + +## TEST CASE FILE + +```json +[{ + "weight": 1, + "sql": "select * from meters where ts>=now+%dm and ts<=now-%dm and c1=%v and c2=%d and c3='%s' and tbname='%s'", + "args": [{ + "type": "range", + "min": 30, + "max": 60 + }, { + "type": "bool" + }, { + "type": "int", + "min": -10, + "max": 20 + }, { + "type": "string", + "min": 0, + "max": 10, + }, { + "type": "list", + "list": [ + "table1", + "table2", + "table3", + "table4" + ] + }] +}] +``` + +The test case file is a standard JSON file which contains an array of test cases. For test cases, field `sql` is mandatory, and it can optionally include a `weight` field and an `args` field which is an array of arguments. + +`sql` is a SQL statement, it can include zero or more arguments (placeholders). + +`weight` defines the possibility of the case being selected, the greater value the higher possibility. It must be an non-negative integer and the default value is zero, but, if all cases have a zero weight, all the weights are regarded as 1. + +Placeholders of `sql` are replaced by arguments in `args` at runtime. There are 5 types of arguments currently: + +* **bool**: generate a `boolean` value randomly. +* **int**: generate an `integer` between [`min`, `max`] randomly, the default value of `min` is 0 and `max` is 100. +* **range**: generate two `integer`s between [`min`, `max`] randomly, the first is less than the second, the default value of `min` is 0 and `max` is 100. +* **string**: generate a `string` with length between [`min`, `max`] randomly, the default value of `min` is 0 and `max` is 100. +* **list**: select an item from `list` randomly. + +## OUTPUT + +``` + 00:00:08 | TOTAL REQ | TOTAL TIME(us) | TOTAL AVG(us) | REQUEST | TIME(us) | AVERAGE(us) | + TOTAL | 3027 | 26183890 | 8650.11 | 287 | 3060935 | 10665.28 | + SUCCESS | 3027 | 26183890 | 8650.11 | 287 | 3060935 | 10665.28 | + FAIL | 0 | 0 | 0.00 | 0 | 0 | 0.00 | +``` + +* **Col 2**: total number of request since test start. +* **Col 3**: total time of all request since test start. +* **Col 4**: average time of all request since test start. +* **Col 5**: number of request in last second. +* **Col 6**: time of all request in last second. +* **Col 7**: average time of all request in last second. diff --git a/tests/stress/go.mod b/tests/stress/go.mod new file mode 100644 index 0000000000000000000000000000000000000000..df9b2806b551429ee59ad0d44e3eb0ad75ab39cb --- /dev/null +++ b/tests/stress/go.mod @@ -0,0 +1,7 @@ +module github.com/taosdata/stress + +go 1.14 + +require ( + github.com/taosdata/driver-go v0.0.0-20200606095205-b786bac1857f +) diff --git a/tests/stress/main.go b/tests/stress/main.go new file mode 100644 index 0000000000000000000000000000000000000000..c3b9290a379b0782f1042909cc0cadb728a4620e --- /dev/null +++ b/tests/stress/main.go @@ -0,0 +1,406 @@ +package main + +import ( + "database/sql" + "encoding/json" + "errors" + "flag" + "fmt" + "math/rand" + "os" + "os/signal" + "strings" + "sync" + "sync/atomic" + "time" + + _ "github.com/taosdata/driver-go/taosSql" +) + +type argument struct { + Type string `json:"type"` + Min int `json:"min"` + Max int `json:"max"` + List []interface{} `json:"list, omitempty"` +} + +type testCase struct { + isQuery bool `json:"-"` + numArgs int `json:"-"` + Weight int `json:"weight"` + SQL string `json:"sql"` + Args []argument `json:"args"` +} + +func (arg *argument) check() (int, error) { + if arg.Type == "list" { + if len(arg.List) == 0 { + return 0, errors.New("list cannot be empty") + } + return 1, nil + } + + if arg.Max < arg.Min { + return 0, errors.New("invalid min/max value") + } + + if arg.Type == "string" { + if arg.Min < 0 { + return 0, errors.New("negative string length") + } + } + + if arg.Type == "int" && arg.Min == 0 && arg.Max == 0 { + arg.Max = arg.Min + 100 + } + + if arg.Type == "range" { + return 2, nil + } + + return 1, nil +} + +func (arg *argument) generate(args []interface{}) []interface{} { + const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" + + switch arg.Type { + case "bool": + if rand.Intn(2) == 1 { + args = append(args, true) + } else { + args = append(args, false) + } + + case "int": + v := rand.Intn(arg.Max-arg.Min+1) + arg.Min + args = append(args, v) + + case "range": + v := rand.Intn(arg.Max-arg.Min) + arg.Min + args = append(args, v) + v = rand.Intn(arg.Max-v+1) + v + args = append(args, v) + + case "string": + l := rand.Intn(arg.Max-arg.Min+1) + arg.Min + sb := strings.Builder{} + for i := 0; i < l; i++ { + sb.WriteByte(chars[rand.Intn(len(chars))]) + } + args = append(args, sb.String()) + + case "list": + v := arg.List[rand.Intn(len(arg.List))] + args = append(args, v) + } + + return args +} + +func (tc *testCase) buildSql() string { + args := make([]interface{}, 0, tc.numArgs) + for i := 0; i < len(tc.Args); i++ { + args = tc.Args[i].generate(args) + } + return fmt.Sprintf(tc.SQL, args...) +} + +type statitics struct { + succeeded int64 + failed int64 + succeededDuration int64 + failedDuration int64 +} + +var ( + host string + port uint + database string + user string + password string + fetch bool + + chLog chan string + wgLog sync.WaitGroup + startAt time.Time + shouldStop int64 + wgTest sync.WaitGroup + stat statitics + totalWeight int + cases []testCase +) + +func loadTestCaseFromFile(file *os.File) error { + if e := json.NewDecoder(file).Decode(&cases); e != nil { + return e + } + + if len(cases) == 0 { + return fmt.Errorf("no test case loaded.") + } + + for i := 0; i < len(cases); i++ { + c := &cases[i] + c.SQL = strings.TrimSpace(c.SQL) + c.isQuery = strings.ToLower(c.SQL[:6]) == "select" + if c.Weight < 0 { + return fmt.Errorf("test %d: negative weight", i) + } + totalWeight += c.Weight + + for j := 0; j < len(c.Args); j++ { + arg := &c.Args[j] + arg.Type = strings.ToLower(arg.Type) + n, e := arg.check() + if e != nil { + return fmt.Errorf("test case %d argument %d: %s", i, j, e.Error()) + } + c.numArgs += n + } + } + + if totalWeight == 0 { + for i := 0; i < len(cases); i++ { + cases[i].Weight = 1 + } + totalWeight = len(cases) + } + + return nil +} + +func loadTestCase(pathOrSQL string) error { + if f, e := os.Open(pathOrSQL); e == nil { + defer f.Close() + return loadTestCaseFromFile(f) + } + + pathOrSQL = strings.TrimSpace(pathOrSQL) + if strings.ToLower(pathOrSQL[:6]) != "select" { + return fmt.Errorf("'%s' is not a valid file or SQL statement", pathOrSQL) + } + + cases = append(cases, testCase{ + isQuery: true, + Weight: 1, + numArgs: 0, + SQL: pathOrSQL, + }) + totalWeight = 1 + + return nil +} + +func selectTestCase() *testCase { + sum, target := 0, rand.Intn(totalWeight) + var c *testCase + for i := 0; i < len(cases); i++ { + c = &cases[i] + sum += c.Weight + if sum > target { + break + } + } + return c +} + +func runTest() { + defer wgTest.Done() + db, e := sql.Open("taosSql", fmt.Sprintf("%s:%s@tcp(%s:%v)/%s", user, password, host, port, database)) + if e != nil { + fmt.Printf("failed to connect to database: %s\n", e.Error()) + return + } + defer db.Close() + + for atomic.LoadInt64(&shouldStop) == 0 { + c := selectTestCase() + str := c.buildSql() + + start := time.Now() + if c.isQuery { + var rows *sql.Rows + if rows, e = db.Query(str); rows != nil { + if fetch { + for rows.Next() { + } + } + rows.Close() + } + } else { + _, e = db.Exec(str) + } + duration := time.Now().Sub(start).Microseconds() + + if e != nil { + if chLog != nil { + chLog <- str + ": " + e.Error() + } + atomic.AddInt64(&stat.failed, 1) + atomic.AddInt64(&stat.failedDuration, duration) + } else { + atomic.AddInt64(&stat.succeeded, 1) + atomic.AddInt64(&stat.succeededDuration, duration) + } + } +} + +func getStatPrinter() func(tm time.Time) { + var last statitics + lastPrintAt := startAt + + return func(tm time.Time) { + var current statitics + + current.succeeded = atomic.LoadInt64(&stat.succeeded) + current.failed = atomic.LoadInt64(&stat.failed) + current.succeededDuration = atomic.LoadInt64(&stat.succeededDuration) + current.failedDuration = atomic.LoadInt64(&stat.failedDuration) + + seconds := int64(tm.Sub(startAt).Seconds()) + format := "\033[47;30m %02v:%02v:%02v | TOTAL REQ | TOTAL TIME(us) | TOTAL AVG(us) | REQUEST | TIME(us) | AVERAGE(us) |\033[0m\n" + fmt.Printf(format, seconds/3600, seconds%3600/60, seconds%60) + + tr := current.succeeded + current.failed + td := current.succeededDuration + current.failedDuration + r := tr - last.succeeded - last.failed + d := td - last.succeededDuration - last.failedDuration + ta, a := 0.0, 0.0 + if tr > 0 { + ta = float64(td) / float64(tr) + } + if r > 0 { + a = float64(d) / float64(r) + } + format = " TOTAL | %9v | %14v | %13.2f | %7v | %10v | % 13.2f |\n" + fmt.Printf(format, tr, td, ta, r, d, a) + + tr = current.succeeded + td = current.succeededDuration + r = tr - last.succeeded + d = td - last.succeededDuration + ta, a = 0.0, 0.0 + if tr > 0 { + ta = float64(td) / float64(tr) + } + if r > 0 { + a = float64(d) / float64(r) + } + format = " SUCCESS | \033[32m%9v\033[0m | \033[32m%14v\033[0m | \033[32m%13.2f\033[0m | \033[32m%7v\033[0m | \033[32m%10v\033[0m | \033[32m%13.2f\033[0m |\n" + fmt.Printf(format, tr, td, ta, r, d, a) + + tr = current.failed + td = current.failedDuration + r = tr - last.failed + d = td - last.failedDuration + ta, a = 0.0, 0.0 + if tr > 0 { + ta = float64(td) / float64(tr) + } + if r > 0 { + a = float64(d) / float64(r) + } + format = " FAIL | \033[31m%9v\033[0m | \033[31m%14v\033[0m | \033[31m%13.2f\033[0m | \033[31m%7v\033[0m | \033[31m%10v\033[0m | \033[31m%13.2f\033[0m |\n" + fmt.Printf(format, tr, td, ta, r, d, a) + + last = current + lastPrintAt = tm + } +} + +func startLogger(path string) error { + if len(path) == 0 { + return nil + } + + f, e := os.Create(path) + if e != nil { + return e + } + + chLog = make(chan string, 100) + wgLog.Add(1) + go func() { + for s := range chLog { + if f != nil { + f.WriteString(s) + f.WriteString("\n") + } + } + f.Close() + wgLog.Done() + }() + + return nil +} + +func main() { + var concurrency uint + var logPath string + flag.StringVar(&host, "h", "localhost", "host name or IP address of TDengine server") + flag.UintVar(&port, "P", 0, "port (default 0)") + flag.StringVar(&database, "d", "test", "database name") + flag.StringVar(&user, "u", "root", "user name") + flag.StringVar(&password, "p", "taosdata", "password") + flag.BoolVar(&fetch, "f", true, "fetch result or not") + flag.UintVar(&concurrency, "c", 4, "concurrency, number of goroutines for query") + flag.StringVar(&logPath, "l", "", "path of log file (default: no log)") + flag.Parse() + + if e := startLogger(logPath); e != nil { + fmt.Println("failed to open log file:", e.Error()) + return + } + + pathOrSQL := flag.Arg(0) + if len(pathOrSQL) == 0 { + pathOrSQL = "cases.json" + } + if e := loadTestCase(pathOrSQL); e != nil { + fmt.Println("failed to load test cases:", e.Error()) + return + } + + rand.Seed(time.Now().UnixNano()) + + fmt.Printf("\nSERVER: %s DATABASE: %s CONCURRENCY: %d FETCH DATA: %v\n\n", host, database, concurrency, fetch) + + startAt = time.Now() + printStat := getStatPrinter() + printStat(startAt) + + for i := uint(0); i < concurrency; i++ { + wgTest.Add(1) + go runTest() + } + + interrupt := make(chan os.Signal, 1) + signal.Notify(interrupt, os.Interrupt) + ticker := time.NewTicker(time.Second) + + fmt.Println("Ctrl + C to exit....\033[1A") + +LOOP: + for { + select { + case <-interrupt: + break LOOP + case tm := <-ticker.C: + fmt.Print("\033[4A") + printStat(tm) + } + } + + atomic.StoreInt64(&shouldStop, 1) + fmt.Print("\033[100D'Ctrl + C' received, Waiting started query to stop...") + wgTest.Wait() + + if chLog != nil { + close(chLog) + wgLog.Wait() + } + fmt.Print("\033[4A\033[100D") + printStat(time.Now()) + fmt.Println() +} diff --git a/tests/test-all.sh b/tests/test-all.sh new file mode 100755 index 0000000000000000000000000000000000000000..29e96b3fc6e6f84157d57f607a3fc33eccad0f65 --- /dev/null +++ b/tests/test-all.sh @@ -0,0 +1,550 @@ +#!/bin/bash + +# Color setting +RED='\033[0;31m' +GREEN='\033[1;32m' +GREEN_DARK='\033[0;32m' +GREEN_UNDERLINE='\033[4;32m' +NC='\033[0m' + +tests_dir=`pwd` +IN_TDINTERNAL="community" + +function stopTaosd { + echo "Stop taosd" + sudo systemctl stop taosd || echo 'no sudo or systemctl or stop fail ' + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + pkill -TERM -x taosd + sleep 1 + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + done +} + +function dohavecore(){ + corefile=`find $corepath -mmin 1` + if [ -n "$corefile" ];then + core_file=`echo $corefile|cut -d " " -f2` + proc=`file $core_file|awk -F "execfn:" '/execfn:/{print $2}'|tr -d \' |awk '{print $1}'|tr -d \,` + echo 'taosd or taos has generated core' + rm case.log + if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]] && [[ $1 == 1 ]]; then + cd ../../../ + tar -zcPf $corepath'taos_'`date "+%Y_%m_%d_%H_%M_%S"`.tar.gz debug/build/bin/taosd debug/build/bin/tsim debug/build/lib/libtaos*so* + if [[ $2 == 1 ]];then + cp -r sim ~/sim_`date "+%Y_%m_%d_%H:%M:%S"` + else + cd community + cp -r sim ~/sim_`date "+%Y_%m_%d_%H:%M:%S" ` + fi + else + cd ../../ + if [[ $1 == 1 ]];then + tar -zcPf $corepath'taos_'`date "+%Y_%m_%d_%H_%M_%S"`.tar.gz debug/build/bin/taosd debug/build/bin/tsim debug/build/lib/libtaos*so* + cp -r sim ~/sim_`date "+%Y_%m_%d_%H:%M:%S" ` + fi + fi + if [[ $1 == 1 ]];then + echo '\n'|gdb $proc $core_file -ex "bt 10" -ex quit + exit 8 + fi + fi +} + +function runSimCaseOneByOne { + while read -r line; do + if [[ $line =~ ^./test.sh* ]] || [[ $line =~ ^run* ]]; then + case=`echo $line | grep sim$ |awk '{print $NF}'` + start_time=`date +%s` + date +%F\ %T | tee -a out.log + if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then + echo -n $case + ./test.sh -f $case > /dev/null 2>&1 && \ + ( grep -q 'script.*'$case'.*failed.*, err.*lineNum' ../../../sim/tsim/log/taoslog0.0 && echo -e "${RED} failed${NC}" | tee -a out.log || echo -e "${GREEN} success${NC}" | tee -a out.log )|| \ + ( grep -q 'script.*success.*m$' ../../../sim/tsim/log/taoslog0.0 && echo -e "${GREEN} success${NC}" | tee -a out.log ) || \ + echo -e "${RED} failed${NC}" | tee -a out.log + else + echo -n $case + ./test.sh -f $case > /dev/null 2>&1 && \ + ( grep -q 'script.*'$case'.*failed.*, err.*lineNum' ../../sim/tsim/log/taoslog0.0 && echo -e "${RED} failed${NC}" | tee -a out.log || echo -e "${GREEN} success${NC}" | tee -a out.log )|| \ + ( grep -q 'script.*success.*m$' ../../sim/tsim/log/taoslog0.0 && echo -e "${GREEN} success${NC}" | tee -a out.log ) || \ + echo -e "${RED} failed${NC}" | tee -a out.log + fi + out_log=`tail -1 out.log ` + # if [[ $out_log =~ 'failed' ]];then + # exit 8 + # fi + end_time=`date +%s` + echo execution time of $case was `expr $end_time - $start_time`s. | tee -a out.log + fi + done < $1 +} + +function runSimCaseOneByOnefq { + + start=`sed -n "/$1-start/=" jenkins/basic.txt` + end=`sed -n "/$1-end/=" jenkins/basic.txt` + for ((i=$start;i<=$end;i++)) ; do + line=`sed -n "$i"p jenkins/basic.txt` + if [[ $line =~ ^./test.sh* ]] || [[ $line =~ ^run* ]]; then + case=`echo $line | grep sim$ |awk '{print $NF}'` + + start_time=`date +%s` + date +%F\ %T | tee -a out.log + if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then + echo -n $case + ./test.sh -f $case > case.log 2>&1 && \ + ( grep -q 'script.*'$case'.*failed.*, err.*lineNum' ../../../sim/tsim/log/taoslog0.0 && echo -e "${RED} failed${NC}" | tee -a out.log || echo -e "${GREEN} success${NC}" | tee -a out.log )|| \ + ( grep -q 'script.*success.*m$' ../../../sim/tsim/log/taoslog0.0 && echo -e "${GREEN} success${NC}" | tee -a out.log ) || \ + ( echo -e "${RED} failed${NC}" | tee -a out.log && echo '=====================log=====================' && cat case.log ) + else + echo -n $case + ./test.sh -f $case > ../../sim/case.log 2>&1 && \ + ( grep -q 'script.*'$case'.*failed.*, err.*lineNum' ../../sim/tsim/log/taoslog0.0 && echo -e "${RED} failed${NC}" | tee -a out.log || echo -e "${GREEN} success${NC}" | tee -a out.log )|| \ + ( grep -q 'script.*success.*m$' ../../sim/tsim/log/taoslog0.0 && echo -e "${GREEN} success${NC}" | tee -a out.log ) || \ + ( echo -e "${RED} failed${NC}" | tee -a out.log && echo '=====================log=====================' && cat case.log ) + fi + + out_log=`tail -1 out.log ` + if [[ $out_log =~ 'failed' ]];then + rm case.log + if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then + cp -r ../../../sim ~/sim_`date "+%Y_%m_%d_%H:%M:%S"` + else + cp -r ../../sim ~/sim_`date "+%Y_%m_%d_%H:%M:%S" ` + fi + dohavecore $2 1 + if [[ $2 == 1 ]];then + exit 8 + fi + fi + end_time=`date +%s` + echo execution time of $case was `expr $end_time - $start_time`s. | tee -a out.log + dohavecore $2 1 + fi + done + rm -rf ../../../sim/case.log + rm -rf ../../sim/case.log +} + +function runPyCaseOneByOne { + while read -r line; do + if [[ $line =~ ^python.* ]]; then + if [[ $line != *sleep* ]]; then + + if [[ $line =~ '-r' ]];then + case=`echo $line|awk '{print $4}'` + else + case=`echo $line|awk '{print $NF}'` + fi + start_time=`date +%s` + date +%F\ %T | tee -a pytest-out.log + echo -n $case + $line > /dev/null 2>&1 && \ + echo -e "${GREEN} success${NC}" | tee -a pytest-out.log || \ + echo -e "${RED} failed${NC}" | tee -a pytest-out.log + end_time=`date +%s` + out_log=`tail -1 pytest-out.log ` + # if [[ $out_log =~ 'failed' ]];then + # exit 8 + # fi + echo execution time of $case was `expr $end_time - $start_time`s. | tee -a pytest-out.log + else + $line > /dev/null 2>&1 + fi + fi + done < $1 +} + +function runPyCaseOneByOnefq() { + cd $tests_dir/pytest + if [[ $1 =~ full ]] ; then + start=1 + end=`sed -n '$=' fulltest.sh` + else + start=`sed -n "/$1-start/=" fulltest.sh` + end=`sed -n "/$1-end/=" fulltest.sh` + fi + for ((i=$start;i<=$end;i++)) ; do + line=`sed -n "$i"p fulltest.sh` + if [[ $line =~ ^python.* ]]; then + if [[ $line != *sleep* ]]; then + + if [[ $line =~ '-r' ]];then + case=`echo $line|awk '{print $4}'` + else + case=`echo $line|awk '{print $NF}'` + fi + start_time=`date +%s` + date +%F\ %T | tee -a pytest-out.log + echo -n $case + if [[ $1 =~ full ]] ; then + line=$line" -s" + fi + $line > case.log 2>&1 && \ + echo -e "${GREEN} success${NC}" | tee -a pytest-out.log || \ + echo -e "${RED} failed${NC}" | tee -a pytest-out.log + end_time=`date +%s` + out_log=`tail -1 pytest-out.log ` + if [[ $out_log =~ 'failed' ]];then + cp -r ../../sim ~/sim_`date "+%Y_%m_%d_%H:%M:%S" ` + echo '=====================log===================== ' + cat case.log + rm -rf case.log + dohavecore $2 2 + if [[ $2 == 1 ]];then + exit 8 + fi + fi + echo execution time of $case was `expr $end_time - $start_time`s. | tee -a pytest-out.log + else + $line > /dev/null 2>&1 + fi + dohavecore $2 2 + fi + done + rm -rf ../../sim/case.log +} + +###################### +# main entry +###################### + +unameOut="$(uname -s)" +case "${unameOut}" in + Linux*) OS=Linux;; + Darwin*) OS=Darwin;; + CYGWIN*) OS=Windows;; + *) OS=Unknown;; +esac + +case "${OS}" in + Linux*) TAOSLIB=libtaos.so;; + Darwin*) TAOSLIB=libtaos.dylib;; + Windows*) TAOSLIB=taos.dll;; + Unknown) TAOSLIB="UNKNOWN:${unameOut}";; +esac + +echo TAOSLIB is ${TAOSLIB} + +totalFailed=0 +totalPyFailed=0 +totalJDBCFailed=0 +totalUnitFailed=0 +totalExampleFailed=0 + +if [ "${OS}" == "Linux" ]; then + corepath=`grep -oP '.*(?=core_)' /proc/sys/kernel/core_pattern||grep -oP '.*(?=core-)' /proc/sys/kernel/core_pattern` + if [ -z "$corepath" ];then + echo "/coredump/core_%e_%p_%t" > /proc/sys/kernel/core_pattern || echo "Permission denied" + corepath="/coredump/" + fi +fi + +if [ "$2" != "jdbc" ] && [ "$2" != "python" ] && [ "$2" != "unit" ] && [ "$2" != "example" ]; then + echo "### run TSIM test case ###" + cd $tests_dir/script + + [ -f out.log ] && rm -f out.log + if [ "$1" == "cron" ]; then + echo "### run TSIM regression test ###" + runSimCaseOneByOne regressionSuite.sim + elif [ "$1" == "full" ]; then + echo "### run TSIM full test ###" + runSimCaseOneByOne jenkins/basic.txt + elif [ "$1" == "b1" ]; then + echo "### run TSIM b1 test ###" + runSimCaseOneByOnefq b1 0 + runSimCaseOneByOnefq b4 0 + runSimCaseOneByOnefq b7 0 + elif [ "$1" == "b2" ]; then + echo "### run TSIM b2 test ###" + runSimCaseOneByOnefq b2 0 + runSimCaseOneByOnefq b5 0 + elif [ "$1" == "b3" ]; then + echo "### run TSIM b3 test ###" + runSimCaseOneByOnefq b3 0 + runSimCaseOneByOnefq b6 0 + elif [ "$1" == "b1fq" ]; then + echo "### run TSIM b1 test ###" + runSimCaseOneByOnefq b1 1 + elif [ "$1" == "b2fq" ]; then + echo "### run TSIM b2 test ###" + runSimCaseOneByOnefq b2 1 + elif [ "$1" == "b3fq" ]; then + echo "### run TSIM b3 test ###" + runSimCaseOneByOnefq b3 1 + elif [ "$1" == "b4fq" ]; then + echo "### run TSIM b4 test ###" + runSimCaseOneByOnefq b4 1 + elif [ "$1" == "b5fq" ]; then + echo "### run TSIM b5 test ###" + runSimCaseOneByOnefq b5 1 + elif [ "$1" == "b6fq" ]; then + echo "### run TSIM b6 test ###" + runSimCaseOneByOnefq b6 1 + elif [ "$1" == "b7fq" ]; then + echo "### run TSIM b7 test ###" + runSimCaseOneByOnefq b7 1 + elif [ "$1" == "smoke" ] || [ -z "$1" ]; then + echo "### run TSIM smoke test ###" + runSimCaseOneByOne basicSuite.sim + fi + + totalSuccess=`grep 'success' out.log | wc -l` + totalBasic=`grep success out.log | grep Suite | wc -l` + + if [ "$totalSuccess" -gt "0" ]; then + totalSuccess=`expr $totalSuccess - $totalBasic` + fi + + echo -e "\n${GREEN} ### Total $totalSuccess TSIM case(s) succeed! ### ${NC}" + + totalFailed=`grep 'failed\|fault' out.log | wc -l` +# echo -e "${RED} ### Total $totalFailed TSIM case(s) failed! ### ${NC}" + + if [ "$totalFailed" -ne "0" ]; then + echo -e "\n${RED} ### Total $totalFailed TSIM case(s) failed! ### ${NC}" + +# exit $totalFailed + fi +fi + +if [ "$2" != "sim" ] && [ "$2" != "jdbc" ] && [ "$2" != "unit" ] && [ "$2" != "example" ]; then + echo "### run Python test case ###" + + cd $tests_dir + + if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then + cd ../.. + else + cd ../ + fi + + TOP_DIR=`pwd` + TAOSLIB_DIR=`find . -name "${TAOSLIB}"|grep -w lib|head -n1` + if [[ "$TAOSLIB_DIR" == *"$IN_TDINTERNAL"* ]]; then + LIB_DIR=`find . -name "${TAOSLIB}"|grep -w lib|head -n1|cut -d '/' -f 2,3,4,5` + else + LIB_DIR=`find . -name "${TAOSLIB}"|grep -w lib|head -n1|cut -d '/' -f 2,3,4` + fi + + export LD_LIBRARY_PATH=$TOP_DIR/$LIB_DIR:$LD_LIBRARY_PATH + + cd $tests_dir/pytest + + [ -f pytest-out.log ] && rm -f pytest-out.log + + if [ "$1" == "cron" ]; then + echo "### run Python regression test ###" + runPyCaseOneByOne regressiontest.sh + elif [ "$1" == "full" ]; then + echo "### run Python full test ###" + runPyCaseOneByOne fulltest.sh + elif [ "$1" == "pytest" ]; then + echo "### run Python full test ###" + runPyCaseOneByOne fulltest.sh + elif [ "$1" == "pytestfq" ]; then + echo "### run Python full test ###" + runPyCaseOneByOnefq full 0 + elif [ "$1" == "p1" ]; then + echo "### run Python_1 test ###" + runPyCaseOneByOnefq p1 1 + elif [ "$1" == "p2" ]; then + echo "### run Python_2 test ###" + runPyCaseOneByOnefq p2 1 + elif [ "$1" == "p3" ]; then + echo "### run Python_3 test ###" + runPyCaseOneByOnefq p3 1 + elif [ "$1" == "p4" ]; then + echo "### run Python_4 test ###" + runPyCaseOneByOnefq p4 1 + elif [ "$1" == "b2" ] || [ "$1" == "b3" ]; then + exit $(($totalFailed + $totalPyFailed)) + elif [ "$1" == "smoke" ] || [ -z "$1" ]; then + echo "### run Python smoke test ###" + runPyCaseOneByOne smoketest.sh + fi + totalPySuccess=`grep 'success' pytest-out.log | wc -l` + + if [ "$totalPySuccess" -gt "0" ]; then + echo -e "\n${GREEN} ### Total $totalPySuccess python case(s) succeed! ### ${NC}" + fi + + totalPyFailed=`grep 'failed\|fault' pytest-out.log | wc -l` + if [ "$totalPyFailed" -ne "0" ]; then + echo -e "\n${RED} ### Total $totalPyFailed python case(s) failed! ### ${NC}" +# exit $totalPyFailed + fi +fi + + +if [ "$2" != "sim" ] && [ "$2" != "python" ] && [ "$2" != "unit" ] && [ "$2" != "example" ] && [ "$1" == "full" ]; then + echo "### run JDBC test cases ###" + + cd $tests_dir + + if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then + cd ../../ + else + cd ../ + fi + + pwd + cd debug/ + + stopTaosd + rm -rf /var/lib/taos/* + nohup build/bin/taosd -c /etc/taos/ > /dev/null 2>&1 & + sleep 30 + + cd $tests_dir/../src/connector/jdbc + + mvn test > jdbc-out.log 2>&1 + tail -n 20 jdbc-out.log + + cases=`grep 'Tests run' jdbc-out.log | awk 'END{print $3}'` + totalJDBCCases=`echo ${cases/%,}` + failed=`grep 'Tests run' jdbc-out.log | awk 'END{print $5}'` + JDBCFailed=`echo ${failed/%,}` + error=`grep 'Tests run' jdbc-out.log | awk 'END{print $7}'` + JDBCError=`echo ${error/%,}` + + totalJDBCFailed=`expr $JDBCFailed + $JDBCError` + totalJDBCSuccess=`expr $totalJDBCCases - $totalJDBCFailed` + + if [ "$totalJDBCSuccess" -gt "0" ]; then + echo -e "\n${GREEN} ### Total $totalJDBCSuccess JDBC case(s) succeed! ### ${NC}" + fi + + if [ "$totalJDBCFailed" -ne "0" ]; then + echo -e "\n${RED} ### Total $totalJDBCFailed JDBC case(s) failed! ### ${NC}" + fi + dohavecore 1 +fi + +if [ "$2" != "sim" ] && [ "$2" != "python" ] && [ "$2" != "jdbc" ] && [ "$2" != "example" ] && [ "$1" == "full" ]; then + echo "### run Unit tests ###" + + stopTaosd + cd $tests_dir + + if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then + cd ../../ + else + cd ../ + fi + + pwd + cd debug/build/bin + rm -rf /var/lib/taos/* + nohup ./taosd -c /etc/taos/ > /dev/null 2>&1 & + sleep 30 + + pwd + ./queryTest > unittest-out.log 2>&1 + tail -n 20 unittest-out.log + + totalUnitTests=`grep "Running" unittest-out.log | awk '{print $3}'` + totalUnitSuccess=`grep 'PASSED' unittest-out.log | awk '{print $4}'` + totalUnitFailed=`expr $totalUnitTests - $totalUnitSuccess` + + if [ "$totalUnitSuccess" -gt "0" ]; then + echo -e "\n${GREEN} ### Total $totalUnitSuccess Unit test succeed! ### ${NC}" + fi + + if [ "$totalUnitFailed" -ne "0" ]; then + echo -e "\n${RED} ### Total $totalUnitFailed Unit test failed! ### ${NC}" + fi + dohavecore 1 +fi + +if [ "$2" != "sim" ] && [ "$2" != "python" ] && [ "$2" != "jdbc" ] && [ "$2" != "unit" ] && [ "$1" == "full" ]; then + echo "### run Example tests ###" + + stopTaosd + cd $tests_dir + + if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then + cd ../../ + else + cd ../ + fi + + pwd + cd debug/build/bin + rm -rf /var/lib/taos/* + nohup ./taosd -c /etc/taos/ > /dev/null 2>&1 & + echo "sleeping for 30 seconds" + #sleep 30 + + cd $tests_dir + echo "current dir: " + pwd + cd examples/c + echo "building applications" + make > /dev/null + totalExamplePass=0 + + echo "Running tests" + ./apitest > /dev/null 2>&1 + if [ $? != "0" ]; then + echo "apitest failed" + totalExampleFailed=`expr $totalExampleFailed + 1` + else + echo "apitest pass" + totalExamplePass=`expr $totalExamplePass + 1` + fi + + ./prepare > /dev/null 2>&1 + if [ $? != "0" ]; then + echo "prepare failed" + totalExampleFailed=`expr $totalExampleFailed + 1` + else + echo "prepare pass" + totalExamplePass=`expr $totalExamplePass + 1` + fi + + ./subscribe -test > /dev/null 2>&1 + if [ $? != "0" ]; then + echo "subscribe failed" + totalExampleFailed=`expr $totalExampleFailed + 1` + else + echo "subscribe pass" + totalExamplePass=`expr $totalExamplePass + 1` + fi + + yes |./asyncdemo 127.0.0.1 test 1000 10 > /dev/null 2>&1 + if [ $? != "0" ]; then + echo "asyncdemo failed" + totalExampleFailed=`expr $totalExampleFailed + 1` + else + echo "asyncdemo pass" + totalExamplePass=`expr $totalExamplePass + 1` + fi + + ./demo 127.0.0.1 > /dev/null 2>&1 + if [ $? != "0" ]; then + echo "demo failed" + totalExampleFailed=`expr $totalExampleFailed + 1` + else + echo "demo pass" + totalExamplePass=`expr $totalExamplePass + 1` + fi + + if [ "$totalExamplePass" -gt "0" ]; then + echo -e "\n${GREEN} ### Total $totalExamplePass examples succeed! ### ${NC}" + fi + + if [ "$totalExampleFailed" -ne "0" ]; then + echo -e "\n${RED} ### Total $totalExampleFailed examples failed! ### ${NC}" + fi + + if [ "${OS}" == "Linux" ]; then + dohavecore 1 + fi +fi + + +exit $(($totalFailed + $totalPyFailed + $totalJDBCFailed + $totalUnitFailed + $totalExampleFailed)) diff --git a/tests/test/c/CMakeLists.txt b/tests/test/c/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..2702d192d3f47022f05888f90ca89c4ef533fe44 --- /dev/null +++ b/tests/test/c/CMakeLists.txt @@ -0,0 +1,52 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8...3.20) +PROJECT(TDengine) + +INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/inc) +INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/os/inc) +INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/util/inc) +INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/common/inc) +INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/query/inc) +INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/mnode/inc) +INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/tsdb/inc) +INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/plugins/http/inc) +INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/inc) +INCLUDE_DIRECTORIES(${TD_ENTERPRISE_DIR}/src/inc) + +IF (TD_LINUX) + #add_executable(insertPerTable insertPerTable.c) + #target_link_libraries(insertPerTable taos_static pthread) + + #add_executable(insertPerRow insertPerRow.c) + #target_link_libraries(insertPerRow taos_static pthread) + + #add_executable(importOneRow importOneRow.c) + #target_link_libraries(importOneRow taos_static pthread) + + #add_executable(importPerTable importPerTable.c) + #target_link_libraries(importPerTable taos_static pthread) + + #add_executable(hashPerformance hashPerformance.c) + #target_link_libraries(hashPerformance taos_static tutil common pthread) + + #add_executable(createTablePerformance createTablePerformance.c) + #target_link_libraries(createTablePerformance taos_static tutil common pthread) + + #add_executable(createNormalTable createNormalTable.c) + #target_link_libraries(createNormalTable taos_static tutil common pthread) + + #add_executable(queryPerformance queryPerformance.c) + #target_link_libraries(queryPerformance taos_static tutil common pthread) + + #add_executable(httpTest httpTest.c) + #target_link_libraries(httpTest taos_static tutil common pthread mnode monitor http tsdb twal vnode cJson lz4) + + #add_executable(cacheTest cacheTest.c) + #target_link_libraries(cacheTest taos_static tutil common pthread mnode monitor http tsdb twal vnode cJson lz4) + + #add_executable(invalidTableId invalidTableId.c) + #target_link_libraries(invalidTableId taos_static tutil common pthread) + + #add_executable(hashIterator hashIterator.c) + #target_link_libraries(hashIterator taos_static tutil common pthread) +ENDIF() + diff --git a/tests/test/c/cacheTest.c b/tests/test/c/cacheTest.c new file mode 100644 index 0000000000000000000000000000000000000000..54aca0038ed39d8d0294a5f88acd271c10f42319 --- /dev/null +++ b/tests/test/c/cacheTest.c @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#define _DEFAULT_SOURCE +#include +#include "os.h" +#include "taos.h" +#include "tcache.h" +#include "tulog.h" +#include "tutil.h" + +#define MAX_REFRESH_TIME_SEC 2 +#define MAX_RANDOM_POINTS 20000 +#define GREEN "\033[1;32m" +#define NC "\033[0m" + +int32_t tsKeepTimeInSec = 3; +int32_t tsNumOfRows = 1000000; +int32_t tsSizeOfRow = 64 * 1024; +void * tsCacheObj = NULL; +int32_t destroyTimes = 0; + +typedef int64_t CacheTestKey; +typedef struct CacheTestRow { + int32_t index; + void ** ppRow; + void * data; +} CacheTestRow; + +CacheTestRow *initRow(int32_t index) { + CacheTestRow *row = calloc(sizeof(CacheTestRow), 1); + row->index = index; + row->data = malloc(tsSizeOfRow * sizeof(int8_t)); + return row; +} + +void detroyRow(void *data) { + CacheTestRow *row = *(CacheTestRow **)data; + free(row->data); + free(row); + destroyTimes++; + if (destroyTimes % 50000 == 0) { + pPrint("%s ===> destroyTimes:%d %s", GREEN, destroyTimes, NC); + } +} + +void initCache() { + tsCacheObj = taosCacheInit(TSDB_DATA_TYPE_BIGINT, MAX_REFRESH_TIME_SEC, true, detroyRow, "cachetest"); +} + +void putRowInCache() { + for (int index = 0; index < tsNumOfRows; ++index) { + CacheTestRow *row = initRow(index); + uint64_t key = (uint64_t)row; + void **ppRow = taosCachePut(tsCacheObj, &key, sizeof(int64_t), &row, sizeof(int64_t), tsKeepTimeInSec * 1000); + row->ppRow = ppRow; + taosCacheRelease(tsCacheObj, (void **)&ppRow, false); + } +} + +void cleanupCache() { + taosCacheCleanup(tsCacheObj); +} + +void initGetMemory() { + osInit(); + taos_init(); +} + +float getProcMemory() { + float procMemoryUsedMB = 0; + taosGetProcMemory(&procMemoryUsedMB); + return procMemoryUsedMB; +} + +void doTest() { + initCache(); + pPrint("%s initialize procMemory %f MB %s", GREEN, getProcMemory(), NC); + + putRowInCache(); + pPrint("%s insert %d rows, procMemory %f MB %s", GREEN, tsNumOfRows, getProcMemory(), NC); + + int32_t sleepMs = (MAX_REFRESH_TIME_SEC * 3) * 1000 + tsKeepTimeInSec * 1000; + taosMsleep(sleepMs); + pPrint("%s after sleep %d ms, procMemory %f MB %s", GREEN, sleepMs, getProcMemory(), NC); + + cleanupCache(); + taosMsleep(sleepMs); + pPrint("%s after cleanup cache, procMemory %f MB %s", GREEN, getProcMemory(), NC); + + malloc_trim(0); + taosMsleep(sleepMs); + pPrint("%s after malloc_trim, procMemory %f MB %s", GREEN, getProcMemory(), NC); +} + +void printHelp() { + char indent[10] = " "; + printf("Used to test the performance of cache\n"); + + printf("%s%s\n", indent, "-k"); + printf("%s%s%s%d\n", indent, indent, "KeepTimeInSec, default is ", tsKeepTimeInSec); + printf("%s%s\n", indent, "-n"); + printf("%s%s%s%d\n", indent, indent, "NumOfRows, default is ", tsNumOfRows); + printf("%s%s\n", indent, "-s"); + printf("%s%s%s%d\n", indent, indent, "SizeOfData, default is ", tsSizeOfRow); + + exit(EXIT_SUCCESS); +} + +void parseArgument(int argc, char *argv[]) { + for (int i = 1; i < argc; i++) { + if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) { + printHelp(); + exit(0); + } else if (strcmp(argv[i], "-k") == 0) { + tsKeepTimeInSec = atoi(argv[++i]); + } else if (strcmp(argv[i], "-n") == 0) { + tsNumOfRows = atoi(argv[++i]); + } else if (strcmp(argv[i], "-s") == 0) { + tsSizeOfRow = atoi(argv[++i]); + } else { + } + } + + pPrint("%s KeepTimeInSec:%d %s", GREEN, tsKeepTimeInSec, NC); + pPrint("%s NumOfRows:%d %s", GREEN, tsNumOfRows, NC); + pPrint("%s SizeOfData:%d %s", GREEN, tsSizeOfRow, NC); +} + +int main(int argc, char *argv[]) { + initGetMemory(); + parseArgument(argc, argv); + doTest(); +} diff --git a/tests/test/c/createNormalTable.c b/tests/test/c/createNormalTable.c new file mode 100644 index 0000000000000000000000000000000000000000..60253e2add1ebaa1e6c2c00b073cf13672789346 --- /dev/null +++ b/tests/test/c/createNormalTable.c @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#define _DEFAULT_SOURCE +#include "os.h" +#include "taoserror.h" +#include "taos.h" +#include "tulog.h" +#include "tutil.h" +#include "tglobal.h" +#include "hash.h" + +#define MAX_RANDOM_POINTS 20000 +#define GREEN "\033[1;32m" +#define NC "\033[0m" + +char dbName[32] = "db"; +char stableName[64] = "st"; +int32_t numOfThreads = 30; +int32_t numOfTables = 100000; +int32_t replica = 1; +int32_t numOfColumns = 2; + +typedef struct { + int32_t tableBeginIndex; + int32_t tableEndIndex; + int32_t threadIndex; + char dbName[32]; + char stableName[64]; + float createTableSpeed; + pthread_t thread; +} SThreadInfo; + +void shellParseArgument(int argc, char *argv[]); +void *threadFunc(void *param); +void createDbAndSTable(); + +int main(int argc, char *argv[]) { + shellParseArgument(argc, argv); + taos_init(); + if (replica != 0) { + createDbAndSTable(); + } + + pPrint("%d threads are spawned to create table", numOfThreads); + + pthread_attr_t thattr; + pthread_attr_init(&thattr); + pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_JOINABLE); + SThreadInfo *pInfo = (SThreadInfo *)calloc(numOfThreads, sizeof(SThreadInfo)); + + int32_t numOfTablesPerThread = numOfTables / numOfThreads; + numOfTables = numOfTablesPerThread * numOfThreads; + for (int i = 0; i < numOfThreads; ++i) { + pInfo[i].tableBeginIndex = i * numOfTablesPerThread; + pInfo[i].tableEndIndex = (i + 1) * numOfTablesPerThread; + pInfo[i].threadIndex = i; + strcpy(pInfo[i].dbName, dbName); + strcpy(pInfo[i].stableName, stableName); + pthread_create(&(pInfo[i].thread), &thattr, threadFunc, (void *)(pInfo + i)); + } + + taosMsleep(300); + for (int i = 0; i < numOfThreads; i++) { + pthread_join(pInfo[i].thread, NULL); + } + + float createTableSpeed = 0; + for (int i = 0; i < numOfThreads; ++i) { + createTableSpeed += pInfo[i].createTableSpeed; + } + + pPrint("%s total speed:%.1f tables/second, threads:%d %s", GREEN, createTableSpeed, numOfThreads, NC); + + pthread_attr_destroy(&thattr); + free(pInfo); +} + +void createDbAndSTable() { + pPrint("start to create db and stable"); + char qstr[64000]; + + TAOS *con = taos_connect(NULL, "root", "taosdata", NULL, 0); + if (con == NULL) { + pError("failed to connect to DB, reason:%s", taos_errstr(con)); + exit(1); + } + + sprintf(qstr, "create database if not exists %s replica %d", dbName, replica); + TAOS_RES *pSql = taos_query(con, qstr); + int32_t code = taos_errno(pSql); + if (code != 0) { + pError("failed to create database:%s, sql:%s, code:%d reason:%s", dbName, qstr, taos_errno(con), taos_errstr(con)); + exit(0); + } + taos_free_result(pSql); + + sprintf(qstr, "use %s", dbName); + pSql = taos_query(con, qstr); + code = taos_errno(pSql); + if (code != 0) { + pError("failed to use db, code:%d reason:%s", taos_errno(con), taos_errstr(con)); + exit(0); + } + taos_free_result(pSql); + + taos_close(con); +} + +void *threadFunc(void *param) { + SThreadInfo *pInfo = (SThreadInfo *)param; + char qstr[65000]; + int code; + + TAOS *con = taos_connect(NULL, "root", "taosdata", NULL, 0); + if (con == NULL) { + pError("index:%d, failed to connect to DB, reason:%s", pInfo->threadIndex, taos_errstr(con)); + exit(1); + } + + sprintf(qstr, "use %s", pInfo->dbName); + TAOS_RES *pSql = taos_query(con, qstr); + taos_free_result(pSql); + + int64_t startMs = taosGetTimestampMs(); + + if (replica != 0) { + for (int32_t t = pInfo->tableBeginIndex; t < pInfo->tableEndIndex; ++t) { + sprintf(qstr, "create table %s%d (ts timestamp, i int)", stableName, t); + TAOS_RES *pSql = taos_query(con, qstr); + code = taos_errno(pSql); + if (code != 0) { + pError("failed to create table %s%d, reason:%s", stableName, t, tstrerror(code)); + } + taos_free_result(pSql); + } + } else { + for (int32_t t = pInfo->tableBeginIndex; t < pInfo->tableEndIndex; ++t) { + sprintf(qstr, "insert into %s%d values(now, 1)", stableName, t); + TAOS_RES *pSql = taos_query(con, qstr); + code = taos_errno(pSql); + if (code != 0) { + if (code != TSDB_CODE_MND_INVALID_TABLE_NAME) { + pError("failed to create table %s%d, reason:%s", stableName, t, tstrerror(code)); + } + if (code == TSDB_CODE_VND_INVALID_VGROUP_ID) { + exit(0); + } + } + taos_free_result(pSql); + } + } + + float createTableSpeed = 0; + for (int i = 0; i < numOfThreads; ++i) { + createTableSpeed += pInfo[i].createTableSpeed; + } + + int64_t endMs = taosGetTimestampMs(); + int32_t totalTables = pInfo->tableEndIndex - pInfo->tableBeginIndex; + float seconds = (endMs - startMs) / 1000.0; + float speed = totalTables / seconds; + pInfo->createTableSpeed = speed; + + pPrint("thread:%d, time:%.2f sec, speed:%.1f tables/second, ", pInfo->threadIndex, seconds, speed); + taos_close(con); + + return 0; +} + +void printHelp() { + char indent[10] = " "; + printf("Used to test the performance while create table\n"); + + printf("%s%s\n", indent, "-c"); + printf("%s%s%s%s\n", indent, indent, "Configuration directory, default is ", configDir); + printf("%s%s\n", indent, "-d"); + printf("%s%s%s%s\n", indent, indent, "The name of the database to be created, default is ", dbName); + printf("%s%s\n", indent, "-s"); + printf("%s%s%s%s\n", indent, indent, "The name of the super table to be created, default is ", stableName); + printf("%s%s\n", indent, "-t"); + printf("%s%s%s%d\n", indent, indent, "numOfThreads, default is ", numOfThreads); + printf("%s%s\n", indent, "-n"); + printf("%s%s%s%d\n", indent, indent, "numOfTables, default is ", numOfTables); + printf("%s%s\n", indent, "-r"); + printf("%s%s%s%d\n", indent, indent, "replica, default is ", replica); + printf("%s%s\n", indent, "-columns"); + printf("%s%s%s%d\n", indent, indent, "numOfColumns, default is ", numOfColumns); + + exit(EXIT_SUCCESS); +} + +void shellParseArgument(int argc, char *argv[]) { + for (int i = 1; i < argc; i++) { + if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) { + printHelp(); + exit(0); + } else if (strcmp(argv[i], "-d") == 0) { + strcpy(dbName, argv[++i]); + } else if (strcmp(argv[i], "-c") == 0) { + strcpy(configDir, argv[++i]); + } else if (strcmp(argv[i], "-s") == 0) { + strcpy(stableName, argv[++i]); + } else if (strcmp(argv[i], "-t") == 0) { + numOfThreads = atoi(argv[++i]); + } else if (strcmp(argv[i], "-n") == 0) { + numOfTables = atoi(argv[++i]); + } else if (strcmp(argv[i], "-r") == 0) { + replica = atoi(argv[++i]); + } else if (strcmp(argv[i], "-columns") == 0) { + numOfColumns = atoi(argv[++i]); + } else { + } + } + + pPrint("%s dbName:%s %s", GREEN, dbName, NC); + pPrint("%s stableName:%s %s", GREEN, stableName, NC); + pPrint("%s configDir:%s %s", GREEN, configDir, NC); + pPrint("%s numOfTables:%d %s", GREEN, numOfTables, NC); + pPrint("%s numOfThreads:%d %s", GREEN, numOfThreads, NC); + pPrint("%s numOfColumns:%d %s", GREEN, numOfColumns, NC); + pPrint("%s replica:%d %s", GREEN, replica, NC); + + pPrint("%s start create table performace test %s", GREEN, NC); +} diff --git a/tests/test/c/createTablePerformance.c b/tests/test/c/createTablePerformance.c new file mode 100644 index 0000000000000000000000000000000000000000..b94c687f2cba7310949b0a3b12b6f4fc007e5a9a --- /dev/null +++ b/tests/test/c/createTablePerformance.c @@ -0,0 +1,225 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#define _DEFAULT_SOURCE +#include "os.h" +#include "taoserror.h" +#include "taos.h" +#include "tulog.h" +#include "tutil.h" +#include "tglobal.h" +#include "hash.h" + +#define MAX_RANDOM_POINTS 20000 +#define GREEN "\033[1;32m" +#define NC "\033[0m" + +char dbName[32] = "db"; +char stableName[64] = "st"; +int32_t numOfThreads = 30; +int32_t numOfTables = 100000; +int32_t replica = 1; +int32_t numOfColumns = 2; +TAOS * con = NULL; + +typedef struct { + int32_t tableBeginIndex; + int32_t tableEndIndex; + int32_t threadIndex; + char dbName[32]; + char stableName[64]; + float createTableSpeed; + pthread_t thread; +} SThreadInfo; + +void shellParseArgument(int argc, char *argv[]); +void *threadFunc(void *param); +void createDbAndSTable(); + +int main(int argc, char *argv[]) { + shellParseArgument(argc, argv); + taos_init(); + createDbAndSTable(); + + pPrint("%d threads are spawned to create table", numOfThreads); + + pthread_attr_t thattr; + pthread_attr_init(&thattr); + pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_JOINABLE); + SThreadInfo *pInfo = (SThreadInfo *)calloc(numOfThreads, sizeof(SThreadInfo)); + + int32_t numOfTablesPerThread = numOfTables / numOfThreads; + numOfTables = numOfTablesPerThread * numOfThreads; + for (int i = 0; i < numOfThreads; ++i) { + pInfo[i].tableBeginIndex = i * numOfTablesPerThread; + pInfo[i].tableEndIndex = (i + 1) * numOfTablesPerThread; + pInfo[i].threadIndex = i; + strcpy(pInfo[i].dbName, dbName); + strcpy(pInfo[i].stableName, stableName); + pthread_create(&(pInfo[i].thread), &thattr, threadFunc, (void *)(pInfo + i)); + } + + taosMsleep(300); + for (int i = 0; i < numOfThreads; i++) { + pthread_join(pInfo[i].thread, NULL); + } + + float createTableSpeed = 0; + for (int i = 0; i < numOfThreads; ++i) { + createTableSpeed += pInfo[i].createTableSpeed; + } + + pPrint("%s total speed:%.1f tables/second, threads:%d %s", GREEN, createTableSpeed, numOfThreads, NC); + + pthread_attr_destroy(&thattr); + free(pInfo); + taos_close(con); +} + +void createDbAndSTable() { + pPrint("start to create db and stable"); + char qstr[64000]; + + con = taos_connect(NULL, "root", "taosdata", NULL, 0); + if (con == NULL) { + pError("failed to connect to DB, reason:%s", taos_errstr(con)); + exit(1); + } + + sprintf(qstr, "create database if not exists %s replica %d", dbName, replica); + TAOS_RES *pSql = taos_query(con, qstr); + int32_t code = taos_errno(pSql); + if (code != 0) { + pError("failed to create database:%s, sql:%s, code:%d reason:%s", dbName, qstr, taos_errno(con), taos_errstr(con)); + exit(0); + } + taos_free_result(pSql); + + sprintf(qstr, "use %s", dbName); + pSql = taos_query(con, qstr); + code = taos_errno(pSql); + if (code != 0) { + pError("failed to use db, code:%d reason:%s", taos_errno(con), taos_errstr(con)); + exit(0); + } + taos_free_result(pSql); + + int len = sprintf(qstr, "create table if not exists %s(ts timestamp", stableName); + for (int32_t f = 0; f < numOfColumns - 1; ++f) { + len += sprintf(qstr + len, ", f%d double", f); + } + sprintf(qstr + len, ") tags(t int)"); + + pSql = taos_query(con, qstr); + code = taos_errno(pSql); + if (code != 0) { + pError("failed to create stable, code:%d reason:%s", taos_errno(con), taos_errstr(con)); + exit(0); + } + taos_free_result(pSql); +} + +void *threadFunc(void *param) { + SThreadInfo *pInfo = (SThreadInfo *)param; + char qstr[65000]; + int code; + + sprintf(qstr, "use %s", pInfo->dbName); + TAOS_RES *pSql = taos_query(con, qstr); + taos_free_result(pSql); + + int64_t startMs = taosGetTimestampMs(); + + for (int32_t t = pInfo->tableBeginIndex; t < pInfo->tableEndIndex; ++t) { + sprintf(qstr, "create table if not exists %s%d using %s tags(%d)", stableName, t, stableName, t); + TAOS_RES *pSql = taos_query(con, qstr); + code = taos_errno(pSql); + if (code != 0) { + pError("failed to create table %s%d, reason:%s", stableName, t, tstrerror(code)); + } + taos_free_result(pSql); + } + + float createTableSpeed = 0; + for (int i = 0; i < numOfThreads; ++i) { + createTableSpeed += pInfo[i].createTableSpeed; + } + + int64_t endMs = taosGetTimestampMs(); + int32_t totalTables = pInfo->tableEndIndex - pInfo->tableBeginIndex; + float seconds = (endMs - startMs) / 1000.0; + float speed = totalTables / seconds; + pInfo->createTableSpeed = speed; + + pPrint("thread:%d, time:%.2f sec, speed:%.1f tables/second, ", pInfo->threadIndex, seconds, speed); + + return 0; +} + +void printHelp() { + char indent[10] = " "; + printf("Used to test the performance while create table\n"); + + printf("%s%s\n", indent, "-c"); + printf("%s%s%s%s\n", indent, indent, "Configuration directory, default is ", configDir); + printf("%s%s\n", indent, "-d"); + printf("%s%s%s%s\n", indent, indent, "The name of the database to be created, default is ", dbName); + printf("%s%s\n", indent, "-s"); + printf("%s%s%s%s\n", indent, indent, "The name of the super table to be created, default is ", stableName); + printf("%s%s\n", indent, "-t"); + printf("%s%s%s%d\n", indent, indent, "numOfThreads, default is ", numOfThreads); + printf("%s%s\n", indent, "-n"); + printf("%s%s%s%d\n", indent, indent, "numOfTables, default is ", numOfTables); + printf("%s%s\n", indent, "-r"); + printf("%s%s%s%d\n", indent, indent, "replica, default is ", replica); + printf("%s%s\n", indent, "-columns"); + printf("%s%s%s%d\n", indent, indent, "numOfColumns, default is ", numOfColumns); + + exit(EXIT_SUCCESS); +} + +void shellParseArgument(int argc, char *argv[]) { + for (int i = 1; i < argc; i++) { + if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) { + printHelp(); + exit(0); + } else if (strcmp(argv[i], "-d") == 0) { + strcpy(dbName, argv[++i]); + } else if (strcmp(argv[i], "-c") == 0) { + strcpy(configDir, argv[++i]); + } else if (strcmp(argv[i], "-s") == 0) { + strcpy(stableName, argv[++i]); + } else if (strcmp(argv[i], "-t") == 0) { + numOfThreads = atoi(argv[++i]); + } else if (strcmp(argv[i], "-n") == 0) { + numOfTables = atoi(argv[++i]); + } else if (strcmp(argv[i], "-r") == 0) { + replica = atoi(argv[++i]); + } else if (strcmp(argv[i], "-columns") == 0) { + numOfColumns = atoi(argv[++i]); + } else { + } + } + + pPrint("%s dbName:%s %s", GREEN, dbName, NC); + pPrint("%s stableName:%s %s", GREEN, stableName, NC); + pPrint("%s configDir:%s %s", GREEN, configDir, NC); + pPrint("%s numOfTables:%d %s", GREEN, numOfTables, NC); + pPrint("%s numOfThreads:%d %s", GREEN, numOfThreads, NC); + pPrint("%s numOfColumns:%d %s", GREEN, numOfColumns, NC); + pPrint("%s replica:%d %s", GREEN, replica, NC); + + pPrint("%s start create table performace test %s", GREEN, NC); +} diff --git a/tests/test/c/hashIterator.c b/tests/test/c/hashIterator.c new file mode 100644 index 0000000000000000000000000000000000000000..cbd8a0895ebedd4fb0e3c448e4b6865fc0d8a454 --- /dev/null +++ b/tests/test/c/hashIterator.c @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#define _DEFAULT_SOURCE +#include "os.h" +#include "taos.h" +#include "tulog.h" +#include "tutil.h" +#include "hash.h" + +typedef struct HashTestRow { + int32_t keySize; + char key[100]; +} HashTestRow; + +int main(int argc, char *argv[]) { + _hash_fn_t hashFp = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); + void * hashHandle = taosHashInit(100, hashFp, true, HASH_ENTRY_LOCK); + + pPrint("insert 3 rows to hash"); + for (int32_t t = 0; t < 3; ++t) { + HashTestRow row = {0}; + row.keySize = sprintf(row.key, "0.db.st%d", t); + + taosHashPut(hashHandle, row.key, row.keySize, &row, sizeof(HashTestRow)); + } + + pPrint("start iterator"); + HashTestRow *row = taosHashIterate(hashHandle, NULL); + while (row) { + pPrint("drop key:%s", row->key); + taosHashRemove(hashHandle, row->key, row->keySize); + + pPrint("get rows from hash"); + for (int32_t t = 0; t < 3; ++t) { + HashTestRow r = {0}; + r.keySize = sprintf(r.key, "0.db.st%d", t); + + void *result = taosHashGet(hashHandle, r.key, r.keySize); + pPrint("get key:%s result:%p", r.key, result); + } + + //Before getting the next iterator, the object just deleted can be obtained + row = taosHashIterate(hashHandle, row); + } + + pPrint("stop iterator"); + taosHashCancelIterate(hashHandle, row); + + pPrint("get rows from hash"); + for (int32_t t = 0; t < 3; ++t) { + HashTestRow r = {0}; + r.keySize = sprintf(r.key, "0.db.st%d", t); + + void *result = taosHashGet(hashHandle, r.key, r.keySize); + pPrint("get key:%s result:%p", r.key, result); + } + + return 0; +} \ No newline at end of file diff --git a/tests/test/c/hashPerformance.c b/tests/test/c/hashPerformance.c new file mode 100644 index 0000000000000000000000000000000000000000..111ea25a09823fbbeeda3c990d86af849c3821d8 --- /dev/null +++ b/tests/test/c/hashPerformance.c @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#define _DEFAULT_SOURCE +#include "os.h" +#include "taos.h" +#include "tulog.h" +#include "tutil.h" +#include "hash.h" + +#define MAX_RANDOM_POINTS 20000 +#define GREEN "\033[1;32m" +#define NC "\033[0m" + +int32_t capacity = 128; +int32_t q1Times = 10; +int32_t q2Times = 10; +int32_t keyNum = 100000; +int32_t printInterval = 1000; +void * hashHandle; +pthread_t thread; + +typedef struct HashTestRow { + int32_t keySize; + char key[100]; +} HashTestRow; + +void shellParseArgument(int argc, char *argv[]); + +void testHashPerformance() { + int64_t initialMs = taosGetTimestampMs(); + _hash_fn_t hashFp = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); + hashHandle = taosHashInit(128, hashFp, true, HASH_NO_LOCK); + + int64_t startMs = taosGetTimestampMs(); + float seconds = (startMs - initialMs) / 1000.0; + pPrint("initial time %.2f sec", seconds); + + for (int32_t t = 1; t <= keyNum; ++t) { + HashTestRow row = {0}; + row.keySize = sprintf(row.key, "0.db.st%d", t); + + for (int32_t q = 0; q < q1Times; q++) { + taosHashGet(hashHandle, row.key, row.keySize); + } + + taosHashPut(hashHandle, row.key, row.keySize, &row, sizeof(HashTestRow)); + + for (int32_t q = 0; q < q2Times; q++) { + taosHashGet(hashHandle, row.key, row.keySize); + } + + // test iterator + { + HashTestRow *row = taosHashIterate(hashHandle, NULL); + while (row) { + taosHashGet(hashHandle, row->key, row->keySize); + row = taosHashIterate(hashHandle, row); + } + } + + if (t % printInterval == 0) { + int64_t endMs = taosGetTimestampMs(); + int64_t hashSize = taosHashGetSize(hashHandle); + float seconds = (endMs - startMs) / 1000.0; + float speed = printInterval / seconds; + pPrint("time:%.2f sec, speed:%.1f rows/second, hashSize:%ld", seconds, speed, hashSize); + startMs = endMs; + } + } + + int64_t endMs = taosGetTimestampMs(); + int64_t hashSize = taosHashGetSize(hashHandle); + seconds = (endMs - initialMs) / 1000.0; + float speed = hashSize / seconds; + + pPrint("total time:%.2f sec, avg speed:%.1f rows/second, hashSize:%ld", seconds, speed, hashSize); + taosHashCleanup(hashHandle); +} + +void *multiThreadFunc(void *param) { + for (int i = 0; i < 100; ++i) { + taosMsleep(1000); + HashTestRow *row = taosHashIterate(hashHandle, NULL); + while (row) { + taosHashGet(hashHandle, row->key, row->keySize); + row = taosHashIterate(hashHandle, row); + } + int64_t hashSize = taosHashGetSize(hashHandle); + pPrint("i:%d hashSize:%ld", i, hashSize); + } + + return NULL; +} + +void multiThreadTest() { + pthread_attr_t thattr; + pthread_attr_init(&thattr); + pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_JOINABLE); + + // Start threads to write + pthread_create(&thread, &thattr, multiThreadFunc, NULL); +} + +int main(int argc, char *argv[]) { + shellParseArgument(argc, argv); + multiThreadTest(); + testHashPerformance(); + pthread_join(thread, NULL); +} + +void printHelp() { + char indent[10] = " "; + printf("Used to test the performance of cache\n"); + + printf("%s%s\n", indent, "-k"); + printf("%s%s%s%d\n", indent, indent, "key num, default is ", keyNum); + printf("%s%s\n", indent, "-p"); + printf("%s%s%s%d\n", indent, indent, "print interval while put into hash, default is ", printInterval); + printf("%s%s\n", indent, "-c"); + printf("%s%s%s%d\n", indent, indent, "the initial capacity of hash ", capacity); + printf("%s%s\n", indent, "-q1"); + printf("%s%s%s%d\n", indent, indent, "query times before put into hash", q1Times); + printf("%s%s\n", indent, "-q2"); + printf("%s%s%s%d\n", indent, indent, "query times after put into hash", q2Times); + + exit(EXIT_SUCCESS); +} + +void shellParseArgument(int argc, char *argv[]) { + for (int i = 1; i < argc; i++) { + if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) { + printHelp(); + exit(0); + } else if (strcmp(argv[i], "-k") == 0) { + keyNum = atoi(argv[++i]); + } else if (strcmp(argv[i], "-p") == 0) { + printInterval = atoi(argv[++i]); + } else if (strcmp(argv[i], "-c") == 0) { + capacity = atoi(argv[++i]); + } else if (strcmp(argv[i], "-q1") == 0) { + q1Times = atoi(argv[++i]); + } else if (strcmp(argv[i], "-q2") == 0) { + q2Times = atoi(argv[++i]); + } else { + } + } + + pPrint("%s capacity:%d %s", GREEN, capacity, NC); + pPrint("%s printInterval:%d %s", GREEN, printInterval, NC); + pPrint("%s q1Times:%d %s", GREEN, q1Times, NC); + pPrint("%s q2Times:%d %s", GREEN, q2Times, NC); + pPrint("%s keyNum:%d %s", GREEN, keyNum, NC); +} diff --git a/tests/test/c/httpTest.c b/tests/test/c/httpTest.c new file mode 100644 index 0000000000000000000000000000000000000000..261546770eed889894ec93cbbdfb2cdad9f4cad0 --- /dev/null +++ b/tests/test/c/httpTest.c @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "os.h" +#include "os.h" +#include "tglobal.h" +#include "taoserror.h" +#include "httpSystem.h" + +void signal_handler(int signum) { + httpStopSystem(); + httpCleanUpSystem(); + exit(EXIT_SUCCESS); +} + +int main(int argc, char *argv[]) { + struct sigaction act; + act.sa_handler = signal_handler; + sigaction(SIGTERM, &act, NULL); + sigaction(SIGHUP, &act, NULL); + sigaction(SIGINT, &act, NULL); + sigaction(SIGABRT, &act, NULL); + + // Initialize the system + if (httpInitSystem() < 0) { + exit(EXIT_FAILURE); + } + + if (httpStartSystem() < 0) { + exit(EXIT_FAILURE); + } + + while (1) { + sleep(1000); + } +} diff --git a/tests/test/c/importOneRow.c b/tests/test/c/importOneRow.c new file mode 100644 index 0000000000000000000000000000000000000000..858926106c14afa6fb35bb66d44075c04add89f0 --- /dev/null +++ b/tests/test/c/importOneRow.c @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#define _DEFAULT_SOURCE +#include "os.h" +#include "taos.h" +#include "tulog.h" +#include "ttimer.h" +#include "tutil.h" +#include "tglobal.h" + +#define MAX_RANDOM_POINTS 20000 +#define GREEN "\033[1;32m" +#define NC "\033[0m" + +void taos_error(TAOS *taos); +void* taos_execute(void *param); + +typedef struct { + pthread_t pid; + int index; +} ThreadObj; + +int threadNum = 1; +int rowNum = 1000; +int replica = 1; + +void printHelp() { + char indent[10] = " "; + printf("Used to test the performance of TDengine\n After writing one row of data to all tables, write the next row\n"); + + printf("%s%s\n", indent, "-r"); + printf("%s%s%s%d\n", indent, indent, "Number of records to write table, default is ", rowNum); + printf("%s%s\n", indent, "-t"); + printf("%s%s%s%d\n", indent, indent, "Number of threads to be used, default is ", threadNum); + printf("%s%s\n", indent, "-replica"); + printf("%s%s%s%d\n", indent, indent, "Database parameters replica, default is ", replica); + + exit(EXIT_SUCCESS); +} + +void shellParseArgument(int argc, char *argv[]) { + for (int i = 1; i < argc; i++) { + if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) { + printHelp(); + exit(0); + } else if (strcmp(argv[i], "-r") == 0) { + rowNum = atoi(argv[++i]); + } else if (strcmp(argv[i], "-t") == 0) { + threadNum = atoi(argv[++i]); + } else if (strcmp(argv[i], "-replica") == 0) { + replica = atoi(argv[++i]); + } else { + } + } + + pPrint("%s rowNum:%d %s", GREEN, rowNum, NC); + pPrint("%s threadNum:%d %s", GREEN, threadNum, NC); + pPrint("%s replica:%d %s", GREEN, replica, NC); +} + +int main(int argc, char *argv[]) { + shellParseArgument(argc, argv); + + taos_init(); + + ThreadObj *threads = calloc(threadNum, sizeof(ThreadObj)); + for (int i = 0; i < threadNum; ++i) { + ThreadObj * pthread = threads + i; + pthread_attr_t thattr; + pthread->index = i; + pthread_attr_init(&thattr); + pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_JOINABLE); + pthread_create(&pthread->pid, &thattr, taos_execute, pthread); + } + + for (int i = 0; i < threadNum; i++) { + pthread_join(threads[i].pid, NULL); + } + + printf("all finished\n"); + + return 0; +} + +void taos_error(TAOS *con) { + fprintf(stderr, "TDengine error: %s\n", taos_errstr(con)); + taos_close(con); + exit(1); +} + +void* taos_execute(void *param) { + ThreadObj *pThread = (ThreadObj *)param; + + char fqdn[TSDB_FQDN_LEN]; + uint16_t port; + + taosGetFqdnPortFromEp(tsFirst, fqdn, &port); + + void *taos = taos_connect(fqdn, "root", "taosdata", NULL, port); + if (taos == NULL) taos_error(taos); + + char sql[1024] = {0}; + sprintf(sql, "create database if not exists db replica %d", replica); + taos_query(taos, sql); + + sprintf(sql, "create table if not exists db.t%d (ts timestamp, i int, j float, k double)", pThread->index); + taos_query(taos, sql); + + int64_t timestamp = 1530374400000L; + + sprintf(sql, "insert into db.t%d values(%ld, %d, %d, %d)", pThread->index, timestamp, 0, 0, 0); + TAOS_RES *pSql = taos_query(taos, sql); + int code = taos_errno(pSql); + if (code != 0) + { + printf("error code:%d, sql:%s\n", code, sql); + taos_free_result(pSql); + taos_close(taos); + return NULL; + } + int affectrows = taos_affected_rows(taos); + if (affectrows != 1) + { + printf("affect rows:%d, sql:%s\n", affectrows, sql); + taos_free_result(pSql); + taos_close(taos); + return NULL; + } + taos_free_result(pSql); + pSql = NULL; + + + timestamp -= 1000; + + int total_affect_rows = affectrows; + + for (int i = 1; i < rowNum; ++i) { + sprintf(sql, "import into db.t%d values(%ld, %d, %d, %d)", pThread->index, timestamp, i, i, i); + + pSql = taos_query(taos, sql); + code = taos_errno(pSql); + if (code != 0) + { + printf("error code:%d, sql:%s\n", code, sql); + taos_free_result(pSql); + pSql = NULL; + taos_close(taos); + return NULL; + } + int affectrows = taos_affected_rows(taos); + if (affectrows != 1) { + printf("affect rows:%d, sql:%s\n", affectrows, sql); + taos_free_result(pSql); + pSql = NULL; + taos_close(taos); + } + + total_affect_rows += affectrows; + taos_free_result(pSql); + pSql = NULL; + + timestamp -= 1000; + } + + printf("thread:%d run finished total_affect_rows:%d\n", pThread->index, total_affect_rows); + taos_close(taos); + + return NULL; +} diff --git a/tests/test/c/importPerTable.c b/tests/test/c/importPerTable.c new file mode 100644 index 0000000000000000000000000000000000000000..68f78980509d5956f6fc177d7e940af5345b68a7 --- /dev/null +++ b/tests/test/c/importPerTable.c @@ -0,0 +1,356 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#define _DEFAULT_SOURCE +#include "os.h" +#include "taos.h" +#include "tulog.h" +#include "ttimer.h" +#include "tutil.h" +#include "tglobal.h" +#include "osTime.h" + +#define MAX_RANDOM_POINTS 20000 +#define GREEN "\033[1;32m" +#define NC "\033[0m" + +typedef struct { + int64_t rowsPerTable; + int64_t pointsPerTable; + int64_t tableBeginIndex; + int64_t tableEndIndex; + int threadIndex; + char dbName[32]; + char stableName[64]; + pthread_t thread; +} SInfo; + +void *syncTest(void *param); +void generateRandomPoints(); +void shellParseArgument(int argc, char *argv[]); +void createDbAndTable(); +void insertData(); + +int32_t randomData[MAX_RANDOM_POINTS]; +int64_t rowsPerTable = 1000000; +int64_t pointsPerTable = 1; +int64_t numOfThreads = 10; +int64_t numOfTablesPerThread = 100; +char dbName[32] = "db"; +char stableName[64] = "st"; +int64_t totalUs = 0; +int64_t reqNum = 0; +int64_t maxUs = 0; +int64_t minUs = 100000000; + +int main(int argc, char *argv[]) { + shellParseArgument(argc, argv); + generateRandomPoints(); + taos_init(); + createDbAndTable(); + insertData(); + int64_t avgUs = totalUs / reqNum; + pError("%s totalUs:%ld, avgUs:%ld maxUs:%ld minUs:%ld reqNum:%ld %s\n", GREEN, totalUs, avgUs, maxUs, minUs, reqNum, NC); +} + +int32_t query(void *con, char *qstr) { + int64_t begin = taosGetTimestampUs(); + + TAOS_RES *pSql = taos_query(con, qstr); + int32_t code = taos_errno(pSql); + if (code != 0) { + pError("failed to exec sql:%s, code:%d reason:%s", qstr, taos_errno(con), taos_errstr(con)); + exit(0); + } + taos_free_result(pSql); + + int64_t us = taosGetTimestampUs() - begin; + maxUs = MAX(us, maxUs); + minUs = MIN(us, minUs); + atomic_add_fetch_64(&totalUs, us); + atomic_add_fetch_64(&reqNum, 1); + if (reqNum > 100000) { + int64_t avgUs = totalUs / reqNum; + if (us > avgUs * 100) { + pError("sql:%s", qstr); + pError("%s totalUs:%ld, avgUs:%ld maxUs:%ld minUs:%ld reqNum:%ld %s\n", GREEN, totalUs, avgUs, maxUs, minUs, + reqNum, NC); + taosMsleep(1000); + exit(0); + } + } + + return code; +} + +void createDbAndTable() { + pPrint("start to create table"); + + TAOS * con; + struct timeval systemTime; + int64_t st, et; + char qstr[64000]; + + char fqdn[TSDB_FQDN_LEN]; + uint16_t port; + + taosGetFqdnPortFromEp(tsFirst, fqdn, &port); + + con = taos_connect(fqdn, "root", "taosdata", NULL, port); + if (con == NULL) { + pError("failed to connect to DB, reason:%s", taos_errstr(con)); + exit(1); + } + + sprintf(qstr, "create database if not exists %s", dbName); + if (query(con, qstr)) { + pError("failed to create database:%s, code:%d reason:%s", dbName, taos_errno(con), taos_errstr(con)); + exit(0); + } + + sprintf(qstr, "use %s", dbName); + if (query(con, qstr)) { + pError("failed to use db, code:%d reason:%s", taos_errno(con), taos_errstr(con)); + exit(0); + } + + gettimeofday(&systemTime, NULL); + st = systemTime.tv_sec * 1000000 + systemTime.tv_usec; + int64_t totalTables = numOfTablesPerThread * numOfThreads; + + if (strcmp(stableName, "no") != 0) { + int len = sprintf(qstr, "create table if not exists %s(ts timestamp", stableName); + for (int64_t f = 0; f < pointsPerTable; ++f) { + len += sprintf(qstr + len, ", f%ld double", f); + } + sprintf(qstr + len, ") tags(t int)"); + + if (query(con, qstr)) { + pError("failed to create stable, code:%d reason:%s", taos_errno(con), taos_errstr(con)); + exit(0); + } + + for (int64_t t = 0; t < totalTables; ++t) { + sprintf(qstr, "create table if not exists %s%ld using %s tags(%ld)", stableName, t, stableName, t); + if (query(con, qstr)) { + pError("failed to create table %s%" PRId64 ", reason:%s", stableName, t, taos_errstr(con)); + exit(0); + } + } + } else { + for (int64_t t = 0; t < totalTables; ++t) { + int len = sprintf(qstr, "create table if not exists %s%ld(ts timestamp", stableName, t); + for (int64_t f = 0; f < pointsPerTable; ++f) { + len += sprintf(qstr + len, ", f%ld double", f); + } + sprintf(qstr + len, ")"); + + if (query(con, qstr)) { + pError("failed to create table %s%ld, reason:%s", stableName, t, taos_errstr(con)); + exit(0); + } + } + } + + gettimeofday(&systemTime, NULL); + et = systemTime.tv_sec * 1000000 + systemTime.tv_usec; + pPrint("%.1f seconds to create %ld tables", (et - st) / 1000.0 / 1000.0, totalTables); +} + +void insertData() { + struct timeval systemTime; + int64_t st, et; + + gettimeofday(&systemTime, NULL); + st = systemTime.tv_sec * 1000000 + systemTime.tv_usec; + + pPrint("%" PRId64 " threads are spawned to import data", numOfThreads); + + pthread_attr_t thattr; + pthread_attr_init(&thattr); + pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_JOINABLE); + SInfo *pInfo = (SInfo *)malloc(sizeof(SInfo) * numOfThreads); + + // Start threads to write + for (int i = 0; i < numOfThreads; ++i) { + pInfo[i].rowsPerTable = rowsPerTable; + pInfo[i].pointsPerTable = pointsPerTable; + pInfo[i].tableBeginIndex = i * numOfTablesPerThread; + pInfo[i].tableEndIndex = (i + 1) * numOfTablesPerThread; + pInfo[i].threadIndex = i; + strcpy(pInfo[i].dbName, dbName); + strcpy(pInfo[i].stableName, stableName); + pthread_create(&(pInfo[i].thread), &thattr, syncTest, (void *)(pInfo + i)); + } + + taosMsleep(300); + for (int i = 0; i < numOfThreads; i++) { + pthread_join(pInfo[i].thread, NULL); + } + + gettimeofday(&systemTime, NULL); + et = systemTime.tv_sec * 1000000 + systemTime.tv_usec; + double seconds = (et - st) / 1000.0 / 1000.0; + + int64_t totalTables = numOfTablesPerThread * numOfThreads; + int64_t totalRows = totalTables * rowsPerTable; + int64_t totalPoints = totalTables * rowsPerTable * pointsPerTable; + double speedOfRows = totalRows / seconds; + double speedOfPoints = totalPoints / seconds; + + pPrint( + "%sall threads:%ld finished, use %.1lf seconds, tables:%.ld rows:%ld points:%ld, speed RowsPerSecond:%.1lf " + "PointsPerSecond:%.1lf%s", + GREEN, numOfThreads, seconds, totalTables, totalRows, totalPoints, speedOfRows, speedOfPoints, NC); + + pPrint("threads exit"); + + pthread_attr_destroy(&thattr); + free(pInfo); +} + +void *syncTest(void *param) { + TAOS * con; + SInfo * pInfo = (SInfo *)param; + struct timeval systemTime; + int64_t st, et; + char qstr[65000]; + int maxBytes = 60000; + + pPrint("thread:%d, start to run", pInfo->threadIndex); + char fqdn[TSDB_FQDN_LEN]; + uint16_t port; + + taosGetFqdnPortFromEp(tsFirst, fqdn, &port); + + con = taos_connect(fqdn, "root", "taosdata", NULL, port); + if (con == NULL) { + pError("index:%d, failed to connect to DB, reason:%s", pInfo->threadIndex, taos_errstr(con)); + exit(1); + } + + sprintf(qstr, "use %s", pInfo->dbName); + query(con, qstr); + + gettimeofday(&systemTime, NULL); + st = systemTime.tv_sec * 1000000 + systemTime.tv_usec; + + int64_t start = 1587225600000; + int64_t interval = 1000; // 1000 ms + + char *sql = qstr; + char inserStr[] = "import into"; + int len = sprintf(sql, "%s", inserStr); + + for (int64_t table = pInfo->tableBeginIndex; table < pInfo->tableEndIndex; ++table) { + len += sprintf(sql + len, " %s%ld values", pInfo->stableName, table); + for (int64_t row = 0; row < pInfo->rowsPerTable; row++) { + len += sprintf(sql + len, "(%ld", start - row * interval); + for (int64_t point = 0; point < pInfo->pointsPerTable; ++point) { + len += sprintf(sql + len, ",%d", randomData[(123 * table + 456 * row + 789 * point) % MAX_RANDOM_POINTS]); + // len += sprintf(sql + len, ",%ld", row); + } + len += sprintf(sql + len, ")"); + if (len > maxBytes) { + if (query(con, qstr)) { + pError("thread:%d, failed to import table:%s%ld row:%ld, reason:%s", pInfo->threadIndex, pInfo->stableName, + table, row, taos_errstr(con)); + } + + // "insert into" + len = sprintf(sql, "%s", inserStr); + + // "insert into st1 values" + if (row != pInfo->rowsPerTable - 1) { + len += sprintf(sql + len, " %s%ld values", pInfo->stableName, table); + } + } + } + } + + if (len != strlen(inserStr)) { + query(con, qstr); + } + + gettimeofday(&systemTime, NULL); + et = systemTime.tv_sec * 1000000 + systemTime.tv_usec; + int64_t totalTables = pInfo->tableEndIndex - pInfo->tableBeginIndex; + int64_t totalRows = totalTables * pInfo->rowsPerTable; + int64_t totalPoints = totalRows * pInfo->pointsPerTable; + pPrint("thread:%d, import finished, use %.2f seconds, tables:%ld rows:%ld points:%ld", pInfo->threadIndex, + (et - st) / 1000.0 / 1000.0, totalTables, totalRows, totalPoints); + + return NULL; +} + +void generateRandomPoints() { + for (int r = 0; r < MAX_RANDOM_POINTS; ++r) { + randomData[r] = rand() % 1000; + } +} + +void printHelp() { + char indent[10] = " "; + printf("Used to test the performance of TDengine\n After writing all the data in one table, start the next table\n"); + + printf("%s%s\n", indent, "-d"); + printf("%s%s%s%s\n", indent, indent, "The name of the database to be created, default is ", dbName); + printf("%s%s\n", indent, "-s"); + printf("%s%s%s%s%s\n", indent, indent, "The name of the super table to be created, default is ", stableName, ", if 'no' then create normal table"); + printf("%s%s\n", indent, "-c"); + printf("%s%s%s%s\n", indent, indent, "Configuration directory, default is ", configDir); + printf("%s%s\n", indent, "-r"); + printf("%s%s%s%ld\n", indent, indent, "Number of records to write to each table, default is ", rowsPerTable); + printf("%s%s\n", indent, "-p"); + printf("%s%s%s%" PRId64 "\n", indent, indent, "Number of columns per table, default is ", pointsPerTable); + printf("%s%s\n", indent, "-t"); + printf("%s%s%s%" PRId64 "\n", indent, indent, "Number of threads to be used, default is ", numOfThreads); + printf("%s%s\n", indent, "-n"); + printf("%s%s%s%" PRId64 "\n", indent, indent, "Number of tables per thread, default is ", numOfTablesPerThread); + + exit(EXIT_SUCCESS); +} + +void shellParseArgument(int argc, char *argv[]) { + for (int i = 1; i < argc; i++) { + if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) { + printHelp(); + exit(0); + } else if (strcmp(argv[i], "-d") == 0) { + strcpy(dbName, argv[++i]); + } else if (strcmp(argv[i], "-c") == 0) { + strcpy(configDir, argv[++i]); + } else if (strcmp(argv[i], "-s") == 0) { + strcpy(stableName, argv[++i]); + } else if (strcmp(argv[i], "-r") == 0) { + rowsPerTable = atoi(argv[++i]); + } else if (strcmp(argv[i], "-p") == 0) { + pointsPerTable = atoi(argv[++i]); + } else if (strcmp(argv[i], "-t") == 0) { + numOfThreads = atoi(argv[++i]); + } else if (strcmp(argv[i], "-n") == 0) { + numOfTablesPerThread = atoi(argv[++i]); + } else { + } + } + + pPrint("%srowsPerTable:%" PRId64 "%s", GREEN, rowsPerTable, NC); + pPrint("%spointsPerTable:%" PRId64 "%s", GREEN, pointsPerTable, NC); + pPrint("%snumOfThreads:%" PRId64 "%s", GREEN, numOfThreads, NC); + pPrint("%snumOfTablesPerThread:%" PRId64 "%s", GREEN, numOfTablesPerThread, NC); + pPrint("%sdbName:%s%s", GREEN, dbName, NC); + pPrint("%stableName:%s%s", GREEN, stableName, NC); + pPrint("%sstart to run%s", GREEN, NC); +} diff --git a/tests/test/c/insertPerRow.c b/tests/test/c/insertPerRow.c new file mode 100644 index 0000000000000000000000000000000000000000..824c1b925a1b155acfbd22694cf95651ed88f1b4 --- /dev/null +++ b/tests/test/c/insertPerRow.c @@ -0,0 +1,366 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#define _DEFAULT_SOURCE +#include "os.h" +#include "taos.h" +#include "tulog.h" +#include "ttimer.h" +#include "tutil.h" +#include "tglobal.h" + +#define MAX_RANDOM_POINTS 20000 +#define GREEN "\033[1;32m" +#define NC "\033[0m" + +typedef struct { + int64_t rowsPerTable; + int64_t pointsPerTable; + int64_t tableBeginIndex; + int64_t tableEndIndex; + int threadIndex; + char dbName[32]; + char stableName[64]; + float createTableSpeed; + pthread_t thread; +} SInfo; + +void *syncTest(void *param); +void generateRandomPoints(); +void shellParseArgument(int argc, char *argv[]); +void createDbAndTable(); +void insertData(); + +int32_t randomData[MAX_RANDOM_POINTS]; +int64_t rowsPerTable = 1000000000; +int64_t pointsPerTable = 1; +int64_t numOfThreads = 10; +int64_t numOfTablesPerThread = 100; +char dbName[32] = "db"; +char stableName[64] = "st"; +int32_t cache = 1; +int32_t replica = 3; +int32_t days = 10; +int32_t interval = 1000; + +int main(int argc, char *argv[]) { + shellParseArgument(argc, argv); + generateRandomPoints(); + taos_init(); + createDbAndTable(); + insertData(); +} + +void createDbAndTable() { + pPrint("start to create table"); + + TAOS_RES * pSql; + TAOS * con; + char qstr[64000]; + + char fqdn[TSDB_FQDN_LEN]; + uint16_t port; + taosGetFqdnPortFromEp(tsFirst, fqdn, &port); + con = taos_connect(fqdn, "root", "taosdata", NULL, port); + if (con == NULL) { + pError("failed to connect to DB, reason:%s", taos_errstr(con)); + exit(1); + } + + sprintf(qstr, "create database if not exists %s cache %d replica %d days %d", dbName, cache, replica, days); + pSql = taos_query(con, qstr); + int32_t code = taos_errno(pSql); + if (code != 0) { + pError("failed to create database:%s, sql:%s, code:%d reason:%s", dbName, qstr, taos_errno(con), taos_errstr(con)); + exit(0); + } + taos_free_result(pSql); + + sprintf(qstr, "use %s", dbName); + pSql = taos_query(con, qstr); + code = taos_errno(pSql); + if (code != 0) { + pError("failed to use db, code:%d reason:%s", taos_errno(con), taos_errstr(con)); + exit(0); + } + taos_free_result(pSql); + + if (strcmp(stableName, "no") != 0) { + int len = sprintf(qstr, "create table if not exists %s(ts timestamp", stableName); + for (int64_t f = 0; f < pointsPerTable; ++f) { + len += sprintf(qstr + len, ", f%ld double", f); + } + sprintf(qstr + len, ") tags(t int)"); + + pSql = taos_query(con, qstr); + code = taos_errno(pSql); + if (code != 0) { + pError("failed to create stable, code:%d reason:%s", taos_errno(con), taos_errstr(con)); + exit(0); + } + taos_free_result(pSql); + } +} + +void insertData() { + struct timeval systemTime; + int64_t st, et; + + gettimeofday(&systemTime, NULL); + st = systemTime.tv_sec * 1000000 + systemTime.tv_usec; + + pPrint("%" PRId64 " threads are spawned to insert data", numOfThreads); + + pthread_attr_t thattr; + pthread_attr_init(&thattr); + pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_JOINABLE); + SInfo *pInfo = (SInfo *)calloc(numOfThreads, sizeof(SInfo)); + + // Start threads to write + for (int i = 0; i < numOfThreads; ++i) { + pInfo[i].rowsPerTable = rowsPerTable; + pInfo[i].pointsPerTable = pointsPerTable; + pInfo[i].tableBeginIndex = i * numOfTablesPerThread; + pInfo[i].tableEndIndex = (i + 1) * numOfTablesPerThread; + pInfo[i].threadIndex = i; + strcpy(pInfo[i].dbName, dbName); + strcpy(pInfo[i].stableName, stableName); + pthread_create(&(pInfo[i].thread), &thattr, syncTest, (void *)(pInfo + i)); + } + + taosMsleep(300); + for (int i = 0; i < numOfThreads; i++) { + pthread_join(pInfo[i].thread, NULL); + } + + gettimeofday(&systemTime, NULL); + et = systemTime.tv_sec * 1000000 + systemTime.tv_usec; + double seconds = (et - st) / 1000.0 / 1000.0; + + int64_t totalTables = numOfTablesPerThread * numOfThreads; + int64_t totalRows = totalTables * rowsPerTable; + int64_t totalPoints = totalTables * rowsPerTable * pointsPerTable; + double speedOfRows = totalRows / seconds; + double speedOfPoints = totalPoints / seconds; + + float createTableSpeed = 0; + for (int i = 0; i < numOfThreads; ++i) { + createTableSpeed += pInfo[i].createTableSpeed; + } + + pPrint( + "%sall threads:%ld finished, use %.1lf seconds, tables:%.ld rows:%ld points:%ld, speed RowsPerSecond:%.1lf " + "PointsPerSecond:%.1lf CreateTableSpeed:%.1f t/s %s", + GREEN, numOfThreads, seconds, totalTables, totalRows, totalPoints, speedOfRows, speedOfPoints, createTableSpeed, NC); + + pPrint("threads exit"); + + pthread_attr_destroy(&thattr); + free(pInfo); +} + +void *syncTest(void *param) { + TAOS * con; + SInfo * pInfo = (SInfo *)param; + struct timeval systemTime; + int64_t st, et; + char qstr[65000]; + int maxBytes = 60000; + int code; + + pPrint("thread:%d, start to run", pInfo->threadIndex); + + char fqdn[TSDB_FQDN_LEN]; + uint16_t port; + + taosGetFqdnPortFromEp(tsFirst, fqdn, &port); + con = taos_connect(fqdn, "root", "taosdata", NULL, port); + if (con == NULL) { + pError("index:%d, failed to connect to DB, reason:%s", pInfo->threadIndex, taos_errstr(con)); + exit(1); + } + + sprintf(qstr, "use %s", pInfo->dbName); + taos_query(con, qstr); + + gettimeofday(&systemTime, NULL); + st = systemTime.tv_sec * 1000000 + systemTime.tv_usec; + + if (strcmp(stableName, "no") != 0) { + for (int64_t t = pInfo->tableBeginIndex; t < pInfo->tableEndIndex; ++t) { + sprintf(qstr, "create table if not exists %s%ld using %s tags(%ld)", stableName, t, stableName, t); + TAOS_RES *pSql = taos_query(con, qstr); + code = taos_errno(pSql); + if (code != 0) { + pError("failed to create table %s%" PRId64 ", reason:%s", stableName, t, taos_errstr(con)); + exit(0); + } + taos_free_result(pSql); + } + } else { + for (int64_t t = pInfo->tableBeginIndex; t < pInfo->tableEndIndex; ++t) { + int len = sprintf(qstr, "create table if not exists %s%ld(ts timestamp", stableName, t); + for (int64_t f = 0; f < pointsPerTable; ++f) { + len += sprintf(qstr + len, ", f%ld double", f); + } + sprintf(qstr + len, ")"); + + TAOS_RES *pSql = taos_query(con, qstr); + code = taos_errno(pSql); + if (code != 0) { + pError("failed to create table %s%ld, reason:%s", stableName, t, taos_errstr(con)); + exit(0); + } + taos_free_result(pSql); + } + } + + gettimeofday(&systemTime, NULL); + et = systemTime.tv_sec * 1000000 + systemTime.tv_usec; + float seconds = (et - st) / 1000.0 / 1000.0; + int64_t tables = pInfo->tableEndIndex - pInfo->tableBeginIndex; + pInfo->createTableSpeed = (float)tables / seconds; + pPrint("thread:%d, %.1f seconds to create %ld tables, speed:%.1f", pInfo->threadIndex, seconds, tables, + pInfo->createTableSpeed); + + if (pInfo->rowsPerTable == 0) return NULL; + + gettimeofday(&systemTime, NULL); + st = systemTime.tv_sec * 1000000 + systemTime.tv_usec; + + int64_t start = 1430000000000; + interval = 1000; // 1000 ms + + char *sql = qstr; + char inserStr[] = "insert into"; + int len = sprintf(sql, "%s", inserStr); + + for (int64_t row = 0; row < pInfo->rowsPerTable; row++) { + for (int64_t table = pInfo->tableBeginIndex; table < pInfo->tableEndIndex; ++table) { + len += sprintf(sql + len, " %s%ld values", pInfo->stableName, table); + len += sprintf(sql + len, "(%ld", start + row * interval); + for (int64_t point = 0; point < pInfo->pointsPerTable; ++point) { + len += sprintf(sql + len, ",%d", randomData[(123 * table + 456 * row + 789 * point) % MAX_RANDOM_POINTS]); + // len += sprintf(sql + len, ",%ld", row); + } + len += sprintf(sql + len, ")"); + if (len > maxBytes) { + TAOS_RES *pSql = taos_query(con, qstr); + int32_t code = taos_errno(pSql); + if (code != 0) { + pError("thread:%d, failed to insert table:%s%ld row:%ld, reason:%s", pInfo->threadIndex, pInfo->stableName, + table, row, taos_errstr(con)); + } + taos_free_result(pSql); + + // "insert into" + len = sprintf(sql, "%s", inserStr); + } + } + } + + if (len != strlen(inserStr)) { + TAOS_RES *pSql = taos_query(con, qstr); + taos_free_result(pSql); + } + + gettimeofday(&systemTime, NULL); + et = systemTime.tv_sec * 1000000 + systemTime.tv_usec; + int64_t totalTables = pInfo->tableEndIndex - pInfo->tableBeginIndex; + int64_t totalRows = totalTables * pInfo->rowsPerTable; + int64_t totalPoints = totalRows * pInfo->pointsPerTable; + pPrint("thread:%d, insert finished, use %.2f seconds, tables:%ld rows:%ld points:%ld", pInfo->threadIndex, + (et - st) / 1000.0 / 1000.0, totalTables, totalRows, totalPoints); + + return NULL; +} + +void generateRandomPoints() { + for (int r = 0; r < MAX_RANDOM_POINTS; ++r) { + randomData[r] = rand() % 1000; + } +} + +void printHelp() { + char indent[10] = " "; + printf("Used to test the performance of TDengine\n After writing one row of data to all tables, write the next row\n"); + + printf("%s%s\n", indent, "-d"); + printf("%s%s%s%s\n", indent, indent, "The name of the database to be created, default is ", dbName); + printf("%s%s\n", indent, "-s"); + printf("%s%s%s%s%s\n", indent, indent, "The name of the super table to be created, default is ", stableName, ", if 'no' then create normal table"); + printf("%s%s\n", indent, "-c"); + printf("%s%s%s%s\n", indent, indent, "Configuration directory, default is ", configDir); + printf("%s%s\n", indent, "-r"); + printf("%s%s%s%ld\n", indent, indent, "Number of records to write to each table, default is ", rowsPerTable); + printf("%s%s\n", indent, "-p"); + printf("%s%s%s%" PRId64 "\n", indent, indent, "Number of columns per table, default is ", pointsPerTable); + printf("%s%s\n", indent, "-t"); + printf("%s%s%s%" PRId64 "\n", indent, indent, "Number of threads to be used, default is ", numOfThreads); + printf("%s%s\n", indent, "-n"); + printf("%s%s%s%" PRId64 "\n", indent, indent, "Number of tables per thread, default is ", numOfTablesPerThread); + printf("%s%s\n", indent, "-replica"); + printf("%s%s%s%d\n", indent, indent, "Database parameters replica, default is ", replica); + printf("%s%s\n", indent, "-cache"); + printf("%s%s%s%d\n", indent, indent, "Database parameters replica, default is ", cache); + printf("%s%s\n", indent, "-days"); + printf("%s%s%s%d\n", indent, indent, "Database parameters days, default is ", days); + printf("%s%s\n", indent, "-interval"); + printf("%s%s%s%d\n", indent, indent, "Interval of each rows in ms, default is ", interval); + + exit(EXIT_SUCCESS); +} + +void shellParseArgument(int argc, char *argv[]) { + for (int i = 1; i < argc; i++) { + if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) { + printHelp(); + exit(0); + } else if (strcmp(argv[i], "-d") == 0) { + strcpy(dbName, argv[++i]); + } else if (strcmp(argv[i], "-c") == 0) { + strcpy(configDir, argv[++i]); + } else if (strcmp(argv[i], "-s") == 0) { + strcpy(stableName, argv[++i]); + } else if (strcmp(argv[i], "-r") == 0) { + rowsPerTable = atoi(argv[++i]); + } else if (strcmp(argv[i], "-p") == 0) { + pointsPerTable = atoi(argv[++i]); + } else if (strcmp(argv[i], "-t") == 0) { + numOfThreads = atoi(argv[++i]); + } else if (strcmp(argv[i], "-n") == 0) { + numOfTablesPerThread = atoi(argv[++i]); + } else if (strcmp(argv[i], "-replica") == 0) { + replica = atoi(argv[++i]); + } else if (strcmp(argv[i], "-cache") == 0) { + cache = atoi(argv[++i]); + } else if (strcmp(argv[i], "-days") == 0) { + days = atoi(argv[++i]); + } else if (strcmp(argv[i], "-interval") == 0) { + interval = atoi(argv[++i]); + } else { + } + } + + pPrint("%srowsPerTable:%" PRId64 "%s", GREEN, rowsPerTable, NC); + pPrint("%spointsPerTable:%" PRId64 "%s", GREEN, pointsPerTable, NC); + pPrint("%snumOfThreads:%" PRId64 "%s", GREEN, numOfThreads, NC); + pPrint("%snumOfTablesPerThread:%" PRId64 "%s", GREEN, numOfTablesPerThread, NC); + pPrint("%scache:%" PRId32 "%s", GREEN, cache, NC); + pPrint("%stables:%" PRId32 "%s", GREEN, replica, NC); + pPrint("%sdbName:%s%s", GREEN, dbName, NC); + pPrint("%stableName:%s%s", GREEN, stableName, NC); + pPrint("%sstart to run%s", GREEN, NC); +} diff --git a/tests/test/c/insertPerTable.c b/tests/test/c/insertPerTable.c new file mode 100644 index 0000000000000000000000000000000000000000..d79df0f4d11e4bc97283f7996cab0d3c26e776e9 --- /dev/null +++ b/tests/test/c/insertPerTable.c @@ -0,0 +1,357 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#define _DEFAULT_SOURCE +#include "os.h" +#include "taos.h" +#include "tulog.h" +#include "ttimer.h" +#include "tutil.h" +#include "tglobal.h" + +#define MAX_RANDOM_POINTS 20000 +#define GREEN "\033[1;32m" +#define NC "\033[0m" + +typedef struct { + int64_t rowsPerTable; + int64_t pointsPerTable; + int64_t tableBeginIndex; + int64_t tableEndIndex; + int threadIndex; + char dbName[32]; + char stableName[64]; + pthread_t thread; +} SInfo; + +void *syncTest(void *param); +void generateRandomPoints(); +void shellParseArgument(int argc, char *argv[]); +void createDbAndTable(); +void insertData(); + +int32_t randomData[MAX_RANDOM_POINTS]; +int64_t rowsPerTable = 10000; +int64_t pointsPerTable = 1; +int64_t numOfThreads = 1; +int64_t numOfTablesPerThread = 1; +char dbName[32] = "db"; +char stableName[64] = "st"; +int32_t cache = 16; +int32_t tables = 5000; + +int main(int argc, char *argv[]) { + shellParseArgument(argc, argv); + generateRandomPoints(); + taos_init(); + createDbAndTable(); + insertData(); +} + +void createDbAndTable() { + pPrint("start to create table"); + + TAOS_RES * pSql; + TAOS * con; + struct timeval systemTime; + int64_t st, et; + char qstr[64000]; + + char fqdn[TSDB_FQDN_LEN]; + uint16_t port; + + taosGetFqdnPortFromEp(tsFirst, fqdn, &port); + + con = taos_connect(fqdn, "root", "taosdata", NULL, port); + if (con == NULL) { + pError("failed to connect to DB, reason:%s", taos_errstr(con)); + exit(1); + } + + sprintf(qstr, "create database if not exists %s cache %d maxtables %d", dbName, cache, tables); + pSql = taos_query(con, qstr); + int32_t code = taos_errno(pSql); + if (code != 0) { + pError("failed to create database:%s, sql:%s, code:%d reason:%s", dbName, qstr, taos_errno(con), taos_errstr(con)); + exit(0); + } + + sprintf(qstr, "use %s", dbName); + pSql = taos_query(con, qstr); + code = taos_errno(pSql); + if (code != 0) { + pError("failed to use db, code:%d reason:%s", taos_errno(con), taos_errstr(con)); + exit(0); + } + taos_free_result(pSql); + + gettimeofday(&systemTime, NULL); + st = systemTime.tv_sec * 1000000 + systemTime.tv_usec; + int64_t totalTables = numOfTablesPerThread * numOfThreads; + + if (strcmp(stableName, "no") != 0) { + int len = sprintf(qstr, "create table if not exists %s(ts timestamp", stableName); + for (int64_t f = 0; f < pointsPerTable; ++f) { + len += sprintf(qstr + len, ", f%ld double", f); + } + sprintf(qstr + len, ") tags(t int)"); + + pSql = taos_query(con, qstr); + code = taos_errno(pSql); + if (code != 0) { + pError("failed to create stable, code:%d reason:%s", taos_errno(con), taos_errstr(con)); + exit(0); + } + taos_free_result(pSql); + + for (int64_t t = 0; t < totalTables; ++t) { + sprintf(qstr, "create table if not exists %s%ld using %s tags(%ld)", stableName, t, stableName, t); + pSql = taos_query(con, qstr); + code = taos_errno(pSql); + if (code != 0) { + pError("failed to create table %s%" PRId64 ", reason:%s", stableName, t, taos_errstr(con)); + exit(0); + } + taos_free_result(pSql); + } + } else { + for (int64_t t = 0; t < totalTables; ++t) { + int len = sprintf(qstr, "create table if not exists %s%ld(ts timestamp", stableName, t); + for (int64_t f = 0; f < pointsPerTable; ++f) { + len += sprintf(qstr + len, ", f%ld double", f); + } + sprintf(qstr + len, ")"); + + pSql = taos_query(con, qstr); + code = taos_errno(pSql); + if (code != 0) { + pError("failed to create table %s%ld, reason:%s", stableName, t, taos_errstr(con)); + exit(0); + } + taos_free_result(pSql); + } + } + + gettimeofday(&systemTime, NULL); + et = systemTime.tv_sec * 1000000 + systemTime.tv_usec; + float seconds = (et - st) / 1000.0 / 1000.0; + pPrint("%.1f seconds to create %ld tables, speed:%.1f", seconds, totalTables, totalTables / seconds); + taos_close(con); +} + +void insertData() { + struct timeval systemTime; + int64_t st, et; + + gettimeofday(&systemTime, NULL); + st = systemTime.tv_sec * 1000000 + systemTime.tv_usec; + + if (rowsPerTable <= 0) { + pPrint("not insert data for rowsPerTable is :%" PRId64, rowsPerTable); + exit(0); + } else { + pPrint("%" PRId64 " threads are spawned to insert data", numOfThreads); + } + + pthread_attr_t thattr; + pthread_attr_init(&thattr); + pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_JOINABLE); + SInfo *pInfo = (SInfo *)malloc(sizeof(SInfo) * numOfThreads); + + // Start threads to write + for (int i = 0; i < numOfThreads; ++i) { + pInfo[i].rowsPerTable = rowsPerTable; + pInfo[i].pointsPerTable = pointsPerTable; + pInfo[i].tableBeginIndex = i * numOfTablesPerThread; + pInfo[i].tableEndIndex = (i + 1) * numOfTablesPerThread; + pInfo[i].threadIndex = i; + strcpy(pInfo[i].dbName, dbName); + strcpy(pInfo[i].stableName, stableName); + pthread_create(&(pInfo[i].thread), &thattr, syncTest, (void *)(pInfo + i)); + } + + taosMsleep(300); + for (int i = 0; i < numOfThreads; i++) { + pthread_join(pInfo[i].thread, NULL); + } + + gettimeofday(&systemTime, NULL); + et = systemTime.tv_sec * 1000000 + systemTime.tv_usec; + double seconds = (et - st) / 1000.0 / 1000.0; + + int64_t totalTables = numOfTablesPerThread * numOfThreads; + int64_t totalRows = totalTables * rowsPerTable; + int64_t totalPoints = totalTables * rowsPerTable * pointsPerTable; + double speedOfRows = totalRows / seconds; + double speedOfPoints = totalPoints / seconds; + + pPrint( + "%sall threads:%ld finished, use %.1lf seconds, tables:%.ld rows:%ld points:%ld, speed RowsPerSecond:%.1lf " + "PointsPerSecond:%.1lf%s", + GREEN, numOfThreads, seconds, totalTables, totalRows, totalPoints, speedOfRows, speedOfPoints, NC); + + pPrint("threads exit"); + + pthread_attr_destroy(&thattr); + free(pInfo); +} + +void *syncTest(void *param) { + TAOS * con; + SInfo * pInfo = (SInfo *)param; + struct timeval systemTime; + int64_t st, et; + char qstr[65000]; + int maxBytes = 60000; + + pPrint("thread:%d, start to run", pInfo->threadIndex); + + char fqdn[TSDB_FQDN_LEN]; + uint16_t port; + + taosGetFqdnPortFromEp(tsFirst, fqdn, &port); + + con = taos_connect(fqdn, "root", "taosdata", NULL, port); + if (con == NULL) { + pError("index:%d, failed to connect to DB, reason:%s", pInfo->threadIndex, taos_errstr(con)); + exit(1); + } + + sprintf(qstr, "use %s", pInfo->dbName); + taos_query(con, qstr); + + gettimeofday(&systemTime, NULL); + st = systemTime.tv_sec * 1000000 + systemTime.tv_usec; + + int64_t start = 1430000000000; + int64_t interval = 1000; // 1000 ms + + char *sql = qstr; + char inserStr[] = "insert into"; + int len = sprintf(sql, "%s", inserStr); + + for (int64_t table = pInfo->tableBeginIndex; table < pInfo->tableEndIndex; ++table) { + len += sprintf(sql + len, " %s%ld values", pInfo->stableName, table); + for (int64_t row = 0; row < pInfo->rowsPerTable; row++) { + len += sprintf(sql + len, "(%ld", start + row * interval); + for (int64_t point = 0; point < pInfo->pointsPerTable; ++point) { + len += sprintf(sql + len, ",%d", randomData[(123 * table + 456 * row + 789 * point) % MAX_RANDOM_POINTS]); + // len += sprintf(sql + len, ",%ld", row); + } + len += sprintf(sql + len, ")"); + if (len > maxBytes) { + TAOS_RES *pSql = taos_query(con, qstr); + int32_t code = taos_errno(pSql); + if (code != 0) { + pError("thread:%d, failed to insert table:%s%ld row:%ld, reason:%s", pInfo->threadIndex, pInfo->stableName, + table, row, taos_errstr(con)); + } + taos_free_result(pSql); + + // "insert into" + len = sprintf(sql, "%s", inserStr); + + // "insert into st1 values" + if (row != pInfo->rowsPerTable - 1) { + len += sprintf(sql + len, " %s%ld values", pInfo->stableName, table); + } + } + } + } + + if (len != strlen(inserStr)) { + taos_query(con, qstr); + } + + gettimeofday(&systemTime, NULL); + et = systemTime.tv_sec * 1000000 + systemTime.tv_usec; + int64_t totalTables = pInfo->tableEndIndex - pInfo->tableBeginIndex; + int64_t totalRows = totalTables * pInfo->rowsPerTable; + int64_t totalPoints = totalRows * pInfo->pointsPerTable; + pPrint("thread:%d, insert finished, use %.2f seconds, tables:%ld rows:%ld points:%ld", pInfo->threadIndex, + (et - st) / 1000.0 / 1000.0, totalTables, totalRows, totalPoints); + + return NULL; +} + +void generateRandomPoints() { + for (int r = 0; r < MAX_RANDOM_POINTS; ++r) { + randomData[r] = rand() % 1000; + } +} + +void printHelp() { + char indent[10] = " "; + printf("Used to test the performance of TDengine\n After writing all the data in one table, start the next table\n"); + + printf("%s%s\n", indent, "-d"); + printf("%s%s%s%s\n", indent, indent, "The name of the database to be created, default is ", dbName); + printf("%s%s\n", indent, "-s"); + printf("%s%s%s%s%s\n", indent, indent, "The name of the super table to be created, default is ", stableName, ", if 'no' then create normal table"); + printf("%s%s\n", indent, "-c"); + printf("%s%s%s%s\n", indent, indent, "Configuration directory, default is ", configDir); + printf("%s%s\n", indent, "-r"); + printf("%s%s%s%ld\n", indent, indent, "Number of records to write to each table, default is ", rowsPerTable); + printf("%s%s\n", indent, "-p"); + printf("%s%s%s%" PRId64 "\n", indent, indent, "Number of columns per table, default is ", pointsPerTable); + printf("%s%s\n", indent, "-t"); + printf("%s%s%s%" PRId64 "\n", indent, indent, "Number of threads to be used, default is ", numOfThreads); + printf("%s%s\n", indent, "-n"); + printf("%s%s%s%" PRId64 "\n", indent, indent, "Number of tables per thread, default is ", numOfTablesPerThread); + printf("%s%s\n", indent, "-tables"); + printf("%s%s%s%d\n", indent, indent, "Database parameters tables, default is ", tables); + printf("%s%s\n", indent, "-cache"); + printf("%s%s%s%d\n", indent, indent, "Database parameters cache, default is ", cache); + + exit(EXIT_SUCCESS); +} + +void shellParseArgument(int argc, char *argv[]) { + for (int i = 1; i < argc; i++) { + if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) { + printHelp(); + exit(0); + } else if (strcmp(argv[i], "-d") == 0) { + strcpy(dbName, argv[++i]); + } else if (strcmp(argv[i], "-c") == 0) { + strcpy(configDir, argv[++i]); + } else if (strcmp(argv[i], "-s") == 0) { + strcpy(stableName, argv[++i]); + } else if (strcmp(argv[i], "-r") == 0) { + rowsPerTable = atoi(argv[++i]); + } else if (strcmp(argv[i], "-p") == 0) { + pointsPerTable = atoi(argv[++i]); + } else if (strcmp(argv[i], "-t") == 0) { + numOfThreads = atoi(argv[++i]); + } else if (strcmp(argv[i], "-n") == 0) { + numOfTablesPerThread = atoi(argv[++i]); + } else if (strcmp(argv[i], "-tables") == 0) { + tables = atoi(argv[++i]); + } else if (strcmp(argv[i], "-cache") == 0) { + cache = atoi(argv[++i]); + } else { + } + } + + pPrint("%srowsPerTable:%" PRId64 "%s", GREEN, rowsPerTable, NC); + pPrint("%spointsPerTable:%" PRId64 "%s", GREEN, pointsPerTable, NC); + pPrint("%snumOfThreads:%" PRId64 "%s", GREEN, numOfThreads, NC); + pPrint("%snumOfTablesPerThread:%" PRId64 "%s", GREEN, numOfTablesPerThread, NC); + pPrint("%scache:%" PRId32 "%s", GREEN, cache, NC); + pPrint("%stables:%" PRId32 "%s", GREEN, tables, NC); + pPrint("%sdbName:%s%s", GREEN, dbName, NC); + pPrint("%stableName:%s%s", GREEN, stableName, NC); + pPrint("%sstart to run%s", GREEN, NC); +} diff --git a/tests/test/c/invalidTableId.c b/tests/test/c/invalidTableId.c new file mode 100644 index 0000000000000000000000000000000000000000..581387a4ee9dc8d72538e175d674bd0fbe83072c --- /dev/null +++ b/tests/test/c/invalidTableId.c @@ -0,0 +1,220 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#define _DEFAULT_SOURCE +#include "os.h" +#include "taoserror.h" +#include "taos.h" +#include "tulog.h" +#include "tutil.h" +#include "tglobal.h" +#include "hash.h" + +#define MAX_RANDOM_POINTS 20000 +#define GREEN "\033[1;32m" +#define NC "\033[0m" + +#define MAX_DB_NUM 100 +void * con; +char dbNames[MAX_DB_NUM][48]; +int32_t dbNum = 0; +void parseArgument(int argc, char *argv[]); +void connDb(); +void getDbNames(); +void printDbNames(); +void queryTables(char *dbName); +void checkTables(char *dbName); + +int main(int argc, char *argv[]) { + parseArgument(argc, argv); + taos_init(); + connDb(); + getDbNames(); + printDbNames(); + for (int dbIndex = 0; dbIndex < dbNum; ++dbIndex) { + queryTables((char*)(dbNames[dbIndex])); + checkTables((char*)(dbNames[dbIndex])); + } + + pPrint("all %d database is checked", dbNum); +} + +void connDb() { + con = taos_connect(NULL, "root", "taosdata", NULL, 0); + if (con == NULL) { + pError("failed to connect to DB, reason:%s", taos_errstr(con)); + exit(0); + } +} + +void getDbNames() { + if (dbNum != 0) return; + + char * qstr = "show databases"; + TAOS_RES *result = taos_query(con, qstr); + int32_t code = taos_errno(result); + if (result == NULL || code != 0) { + pError("failed to exec sql:%s, code:0x%x reason:%s", qstr, code & 0XFFFF, tstrerror(code)); + exit(0); + } + + TAOS_ROW row; + int num_fields = taos_num_fields(result); + if (num_fields <= 0) return; + while ((row = taos_fetch_row(result))) { + char * dbName = (char*)dbNames[dbNum]; + int32_t *length = taos_fetch_lengths(result); + int len = length[0]; + memcpy(dbName, (char *)row[0], len); + dbName[len] = 0; + dbNum++; + } + + taos_free_result(result); +} + +void printDbNames() { + for (int dbIndex = 0; dbIndex < dbNum; ++dbIndex) { + pPrint("db:%d %s", dbIndex, dbNames[dbIndex]); + } +} + +void queryTables(char *dbName) { + char qstr[1024]; + char fileName[1024]; + char ts[35] = {0}; + int32_t precision = 1000; + + sprintf(qstr, "show %s.tables", dbName); + sprintf(fileName, "%s_tables.txt", dbName); + + TAOS_RES *result = taos_query(con, qstr); + int32_t code = taos_errno(result); + if (result == NULL || code != 0) { + pError("failed to exec sql:%s, code:0x%x reason:%s", qstr, code & 0XFFFF, tstrerror(code)); + exit(0); + } + + FILE *fp = fopen(fileName, "w"); + if (!fp) return; + + TAOS_ROW row; + int32_t rows = 0; + while ((row = taos_fetch_row(result))) { + char tableName[256] = {0}; + int32_t *length = taos_fetch_lengths(result); + int len = length[0]; + memcpy(tableName, (char *)row[0], len); + tableName[len] = 0; + + int64_t t = *((int64_t *)row[1]); + time_t tt = t / 1000; + struct tm *ptm = localtime(&tt); + int32_t tl = (int32_t)strftime(ts, 35, "%Y-%m-%d %H:%M:%S", ptm); + snprintf(ts + tl, 5, ".%03ld", t % precision); + + // fprintf(fp, "%s %s\n", tableName, ts); + fprintf(fp, "%s.%s\n", dbName, tableName); + rows++; + } + + taos_free_result(result); + fclose(fp); + pPrint("db:%s has %d tables, write to %s", dbName, rows, fileName); +} + +void checkTables(char *dbName) { + char qstr[1024]; + char fileName1[1024]; + char fileName2[1024]; + + sprintf(qstr, "show %s.tables", dbName); + sprintf(fileName1, "%s_tables.txt", dbName); + sprintf(fileName2, "%s_count.txt", dbName); + + FILE *fp1 = fopen(fileName1, "r"); + if (!fp1) return; + + FILE *fp2 = fopen(fileName2, "w"); + if (!fp2) return; + + int32_t successRows = 0; + int32_t failedRows = 0; + char tbName[256]; + while (!feof(fp1)) { + int size = fscanf(fp1, "%s", tbName); + if (size <= 0) { + break; + } + + sprintf(qstr, "select count(*) from %s", tbName); + TAOS_RES *result = taos_query(con, qstr); + int32_t code = taos_errno(result); + if (result == NULL || code != 0) { + pError("failed to exec sql:%s, code:0x%x reason:%s", qstr, code & 0XFFFF, tstrerror(code)); + fprintf(fp2, "%s failed to exec sql:%s, code:0x%x reason:%s", tbName, qstr, code & 0XFFFF, tstrerror(code)); + taos_free_result(result); + failedRows++; + continue; + } + + TAOS_ROW row; + int64_t count = 0; + while ((row = taos_fetch_row(result))) { + count = *((int64_t *)row[0]); + } + fprintf(fp2, "%s %" PRId64 "\n", tbName, count); + + successRows++; + if (successRows % 1000 == 0) { + pPrint("query %d tables", successRows); + } + taos_free_result(result); + } + + fclose(fp1); + fclose(fp2); + pPrint("db:%s query tables, success:%d failed:%d write to %s", dbName, successRows, failedRows, fileName2); +} + +void printHelp() { + char indent[10] = " "; + printf("Used to checkTables\n"); + + printf("%s%s\n", indent, "-c"); + printf("%s%s%s%s\n", indent, indent, "Configuration directory, default is ", configDir); + printf("%s%s\n", indent, "-d"); + printf("%s%s%s%s\n", indent, indent, "The name of the database to be checked, default is ", "all"); + + exit(EXIT_SUCCESS); +} + +void parseArgument(int argc, char *argv[]) { + for (int i = 1; i < argc; i++) { + if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) { + printHelp(); + exit(0); + } else if (strcmp(argv[i], "-d") == 0) { + strcpy(dbNames[0], argv[++i]); + dbNum++; + } else if (strcmp(argv[i], "-c") == 0) { + strcpy(configDir, argv[++i]); + } else { + } + } + + pPrint("%s configDir:%s %s", GREEN, configDir, NC); + pPrint("%s start to checkTables %s", GREEN, NC); +} diff --git a/tests/test/c/queryPerformance.c b/tests/test/c/queryPerformance.c new file mode 100644 index 0000000000000000000000000000000000000000..eda082dd4f293f0879603f6b71cc59150d6cfb3d --- /dev/null +++ b/tests/test/c/queryPerformance.c @@ -0,0 +1,183 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#define _DEFAULT_SOURCE +#include "os.h" +#include "taos.h" +#include "tulog.h" +#include "ttimer.h" +#include "tutil.h" +#include "tglobal.h" + +#define MAX_RANDOM_POINTS 20000 +#define GREEN "\033[1;32m" +#define NC "\033[0m" + +typedef struct { + int64_t startTimeMs; + int64_t endTimeMs; + int threadIndex; + pthread_t thread; +} SInfo; + +void *syncTest(void *param); +void shellParseArgument(int argc, char *argv[]); +void queryData(); + +int numOfThreads = 10; +int useGlobalConn = 1; +int requestPerThread = 10000; +char requestSql[10240] = "show dnodes"; +TAOS *globalConn; + +int main(int argc, char *argv[]) { + shellParseArgument(argc, argv); + taos_init(); + queryData(); +} + +void queryData() { + struct timeval systemTime; + int64_t st, et; + char fqdn[TSDB_FQDN_LEN]; + uint16_t port; + + if (useGlobalConn) { + taosGetFqdnPortFromEp(tsFirst, fqdn, &port); + + globalConn = taos_connect(fqdn, "root", "taosdata", NULL, port); + if (globalConn == NULL) { + pError("failed to connect to DB, reason:%s", taos_errstr(globalConn)); + exit(1); + } + } + + pPrint("%d threads are spawned to query", numOfThreads); + + gettimeofday(&systemTime, NULL); + st = systemTime.tv_sec * 1000000 + systemTime.tv_usec; + + pthread_attr_t thattr; + pthread_attr_init(&thattr); + pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_JOINABLE); + SInfo *pInfo = (SInfo *)malloc(sizeof(SInfo) * numOfThreads); + + // Start threads to write + for (int i = 0; i < numOfThreads; ++i) { + pInfo[i].threadIndex = i; + pthread_create(&(pInfo[i].thread), &thattr, syncTest, (void *)(pInfo + i)); + } + + taosMsleep(300); + for (int i = 0; i < numOfThreads; i++) { + pthread_join(pInfo[i].thread, NULL); + } + + gettimeofday(&systemTime, NULL); + et = systemTime.tv_sec * 1000000 + systemTime.tv_usec; + double totalTimeMs = (et - st) / 1000.0; + + int totalReq = requestPerThread * numOfThreads; + float rspTime = totalTimeMs / requestPerThread; + float qps = totalReq / (totalTimeMs / 1000); + + pPrint("%s threads:%d, totalTime %.1fms totalReq:%d qps:%.1f rspTime:%.3fms %s", GREEN, numOfThreads, totalTimeMs, + totalReq, qps, rspTime, NC); + + pthread_attr_destroy(&thattr); + free(pInfo); +} + +void *syncTest(void *param) { + TAOS * con; + SInfo * pInfo = (SInfo *)param; + char fqdn[TSDB_FQDN_LEN]; + uint16_t port; + + if (useGlobalConn) { + pPrint("thread:%d, start to run use global connection", pInfo->threadIndex); + con = globalConn; + } else { + pPrint("thread:%d, start to run, and create new conn", pInfo->threadIndex); + taosGetFqdnPortFromEp(tsFirst, fqdn, &port); + + con = taos_connect(fqdn, "root", "taosdata", NULL, port); + if (con == NULL) { + pError("index:%d, failed to connect to DB, reason:%s", pInfo->threadIndex, taos_errstr(con)); + exit(1); + } + } + + for (int i = 0; i < requestPerThread; ++i) { + void *tres = taos_query(con, requestSql); + + TAOS_ROW row = taos_fetch_row(tres); + if (row == NULL) { + taos_free_result(tres); + exit(0); + } + + do { + row = taos_fetch_row(tres); + } while (row != NULL); + + taos_free_result(tres); + } + return NULL; +} + +void printHelp() { + char indent[10] = " "; + printf("Used to test the query performance of TDengine\n"); + + printf("%s%s\n", indent, "-c"); + printf("%s%s%s%s\n", indent, indent, "Configuration directory, default is ", configDir); + printf("%s%s\n", indent, "-s"); + printf("%s%s%s%s\n", indent, indent, "The sql to be executed, default is ", requestSql); + printf("%s%s\n", indent, "-r"); + printf("%s%s%s%d\n", indent, indent, "Request per thread, default is ", requestPerThread); + printf("%s%s\n", indent, "-t"); + printf("%s%s%s%d\n", indent, indent, "Number of threads to be used, default is ", numOfThreads); + printf("%s%s\n", indent, "-g"); + printf("%s%s%s%d\n", indent, indent, "Whether to share connections between threads, default is ", useGlobalConn); + + exit(EXIT_SUCCESS); +} + +void shellParseArgument(int argc, char *argv[]) { + for (int i = 1; i < argc; i++) { + if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) { + printHelp(); + exit(0); + } else if (strcmp(argv[i], "-c") == 0) { + strcpy(configDir, argv[++i]); + } else if (strcmp(argv[i], "-s") == 0) { + strcpy(requestSql, argv[++i]); + } else if (strcmp(argv[i], "-r") == 0) { + requestPerThread = atoi(argv[++i]); + } else if (strcmp(argv[i], "-t") == 0) { + numOfThreads = atoi(argv[++i]); + } else if (strcmp(argv[i], "-g") == 0) { + useGlobalConn = atoi(argv[++i]); + } else { + } + } + + pPrint("%s sql:%s %s", GREEN, requestSql, NC); + pPrint("%s requestPerThread:%d %s", GREEN, requestPerThread, NC); + pPrint("%s numOfThreads:%d %s", GREEN, numOfThreads, NC); + pPrint("%s useGlobalConn:%d %s", GREEN, useGlobalConn, NC); + pPrint("%s start to run %s", GREEN, NC); +} diff --git a/tests/tsim/CMakeLists.txt b/tests/tsim/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..50b42941aff12ec6762b2da904675e6fa0183cad --- /dev/null +++ b/tests/tsim/CMakeLists.txt @@ -0,0 +1,9 @@ +PROJECT(TDengine) + +INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/client/inc) +INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/cJson/inc) +INCLUDE_DIRECTORIES(inc) + +AUX_SOURCE_DIRECTORY(src SRC) +ADD_EXECUTABLE(tsim ${SRC}) +TARGET_LINK_LIBRARIES(tsim taos_static trpc tutil pthread cJson) diff --git a/tests/tsim/inc/sim.h b/tests/tsim/inc/sim.h new file mode 100644 index 0000000000000000000000000000000000000000..d9a7e13138b125f92d0611614f74abf268eaee70 --- /dev/null +++ b/tests/tsim/inc/sim.h @@ -0,0 +1,181 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef __SIM_H__ +#define __SIM_H__ + +#include +#include +#include + +#include "taos.h" +#include "tidpool.h" +#include "tlog.h" +#include "tutil.h" + +#define MAX_MAIN_SCRIPT_NUM 10 +#define MAX_BACKGROUND_SCRIPT_NUM 10 +#define MAX_FILE_NAME_LEN 256 +#define MAX_ERROR_LEN 1024 +#define MAX_QUERY_VALUE_LEN 40 +#define MAX_QUERY_COL_NUM 20 +#define MAX_QUERY_ROW_NUM 20 +#define MAX_SYSTEM_RESULT_LEN 2048 +#define MAX_VAR_LEN 100 +#define MAX_VAR_NAME_LEN 32 +#define MAX_VAR_VAL_LEN 80 +#define MAX_OPT_NAME_LEN 32 +#define MAX_SIM_CMD_NAME_LEN 40 + +#ifdef LINUX +#define SUCCESS_PREFIX "\033[44;32;1m" +#define SUCCESS_POSTFIX "\033[0m" +#define FAILED_PREFIX "\033[44;31;1m" +#define FAILED_POSTFIX "\033[0m" +#else +#define SUCCESS_PREFIX "" +#define SUCCESS_POSTFIX "" +#define FAILED_PREFIX "" +#define FAILED_POSTFIX "" +#endif + +#define simFatal(...) { if (simDebugFlag & DEBUG_FATAL) { taosPrintLog("SIM FATAL ", 255, __VA_ARGS__); }} +#define simError(...) { if (simDebugFlag & DEBUG_ERROR) { taosPrintLog("SIM ERROR ", 255, __VA_ARGS__); }} +#define simWarn(...) { if (simDebugFlag & DEBUG_WARN) { taosPrintLog("SIM WARN ", 255, __VA_ARGS__); }} +#define simInfo(...) { if (simDebugFlag & DEBUG_INFO) { taosPrintLog("SIM ", 255, __VA_ARGS__); }} +#define simDebug(...) { if (simDebugFlag & DEBUG_DEBUG) { taosPrintLog("SIM ", simDebugFlag, __VA_ARGS__); }} +#define simTrace(...) { if (simDebugFlag & DEBUG_TRACE) { taosPrintLog("SIM ", simDebugFlag, __VA_ARGS__); }} + +enum { SIM_SCRIPT_TYPE_MAIN, SIM_SCRIPT_TYPE_BACKGROUND }; + +enum { + SIM_CMD_EXP, + SIM_CMD_IF, + SIM_CMD_ELIF, + SIM_CMD_ELSE, + SIM_CMD_ENDI, + SIM_CMD_WHILE, + SIM_CMD_ENDW, + SIM_CMD_SWITCH, + SIM_CMD_CASE, + SIM_CMD_DEFAULT, + SIM_CMD_CONTINUE, + SIM_CMD_BREAK, + SIM_CMD_ENDS, + SIM_CMD_SLEEP, + SIM_CMD_GOTO, + SIM_CMD_RUN, + SIM_CMD_RUN_BACK, + SIM_CMD_PRINT, + SIM_CMD_SYSTEM, + SIM_CMD_SYSTEM_CONTENT, + SIM_CMD_SQL, + SIM_CMD_SQL_ERROR, + SIM_CMD_SQL_SLOW, + SIM_CMD_RESTFUL, + SIM_CMD_TEST, + SIM_CMD_RETURN, + SIM_CMD_LINE_INSERT, + SIM_CMD_LINE_INSERT_ERROR, + SIM_CMD_END +}; + +enum { + SQL_JUMP_FALSE, + SQL_JUMP_TRUE, +}; + +struct _script_t; +typedef struct _cmd_t { + int16_t cmdno; + int16_t nlen; + char name[MAX_SIM_CMD_NAME_LEN]; + bool (*parseCmd)(char *, struct _cmd_t *, int32_t); + bool (*executeCmd)(struct _script_t *script, char *option); + struct _cmd_t *next; +} SCommand; + +typedef struct { + int16_t cmdno; + int16_t jump; // jump position + int16_t errorJump; // sql jump flag, while '-x' exist in sql cmd, this flag + // will be SQL_JUMP_TRUE, otherwise is SQL_JUMP_FALSE */ + int16_t lineNum; // correspodning line number in original file + int32_t optionOffset;// relative option offset +} SCmdLine; + +typedef struct _var_t { + char varName[MAX_VAR_NAME_LEN]; + char varValue[MAX_VAR_VAL_LEN]; + char varNameLen; +} SVariable; + +typedef struct _script_t { + int32_t type; + bool killed; + void * taos; + char rows[12]; // number of rows data retrieved + char data[MAX_QUERY_ROW_NUM][MAX_QUERY_COL_NUM][MAX_QUERY_VALUE_LEN]; // query results + char system_exit_code[12]; + char system_ret_content[MAX_SYSTEM_RESULT_LEN]; + int32_t varLen; + int32_t linePos; // current cmd position + int32_t numOfLines; // number of lines in the script + int32_t bgScriptLen; + char fileName[MAX_FILE_NAME_LEN]; // script file name + char error[TSDB_MAX_BINARY_LEN + 100]; + char * optionBuffer; + SCmdLine *lines; // command list + SVariable variables[MAX_VAR_LEN]; + pthread_t bgPid; + char auth[128]; + struct _script_t *bgScripts[MAX_BACKGROUND_SCRIPT_NUM]; +} SScript; + +extern SScript *simScriptList[MAX_MAIN_SCRIPT_NUM]; +extern SCommand simCmdList[]; +extern int32_t simScriptPos; +extern int32_t simScriptSucced; +extern int32_t simDebugFlag; +extern char tsScriptDir[]; +extern bool simAsyncQuery; +extern bool abortExecution; + +SScript *simParseScript(char *fileName); +SScript *simProcessCallOver(SScript *script); +void * simExecuteScript(void *script); +void simInitsimCmdList(); +bool simSystemInit(); +void simSystemCleanUp(); +char * simGetVariable(SScript *script, char *varName, int32_t varLen); +bool simExecuteExpCmd(SScript *script, char *option); +bool simExecuteTestCmd(SScript *script, char *option); +bool simExecuteGotoCmd(SScript *script, char *option); +bool simExecuteRunCmd(SScript *script, char *option); +bool simExecuteRunBackCmd(SScript *script, char *option); +bool simExecuteSystemCmd(SScript *script, char *option); +bool simExecuteSystemContentCmd(SScript *script, char *option); +bool simExecutePrintCmd(SScript *script, char *option); +bool simExecuteSleepCmd(SScript *script, char *option); +bool simExecuteReturnCmd(SScript *script, char *option); +bool simExecuteSqlCmd(SScript *script, char *option); +bool simExecuteSqlErrorCmd(SScript *script, char *rest); +bool simExecuteSqlSlowCmd(SScript *script, char *option); +bool simExecuteRestfulCmd(SScript *script, char *rest); +bool simExecuteLineInsertCmd(SScript *script, char *option); +bool simExecuteLineInsertErrorCmd(SScript *script, char *option); +void simVisuallizeOption(SScript *script, char *src, char *dst); + +#endif diff --git a/tests/tsim/inc/simParse.h b/tests/tsim/inc/simParse.h new file mode 100644 index 0000000000000000000000000000000000000000..ef7d8e5ce72cc9bf0ae52380089d36576e84bd28 --- /dev/null +++ b/tests/tsim/inc/simParse.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef __SIM_PARSE_H__ +#define __SIM_PARSE_H__ + +#define MAX_NUM_CMD 64 +#define MAX_NUM_LABLES 100 +#define MAX_LABEL_LEN 40 +#define MAX_NUM_BLOCK 100 +#define MAX_NUM_JUMP 100 +#define MAX_LINE_LEN 3000 +#define MAX_CMD_LINES 2048 +#define MAX_OPTION_BUFFER 64000 + +enum { + BLOCK_IF, + BLOCK_WHILE, + BLOCK_SWITCH, +}; + +/* label stack */ +typedef struct { + char top; /* number of labels */ + int16_t pos[MAX_NUM_LABLES]; /* the position of the label */ + char label[MAX_NUM_LABLES][MAX_LABEL_LEN]; /* name of the label */ +} SLabel; + +/* block definition */ +typedef struct { + char top; /* the number of blocks stacked */ + char type[MAX_NUM_BLOCK]; /* the block type */ + int16_t *pos[MAX_NUM_BLOCK]; /* position of the jump for if/elif/case */ + int16_t back[MAX_NUM_BLOCK]; /* go back, endw and continue */ + char numJump[MAX_NUM_BLOCK]; + int16_t *jump[MAX_NUM_BLOCK][MAX_NUM_JUMP]; /* break or elif */ + char sexp[MAX_NUM_BLOCK][40]; /*switch expression */ + char sexpLen[MAX_NUM_BLOCK]; /*switch expression length */ +} SBlock; + +bool simParseExpression(char *token, int32_t lineNum); + +#endif \ No newline at end of file diff --git a/tests/tsim/src/simExe.c b/tests/tsim/src/simExe.c new file mode 100644 index 0000000000000000000000000000000000000000..843335406c60db688649daf452286420d09928f1 --- /dev/null +++ b/tests/tsim/src/simExe.c @@ -0,0 +1,1120 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#define _DEFAULT_SOURCE +#include "os.h" +#include "sim.h" +#include "taos.h" +#include "taoserror.h" +#include "tglobal.h" +#include "tutil.h" +#include "cJSON.h" +#undef TAOS_MEM_CHECK + +void simLogSql(char *sql, bool useSharp) { + static FILE *fp = NULL; + char filename[256]; + sprintf(filename, "%s/sim.sql", tsScriptDir); + if (fp == NULL) { + fp = fopen(filename, "w"); + if (fp == NULL) { + fprintf(stderr, "ERROR: failed to open file: %s\n", filename); + return; + } + } + if (useSharp) { + fprintf(fp, "# %s;\n", sql); + } else { + fprintf(fp, "%s;\n", sql); + } + + fflush(fp); +} + +char *simParseArbitratorName(char *varName); +char *simParseHostName(char *varName); +char *simGetVariable(SScript *script, char *varName, int32_t varLen) { + if (strncmp(varName, "hostname", 8) == 0) { + return simParseHostName(varName); + } + + if (strncmp(varName, "arbitrator", 10) == 0) { + return simParseArbitratorName(varName); + } + + if (strncmp(varName, "error", varLen) == 0) return script->error; + + if (strncmp(varName, "rows", varLen) == 0) return script->rows; + + if (strncmp(varName, "system_exit", varLen) == 0) return script->system_exit_code; + + if (strncmp(varName, "system_content", varLen) == 0) return script->system_ret_content; + + // variable like data2_192.168.0.1 + if (strncmp(varName, "data", 4) == 0) { + if (varLen < 6) { + return "null"; + } + + if (varName[5] == '_') { + int32_t col = varName[4] - '0'; + if (col < 0 || col >= MAX_QUERY_COL_NUM) { + return "null"; + } + + char * keyName; + int32_t keyLen; + paGetToken(varName + 6, &keyName, &keyLen); + + for (int32_t i = 0; i < MAX_QUERY_ROW_NUM; ++i) { + if (strncmp(keyName, script->data[i][0], keyLen) == 0) { + simDebug("script:%s, keyName:%s, keyValue:%s", script->fileName, script->data[i][0], script->data[i][col]); + return script->data[i][col]; + } + } + return "null"; + } else if (varName[6] == '_') { + int32_t col = (varName[4] - '0') * 10 + (varName[5] - '0'); + if (col < 0 || col >= MAX_QUERY_COL_NUM) { + return "null"; + } + + char * keyName; + int32_t keyLen; + paGetToken(varName + 7, &keyName, &keyLen); + + for (int32_t i = 0; i < MAX_QUERY_ROW_NUM; ++i) { + if (strncmp(keyName, script->data[i][0], keyLen) == 0) { + simTrace("script:%s, keyName:%s, keyValue:%s", script->fileName, script->data[i][0], script->data[i][col]); + return script->data[i][col]; + } + } + return "null"; + } else { + int32_t row = varName[4] - '0'; + int32_t col = varName[5] - '0'; + if (row < 0 || row >= MAX_QUERY_ROW_NUM) { + return "null"; + } + if (col < 0 || col >= MAX_QUERY_COL_NUM) { + return "null"; + } + + simDebug("script:%s, data[%d][%d]=%s", script->fileName, row, col, script->data[row][col]); + return script->data[row][col]; + } + } + + for (int32_t i = 0; i < script->varLen; ++i) { + SVariable *var = &script->variables[i]; + if (var->varNameLen != varLen) { + continue; + } + if (strncmp(varName, var->varName, varLen) == 0) { + // if (strlen(var->varValue) != 0) + // simDebug("script:%s, var:%s, value:%s", script->fileName, + // var->varName, var->varValue); + return var->varValue; + } + } + + if (script->varLen >= MAX_VAR_LEN) { + simError("script:%s, too many varialbes:%d", script->fileName, script->varLen); + exit(0); + } + + SVariable *var = &script->variables[script->varLen]; + script->varLen++; + strncpy(var->varName, varName, varLen); + var->varNameLen = varLen; + var->varValue[0] = 0; + return var->varValue; +} + +int32_t simExecuteExpression(SScript *script, char *sim_exp) { + char * op1, *op2, *var1, *var2, *var3, *rest; + int32_t op1Len, op2Len, var1Len, var2Len, var3Len, val0, val1; + char t0[1024], t1[1024], t2[1024], t3[2048]; + int32_t result; + + rest = paGetToken(sim_exp, &var1, &var1Len); + rest = paGetToken(rest, &op1, &op1Len); + rest = paGetToken(rest, &var2, &var2Len); + rest = paGetToken(rest, &op2, &op2Len); + + if (var1[0] == '$') + strcpy(t0, simGetVariable(script, var1 + 1, var1Len - 1)); + else { + memcpy(t0, var1, var1Len); + t0[var1Len] = 0; + } + + if (var2[0] == '$') + strcpy(t1, simGetVariable(script, var2 + 1, var2Len - 1)); + else { + memcpy(t1, var2, var2Len); + t1[var2Len] = 0; + } + + if (op2Len != 0) { + rest = paGetToken(rest, &var3, &var3Len); + + if (var3[0] == '$') + strcpy(t2, simGetVariable(script, var3 + 1, var3Len - 1)); + else { + memcpy(t2, var3, var3Len); + t2[var3Len] = 0; + } + + if (op2[0] == '+') { + sprintf(t3, "%lld", atoll(t1) + atoll(t2)); + } else if (op2[0] == '-') { + sprintf(t3, "%lld", atoll(t1) - atoll(t2)); + } else if (op2[0] == '*') { + sprintf(t3, "%lld", atoll(t1) * atoll(t2)); + } else if (op2[0] == '/') { + sprintf(t3, "%lld", atoll(t1) / atoll(t2)); + } else if (op2[0] == '.') { + sprintf(t3, "%s%s", t1, t2); + } + } else { + strcpy(t3, t1); + } + + result = 0; + + if (op1Len == 1) { + if (op1[0] == '=') { + strcpy(simGetVariable(script, var1 + 1, var1Len - 1), t3); + } else if (op1[0] == '<') { + val0 = atoi(t0); + val1 = atoi(t3); + if (val0 >= val1) result = -1; + } else if (op1[0] == '>') { + val0 = atoi(t0); + val1 = atoi(t3); + if (val0 <= val1) result = -1; + } + } else { + if (op1[0] == '=' && op1[1] == '=') { + if (strcmp(t0, t3) != 0) result = -1; + } else if (op1[0] == '!' && op1[1] == '=') { + if (strcmp(t0, t3) == 0) result = -1; + } else if (op1[0] == '<' && op1[1] == '=') { + val0 = atoi(t0); + val1 = atoi(t3); + if (val0 > val1) result = -1; + } else if (op1[0] == '>' && op1[1] == '=') { + val0 = atoi(t0); + val1 = atoi(t3); + if (val0 < val1) result = -1; + } + } + + return result; +} + +bool simExecuteExpCmd(SScript *script, char *option) { + simExecuteExpression(script, option); + script->linePos++; + return true; +} + +bool simExecuteTestCmd(SScript *script, char *option) { + int32_t result; + result = simExecuteExpression(script, option); + + if (result >= 0) + script->linePos++; + else + script->linePos = script->lines[script->linePos].jump; + + return true; +} + +bool simExecuteGotoCmd(SScript *script, char *option) { + script->linePos = script->lines[script->linePos].jump; + return true; +} + +bool simExecuteRunCmd(SScript *script, char *option) { + char *fileName = option; + if (fileName == NULL || strlen(fileName) == 0) { + sprintf(script->error, "lineNum:%d. script file is null", script->lines[script->linePos].lineNum); + return false; + } + + SScript *newScript = simParseScript(option); + if (newScript == NULL) { + sprintf(script->error, "lineNum:%d. parse file:%s error", script->lines[script->linePos].lineNum, fileName); + return false; + } + + simInfo("script:%s, start to execute", newScript->fileName); + + newScript->type = SIM_SCRIPT_TYPE_MAIN; + simScriptPos++; + simScriptList[simScriptPos] = newScript; + + script->linePos++; + return true; +} + +bool simExecuteRunBackCmd(SScript *script, char *option) { + char *fileName = option; + if (fileName == NULL || strlen(fileName) == 0) { + sprintf(script->error, "lineNum:%d. script file is null", script->lines[script->linePos].lineNum); + return false; + } + + SScript *newScript = simParseScript(option); + if (newScript == NULL) { + sprintf(script->error, "lineNum:%d. parse file:%s error", script->lines[script->linePos].lineNum, fileName); + return false; + } + + newScript->type = SIM_SCRIPT_TYPE_BACKGROUND; + script->bgScripts[script->bgScriptLen++] = newScript; + simInfo("script:%s, start to execute in background,", newScript->fileName); + + if (pthread_create(&newScript->bgPid, NULL, simExecuteScript, (void *)newScript) != 0) { + sprintf(script->error, "lineNum:%d. create background thread failed", script->lines[script->linePos].lineNum); + return false; + } else { + simDebug("script:%s, background thread:0x%08" PRIx64 " is created", newScript->fileName, + taosGetPthreadId(newScript->bgPid)); + } + + script->linePos++; + return true; +} + +void simReplaceShToBat(char *dst) { + char* sh = strstr(dst, ".sh"); + if (sh != NULL) { + int32_t dstLen = (int32_t)strlen(dst); + char *end = dst + dstLen; + *(end + 1) = 0; + + for (char *p = end; p >= sh; p--) { + *(p + 1) = *p; + } + + sh[0] = '.'; + sh[1] = 'b'; + sh[2] = 'a'; + sh[3] = 't'; + sh[4] = ' '; + } + + simDebug("system cmd is %s", dst); +} + +bool simExecuteSystemCmd(SScript *script, char *option) { + char buf[4096] = {0}; + +#ifndef WINDOWS + sprintf(buf, "cd %s; ", tsScriptDir); + simVisuallizeOption(script, option, buf + strlen(buf)); +#else + sprintf(buf, "%s%s", tsScriptDir, option); + simReplaceShToBat(buf); +#endif + + simLogSql(buf, true); + int32_t code = system(buf); + int32_t repeatTimes = 0; + while (code < 0) { + simError("script:%s, failed to execute %s , code %d, errno:%d %s, repeatTimes:%d", script->fileName, buf, code, + errno, strerror(errno), repeatTimes); + taosMsleep(1000); + taosDflSignal(SIGCHLD); + if (repeatTimes++ >= 10) { + exit(0); + } + } + + sprintf(script->system_exit_code, "%d", code); + script->linePos++; + return true; +} + +void simStoreSystemContentResult(SScript *script, char *filename) { + memset(script->system_ret_content, 0, MAX_SYSTEM_RESULT_LEN); + + FILE *fd; + if ((fd = fopen(filename, "r")) != NULL) { + fread(script->system_ret_content, 1, MAX_SYSTEM_RESULT_LEN - 1, fd); + fclose(fd); + char rmCmd[MAX_FILE_NAME_LEN] = {0}; + sprintf(rmCmd, "rm -f %s", filename); + system(rmCmd); + } +} + +bool simExecuteSystemContentCmd(SScript *script, char *option) { + char buf[4096] = {0}; + char buf1[4096 + 512] = {0}; + char filename[400] = {0}; + sprintf(filename, "%s/%s.tmp", tsScriptDir, script->fileName); + + sprintf(buf, "cd %s; ", tsScriptDir); + simVisuallizeOption(script, option, buf + strlen(buf)); + sprintf(buf1, "%s > %s 2>/dev/null", buf, filename); + + sprintf(script->system_exit_code, "%d", system(buf1)); + simStoreSystemContentResult(script, filename); + + script->linePos++; + return true; +} + +bool simExecutePrintCmd(SScript *script, char *rest) { + char buf[65536]; + + simVisuallizeOption(script, rest, buf); + rest = buf; + + simInfo("script:%s, %s", script->fileName, rest); + script->linePos++; + return true; +} + +bool simExecuteSleepCmd(SScript *script, char *option) { + int32_t delta; + char buf[1024]; + + simVisuallizeOption(script, option, buf); + option = buf; + + delta = atoi(option); + if (delta <= 0) delta = 5; + + simInfo("script:%s, sleep %dms begin", script->fileName, delta); + taosMsleep(delta); + simInfo("script:%s, sleep %dms finished", script->fileName, delta); + + char sleepStr[32] = {0}; + sprintf(sleepStr, "sleep %d", delta); + simLogSql(sleepStr, true); + + script->linePos++; + return true; +} + +bool simExecuteReturnCmd(SScript *script, char *option) { + char buf[1024]; + + simVisuallizeOption(script, option, buf); + option = buf; + + int32_t ret = 1; + if (option && option[0] != 0) ret = atoi(option); + + if (ret < 0) { + sprintf(script->error, "lineNum:%d. error return %s", script->lines[script->linePos].lineNum, option); + return false; + } else { + simInfo("script:%s, return cmd execute with:%d", script->fileName, ret); + script->linePos = script->numOfLines; + } + + script->linePos++; + return true; +} + +void simVisuallizeOption(SScript *script, char *src, char *dst) { + char * var, *token, *value; + int32_t dstLen, srcLen, tokenLen; + + dst[0] = 0, dstLen = 0; + + while (1) { + var = strchr(src, '$'); + if (var == NULL) break; + if (var && ((var - src - 1) > 0) && *(var - 1) == '\\') { + srcLen = (int32_t)(var - src - 1); + memcpy(dst + dstLen, src, srcLen); + dstLen += srcLen; + src = var; + break; + } + + srcLen = (int32_t)(var - src); + memcpy(dst + dstLen, src, srcLen); + dstLen += srcLen; + + src = paGetToken(var + 1, &token, &tokenLen); + value = simGetVariable(script, token, tokenLen); + + strcpy(dst + dstLen, value); + dstLen += (int32_t)strlen(value); + } + + strcpy(dst + dstLen, src); +} + +void simCloseRestFulConnect(SScript *script) { + memset(script->auth, 0, sizeof(script->auth)); +} + +void simCloseNativeConnect(SScript *script) { + if (script->taos == NULL) return; + + simDebug("script:%s, taos:%p closed", script->fileName, script->taos); + taos_close(script->taos); + + script->taos = NULL; +} + +void simCloseTaosdConnect(SScript *script) { + if (simAsyncQuery) { + simCloseRestFulConnect(script); + } else { + simCloseNativeConnect(script); + } +} +// {"status":"succ","code":0,"desc":"/KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04"} +// {"status":"succ","head":["affected_rows"],"data":[[1]],"rows":1} +// {"status":"succ","head":["ts","i"],"data":[["2017-12-25 21:28:41.022",1],["2017-12-25 21:28:42.022",2],["2017-12-25 21:28:43.022",3],["2017-12-25 21:28:44.022",4],["2017-12-25 21:28:45.022",5],["2017-12-25 21:28:46.022",6],["2017-12-25 21:28:47.022",7],["2017-12-25 21:28:48.022",8],["2017-12-25 21:28:49.022",9],["2017-12-25 21:28:50.022",10]],"rows":10} +int32_t simParseHttpCommandResult(SScript *script, char *command) { + cJSON* root = cJSON_Parse(command); + if (root == NULL) { + simError("script:%s, failed to parse json, response:%s", script->fileName, command); + return -1; + } + + cJSON *status = cJSON_GetObjectItem(root, "status"); + if (status == NULL) { + simError("script:%s, failed to parse json, status is null, response:%s", script->fileName, command); + cJSON_Delete(root); + return -1; + } + + if (status->valuestring == NULL || strlen(status->valuestring) == 0) { + simError("script:%s, failed to parse json, status value is null, response:%s", script->fileName, command); + cJSON_Delete(root); + return -1; + } + + if (strcmp(status->valuestring, "succ") != 0) { + cJSON *code = cJSON_GetObjectItem(root, "code"); + if (code == NULL) { + simError("script:%s, failed to parse json, code is null, response:%s", script->fileName, command); + cJSON_Delete(root); + return -1; + } + int32_t retcode = (int32_t)code->valueint; + if (retcode != 1017) { + simError("script:%s, json:status:%s not equal to succ, response:%s", script->fileName, status->valuestring, + command); + cJSON_Delete(root); + return retcode; + } else { + simDebug("script:%s, json:status:%s not equal to succ, but code is %d, response:%s", script->fileName, + status->valuestring, retcode, command); + cJSON_Delete(root); + return 0; + } + } + + cJSON *desc = cJSON_GetObjectItem(root, "desc"); + if (desc != NULL) { + if (desc->valuestring == NULL || strlen(desc->valuestring) == 0) { + simError("script:%s, failed to parse json, desc value is null, response:%s", script->fileName, command); + cJSON_Delete(root); + return -1; + } + strcpy(script->auth, desc->valuestring); + cJSON_Delete(root); + return 0; + } + + cJSON *data = cJSON_GetObjectItem(root, "data"); + if (data == NULL) { + simError("script:%s, failed to parse json, data is null, response:%s", script->fileName, command); + cJSON_Delete(root); + return -1; + } + + int32_t rowsize = cJSON_GetArraySize(data); + if (rowsize < 0) { + simError("script:%s, failed to parse json:data, data size %d, response:%s", script->fileName, rowsize, command); + cJSON_Delete(root); + return -1; + } + + int32_t rowIndex = 0; + sprintf(script->rows, "%d", rowsize); + for (int32_t r = 0; r < rowsize; ++r) { + cJSON *row = cJSON_GetArrayItem(data, r); + if (row == NULL) continue; + if (rowIndex++ >= 10) break; + + int32_t colsize = cJSON_GetArraySize(row); + if (colsize < 0) { + break; + } + + colsize = MIN(10, colsize); + for (int32_t c = 0; c < colsize; ++c) { + cJSON *col = cJSON_GetArrayItem(row, c); + if (col->valuestring != NULL) { + strcpy(script->data[r][c], col->valuestring); + } else { + if (col->numberstring[0] == 0) { + strcpy(script->data[r][c], "null"); + } else { + strcpy(script->data[r][c], col->numberstring); + } + } + } + } + + return 0; +} + +int32_t simExecuteRestFulCommand(SScript *script, char *command) { + char buf[5000] = {0}; + sprintf(buf, "%s 2>/dev/null", command); + + FILE *fp = popen(buf, "r"); + if (fp == NULL) { + simError("failed to execute %s", buf); + return -1; + } + + int32_t mallocSize = 2000; + int32_t alreadyReadSize = 0; + char * content = malloc(mallocSize); + + while (!feof(fp)) { + int32_t availSize = mallocSize - alreadyReadSize; + int32_t len = (int32_t)fread(content + alreadyReadSize, 1, availSize, fp); + if (len >= availSize) { + alreadyReadSize += len; + mallocSize *= 2; + content = realloc(content, mallocSize); + } + } + + pclose(fp); + + return simParseHttpCommandResult(script, content); +} + +bool simCreateRestFulConnect(SScript *script, char *user, char *pass) { + char command[4096]; + sprintf(command, "curl 127.0.0.1:6041/rest/login/%s/%s", user, pass); + + bool success = false; + for (int32_t attempt = 0; attempt < 10; ++attempt) { + success = simExecuteRestFulCommand(script, command) == 0; + if (!success) { + simDebug("script:%s, user:%s connect taosd failed:%s, attempt:%d", script->fileName, user, taos_errstr(NULL), + attempt); + taosMsleep(1000); + } else { + simDebug("script:%s, user:%s connect taosd successed, attempt:%d", script->fileName, user, attempt); + break; + } + } + + if (!success) { + sprintf(script->error, "lineNum:%d. connect taosd failed:%s", script->lines[script->linePos].lineNum, + taos_errstr(NULL)); + return false; + } + + simDebug("script:%s, connect taosd successed, auth:%p", script->fileName, script->auth); + return true; +} + +bool simCreateNativeConnect(SScript *script, char *user, char *pass) { + simCloseTaosdConnect(script); + void *taos = NULL; + for (int32_t attempt = 0; attempt < 10; ++attempt) { + if (abortExecution) { + script->killed = true; + return false; + } + + taos = taos_connect(NULL, user, pass, NULL, tsDnodeShellPort); + if (taos == NULL) { + simDebug("script:%s, user:%s connect taosd failed:%s, attempt:%d", script->fileName, user, taos_errstr(NULL), + attempt); + taosMsleep(1000); + } else { + simDebug("script:%s, user:%s connect taosd successed, attempt:%d", script->fileName, user, attempt); + break; + } + } + + if (taos == NULL) { + sprintf(script->error, "lineNum:%d. connect taosd failed:%s", script->lines[script->linePos].lineNum, + taos_errstr(NULL)); + return false; + } + + script->taos = taos; + simDebug("script:%s, connect taosd successed, taos:%p", script->fileName, taos); + + return true; +} + +bool simCreateTaosdConnect(SScript *script, char *rest) { + char * user = TSDB_DEFAULT_USER; + char * token; + int32_t tokenLen; + rest = paGetToken(rest, &token, &tokenLen); + rest = paGetToken(rest, &token, &tokenLen); + if (tokenLen != 0) { + user = token; + } + + if (simAsyncQuery) { + return simCreateRestFulConnect(script, user, TSDB_DEFAULT_PASS); + } else { + return simCreateNativeConnect(script, user, TSDB_DEFAULT_PASS); + } +} + +bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) { + char timeStr[30] = {0}; + time_t tt; + struct tm *tp; + SCmdLine * line = &script->lines[script->linePos]; + int32_t ret = -1; + + TAOS_RES *pSql = NULL; + + for (int32_t attempt = 0; attempt < 10; ++attempt) { + if (abortExecution) { + script->killed = true; + return false; + } + + simLogSql(rest, false); + pSql = taos_query(script->taos, rest); + ret = taos_errno(pSql); + + if (ret == TSDB_CODE_MND_TABLE_ALREADY_EXIST || ret == TSDB_CODE_MND_DB_ALREADY_EXIST) { + simDebug("script:%s, taos:%p, %s success, ret:%d:%s", script->fileName, script->taos, rest, ret & 0XFFFF, + tstrerror(ret)); + ret = 0; + break; + } else if (ret != 0) { + simDebug("script:%s, taos:%p, %s failed, ret:%d:%s, error:%s", script->fileName, script->taos, rest, ret & 0XFFFF, + tstrerror(ret), taos_errstr(pSql)); + + if (line->errorJump == SQL_JUMP_TRUE) { + script->linePos = line->jump; + taos_free_result(pSql); + return true; + } + taosMsleep(1000); + } else { + break; + } + + taos_free_result(pSql); + } + + if (ret) { + sprintf(script->error, "lineNum:%d. sql:%s failed, ret:%d:%s", line->lineNum, rest, ret & 0XFFFF, tstrerror(ret)); + return false; + } + + int32_t numOfRows = 0; + int32_t num_fields = taos_field_count(pSql); + if (num_fields != 0) { + if (pSql == NULL) { + simDebug("script:%s, taos:%p, %s failed, result is null", script->fileName, script->taos, rest); + if (line->errorJump == SQL_JUMP_TRUE) { + script->linePos = line->jump; + return true; + } + + sprintf(script->error, "lineNum:%d. result set null, sql:%s", line->lineNum, rest); + return false; + } + + TAOS_ROW row; + + while ((row = taos_fetch_row(pSql))) { + if (numOfRows < MAX_QUERY_ROW_NUM) { + TAOS_FIELD *fields = taos_fetch_fields(pSql); + int32_t * length = taos_fetch_lengths(pSql); + + for (int32_t i = 0; i < num_fields; i++) { + char *value = NULL; + if (i < MAX_QUERY_COL_NUM) { + value = script->data[numOfRows][i]; + } + if (value == NULL) { + continue; + } + + if (row[i] == 0) { + strcpy(value, TSDB_DATA_NULL_STR); + continue; + } + + switch (fields[i].type) { + case TSDB_DATA_TYPE_BOOL: + sprintf(value, "%s", ((((int32_t)(*((char *)row[i]))) == 1) ? "1" : "0")); + break; + case TSDB_DATA_TYPE_TINYINT: + sprintf(value, "%d", *((int8_t *)row[i])); + break; + case TSDB_DATA_TYPE_UTINYINT: + sprintf(value, "%u", *((uint8_t*)row[i])); + break; + case TSDB_DATA_TYPE_SMALLINT: + sprintf(value, "%d", *((int16_t *)row[i])); + break; + case TSDB_DATA_TYPE_USMALLINT: + sprintf(value, "%u", *((uint16_t *)row[i])); + break; + case TSDB_DATA_TYPE_INT: + sprintf(value, "%d", *((int32_t *)row[i])); + break; + case TSDB_DATA_TYPE_UINT: + sprintf(value, "%u", *((uint32_t *)row[i])); + break; + case TSDB_DATA_TYPE_BIGINT: + sprintf(value, "%" PRId64, *((int64_t *)row[i])); + break; + case TSDB_DATA_TYPE_UBIGINT: + sprintf(value, "%" PRIu64, *((uint64_t *)row[i])); + break; + case TSDB_DATA_TYPE_FLOAT: + sprintf(value, "%.5f", GET_FLOAT_VAL(row[i])); + break; + case TSDB_DATA_TYPE_DOUBLE: + sprintf(value, "%.9lf", GET_DOUBLE_VAL(row[i])); + break; + case TSDB_DATA_TYPE_BINARY: + case TSDB_DATA_TYPE_NCHAR: + if (length[i] < 0 || length[i] > 1 << 20) { + fprintf(stderr, "Invalid length(%d) of BINARY or NCHAR\n", length[i]); + exit(-1); + } + + memset(value, 0, MAX_QUERY_VALUE_LEN); + memcpy(value, row[i], length[i]); + value[length[i]] = 0; + // snprintf(value, fields[i].bytes, "%s", (char *)row[i]); + break; + case TSDB_DATA_TYPE_TIMESTAMP: { + int32_t precision = taos_result_precision(pSql); + if (precision == TSDB_TIME_PRECISION_MILLI) { + tt = (*(int64_t *)row[i]) / 1000; + } else if (precision == TSDB_TIME_PRECISION_MICRO) { + tt = (*(int64_t *)row[i]) / 1000000; + } else { + tt = (*(int64_t *)row[i]) / 1000000000; + } + /* comment out as it make testcases like select_with_tags.sim fail. + but in windows, this may cause the call to localtime crash if tt < 0, + need to find a better solution. + if (tt < 0) { + tt = 0; + } + */ + +#ifdef WINDOWS + if (tt < 0) tt = 0; +#endif + + tp = localtime(&tt); + strftime(timeStr, 64, "%y-%m-%d %H:%M:%S", tp); + if (precision == TSDB_TIME_PRECISION_MILLI) { + sprintf(value, "%s.%03d", timeStr, (int32_t)(*((int64_t *)row[i]) % 1000)); + } else if (precision == TSDB_TIME_PRECISION_MICRO) { + sprintf(value, "%s.%06d", timeStr, (int32_t)(*((int64_t *)row[i]) % 1000000)); + } else { + sprintf(value, "%s.%09d", timeStr, (int32_t)(*((int64_t *)row[i]) % 1000000000)); + } + + break; + } + default: + break; + } // end of switch + } // end of for + } // end of if + numOfRows++; + if (isSlow && numOfRows % 100 == 0) { + taosMsleep(200); + } + if (numOfRows > 2000000000) { + simError("script:%s, too many rows return from query", script->fileName); + break; + } + } + + } else { + numOfRows = taos_affected_rows(pSql); + } + + taos_free_result(pSql); + sprintf(script->rows, "%d", numOfRows); + + script->linePos++; + return true; +} + +bool simExecuteRestFulSqlCommand(SScript *script, char *rest) { + SCmdLine *line = &script->lines[script->linePos]; + char command[4096]; + sprintf(command, "curl -H 'Authorization: Taosd %s' -d \"%s\" 127.0.0.1:6041/rest/sql", script->auth, rest); + + int32_t ret = -1; + for (int32_t attempt = 0; attempt < 10; ++attempt) { + ret = simExecuteRestFulCommand(script, command); + if (ret == TSDB_CODE_MND_TABLE_ALREADY_EXIST || ret == TSDB_CODE_MND_DB_ALREADY_EXIST) { + simDebug("script:%s, taos:%p, %s success, ret:%d:%s", script->fileName, script->taos, rest, ret & 0XFFFF, + tstrerror(ret)); + ret = 0; + break; + } else if (ret != 0) { + simDebug("script:%s, taos:%p, %s failed, ret:%d", script->fileName, script->taos, rest, ret); + + if (line->errorJump == SQL_JUMP_TRUE) { + script->linePos = line->jump; + return true; + } + taosMsleep(1000); + } else { + break; + } + } + + if (ret) { + sprintf(script->error, "lineNum:%d. sql:%s failed, ret:%d", line->lineNum, rest, ret); + return false; + } + + script->linePos++; + return true; +} + +bool simExecuteSqlImpCmd(SScript *script, char *rest, bool isSlow) { + char buf[3000]; + SCmdLine *line = &script->lines[script->linePos]; + + simVisuallizeOption(script, rest, buf); + rest = buf; + + simDebug("script:%s, exec:%s", script->fileName, rest); + strcpy(script->rows, "-1"); + for (int32_t row = 0; row < MAX_QUERY_ROW_NUM; ++row) { + for (int32_t col = 0; col < MAX_QUERY_COL_NUM; ++col) { + strcpy(script->data[row][col], "null"); + } + } + + if (strncmp(rest, "connect", 7) == 0) { + if (!simCreateTaosdConnect(script, rest)) { + return false; + } + script->linePos++; + return true; + } + + if ((!simAsyncQuery && script->taos == NULL) || (simAsyncQuery && script->auth[0] == 0)) { + if (!simCreateTaosdConnect(script, "connect root")) { + if (line->errorJump == SQL_JUMP_TRUE) { + script->linePos = line->jump; + return true; + } + return false; + } + } + + if (strncmp(rest, "close", 5) == 0) { + simCloseTaosdConnect(script); + script->linePos++; + return true; + } + + if (simAsyncQuery) { + return simExecuteRestFulSqlCommand(script, rest); + } else { + return simExecuteNativeSqlCommand(script, rest, isSlow); + } +} + +bool simExecuteSqlCmd(SScript *script, char *rest) { + bool isSlow = false; + return simExecuteSqlImpCmd(script, rest, isSlow); +} + +bool simExecuteSqlSlowCmd(SScript *script, char *rest) { + bool isSlow = true; + return simExecuteSqlImpCmd(script, rest, isSlow); +} + +bool simExecuteRestfulCmd(SScript *script, char *rest) { + FILE *fp = NULL; + char filename[256]; + sprintf(filename, "%s/tmp.sql", tsScriptDir); + fp = fopen(filename, "w"); + if (fp == NULL) { + fprintf(stderr, "ERROR: failed to open file: %s\n", filename); + return false; + } + + char db[64] = {0}; + char tb[64] = {0}; + char gzip[32] = {0}; + int32_t ts; + int32_t times; + sscanf(rest, "%s %s %d %d %s", db, tb, &ts, ×, gzip); + + fprintf(fp, "insert into %s.%s values ", db, tb); + for (int32_t i = 0; i < times; ++i) { + fprintf(fp, "(%d000, %d)", ts + i, ts); + } + fprintf(fp, " \n"); + fflush(fp); + fclose(fp); + + char cmd[1024] = {0}; + if (strcmp(gzip, "gzip") == 0) { + sprintf(cmd, + "curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' --header " + "--compressed --data-ascii @%s 127.0.0.1:7111/rest/sql", + filename); + } else { + sprintf(cmd, + "curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' --header " + "'Transfer-Encoding: chunked' --data-ascii @%s 127.0.0.1:7111/rest/sql", + filename); + } + + return simExecuteSystemCmd(script, cmd); +} + +bool simExecuteSqlErrorCmd(SScript *script, char *rest) { + char buf[3000]; + SCmdLine *line = &script->lines[script->linePos]; + + simVisuallizeOption(script, rest, buf); + rest = buf; + + simDebug("script:%s, exec:%s", script->fileName, rest); + strcpy(script->rows, "-1"); + for (int32_t row = 0; row < MAX_QUERY_ROW_NUM; ++row) { + for (int32_t col = 0; col < MAX_QUERY_COL_NUM; ++col) { + strcpy(script->data[row][col], "null"); + } + } + + if (strncmp(rest, "connect", 7) == 0) { + if (!simCreateTaosdConnect(script, rest)) { + return false; + } + script->linePos++; + return true; + } + + if ((!simAsyncQuery && script->taos == NULL) || (simAsyncQuery && script->auth[0] == 0)) { + if (!simCreateTaosdConnect(script, "connect root")) { + if (line->errorJump == SQL_JUMP_TRUE) { + script->linePos = line->jump; + return true; + } + return false; + } + } + + if (strncmp(rest, "close", 5) == 0) { + simCloseTaosdConnect(script); + script->linePos++; + return true; + } + + int32_t ret; + TAOS_RES *pSql = NULL; + if (simAsyncQuery) { + char command[4096]; + sprintf(command, "curl -H 'Authorization: Taosd %s' -d '%s' 127.0.0.1:6041/rest/sql", script->auth, rest); + ret = simExecuteRestFulCommand(script, command); + } else { + pSql = taos_query(script->taos, rest); + ret = taos_errno(pSql); + taos_free_result(pSql); + } + + if (ret != TSDB_CODE_SUCCESS) { + simDebug("script:%s, taos:%p, %s execute, expect failed, so success, ret:%d:%s", script->fileName, script->taos, + rest, ret & 0XFFFF, tstrerror(ret)); + script->linePos++; + return true; + } + + sprintf(script->error, "lineNum:%d. sql:%s expect failed, but success, ret:%d:%s", line->lineNum, rest, ret & 0XFFFF, + tstrerror(ret)); + + return false; +} + +bool simExecuteLineInsertCmd(SScript *script, char *rest) { + char buf[TSDB_MAX_BINARY_LEN]; + + simVisuallizeOption(script, rest, buf); + rest = buf; + + SCmdLine *line = &script->lines[script->linePos]; + + simInfo("script:%s, %s", script->fileName, rest); + simLogSql(buf, true); + char * lines[] = {rest}; + int32_t ret = taos_insert_lines(script->taos, lines, 1); + if (ret == TSDB_CODE_SUCCESS) { + simDebug("script:%s, taos:%p, %s executed. success.", script->fileName, script->taos, rest); + script->linePos++; + return true; + } else { + sprintf(script->error, "lineNum: %d. line: %s failed, ret:%d:%s", line->lineNum, rest, + ret & 0XFFFF, tstrerror(ret)); + return false; + } +} + +bool simExecuteLineInsertErrorCmd(SScript *script, char *rest) { + char buf[TSDB_MAX_BINARY_LEN]; + + simVisuallizeOption(script, rest, buf); + rest = buf; + + SCmdLine *line = &script->lines[script->linePos]; + + simInfo("script:%s, %s", script->fileName, rest); + simLogSql(buf, true); + char * lines[] = {rest}; + int32_t ret = taos_insert_lines(script->taos, lines, 1); + if (ret == TSDB_CODE_SUCCESS) { + sprintf(script->error, "script:%s, taos:%p, %s executed. expect failed, but success.", script->fileName, script->taos, rest); + script->linePos++; + return false; + } else { + simDebug("lineNum: %d. line: %s failed, ret:%d:%s. Expect failed, so success", line->lineNum, rest, + ret & 0XFFFF, tstrerror(ret)); + return true; + } +} diff --git a/tests/tsim/src/simMain.c b/tests/tsim/src/simMain.c new file mode 100644 index 0000000000000000000000000000000000000000..7d74c62c7daf391fed1bf1afac233f51b84c8f0b --- /dev/null +++ b/tests/tsim/src/simMain.c @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#define _DEFAULT_SOURCE +#include "os.h" +#include "tglobal.h" +#include "sim.h" +#undef TAOS_MEM_CHECK + +bool simAsyncQuery = false; +bool simExecSuccess = false; +bool abortExecution = false; + +void simHandleSignal(int32_t signo, void *sigInfo, void *context) { + simSystemCleanUp(); + abortExecution = true; +// runningScript->killed = true; +// exit(1); +} + +int32_t main(int32_t argc, char *argv[]) { + char scriptFile[MAX_FILE_NAME_LEN] = "sim_main_test.sim"; + + for (int32_t i = 1; i < argc; ++i) { + if (strcmp(argv[i], "-c") == 0 && i < argc - 1) { + tstrncpy(configDir, argv[++i], 128); + } else if (strcmp(argv[i], "-f") == 0 && i < argc - 1) { + strcpy(scriptFile, argv[++i]); + } else if (strcmp(argv[i], "-a") == 0) { + simAsyncQuery = true; + } else { + printf("usage: %s [options] \n", argv[0]); + printf(" [-c config]: config directory, default is: %s\n", configDir); + printf(" [-f script]: script filename\n"); + return 0; + } + } + + if (!simSystemInit()) { + simError("failed to initialize the system"); + simSystemCleanUp(); + return -1; + } + + simInfo("simulator is running ..."); + taosSetSignal(SIGINT, simHandleSignal); + + SScript *script = simParseScript(scriptFile); + if (script == NULL) { + simError("parse script file:%s failed", scriptFile); + return -1; + } + + if (abortExecution) { + simError("execute abort"); + return -1; + } + + simScriptList[++simScriptPos] = script; + simExecuteScript(script); + + int32_t ret = simExecSuccess ? 0 : -1; + simInfo("execute result %d", ret); + + return ret; +} diff --git a/tests/tsim/src/simParse.c b/tests/tsim/src/simParse.c new file mode 100644 index 0000000000000000000000000000000000000000..4dc189d20e235ff70df5ebe76faaa50fc3e20116 --- /dev/null +++ b/tests/tsim/src/simParse.c @@ -0,0 +1,1100 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +/* Thi file is to parse the simScriptPos, function file and default file, + * + * syntax + * + * expression is format like: + * $var [=|<|>|==] var + * or: + * $var = var [+|-|*|/|.] var + * + * if expression + * command + * + * if expression then + * commands + * elif expression + * commands + * elif expression + * commands + * else + * commands + * endi + * + * while expression + * commands + * continue + * break + * endw + * + * switch expression + * case 1 + * commands + * break + * case 2 + * commands + * break + * default + * commands + * ends + * + * label: + * goto label + * + */ + +#define _DEFAULT_SOURCE +#include "os.h" +#include "sim.h" +#include "simParse.h" +#include "tutil.h" +#undef TAOS_MEM_CHECK + +static SCommand *cmdHashList[MAX_NUM_CMD]; +static SCmdLine cmdLine[MAX_CMD_LINES]; +static char parseErr[MAX_ERROR_LEN]; +static char optionBuffer[MAX_OPTION_BUFFER]; +static int32_t numOfLines, optionOffset; +static SLabel label, dest; +static SBlock block; + +int32_t simHashCmd(char *token, int32_t tokenLen) { + int32_t i; + int32_t hash = 0; + + for (i = 0; i < tokenLen; ++i) hash += token[i]; + + hash = hash % MAX_NUM_CMD; + + return hash; +} + +SCommand *simCheckCmd(char *token, int32_t tokenLen) { + int32_t hash; + SCommand *node; + + hash = simHashCmd(token, tokenLen); + + node = cmdHashList[hash]; + + while (node) { + if (node->nlen == tokenLen && strncmp(node->name, token, tokenLen) == 0) { + return node; + } else { + node = node->next; + } + } + + return NULL; +} + +void simAddCmdIntoHash(SCommand *pCmd) { + int32_t hash; + SCommand *node; + + hash = simHashCmd(pCmd->name, (int32_t)strlen(pCmd->name)); + node = cmdHashList[hash]; + pCmd->next = node; + cmdHashList[hash] = pCmd; +} + +void simResetParser() { + optionOffset = 4; + numOfLines = 0; + memset(cmdLine, 0, sizeof(cmdLine)); + memset(optionBuffer, 0, sizeof(optionBuffer)); + memset(&label, 0, sizeof(label)); + memset(&block, 0, sizeof(block)); + memset(&dest, 0, sizeof(dest)); +} + +SScript *simBuildScriptObj(char *fileName) { + int32_t i, destPos; + + /* process labels */ + + cmdLine[numOfLines].cmdno = SIM_CMD_RETURN; + numOfLines++; + + for (i = 0; i < numOfLines; ++i) { + cmdLine[i].errorJump = SQL_JUMP_FALSE; + } + + for (--dest.top; dest.top >= 0; --dest.top) { + for (i = 0; i < label.top; ++i) { + if (strcmp(label.label[i], dest.label[(uint8_t)dest.top]) == 0) break; + } + + if (i == label.top) { + sprintf(parseErr, "label:%s not defined", dest.label[(uint8_t)dest.top]); + return NULL; + } + + destPos = dest.pos[(uint8_t)dest.top]; + cmdLine[destPos].jump = label.pos[i]; + if (cmdLine[destPos].cmdno == SIM_CMD_SQL) { + cmdLine[destPos].errorJump = SQL_JUMP_TRUE; + } + } + + if (block.top != 0) { + sprintf(parseErr, "mismatched block"); + return NULL; + } + + for (i = 0; i < numOfLines; ++i) { + if (cmdLine[i].jump == 0) cmdLine[i].jump = numOfLines; + } + + SScript *script = malloc(sizeof(SScript)); + memset(script, 0, sizeof(SScript)); + + script->type = SIM_SCRIPT_TYPE_MAIN; + script->numOfLines = numOfLines; + tstrncpy(script->fileName, fileName, sizeof(script->fileName)); + + script->optionBuffer = malloc(optionOffset); + memcpy(script->optionBuffer, optionBuffer, optionOffset); + + script->lines = malloc(sizeof(SCmdLine) * numOfLines); + memcpy(script->lines, cmdLine, sizeof(SCmdLine) * numOfLines); + + return script; +} + +SScript *simParseScript(char *fileName) { + FILE * fd; + int32_t tokenLen, lineNum = 0; + char buffer[MAX_LINE_LEN], name[128], *token, *rest; + SCommand *pCmd; + SScript * script; + + if ((fileName[0] == '.') || (fileName[0] == '/')) { + strcpy(name, fileName); + } else { + sprintf(name, "%s/%s", tsScriptDir, fileName); + } + + if ((fd = fopen(name, "r")) == NULL) { + simError("failed to open file:%s", name); + return NULL; + } + + simResetParser(); + + while (!feof(fd)) { + if (fgets(buffer, sizeof(buffer), fd) == NULL) continue; + + lineNum++; + int32_t cmdlen = (int32_t)strlen(buffer); + if (buffer[cmdlen - 1] == '\r' || buffer[cmdlen - 1] == '\n') { + buffer[cmdlen - 1] = 0; + } + rest = buffer; + + for (int32_t i = 0; i < cmdlen; ++i) { + if (buffer[i] == '\r' || buffer[i] == '\n') { + buffer[i] = ' '; + } + } + + again: + rest = paGetToken(rest, &token, &tokenLen); + if (tokenLen == 0) continue; + + if (token[tokenLen - 1] == ':') { + strncpy(label.label[(uint8_t)label.top], token, tokenLen - 1); + label.pos[(uint8_t)label.top] = numOfLines; + label.top++; + goto again; + } + + if (token[0] == '$') { + if (!simParseExpression(token, lineNum)) { + simError("script:%s line:%d %s", fileName, lineNum, parseErr); + return NULL; + } + continue; + } + + if ((pCmd = simCheckCmd(token, tokenLen)) == NULL) { + token[tokenLen] = 0; + simError("script:%s line:%d invalid cmd:%s", fileName, lineNum, token); + return NULL; + } + + if (!pCmd->parseCmd(rest, pCmd, lineNum)) { + simError("script:%s line:%d %s", fileName, lineNum, parseErr); + return NULL; + } + } + + fclose(fd); + + script = simBuildScriptObj(fileName); + if (script == NULL) simError("script:%s %s", fileName, parseErr); + + return script; +} + +int32_t simCheckExpression(char *sim_exp) { + char * op1, *op2, *op, *rest; + int32_t op1Len, op2Len, opLen; + + rest = paGetToken(sim_exp, &op1, &op1Len); + if (op1Len == 0) { + sprintf(parseErr, "expression is required"); + return -1; + } + + rest = paGetToken(rest, &op, &opLen); + if (opLen == 0) { + sprintf(parseErr, "operator is missed"); + return -1; + } + + rest = paGetToken(rest, &op2, &op2Len); + if (op2Len == 0) { + sprintf(parseErr, "operand is missed"); + return -1; + } + + if (opLen == 1) { + if (op[0] != '=' && op[0] != '<' && op[0] != '>') { + sprintf(parseErr, "invalid operator:%s", op); + return -1; + } + + if (op[0] == '=' && op1[0] != '$') { + sprintf(parseErr, "left side of assignment must be variable"); + return -1; + } + } else if (opLen == 2) { + if (op[1] != '=' || (op[0] != '=' && op[0] != '<' && op[0] != '>' && op[0] != '!')) { + sprintf(parseErr, "left side of assignment must be variable"); + return -1; + } + } else { + sprintf(parseErr, "invalid operator:%s", op); + return -1; + } + + rest = paGetToken(rest, &op, &opLen); + + if (opLen == 0) return (int32_t)(rest - sim_exp); + + /* if it is key word "then" */ + if (strncmp(op, "then", 4) == 0) return (int32_t)(op - sim_exp); + + rest = paGetToken(rest, &op2, &op2Len); + if (op2Len == 0) { + sprintf(parseErr, "operand is missed"); + return -1; + } + + if (opLen > 1) { + sprintf(parseErr, "invalid operator:%s", op); + return -1; + } + + if (op[0] == '+' || op[0] == '-' || op[0] == '*' || op[0] == '/' || op[0] == '.') { + return (int32_t)(rest - sim_exp); + } + + return -1; +} + +bool simParseExpression(char *token, int32_t lineNum) { + int32_t expLen; + + expLen = simCheckExpression(token); + if (expLen <= 0) return -1; + + cmdLine[numOfLines].cmdno = SIM_CMD_EXP; + cmdLine[numOfLines].lineNum = lineNum; + cmdLine[numOfLines].optionOffset = optionOffset; + memcpy(optionBuffer + optionOffset, token, expLen); + optionOffset += expLen + 1; + *(optionBuffer + optionOffset - 1) = 0; + + numOfLines++; + return true; +} + +bool simParseIfCmd(char *rest, SCommand *pCmd, int32_t lineNum) { + char * ret; + int32_t expLen; + + expLen = simCheckExpression(rest); + + if (expLen <= 0) return -1; + + ret = rest + expLen; + + if (strncmp(ret, "then", 4) == 0) { + block.type[(uint8_t)block.top] = BLOCK_IF; + block.pos[(uint8_t)block.top] = &cmdLine[numOfLines].jump; + block.top++; + } else { + cmdLine[numOfLines].jump = numOfLines + 2; + } + + cmdLine[numOfLines].optionOffset = optionOffset; + memcpy(optionBuffer + optionOffset, rest, expLen); + optionOffset += expLen + 1; + *(optionBuffer + optionOffset - 1) = 0; + cmdLine[numOfLines].cmdno = SIM_CMD_TEST; + cmdLine[numOfLines].lineNum = lineNum; + + numOfLines++; + return true; +} + +bool simParseElifCmd(char *rest, SCommand *pCmd, int32_t lineNum) { + int32_t expLen; + + expLen = simCheckExpression(rest); + + if (expLen <= 0) return -1; + + if (block.top < 1) { + sprintf(parseErr, "no matching if"); + return false; + } + + if (block.type[block.top - 1] != BLOCK_IF) { + sprintf(parseErr, "no matched if block"); + return false; + } + + cmdLine[numOfLines].cmdno = SIM_CMD_GOTO; + block.jump[block.top - 1][(uint8_t)block.numJump[block.top - 1]] = &(cmdLine[numOfLines].jump); + block.numJump[block.top - 1]++; + + numOfLines++; + + *(block.pos[block.top - 1]) = numOfLines; + block.pos[block.top - 1] = &cmdLine[numOfLines].jump; + + cmdLine[numOfLines].optionOffset = optionOffset; + memcpy(optionBuffer + optionOffset, rest, expLen); + optionOffset += expLen + 1; + *(optionBuffer + optionOffset - 1) = 0; + cmdLine[numOfLines].cmdno = SIM_CMD_TEST; + cmdLine[numOfLines].lineNum = lineNum; + + numOfLines++; + return true; +} + +bool simParseElseCmd(char *rest, SCommand *pCmd, int32_t lineNum) { + if (block.top < 1) { + sprintf(parseErr, "no matching if"); + return false; + } + + if (block.type[block.top - 1] != BLOCK_IF) { + sprintf(parseErr, "no matched if block"); + return false; + } + + cmdLine[numOfLines].cmdno = SIM_CMD_GOTO; + block.jump[block.top - 1][(uint8_t)block.numJump[block.top - 1]] = &(cmdLine[numOfLines].jump); + block.numJump[block.top - 1]++; + + numOfLines++; + + *(block.pos[block.top - 1]) = numOfLines; + block.pos[block.top - 1] = NULL; + + return true; +} + +bool simParseEndiCmd(char *rest, SCommand *pCmd, int32_t lineNum) { + int32_t i; + + if (block.top < 1) { + sprintf(parseErr, "no matching if"); + return false; + } + + if (block.type[block.top - 1] != BLOCK_IF) { + sprintf(parseErr, "no matched if block"); + return false; + } + + if (block.pos[block.top - 1]) *(block.pos[block.top - 1]) = numOfLines; + + for (i = 0; i < block.numJump[block.top - 1]; ++i) { + *(block.jump[block.top - 1][i]) = numOfLines; + } + + block.numJump[block.top - 1] = 0; + block.top--; + + return true; +} + +bool simParseWhileCmd(char *rest, SCommand *pCmd, int32_t lineNum) { + int32_t expLen; + + expLen = simCheckExpression(rest); + + if (expLen <= 0) return false; + + block.type[(uint8_t)block.top] = BLOCK_WHILE; + block.pos[(uint8_t)block.top] = &(cmdLine[numOfLines].jump); + block.back[(uint8_t)block.top] = numOfLines; + block.top++; + + cmdLine[numOfLines].optionOffset = optionOffset; + memcpy(optionBuffer + optionOffset, rest, expLen); + optionOffset += expLen + 1; + *(optionBuffer + optionOffset - 1) = 0; + cmdLine[numOfLines].cmdno = SIM_CMD_TEST; + cmdLine[numOfLines].lineNum = lineNum; + + numOfLines++; + return true; +} + +bool simParseEndwCmd(char *rest, SCommand *pCmd, int32_t lineNum) { + int32_t i; + + if (block.top < 1) { + sprintf(parseErr, "no matching while"); + return false; + } + + if (block.type[block.top - 1] != BLOCK_WHILE) { + sprintf(parseErr, "no matched while block"); + return false; + } + + cmdLine[numOfLines].cmdno = SIM_CMD_GOTO; + cmdLine[numOfLines].jump = block.back[block.top - 1]; + cmdLine[numOfLines].lineNum = lineNum; + numOfLines++; + + *(block.pos[block.top - 1]) = numOfLines; + + for (i = 0; i < block.numJump[block.top - 1]; ++i) { + *(block.jump[block.top - 1][i]) = numOfLines; + } + + block.top--; + + return true; +} + +bool simParseSwitchCmd(char *rest, SCommand *pCmd, int32_t lineNum) { + char * token; + int32_t tokenLen; + + rest = paGetToken(rest, &token, &tokenLen); + if (tokenLen == 0) { + sprintf(parseErr, "switch should be followed by variable"); + return false; + } + + if (token[0] != '$') { + sprintf(parseErr, "switch must be followed by variable"); + return false; + } + + memcpy(block.sexp[(uint8_t)block.top], token, tokenLen); + block.sexpLen[(uint8_t)block.top] = tokenLen; + block.type[(uint8_t)block.top] = BLOCK_SWITCH; + block.top++; + + return true; +} + +bool simParseCaseCmd(char *rest, SCommand *pCmd, int32_t lineNum) { + char * token; + int32_t tokenLen; + + rest = paGetToken(rest, &token, &tokenLen); + if (tokenLen == 0) { + sprintf(parseErr, "case should be followed by value"); + return false; + } + + if (block.top < 1) { + sprintf(parseErr, "no matching switch"); + return false; + } + + if (block.type[block.top - 1] != BLOCK_SWITCH) { + sprintf(parseErr, "case not matched"); + return false; + } + + if (block.pos[block.top - 1] != NULL) { + *(block.pos[block.top - 1]) = numOfLines; + } + + block.pos[block.top - 1] = &(cmdLine[numOfLines].jump); + + cmdLine[numOfLines].cmdno = SIM_CMD_TEST; + cmdLine[numOfLines].lineNum = lineNum; + cmdLine[numOfLines].optionOffset = optionOffset; + memcpy(optionBuffer + optionOffset, block.sexp[block.top - 1], block.sexpLen[block.top - 1]); + optionOffset += block.sexpLen[block.top - 1]; + *(optionBuffer + optionOffset++) = ' '; + *(optionBuffer + optionOffset++) = '='; + *(optionBuffer + optionOffset++) = '='; + *(optionBuffer + optionOffset++) = ' '; + memcpy(optionBuffer + optionOffset, token, tokenLen); + optionOffset += tokenLen + 1; + *(optionBuffer + optionOffset - 1) = 0; + + numOfLines++; + return true; +} + +bool simParseBreakCmd(char *rest, SCommand *pCmd, int32_t lineNum) { + if (block.top < 1) { + sprintf(parseErr, "no blcok exists"); + return false; + } + + if (block.type[block.top - 1] != BLOCK_SWITCH && block.type[block.top - 1] != BLOCK_WHILE) { + sprintf(parseErr, "not in switch or while block"); + return false; + } + + block.jump[block.top - 1][(uint8_t)block.numJump[block.top - 1]] = &(cmdLine[numOfLines].jump); + block.numJump[block.top - 1]++; + + cmdLine[numOfLines].cmdno = SIM_CMD_GOTO; + cmdLine[numOfLines].lineNum = lineNum; + + numOfLines++; + return true; +} + +bool simParseDefaultCmd(char *rest, SCommand *pCmd, int32_t lineNum) { + if (block.top < 1) { + sprintf(parseErr, "no matching switch"); + return false; + } + + if (block.type[block.top - 1] != BLOCK_SWITCH) { + sprintf(parseErr, "default should be matched with switch"); + return false; + } + + if (block.pos[block.top - 1] != NULL) { + *(block.pos[block.top - 1]) = numOfLines; + } + + return true; +} + +bool simParseEndsCmd(char *rest, SCommand *pCmd, int32_t lineNum) { + int32_t i; + + if (block.top < 1) { + sprintf(parseErr, "no matching switch"); + return false; + } + + if (block.type[block.top - 1] != BLOCK_SWITCH) { + sprintf(parseErr, "ends should be matched with switch"); + return false; + } + + for (i = 0; i < block.numJump[block.top - 1]; ++i) { + *(block.jump[block.top - 1][i]) = numOfLines; + } + + block.numJump[block.top - 1] = 0; + block.top--; + + return true; +} + +bool simParseContinueCmd(char *rest, SCommand *pCmd, int32_t lineNum) { + if (block.top < 1) { + sprintf(parseErr, "no matching while"); + return false; + } + + if (block.type[block.top - 1] != BLOCK_WHILE) { + sprintf(parseErr, "continue should be matched with while cmd"); + return false; + } + + cmdLine[numOfLines].cmdno = SIM_CMD_GOTO; + cmdLine[numOfLines].lineNum = lineNum; + cmdLine[numOfLines].jump = block.back[block.top - 1]; + + numOfLines++; + return true; +} + +bool simParsePrintCmd(char *rest, SCommand *pCmd, int32_t lineNum) { + int32_t expLen; + + rest++; + cmdLine[numOfLines].cmdno = SIM_CMD_PRINT; + cmdLine[numOfLines].lineNum = lineNum; + cmdLine[numOfLines].optionOffset = optionOffset; + expLen = (int32_t)strlen(rest); + memcpy(optionBuffer + optionOffset, rest, expLen); + optionOffset += expLen + 1; + *(optionBuffer + optionOffset - 1) = 0; + + numOfLines++; + return true; +} + +void simCheckSqlOption(char *rest) { + int32_t valueLen; + char * value, *xpos; + + xpos = strstr(rest, " -x"); // need a blank + if (xpos) { + paGetToken(xpos + 3, &value, &valueLen); + if (valueLen != 0) { + memcpy(dest.label[(uint8_t)dest.top], value, valueLen); + dest.label[(uint8_t)dest.top][valueLen] = 0; + dest.pos[(uint8_t)dest.top] = numOfLines; + dest.top++; + + *xpos = 0; + } + } +} + +bool simParseSqlCmd(char *rest, SCommand *pCmd, int32_t lineNum) { + int32_t expLen; + + rest++; + simCheckSqlOption(rest); + cmdLine[numOfLines].cmdno = SIM_CMD_SQL; + cmdLine[numOfLines].lineNum = lineNum; + cmdLine[numOfLines].optionOffset = optionOffset; + expLen = (int32_t)strlen(rest); + memcpy(optionBuffer + optionOffset, rest, expLen); + optionOffset += expLen + 1; + *(optionBuffer + optionOffset - 1) = 0; + + numOfLines++; + return true; +} + +bool simParseSqlErrorCmd(char *rest, SCommand *pCmd, int32_t lineNum) { + int32_t expLen; + + rest++; + cmdLine[numOfLines].cmdno = SIM_CMD_SQL_ERROR; + cmdLine[numOfLines].lineNum = lineNum; + cmdLine[numOfLines].optionOffset = optionOffset; + expLen = (int32_t)strlen(rest); + memcpy(optionBuffer + optionOffset, rest, expLen); + optionOffset += expLen + 1; + *(optionBuffer + optionOffset - 1) = 0; + + numOfLines++; + return true; +} + +bool simParseSqlSlowCmd(char *rest, SCommand *pCmd, int32_t lineNum) { + simParseSqlCmd(rest, pCmd, lineNum); + cmdLine[numOfLines - 1].cmdno = SIM_CMD_SQL_SLOW; + return true; +} + +bool simParseRestfulCmd(char *rest, SCommand *pCmd, int32_t lineNum) { + simParseSqlCmd(rest, pCmd, lineNum); + cmdLine[numOfLines - 1].cmdno = SIM_CMD_RESTFUL; + return true; +} + +bool simParseSystemCmd(char *rest, SCommand *pCmd, int32_t lineNum) { + int32_t expLen; + + rest++; + cmdLine[numOfLines].cmdno = SIM_CMD_SYSTEM; + cmdLine[numOfLines].lineNum = lineNum; + cmdLine[numOfLines].optionOffset = optionOffset; + expLen = (int32_t)strlen(rest); + memcpy(optionBuffer + optionOffset, rest, expLen); + optionOffset += expLen + 1; + *(optionBuffer + optionOffset - 1) = 0; + + numOfLines++; + return true; +} + +bool simParseSystemContentCmd(char *rest, SCommand *pCmd, int32_t lineNum) { + simParseSystemCmd(rest, pCmd, lineNum); + cmdLine[numOfLines - 1].cmdno = SIM_CMD_SYSTEM_CONTENT; + return true; +} + +bool simParseSleepCmd(char *rest, SCommand *pCmd, int32_t lineNum) { + char * token; + int32_t tokenLen; + + cmdLine[numOfLines].cmdno = SIM_CMD_SLEEP; + cmdLine[numOfLines].lineNum = lineNum; + + paGetToken(rest, &token, &tokenLen); + if (tokenLen > 0) { + cmdLine[numOfLines].optionOffset = optionOffset; + memcpy(optionBuffer + optionOffset, token, tokenLen); + optionOffset += tokenLen + 1; + *(optionBuffer + optionOffset - 1) = 0; + } + + numOfLines++; + return true; +} + +bool simParseReturnCmd(char *rest, SCommand *pCmd, int32_t lineNum) { + char * token; + int32_t tokenLen; + + cmdLine[numOfLines].cmdno = SIM_CMD_RETURN; + cmdLine[numOfLines].lineNum = lineNum; + + paGetToken(rest, &token, &tokenLen); + if (tokenLen > 0) { + cmdLine[numOfLines].optionOffset = optionOffset; + memcpy(optionBuffer + optionOffset, token, tokenLen); + optionOffset += tokenLen + 1; + *(optionBuffer + optionOffset - 1) = 0; + } + + numOfLines++; + return true; +} + +bool simParseGotoCmd(char *rest, SCommand *pCmd, int32_t lineNum) { + char * token; + int32_t tokenLen; + + rest = paGetToken(rest, &token, &tokenLen); + + if (tokenLen == 0) { + sprintf(parseErr, "label should be followed by goto cmd"); + return false; + } + + memcpy(dest.label[(uint8_t)dest.top], token, tokenLen); + dest.label[(uint8_t)dest.top][tokenLen] = 0; + dest.pos[(uint8_t)dest.top] = numOfLines; + dest.top++; + + cmdLine[numOfLines].cmdno = SIM_CMD_GOTO; + cmdLine[numOfLines].lineNum = lineNum; + + numOfLines++; + return true; +} + +bool simParseRunCmd(char *rest, SCommand *pCmd, int32_t lineNum) { + char * token; + int32_t tokenLen; + + rest = paGetToken(rest, &token, &tokenLen); + + if (tokenLen == 0) { + sprintf(parseErr, "file name should be followed by run cmd"); + return false; + } + + cmdLine[numOfLines].cmdno = SIM_CMD_RUN; + cmdLine[numOfLines].lineNum = lineNum; + cmdLine[numOfLines].optionOffset = optionOffset; + memcpy(optionBuffer + optionOffset, token, tokenLen); + optionOffset += tokenLen + 1; + *(optionBuffer + optionOffset - 1) = 0; + + numOfLines++; + return true; +} + +bool simParseRunBackCmd(char *rest, SCommand *pCmd, int32_t lineNum) { + simParseRunCmd(rest, pCmd, lineNum); + cmdLine[numOfLines - 1].cmdno = SIM_CMD_RUN_BACK; + return true; +} + +bool simParseLineInsertCmd(char* rest, SCommand* pCmd, int32_t lineNum) { + int32_t expLen; + + rest++; + cmdLine[numOfLines].cmdno = SIM_CMD_LINE_INSERT; + cmdLine[numOfLines].lineNum = lineNum; + cmdLine[numOfLines].optionOffset = optionOffset; + expLen = (int32_t)strlen(rest); + memcpy(optionBuffer + optionOffset, rest, expLen); + optionOffset += expLen + 1; + *(optionBuffer + optionOffset - 1) = 0; + + numOfLines++; + return true; +} + +bool simParseLineInsertErrorCmd(char* rest, SCommand* pCmd, int32_t lineNum) { + int32_t expLen; + + rest++; + cmdLine[numOfLines].cmdno = SIM_CMD_LINE_INSERT; + cmdLine[numOfLines].lineNum = lineNum; + cmdLine[numOfLines].optionOffset = optionOffset; + expLen = (int32_t)strlen(rest); + memcpy(optionBuffer + optionOffset, rest, expLen); + optionOffset += expLen + 1; + *(optionBuffer + optionOffset - 1) = 0; + + numOfLines++; + return true; +} + +void simInitsimCmdList() { + int32_t cmdno; + memset(simCmdList, 0, SIM_CMD_END * sizeof(SCommand)); + + /* internal command */ + cmdno = SIM_CMD_EXP; + simCmdList[cmdno].cmdno = cmdno; + strcpy(simCmdList[cmdno].name, "exp"); + simCmdList[cmdno].nlen = (int16_t)strlen(simCmdList[cmdno].name); + simCmdList[cmdno].parseCmd = NULL; + simCmdList[cmdno].executeCmd = simExecuteExpCmd; + + cmdno = SIM_CMD_IF; + simCmdList[cmdno].cmdno = cmdno; + strcpy(simCmdList[cmdno].name, "if"); + simCmdList[cmdno].nlen = (int16_t)strlen(simCmdList[cmdno].name); + simCmdList[cmdno].parseCmd = simParseIfCmd; + simCmdList[cmdno].executeCmd = NULL; + simAddCmdIntoHash(&(simCmdList[cmdno])); + + cmdno = SIM_CMD_ELIF; + simCmdList[cmdno].cmdno = cmdno; + strcpy(simCmdList[cmdno].name, "elif"); + simCmdList[cmdno].nlen = (int16_t)strlen(simCmdList[cmdno].name); + simCmdList[cmdno].parseCmd = simParseElifCmd; + simCmdList[cmdno].executeCmd = NULL; + simAddCmdIntoHash(&(simCmdList[cmdno])); + + cmdno = SIM_CMD_ELSE; + simCmdList[cmdno].cmdno = cmdno; + strcpy(simCmdList[cmdno].name, "else"); + simCmdList[cmdno].nlen = (int16_t)strlen(simCmdList[cmdno].name); + simCmdList[cmdno].parseCmd = simParseElseCmd; + simCmdList[cmdno].executeCmd = NULL; + simAddCmdIntoHash(&(simCmdList[cmdno])); + + cmdno = SIM_CMD_ENDI; + simCmdList[cmdno].cmdno = cmdno; + strcpy(simCmdList[cmdno].name, "endi"); + simCmdList[cmdno].nlen = (int16_t)strlen(simCmdList[cmdno].name); + simCmdList[cmdno].parseCmd = simParseEndiCmd; + simCmdList[cmdno].executeCmd = NULL; + simAddCmdIntoHash(&(simCmdList[cmdno])); + + cmdno = SIM_CMD_WHILE; + simCmdList[cmdno].cmdno = cmdno; + strcpy(simCmdList[cmdno].name, "while"); + simCmdList[cmdno].nlen = (int16_t)strlen(simCmdList[cmdno].name); + simCmdList[cmdno].parseCmd = simParseWhileCmd; + simCmdList[cmdno].executeCmd = NULL; + simAddCmdIntoHash(&(simCmdList[cmdno])); + + cmdno = SIM_CMD_ENDW; + simCmdList[cmdno].cmdno = cmdno; + strcpy(simCmdList[cmdno].name, "endw"); + simCmdList[cmdno].nlen = (int16_t)strlen(simCmdList[cmdno].name); + simCmdList[cmdno].parseCmd = simParseEndwCmd; + simCmdList[cmdno].executeCmd = NULL; + simAddCmdIntoHash(&(simCmdList[cmdno])); + + cmdno = SIM_CMD_SWITCH; + simCmdList[cmdno].cmdno = cmdno; + strcpy(simCmdList[cmdno].name, "switch"); + simCmdList[cmdno].nlen = (int16_t)strlen(simCmdList[cmdno].name); + simCmdList[cmdno].parseCmd = simParseSwitchCmd; + simCmdList[cmdno].executeCmd = NULL; + simAddCmdIntoHash(&(simCmdList[cmdno])); + + cmdno = SIM_CMD_CASE; + simCmdList[cmdno].cmdno = cmdno; + strcpy(simCmdList[cmdno].name, "case"); + simCmdList[cmdno].nlen = (int16_t)strlen(simCmdList[cmdno].name); + simCmdList[cmdno].parseCmd = simParseCaseCmd; + simCmdList[cmdno].executeCmd = NULL; + simAddCmdIntoHash(&(simCmdList[cmdno])); + + cmdno = SIM_CMD_DEFAULT; + simCmdList[cmdno].cmdno = cmdno; + strcpy(simCmdList[cmdno].name, "default"); + simCmdList[cmdno].nlen = (int16_t)strlen(simCmdList[cmdno].name); + simCmdList[cmdno].parseCmd = simParseDefaultCmd; + simCmdList[cmdno].executeCmd = NULL; + simAddCmdIntoHash(&(simCmdList[cmdno])); + + cmdno = SIM_CMD_BREAK; + simCmdList[cmdno].cmdno = cmdno; + strcpy(simCmdList[cmdno].name, "break"); + simCmdList[cmdno].nlen = (int16_t)strlen(simCmdList[cmdno].name); + simCmdList[cmdno].parseCmd = simParseBreakCmd; + simCmdList[cmdno].executeCmd = NULL; + simAddCmdIntoHash(&(simCmdList[cmdno])); + + cmdno = SIM_CMD_CONTINUE; + simCmdList[cmdno].cmdno = cmdno; + strcpy(simCmdList[cmdno].name, "continue"); + simCmdList[cmdno].nlen = (int16_t)strlen(simCmdList[cmdno].name); + simCmdList[cmdno].parseCmd = simParseContinueCmd; + simCmdList[cmdno].executeCmd = NULL; + simAddCmdIntoHash(&(simCmdList[cmdno])); + + cmdno = SIM_CMD_ENDS; + simCmdList[cmdno].cmdno = cmdno; + strcpy(simCmdList[cmdno].name, "ends"); + simCmdList[cmdno].nlen = (int16_t)strlen(simCmdList[cmdno].name); + simCmdList[cmdno].parseCmd = simParseEndsCmd; + simCmdList[cmdno].executeCmd = NULL; + simAddCmdIntoHash(&(simCmdList[cmdno])); + + cmdno = SIM_CMD_SLEEP; + simCmdList[cmdno].cmdno = cmdno; + strcpy(simCmdList[cmdno].name, "sleep"); + simCmdList[cmdno].nlen = (int16_t)strlen(simCmdList[cmdno].name); + simCmdList[cmdno].parseCmd = simParseSleepCmd; + simCmdList[cmdno].executeCmd = simExecuteSleepCmd; + simAddCmdIntoHash(&(simCmdList[cmdno])); + + cmdno = SIM_CMD_GOTO; + simCmdList[cmdno].cmdno = cmdno; + strcpy(simCmdList[cmdno].name, "goto"); + simCmdList[cmdno].nlen = (int16_t)strlen(simCmdList[cmdno].name); + simCmdList[cmdno].parseCmd = simParseGotoCmd; + simCmdList[cmdno].executeCmd = simExecuteGotoCmd; + simAddCmdIntoHash(&(simCmdList[cmdno])); + + cmdno = SIM_CMD_RUN; + simCmdList[cmdno].cmdno = cmdno; + strcpy(simCmdList[cmdno].name, "run"); + simCmdList[cmdno].nlen = (int16_t)strlen(simCmdList[cmdno].name); + simCmdList[cmdno].parseCmd = simParseRunCmd; + simCmdList[cmdno].executeCmd = simExecuteRunCmd; + simAddCmdIntoHash(&(simCmdList[cmdno])); + + cmdno = SIM_CMD_RUN_BACK; + simCmdList[cmdno].cmdno = cmdno; + strcpy(simCmdList[cmdno].name, "run_back"); + simCmdList[cmdno].nlen = (int16_t)strlen(simCmdList[cmdno].name); + simCmdList[cmdno].parseCmd = simParseRunBackCmd; + simCmdList[cmdno].executeCmd = simExecuteRunBackCmd; + simAddCmdIntoHash(&(simCmdList[cmdno])); + + cmdno = SIM_CMD_SYSTEM; + simCmdList[cmdno].cmdno = cmdno; + strcpy(simCmdList[cmdno].name, "system"); + simCmdList[cmdno].nlen = (int16_t)strlen(simCmdList[cmdno].name); + simCmdList[cmdno].parseCmd = simParseSystemCmd; + simCmdList[cmdno].executeCmd = simExecuteSystemCmd; + simAddCmdIntoHash(&(simCmdList[cmdno])); + + cmdno = SIM_CMD_SYSTEM_CONTENT; + simCmdList[cmdno].cmdno = cmdno; + strcpy(simCmdList[cmdno].name, "system_content"); + simCmdList[cmdno].nlen = (int16_t)strlen(simCmdList[cmdno].name); + simCmdList[cmdno].parseCmd = simParseSystemContentCmd; + simCmdList[cmdno].executeCmd = simExecuteSystemContentCmd; + simAddCmdIntoHash(&(simCmdList[cmdno])); + + cmdno = SIM_CMD_PRINT; + simCmdList[cmdno].cmdno = cmdno; + strcpy(simCmdList[cmdno].name, "print"); + simCmdList[cmdno].nlen = (int16_t)strlen(simCmdList[cmdno].name); + simCmdList[cmdno].parseCmd = simParsePrintCmd; + simCmdList[cmdno].executeCmd = simExecutePrintCmd; + simAddCmdIntoHash(&(simCmdList[cmdno])); + + cmdno = SIM_CMD_SQL; + simCmdList[cmdno].cmdno = cmdno; + strcpy(simCmdList[cmdno].name, "sql"); + simCmdList[cmdno].nlen = (int16_t)strlen(simCmdList[cmdno].name); + simCmdList[cmdno].parseCmd = simParseSqlCmd; + simCmdList[cmdno].executeCmd = simExecuteSqlCmd; + simAddCmdIntoHash(&(simCmdList[cmdno])); + + cmdno = SIM_CMD_SQL_ERROR; + simCmdList[cmdno].cmdno = cmdno; + strcpy(simCmdList[cmdno].name, "sql_error"); + simCmdList[cmdno].nlen = (int16_t)strlen(simCmdList[cmdno].name); + simCmdList[cmdno].parseCmd = simParseSqlErrorCmd; + simCmdList[cmdno].executeCmd = simExecuteSqlErrorCmd; + simAddCmdIntoHash(&(simCmdList[cmdno])); + + cmdno = SIM_CMD_SQL_SLOW; + simCmdList[cmdno].cmdno = cmdno; + strcpy(simCmdList[cmdno].name, "sql_slow"); + simCmdList[cmdno].nlen = (int16_t)strlen(simCmdList[cmdno].name); + simCmdList[cmdno].parseCmd = simParseSqlSlowCmd; + simCmdList[cmdno].executeCmd = simExecuteSqlSlowCmd; + simAddCmdIntoHash(&(simCmdList[cmdno])); + + cmdno = SIM_CMD_RESTFUL; + simCmdList[cmdno].cmdno = cmdno; + strcpy(simCmdList[cmdno].name, "restful"); + simCmdList[cmdno].nlen = (int16_t)strlen(simCmdList[cmdno].name); + simCmdList[cmdno].parseCmd = simParseRestfulCmd; + simCmdList[cmdno].executeCmd = simExecuteRestfulCmd; + simAddCmdIntoHash(&(simCmdList[cmdno])); + + /* test is only an internal command */ + cmdno = SIM_CMD_TEST; + simCmdList[cmdno].cmdno = cmdno; + strcpy(simCmdList[cmdno].name, "test"); + simCmdList[cmdno].nlen = (int16_t)strlen(simCmdList[cmdno].name); + simCmdList[cmdno].parseCmd = NULL; + simCmdList[cmdno].executeCmd = simExecuteTestCmd; + + cmdno = SIM_CMD_RETURN; + simCmdList[cmdno].cmdno = cmdno; + strcpy(simCmdList[cmdno].name, "return"); + simCmdList[cmdno].nlen = (int16_t)strlen(simCmdList[cmdno].name); + simCmdList[cmdno].parseCmd = simParseReturnCmd; + simCmdList[cmdno].executeCmd = simExecuteReturnCmd; + simAddCmdIntoHash(&(simCmdList[cmdno])); + + cmdno = SIM_CMD_LINE_INSERT; + simCmdList[cmdno].cmdno = cmdno; + strcpy(simCmdList[cmdno].name, "line_insert"); + simCmdList[cmdno].nlen = (int16_t)strlen(simCmdList[cmdno].name); + simCmdList[cmdno].parseCmd = simParseLineInsertCmd; + simCmdList[cmdno].executeCmd = simExecuteLineInsertCmd; + simAddCmdIntoHash(&(simCmdList[cmdno])); + + cmdno = SIM_CMD_LINE_INSERT_ERROR; + simCmdList[cmdno].cmdno = cmdno; + strcpy(simCmdList[cmdno].name, "line_insert_error"); + simCmdList[cmdno].nlen = (int16_t)strlen(simCmdList[cmdno].name); + simCmdList[cmdno].parseCmd = simParseLineInsertErrorCmd; + simCmdList[cmdno].executeCmd = simExecuteLineInsertErrorCmd; + simAddCmdIntoHash(&(simCmdList[cmdno])); +} diff --git a/tests/tsim/src/simSystem.c b/tests/tsim/src/simSystem.c new file mode 100644 index 0000000000000000000000000000000000000000..1ee7d94b915e6db3881f359b6f14565ddc55f450 --- /dev/null +++ b/tests/tsim/src/simSystem.c @@ -0,0 +1,187 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#define _DEFAULT_SOURCE +#include "os.h" +#include "sim.h" +#include "taos.h" +#include "tglobal.h" +#include "ttimer.h" +#include "tutil.h" +#include "tsocket.h" +#include "taoserror.h" +#undef TAOS_MEM_CHECK + +SScript *simScriptList[MAX_MAIN_SCRIPT_NUM]; +SCommand simCmdList[SIM_CMD_END]; +int32_t simScriptPos = -1; +int32_t simScriptSucced = 0; +int32_t simDebugFlag = 135; +void simCloseTaosdConnect(SScript *script); +char simHostName[128]; + +extern bool simExecSuccess; + +char *simParseArbitratorName(char *varName) { + static char hostName[140]; + sprintf(hostName, "%s:%d", simHostName, 8000); + return hostName; +} + +char *simParseHostName(char *varName) { + static char hostName[140]; + + int32_t sim_index = atoi(varName + 8); + int32_t port = 7100; + switch (sim_index) { + case 1: + port = 7100; + break; + case 2: + port = 7200; + break; + case 3: + port = 7300; + break; + case 4: + port = 7400; + break; + case 5: + port = 7500; + break; + case 6: + port = 7600; + break; + case 7: + port = 7700; + break; + case 8: + port = 7800; + break; + case 9: + port = 7900; + break; + } + + sprintf(hostName, "'%s:%d'", simHostName, port); + // simInfo("hostName:%s", hostName); + return hostName; +} + +bool simSystemInit() { + if (taos_init()) { + return false; + } + taosGetFqdn(simHostName); + simInitsimCmdList(); + memset(simScriptList, 0, sizeof(SScript *) * MAX_MAIN_SCRIPT_NUM); + return true; +} + +void simSystemCleanUp() {} + +void simFreeScript(SScript *script) { + if (script->type == SIM_SCRIPT_TYPE_MAIN) { + simInfo("script:%s, background script num:%d, stop them", script->fileName, script->bgScriptLen); + + for (int32_t i = 0; i < script->bgScriptLen; ++i) { + SScript *bgScript = script->bgScripts[i]; + simDebug("script:%s, is background script, set stop flag", bgScript->fileName); + bgScript->killed = true; + if (taosCheckPthreadValid(bgScript->bgPid)) { + pthread_join(bgScript->bgPid, NULL); + } + + simDebug("script:%s, background thread joined", bgScript->fileName); + taos_close(bgScript->taos); + tfree(bgScript->lines); + tfree(bgScript->optionBuffer); + tfree(bgScript); + } + + simDebug("script:%s, is cleaned", script->fileName); + taos_close(script->taos); + tfree(script->lines); + tfree(script->optionBuffer); + tfree(script); + } +} + +SScript *simProcessCallOver(SScript *script) { + if (script->type == SIM_SCRIPT_TYPE_MAIN) { + simDebug("script:%s, is main script, set stop flag", script->fileName); + if (script->killed) { + simExecSuccess = false; + simInfo("script:" FAILED_PREFIX "%s" FAILED_POSTFIX ", " FAILED_PREFIX "failed" FAILED_POSTFIX ", error:%s", + script->fileName, script->error); + return NULL; + } else { + simExecSuccess = true; + simInfo("script:" SUCCESS_PREFIX "%s" SUCCESS_POSTFIX ", " SUCCESS_PREFIX "success" SUCCESS_POSTFIX, + script->fileName); + simCloseTaosdConnect(script); + simScriptSucced++; + simScriptPos--; + + simFreeScript(script); + if (simScriptPos == -1) { + simInfo("----------------------------------------------------------------------"); + simInfo("Simulation Test Done, " SUCCESS_PREFIX "%d" SUCCESS_POSTFIX " Passed:\n", simScriptSucced); + return NULL; + } + + return simScriptList[simScriptPos]; + } + } else { + simDebug("script:%s, is stopped", script->fileName); + simFreeScript(script); + return NULL; + } +} + +void *simExecuteScript(void *inputScript) { + SScript *script = (SScript *)inputScript; + + while (1) { + if (script->type == SIM_SCRIPT_TYPE_MAIN) { + script = simScriptList[simScriptPos]; + } + + if (abortExecution) { + script->killed = true; + } + + if (script->killed || script->linePos >= script->numOfLines) { + script = simProcessCallOver(script); + if (script == NULL) { + simDebug("sim test abort now!"); + break; + } + } else { + SCmdLine *line = &script->lines[script->linePos]; + char * option = script->optionBuffer + line->optionOffset; + simDebug("script:%s, line:%d with option \"%s\"", script->fileName, line->lineNum, option); + + SCommand *cmd = &simCmdList[line->cmdno]; + int32_t ret = (*(cmd->executeCmd))(script, option); + if (!ret) { + script->killed = true; + } + } + } + + simInfo("thread is stopped"); + return NULL; +}